From 7b62cf4af82180af5dc6c327989f93c68109b41d Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 2 Mar 2015 21:02:59 +1100 Subject: [PATCH 01/22] Added in vera api submodule --- .gitmodules | 3 +++ homeassistant/external/vera | 1 + 2 files changed, 4 insertions(+) create mode 160000 homeassistant/external/vera diff --git a/.gitmodules b/.gitmodules index 6e49e76698a..2e43a7d4dd0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "homeassistant/components/frontend/www_static/polymer/home-assistant-js"] path = homeassistant/components/frontend/www_static/polymer/home-assistant-js url = https://github.com/balloob/home-assistant-js.git +[submodule "homeassistant/external/vera"] + path = homeassistant/external/vera + url = https://github.com/jamespcole/home-assistant-vera-api.git diff --git a/homeassistant/external/vera b/homeassistant/external/vera new file mode 160000 index 00000000000..fedbb5c3af1 --- /dev/null +++ b/homeassistant/external/vera @@ -0,0 +1 @@ +Subproject commit fedbb5c3af1e5f36b7008d894e9fc1ecf3cc2ea8 From 3449b3d1d75ab3c6fc6a38360b464f857256522e Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 2 Mar 2015 21:09:00 +1100 Subject: [PATCH 02/22] vera device types --- homeassistant/components/light/vera.py | 134 ++++++++++++++++++++++++ homeassistant/components/sensor/vera.py | 126 ++++++++++++++++++++++ homeassistant/components/switch/vera.py | 127 ++++++++++++++++++++++ 3 files changed, 387 insertions(+) create mode 100644 homeassistant/components/light/vera.py create mode 100644 homeassistant/components/sensor/vera.py create mode 100644 homeassistant/components/switch/vera.py diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py new file mode 100644 index 00000000000..be16aeba4b7 --- /dev/null +++ b/homeassistant/components/light/vera.py @@ -0,0 +1,134 @@ +""" Support for Vera lights. """ +import logging +import requests +import time +import json + +from homeassistant.helpers import ToggleDevice +import config.custom_components.external.vera as veraApi + +_LOGGER = logging.getLogger('Vera_Light') + + +def setup_platform(hass, config, add_devices_callback, discovery_info=None): + """ Find and return Vera lights. """ + try: + base_url = config.get('vera_controller_url') + if not base_url: + _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") + return False + + device_data_str = config.get('device_data') + device_data = None + if device_data_str: + try: + device_data = json.loads(device_data_str) + except Exception as json_ex: + _LOGGER.error('Vera lights error parsing device info, should be in the format [{"id" : 12, "name": "Lounge Light"}]: %s', json_ex) + + controller = veraApi.VeraController(base_url) + devices = controller.get_devices('Switch') + + lights = [] + for device in devices: + if is_switch_a_light(device_data, device.deviceId): + lights.append(VeraLight(device, get_extra_device_data(device_data, device.deviceId))) + + add_devices_callback(lights) + except Exception as inst: + _LOGGER.error("Could not find Vera lights: %s", inst) + return False + +# If you have z-wave switches that control lights you can configure them +# to be treated as lights using the "device_data" parameter in the config. +# If "device_data" is not set then all switches are treated as lights +def is_switch_a_light(device_data, device_id): + if not device_data: + return True + + for item in device_data: + if item.get('id') == device_id: + return True + + return False + +def get_extra_device_data(device_data, device_id): + if not device_data: + return None + + for item in device_data: + if item.get('id') == device_id: + return item + + return None + + +class VeraLight(ToggleDevice): + """ Represents a Vera light """ + is_on_status = False + #for debouncing status check after command is sent + last_command_send = 0 + extra_data = None + + def __init__(self, vera_device, extra_data=None): + self.vera_device = vera_device + self.extra_data = extra_data + + @property + def unique_id(self): + """ Returns the id of this light """ + return "{}.{}".format( + self.__class__, self.info.get('uniqueid', 'vera-' + self.vera_device.deviceId)) + + @property + def name(self): + """ Get the mame of the light. """ + if self.extra_data and self.extra_data.get('name'): + return self.extra_data.get('name') + return self.vera_device.name + + @property + def state_attributes(self): + attr = super().state_attributes + + if self.vera_device.has_battery: + attr['Battery'] = self.vera_device.battery_level + '%' + + if self.vera_device.is_armable: + armed = self.vera_device.refresh_value('Armed') + attr['Armed'] = 'True' if armed == '1' else 'False' + + if self.vera_device.is_trippable: + lastTripped = self.vera_device.refresh_value('LastTrip') + tripTimeStr = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(lastTripped))) + attr['Last Tripped'] = tripTimeStr + + tripped = self.vera_device.refresh_value('Tripped') + attr['Tripped'] = 'True' if tripped == '1' else 'False' + + attr['Vera Device Id'] = self.vera_device.vera_device_id + + return attr + + def turn_on(self, **kwargs): + self.last_command_send = time.time() + self.vera_device.switch_on() + self.is_on_status = True + + def turn_off(self, **kwargs): + self.last_command_send = time.time() + self.vera_device.switch_off() + self.is_on_status = False + + @property + def is_on(self): + """ True if device is on. """ + self.update() + return self.is_on_status + + def update(self): + # We need to debounce the status call after turning light on or off + # because the vera has some lag in updating the device status + if (self.last_command_send + 5) < time.time(): + self.is_on_status = self.vera_device.is_switched_on() + \ No newline at end of file diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py new file mode 100644 index 00000000000..da75361724d --- /dev/null +++ b/homeassistant/components/sensor/vera.py @@ -0,0 +1,126 @@ +""" Support for Vera lights. """ +import logging +import requests +import time +import json + +from homeassistant.helpers import Device +import config.custom_components.external.vera as veraApi +from homeassistant.const import (STATE_OPEN, STATE_CLOSED, ATTR_FRIENDLY_NAME) + +_LOGGER = logging.getLogger('Vera_Sensor') + +vera_controller = None +vera_sensors = [] + +def get_devices(hass, config): + """ Find and return Vera Sensors. """ + try: + base_url = config.get('vera_controller_url') + if not base_url: + _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") + #return False + + device_data_str = config.get('device_data') + device_data = None + if device_data_str: + try: + device_data = json.loads(device_data_str) + except Exception as json_ex: + _LOGGER.error('Vera sensors error parsing device info, should be in the format [{"id" : 12, "name": "Temperature"}]: %s', json_ex) + + vera_controller = veraApi.VeraController(base_url) + devices = vera_controller.get_devices(['Temperature Sensor', 'Light Sensor', 'Sensor']) + + vera_sensors = [] + for device in devices: + vera_sensors.append(VeraSensor(device, get_extra_device_data(device_data, device.deviceId))) + + except Exception as inst: + _LOGGER.error("Could not find Vera sensors: %s", inst) + + return vera_sensors + +def get_extra_device_data(device_data, device_id): + if not device_data: + return None + + for item in device_data: + if item.get('id') == device_id: + return item + return None + + +def get_sensors(): + return vera_sensors + + +class VeraSensor(Device): + """ Represents a Vera Sensor """ + extra_data = None + current_value = '' + + def __init__(self, vera_device, extra_data=None): + self.vera_device = vera_device + self.extra_data = extra_data + + def __str__(self): + return "%s %s %s" % (self.name(), self.deviceId(), self.state()) + + @property + def state(self): + return self.current_value + + def updateState(self): + return self.state() + + @property + def unique_id(self): + """ Returns the id of this switch """ + return "{}.{}".format( + self.__class__, self.info.get('uniqueid', 'vera-sensor-' + self.vera_device.deviceId)) + + @property + def name(self): + """ Get the mame of the switch. """ + if self.extra_data and self.extra_data.get('name'): + return self.extra_data.get('name') + return self.vera_device.name + + @property + def state_attributes(self): + attr = super().state_attributes + + if self.vera_device.has_battery: + attr['Battery'] = self.vera_device.battery_level + '%' + + if self.vera_device.is_armable: + armed = self.vera_device.refresh_value('Armed') + attr['Armed'] = 'True' if armed == '1' else 'False' + + if self.vera_device.is_trippable: + lastTripped = self.vera_device.refresh_value('LastTrip') + tripTimeStr = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(lastTripped))) + attr['Last Tripped'] = tripTimeStr + + tripped = self.vera_device.refresh_value('Tripped') + attr['Tripped'] = 'True' if tripped == '1' else 'False' + + attr['Vera Device Id'] = self.vera_device.vera_device_id + + return attr + + + def update(self): + if self.vera_device.category == "Temperature Sensor": + self.vera_device.refresh_value('CurrentTemperature') + self.current_value = self.vera_device.get_value('CurrentTemperature') + '°' + self.vera_device.veraController.temperature_units + elif self.vera_device.category == "Light Sensor": + self.vera_device.refresh_value('CurrentLevel') + self.current_value = self.vera_device.get_value('CurrentLevel') + elif self.vera_device.category == "Sensor": + tripped = self.vera_device.refresh_value('Tripped') + self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped' + else: + self.current_value = 'Unknown' + \ No newline at end of file diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py new file mode 100644 index 00000000000..ccbb593e68c --- /dev/null +++ b/homeassistant/components/switch/vera.py @@ -0,0 +1,127 @@ +""" Support for Vera lights. """ +import logging +import requests +import time +import json + +from homeassistant.helpers import ToggleDevice +import config.custom_components.external.vera as veraApi + +_LOGGER = logging.getLogger('Vera_Switch') + +vera_controller = None +vera_switches = [] + +def get_devices(hass, config): + """ Find and return Vera switches. """ + try: + base_url = config.get('vera_controller_url') + if not base_url: + _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") + return False + + device_data_str = config.get('device_data') + device_data = None + if device_data_str: + try: + device_data = json.loads(device_data_str) + except Exception as json_ex: + _LOGGER.error('Vera switch error parsing device info, should be in the format [{"id" : 12, "name": "Lounge Light"}]: %s', json_ex) + + vera_controller = veraApi.VeraController(base_url) + devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) + + vera_switches = [] + for device in devices: + vera_switches.append(VeraSwitch(device, get_extra_device_data(device_data, device.deviceId))) + + except Exception as inst: + _LOGGER.error("Could not find Vera switches: %s", inst) + return False + + return vera_switches + +def get_extra_device_data(device_data, device_id): + if not device_data: + return None + + for item in device_data: + if item.get('id') == device_id: + return item + return None + + +def get_switches(): + return vera_switches + + +class VeraSwitch(ToggleDevice): + """ Represents a Vera Switch """ + is_on_status = False + #for debouncing status check after command is sent + last_command_send = 0 + extra_data = None + + def __init__(self, vera_device, extra_data=None): + self.vera_device = vera_device + self.extra_data = extra_data + + @property + def unique_id(self): + """ Returns the id of this switch """ + return "{}.{}".format( + self.__class__, self.info.get('uniqueid', 'vera-switch-' + self.vera_device.deviceId)) + + @property + def name(self): + """ Get the mame of the switch. """ + if self.extra_data and self.extra_data.get('name'): + return self.extra_data.get('name') + return self.vera_device.name + + @property + def state_attributes(self): + attr = super().state_attributes + + if self.vera_device.has_battery: + attr['Battery'] = self.vera_device.battery_level + '%' + + if self.vera_device.is_armable: + armed = self.vera_device.refresh_value('Armed') + attr['Armed'] = 'True' if armed == '1' else 'False' + + if self.vera_device.is_trippable: + lastTripped = self.vera_device.refresh_value('LastTrip') + tripTimeStr = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(lastTripped))) + attr['Last Tripped'] = tripTimeStr + + tripped = self.vera_device.refresh_value('Tripped') + attr['Tripped'] = 'True' if tripped == '1' else 'False' + + attr['Vera Device Id'] = self.vera_device.vera_device_id + + return attr + + def turn_on(self, **kwargs): + self.last_command_send = time.time() + self.vera_device.switch_on() + self.is_on_status = True + + def turn_off(self, **kwargs): + self.last_command_send = time.time() + self.vera_device.switch_off() + self.is_on_status = False + + + @property + def is_on(self): + """ True if device is on. """ + self.update() + return self.is_on_status + + def update(self): + # We need to debounce the status call after turning switch on or off + # because the vera has some lag in updating the device status + if (self.last_command_send + 5) < time.time(): + self.is_on_status = self.vera_device.is_switched_on() + \ No newline at end of file From 8dfc91a5027e51ae44fcdd4cf60da137cca7ada3 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 2 Mar 2015 22:05:03 +1100 Subject: [PATCH 03/22] Added vera components and added __pycache__ to gitignore --- .gitignore | 1 + config/home-assistant.conf.example | 25 +++++++++++++++++++++++++ homeassistant/components/light/vera.py | 4 ++-- homeassistant/components/sensor/vera.py | 4 ++-- homeassistant/components/switch/vera.py | 4 ++-- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a82763e1b6d..79bde7962fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ config/* !config/home-assistant.conf.default homeassistant/components/frontend/www_static/polymer/bower_components/* +__pycache__ # There is not a better solution afaik.. !config/custom_components diff --git a/config/home-assistant.conf.example b/config/home-assistant.conf.example index d71c3c0cc14..b55b91a6c55 100644 --- a/config/home-assistant.conf.example +++ b/config/home-assistant.conf.example @@ -27,6 +27,7 @@ password=PASSWORD # hosts=192.168.1.1/24 # netmask prefix notation or # hosts=192.168.1.1-255 # address range + [chromecast] [switch] @@ -97,3 +98,27 @@ time_seconds=0 execute_service=notify.notify service_data={"message":"It's 4, time for beer!"} + + +[light] +platform=vera +# The "device_data" field is not required but if you want a switch to show up as a light +# then add it in to here. If you leave out the "name" field the name configured in your +# Vera controller will be used instead. The "id" field should be the Vera id for the device. +device_data=[{"id" : 12, "name": "Lounge Light"}] +vera_controller_url=http://192.168.1.254:3480/ + +[switch] +platform=vera +# The "device_data" field is not required and if not specified all switches will still be added. +# You can use it to override the name specified in your Vera controller using the "name" variable. +# The "id" field should be the Vera id for the device. +device_data=[{"id" : 12, "name": "Lounge Light"}, {"id" : 3, "name": "Lounge Motion"}] +vera_controller_url=http://192.168.1.254:3480/ + +[sensor] +platform=vera +# The "device_data" field is not required and if not specified all sensors will still be added. +# You can use it to override the name specified in your Vera controller using the "name" variable. +device_data=[{"id" : 4, "name": "Lounge Temp"}, {"id" : 3, "name": "Lounge Motion"}, {"id" : 5, "name": "Light Level"}] +vera_controller_url=http://192.168.1.254:3480/ diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index be16aeba4b7..5e7bad29d56 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -5,7 +5,7 @@ import time import json from homeassistant.helpers import ToggleDevice -import config.custom_components.external.vera as veraApi +import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger('Vera_Light') @@ -78,7 +78,7 @@ class VeraLight(ToggleDevice): def unique_id(self): """ Returns the id of this light """ return "{}.{}".format( - self.__class__, self.info.get('uniqueid', 'vera-' + self.vera_device.deviceId)) + self.__class__, self.info.get('uniqueid', self.name)) @property def name(self): diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index da75361724d..57ae4266ca1 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -5,7 +5,7 @@ import time import json from homeassistant.helpers import Device -import config.custom_components.external.vera as veraApi +import homeassistant.external.vera.vera as veraApi from homeassistant.const import (STATE_OPEN, STATE_CLOSED, ATTR_FRIENDLY_NAME) _LOGGER = logging.getLogger('Vera_Sensor') @@ -78,7 +78,7 @@ class VeraSensor(Device): def unique_id(self): """ Returns the id of this switch """ return "{}.{}".format( - self.__class__, self.info.get('uniqueid', 'vera-sensor-' + self.vera_device.deviceId)) + self.__class__, self.info.get('uniqueid', self.name)) @property def name(self): diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index ccbb593e68c..8b5f38e324d 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -5,7 +5,7 @@ import time import json from homeassistant.helpers import ToggleDevice -import config.custom_components.external.vera as veraApi +import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger('Vera_Switch') @@ -70,7 +70,7 @@ class VeraSwitch(ToggleDevice): def unique_id(self): """ Returns the id of this switch """ return "{}.{}".format( - self.__class__, self.info.get('uniqueid', 'vera-switch-' + self.vera_device.deviceId)) + self.__class__, self.info.get('uniqueid', self.name)) @property def name(self): From 53de2ad86d570d45124daa8d78ed65282054bb68 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 2 Mar 2015 22:28:40 +1100 Subject: [PATCH 04/22] Added __pycache__ to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a82763e1b6d..bf10e8732a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ config/* !config/home-assistant.conf.default homeassistant/components/frontend/www_static/polymer/bower_components/* +__pycache__ # There is not a better solution afaik.. !config/custom_components @@ -62,4 +63,4 @@ nosetests.xml # Mr Developer .mr.developer.cfg .project -.pydevproject \ No newline at end of file +.pydevproject From 138eadedccceeb564addb742a9ac0cbf40157c6f Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 2 Mar 2015 23:08:05 +1100 Subject: [PATCH 05/22] undid unnecessary changes to gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 79bde7962fe..a82763e1b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ config/* !config/home-assistant.conf.default homeassistant/components/frontend/www_static/polymer/bower_components/* -__pycache__ # There is not a better solution afaik.. !config/custom_components From 5536f1621d0d2884e44cd8afbed2c7d053bda408 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sat, 7 Mar 2015 12:25:41 +1100 Subject: [PATCH 06/22] fixing issue with built files and upstream merge --- .../frontend/www_static/webcomponents.min.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/frontend/www_static/webcomponents.min.js b/homeassistant/components/frontend/www_static/webcomponents.min.js index 14a06b2ba24..474305f73fc 100644 --- a/homeassistant/components/frontend/www_static/webcomponents.min.js +++ b/homeassistant/components/frontend/www_static/webcomponents.min.js @@ -7,8 +7,8 @@ * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ -// @version 0.5.4 -window.WebComponents=window.WebComponents||{},function(e){var t=e.flags||{},n="webcomponents.js",r=document.querySelector('script[src*="'+n+'"]');if(!t.noOpts){if(location.search.slice(1).split("&").forEach(function(e){e=e.split("="),e[0]&&(t[e[0]]=e[1]||!0)}),r)for(var o,i=0;o=r.attributes[i];i++)"src"!==o.name&&(t[o.name]=o.value||!0);if(t.log){var a=t.log.split(",");t.log={},a.forEach(function(e){t.log[e]=!0})}else t.log={}}t.shadow=t.shadow||t.shadowdom||t.polyfill,t.shadow="native"===t.shadow?!1:t.shadow||!HTMLElement.prototype.createShadowRoot,t.register&&(window.CustomElements=window.CustomElements||{flags:{}},window.CustomElements.flags.register=t.register),e.flags=t}(WebComponents),WebComponents.flags.shadow&&("undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};n.prototype={set:function(t,n){var r=t[this.name];return r&&r[0]===t?r[1]=n:e(t,this.name,{value:[t,n],writable:!0}),this},get:function(e){var t;return(t=e[this.name])&&t[0]===e?t[1]:void 0},"delete":function(e){var t=e[this.name];return t&&t[0]===e?(t[0]=t[1]=void 0,!0):!1},has:function(e){var t=e[this.name];return t?t[0]===e:!1}},window.WeakMap=n}(),window.ShadowDOMPolyfill={},function(e){"use strict";function t(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;if(navigator.getDeviceStorage)return!1;try{var e=new Function("return true;");return e()}catch(t){return!1}}function n(e){if(!e)throw new Error("Assertion failed")}function r(e,t){for(var n=W(t),r=0;rl;l++)c[l]=new Array(s),c[l][0]=l;for(var u=0;s>u;u++)c[0][u]=u;for(var l=1;a>l;l++)for(var u=1;s>u;u++)if(this.equals(e[t+u-1],r[o+l-1]))c[l][u]=c[l-1][u-1];else{var d=c[l-1][u]+1,p=c[l][u-1]+1;c[l][u]=p>d?d:p}return c},spliceOperationsFromEditDistances:function(e){for(var t=e.length-1,n=e[0].length-1,s=e[t][n],c=[];t>0||n>0;)if(0!=t)if(0!=n){var l,u=e[t-1][n-1],d=e[t-1][n],p=e[t][n-1];l=p>d?u>d?d:u:u>p?p:u,l==u?(u==s?c.push(r):(c.push(o),s=u),t--,n--):l==d?(c.push(a),t--,s=d):(c.push(i),n--,s=p)}else c.push(a),t--;else c.push(i),n--;return c.reverse(),c},calcSplices:function(e,n,s,c,l,u){var d=0,p=0,f=Math.min(s-n,u-l);if(0==n&&0==l&&(d=this.sharedPrefix(e,c,f)),s==e.length&&u==c.length&&(p=this.sharedSuffix(e,c,f-d)),n+=d,l+=d,s-=p,u-=p,s-n==0&&u-l==0)return[];if(n==s){for(var h=t(n,[],0);u>l;)h.removed.push(c[l++]);return[h]}if(l==u)return[t(n,[],s-n)];for(var m=this.spliceOperationsFromEditDistances(this.calcEditDistances(e,n,s,c,l,u)),h=void 0,w=[],v=n,g=l,b=0;br;r++)if(!this.equals(e[r],t[r]))return r;return n},sharedSuffix:function(e,t,n){for(var r=e.length,o=t.length,i=0;n>i&&this.equals(e[--r],t[--o]);)i++;return i},calculateSplices:function(e,t){return this.calcSplices(e,0,e.length,t,0,t.length)},equals:function(e,t){return e===t}},e.ArraySplice=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(){a=!1;var e=i.slice(0);i=[];for(var t=0;t0){for(var u=0;u0&&r.length>0;){var i=n.pop(),a=r.pop();if(i!==a)break;o=i}return o}function u(e,t,n){t instanceof G.Window&&(t=t.document);var o,i=k(t),a=k(n),s=r(n,e),o=l(i,a);o||(o=a.root);for(var c=o;c;c=c.parent)for(var u=0;u0;i--)if(!g(t[i],e,o,t,r))return!1;return!0}function w(e,t,n,r){var o=it,i=t[0]||n;return g(i,e,o,t,r)}function v(e,t,n,r){for(var o=at,i=1;i0&&g(n,e,o,t,r)}function g(e,t,n,r,o){var i=z.get(e);if(!i)return!0;var a=o||s(r,e);if(a===e){if(n===ot)return!0;n===at&&(n=it)}else if(n===at&&!t.bubbles)return!0;if("relatedTarget"in t){var c=q(t),l=c.relatedTarget;if(l){if(l instanceof Object&&l.addEventListener){var d=V(l),p=u(t,e,d);if(p===a)return!0}else p=null;J.set(t,p)}}Z.set(t,n);var f=t.type,h=!1;X.set(t,a),$.set(t,e),i.depth++;for(var m=0,w=i.length;w>m;m++){var v=i[m];if(v.removed)h=!0;else if(!(v.type!==f||!v.capture&&n===ot||v.capture&&n===at))try{if("function"==typeof v.handler?v.handler.call(e,t):v.handler.handleEvent(t),et.get(t))return!1}catch(g){I||(I=g)}}if(i.depth--,h&&0===i.depth){var b=i.slice();i.length=0;for(var m=0;mr;r++)t[r]=a(e[r]);return t.length=o,t}function o(e,t){e.prototype[t]=function(){return r(i(this)[t].apply(i(this),arguments))}}var i=e.unsafeUnwrap,a=e.wrap,s={enumerable:!1};n.prototype={item:function(e){return this[e]}},t(n.prototype,"item"),e.wrappers.NodeList=n,e.addWrapNodeListMethod=o,e.wrapNodeList=r}(window.ShadowDOMPolyfill),function(e){"use strict";e.wrapHTMLCollection=e.wrapNodeList,e.wrappers.HTMLCollection=e.wrappers.NodeList}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){O(e instanceof S)}function n(e){var t=new M;return t[0]=e,t.length=1,t}function r(e,t,n){N(t,"childList",{removedNodes:n,previousSibling:e.previousSibling,nextSibling:e.nextSibling})}function o(e,t){N(e,"childList",{removedNodes:t})}function i(e,t,r,o){if(e instanceof DocumentFragment){var i=s(e);B=!0;for(var a=i.length-1;a>=0;a--)e.removeChild(i[a]),i[a].parentNode_=t;B=!1;for(var a=0;ao;o++)r.appendChild(I(t[o]));return r}function w(e){if(void 0!==e.firstChild_)for(var t=e.firstChild_;t;){var n=t;t=t.nextSibling_,n.parentNode_=n.previousSibling_=n.nextSibling_=void 0}e.firstChild_=e.lastChild_=void 0}function v(e){if(e.invalidateShadowRenderer()){for(var t=e.firstChild;t;){O(t.parentNode===e);var n=t.nextSibling,r=I(t),o=r.parentNode;o&&Y.call(o,r),t.previousSibling_=t.nextSibling_=t.parentNode_=null,t=n}e.firstChild_=e.lastChild_=null}else for(var n,i=I(e),a=i.firstChild;a;)n=a.nextSibling,Y.call(i,a),a=n}function g(e){var t=e.parentNode;return t&&t.invalidateShadowRenderer()}function b(e){for(var t,n=0;ns;s++)i=g(t[s]),!o&&(a=w(i).root)&&a instanceof e.wrappers.ShadowRoot||(r[n++]=i);return n}function n(e){return String(e).replace(/\/deep\//g," ")}function r(e,t){for(var n,o=e.firstElementChild;o;){if(o.matches(t))return o;if(n=r(o,t))return n;o=o.nextElementSibling}return null}function o(e,t){return e.matches(t)}function i(e,t,n){var r=e.localName;return r===t||r===n&&e.namespaceURI===C}function a(){return!0}function s(e,t,n){return e.localName===n}function c(e,t){return e.namespaceURI===t}function l(e,t,n){return e.namespaceURI===t&&e.localName===n}function u(e,t,n,r,o,i){for(var a=e.firstElementChild;a;)r(a,o,i)&&(n[t++]=a),t=u(a,t,n,r,o,i),a=a.nextElementSibling;return t}function d(n,r,o,i,a){var s,c=v(this),l=w(this).root;if(l instanceof e.wrappers.ShadowRoot)return u(this,r,o,n,i,null);if(c instanceof _)s=S.call(c,i);else{if(!(c instanceof N))return u(this,r,o,n,i,null);s=E.call(c,i)}return t(s,r,o,a)}function p(n,r,o,i,a){var s,c=v(this),l=w(this).root;if(l instanceof e.wrappers.ShadowRoot)return u(this,r,o,n,i,a);if(c instanceof _)s=M.call(c,i,a);else{if(!(c instanceof N))return u(this,r,o,n,i,a);s=T.call(c,i,a)}return t(s,r,o,!1)}function f(n,r,o,i,a){var s,c=v(this),l=w(this).root;if(l instanceof e.wrappers.ShadowRoot)return u(this,r,o,n,i,a);if(c instanceof _)s=O.call(c,i,a);else{if(!(c instanceof N))return u(this,r,o,n,i,a);s=L.call(c,i,a)}return t(s,r,o,!1)}var h=e.wrappers.HTMLCollection,m=e.wrappers.NodeList,w=e.getTreeScope,v=e.unsafeUnwrap,g=e.wrap,b=document.querySelector,y=document.documentElement.querySelector,E=document.querySelectorAll,S=document.documentElement.querySelectorAll,T=document.getElementsByTagName,M=document.documentElement.getElementsByTagName,L=document.getElementsByTagNameNS,O=document.documentElement.getElementsByTagNameNS,_=window.Element,N=window.HTMLDocument||window.Document,C="http://www.w3.org/1999/xhtml",D={querySelector:function(t){var o=n(t),i=o!==t;t=o;var a,s=v(this),c=w(this).root;if(c instanceof e.wrappers.ShadowRoot)return r(this,t);if(s instanceof _)a=g(y.call(s,t));else{if(!(s instanceof N))return r(this,t);a=g(b.call(s,t))}return a&&!i&&(c=w(a).root)&&c instanceof e.wrappers.ShadowRoot?r(this,t):a},querySelectorAll:function(e){var t=n(e),r=t!==e;e=t;var i=new m;return i.length=d.call(this,o,0,i,e,r),i}},j={getElementsByTagName:function(e){var t=new h,n="*"===e?a:i;return t.length=p.call(this,n,0,t,e,e.toLowerCase()),t},getElementsByClassName:function(e){return this.querySelectorAll("."+e)},getElementsByTagNameNS:function(e,t){var n=new h,r=null; -return r="*"===e?"*"===t?a:s:"*"===t?c:l,n.length=f.call(this,r,0,n,e||null,t),n}};e.GetElementsByInterface=j,e.SelectorsInterface=D}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.nextSibling;return e}function n(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.previousSibling;return e}var r=e.wrappers.NodeList,o={get firstElementChild(){return t(this.firstChild)},get lastElementChild(){return n(this.lastChild)},get childElementCount(){for(var e=0,t=this.firstElementChild;t;t=t.nextElementSibling)e++;return e},get children(){for(var e=new r,t=0,n=this.firstElementChild;n;n=n.nextElementSibling)e[t++]=n;return e.length=t,e},remove:function(){var e=this.parentNode;e&&e.removeChild(this)}},i={get nextElementSibling(){return t(this.nextSibling)},get previousElementSibling(){return n(this.previousSibling)}};e.ChildNodeInterface=i,e.ParentNodeInterface=o}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}var n=e.ChildNodeInterface,r=e.wrappers.Node,o=e.enqueueMutation,i=e.mixin,a=e.registerWrapper,s=e.unsafeUnwrap,c=window.CharacterData;t.prototype=Object.create(r.prototype),i(t.prototype,{get textContent(){return this.data},set textContent(e){this.data=e},get data(){return s(this).data},set data(e){var t=s(this).data;o(this,"characterData",{oldValue:t}),s(this).data=e}}),i(t.prototype,n),a(c,t,document.createTextNode("")),e.wrappers.CharacterData=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e>>>0}function n(e){r.call(this,e)}var r=e.wrappers.CharacterData,o=(e.enqueueMutation,e.mixin),i=e.registerWrapper,a=window.Text;n.prototype=Object.create(r.prototype),o(n.prototype,{splitText:function(e){e=t(e);var n=this.data;if(e>n.length)throw new Error("IndexSizeError");var r=n.slice(0,e),o=n.slice(e);this.data=r;var i=this.ownerDocument.createTextNode(o);return this.parentNode&&this.parentNode.insertBefore(i,this.nextSibling),i}}),i(a,n,document.createTextNode("")),e.wrappers.Text=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return i(e).getAttribute("class")}function n(e,t){a(e,"attributes",{name:"class",namespace:null,oldValue:t})}function r(t){e.invalidateRendererBasedOnAttribute(t,"class")}function o(e,o,i){var a=e.ownerElement_;if(null==a)return o.apply(e,i);var s=t(a),c=o.apply(e,i);return t(a)!==s&&(n(a,s),r(a)),c}var i=e.unsafeUnwrap,a=e.enqueueMutation,s=DOMTokenList.prototype.add;DOMTokenList.prototype.add=function(){o(this,s,arguments)};var c=DOMTokenList.prototype.remove;DOMTokenList.prototype.remove=function(){o(this,c,arguments)};var l=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(){return o(this,l,arguments)}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(t,n){var r=t.parentNode;if(r&&r.shadowRoot){var o=e.getRendererForHost(r);o.dependsOnAttribute(n)&&o.invalidate()}}function n(e,t,n){l(e,"attributes",{name:t,namespace:null,oldValue:n})}function r(e){a.call(this,e)}var o=e.ChildNodeInterface,i=e.GetElementsByInterface,a=e.wrappers.Node,s=e.ParentNodeInterface,c=e.SelectorsInterface,l=(e.addWrapNodeListMethod,e.enqueueMutation),u=e.mixin,d=(e.oneOf,e.registerWrapper),p=e.unsafeUnwrap,f=e.wrappers,h=window.Element,m=["matches","mozMatchesSelector","msMatchesSelector","webkitMatchesSelector"].filter(function(e){return h.prototype[e]}),w=m[0],v=h.prototype[w],g=new WeakMap;r.prototype=Object.create(a.prototype),u(r.prototype,{createShadowRoot:function(){var t=new f.ShadowRoot(this);p(this).polymerShadowRoot_=t;var n=e.getRendererForHost(this);return n.invalidate(),t},get shadowRoot(){return p(this).polymerShadowRoot_||null},setAttribute:function(e,r){var o=p(this).getAttribute(e);p(this).setAttribute(e,r),n(this,e,o),t(this,e)},removeAttribute:function(e){var r=p(this).getAttribute(e);p(this).removeAttribute(e),n(this,e,r),t(this,e)},matches:function(e){return v.call(p(this),e)},get classList(){var e=g.get(this);return e||(e=p(this).classList,e.ownerElement_=this,g.set(this,e)),e},get className(){return p(this).className},set className(e){this.setAttribute("class",e)},get id(){return p(this).id},set id(e){this.setAttribute("id",e)}}),m.forEach(function(e){"matches"!==e&&(r.prototype[e]=function(e){return this.matches(e)})}),h.prototype.webkitCreateShadowRoot&&(r.prototype.webkitCreateShadowRoot=r.prototype.createShadowRoot),u(r.prototype,o),u(r.prototype,i),u(r.prototype,s),u(r.prototype,c),d(h,r,document.createElementNS(null,"x")),e.invalidateRendererBasedOnAttribute=t,e.matchesNames=m,e.wrappers.Element=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case" ":return" "}}function n(e){return e.replace(O,t)}function r(e){return e.replace(_,t)}function o(e){for(var t={},n=0;n";case Node.TEXT_NODE:var u=e.data;return t&&C[t.localName]?u:r(u);case Node.COMMENT_NODE:return"";default:throw console.error(e),new Error("not implemented")}}function a(e){e instanceof L.HTMLTemplateElement&&(e=e.content);for(var t="",n=e.firstChild;n;n=n.nextSibling)t+=i(n,e);return t}function s(e,t,n){var r=n||"div";e.textContent="";var o=T(e.ownerDocument.createElement(r));o.innerHTML=t;for(var i;i=o.firstChild;)e.appendChild(M(i))}function c(e){h.call(this,e)}function l(e,t){var n=T(e.cloneNode(!1));n.innerHTML=t;for(var r,o=T(document.createDocumentFragment());r=n.firstChild;)o.appendChild(r);return M(o)}function u(t){return function(){return e.renderAllPending(),S(this)[t]}}function d(e){m(c,e,u(e))}function p(t){Object.defineProperty(c.prototype,t,{get:u(t),set:function(n){e.renderAllPending(),S(this)[t]=n},configurable:!0,enumerable:!0})}function f(t){Object.defineProperty(c.prototype,t,{value:function(){return e.renderAllPending(),S(this)[t].apply(S(this),arguments)},configurable:!0,enumerable:!0})}var h=e.wrappers.Element,m=e.defineGetter,w=e.enqueueMutation,v=e.mixin,g=e.nodesWereAdded,b=e.nodesWereRemoved,y=e.registerWrapper,E=e.snapshotNodeList,S=e.unsafeUnwrap,T=e.unwrap,M=e.wrap,L=e.wrappers,O=/[&\u00A0"]/g,_=/[&\u00A0<>]/g,N=o(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),C=o(["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"]),D=/MSIE/.test(navigator.userAgent),j=window.HTMLElement,H=window.HTMLTemplateElement;c.prototype=Object.create(h.prototype),v(c.prototype,{get innerHTML(){return a(this)},set innerHTML(e){if(D&&C[this.localName])return void(this.textContent=e);var t=E(this.childNodes);this.invalidateShadowRenderer()?this instanceof L.HTMLTemplateElement?s(this.content,e):s(this,e,this.tagName):!H&&this instanceof L.HTMLTemplateElement?s(this.content,e):S(this).innerHTML=e;var n=E(this.childNodes);w(this,"childList",{addedNodes:n,removedNodes:t}),b(t),g(n,this)},get outerHTML(){return i(this,this.parentNode)},set outerHTML(e){var t=this.parentNode;if(t){t.invalidateShadowRenderer();var n=l(t,e);t.replaceChild(n,this)}},insertAdjacentHTML:function(e,t){var n,r;switch(String(e).toLowerCase()){case"beforebegin":n=this.parentNode,r=this;break;case"afterend":n=this.parentNode,r=this.nextSibling;break;case"afterbegin":n=this,r=this.firstChild;break;case"beforeend":n=this,r=null;break;default:return}var o=l(n,t);n.insertBefore(o,r)},get hidden(){return this.hasAttribute("hidden")},set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollWidth"].forEach(d),["scrollLeft","scrollTop"].forEach(p),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(f),y(j,c,document.createElement("b")),e.wrappers.HTMLElement=c,e.getInnerHTML=a,e.setInnerHTML=s}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unsafeUnwrap,a=e.wrap,s=window.HTMLCanvasElement;t.prototype=Object.create(n.prototype),r(t.prototype,{getContext:function(){var e=i(this).getContext.apply(i(this),arguments);return e&&a(e)}}),o(s,t,document.createElement("canvas")),e.wrappers.HTMLCanvasElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=window.HTMLContentElement;t.prototype=Object.create(n.prototype),r(t.prototype,{constructor:t,get select(){return this.getAttribute("select")},set select(e){this.setAttribute("select",e)},setAttribute:function(e,t){n.prototype.setAttribute.call(this,e,t),"select"===String(e).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),i&&o(i,t),e.wrappers.HTMLContentElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=window.HTMLFormElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get elements(){return i(a(this).elements)}}),o(s,t,document.createElement("form")),e.wrappers.HTMLFormElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}function n(e,t){if(!(this instanceof n))throw new TypeError("DOM object constructor cannot be called as a function.");var o=i(document.createElement("img"));r.call(this,o),a(o,this),void 0!==e&&(o.width=e),void 0!==t&&(o.height=t)}var r=e.wrappers.HTMLElement,o=e.registerWrapper,i=e.unwrap,a=e.rewrap,s=window.HTMLImageElement;t.prototype=Object.create(r.prototype),o(s,t,document.createElement("img")),n.prototype=t.prototype,e.wrappers.HTMLImageElement=t,e.wrappers.Image=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=(e.mixin,e.wrappers.NodeList,e.registerWrapper),o=window.HTMLShadowElement;t.prototype=Object.create(n.prototype),t.prototype.constructor=t,o&&r(o,t),e.wrappers.HTMLShadowElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){if(!e.defaultView)return e;var t=d.get(e);if(!t){for(t=e.implementation.createHTMLDocument("");t.lastChild;)t.removeChild(t.lastChild);d.set(e,t)}return t}function n(e){for(var n,r=t(e.ownerDocument),o=c(r.createDocumentFragment());n=e.firstChild;)o.appendChild(n);return o}function r(e){if(o.call(this,e),!p){var t=n(e);u.set(this,l(t))}}var o=e.wrappers.HTMLElement,i=e.mixin,a=e.registerWrapper,s=e.unsafeUnwrap,c=e.unwrap,l=e.wrap,u=new WeakMap,d=new WeakMap,p=window.HTMLTemplateElement;r.prototype=Object.create(o.prototype),i(r.prototype,{constructor:r,get content(){return p?l(s(this).content):u.get(this)}}),p&&a(p,r),e.wrappers.HTMLTemplateElement=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.registerWrapper,o=window.HTMLMediaElement;o&&(t.prototype=Object.create(n.prototype),r(o,t,document.createElement("audio")),e.wrappers.HTMLMediaElement=t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}function n(e){if(!(this instanceof n))throw new TypeError("DOM object constructor cannot be called as a function.");var t=i(document.createElement("audio"));r.call(this,t),a(t,this),t.setAttribute("preload","auto"),void 0!==e&&t.setAttribute("src",e)}var r=e.wrappers.HTMLMediaElement,o=e.registerWrapper,i=e.unwrap,a=e.rewrap,s=window.HTMLAudioElement;s&&(t.prototype=Object.create(r.prototype),o(s,t,document.createElement("audio")),n.prototype=t.prototype,e.wrappers.HTMLAudioElement=t,e.wrappers.Audio=n)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e.replace(/\s+/g," ").trim()}function n(e){o.call(this,e)}function r(e,t,n,i){if(!(this instanceof r))throw new TypeError("DOM object constructor cannot be called as a function.");var a=c(document.createElement("option"));o.call(this,a),s(a,this),void 0!==e&&(a.text=e),void 0!==t&&a.setAttribute("value",t),n===!0&&a.setAttribute("selected",""),a.selected=i===!0}var o=e.wrappers.HTMLElement,i=e.mixin,a=e.registerWrapper,s=e.rewrap,c=e.unwrap,l=e.wrap,u=window.HTMLOptionElement;n.prototype=Object.create(o.prototype),i(n.prototype,{get text(){return t(this.textContent)},set text(e){this.textContent=t(String(e))},get form(){return l(c(this).form)}}),a(u,n,document.createElement("option")),r.prototype=n.prototype,e.wrappers.HTMLOptionElement=n,e.wrappers.Option=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unwrap,a=e.wrap,s=window.HTMLSelectElement;t.prototype=Object.create(n.prototype),r(t.prototype,{add:function(e,t){"object"==typeof t&&(t=i(t)),i(this).add(i(e),t)},remove:function(e){return void 0===e?void n.prototype.remove.call(this):("object"==typeof e&&(e=i(e)),void i(this).remove(e))},get form(){return a(i(this).form)}}),o(s,t,document.createElement("select")),e.wrappers.HTMLSelectElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unwrap,a=e.wrap,s=e.wrapHTMLCollection,c=window.HTMLTableElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get caption(){return a(i(this).caption)},createCaption:function(){return a(i(this).createCaption())},get tHead(){return a(i(this).tHead)},createTHead:function(){return a(i(this).createTHead())},createTFoot:function(){return a(i(this).createTFoot())},get tFoot(){return a(i(this).tFoot)},get tBodies(){return s(i(this).tBodies)},createTBody:function(){return a(i(this).createTBody())},get rows(){return s(i(this).rows)},insertRow:function(e){return a(i(this).insertRow(e))}}),o(c,t,document.createElement("table")),e.wrappers.HTMLTableElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=e.wrap,c=window.HTMLTableSectionElement;t.prototype=Object.create(n.prototype),r(t.prototype,{constructor:t,get rows(){return i(a(this).rows)},insertRow:function(e){return s(a(this).insertRow(e))}}),o(c,t,document.createElement("thead")),e.wrappers.HTMLTableSectionElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=e.wrap,c=window.HTMLTableRowElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get cells(){return i(a(this).cells)},insertCell:function(e){return s(a(this).insertCell(e))}}),o(c,t,document.createElement("tr")),e.wrappers.HTMLTableRowElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e.localName){case"content":return new n(e);case"shadow":return new o(e);case"template":return new i(e)}r.call(this,e)}var n=e.wrappers.HTMLContentElement,r=e.wrappers.HTMLElement,o=e.wrappers.HTMLShadowElement,i=e.wrappers.HTMLTemplateElement,a=(e.mixin,e.registerWrapper),s=window.HTMLUnknownElement;t.prototype=Object.create(r.prototype),a(s,t),e.wrappers.HTMLUnknownElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.wrappers.Element,n=e.wrappers.HTMLElement,r=e.registerObject,o="http://www.w3.org/2000/svg",i=document.createElementNS(o,"title"),a=r(i),s=Object.getPrototypeOf(a.prototype).constructor;if(!("classList"in i)){var c=Object.getOwnPropertyDescriptor(t.prototype,"classList");Object.defineProperty(n.prototype,"classList",c),delete t.prototype.classList}e.wrappers.SVGElement=s}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){p.call(this,e)}var n=e.mixin,r=e.registerWrapper,o=e.unwrap,i=e.wrap,a=window.SVGUseElement,s="http://www.w3.org/2000/svg",c=i(document.createElementNS(s,"g")),l=document.createElementNS(s,"use"),u=c.constructor,d=Object.getPrototypeOf(u.prototype),p=d.constructor;t.prototype=Object.create(d),"instanceRoot"in l&&n(t.prototype,{get instanceRoot(){return i(o(this).instanceRoot)},get animatedInstanceRoot(){return i(o(this).animatedInstanceRoot)}}),r(a,t,l),e.wrappers.SVGUseElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.mixin,o=e.registerWrapper,i=e.unsafeUnwrap,a=e.wrap,s=window.SVGElementInstance;s&&(t.prototype=Object.create(n.prototype),r(t.prototype,{get correspondingElement(){return a(i(this).correspondingElement)},get correspondingUseElement(){return a(i(this).correspondingUseElement)},get parentNode(){return a(i(this).parentNode)},get childNodes(){throw new Error("Not implemented")},get firstChild(){return a(i(this).firstChild)},get lastChild(){return a(i(this).lastChild)},get previousSibling(){return a(i(this).previousSibling)},get nextSibling(){return a(i(this).nextSibling)}}),o(s,t),e.wrappers.SVGElementInstance=t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){o(e,this)}var n=e.mixin,r=e.registerWrapper,o=e.setWrapper,i=e.unsafeUnwrap,a=e.unwrap,s=e.unwrapIfNeeded,c=e.wrap,l=window.CanvasRenderingContext2D;n(t.prototype,{get canvas(){return c(i(this).canvas)},drawImage:function(){arguments[0]=s(arguments[0]),i(this).drawImage.apply(i(this),arguments)},createPattern:function(){return arguments[0]=a(arguments[0]),i(this).createPattern.apply(i(this),arguments)}}),r(l,t,document.createElement("canvas").getContext("2d")),e.wrappers.CanvasRenderingContext2D=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){o(e,this)}var n=e.mixin,r=e.registerWrapper,o=e.setWrapper,i=e.unsafeUnwrap,a=e.unwrapIfNeeded,s=e.wrap,c=window.WebGLRenderingContext;if(c){n(t.prototype,{get canvas(){return s(i(this).canvas)},texImage2D:function(){arguments[5]=a(arguments[5]),i(this).texImage2D.apply(i(this),arguments)},texSubImage2D:function(){arguments[6]=a(arguments[6]),i(this).texSubImage2D.apply(i(this),arguments)}});var l=/WebKit/.test(navigator.userAgent)?{drawingBufferHeight:null,drawingBufferWidth:null}:{};r(c,t,l),e.wrappers.WebGLRenderingContext=t}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r(e,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unsafeUnwrap,i=e.unwrap,a=e.unwrapIfNeeded,s=e.wrap,c=window.Range;t.prototype={get startContainer(){return s(o(this).startContainer)},get endContainer(){return s(o(this).endContainer)},get commonAncestorContainer(){return s(o(this).commonAncestorContainer)},setStart:function(e,t){o(this).setStart(a(e),t)},setEnd:function(e,t){o(this).setEnd(a(e),t)},setStartBefore:function(e){o(this).setStartBefore(a(e))},setStartAfter:function(e){o(this).setStartAfter(a(e))},setEndBefore:function(e){o(this).setEndBefore(a(e))},setEndAfter:function(e){o(this).setEndAfter(a(e))},selectNode:function(e){o(this).selectNode(a(e))},selectNodeContents:function(e){o(this).selectNodeContents(a(e))},compareBoundaryPoints:function(e,t){return o(this).compareBoundaryPoints(e,i(t))},extractContents:function(){return s(o(this).extractContents())},cloneContents:function(){return s(o(this).cloneContents())},insertNode:function(e){o(this).insertNode(a(e))},surroundContents:function(e){o(this).surroundContents(a(e))},cloneRange:function(){return s(o(this).cloneRange())},isPointInRange:function(e,t){return o(this).isPointInRange(a(e),t)},comparePoint:function(e,t){return o(this).comparePoint(a(e),t)},intersectsNode:function(e){return o(this).intersectsNode(a(e))},toString:function(){return o(this).toString()}},c.prototype.createContextualFragment&&(t.prototype.createContextualFragment=function(e){return s(o(this).createContextualFragment(e))}),n(window.Range,t,document.createRange()),e.wrappers.Range=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.GetElementsByInterface,n=e.ParentNodeInterface,r=e.SelectorsInterface,o=e.mixin,i=e.registerObject,a=i(document.createDocumentFragment());o(a.prototype,n),o(a.prototype,r),o(a.prototype,t);var s=i(document.createComment(""));e.wrappers.Comment=s,e.wrappers.DocumentFragment=a}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=d(u(e).ownerDocument.createDocumentFragment());n.call(this,t),c(t,this);var o=e.shadowRoot;f.set(this,o),this.treeScope_=new r(this,a(o||e)),p.set(this,e)}var n=e.wrappers.DocumentFragment,r=e.TreeScope,o=e.elementFromPoint,i=e.getInnerHTML,a=e.getTreeScope,s=e.mixin,c=e.rewrap,l=e.setInnerHTML,u=e.unsafeUnwrap,d=e.unwrap,p=new WeakMap,f=new WeakMap,h=/[ \t\n\r\f]/;t.prototype=Object.create(n.prototype),s(t.prototype,{constructor:t,get innerHTML(){return i(this)},set innerHTML(e){l(this,e),this.invalidateShadowRenderer()},get olderShadowRoot(){return f.get(this)||null},get host(){return p.get(this)||null},invalidateShadowRenderer:function(){return p.get(this).invalidateShadowRenderer()},elementFromPoint:function(e,t){return o(this,this.ownerDocument,e,t)},getElementById:function(e){return h.test(e)?null:this.querySelector('[id="'+e+'"]')}}),e.wrappers.ShadowRoot=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){e.previousSibling_=e.previousSibling,e.nextSibling_=e.nextSibling,e.parentNode_=e.parentNode}function n(n,o,i){var a=x(n),s=x(o),c=i?x(i):null;if(r(o),t(o),i)n.firstChild===i&&(n.firstChild_=i),i.previousSibling_=i.previousSibling;else{n.lastChild_=n.lastChild,n.lastChild===n.firstChild&&(n.firstChild_=n.firstChild);var l=R(a.lastChild);l&&(l.nextSibling_=l.nextSibling)}e.originalInsertBefore.call(a,s,c)}function r(n){var r=x(n),o=r.parentNode;if(o){var i=R(o);t(n),n.previousSibling&&(n.previousSibling.nextSibling_=n),n.nextSibling&&(n.nextSibling.previousSibling_=n),i.lastChild===n&&(i.lastChild_=n),i.firstChild===n&&(i.firstChild_=n),e.originalRemoveChild.call(o,r)}}function o(e){I.set(e,[])}function i(e){var t=I.get(e);return t||I.set(e,t=[]),t}function a(e){for(var t=[],n=0,r=e.firstChild;r;r=r.nextSibling)t[n++]=r;return t}function s(){for(var e=0;em;m++){var w=R(i[u++]);s.get(w)||r(w)}for(var v=f.addedCount,g=i[u]&&R(i[u]),m=0;v>m;m++){var b=o[l++],y=b.node;n(t,y,g),s.set(y,!0),b.sync(s)}d+=v}for(var p=d;p=0;o--){var i=r[o],a=m(i);if(a){var s=i.olderShadowRoot;s&&(n=h(s));for(var c=0;c=0;u--)l=Object.create(l);["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"].forEach(function(e){var t=o[e];t&&(l[e]=function(){N(this)instanceof r||M(this),t.apply(N(this),arguments)})});var d={prototype:l};i&&(d["extends"]=i),r.prototype=o,r.prototype.constructor=r,e.constructorTable.set(l,r),e.nativePrototypeTable.set(o,l);x.call(_(this),t,d);return r},b([window.HTMLDocument||window.Document],["registerElement"])}b([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement,window.HTMLHtmlElement],["appendChild","compareDocumentPosition","contains","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"]),b([window.HTMLBodyElement,window.HTMLHeadElement,window.HTMLHtmlElement],y),b([window.HTMLDocument||window.Document],["adoptNode","importNode","contains","createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","elementFromPoint","getElementById","getElementsByName","getSelection"]),E(t.prototype,l),E(t.prototype,d),E(t.prototype,f),E(t.prototype,{get implementation(){var e=D.get(this);return e?e:(e=new a(_(this).implementation),D.set(this,e),e)},get defaultView(){return N(_(this).defaultView) -}}),S(window.Document,t,document.implementation.createHTMLDocument("")),window.HTMLDocument&&S(window.HTMLDocument,t),C([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]),s(a,"createDocumentType"),s(a,"createDocument"),s(a,"createHTMLDocument"),c(a,"hasFeature"),S(window.DOMImplementation,a),b([window.DOMImplementation],["createDocumentType","createDocument","createHTMLDocument","hasFeature"]),e.adoptNodeNoRemove=r,e.wrappers.DOMImplementation=a,e.wrappers.Document=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.wrappers.Selection,o=e.mixin,i=e.registerWrapper,a=e.renderAllPending,s=e.unwrap,c=e.unwrapIfNeeded,l=e.wrap,u=window.Window,d=window.getComputedStyle,p=window.getDefaultComputedStyle,f=window.getSelection;t.prototype=Object.create(n.prototype),u.prototype.getComputedStyle=function(e,t){return l(this||window).getComputedStyle(c(e),t)},p&&(u.prototype.getDefaultComputedStyle=function(e,t){return l(this||window).getDefaultComputedStyle(c(e),t)}),u.prototype.getSelection=function(){return l(this||window).getSelection()},delete window.getComputedStyle,delete window.getDefaultComputedStyle,delete window.getSelection,["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){u.prototype[e]=function(){var t=l(this||window);return t[e].apply(t,arguments)},delete window[e]}),o(t.prototype,{getComputedStyle:function(e,t){return a(),d.call(s(this),c(e),t)},getSelection:function(){return a(),new r(f.call(s(this)))},get document(){return l(s(this).document)}}),p&&(t.prototype.getDefaultComputedStyle=function(e,t){return a(),p.call(s(this),c(e),t)}),i(u,t,window),e.wrappers.Window=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.unwrap,n=window.DataTransfer||window.Clipboard,r=n.prototype.setDragImage;r&&(n.prototype.setDragImage=function(e,n,o){r.call(this,t(e),n,o)})}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t;t=e instanceof i?e:new i(e&&o(e)),r(t,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unwrap,i=window.FormData;i&&(n(i,t,new i),e.wrappers.FormData=t)}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.unwrapIfNeeded,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(e){return n.call(this,t(e))}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=n[e],r=window[t];if(r){var o=document.createElement(e),i=o.constructor;window[t]=i}}var n=(e.isWrapperFor,{a:"HTMLAnchorElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",base:"HTMLBaseElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",content:"HTMLContentElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",del:"HTMLModElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",head:"HTMLHeadElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",shadow:"HTMLShadowElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",ul:"HTMLUListElement",video:"HTMLVideoElement"});Object.keys(n).forEach(t),Object.getOwnPropertyNames(e.wrappers).forEach(function(t){window[t]=e.wrappers[t]})}(window.ShadowDOMPolyfill),function(e){function t(e,t){var n="";return Array.prototype.forEach.call(e,function(e){n+=e.textContent+"\n\n"}),t||(n=n.replace(d,"")),n}function n(e){var t=document.createElement("style");return t.textContent=e,t}function r(e){var t=n(e);document.head.appendChild(t);var r=[];if(t.sheet)try{r=t.sheet.cssRules}catch(o){}else console.warn("sheet not found",t);return t.parentNode.removeChild(t),r}function o(){C.initialized=!0,document.body.appendChild(C);var e=C.contentDocument,t=e.createElement("base");t.href=document.baseURI,e.head.appendChild(t)}function i(e){C.initialized||o(),document.body.appendChild(C),e(C.contentDocument),document.body.removeChild(C)}function a(e,t){if(t){var o;if(e.match("@import")&&j){var a=n(e);i(function(e){e.head.appendChild(a.impl),o=Array.prototype.slice.call(a.sheet.cssRules,0),t(o)})}else o=r(e),t(o)}}function s(e){e&&l().appendChild(document.createTextNode(e))}function c(e,t){var r=n(e);r.setAttribute(t,""),r.setAttribute(x,""),document.head.appendChild(r)}function l(){return D||(D=document.createElement("style"),D.setAttribute(x,""),D[x]=!0),D}var u={strictStyling:!1,registry:{},shimStyling:function(e,n,r){var o=this.prepareRoot(e,n,r),i=this.isTypeExtension(r),a=this.makeScopeSelector(n,i),s=t(o,!0);s=this.scopeCssText(s,a),e&&(e.shimmedStyle=s),this.addCssToDocument(s,n)},shimStyle:function(e,t){return this.shimCssText(e.textContent,t)},shimCssText:function(e,t){return e=this.insertDirectives(e),this.scopeCssText(e,t)},makeScopeSelector:function(e,t){return e?t?"[is="+e+"]":e:""},isTypeExtension:function(e){return e&&e.indexOf("-")<0},prepareRoot:function(e,t,n){var r=this.registerRoot(e,t,n);return this.replaceTextInStyles(r.rootStyles,this.insertDirectives),this.removeStyles(e,r.rootStyles),this.strictStyling&&this.applyScopeToContent(e,t),r.scopeStyles},removeStyles:function(e,t){for(var n,r=0,o=t.length;o>r&&(n=t[r]);r++)n.parentNode.removeChild(n)},registerRoot:function(e,t,n){var r=this.registry[t]={root:e,name:t,extendsName:n},o=this.findStyles(e);r.rootStyles=o,r.scopeStyles=r.rootStyles;var i=this.registry[r.extendsName];return i&&(r.scopeStyles=i.scopeStyles.concat(r.scopeStyles)),r},findStyles:function(e){if(!e)return[];var t=e.querySelectorAll("style");return Array.prototype.filter.call(t,function(e){return!e.hasAttribute(R)})},applyScopeToContent:function(e,t){e&&(Array.prototype.forEach.call(e.querySelectorAll("*"),function(e){e.setAttribute(t,"")}),Array.prototype.forEach.call(e.querySelectorAll("template"),function(e){this.applyScopeToContent(e.content,t)},this))},insertDirectives:function(e){return e=this.insertPolyfillDirectivesInCssText(e),this.insertPolyfillRulesInCssText(e)},insertPolyfillDirectivesInCssText:function(e){return e=e.replace(p,function(e,t){return t.slice(0,-2)+"{"}),e.replace(f,function(e,t){return t+" {"})},insertPolyfillRulesInCssText:function(e){return e=e.replace(h,function(e,t){return t.slice(0,-1)}),e.replace(m,function(e,t,n,r){var o=e.replace(t,"").replace(n,"");return r+o})},scopeCssText:function(e,t){var n=this.extractUnscopedRulesFromCssText(e);if(e=this.insertPolyfillHostInCssText(e),e=this.convertColonHost(e),e=this.convertColonHostContext(e),e=this.convertShadowDOMSelectors(e),t){var e,r=this;a(e,function(n){e=r.scopeRules(n,t)})}return e=e+"\n"+n,e.trim()},extractUnscopedRulesFromCssText:function(e){for(var t,n="";t=w.exec(e);)n+=t[1].slice(0,-1)+"\n\n";for(;t=v.exec(e);)n+=t[0].replace(t[2],"").replace(t[1],t[3])+"\n\n";return n},convertColonHost:function(e){return this.convertColonRule(e,E,this.colonHostPartReplacer)},convertColonHostContext:function(e){return this.convertColonRule(e,S,this.colonHostContextPartReplacer)},convertColonRule:function(e,t,n){return e.replace(t,function(e,t,r,o){if(t=O,r){for(var i,a=r.split(","),s=[],c=0,l=a.length;l>c&&(i=a[c]);c++)i=i.trim(),s.push(n(t,i,o));return s.join(",")}return t+o})},colonHostContextPartReplacer:function(e,t,n){return t.match(g)?this.colonHostPartReplacer(e,t,n):e+t+n+", "+t+" "+e+n},colonHostPartReplacer:function(e,t,n){return e+t.replace(g,"")+n},convertShadowDOMSelectors:function(e){for(var t=0;t","+","~"],r=e,o="["+t+"]";return n.forEach(function(e){var t=r.split(e);r=t.map(function(e){var t=e.trim().replace(_,"");return t&&n.indexOf(t)<0&&t.indexOf(o)<0&&(e=t.replace(/([^:]*)(:*)(.*)/,"$1"+o+"$2$3")),e}).join(e)}),r},insertPolyfillHostInCssText:function(e){return e.replace(L,b).replace(M,g)},propertiesFromRule:function(e){var t=e.style.cssText;e.style.content&&!e.style.content.match(/['"]+|attr/)&&(t=t.replace(/content:[^;]*;/g,"content: '"+e.style.content+"';"));var n=e.style;for(var r in n)"initial"===n[r]&&(t+=r+": initial; ");return t},replaceTextInStyles:function(e,t){e&&t&&(e instanceof Array||(e=[e]),Array.prototype.forEach.call(e,function(e){e.textContent=t.call(this,e.textContent)},this))},addCssToDocument:function(e,t){e.match("@import")?c(e,t):s(e)}},d=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,p=/\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim,f=/polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim,h=/\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,m=/(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,w=/\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,v=/(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,g="-shadowcsshost",b="-shadowcsscontext",y=")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)",E=new RegExp("("+g+y,"gim"),S=new RegExp("("+b+y,"gim"),T="([>\\s~+[.,{:][\\s\\S]*)?$",M=/\:host/gim,L=/\:host-context/gim,O=g+"-no-combinator",_=new RegExp(g,"gim"),N=(new RegExp(b,"gim"),[/\^\^/g,/\^/g,/\/shadow\//g,/\/shadow-deep\//g,/::shadow/g,/\/deep\//g,/::content/g]),C=document.createElement("iframe");C.style.display="none";var D,j=navigator.userAgent.match("Chrome"),H="shim-shadowdom",x="shim-shadowdom-css",R="no-shim";if(window.ShadowDOMPolyfill){s("style { display: none !important; }\n");var P=ShadowDOMPolyfill.wrap(document),I=P.querySelector("head");I.insertBefore(l(),I.childNodes[0]),document.addEventListener("DOMContentLoaded",function(){e.urlResolver;if(window.HTMLImports&&!HTMLImports.useNative){var t="link[rel=stylesheet]["+H+"]",n="style["+H+"]";HTMLImports.importer.documentPreloadSelectors+=","+t,HTMLImports.importer.importsPreloadSelectors+=","+t,HTMLImports.parser.documentSelectors=[HTMLImports.parser.documentSelectors,t,n].join(",");var r=HTMLImports.parser.parseGeneric;HTMLImports.parser.parseGeneric=function(e){if(!e[x]){var t=e.__importElement||e;if(!t.hasAttribute(H))return void r.call(this,e);e.__resource&&(t=e.ownerDocument.createElement("style"),t.textContent=e.__resource),HTMLImports.path.resolveUrlsInStyle(t),t.textContent=u.shimStyle(t),t.removeAttribute(H,""),t.setAttribute(x,""),t[x]=!0,t.parentNode!==I&&(e.parentNode===I?I.replaceChild(t,e):this.addElementToDocument(t)),t.__importParsed=!0,this.markParsingComplete(e),this.parseNext()}};var o=HTMLImports.parser.hasResource;HTMLImports.parser.hasResource=function(e){return"link"===e.localName&&"stylesheet"===e.rel&&e.hasAttribute(H)?e.__resource:o.call(this,e)}}})}e.ShadowCSS=u}(window.WebComponents)),function(){window.ShadowDOMPolyfill?(window.wrap=ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=ShadowDOMPolyfill.unwrapIfNeeded):window.wrap=window.unwrap=function(e){return e}}(window.WebComponents),function(e){function t(e){y.push(e),b||(b=!0,m(r))}function n(e){return window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(e)||e}function r(){b=!1;var e=y;y=[],e.sort(function(e,t){return e.uid_-t.uid_});var t=!1;e.forEach(function(e){var n=e.takeRecords();o(e),n.length&&(e.callback_(n,e),t=!0)}),t&&r()}function o(e){e.nodes_.forEach(function(t){var n=w.get(t);n&&n.forEach(function(t){t.observer===e&&t.removeTransientObservers()})})}function i(e,t){for(var n=e;n;n=n.parentNode){var r=w.get(n);if(r)for(var o=0;o0){var o=n[r-1],i=f(o,e);if(i)return void(n[r-1]=i)}else t(this.observer);n[r]=e},addListeners:function(){this.addListeners_(this.target)},addListeners_:function(e){var t=this.options;t.attributes&&e.addEventListener("DOMAttrModified",this,!0),t.characterData&&e.addEventListener("DOMCharacterDataModified",this,!0),t.childList&&e.addEventListener("DOMNodeInserted",this,!0),(t.childList||t.subtree)&&e.addEventListener("DOMNodeRemoved",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},removeListeners_:function(e){var t=this.options;t.attributes&&e.removeEventListener("DOMAttrModified",this,!0),t.characterData&&e.removeEventListener("DOMCharacterDataModified",this,!0),t.childList&&e.removeEventListener("DOMNodeInserted",this,!0),(t.childList||t.subtree)&&e.removeEventListener("DOMNodeRemoved",this,!0)},addTransientObserver:function(e){if(e!==this.target){this.addListeners_(e),this.transientObservedNodes.push(e);var t=w.get(e);t||w.set(e,t=[]),t.push(this)}},removeTransientObservers:function(){var e=this.transientObservedNodes;this.transientObservedNodes=[],e.forEach(function(e){this.removeListeners_(e);for(var t=w.get(e),n=0;nu&&(l=i[u]);u++)a(l)?r.call(l,{target:l}):(l.addEventListener("load",r),l.addEventListener("error",r));else n()}function a(e){return d?e.__loaded||e["import"]&&"loading"!==e["import"].readyState:e.__importParsed}function s(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)c(t)&&l(t)}function c(e){return"link"===e.localName&&"import"===e.rel}function l(e){var t=e["import"];t?o({target:e}):(e.addEventListener("load",o),e.addEventListener("error",o))}var u="import",d=Boolean(u in document.createElement("link")),p=Boolean(window.ShadowDOMPolyfill),f=function(e){return p?ShadowDOMPolyfill.wrapIfNeeded(e):e},h=f(document),m={get:function(){var e=HTMLImports.currentScript||document.currentScript||("complete"!==document.readyState?document.scripts[document.scripts.length-1]:null);return f(e)},configurable:!0};Object.defineProperty(document,"_currentScript",m),Object.defineProperty(h,"_currentScript",m);var w=/Trident|Edge/.test(navigator.userAgent),v=w?"complete":"interactive",g="readystatechange";d&&(new MutationObserver(function(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)t.addedNodes&&s(t.addedNodes)}).observe(document.head,{childList:!0}),function(){if("loading"===document.readyState)for(var e,t=document.querySelectorAll("link[rel=import]"),n=0,r=t.length;r>n&&(e=t[n]);n++)l(e)}()),t(function(){HTMLImports.ready=!0,HTMLImports.readyTime=(new Date).getTime();var e=h.createEvent("CustomEvent");e.initCustomEvent("HTMLImportsLoaded",!0,!0,{}),h.dispatchEvent(e)}),e.IMPORT_LINK_TYPE=u,e.useNative=d,e.rootDocument=h,e.whenReady=t,e.isIE=w}(HTMLImports),function(e){var t=[],n=function(e){t.push(e)},r=function(){t.forEach(function(t){t(e)})};e.addModule=n,e.initializeModules=r}(HTMLImports),HTMLImports.addModule(function(e){var t=/(url\()([^)]*)(\))/g,n=/(@import[\s]+(?!url\())([^;]*)(;)/g,r={resolveUrlsInStyle:function(e){var t=e.ownerDocument,n=t.createElement("a");return e.textContent=this.resolveUrlsInCssText(e.textContent,n),e},resolveUrlsInCssText:function(e,r){var o=this.replaceUrls(e,r,t);return o=this.replaceUrls(o,r,n)},replaceUrls:function(e,t,n){return e.replace(n,function(e,n,r,o){var i=r.replace(/["']/g,"");return t.href=i,i=t.href,n+"'"+i+"'"+o})}};e.path=r}),HTMLImports.addModule(function(e){var t={async:!0,ok:function(e){return e.status>=200&&e.status<300||304===e.status||0===e.status},load:function(n,r,o){var i=new XMLHttpRequest;return(e.flags.debug||e.flags.bust)&&(n+="?"+Math.random()),i.open("GET",n,t.async),i.addEventListener("readystatechange",function(){if(4===i.readyState){var e=i.getResponseHeader("Location"),n=null;if(e)var n="/"===e.substr(0,1)?location.origin+e:e;r.call(o,!t.ok(i)&&i,i.response||i.responseText,n)}}),i.send(),i},loadDocument:function(e,t,n){this.load(e,t,n).responseType="document"}};e.xhr=t}),HTMLImports.addModule(function(e){var t=e.xhr,n=e.flags,r=function(e,t){this.cache={},this.onload=e,this.oncomplete=t,this.inflight=0,this.pending={}};r.prototype={addNodes:function(e){this.inflight+=e.length;for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)this.require(t);this.checkDone()},addNode:function(e){this.inflight++,this.require(e),this.checkDone()},require:function(e){var t=e.src||e.href;e.__nodeUrl=t,this.dedupe(t,e)||this.fetch(t,e)},dedupe:function(e,t){if(this.pending[e])return this.pending[e].push(t),!0;return this.cache[e]?(this.onload(e,t,this.cache[e]),this.tail(),!0):(this.pending[e]=[t],!1)},fetch:function(e,r){if(n.load&&console.log("fetch",e,r),e)if(e.match(/^data:/)){var o=e.split(","),i=o[0],a=o[1];a=i.indexOf(";base64")>-1?atob(a):decodeURIComponent(a),setTimeout(function(){this.receive(e,r,null,a)}.bind(this),0)}else{var s=function(t,n,o){this.receive(e,r,t,n,o)}.bind(this);t.load(e,s)}else setTimeout(function(){this.receive(e,r,{error:"href must be specified"},null)}.bind(this),0)},receive:function(e,t,n,r,o){this.cache[e]=r;for(var i,a=this.pending[e],s=0,c=a.length;c>s&&(i=a[s]);s++)this.onload(e,i,r,n,o),this.tail();this.pending[e]=null},tail:function(){--this.inflight,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}},e.Loader=r}),HTMLImports.addModule(function(e){var t=function(e){this.addCallback=e,this.mo=new MutationObserver(this.handler.bind(this))};t.prototype={handler:function(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)"childList"===t.type&&t.addedNodes.length&&this.addedNodes(t.addedNodes)},addedNodes:function(e){this.addCallback&&this.addCallback(e);for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)t.children&&t.children.length&&this.addedNodes(t.children)},observe:function(e){this.mo.observe(e,{childList:!0,subtree:!0})}},e.Observer=t}),HTMLImports.addModule(function(e){function t(e){return"link"===e.localName&&e.rel===u}function n(e){var t=r(e);return"data:text/javascript;charset=utf-8,"+encodeURIComponent(t)}function r(e){return e.textContent+o(e)}function o(e){var t=e.ownerDocument;t.__importedScripts=t.__importedScripts||0;var n=e.ownerDocument.baseURI,r=t.__importedScripts?"-"+t.__importedScripts:"";return t.__importedScripts++,"\n//# sourceURL="+n+r+".js\n"}function i(e){var t=e.ownerDocument.createElement("style");return t.textContent=e.textContent,a.resolveUrlsInStyle(t),t}var a=e.path,s=e.rootDocument,c=e.flags,l=e.isIE,u=e.IMPORT_LINK_TYPE,d="link[rel="+u+"]",p={documentSelectors:d,importsSelectors:[d,"link[rel=stylesheet]","style","script:not([type])",'script[type="text/javascript"]'].join(","),map:{link:"parseLink",script:"parseScript",style:"parseStyle"},dynamicElements:[],parseNext:function(){var e=this.nextToParse();e&&this.parse(e)},parse:function(e){if(this.isParsed(e))return void(c.parse&&console.log("[%s] is already parsed",e.localName));var t=this[this.map[e.localName]];t&&(this.markParsing(e),t.call(this,e))},parseDynamic:function(e,t){this.dynamicElements.push(e),t||this.parseNext()},markParsing:function(e){c.parse&&console.log("parsing",e),this.parsingElement=e},markParsingComplete:function(e){e.__importParsed=!0,this.markDynamicParsingComplete(e),e.__importElement&&(e.__importElement.__importParsed=!0,this.markDynamicParsingComplete(e.__importElement)),this.parsingElement=null,c.parse&&console.log("completed",e)},markDynamicParsingComplete:function(e){var t=this.dynamicElements.indexOf(e);t>=0&&this.dynamicElements.splice(t,1)},parseImport:function(e){if(HTMLImports.__importsParsingHook&&HTMLImports.__importsParsingHook(e),e["import"]&&(e["import"].__importParsed=!0),this.markParsingComplete(e),e.dispatchEvent(e.__resource&&!e.__error?new CustomEvent("load",{bubbles:!1}):new CustomEvent("error",{bubbles:!1})),e.__pending)for(var t;e.__pending.length;)t=e.__pending.shift(),t&&t({target:e});this.parseNext()},parseLink:function(e){t(e)?this.parseImport(e):(e.href=e.href,this.parseGeneric(e))},parseStyle:function(e){var t=e;e=i(e),e.__importElement=t,this.parseGeneric(e)},parseGeneric:function(e){this.trackElement(e),this.addElementToDocument(e)},rootImportForElement:function(e){for(var t=e;t.ownerDocument.__importLink;)t=t.ownerDocument.__importLink;return t},addElementToDocument:function(e){var t=this.rootImportForElement(e.__importElement||e);t.parentNode.insertBefore(e,t)},trackElement:function(e,t){var n=this,r=function(r){t&&t(r),n.markParsingComplete(e),n.parseNext()};if(e.addEventListener("load",r),e.addEventListener("error",r),l&&"style"===e.localName){var o=!1;if(-1==e.textContent.indexOf("@import"))o=!0;else if(e.sheet){o=!0;for(var i,a=e.sheet.cssRules,s=a?a.length:0,c=0;s>c&&(i=a[c]);c++)i.type===CSSRule.IMPORT_RULE&&(o=o&&Boolean(i.styleSheet))}o&&e.dispatchEvent(new CustomEvent("load",{bubbles:!1}))}},parseScript:function(t){var r=document.createElement("script");r.__importElement=t,r.src=t.src?t.src:n(t),e.currentScript=t,this.trackElement(r,function(){r.parentNode.removeChild(r),e.currentScript=null}),this.addElementToDocument(r)},nextToParse:function(){return this._mayParse=[],!this.parsingElement&&(this.nextToParseInDoc(s)||this.nextToParseDynamic())},nextToParseInDoc:function(e,n){if(e&&this._mayParse.indexOf(e)<0){this._mayParse.push(e);for(var r,o=e.querySelectorAll(this.parseSelectorsForNode(e)),i=0,a=o.length;a>i&&(r=o[i]);i++)if(!this.isParsed(r))return this.hasResource(r)?t(r)?this.nextToParseInDoc(r["import"],r):r:void 0}return n},nextToParseDynamic:function(){return this.dynamicElements[0]},parseSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===s?this.documentSelectors:this.importsSelectors},isParsed:function(e){return e.__importParsed},needsDynamicParsing:function(e){return this.dynamicElements.indexOf(e)>=0},hasResource:function(e){return t(e)&&void 0===e["import"]?!1:!0}};e.parser=p,e.IMPORT_SELECTOR=d}),HTMLImports.addModule(function(e){function t(e){return n(e,i)}function n(e,t){return"link"===e.localName&&e.getAttribute("rel")===t}function r(e,t){var n=document.implementation.createHTMLDocument(i);n._URL=t;var r=n.createElement("base");r.setAttribute("href",t),n.baseURI||Object.defineProperty(n,"baseURI",{value:t});var o=n.createElement("meta");return o.setAttribute("charset","utf-8"),n.head.appendChild(o),n.head.appendChild(r),n.body.innerHTML=e,window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(n),n}var o=e.flags,i=e.IMPORT_LINK_TYPE,a=e.IMPORT_SELECTOR,s=e.rootDocument,c=e.Loader,l=e.Observer,u=e.parser,d={documents:{},documentPreloadSelectors:a,importsPreloadSelectors:[a].join(","),loadNode:function(e){p.addNode(e)},loadSubtree:function(e){var t=this.marshalNodes(e);p.addNodes(t)},marshalNodes:function(e){return e.querySelectorAll(this.loadSelectorsForNode(e))},loadSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===s?this.documentPreloadSelectors:this.importsPreloadSelectors},loaded:function(e,n,i,a,s){if(o.load&&console.log("loaded",e,n),n.__resource=i,n.__error=a,t(n)){var c=this.documents[e];void 0===c&&(c=a?null:r(i,s||e),c&&(c.__importLink=n,this.bootDocument(c)),this.documents[e]=c),n["import"]=c}u.parseNext()},bootDocument:function(e){this.loadSubtree(e),this.observer.observe(e),u.parseNext()},loadedAll:function(){u.parseNext()}},p=new c(d.loaded.bind(d),d.loadedAll.bind(d));if(d.observer=new l,!document.baseURI){var f={get:function(){var e=document.querySelector("base");return e?e.href:window.location.href},configurable:!0};Object.defineProperty(document,"baseURI",f),Object.defineProperty(s,"baseURI",f)}e.importer=d,e.importLoader=p}),HTMLImports.addModule(function(e){var t=e.parser,n=e.importer,r={added:function(e){for(var r,o,i,a,s=0,c=e.length;c>s&&(a=e[s]);s++)r||(r=a.ownerDocument,o=t.isParsed(r)),i=this.shouldLoadNode(a),i&&n.loadNode(a),this.shouldParseNode(a)&&o&&t.parseDynamic(a,i)},shouldLoadNode:function(e){return 1===e.nodeType&&o.call(e,n.loadSelectorsForNode(e))},shouldParseNode:function(e){return 1===e.nodeType&&o.call(e,t.parseSelectorsForNode(e))}};n.observer.addCallback=r.added.bind(r);var o=HTMLElement.prototype.matches||HTMLElement.prototype.matchesSelector||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector}),function(e){function t(){HTMLImports.importer.bootDocument(o)}var n=e.initializeModules,r=e.isIE;if(!e.useNative){r&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),n},window.CustomEvent.prototype=window.Event.prototype),n();var o=e.rootDocument;"complete"===document.readyState||"interactive"===document.readyState&&!window.attachEvent?t():document.addEventListener("DOMContentLoaded",t)}}(HTMLImports),window.CustomElements=window.CustomElements||{flags:{}},function(e){var t=e.flags,n=[],r=function(e){n.push(e)},o=function(){n.forEach(function(t){t(e)})};e.addModule=r,e.initializeModules=o,e.hasNative=Boolean(document.registerElement),e.useNative=!t.register&&e.hasNative&&!window.ShadowDOMPolyfill&&(!window.HTMLImports||HTMLImports.useNative)}(CustomElements),CustomElements.addModule(function(e){function t(e,t){n(e,function(e){return t(e)?!0:void r(e,t)}),r(e,t)}function n(e,t,r){var o=e.firstElementChild;if(!o)for(o=e.firstChild;o&&o.nodeType!==Node.ELEMENT_NODE;)o=o.nextSibling;for(;o;)t(o,r)!==!0&&n(o,t,r),o=o.nextElementSibling;return null}function r(e,n){for(var r=e.shadowRoot;r;)t(r,n),r=r.olderShadowRoot}function o(e,t){a=[],i(e,t),a=null}function i(e,t){if(e=wrap(e),!(a.indexOf(e)>=0)){a.push(e);for(var n,r=e.querySelectorAll("link[rel="+s+"]"),o=0,c=r.length;c>o&&(n=r[o]);o++)n["import"]&&i(n["import"],t);t(e)}}var a,s=window.HTMLImports?HTMLImports.IMPORT_LINK_TYPE:"none";e.forDocumentTree=o,e.forSubtree=t}),CustomElements.addModule(function(e){function t(e){return n(e)||r(e)}function n(t){return e.upgrade(t)?!0:void s(t)}function r(e){y(e,function(e){return n(e)?!0:void 0})}function o(e){s(e),p(e)&&y(e,function(e){s(e)})}function i(e){M.push(e),T||(T=!0,setTimeout(a))}function a(){T=!1;for(var e,t=M,n=0,r=t.length;r>n&&(e=t[n]);n++)e();M=[]}function s(e){S?i(function(){c(e)}):c(e)}function c(e){e.__upgraded__&&(e.attachedCallback||e.detachedCallback)&&!e.__attached&&p(e)&&(e.__attached=!0,e.attachedCallback&&e.attachedCallback())}function l(e){u(e),y(e,function(e){u(e)})}function u(e){S?i(function(){d(e) -}):d(e)}function d(e){e.__upgraded__&&(e.attachedCallback||e.detachedCallback)&&e.__attached&&!p(e)&&(e.__attached=!1,e.detachedCallback&&e.detachedCallback())}function p(e){for(var t=e,n=wrap(document);t;){if(t==n)return!0;t=t.parentNode||t.host}}function f(e){if(e.shadowRoot&&!e.shadowRoot.__watched){b.dom&&console.log("watching shadow-root for: ",e.localName);for(var t=e.shadowRoot;t;)w(t),t=t.olderShadowRoot}}function h(e){if(b.dom){var n=e[0];if(n&&"childList"===n.type&&n.addedNodes&&n.addedNodes){for(var r=n.addedNodes[0];r&&r!==document&&!r.host;)r=r.parentNode;var o=r&&(r.URL||r._URL||r.host&&r.host.localName)||"";o=o.split("/?").shift().split("/").pop()}console.group("mutations (%d) [%s]",e.length,o||"")}e.forEach(function(e){"childList"===e.type&&(L(e.addedNodes,function(e){e.localName&&t(e)}),L(e.removedNodes,function(e){e.localName&&l(e)}))}),b.dom&&console.groupEnd()}function m(e){for(e=wrap(e),e||(e=wrap(document));e.parentNode;)e=e.parentNode;var t=e.__observer;t&&(h(t.takeRecords()),a())}function w(e){if(!e.__observer){var t=new MutationObserver(h);t.observe(e,{childList:!0,subtree:!0}),e.__observer=t}}function v(e){e=wrap(e),b.dom&&console.group("upgradeDocument: ",e.baseURI.split("/").pop()),t(e),w(e),b.dom&&console.groupEnd()}function g(e){E(e,v)}var b=e.flags,y=e.forSubtree,E=e.forDocumentTree,S=!window.MutationObserver||window.MutationObserver===window.JsMutationObserver;e.hasPolyfillMutations=S;var T=!1,M=[],L=Array.prototype.forEach.call.bind(Array.prototype.forEach),O=Element.prototype.createShadowRoot;Element.prototype.createShadowRoot=function(){var e=O.call(this);return CustomElements.watchShadow(this),e},e.watchShadow=f,e.upgradeDocumentTree=g,e.upgradeSubtree=r,e.upgradeAll=t,e.attachedNode=o,e.takeRecords=m}),CustomElements.addModule(function(e){function t(t){if(!t.__upgraded__&&t.nodeType===Node.ELEMENT_NODE){var r=t.getAttribute("is"),o=e.getRegisteredDefinition(r||t.localName);if(o){if(r&&o.tag==t.localName)return n(t,o);if(!r&&!o["extends"])return n(t,o)}}}function n(t,n){return a.upgrade&&console.group("upgrade:",t.localName),n.is&&t.setAttribute("is",n.is),r(t,n),t.__upgraded__=!0,i(t),e.attachedNode(t),e.upgradeSubtree(t),a.upgrade&&console.groupEnd(),t}function r(e,t){Object.__proto__?e.__proto__=t.prototype:(o(e,t.prototype,t["native"]),e.__proto__=t.prototype)}function o(e,t,n){for(var r={},o=t;o!==n&&o!==HTMLElement.prototype;){for(var i,a=Object.getOwnPropertyNames(o),s=0;i=a[s];s++)r[i]||(Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(o,i)),r[i]=1);o=Object.getPrototypeOf(o)}}function i(e){e.createdCallback&&e.createdCallback()}var a=e.flags;e.upgrade=t,e.upgradeWithDefinition=n,e.implementPrototype=r}),CustomElements.addModule(function(e){function t(t,r){var c=r||{};if(!t)throw new Error("document.registerElement: first argument `name` must not be empty");if(t.indexOf("-")<0)throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '"+String(t)+"'.");if(o(t))throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '"+String(t)+"'. The type name is invalid.");if(l(t))throw new Error("DuplicateDefinitionError: a type with name '"+String(t)+"' is already registered");return c.prototype||(c.prototype=Object.create(HTMLElement.prototype)),c.__name=t.toLowerCase(),c.lifecycle=c.lifecycle||{},c.ancestry=i(c["extends"]),a(c),s(c),n(c.prototype),u(c.__name,c),c.ctor=d(c),c.ctor.prototype=c.prototype,c.prototype.constructor=c.ctor,e.ready&&w(document),c.ctor}function n(e){if(!e.setAttribute._polyfilled){var t=e.setAttribute;e.setAttribute=function(e,n){r.call(this,e,n,t)};var n=e.removeAttribute;e.removeAttribute=function(e){r.call(this,e,null,n)},e.setAttribute._polyfilled=!0}}function r(e,t,n){e=e.toLowerCase();var r=this.getAttribute(e);n.apply(this,arguments);var o=this.getAttribute(e);this.attributeChangedCallback&&o!==r&&this.attributeChangedCallback(e,r,o)}function o(e){for(var t=0;t=0&&b(r,HTMLElement),r)}function h(e){var t=O.call(this,e);return v(t),t}var m,w=e.upgradeDocumentTree,v=e.upgrade,g=e.upgradeWithDefinition,b=e.implementPrototype,y=e.useNative,E=["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"],S={},T="http://www.w3.org/1999/xhtml",M=document.createElement.bind(document),L=document.createElementNS.bind(document),O=Node.prototype.cloneNode;m=Object.__proto__||y?function(e,t){return e instanceof t}:function(e,t){for(var n=e;n;){if(n===t.prototype)return!0;n=n.__proto__}return!1},document.registerElement=t,document.createElement=f,document.createElementNS=p,Node.prototype.cloneNode=h,e.registry=S,e["instanceof"]=m,e.reservedTagList=E,e.getRegisteredDefinition=l,document.register=document.registerElement}),function(e){function t(){a(wrap(document)),window.HTMLImports&&(HTMLImports.__importsParsingHook=function(e){a(wrap(e["import"]))}),CustomElements.ready=!0,setTimeout(function(){CustomElements.readyTime=Date.now(),window.HTMLImports&&(CustomElements.elapsed=CustomElements.readyTime-HTMLImports.readyTime),document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0}))})}var n=e.useNative,r=e.initializeModules,o=/Trident/.test(navigator.userAgent);if(n){var i=function(){};e.watchShadow=i,e.upgrade=i,e.upgradeAll=i,e.upgradeDocumentTree=i,e.upgradeSubtree=i,e.takeRecords=i,e["instanceof"]=function(e,t){return e instanceof t}}else r();var a=e.upgradeDocumentTree;if(window.wrap||(window.ShadowDOMPolyfill?(window.wrap=ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=ShadowDOMPolyfill.unwrapIfNeeded):window.wrap=window.unwrap=function(e){return e}),o&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),n},window.CustomEvent.prototype=window.Event.prototype),"complete"===document.readyState||e.flags.eager)t();else if("interactive"!==document.readyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var s=window.HTMLImports&&!HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(s,t)}else t()}(window.CustomElements),function(){Function.prototype.bind||(Function.prototype.bind=function(e){var t=this,n=Array.prototype.slice.call(arguments,1);return function(){var r=n.slice();return r.push.apply(r,arguments),t.apply(e,r)}})}(window.WebComponents),function(e){"use strict";function t(){window.Polymer===o&&(window.Polymer=function(){throw new Error('You tried to use polymer without loading it first. To load polymer, ')})}if(!window.performance){var n=Date.now();window.performance={now:function(){return Date.now()-n}}}window.requestAnimationFrame||(window.requestAnimationFrame=function(){var e=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame;return e?function(t){return e(function(){t(performance.now())})}:function(e){return window.setTimeout(e,1e3/60)}}()),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(){return window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(e){clearTimeout(e)}}());var r=[],o=function(e){"string"!=typeof e&&1===arguments.length&&Array.prototype.push.call(arguments,document._currentScript),r.push(arguments)};window.Polymer=o,e.consumeDeclarations=function(t){e.consumeDeclarations=function(){throw"Possible attempt to load Polymer twice"},t&&t(r),r=null},HTMLImports.useNative?t():addEventListener("DOMContentLoaded",t)}(window.WebComponents),function(){var e=document.createElement("style");e.textContent="body {transition: opacity ease-in 0.2s; } \nbody[unresolved] {opacity: 0; display: block; overflow: hidden; position: relative; } \n";var t=document.querySelector("head");t.insertBefore(e,t.firstChild)}(window.WebComponents),function(e){window.Platform=e}(window.WebComponents); \ No newline at end of file +// @version 0.5.5 +window.WebComponents=window.WebComponents||{},function(e){var t=e.flags||{},n="webcomponents.js",r=document.querySelector('script[src*="'+n+'"]');if(!t.noOpts){if(location.search.slice(1).split("&").forEach(function(e){e=e.split("="),e[0]&&(t[e[0]]=e[1]||!0)}),r)for(var o,i=0;o=r.attributes[i];i++)"src"!==o.name&&(t[o.name]=o.value||!0);if(t.log){var a=t.log.split(",");t.log={},a.forEach(function(e){t.log[e]=!0})}else t.log={}}t.shadow=t.shadow||t.shadowdom||t.polyfill,t.shadow="native"===t.shadow?!1:t.shadow||!HTMLElement.prototype.createShadowRoot,t.register&&(window.CustomElements=window.CustomElements||{flags:{}},window.CustomElements.flags.register=t.register),e.flags=t}(WebComponents),WebComponents.flags.shadow&&("undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};n.prototype={set:function(t,n){var r=t[this.name];return r&&r[0]===t?r[1]=n:e(t,this.name,{value:[t,n],writable:!0}),this},get:function(e){var t;return(t=e[this.name])&&t[0]===e?t[1]:void 0},"delete":function(e){var t=e[this.name];return t&&t[0]===e?(t[0]=t[1]=void 0,!0):!1},has:function(e){var t=e[this.name];return t?t[0]===e:!1}},window.WeakMap=n}(),window.ShadowDOMPolyfill={},function(e){"use strict";function t(){if("undefined"!=typeof chrome&&chrome.app&&chrome.app.runtime)return!1;if(navigator.getDeviceStorage)return!1;try{var e=new Function("return true;");return e()}catch(t){return!1}}function n(e){if(!e)throw new Error("Assertion failed")}function r(e,t){for(var n=W(t),r=0;rl;l++)c[l]=new Array(s),c[l][0]=l;for(var u=0;s>u;u++)c[0][u]=u;for(var l=1;a>l;l++)for(var u=1;s>u;u++)if(this.equals(e[t+u-1],r[o+l-1]))c[l][u]=c[l-1][u-1];else{var d=c[l-1][u]+1,p=c[l][u-1]+1;c[l][u]=p>d?d:p}return c},spliceOperationsFromEditDistances:function(e){for(var t=e.length-1,n=e[0].length-1,s=e[t][n],c=[];t>0||n>0;)if(0!=t)if(0!=n){var l,u=e[t-1][n-1],d=e[t-1][n],p=e[t][n-1];l=p>d?u>d?d:u:u>p?p:u,l==u?(u==s?c.push(r):(c.push(o),s=u),t--,n--):l==d?(c.push(a),t--,s=d):(c.push(i),n--,s=p)}else c.push(a),t--;else c.push(i),n--;return c.reverse(),c},calcSplices:function(e,n,s,c,l,u){var d=0,p=0,f=Math.min(s-n,u-l);if(0==n&&0==l&&(d=this.sharedPrefix(e,c,f)),s==e.length&&u==c.length&&(p=this.sharedSuffix(e,c,f-d)),n+=d,l+=d,s-=p,u-=p,s-n==0&&u-l==0)return[];if(n==s){for(var h=t(n,[],0);u>l;)h.removed.push(c[l++]);return[h]}if(l==u)return[t(n,[],s-n)];for(var m=this.spliceOperationsFromEditDistances(this.calcEditDistances(e,n,s,c,l,u)),h=void 0,w=[],v=n,g=l,b=0;br;r++)if(!this.equals(e[r],t[r]))return r;return n},sharedSuffix:function(e,t,n){for(var r=e.length,o=t.length,i=0;n>i&&this.equals(e[--r],t[--o]);)i++;return i},calculateSplices:function(e,t){return this.calcSplices(e,0,e.length,t,0,t.length)},equals:function(e,t){return e===t}},e.ArraySplice=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(){a=!1;var e=i.slice(0);i=[];for(var t=0;t0){for(var u=0;u0&&r.length>0;){var i=n.pop(),a=r.pop();if(i!==a)break;o=i}return o}function u(e,t,n){t instanceof G.Window&&(t=t.document);var o,i=k(t),a=k(n),s=r(n,e),o=l(i,a);o||(o=a.root);for(var c=o;c;c=c.parent)for(var u=0;u0;i--)if(!g(t[i],e,o,t,r))return!1;return!0}function w(e,t,n,r){var o=it,i=t[0]||n;return g(i,e,o,t,r)}function v(e,t,n,r){for(var o=at,i=1;i0&&g(n,e,o,t,r)}function g(e,t,n,r,o){var i=z.get(e);if(!i)return!0;var a=o||s(r,e);if(a===e){if(n===ot)return!0;n===at&&(n=it)}else if(n===at&&!t.bubbles)return!0;if("relatedTarget"in t){var c=q(t),l=c.relatedTarget;if(l){if(l instanceof Object&&l.addEventListener){var d=V(l),p=u(t,e,d);if(p===a)return!0}else p=null;J.set(t,p)}}Z.set(t,n);var f=t.type,h=!1;X.set(t,a),$.set(t,e),i.depth++;for(var m=0,w=i.length;w>m;m++){var v=i[m];if(v.removed)h=!0;else if(!(v.type!==f||!v.capture&&n===ot||v.capture&&n===at))try{if("function"==typeof v.handler?v.handler.call(e,t):v.handler.handleEvent(t),et.get(t))return!1}catch(g){I||(I=g)}}if(i.depth--,h&&0===i.depth){var b=i.slice();i.length=0;for(var m=0;mr;r++)t[r]=a(e[r]);return t.length=o,t}function o(e,t){e.prototype[t]=function(){return r(i(this)[t].apply(i(this),arguments))}}var i=e.unsafeUnwrap,a=e.wrap,s={enumerable:!1};n.prototype={item:function(e){return this[e]}},t(n.prototype,"item"),e.wrappers.NodeList=n,e.addWrapNodeListMethod=o,e.wrapNodeList=r}(window.ShadowDOMPolyfill),function(e){"use strict";e.wrapHTMLCollection=e.wrapNodeList,e.wrappers.HTMLCollection=e.wrappers.NodeList}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){L(e instanceof S)}function n(e){var t=new M;return t[0]=e,t.length=1,t}function r(e,t,n){C(t,"childList",{removedNodes:n,previousSibling:e.previousSibling,nextSibling:e.nextSibling})}function o(e,t){C(e,"childList",{removedNodes:t})}function i(e,t,r,o){if(e instanceof DocumentFragment){var i=s(e);B=!0;for(var a=i.length-1;a>=0;a--)e.removeChild(i[a]),i[a].parentNode_=t;B=!1;for(var a=0;ao;o++)r.appendChild(I(t[o]));return r}function w(e){if(void 0!==e.firstChild_)for(var t=e.firstChild_;t;){var n=t;t=t.nextSibling_,n.parentNode_=n.previousSibling_=n.nextSibling_=void 0}e.firstChild_=e.lastChild_=void 0}function v(e){if(e.invalidateShadowRenderer()){for(var t=e.firstChild;t;){L(t.parentNode===e);var n=t.nextSibling,r=I(t),o=r.parentNode;o&&Y.call(o,r),t.previousSibling_=t.nextSibling_=t.parentNode_=null,t=n}e.firstChild_=e.lastChild_=null}else for(var n,i=I(e),a=i.firstChild;a;)n=a.nextSibling,Y.call(i,a),a=n}function g(e){var t=e.parentNode;return t&&t.invalidateShadowRenderer()}function b(e){for(var t,n=0;ns;s++)i=b(t[s]),!o&&(a=v(i).root)&&a instanceof e.wrappers.ShadowRoot||(r[n++]=i);return n}function n(e){return String(e).replace(/\/deep\/|::shadow/g," ")}function r(e){return String(e).replace(/:host\(([^\s]+)\)/g,"$1").replace(/([^\s]):host/g,"$1").replace(":host","*").replace(/\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content/g," ")}function o(e,t){for(var n,r=e.firstElementChild;r;){if(r.matches(t))return r;if(n=o(r,t))return n;r=r.nextElementSibling}return null}function i(e,t){return e.matches(t)}function a(e,t,n){var r=e.localName;return r===t||r===n&&e.namespaceURI===D}function s(){return!0}function c(e,t,n){return e.localName===n}function l(e,t){return e.namespaceURI===t}function u(e,t,n){return e.namespaceURI===t&&e.localName===n}function d(e,t,n,r,o,i){for(var a=e.firstElementChild;a;)r(a,o,i)&&(n[t++]=a),t=d(a,t,n,r,o,i),a=a.nextElementSibling;return t}function p(n,r,o,i,a){var s,c=g(this),l=v(this).root;if(l instanceof e.wrappers.ShadowRoot)return d(this,r,o,n,i,null);if(c instanceof C)s=T.call(c,i);else{if(!(c instanceof N))return d(this,r,o,n,i,null);s=S.call(c,i)}return t(s,r,o,a)}function f(n,r,o,i,a){var s,c=g(this),l=v(this).root;if(l instanceof e.wrappers.ShadowRoot)return d(this,r,o,n,i,a);if(c instanceof C)s=_.call(c,i,a);else{if(!(c instanceof N))return d(this,r,o,n,i,a);s=M.call(c,i,a)}return t(s,r,o,!1)}function h(n,r,o,i,a){var s,c=g(this),l=v(this).root;if(l instanceof e.wrappers.ShadowRoot)return d(this,r,o,n,i,a);if(c instanceof C)s=O.call(c,i,a);else{if(!(c instanceof N))return d(this,r,o,n,i,a);s=L.call(c,i,a)}return t(s,r,o,!1)}var m=e.wrappers.HTMLCollection,w=e.wrappers.NodeList,v=e.getTreeScope,g=e.unsafeUnwrap,b=e.wrap,y=document.querySelector,E=document.documentElement.querySelector,S=document.querySelectorAll,T=document.documentElement.querySelectorAll,M=document.getElementsByTagName,_=document.documentElement.getElementsByTagName,L=document.getElementsByTagNameNS,O=document.documentElement.getElementsByTagNameNS,C=window.Element,N=window.HTMLDocument||window.Document,D="http://www.w3.org/1999/xhtml",j={querySelector:function(t){var r=n(t),i=r!==t;t=r;var a,s=g(this),c=v(this).root;if(c instanceof e.wrappers.ShadowRoot)return o(this,t);if(s instanceof C)a=b(E.call(s,t));else{if(!(s instanceof N))return o(this,t);a=b(y.call(s,t))}return a&&!i&&(c=v(a).root)&&c instanceof e.wrappers.ShadowRoot?o(this,t):a},querySelectorAll:function(e){var t=n(e),r=t!==e;e=t;var o=new w;return o.length=p.call(this,i,0,o,e,r),o +}},H={matches:function(t){return t=r(t),e.originalMatches.call(g(this),t)}},x={getElementsByTagName:function(e){var t=new m,n="*"===e?s:a;return t.length=f.call(this,n,0,t,e,e.toLowerCase()),t},getElementsByClassName:function(e){return this.querySelectorAll("."+e)},getElementsByTagNameNS:function(e,t){var n=new m,r=null;return r="*"===e?"*"===t?s:c:"*"===t?l:u,n.length=h.call(this,r,0,n,e||null,t),n}};e.GetElementsByInterface=x,e.SelectorsInterface=j,e.MatchesInterface=H}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.nextSibling;return e}function n(e){for(;e&&e.nodeType!==Node.ELEMENT_NODE;)e=e.previousSibling;return e}var r=e.wrappers.NodeList,o={get firstElementChild(){return t(this.firstChild)},get lastElementChild(){return n(this.lastChild)},get childElementCount(){for(var e=0,t=this.firstElementChild;t;t=t.nextElementSibling)e++;return e},get children(){for(var e=new r,t=0,n=this.firstElementChild;n;n=n.nextElementSibling)e[t++]=n;return e.length=t,e},remove:function(){var e=this.parentNode;e&&e.removeChild(this)}},i={get nextElementSibling(){return t(this.nextSibling)},get previousElementSibling(){return n(this.previousSibling)}};e.ChildNodeInterface=i,e.ParentNodeInterface=o}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}var n=e.ChildNodeInterface,r=e.wrappers.Node,o=e.enqueueMutation,i=e.mixin,a=e.registerWrapper,s=e.unsafeUnwrap,c=window.CharacterData;t.prototype=Object.create(r.prototype),i(t.prototype,{get textContent(){return this.data},set textContent(e){this.data=e},get data(){return s(this).data},set data(e){var t=s(this).data;o(this,"characterData",{oldValue:t}),s(this).data=e}}),i(t.prototype,n),a(c,t,document.createTextNode("")),e.wrappers.CharacterData=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e>>>0}function n(e){r.call(this,e)}var r=e.wrappers.CharacterData,o=(e.enqueueMutation,e.mixin),i=e.registerWrapper,a=window.Text;n.prototype=Object.create(r.prototype),o(n.prototype,{splitText:function(e){e=t(e);var n=this.data;if(e>n.length)throw new Error("IndexSizeError");var r=n.slice(0,e),o=n.slice(e);this.data=r;var i=this.ownerDocument.createTextNode(o);return this.parentNode&&this.parentNode.insertBefore(i,this.nextSibling),i}}),i(a,n,document.createTextNode("")),e.wrappers.Text=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return i(e).getAttribute("class")}function n(e,t){a(e,"attributes",{name:"class",namespace:null,oldValue:t})}function r(t){e.invalidateRendererBasedOnAttribute(t,"class")}function o(e,o,i){var a=e.ownerElement_;if(null==a)return o.apply(e,i);var s=t(a),c=o.apply(e,i);return t(a)!==s&&(n(a,s),r(a)),c}if(!window.DOMTokenList)return void console.warn("Missing DOMTokenList prototype, please include a compatible classList polyfill such as http://goo.gl/uTcepH.");var i=e.unsafeUnwrap,a=e.enqueueMutation,s=DOMTokenList.prototype.add;DOMTokenList.prototype.add=function(){o(this,s,arguments)};var c=DOMTokenList.prototype.remove;DOMTokenList.prototype.remove=function(){o(this,c,arguments)};var l=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(){return o(this,l,arguments)}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(t,n){var r=t.parentNode;if(r&&r.shadowRoot){var o=e.getRendererForHost(r);o.dependsOnAttribute(n)&&o.invalidate()}}function n(e,t,n){u(e,"attributes",{name:t,namespace:null,oldValue:n})}function r(e){a.call(this,e)}var o=e.ChildNodeInterface,i=e.GetElementsByInterface,a=e.wrappers.Node,s=e.ParentNodeInterface,c=e.SelectorsInterface,l=e.MatchesInterface,u=(e.addWrapNodeListMethod,e.enqueueMutation),d=e.mixin,p=(e.oneOf,e.registerWrapper),f=e.unsafeUnwrap,h=e.wrappers,m=window.Element,w=["matches","mozMatchesSelector","msMatchesSelector","webkitMatchesSelector"].filter(function(e){return m.prototype[e]}),v=w[0],g=m.prototype[v],b=new WeakMap;r.prototype=Object.create(a.prototype),d(r.prototype,{createShadowRoot:function(){var t=new h.ShadowRoot(this);f(this).polymerShadowRoot_=t;var n=e.getRendererForHost(this);return n.invalidate(),t},get shadowRoot(){return f(this).polymerShadowRoot_||null},setAttribute:function(e,r){var o=f(this).getAttribute(e);f(this).setAttribute(e,r),n(this,e,o),t(this,e)},removeAttribute:function(e){var r=f(this).getAttribute(e);f(this).removeAttribute(e),n(this,e,r),t(this,e)},get classList(){var e=b.get(this);if(!e){if(e=f(this).classList,!e)return;e.ownerElement_=this,b.set(this,e)}return e},get className(){return f(this).className},set className(e){this.setAttribute("class",e)},get id(){return f(this).id},set id(e){this.setAttribute("id",e)}}),w.forEach(function(e){"matches"!==e&&(r.prototype[e]=function(e){return this.matches(e)})}),m.prototype.webkitCreateShadowRoot&&(r.prototype.webkitCreateShadowRoot=r.prototype.createShadowRoot),d(r.prototype,o),d(r.prototype,i),d(r.prototype,s),d(r.prototype,c),d(r.prototype,l),p(m,r,document.createElementNS(null,"x")),e.invalidateRendererBasedOnAttribute=t,e.matchesNames=w,e.originalMatches=g,e.wrappers.Element=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case" ":return" "}}function n(e){return e.replace(L,t)}function r(e){return e.replace(O,t)}function o(e){for(var t={},n=0;n";case Node.TEXT_NODE:var u=e.data;return t&&N[t.localName]?u:r(u);case Node.COMMENT_NODE:return"";default:throw console.error(e),new Error("not implemented")}}function a(e){e instanceof _.HTMLTemplateElement&&(e=e.content);for(var t="",n=e.firstChild;n;n=n.nextSibling)t+=i(n,e);return t}function s(e,t,n){var r=n||"div";e.textContent="";var o=T(e.ownerDocument.createElement(r));o.innerHTML=t;for(var i;i=o.firstChild;)e.appendChild(M(i))}function c(e){h.call(this,e)}function l(e,t){var n=T(e.cloneNode(!1));n.innerHTML=t;for(var r,o=T(document.createDocumentFragment());r=n.firstChild;)o.appendChild(r);return M(o)}function u(t){return function(){return e.renderAllPending(),S(this)[t]}}function d(e){m(c,e,u(e))}function p(t){Object.defineProperty(c.prototype,t,{get:u(t),set:function(n){e.renderAllPending(),S(this)[t]=n},configurable:!0,enumerable:!0})}function f(t){Object.defineProperty(c.prototype,t,{value:function(){return e.renderAllPending(),S(this)[t].apply(S(this),arguments)},configurable:!0,enumerable:!0})}var h=e.wrappers.Element,m=e.defineGetter,w=e.enqueueMutation,v=e.mixin,g=e.nodesWereAdded,b=e.nodesWereRemoved,y=e.registerWrapper,E=e.snapshotNodeList,S=e.unsafeUnwrap,T=e.unwrap,M=e.wrap,_=e.wrappers,L=/[&\u00A0"]/g,O=/[&\u00A0<>]/g,C=o(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),N=o(["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"]),D=/MSIE/.test(navigator.userAgent),j=window.HTMLElement,H=window.HTMLTemplateElement;c.prototype=Object.create(h.prototype),v(c.prototype,{get innerHTML(){return a(this)},set innerHTML(e){if(D&&N[this.localName])return void(this.textContent=e);var t=E(this.childNodes);this.invalidateShadowRenderer()?this instanceof _.HTMLTemplateElement?s(this.content,e):s(this,e,this.tagName):!H&&this instanceof _.HTMLTemplateElement?s(this.content,e):S(this).innerHTML=e;var n=E(this.childNodes);w(this,"childList",{addedNodes:n,removedNodes:t}),b(t),g(n,this)},get outerHTML(){return i(this,this.parentNode)},set outerHTML(e){var t=this.parentNode;if(t){t.invalidateShadowRenderer();var n=l(t,e);t.replaceChild(n,this)}},insertAdjacentHTML:function(e,t){var n,r;switch(String(e).toLowerCase()){case"beforebegin":n=this.parentNode,r=this;break;case"afterend":n=this.parentNode,r=this.nextSibling;break;case"afterbegin":n=this,r=this.firstChild;break;case"beforeend":n=this,r=null;break;default:return}var o=l(n,t);n.insertBefore(o,r)},get hidden(){return this.hasAttribute("hidden")},set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}}),["clientHeight","clientLeft","clientTop","clientWidth","offsetHeight","offsetLeft","offsetTop","offsetWidth","scrollHeight","scrollWidth"].forEach(d),["scrollLeft","scrollTop"].forEach(p),["getBoundingClientRect","getClientRects","scrollIntoView"].forEach(f),y(j,c,document.createElement("b")),e.wrappers.HTMLElement=c,e.getInnerHTML=a,e.setInnerHTML=s}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unsafeUnwrap,a=e.wrap,s=window.HTMLCanvasElement;t.prototype=Object.create(n.prototype),r(t.prototype,{getContext:function(){var e=i(this).getContext.apply(i(this),arguments);return e&&a(e)}}),o(s,t,document.createElement("canvas")),e.wrappers.HTMLCanvasElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=window.HTMLContentElement;t.prototype=Object.create(n.prototype),r(t.prototype,{constructor:t,get select(){return this.getAttribute("select")},set select(e){this.setAttribute("select",e)},setAttribute:function(e,t){n.prototype.setAttribute.call(this,e,t),"select"===String(e).toLowerCase()&&this.invalidateShadowRenderer(!0)}}),i&&o(i,t),e.wrappers.HTMLContentElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=window.HTMLFormElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get elements(){return i(a(this).elements)}}),o(s,t,document.createElement("form")),e.wrappers.HTMLFormElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}function n(e,t){if(!(this instanceof n))throw new TypeError("DOM object constructor cannot be called as a function.");var o=i(document.createElement("img"));r.call(this,o),a(o,this),void 0!==e&&(o.width=e),void 0!==t&&(o.height=t)}var r=e.wrappers.HTMLElement,o=e.registerWrapper,i=e.unwrap,a=e.rewrap,s=window.HTMLImageElement;t.prototype=Object.create(r.prototype),o(s,t,document.createElement("img")),n.prototype=t.prototype,e.wrappers.HTMLImageElement=t,e.wrappers.Image=n}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=(e.mixin,e.wrappers.NodeList,e.registerWrapper),o=window.HTMLShadowElement;t.prototype=Object.create(n.prototype),t.prototype.constructor=t,o&&r(o,t),e.wrappers.HTMLShadowElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){if(!e.defaultView)return e;var t=d.get(e);if(!t){for(t=e.implementation.createHTMLDocument("");t.lastChild;)t.removeChild(t.lastChild);d.set(e,t)}return t}function n(e){for(var n,r=t(e.ownerDocument),o=c(r.createDocumentFragment());n=e.firstChild;)o.appendChild(n);return o}function r(e){if(o.call(this,e),!p){var t=n(e);u.set(this,l(t))}}var o=e.wrappers.HTMLElement,i=e.mixin,a=e.registerWrapper,s=e.unsafeUnwrap,c=e.unwrap,l=e.wrap,u=new WeakMap,d=new WeakMap,p=window.HTMLTemplateElement;r.prototype=Object.create(o.prototype),i(r.prototype,{constructor:r,get content(){return p?l(s(this).content):u.get(this)}}),p&&a(p,r),e.wrappers.HTMLTemplateElement=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.registerWrapper,o=window.HTMLMediaElement;o&&(t.prototype=Object.create(n.prototype),r(o,t,document.createElement("audio")),e.wrappers.HTMLMediaElement=t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r.call(this,e)}function n(e){if(!(this instanceof n))throw new TypeError("DOM object constructor cannot be called as a function.");var t=i(document.createElement("audio"));r.call(this,t),a(t,this),t.setAttribute("preload","auto"),void 0!==e&&t.setAttribute("src",e)}var r=e.wrappers.HTMLMediaElement,o=e.registerWrapper,i=e.unwrap,a=e.rewrap,s=window.HTMLAudioElement;s&&(t.prototype=Object.create(r.prototype),o(s,t,document.createElement("audio")),n.prototype=t.prototype,e.wrappers.HTMLAudioElement=t,e.wrappers.Audio=n)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){return e.replace(/\s+/g," ").trim()}function n(e){o.call(this,e)}function r(e,t,n,i){if(!(this instanceof r))throw new TypeError("DOM object constructor cannot be called as a function.");var a=c(document.createElement("option"));o.call(this,a),s(a,this),void 0!==e&&(a.text=e),void 0!==t&&a.setAttribute("value",t),n===!0&&a.setAttribute("selected",""),a.selected=i===!0}var o=e.wrappers.HTMLElement,i=e.mixin,a=e.registerWrapper,s=e.rewrap,c=e.unwrap,l=e.wrap,u=window.HTMLOptionElement;n.prototype=Object.create(o.prototype),i(n.prototype,{get text(){return t(this.textContent)},set text(e){this.textContent=t(String(e))},get form(){return l(c(this).form)}}),a(u,n,document.createElement("option")),r.prototype=n.prototype,e.wrappers.HTMLOptionElement=n,e.wrappers.Option=r}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unwrap,a=e.wrap,s=window.HTMLSelectElement;t.prototype=Object.create(n.prototype),r(t.prototype,{add:function(e,t){"object"==typeof t&&(t=i(t)),i(this).add(i(e),t)},remove:function(e){return void 0===e?void n.prototype.remove.call(this):("object"==typeof e&&(e=i(e)),void i(this).remove(e))},get form(){return a(i(this).form)}}),o(s,t,document.createElement("select")),e.wrappers.HTMLSelectElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.unwrap,a=e.wrap,s=e.wrapHTMLCollection,c=window.HTMLTableElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get caption(){return a(i(this).caption)},createCaption:function(){return a(i(this).createCaption())},get tHead(){return a(i(this).tHead)},createTHead:function(){return a(i(this).createTHead())},createTFoot:function(){return a(i(this).createTFoot())},get tFoot(){return a(i(this).tFoot)},get tBodies(){return s(i(this).tBodies)},createTBody:function(){return a(i(this).createTBody())},get rows(){return s(i(this).rows)},insertRow:function(e){return a(i(this).insertRow(e))}}),o(c,t,document.createElement("table")),e.wrappers.HTMLTableElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=e.wrap,c=window.HTMLTableSectionElement;t.prototype=Object.create(n.prototype),r(t.prototype,{constructor:t,get rows(){return i(a(this).rows)},insertRow:function(e){return s(a(this).insertRow(e))}}),o(c,t,document.createElement("thead")),e.wrappers.HTMLTableSectionElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.HTMLElement,r=e.mixin,o=e.registerWrapper,i=e.wrapHTMLCollection,a=e.unwrap,s=e.wrap,c=window.HTMLTableRowElement;t.prototype=Object.create(n.prototype),r(t.prototype,{get cells(){return i(a(this).cells)},insertCell:function(e){return s(a(this).insertCell(e))}}),o(c,t,document.createElement("tr")),e.wrappers.HTMLTableRowElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){switch(e.localName){case"content":return new n(e);case"shadow":return new o(e);case"template":return new i(e)}r.call(this,e)}var n=e.wrappers.HTMLContentElement,r=e.wrappers.HTMLElement,o=e.wrappers.HTMLShadowElement,i=e.wrappers.HTMLTemplateElement,a=(e.mixin,e.registerWrapper),s=window.HTMLUnknownElement;t.prototype=Object.create(r.prototype),a(s,t),e.wrappers.HTMLUnknownElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.wrappers.Element,n=e.wrappers.HTMLElement,r=e.registerObject,o=e.defineWrapGetter,i="http://www.w3.org/2000/svg",a=document.createElementNS(i,"title"),s=r(a),c=Object.getPrototypeOf(s.prototype).constructor;if(!("classList"in a)){var l=Object.getOwnPropertyDescriptor(t.prototype,"classList");Object.defineProperty(n.prototype,"classList",l),delete t.prototype.classList}o(c,"ownerSVGElement"),e.wrappers.SVGElement=c}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){p.call(this,e)}var n=e.mixin,r=e.registerWrapper,o=e.unwrap,i=e.wrap,a=window.SVGUseElement,s="http://www.w3.org/2000/svg",c=i(document.createElementNS(s,"g")),l=document.createElementNS(s,"use"),u=c.constructor,d=Object.getPrototypeOf(u.prototype),p=d.constructor;t.prototype=Object.create(d),"instanceRoot"in l&&n(t.prototype,{get instanceRoot(){return i(o(this).instanceRoot)},get animatedInstanceRoot(){return i(o(this).animatedInstanceRoot)}}),r(a,t,l),e.wrappers.SVGUseElement=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.mixin,o=e.registerWrapper,i=e.unsafeUnwrap,a=e.wrap,s=window.SVGElementInstance;s&&(t.prototype=Object.create(n.prototype),r(t.prototype,{get correspondingElement(){return a(i(this).correspondingElement)},get correspondingUseElement(){return a(i(this).correspondingUseElement)},get parentNode(){return a(i(this).parentNode)},get childNodes(){throw new Error("Not implemented")},get firstChild(){return a(i(this).firstChild)},get lastChild(){return a(i(this).lastChild)},get previousSibling(){return a(i(this).previousSibling)},get nextSibling(){return a(i(this).nextSibling)}}),o(s,t),e.wrappers.SVGElementInstance=t)}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){o(e,this)}var n=e.mixin,r=e.registerWrapper,o=e.setWrapper,i=e.unsafeUnwrap,a=e.unwrap,s=e.unwrapIfNeeded,c=e.wrap,l=window.CanvasRenderingContext2D;n(t.prototype,{get canvas(){return c(i(this).canvas)},drawImage:function(){arguments[0]=s(arguments[0]),i(this).drawImage.apply(i(this),arguments)},createPattern:function(){return arguments[0]=a(arguments[0]),i(this).createPattern.apply(i(this),arguments)}}),r(l,t,document.createElement("canvas").getContext("2d")),e.wrappers.CanvasRenderingContext2D=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){o(e,this)}var n=e.mixin,r=e.registerWrapper,o=e.setWrapper,i=e.unsafeUnwrap,a=e.unwrapIfNeeded,s=e.wrap,c=window.WebGLRenderingContext;if(c){n(t.prototype,{get canvas(){return s(i(this).canvas)},texImage2D:function(){arguments[5]=a(arguments[5]),i(this).texImage2D.apply(i(this),arguments)},texSubImage2D:function(){arguments[6]=a(arguments[6]),i(this).texSubImage2D.apply(i(this),arguments)}});var l=/WebKit/.test(navigator.userAgent)?{drawingBufferHeight:null,drawingBufferWidth:null}:{};r(c,t,l),e.wrappers.WebGLRenderingContext=t}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){r(e,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unsafeUnwrap,i=e.unwrap,a=e.unwrapIfNeeded,s=e.wrap,c=window.Range;t.prototype={get startContainer(){return s(o(this).startContainer)},get endContainer(){return s(o(this).endContainer)},get commonAncestorContainer(){return s(o(this).commonAncestorContainer)},setStart:function(e,t){o(this).setStart(a(e),t)},setEnd:function(e,t){o(this).setEnd(a(e),t)},setStartBefore:function(e){o(this).setStartBefore(a(e))},setStartAfter:function(e){o(this).setStartAfter(a(e))},setEndBefore:function(e){o(this).setEndBefore(a(e))},setEndAfter:function(e){o(this).setEndAfter(a(e))},selectNode:function(e){o(this).selectNode(a(e))},selectNodeContents:function(e){o(this).selectNodeContents(a(e))},compareBoundaryPoints:function(e,t){return o(this).compareBoundaryPoints(e,i(t))},extractContents:function(){return s(o(this).extractContents())},cloneContents:function(){return s(o(this).cloneContents())},insertNode:function(e){o(this).insertNode(a(e))},surroundContents:function(e){o(this).surroundContents(a(e))},cloneRange:function(){return s(o(this).cloneRange())},isPointInRange:function(e,t){return o(this).isPointInRange(a(e),t)},comparePoint:function(e,t){return o(this).comparePoint(a(e),t)},intersectsNode:function(e){return o(this).intersectsNode(a(e))},toString:function(){return o(this).toString()}},c.prototype.createContextualFragment&&(t.prototype.createContextualFragment=function(e){return s(o(this).createContextualFragment(e))}),n(window.Range,t,document.createRange()),e.wrappers.Range=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.GetElementsByInterface,n=e.ParentNodeInterface,r=e.SelectorsInterface,o=e.mixin,i=e.registerObject,a=i(document.createDocumentFragment());o(a.prototype,n),o(a.prototype,r),o(a.prototype,t);var s=i(document.createComment(""));e.wrappers.Comment=s,e.wrappers.DocumentFragment=a}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=d(u(e).ownerDocument.createDocumentFragment());n.call(this,t),c(t,this);var o=e.shadowRoot;f.set(this,o),this.treeScope_=new r(this,a(o||e)),p.set(this,e)}var n=e.wrappers.DocumentFragment,r=e.TreeScope,o=e.elementFromPoint,i=e.getInnerHTML,a=e.getTreeScope,s=e.mixin,c=e.rewrap,l=e.setInnerHTML,u=e.unsafeUnwrap,d=e.unwrap,p=new WeakMap,f=new WeakMap,h=/[ \t\n\r\f]/;t.prototype=Object.create(n.prototype),s(t.prototype,{constructor:t,get innerHTML(){return i(this)},set innerHTML(e){l(this,e),this.invalidateShadowRenderer()},get olderShadowRoot(){return f.get(this)||null},get host(){return p.get(this)||null},invalidateShadowRenderer:function(){return p.get(this).invalidateShadowRenderer()},elementFromPoint:function(e,t){return o(this,this.ownerDocument,e,t)},getElementById:function(e){return h.test(e)?null:this.querySelector('[id="'+e+'"]')}}),e.wrappers.ShadowRoot=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){e.previousSibling_=e.previousSibling,e.nextSibling_=e.nextSibling,e.parentNode_=e.parentNode}function n(n,o,i){var a=x(n),s=x(o),c=i?x(i):null;if(r(o),t(o),i)n.firstChild===i&&(n.firstChild_=i),i.previousSibling_=i.previousSibling;else{n.lastChild_=n.lastChild,n.lastChild===n.firstChild&&(n.firstChild_=n.firstChild);var l=R(a.lastChild);l&&(l.nextSibling_=l.nextSibling)}e.originalInsertBefore.call(a,s,c)}function r(n){var r=x(n),o=r.parentNode;if(o){var i=R(o);t(n),n.previousSibling&&(n.previousSibling.nextSibling_=n),n.nextSibling&&(n.nextSibling.previousSibling_=n),i.lastChild===n&&(i.lastChild_=n),i.firstChild===n&&(i.firstChild_=n),e.originalRemoveChild.call(o,r)}}function o(e){I.set(e,[])}function i(e){var t=I.get(e);return t||I.set(e,t=[]),t}function a(e){for(var t=[],n=0,r=e.firstChild;r;r=r.nextSibling)t[n++]=r;return t}function s(){for(var e=0;em;m++){var w=R(i[u++]);s.get(w)||r(w)}for(var v=f.addedCount,g=i[u]&&R(i[u]),m=0;v>m;m++){var b=o[l++],y=b.node;n(t,y,g),s.set(y,!0),b.sync(s)}d+=v}for(var p=d;p=0;o--){var i=r[o],a=m(i);if(a){var s=i.olderShadowRoot;s&&(n=h(s));for(var c=0;c=0;u--)l=Object.create(l);["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"].forEach(function(e){var t=o[e];t&&(l[e]=function(){C(this)instanceof r||M(this),t.apply(C(this),arguments)})});var d={prototype:l};i&&(d["extends"]=i),r.prototype=o,r.prototype.constructor=r,e.constructorTable.set(l,r),e.nativePrototypeTable.set(o,l);x.call(O(this),t,d);return r},b([window.HTMLDocument||window.Document],["registerElement"])}b([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement,window.HTMLHtmlElement],["appendChild","compareDocumentPosition","contains","getElementsByClassName","getElementsByTagName","getElementsByTagNameNS","insertBefore","querySelector","querySelectorAll","removeChild","replaceChild"]),b([window.HTMLBodyElement,window.HTMLHeadElement,window.HTMLHtmlElement],y),b([window.HTMLDocument||window.Document],["adoptNode","importNode","contains","createComment","createDocumentFragment","createElement","createElementNS","createEvent","createEventNS","createRange","createTextNode","elementFromPoint","getElementById","getElementsByName","getSelection"]),E(t.prototype,l),E(t.prototype,d),E(t.prototype,f),E(t.prototype,{get implementation(){var e=D.get(this); +return e?e:(e=new a(O(this).implementation),D.set(this,e),e)},get defaultView(){return C(O(this).defaultView)}}),S(window.Document,t,document.implementation.createHTMLDocument("")),window.HTMLDocument&&S(window.HTMLDocument,t),N([window.HTMLBodyElement,window.HTMLDocument||window.Document,window.HTMLHeadElement]),s(a,"createDocumentType"),s(a,"createDocument"),s(a,"createHTMLDocument"),c(a,"hasFeature"),S(window.DOMImplementation,a),b([window.DOMImplementation],["createDocumentType","createDocument","createHTMLDocument","hasFeature"]),e.adoptNodeNoRemove=r,e.wrappers.DOMImplementation=a,e.wrappers.Document=t}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){n.call(this,e)}var n=e.wrappers.EventTarget,r=e.wrappers.Selection,o=e.mixin,i=e.registerWrapper,a=e.renderAllPending,s=e.unwrap,c=e.unwrapIfNeeded,l=e.wrap,u=window.Window,d=window.getComputedStyle,p=window.getDefaultComputedStyle,f=window.getSelection;t.prototype=Object.create(n.prototype),u.prototype.getComputedStyle=function(e,t){return l(this||window).getComputedStyle(c(e),t)},p&&(u.prototype.getDefaultComputedStyle=function(e,t){return l(this||window).getDefaultComputedStyle(c(e),t)}),u.prototype.getSelection=function(){return l(this||window).getSelection()},delete window.getComputedStyle,delete window.getDefaultComputedStyle,delete window.getSelection,["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){u.prototype[e]=function(){var t=l(this||window);return t[e].apply(t,arguments)},delete window[e]}),o(t.prototype,{getComputedStyle:function(e,t){return a(),d.call(s(this),c(e),t)},getSelection:function(){return a(),new r(f.call(s(this)))},get document(){return l(s(this).document)}}),p&&(t.prototype.getDefaultComputedStyle=function(e,t){return a(),p.call(s(this),c(e),t)}),i(u,t,window),e.wrappers.Window=t}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.unwrap,n=window.DataTransfer||window.Clipboard,r=n.prototype.setDragImage;r&&(n.prototype.setDragImage=function(e,n,o){r.call(this,t(e),n,o)})}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t;t=e instanceof i?e:new i(e&&o(e)),r(t,this)}var n=e.registerWrapper,r=e.setWrapper,o=e.unwrap,i=window.FormData;i&&(n(i,t,new i),e.wrappers.FormData=t)}(window.ShadowDOMPolyfill),function(e){"use strict";var t=e.unwrapIfNeeded,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(e){return n.call(this,t(e))}}(window.ShadowDOMPolyfill),function(e){"use strict";function t(e){var t=n[e],r=window[t];if(r){var o=document.createElement(e),i=o.constructor;window[t]=i}}var n=(e.isWrapperFor,{a:"HTMLAnchorElement",area:"HTMLAreaElement",audio:"HTMLAudioElement",base:"HTMLBaseElement",body:"HTMLBodyElement",br:"HTMLBRElement",button:"HTMLButtonElement",canvas:"HTMLCanvasElement",caption:"HTMLTableCaptionElement",col:"HTMLTableColElement",content:"HTMLContentElement",data:"HTMLDataElement",datalist:"HTMLDataListElement",del:"HTMLModElement",dir:"HTMLDirectoryElement",div:"HTMLDivElement",dl:"HTMLDListElement",embed:"HTMLEmbedElement",fieldset:"HTMLFieldSetElement",font:"HTMLFontElement",form:"HTMLFormElement",frame:"HTMLFrameElement",frameset:"HTMLFrameSetElement",h1:"HTMLHeadingElement",head:"HTMLHeadElement",hr:"HTMLHRElement",html:"HTMLHtmlElement",iframe:"HTMLIFrameElement",img:"HTMLImageElement",input:"HTMLInputElement",keygen:"HTMLKeygenElement",label:"HTMLLabelElement",legend:"HTMLLegendElement",li:"HTMLLIElement",link:"HTMLLinkElement",map:"HTMLMapElement",marquee:"HTMLMarqueeElement",menu:"HTMLMenuElement",menuitem:"HTMLMenuItemElement",meta:"HTMLMetaElement",meter:"HTMLMeterElement",object:"HTMLObjectElement",ol:"HTMLOListElement",optgroup:"HTMLOptGroupElement",option:"HTMLOptionElement",output:"HTMLOutputElement",p:"HTMLParagraphElement",param:"HTMLParamElement",pre:"HTMLPreElement",progress:"HTMLProgressElement",q:"HTMLQuoteElement",script:"HTMLScriptElement",select:"HTMLSelectElement",shadow:"HTMLShadowElement",source:"HTMLSourceElement",span:"HTMLSpanElement",style:"HTMLStyleElement",table:"HTMLTableElement",tbody:"HTMLTableSectionElement",template:"HTMLTemplateElement",textarea:"HTMLTextAreaElement",thead:"HTMLTableSectionElement",time:"HTMLTimeElement",title:"HTMLTitleElement",tr:"HTMLTableRowElement",track:"HTMLTrackElement",ul:"HTMLUListElement",video:"HTMLVideoElement"});Object.keys(n).forEach(t),Object.getOwnPropertyNames(e.wrappers).forEach(function(t){window[t]=e.wrappers[t]})}(window.ShadowDOMPolyfill),function(e){function t(e,t){var n="";return Array.prototype.forEach.call(e,function(e){n+=e.textContent+"\n\n"}),t||(n=n.replace(d,"")),n}function n(e){var t=document.createElement("style");return t.textContent=e,t}function r(e){var t=n(e);document.head.appendChild(t);var r=[];if(t.sheet)try{r=t.sheet.cssRules}catch(o){}else console.warn("sheet not found",t);return t.parentNode.removeChild(t),r}function o(){N.initialized=!0,document.body.appendChild(N);var e=N.contentDocument,t=e.createElement("base");t.href=document.baseURI,e.head.appendChild(t)}function i(e){N.initialized||o(),document.body.appendChild(N),e(N.contentDocument),document.body.removeChild(N)}function a(e,t){if(t){var o;if(e.match("@import")&&j){var a=n(e);i(function(e){e.head.appendChild(a.impl),o=Array.prototype.slice.call(a.sheet.cssRules,0),t(o)})}else o=r(e),t(o)}}function s(e){e&&l().appendChild(document.createTextNode(e))}function c(e,t){var r=n(e);r.setAttribute(t,""),r.setAttribute(x,""),document.head.appendChild(r)}function l(){return D||(D=document.createElement("style"),D.setAttribute(x,""),D[x]=!0),D}var u={strictStyling:!1,registry:{},shimStyling:function(e,n,r){var o=this.prepareRoot(e,n,r),i=this.isTypeExtension(r),a=this.makeScopeSelector(n,i),s=t(o,!0);s=this.scopeCssText(s,a),e&&(e.shimmedStyle=s),this.addCssToDocument(s,n)},shimStyle:function(e,t){return this.shimCssText(e.textContent,t)},shimCssText:function(e,t){return e=this.insertDirectives(e),this.scopeCssText(e,t)},makeScopeSelector:function(e,t){return e?t?"[is="+e+"]":e:""},isTypeExtension:function(e){return e&&e.indexOf("-")<0},prepareRoot:function(e,t,n){var r=this.registerRoot(e,t,n);return this.replaceTextInStyles(r.rootStyles,this.insertDirectives),this.removeStyles(e,r.rootStyles),this.strictStyling&&this.applyScopeToContent(e,t),r.scopeStyles},removeStyles:function(e,t){for(var n,r=0,o=t.length;o>r&&(n=t[r]);r++)n.parentNode.removeChild(n)},registerRoot:function(e,t,n){var r=this.registry[t]={root:e,name:t,extendsName:n},o=this.findStyles(e);r.rootStyles=o,r.scopeStyles=r.rootStyles;var i=this.registry[r.extendsName];return i&&(r.scopeStyles=i.scopeStyles.concat(r.scopeStyles)),r},findStyles:function(e){if(!e)return[];var t=e.querySelectorAll("style");return Array.prototype.filter.call(t,function(e){return!e.hasAttribute(R)})},applyScopeToContent:function(e,t){e&&(Array.prototype.forEach.call(e.querySelectorAll("*"),function(e){e.setAttribute(t,"")}),Array.prototype.forEach.call(e.querySelectorAll("template"),function(e){this.applyScopeToContent(e.content,t)},this))},insertDirectives:function(e){return e=this.insertPolyfillDirectivesInCssText(e),this.insertPolyfillRulesInCssText(e)},insertPolyfillDirectivesInCssText:function(e){return e=e.replace(p,function(e,t){return t.slice(0,-2)+"{"}),e.replace(f,function(e,t){return t+" {"})},insertPolyfillRulesInCssText:function(e){return e=e.replace(h,function(e,t){return t.slice(0,-1)}),e.replace(m,function(e,t,n,r){var o=e.replace(t,"").replace(n,"");return r+o})},scopeCssText:function(e,t){var n=this.extractUnscopedRulesFromCssText(e);if(e=this.insertPolyfillHostInCssText(e),e=this.convertColonHost(e),e=this.convertColonHostContext(e),e=this.convertShadowDOMSelectors(e),t){var e,r=this;a(e,function(n){e=r.scopeRules(n,t)})}return e=e+"\n"+n,e.trim()},extractUnscopedRulesFromCssText:function(e){for(var t,n="";t=w.exec(e);)n+=t[1].slice(0,-1)+"\n\n";for(;t=v.exec(e);)n+=t[0].replace(t[2],"").replace(t[1],t[3])+"\n\n";return n},convertColonHost:function(e){return this.convertColonRule(e,E,this.colonHostPartReplacer)},convertColonHostContext:function(e){return this.convertColonRule(e,S,this.colonHostContextPartReplacer)},convertColonRule:function(e,t,n){return e.replace(t,function(e,t,r,o){if(t=L,r){for(var i,a=r.split(","),s=[],c=0,l=a.length;l>c&&(i=a[c]);c++)i=i.trim(),s.push(n(t,i,o));return s.join(",")}return t+o})},colonHostContextPartReplacer:function(e,t,n){return t.match(g)?this.colonHostPartReplacer(e,t,n):e+t+n+", "+t+" "+e+n},colonHostPartReplacer:function(e,t,n){return e+t.replace(g,"")+n},convertShadowDOMSelectors:function(e){for(var t=0;t","+","~"],r=e,o="["+t+"]";return n.forEach(function(e){var t=r.split(e);r=t.map(function(e){var t=e.trim().replace(O,"");return t&&n.indexOf(t)<0&&t.indexOf(o)<0&&(e=t.replace(/([^:]*)(:*)(.*)/,"$1"+o+"$2$3")),e}).join(e)}),r},insertPolyfillHostInCssText:function(e){return e.replace(_,b).replace(M,g)},propertiesFromRule:function(e){var t=e.style.cssText;e.style.content&&!e.style.content.match(/['"]+|attr/)&&(t=t.replace(/content:[^;]*;/g,"content: '"+e.style.content+"';"));var n=e.style;for(var r in n)"initial"===n[r]&&(t+=r+": initial; ");return t},replaceTextInStyles:function(e,t){e&&t&&(e instanceof Array||(e=[e]),Array.prototype.forEach.call(e,function(e){e.textContent=t.call(this,e.textContent)},this))},addCssToDocument:function(e,t){e.match("@import")?c(e,t):s(e)}},d=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,p=/\/\*\s*@polyfill ([^*]*\*+([^/*][^*]*\*+)*\/)([^{]*?){/gim,f=/polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim,h=/\/\*\s@polyfill-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,m=/(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,w=/\/\*\s@polyfill-unscoped-rule([^*]*\*+([^/*][^*]*\*+)*)\//gim,v=/(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim,g="-shadowcsshost",b="-shadowcsscontext",y=")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)",E=new RegExp("("+g+y,"gim"),S=new RegExp("("+b+y,"gim"),T="([>\\s~+[.,{:][\\s\\S]*)?$",M=/\:host/gim,_=/\:host-context/gim,L=g+"-no-combinator",O=new RegExp(g,"gim"),C=(new RegExp(b,"gim"),[/\^\^/g,/\^/g,/\/shadow\//g,/\/shadow-deep\//g,/::shadow/g,/\/deep\//g,/::content/g]),N=document.createElement("iframe");N.style.display="none";var D,j=navigator.userAgent.match("Chrome"),H="shim-shadowdom",x="shim-shadowdom-css",R="no-shim";if(window.ShadowDOMPolyfill){s("style { display: none !important; }\n");var P=ShadowDOMPolyfill.wrap(document),I=P.querySelector("head");I.insertBefore(l(),I.childNodes[0]),document.addEventListener("DOMContentLoaded",function(){e.urlResolver;if(window.HTMLImports&&!HTMLImports.useNative){var t="link[rel=stylesheet]["+H+"]",n="style["+H+"]";HTMLImports.importer.documentPreloadSelectors+=","+t,HTMLImports.importer.importsPreloadSelectors+=","+t,HTMLImports.parser.documentSelectors=[HTMLImports.parser.documentSelectors,t,n].join(",");var r=HTMLImports.parser.parseGeneric;HTMLImports.parser.parseGeneric=function(e){if(!e[x]){var t=e.__importElement||e;if(!t.hasAttribute(H))return void r.call(this,e);e.__resource&&(t=e.ownerDocument.createElement("style"),t.textContent=e.__resource),HTMLImports.path.resolveUrlsInStyle(t),t.textContent=u.shimStyle(t),t.removeAttribute(H,""),t.setAttribute(x,""),t[x]=!0,t.parentNode!==I&&(e.parentNode===I?I.replaceChild(t,e):this.addElementToDocument(t)),t.__importParsed=!0,this.markParsingComplete(e),this.parseNext()}};var o=HTMLImports.parser.hasResource;HTMLImports.parser.hasResource=function(e){return"link"===e.localName&&"stylesheet"===e.rel&&e.hasAttribute(H)?e.__resource:o.call(this,e)}}})}e.ShadowCSS=u}(window.WebComponents)),function(){window.ShadowDOMPolyfill?(window.wrap=ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=ShadowDOMPolyfill.unwrapIfNeeded):window.wrap=window.unwrap=function(e){return e}}(window.WebComponents),window.HTMLImports=window.HTMLImports||{flags:{}},function(e){function t(e,t){t=t||h,r(function(){i(e,t)},t)}function n(e){return"complete"===e.readyState||e.readyState===v}function r(e,t){if(n(t))e&&e();else{var o=function(){("complete"===t.readyState||t.readyState===v)&&(t.removeEventListener(g,o),r(e,t))};t.addEventListener(g,o)}}function o(e){e.target.__loaded=!0}function i(e,t){function n(){s==c&&e&&e()}function r(e){o(e),s++,n()}var i=t.querySelectorAll("link[rel=import]"),s=0,c=i.length;if(c)for(var l,u=0;c>u&&(l=i[u]);u++)a(l)?r.call(l,{target:l}):(l.addEventListener("load",r),l.addEventListener("error",r));else n()}function a(e){return d?e.__loaded||e["import"]&&"loading"!==e["import"].readyState:e.__importParsed}function s(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)c(t)&&l(t)}function c(e){return"link"===e.localName&&"import"===e.rel}function l(e){var t=e["import"];t?o({target:e}):(e.addEventListener("load",o),e.addEventListener("error",o))}var u="import",d=Boolean(u in document.createElement("link")),p=Boolean(window.ShadowDOMPolyfill),f=function(e){return p?ShadowDOMPolyfill.wrapIfNeeded(e):e},h=f(document),m={get:function(){var e=HTMLImports.currentScript||document.currentScript||("complete"!==document.readyState?document.scripts[document.scripts.length-1]:null);return f(e)},configurable:!0};Object.defineProperty(document,"_currentScript",m),Object.defineProperty(h,"_currentScript",m);var w=/Trident|Edge/.test(navigator.userAgent),v=w?"complete":"interactive",g="readystatechange";d&&(new MutationObserver(function(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)t.addedNodes&&s(t.addedNodes)}).observe(document.head,{childList:!0}),function(){if("loading"===document.readyState)for(var e,t=document.querySelectorAll("link[rel=import]"),n=0,r=t.length;r>n&&(e=t[n]);n++)l(e)}()),t(function(){HTMLImports.ready=!0,HTMLImports.readyTime=(new Date).getTime();var e=h.createEvent("CustomEvent");e.initCustomEvent("HTMLImportsLoaded",!0,!0,{}),h.dispatchEvent(e)}),e.IMPORT_LINK_TYPE=u,e.useNative=d,e.rootDocument=h,e.whenReady=t,e.isIE=w}(HTMLImports),function(e){var t=[],n=function(e){t.push(e)},r=function(){t.forEach(function(t){t(e)})};e.addModule=n,e.initializeModules=r}(HTMLImports),HTMLImports.addModule(function(e){var t=/(url\()([^)]*)(\))/g,n=/(@import[\s]+(?!url\())([^;]*)(;)/g,r={resolveUrlsInStyle:function(e){var t=e.ownerDocument,n=t.createElement("a");return e.textContent=this.resolveUrlsInCssText(e.textContent,n),e},resolveUrlsInCssText:function(e,r){var o=this.replaceUrls(e,r,t);return o=this.replaceUrls(o,r,n)},replaceUrls:function(e,t,n){return e.replace(n,function(e,n,r,o){var i=r.replace(/["']/g,"");return t.href=i,i=t.href,n+"'"+i+"'"+o})}};e.path=r}),HTMLImports.addModule(function(e){var t={async:!0,ok:function(e){return e.status>=200&&e.status<300||304===e.status||0===e.status},load:function(n,r,o){var i=new XMLHttpRequest;return(e.flags.debug||e.flags.bust)&&(n+="?"+Math.random()),i.open("GET",n,t.async),i.addEventListener("readystatechange",function(){if(4===i.readyState){var e=i.getResponseHeader("Location"),n=null;if(e)var n="/"===e.substr(0,1)?location.origin+e:e;r.call(o,!t.ok(i)&&i,i.response||i.responseText,n)}}),i.send(),i},loadDocument:function(e,t,n){this.load(e,t,n).responseType="document"}};e.xhr=t}),HTMLImports.addModule(function(e){var t=e.xhr,n=e.flags,r=function(e,t){this.cache={},this.onload=e,this.oncomplete=t,this.inflight=0,this.pending={}};r.prototype={addNodes:function(e){this.inflight+=e.length;for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)this.require(t);this.checkDone()},addNode:function(e){this.inflight++,this.require(e),this.checkDone()},require:function(e){var t=e.src||e.href;e.__nodeUrl=t,this.dedupe(t,e)||this.fetch(t,e)},dedupe:function(e,t){if(this.pending[e])return this.pending[e].push(t),!0;return this.cache[e]?(this.onload(e,t,this.cache[e]),this.tail(),!0):(this.pending[e]=[t],!1)},fetch:function(e,r){if(n.load&&console.log("fetch",e,r),e)if(e.match(/^data:/)){var o=e.split(","),i=o[0],a=o[1];a=i.indexOf(";base64")>-1?atob(a):decodeURIComponent(a),setTimeout(function(){this.receive(e,r,null,a)}.bind(this),0)}else{var s=function(t,n,o){this.receive(e,r,t,n,o)}.bind(this);t.load(e,s)}else setTimeout(function(){this.receive(e,r,{error:"href must be specified"},null)}.bind(this),0)},receive:function(e,t,n,r,o){this.cache[e]=r;for(var i,a=this.pending[e],s=0,c=a.length;c>s&&(i=a[s]);s++)this.onload(e,i,r,n,o),this.tail();this.pending[e]=null},tail:function(){--this.inflight,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}},e.Loader=r}),HTMLImports.addModule(function(e){var t=function(e){this.addCallback=e,this.mo=new MutationObserver(this.handler.bind(this))};t.prototype={handler:function(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)"childList"===t.type&&t.addedNodes.length&&this.addedNodes(t.addedNodes)},addedNodes:function(e){this.addCallback&&this.addCallback(e);for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)t.children&&t.children.length&&this.addedNodes(t.children)},observe:function(e){this.mo.observe(e,{childList:!0,subtree:!0})}},e.Observer=t}),HTMLImports.addModule(function(e){function t(e){return"link"===e.localName&&e.rel===u}function n(e){var t=r(e);return"data:text/javascript;charset=utf-8,"+encodeURIComponent(t)}function r(e){return e.textContent+o(e)}function o(e){var t=e.ownerDocument;t.__importedScripts=t.__importedScripts||0;var n=e.ownerDocument.baseURI,r=t.__importedScripts?"-"+t.__importedScripts:"";return t.__importedScripts++,"\n//# sourceURL="+n+r+".js\n"}function i(e){var t=e.ownerDocument.createElement("style");return t.textContent=e.textContent,a.resolveUrlsInStyle(t),t}var a=e.path,s=e.rootDocument,c=e.flags,l=e.isIE,u=e.IMPORT_LINK_TYPE,d="link[rel="+u+"]",p={documentSelectors:d,importsSelectors:[d,"link[rel=stylesheet]","style","script:not([type])",'script[type="text/javascript"]'].join(","),map:{link:"parseLink",script:"parseScript",style:"parseStyle"},dynamicElements:[],parseNext:function(){var e=this.nextToParse();e&&this.parse(e)},parse:function(e){if(this.isParsed(e))return void(c.parse&&console.log("[%s] is already parsed",e.localName));var t=this[this.map[e.localName]];t&&(this.markParsing(e),t.call(this,e))},parseDynamic:function(e,t){this.dynamicElements.push(e),t||this.parseNext()},markParsing:function(e){c.parse&&console.log("parsing",e),this.parsingElement=e},markParsingComplete:function(e){e.__importParsed=!0,this.markDynamicParsingComplete(e),e.__importElement&&(e.__importElement.__importParsed=!0,this.markDynamicParsingComplete(e.__importElement)),this.parsingElement=null,c.parse&&console.log("completed",e)},markDynamicParsingComplete:function(e){var t=this.dynamicElements.indexOf(e);t>=0&&this.dynamicElements.splice(t,1)},parseImport:function(e){if(HTMLImports.__importsParsingHook&&HTMLImports.__importsParsingHook(e),e["import"]&&(e["import"].__importParsed=!0),this.markParsingComplete(e),e.dispatchEvent(e.__resource&&!e.__error?new CustomEvent("load",{bubbles:!1}):new CustomEvent("error",{bubbles:!1})),e.__pending)for(var t;e.__pending.length;)t=e.__pending.shift(),t&&t({target:e});this.parseNext()},parseLink:function(e){t(e)?this.parseImport(e):(e.href=e.href,this.parseGeneric(e))},parseStyle:function(e){var t=e;e=i(e),e.__importElement=t,this.parseGeneric(e)},parseGeneric:function(e){this.trackElement(e),this.addElementToDocument(e)},rootImportForElement:function(e){for(var t=e;t.ownerDocument.__importLink;)t=t.ownerDocument.__importLink;return t},addElementToDocument:function(e){var t=this.rootImportForElement(e.__importElement||e);t.parentNode.insertBefore(e,t)},trackElement:function(e,t){var n=this,r=function(r){t&&t(r),n.markParsingComplete(e),n.parseNext()};if(e.addEventListener("load",r),e.addEventListener("error",r),l&&"style"===e.localName){var o=!1;if(-1==e.textContent.indexOf("@import"))o=!0;else if(e.sheet){o=!0;for(var i,a=e.sheet.cssRules,s=a?a.length:0,c=0;s>c&&(i=a[c]);c++)i.type===CSSRule.IMPORT_RULE&&(o=o&&Boolean(i.styleSheet))}o&&e.dispatchEvent(new CustomEvent("load",{bubbles:!1}))}},parseScript:function(t){var r=document.createElement("script");r.__importElement=t,r.src=t.src?t.src:n(t),e.currentScript=t,this.trackElement(r,function(){r.parentNode.removeChild(r),e.currentScript=null}),this.addElementToDocument(r)},nextToParse:function(){return this._mayParse=[],!this.parsingElement&&(this.nextToParseInDoc(s)||this.nextToParseDynamic())},nextToParseInDoc:function(e,n){if(e&&this._mayParse.indexOf(e)<0){this._mayParse.push(e);for(var r,o=e.querySelectorAll(this.parseSelectorsForNode(e)),i=0,a=o.length;a>i&&(r=o[i]);i++)if(!this.isParsed(r))return this.hasResource(r)?t(r)?this.nextToParseInDoc(r["import"],r):r:void 0}return n},nextToParseDynamic:function(){return this.dynamicElements[0]},parseSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===s?this.documentSelectors:this.importsSelectors},isParsed:function(e){return e.__importParsed},needsDynamicParsing:function(e){return this.dynamicElements.indexOf(e)>=0},hasResource:function(e){return t(e)&&void 0===e["import"]?!1:!0}};e.parser=p,e.IMPORT_SELECTOR=d}),HTMLImports.addModule(function(e){function t(e){return n(e,a)}function n(e,t){return"link"===e.localName&&e.getAttribute("rel")===t}function r(e){return!!Object.getOwnPropertyDescriptor(e,"baseURI")}function o(e,t){var n=document.implementation.createHTMLDocument(a);n._URL=t;var o=n.createElement("base");o.setAttribute("href",t),n.baseURI||r(n)||Object.defineProperty(n,"baseURI",{value:t});var i=n.createElement("meta");return i.setAttribute("charset","utf-8"),n.head.appendChild(i),n.head.appendChild(o),n.body.innerHTML=e,window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(n),n}var i=e.flags,a=e.IMPORT_LINK_TYPE,s=e.IMPORT_SELECTOR,c=e.rootDocument,l=e.Loader,u=e.Observer,d=e.parser,p={documents:{},documentPreloadSelectors:s,importsPreloadSelectors:[s].join(","),loadNode:function(e){f.addNode(e)},loadSubtree:function(e){var t=this.marshalNodes(e);f.addNodes(t)},marshalNodes:function(e){return e.querySelectorAll(this.loadSelectorsForNode(e))},loadSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===c?this.documentPreloadSelectors:this.importsPreloadSelectors},loaded:function(e,n,r,a,s){if(i.load&&console.log("loaded",e,n),n.__resource=r,n.__error=a,t(n)){var c=this.documents[e];void 0===c&&(c=a?null:o(r,s||e),c&&(c.__importLink=n,this.bootDocument(c)),this.documents[e]=c),n["import"]=c}d.parseNext()},bootDocument:function(e){this.loadSubtree(e),this.observer.observe(e),d.parseNext()},loadedAll:function(){d.parseNext()}},f=new l(p.loaded.bind(p),p.loadedAll.bind(p));if(p.observer=new u,!document.baseURI){var h={get:function(){var e=document.querySelector("base");return e?e.href:window.location.href},configurable:!0};Object.defineProperty(document,"baseURI",h),Object.defineProperty(c,"baseURI",h)}e.importer=p,e.importLoader=f}),HTMLImports.addModule(function(e){var t=e.parser,n=e.importer,r={added:function(e){for(var r,o,i,a,s=0,c=e.length;c>s&&(a=e[s]);s++)r||(r=a.ownerDocument,o=t.isParsed(r)),i=this.shouldLoadNode(a),i&&n.loadNode(a),this.shouldParseNode(a)&&o&&t.parseDynamic(a,i)},shouldLoadNode:function(e){return 1===e.nodeType&&o.call(e,n.loadSelectorsForNode(e))},shouldParseNode:function(e){return 1===e.nodeType&&o.call(e,t.parseSelectorsForNode(e))}};n.observer.addCallback=r.added.bind(r);var o=HTMLElement.prototype.matches||HTMLElement.prototype.matchesSelector||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector}),function(e){function t(){HTMLImports.importer.bootDocument(o)}var n=e.initializeModules,r=e.isIE;if(!e.useNative){r&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),n},window.CustomEvent.prototype=window.Event.prototype),n();var o=e.rootDocument;"complete"===document.readyState||"interactive"===document.readyState&&!window.attachEvent?t():document.addEventListener("DOMContentLoaded",t)}}(HTMLImports),window.CustomElements=window.CustomElements||{flags:{}},function(e){var t=e.flags,n=[],r=function(e){n.push(e)},o=function(){n.forEach(function(t){t(e)})};e.addModule=r,e.initializeModules=o,e.hasNative=Boolean(document.registerElement),e.useNative=!t.register&&e.hasNative&&!window.ShadowDOMPolyfill&&(!window.HTMLImports||HTMLImports.useNative)}(CustomElements),CustomElements.addModule(function(e){function t(e,t){n(e,function(e){return t(e)?!0:void r(e,t)}),r(e,t)}function n(e,t,r){var o=e.firstElementChild;if(!o)for(o=e.firstChild;o&&o.nodeType!==Node.ELEMENT_NODE;)o=o.nextSibling;for(;o;)t(o,r)!==!0&&n(o,t,r),o=o.nextElementSibling;return null}function r(e,n){for(var r=e.shadowRoot;r;)t(r,n),r=r.olderShadowRoot}function o(e,t){a=[],i(e,t),a=null}function i(e,t){if(e=wrap(e),!(a.indexOf(e)>=0)){a.push(e);for(var n,r=e.querySelectorAll("link[rel="+s+"]"),o=0,c=r.length;c>o&&(n=r[o]);o++)n["import"]&&i(n["import"],t);t(e)}}var a,s=window.HTMLImports?HTMLImports.IMPORT_LINK_TYPE:"none";e.forDocumentTree=o,e.forSubtree=t}),CustomElements.addModule(function(e){function t(e){return n(e)||r(e)}function n(t){return e.upgrade(t)?!0:void s(t)}function r(e){y(e,function(e){return n(e)?!0:void 0})}function o(e){s(e),p(e)&&y(e,function(e){s(e)})}function i(e){M.push(e),T||(T=!0,setTimeout(a))}function a(){T=!1;for(var e,t=M,n=0,r=t.length;r>n&&(e=t[n]);n++)e();M=[]}function s(e){S?i(function(){c(e)}):c(e)}function c(e){e.__upgraded__&&(e.attachedCallback||e.detachedCallback)&&!e.__attached&&p(e)&&(e.__attached=!0,e.attachedCallback&&e.attachedCallback())}function l(e){u(e),y(e,function(e){u(e)})}function u(e){S?i(function(){d(e)}):d(e)}function d(e){e.__upgraded__&&(e.attachedCallback||e.detachedCallback)&&e.__attached&&!p(e)&&(e.__attached=!1,e.detachedCallback&&e.detachedCallback())}function p(e){for(var t=e,n=wrap(document);t;){if(t==n)return!0;t=t.parentNode||t.host}}function f(e){if(e.shadowRoot&&!e.shadowRoot.__watched){b.dom&&console.log("watching shadow-root for: ",e.localName);for(var t=e.shadowRoot;t;)w(t),t=t.olderShadowRoot}}function h(e){if(b.dom){var n=e[0];if(n&&"childList"===n.type&&n.addedNodes&&n.addedNodes){for(var r=n.addedNodes[0];r&&r!==document&&!r.host;)r=r.parentNode;var o=r&&(r.URL||r._URL||r.host&&r.host.localName)||"";o=o.split("/?").shift().split("/").pop()}console.group("mutations (%d) [%s]",e.length,o||"")}e.forEach(function(e){"childList"===e.type&&(_(e.addedNodes,function(e){e.localName&&t(e)}),_(e.removedNodes,function(e){e.localName&&l(e)}))}),b.dom&&console.groupEnd()}function m(e){for(e=wrap(e),e||(e=wrap(document));e.parentNode;)e=e.parentNode;var t=e.__observer;t&&(h(t.takeRecords()),a())}function w(e){if(!e.__observer){var t=new MutationObserver(h);t.observe(e,{childList:!0,subtree:!0}),e.__observer=t}}function v(e){e=wrap(e),b.dom&&console.group("upgradeDocument: ",e.baseURI.split("/").pop()),t(e),w(e),b.dom&&console.groupEnd()}function g(e){E(e,v)}var b=e.flags,y=e.forSubtree,E=e.forDocumentTree,S=!window.MutationObserver||window.MutationObserver===window.JsMutationObserver;e.hasPolyfillMutations=S;var T=!1,M=[],_=Array.prototype.forEach.call.bind(Array.prototype.forEach),L=Element.prototype.createShadowRoot;L&&(Element.prototype.createShadowRoot=function(){var e=L.call(this);return CustomElements.watchShadow(this),e}),e.watchShadow=f,e.upgradeDocumentTree=g,e.upgradeSubtree=r,e.upgradeAll=t,e.attachedNode=o,e.takeRecords=m}),CustomElements.addModule(function(e){function t(t){if(!t.__upgraded__&&t.nodeType===Node.ELEMENT_NODE){var r=t.getAttribute("is"),o=e.getRegisteredDefinition(r||t.localName);if(o){if(r&&o.tag==t.localName)return n(t,o);if(!r&&!o["extends"])return n(t,o)}}}function n(t,n){return a.upgrade&&console.group("upgrade:",t.localName),n.is&&t.setAttribute("is",n.is),r(t,n),t.__upgraded__=!0,i(t),e.attachedNode(t),e.upgradeSubtree(t),a.upgrade&&console.groupEnd(),t}function r(e,t){Object.__proto__?e.__proto__=t.prototype:(o(e,t.prototype,t["native"]),e.__proto__=t.prototype)}function o(e,t,n){for(var r={},o=t;o!==n&&o!==HTMLElement.prototype;){for(var i,a=Object.getOwnPropertyNames(o),s=0;i=a[s];s++)r[i]||(Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(o,i)),r[i]=1);o=Object.getPrototypeOf(o)}}function i(e){e.createdCallback&&e.createdCallback()}var a=e.flags;e.upgrade=t,e.upgradeWithDefinition=n,e.implementPrototype=r}),CustomElements.addModule(function(e){function t(t,r){var c=r||{};if(!t)throw new Error("document.registerElement: first argument `name` must not be empty");if(t.indexOf("-")<0)throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '"+String(t)+"'.");if(o(t))throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '"+String(t)+"'. The type name is invalid.");if(l(t))throw new Error("DuplicateDefinitionError: a type with name '"+String(t)+"' is already registered");return c.prototype||(c.prototype=Object.create(HTMLElement.prototype)),c.__name=t.toLowerCase(),c.lifecycle=c.lifecycle||{},c.ancestry=i(c["extends"]),a(c),s(c),n(c.prototype),u(c.__name,c),c.ctor=d(c),c.ctor.prototype=c.prototype,c.prototype.constructor=c.ctor,e.ready&&w(document),c.ctor}function n(e){if(!e.setAttribute._polyfilled){var t=e.setAttribute;e.setAttribute=function(e,n){r.call(this,e,n,t)};var n=e.removeAttribute;e.removeAttribute=function(e){r.call(this,e,null,n)},e.setAttribute._polyfilled=!0}}function r(e,t,n){e=e.toLowerCase();var r=this.getAttribute(e);n.apply(this,arguments);var o=this.getAttribute(e);this.attributeChangedCallback&&o!==r&&this.attributeChangedCallback(e,r,o)}function o(e){for(var t=0;t=0&&b(r,HTMLElement),r)}function h(e){var t=L.call(this,e);return v(t),t}var m,w=e.upgradeDocumentTree,v=e.upgrade,g=e.upgradeWithDefinition,b=e.implementPrototype,y=e.useNative,E=["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"],S={},T="http://www.w3.org/1999/xhtml",M=document.createElement.bind(document),_=document.createElementNS.bind(document),L=Node.prototype.cloneNode;m=Object.__proto__||y?function(e,t){return e instanceof t}:function(e,t){for(var n=e;n;){if(n===t.prototype)return!0;n=n.__proto__}return!1},document.registerElement=t,document.createElement=f,document.createElementNS=p,Node.prototype.cloneNode=h,e.registry=S,e["instanceof"]=m,e.reservedTagList=E,e.getRegisteredDefinition=l,document.register=document.registerElement}),function(e){function t(){a(wrap(document)),window.HTMLImports&&(HTMLImports.__importsParsingHook=function(e){a(wrap(e["import"]))}),CustomElements.ready=!0,setTimeout(function(){CustomElements.readyTime=Date.now(),window.HTMLImports&&(CustomElements.elapsed=CustomElements.readyTime-HTMLImports.readyTime),document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0}))})}var n=e.useNative,r=e.initializeModules,o=/Trident/.test(navigator.userAgent);if(n){var i=function(){};e.watchShadow=i,e.upgrade=i,e.upgradeAll=i,e.upgradeDocumentTree=i,e.upgradeSubtree=i,e.takeRecords=i,e["instanceof"]=function(e,t){return e instanceof t}}else r();var a=e.upgradeDocumentTree;if(window.wrap||(window.ShadowDOMPolyfill?(window.wrap=ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=ShadowDOMPolyfill.unwrapIfNeeded):window.wrap=window.unwrap=function(e){return e}),o&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),n},window.CustomEvent.prototype=window.Event.prototype),"complete"===document.readyState||e.flags.eager)t();else if("interactive"!==document.readyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var s=window.HTMLImports&&!HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(s,t)}else t()}(window.CustomElements),function(){Function.prototype.bind||(Function.prototype.bind=function(e){var t=this,n=Array.prototype.slice.call(arguments,1);return function(){var r=n.slice();return r.push.apply(r,arguments),t.apply(e,r)}})}(window.WebComponents),function(e){"use strict";function t(){window.Polymer===o&&(window.Polymer=function(){throw new Error('You tried to use polymer without loading it first. To load polymer, ')})}if(!window.performance){var n=Date.now();window.performance={now:function(){return Date.now()-n}}}window.requestAnimationFrame||(window.requestAnimationFrame=function(){var e=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame;return e?function(t){return e(function(){t(performance.now())})}:function(e){return window.setTimeout(e,1e3/60)}}()),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(){return window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(e){clearTimeout(e)}}());var r=[],o=function(e){"string"!=typeof e&&1===arguments.length&&Array.prototype.push.call(arguments,document._currentScript),r.push(arguments)};window.Polymer=o,e.consumeDeclarations=function(t){e.consumeDeclarations=function(){throw"Possible attempt to load Polymer twice"},t&&t(r),r=null},HTMLImports.useNative?t():addEventListener("DOMContentLoaded",t)}(window.WebComponents),function(){var e=document.createElement("style");e.textContent="body {transition: opacity ease-in 0.2s; } \nbody[unresolved] {opacity: 0; display: block; overflow: hidden; position: relative; } \n";var t=document.querySelector("head");t.insertBefore(e,t.firstChild)}(window.WebComponents),function(e){window.Platform=e}(window.WebComponents); \ No newline at end of file From fceac45ddd683dca6920183108b8efe219d9ee5a Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sat, 7 Mar 2015 12:59:13 +1100 Subject: [PATCH 07/22] Updated vera switch and sensor to the new architecture --- homeassistant/components/sensor/vera.py | 13 +++---------- homeassistant/components/switch/vera.py | 11 ++--------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 57ae4266ca1..681799cc7e9 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -41,6 +41,9 @@ def get_devices(hass, config): return vera_sensors +def setup_platform(hass, config, add_devices, discovery_info=None): + add_devices(get_devices(hass, config)) + def get_extra_device_data(device_data, device_id): if not device_data: return None @@ -51,10 +54,6 @@ def get_extra_device_data(device_data, device_id): return None -def get_sensors(): - return vera_sensors - - class VeraSensor(Device): """ Represents a Vera Sensor """ extra_data = None @@ -74,12 +73,6 @@ class VeraSensor(Device): def updateState(self): return self.state() - @property - def unique_id(self): - """ Returns the id of this switch """ - return "{}.{}".format( - self.__class__, self.info.get('uniqueid', self.name)) - @property def name(self): """ Get the mame of the switch. """ diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 8b5f38e324d..17847f5f83a 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -51,9 +51,8 @@ def get_extra_device_data(device_data, device_id): return None -def get_switches(): - return vera_switches - +def setup_platform(hass, config, add_devices, discovery_info=None): + add_devices(get_devices(hass, config)) class VeraSwitch(ToggleDevice): """ Represents a Vera Switch """ @@ -66,12 +65,6 @@ class VeraSwitch(ToggleDevice): self.vera_device = vera_device self.extra_data = extra_data - @property - def unique_id(self): - """ Returns the id of this switch """ - return "{}.{}".format( - self.__class__, self.info.get('uniqueid', self.name)) - @property def name(self): """ Get the mame of the switch. """ From 250f35c2a59366dad8d2359a2e4cc25b10a4f837 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sat, 7 Mar 2015 14:49:20 +1100 Subject: [PATCH 08/22] Added documentation for proposed format of YAML config --- homeassistant/components/switch/vera.py | 54 ++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 17847f5f83a..587fbfee708 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -1,4 +1,56 @@ -""" Support for Vera lights. """ +""" +Support for Vera switches. + +Configuration: +To use the Vera switches you will need to add something like the following to your config/configuration.yaml + +switch: + platform: vera + vera_controller_url: http://YOUR_VERA_IP:3480/ + device_data: + - + vera_id: 12 + name: My awesome switch + exclude: true + - + vera_id: 13 + name: Another Switch + +VARIABLES: + +vera_controller_url +*Required +This is the base URL of your vera controller including the port number if not running on 80 +Example: http://192.168.1.21:3480/ + + +device_data +*Optional +This contains an array additional device info for your Vera devices. It is not required and if +not specified all switches configured in your Vera controller will be added with default values. + + +These are the variables for the device_data array: + +vera_id +*Required +The Vera device id you wish these configuration options to be applied to + + +name +*Optional +This parameter allows you to override the name of your Vera device in the HA interface, if not specified the +value configured for the device in your Vera will be used + + +exclude +*Optional +This parameter allows you to exclude the specified device from homeassistant, it should be set to "true" if +you want this device excluded + + + +""" import logging import requests import time From dc8147c46db586c491b7a11b55ceae17647c2606 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sun, 8 Mar 2015 23:52:50 +1100 Subject: [PATCH 09/22] Changed vera components over to new config file format --- homeassistant/components/light/vera.py | 95 +++++++++++++++++-------- homeassistant/components/sensor/vera.py | 78 ++++++++++++++++---- homeassistant/components/switch/vera.py | 20 +++--- 3 files changed, 141 insertions(+), 52 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 5e7bad29d56..bb60c97624b 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -1,4 +1,59 @@ -""" Support for Vera lights. """ +""" +Support for Vera lights. + +Configuration: +This component is useful if you wish for switches connected to your Vera controller to appear as lights +in homeassistant. All switches will be added as a light unless you exclude them in the config. + +To use the Vera lights you will need to add something like the following to your config/configuration.yaml + +light: + platform: vera + vera_controller_url: http://YOUR_VERA_IP:3480/ + device_data: + - + vera_id: 12 + name: My awesome switch + exclude: true + - + vera_id: 13 + name: Another switch + +VARIABLES: + +vera_controller_url +*Required +This is the base URL of your vera controller including the port number if not running on 80 +Example: http://192.168.1.21:3480/ + + +device_data +*Optional +This contains an array additional device info for your Vera devices. It is not required and if +not specified all sensors configured in your Vera controller will be added with default values. + + +These are the variables for the device_data array: + +vera_id +*Required +The Vera device id you wish these configuration options to be applied to + + +name +*Optional +This parameter allows you to override the name of your Vera device in the HA interface, if not specified the +value configured for the device in your Vera will be used + + +exclude +*Optional +This parameter allows you to exclude the specified device from homeassistant, it should be set to "true" if +you want this device excluded + + + +""" import logging import requests import time @@ -7,7 +62,7 @@ import json from homeassistant.helpers import ToggleDevice import homeassistant.external.vera.vera as veraApi -_LOGGER = logging.getLogger('Vera_Light') +_LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices_callback, discovery_info=None): @@ -18,46 +73,33 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") return False - device_data_str = config.get('device_data') - device_data = None - if device_data_str: - try: - device_data = json.loads(device_data_str) - except Exception as json_ex: - _LOGGER.error('Vera lights error parsing device info, should be in the format [{"id" : 12, "name": "Lounge Light"}]: %s', json_ex) + device_data = config.get('device_data', None) controller = veraApi.VeraController(base_url) devices = controller.get_devices('Switch') lights = [] for device in devices: - if is_switch_a_light(device_data, device.deviceId): - lights.append(VeraLight(device, get_extra_device_data(device_data, device.deviceId))) + extra_data = get_extra_device_data(device_data, device.deviceId) + exclude = False + if extra_data: + exclude = extra_data.get('exclude', False) + + if exclude is not True: + lights.append(VeraLight(device, extra_data)) add_devices_callback(lights) except Exception as inst: _LOGGER.error("Could not find Vera lights: %s", inst) return False -# If you have z-wave switches that control lights you can configure them -# to be treated as lights using the "device_data" parameter in the config. -# If "device_data" is not set then all switches are treated as lights -def is_switch_a_light(device_data, device_id): - if not device_data: - return True - - for item in device_data: - if item.get('id') == device_id: - return True - - return False def get_extra_device_data(device_data, device_id): if not device_data: return None for item in device_data: - if item.get('id') == device_id: + if item.get('vera_id') == device_id: return item return None @@ -74,11 +116,6 @@ class VeraLight(ToggleDevice): self.vera_device = vera_device self.extra_data = extra_data - @property - def unique_id(self): - """ Returns the id of this light """ - return "{}.{}".format( - self.__class__, self.info.get('uniqueid', self.name)) @property def name(self): diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 681799cc7e9..0f901123864 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -1,4 +1,56 @@ -""" Support for Vera lights. """ +""" +Support for Vera sensors. + +Configuration: +To use the Vera sensors you will need to add something like the following to your config/configuration.yaml + +sensor: + platform: vera + vera_controller_url: http://YOUR_VERA_IP:3480/ + device_data: + - + vera_id: 12 + name: My awesome sensor + exclude: true + - + vera_id: 13 + name: Another sensor + +VARIABLES: + +vera_controller_url +*Required +This is the base URL of your vera controller including the port number if not running on 80 +Example: http://192.168.1.21:3480/ + + +device_data +*Optional +This contains an array additional device info for your Vera devices. It is not required and if +not specified all sensors configured in your Vera controller will be added with default values. + + +These are the variables for the device_data array: + +vera_id +*Required +The Vera device id you wish these configuration options to be applied to + + +name +*Optional +This parameter allows you to override the name of your Vera device in the HA interface, if not specified the +value configured for the device in your Vera will be used + + +exclude +*Optional +This parameter allows you to exclude the specified device from homeassistant, it should be set to "true" if +you want this device excluded + + + +""" import logging import requests import time @@ -8,7 +60,7 @@ from homeassistant.helpers import Device import homeassistant.external.vera.vera as veraApi from homeassistant.const import (STATE_OPEN, STATE_CLOSED, ATTR_FRIENDLY_NAME) -_LOGGER = logging.getLogger('Vera_Sensor') +_LOGGER = logging.getLogger(__name__) vera_controller = None vera_sensors = [] @@ -19,22 +71,22 @@ def get_devices(hass, config): base_url = config.get('vera_controller_url') if not base_url: _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") - #return False + return False - device_data_str = config.get('device_data') - device_data = None - if device_data_str: - try: - device_data = json.loads(device_data_str) - except Exception as json_ex: - _LOGGER.error('Vera sensors error parsing device info, should be in the format [{"id" : 12, "name": "Temperature"}]: %s', json_ex) + device_data = config.get('device_data', None) vera_controller = veraApi.VeraController(base_url) devices = vera_controller.get_devices(['Temperature Sensor', 'Light Sensor', 'Sensor']) vera_sensors = [] for device in devices: - vera_sensors.append(VeraSensor(device, get_extra_device_data(device_data, device.deviceId))) + extra_data = get_extra_device_data(device_data, device.deviceId) + exclude = False + if extra_data: + exclude = extra_data.get('exclude', False) + + if exclude is not True: + vera_sensors.append(VeraSensor(device, extra_data)) except Exception as inst: _LOGGER.error("Could not find Vera sensors: %s", inst) @@ -49,7 +101,7 @@ def get_extra_device_data(device_data, device_id): return None for item in device_data: - if item.get('id') == device_id: + if item.get('vera_id') == device_id: return item return None @@ -75,7 +127,7 @@ class VeraSensor(Device): @property def name(self): - """ Get the mame of the switch. """ + """ Get the mame of the sensor. """ if self.extra_data and self.extra_data.get('name'): return self.extra_data.get('name') return self.vera_device.name diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 587fbfee708..8efb0a85b03 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -59,7 +59,7 @@ import json from homeassistant.helpers import ToggleDevice import homeassistant.external.vera.vera as veraApi -_LOGGER = logging.getLogger('Vera_Switch') +_LOGGER = logging.getLogger(__name__) vera_controller = None vera_switches = [] @@ -72,20 +72,20 @@ def get_devices(hass, config): _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") return False - device_data_str = config.get('device_data') - device_data = None - if device_data_str: - try: - device_data = json.loads(device_data_str) - except Exception as json_ex: - _LOGGER.error('Vera switch error parsing device info, should be in the format [{"id" : 12, "name": "Lounge Light"}]: %s', json_ex) + device_data = config.get('device_data', None) vera_controller = veraApi.VeraController(base_url) devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) vera_switches = [] for device in devices: - vera_switches.append(VeraSwitch(device, get_extra_device_data(device_data, device.deviceId))) + extra_data = get_extra_device_data(device_data, device.deviceId) + exclude = False + if extra_data: + exclude = extra_data.get('exclude', False) + + if exclude is not True: + vera_switches.append(VeraSwitch(device, extra_data)) except Exception as inst: _LOGGER.error("Could not find Vera switches: %s", inst) @@ -98,7 +98,7 @@ def get_extra_device_data(device_data, device_id): return None for item in device_data: - if item.get('id') == device_id: + if item.get('vera_id') == device_id: return item return None From 42dc973ccc34b0610838fbb43720a6d897b27043 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 01:14:44 +1100 Subject: [PATCH 10/22] Fixed up linting errors --- homeassistant/components/light/vera.py | 61 +++++++++++--------- homeassistant/components/sensor/vera.py | 74 +++++++++++++------------ homeassistant/components/switch/vera.py | 60 ++++++++++---------- 3 files changed, 105 insertions(+), 90 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index bb60c97624b..15033a7c495 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -1,36 +1,40 @@ -""" -Support for Vera lights. +""" +Support for Vera lights. Configuration: -This component is useful if you wish for switches connected to your Vera controller to appear as lights -in homeassistant. All switches will be added as a light unless you exclude them in the config. +This component is useful if you wish for switches connected to your Vera +controller to appear as lights in homeassistant. All switches will be added +as a light unless you exclude them in the config. -To use the Vera lights you will need to add something like the following to your config/configuration.yaml +To use the Vera lights you will need to add something like the following to +your config/configuration.yaml light: platform: vera vera_controller_url: http://YOUR_VERA_IP:3480/ - device_data: - - + device_data: + - vera_id: 12 name: My awesome switch exclude: true - vera_id: 13 - name: Another switch + name: Another switch -VARIABLES: +VARIABLES: vera_controller_url *Required -This is the base URL of your vera controller including the port number if not running on 80 +This is the base URL of your vera controller including the port number if not +running on 80 Example: http://192.168.1.21:3480/ device_data *Optional -This contains an array additional device info for your Vera devices. It is not required and if -not specified all sensors configured in your Vera controller will be added with default values. +This contains an array additional device info for your Vera devices. It is not +required and if not specified all lights configured in your Vera controller +will be added with default values. These are the variables for the device_data array: @@ -42,35 +46,34 @@ The Vera device id you wish these configuration options to be applied to name *Optional -This parameter allows you to override the name of your Vera device in the HA interface, if not specified the -value configured for the device in your Vera will be used +This parameter allows you to override the name of your Vera device in the HA +interface, if not specified the value configured for the device in your Vera +will be used exclude *Optional -This parameter allows you to exclude the specified device from homeassistant, it should be set to "true" if -you want this device excluded - - +This parameter allows you to exclude the specified device from homeassistant, +it should be set to "true" if you want this device excluded """ import logging -import requests import time -import json from homeassistant.helpers import ToggleDevice +# pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger(__name__) - +# pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Find and return Vera lights. """ try: base_url = config.get('vera_controller_url') if not base_url: - _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") + _LOGGER.error("The required parameter 'vera_controller_url'" + " was not found in config") return False device_data = config.get('device_data', None) @@ -85,16 +88,18 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): if extra_data: exclude = extra_data.get('exclude', False) - if exclude is not True: + if exclude is not True: lights.append(VeraLight(device, extra_data)) add_devices_callback(lights) + # pylint: disable=broad-except except Exception as inst: _LOGGER.error("Could not find Vera lights: %s", inst) return False def get_extra_device_data(device_data, device_id): + """ Gets the additional configuration data by Vera device Id """ if not device_data: return None @@ -136,9 +141,11 @@ class VeraLight(ToggleDevice): attr['Armed'] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: - lastTripped = self.vera_device.refresh_value('LastTrip') - tripTimeStr = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(lastTripped))) - attr['Last Tripped'] = tripTimeStr + last_tripped = self.vera_device.refresh_value('LastTrip') + trip_time_str = time.strftime("%Y-%m-%d %H:%M", + time.localtime(int(last_tripped))) + + attr['Last Tripped'] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') attr['Tripped'] = 'True' if tripped == '1' else 'False' @@ -164,7 +171,7 @@ class VeraLight(ToggleDevice): return self.is_on_status def update(self): - # We need to debounce the status call after turning light on or off + # We need to debounce the status call after turning light on or off # because the vera has some lag in updating the device status if (self.last_command_send + 5) < time.time(): self.is_on_status = self.vera_device.is_switched_on() diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 0f901123864..885186fb9f9 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -1,33 +1,36 @@ -""" -Support for Vera sensors. +""" +Support for Vera sensors. Configuration: -To use the Vera sensors you will need to add something like the following to your config/configuration.yaml +To use the Vera sensors you will need to add something like the following to +your config/configuration.yaml sensor: platform: vera vera_controller_url: http://YOUR_VERA_IP:3480/ - device_data: - - + device_data: + - vera_id: 12 name: My awesome sensor exclude: true - vera_id: 13 - name: Another sensor + name: Another sensor -VARIABLES: +VARIABLES: vera_controller_url *Required -This is the base URL of your vera controller including the port number if not running on 80 +This is the base URL of your vera controller including the port number if not +running on 80 Example: http://192.168.1.21:3480/ device_data *Optional -This contains an array additional device info for your Vera devices. It is not required and if -not specified all sensors configured in your Vera controller will be added with default values. +This contains an array additional device info for your Vera devices. It is not +required and if not specified all sensors configured in your Vera controller +will be added with default values. These are the variables for the device_data array: @@ -39,44 +42,41 @@ The Vera device id you wish these configuration options to be applied to name *Optional -This parameter allows you to override the name of your Vera device in the HA interface, if not specified the -value configured for the device in your Vera will be used +This parameter allows you to override the name of your Vera device in the HA +interface, if not specified the value configured for the device in your Vera +will be used exclude *Optional -This parameter allows you to exclude the specified device from homeassistant, it should be set to "true" if -you want this device excluded - - +This parameter allows you to exclude the specified device from homeassistant, +it should be set to "true" if you want this device excluded """ import logging -import requests import time -import json from homeassistant.helpers import Device +# pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi -from homeassistant.const import (STATE_OPEN, STATE_CLOSED, ATTR_FRIENDLY_NAME) _LOGGER = logging.getLogger(__name__) -vera_controller = None -vera_sensors = [] - +# pylint: disable=unused-argument def get_devices(hass, config): """ Find and return Vera Sensors. """ try: base_url = config.get('vera_controller_url') if not base_url: - _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") + _LOGGER.error("The required parameter 'vera_controller_url'" + " was not found in config") return False device_data = config.get('device_data', None) vera_controller = veraApi.VeraController(base_url) - devices = vera_controller.get_devices(['Temperature Sensor', 'Light Sensor', 'Sensor']) + categories = ['Temperature Sensor', 'Light Sensor', 'Sensor'] + devices = vera_controller.get_devices(categories) vera_sensors = [] for device in devices: @@ -85,18 +85,20 @@ def get_devices(hass, config): if extra_data: exclude = extra_data.get('exclude', False) - if exclude is not True: + if exclude is not True: vera_sensors.append(VeraSensor(device, extra_data)) - + # pylint: disable=broad-except except Exception as inst: _LOGGER.error("Could not find Vera sensors: %s", inst) return vera_sensors def setup_platform(hass, config, add_devices, discovery_info=None): + """ Performs setup for Vera controller devices """ add_devices(get_devices(hass, config)) def get_extra_device_data(device_data, device_id): + """ Gets the additional configuration data by Vera device Id """ if not device_data: return None @@ -113,18 +115,15 @@ class VeraSensor(Device): def __init__(self, vera_device, extra_data=None): self.vera_device = vera_device - self.extra_data = extra_data + self.extra_data = extra_data def __str__(self): - return "%s %s %s" % (self.name(), self.deviceId(), self.state()) + return "%s %s %s" % (self.name, self.vera_device.deviceId, self.state) @property def state(self): return self.current_value - def updateState(self): - return self.state() - @property def name(self): """ Get the mame of the sensor. """ @@ -144,9 +143,11 @@ class VeraSensor(Device): attr['Armed'] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: - lastTripped = self.vera_device.refresh_value('LastTrip') - tripTimeStr = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(lastTripped))) - attr['Last Tripped'] = tripTimeStr + last_tripped = self.vera_device.refresh_value('LastTrip') + trip_time_str = time.strftime("%Y-%m-%d %H:%M", + time.localtime(int(last_tripped))) + + attr['Last Tripped'] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') attr['Tripped'] = 'True' if tripped == '1' else 'False' @@ -159,7 +160,10 @@ class VeraSensor(Device): def update(self): if self.vera_device.category == "Temperature Sensor": self.vera_device.refresh_value('CurrentTemperature') - self.current_value = self.vera_device.get_value('CurrentTemperature') + '°' + self.vera_device.veraController.temperature_units + current_temp = self.vera_device.get_value('CurrentTemperature') + vera_temp_units = self.vera_device.veraController.temperature_units + self.current_value = current_temp + '°' + vera_temp_units + elif self.vera_device.category == "Light Sensor": self.vera_device.refresh_value('CurrentLevel') self.current_value = self.vera_device.get_value('CurrentLevel') diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 8efb0a85b03..f917b7f0477 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -1,33 +1,36 @@ -""" -Support for Vera switches. +""" +Support for Vera switches. Configuration: -To use the Vera switches you will need to add something like the following to your config/configuration.yaml +To use the Vera lights you will need to add something like the following to +your config/configuration.yaml switch: platform: vera vera_controller_url: http://YOUR_VERA_IP:3480/ - device_data: - - + device_data: + - vera_id: 12 name: My awesome switch exclude: true - vera_id: 13 - name: Another Switch + name: Another Switch -VARIABLES: +VARIABLES: vera_controller_url *Required -This is the base URL of your vera controller including the port number if not running on 80 +This is the base URL of your vera controller including the port number if not +running on 80 Example: http://192.168.1.21:3480/ device_data *Optional -This contains an array additional device info for your Vera devices. It is not required and if -not specified all switches configured in your Vera controller will be added with default values. +This contains an array additional device info for your Vera devices. It is not +required and if not specified all lights configured in your Vera controller +will be added with default values. These are the variables for the device_data array: @@ -39,37 +42,34 @@ The Vera device id you wish these configuration options to be applied to name *Optional -This parameter allows you to override the name of your Vera device in the HA interface, if not specified the -value configured for the device in your Vera will be used +This parameter allows you to override the name of your Vera device in the HA +interface, if not specified the value configured for the device in your Vera +will be used exclude *Optional -This parameter allows you to exclude the specified device from homeassistant, it should be set to "true" if -you want this device excluded - - +This parameter allows you to exclude the specified device from homeassistant, +it should be set to "true" if you want this device excluded """ import logging -import requests import time -import json from homeassistant.helpers import ToggleDevice +# pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger(__name__) -vera_controller = None -vera_switches = [] - +# pylint: disable=unused-argument def get_devices(hass, config): """ Find and return Vera switches. """ try: base_url = config.get('vera_controller_url') if not base_url: - _LOGGER.error("The required parameter 'vera_controller_url' was not found in config") + _LOGGER.error("The required parameter 'vera_controller_url'" + " was not found in config") return False device_data = config.get('device_data', None) @@ -84,9 +84,10 @@ def get_devices(hass, config): if extra_data: exclude = extra_data.get('exclude', False) - if exclude is not True: + if exclude is not True: vera_switches.append(VeraSwitch(device, extra_data)) + # pylint: disable=broad-except except Exception as inst: _LOGGER.error("Could not find Vera switches: %s", inst) return False @@ -94,6 +95,7 @@ def get_devices(hass, config): return vera_switches def get_extra_device_data(device_data, device_id): + """ Gets the additional configuration data by Vera device Id """ if not device_data: return None @@ -104,6 +106,7 @@ def get_extra_device_data(device_data, device_id): def setup_platform(hass, config, add_devices, discovery_info=None): + """ Find and return Vera lights. """ add_devices(get_devices(hass, config)) class VeraSwitch(ToggleDevice): @@ -136,9 +139,11 @@ class VeraSwitch(ToggleDevice): attr['Armed'] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: - lastTripped = self.vera_device.refresh_value('LastTrip') - tripTimeStr = time.strftime("%Y-%m-%d %H:%M", time.localtime(int(lastTripped))) - attr['Last Tripped'] = tripTimeStr + last_tripped = self.vera_device.refresh_value('LastTrip') + trip_time_str = time.strftime("%Y-%m-%d %H:%M", + time.localtime(int(last_tripped))) + + attr['Last Tripped'] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') attr['Tripped'] = 'True' if tripped == '1' else 'False' @@ -156,7 +161,6 @@ class VeraSwitch(ToggleDevice): self.last_command_send = time.time() self.vera_device.switch_off() self.is_on_status = False - @property def is_on(self): @@ -165,7 +169,7 @@ class VeraSwitch(ToggleDevice): return self.is_on_status def update(self): - # We need to debounce the status call after turning switch on or off + # We need to debounce the status call after turning switch on or off # because the vera has some lag in updating the device status if (self.last_command_send + 5) < time.time(): self.is_on_status = self.vera_device.is_switched_on() From f38787c2589311ab556d8afaaab14db9d8a54012 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 01:20:56 +1100 Subject: [PATCH 11/22] reverted gitignore changes --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bf10e8732a1..a82763e1b6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ config/* !config/home-assistant.conf.default homeassistant/components/frontend/www_static/polymer/bower_components/* -__pycache__ # There is not a better solution afaik.. !config/custom_components @@ -63,4 +62,4 @@ nosetests.xml # Mr Developer .mr.developer.cfg .project -.pydevproject +.pydevproject \ No newline at end of file From 50ff26ea209e456be68ef973d444babaff460d4c Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 01:58:11 +1100 Subject: [PATCH 12/22] Fixed flake8 errors --- homeassistant/components/light/vera.py | 15 +++++++++------ homeassistant/components/sensor/vera.py | 22 +++++++++++----------- homeassistant/components/switch/vera.py | 16 +++++++++++----- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 15033a7c495..7ad78e64017 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -66,14 +66,17 @@ import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger(__name__) + # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Find and return Vera lights. """ try: base_url = config.get('vera_controller_url') if not base_url: - _LOGGER.error("The required parameter 'vera_controller_url'" - " was not found in config") + _LOGGER.error( + "The required parameter 'vera_controller_url'" + " was not found in config" + ) return False device_data = config.get('device_data', None) @@ -121,7 +124,6 @@ class VeraLight(ToggleDevice): self.vera_device = vera_device self.extra_data = extra_data - @property def name(self): """ Get the mame of the light. """ @@ -142,8 +144,10 @@ class VeraLight(ToggleDevice): if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') - trip_time_str = time.strftime("%Y-%m-%d %H:%M", - time.localtime(int(last_tripped))) + trip_time_str = time.strftime( + "%Y-%m-%d %H:%M", + time.localtime(int(last_tripped)) + ) attr['Last Tripped'] = trip_time_str @@ -175,4 +179,3 @@ class VeraLight(ToggleDevice): # because the vera has some lag in updating the device status if (self.last_command_send + 5) < time.time(): self.is_on_status = self.vera_device.is_switched_on() - \ No newline at end of file diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 885186fb9f9..b6b777c8dd5 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -62,14 +62,17 @@ import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger(__name__) + # pylint: disable=unused-argument def get_devices(hass, config): """ Find and return Vera Sensors. """ try: base_url = config.get('vera_controller_url') if not base_url: - _LOGGER.error("The required parameter 'vera_controller_url'" - " was not found in config") + _LOGGER.error( + "The required parameter 'vera_controller_url'" + " was not found in config" + ) return False device_data = config.get('device_data', None) @@ -93,10 +96,12 @@ def get_devices(hass, config): return vera_sensors + def setup_platform(hass, config, add_devices, discovery_info=None): """ Performs setup for Vera controller devices """ add_devices(get_devices(hass, config)) + def get_extra_device_data(device_data, device_id): """ Gets the additional configuration data by Vera device Id """ if not device_data: @@ -134,7 +139,6 @@ class VeraSensor(Device): @property def state_attributes(self): attr = super().state_attributes - if self.vera_device.has_battery: attr['Battery'] = self.vera_device.battery_level + '%' @@ -144,26 +148,23 @@ class VeraSensor(Device): if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') - trip_time_str = time.strftime("%Y-%m-%d %H:%M", - time.localtime(int(last_tripped))) - + trip_time_str = time.strftime( + "%Y-%m-%d %H:%M", + time.localtime(int(last_tripped)) + ) attr['Last Tripped'] = trip_time_str - tripped = self.vera_device.refresh_value('Tripped') attr['Tripped'] = 'True' if tripped == '1' else 'False' attr['Vera Device Id'] = self.vera_device.vera_device_id - return attr - def update(self): if self.vera_device.category == "Temperature Sensor": self.vera_device.refresh_value('CurrentTemperature') current_temp = self.vera_device.get_value('CurrentTemperature') vera_temp_units = self.vera_device.veraController.temperature_units self.current_value = current_temp + '°' + vera_temp_units - elif self.vera_device.category == "Light Sensor": self.vera_device.refresh_value('CurrentLevel') self.current_value = self.vera_device.get_value('CurrentLevel') @@ -172,4 +173,3 @@ class VeraSensor(Device): self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped' else: self.current_value = 'Unknown' - \ No newline at end of file diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index f917b7f0477..245747a11d0 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -62,14 +62,17 @@ import homeassistant.external.vera.vera as veraApi _LOGGER = logging.getLogger(__name__) + # pylint: disable=unused-argument def get_devices(hass, config): """ Find and return Vera switches. """ try: base_url = config.get('vera_controller_url') if not base_url: - _LOGGER.error("The required parameter 'vera_controller_url'" - " was not found in config") + _LOGGER.error( + "The required parameter 'vera_controller_url'" + " was not found in config" + ) return False device_data = config.get('device_data', None) @@ -94,6 +97,7 @@ def get_devices(hass, config): return vera_switches + def get_extra_device_data(device_data, device_id): """ Gets the additional configuration data by Vera device Id """ if not device_data: @@ -109,6 +113,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): """ Find and return Vera lights. """ add_devices(get_devices(hass, config)) + class VeraSwitch(ToggleDevice): """ Represents a Vera Switch """ is_on_status = False @@ -140,8 +145,10 @@ class VeraSwitch(ToggleDevice): if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') - trip_time_str = time.strftime("%Y-%m-%d %H:%M", - time.localtime(int(last_tripped))) + trip_time_str = time.strftime( + "%Y-%m-%d %H:%M", + time.localtime(int(last_tripped)) + ) attr['Last Tripped'] = trip_time_str @@ -173,4 +180,3 @@ class VeraSwitch(ToggleDevice): # because the vera has some lag in updating the device status if (self.last_command_send + 5) < time.time(): self.is_on_status = self.vera_device.is_switched_on() - \ No newline at end of file From 7a21e8a3fb795213ddc21e55b36f744cfd3b20b8 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 02:08:46 +1100 Subject: [PATCH 13/22] Fixed flake8 comment warning --- homeassistant/components/light/vera.py | 2 +- homeassistant/components/switch/vera.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 7ad78e64017..d1e55a768c5 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -116,7 +116,7 @@ def get_extra_device_data(device_data, device_id): class VeraLight(ToggleDevice): """ Represents a Vera light """ is_on_status = False - #for debouncing status check after command is sent + # for debouncing status check after command is sent last_command_send = 0 extra_data = None diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 245747a11d0..6deb98631ee 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -117,7 +117,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class VeraSwitch(ToggleDevice): """ Represents a Vera Switch """ is_on_status = False - #for debouncing status check after command is sent + # for debouncing status check after command is sent last_command_send = 0 extra_data = None From 1b29d615622232a9fa969f9a1ea57088d52f5276 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 07:03:56 +1100 Subject: [PATCH 14/22] Made exception handling more specific --- homeassistant/components/light/vera.py | 48 +++++++++++++------------ homeassistant/components/sensor/vera.py | 47 ++++++++++++------------ homeassistant/components/switch/vera.py | 45 +++++++++++------------ 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index d1e55a768c5..ae63777cb8d 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -70,36 +70,38 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices_callback, discovery_info=None): """ Find and return Vera lights. """ + + base_url = config.get('vera_controller_url') + if not base_url: + _LOGGER.error( + "The required parameter 'vera_controller_url'" + " was not found in config" + ) + return False + + device_data = config.get('device_data', None) + + controller = veraApi.VeraController(base_url) + devices = [] try: - base_url = config.get('vera_controller_url') - if not base_url: - _LOGGER.error( - "The required parameter 'vera_controller_url'" - " was not found in config" - ) - return False - - device_data = config.get('device_data', None) - - controller = veraApi.VeraController(base_url) devices = controller.get_devices('Switch') - - lights = [] - for device in devices: - extra_data = get_extra_device_data(device_data, device.deviceId) - exclude = False - if extra_data: - exclude = extra_data.get('exclude', False) - - if exclude is not True: - lights.append(VeraLight(device, extra_data)) - - add_devices_callback(lights) # pylint: disable=broad-except except Exception as inst: _LOGGER.error("Could not find Vera lights: %s", inst) return False + lights = [] + for device in devices: + extra_data = get_extra_device_data(device_data, device.deviceId) + exclude = False + if extra_data: + exclude = extra_data.get('exclude', False) + + if exclude is not True: + lights.append(VeraLight(device, extra_data)) + + add_devices_callback(lights) + def get_extra_device_data(device_data, device_id): """ Gets the additional configuration data by Vera device Id """ diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index b6b777c8dd5..385b5165bb1 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -66,33 +66,36 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def get_devices(hass, config): """ Find and return Vera Sensors. """ + + base_url = config.get('vera_controller_url') + if not base_url: + _LOGGER.error( + "The required parameter 'vera_controller_url'" + " was not found in config" + ) + return False + + device_data = config.get('device_data', None) + + vera_controller = veraApi.VeraController(base_url) + categories = ['Temperature Sensor', 'Light Sensor', 'Sensor'] + devices = [] try: - base_url = config.get('vera_controller_url') - if not base_url: - _LOGGER.error( - "The required parameter 'vera_controller_url'" - " was not found in config" - ) - return False - - device_data = config.get('device_data', None) - - vera_controller = veraApi.VeraController(base_url) - categories = ['Temperature Sensor', 'Light Sensor', 'Sensor'] devices = vera_controller.get_devices(categories) - - vera_sensors = [] - for device in devices: - extra_data = get_extra_device_data(device_data, device.deviceId) - exclude = False - if extra_data: - exclude = extra_data.get('exclude', False) - - if exclude is not True: - vera_sensors.append(VeraSensor(device, extra_data)) # pylint: disable=broad-except except Exception as inst: _LOGGER.error("Could not find Vera sensors: %s", inst) + return False + + vera_sensors = [] + for device in devices: + extra_data = get_extra_device_data(device_data, device.deviceId) + exclude = False + if extra_data: + exclude = extra_data.get('exclude', False) + + if exclude is not True: + vera_sensors.append(VeraSensor(device, extra_data)) return vera_sensors diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 6deb98631ee..7af893d851f 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -66,35 +66,36 @@ _LOGGER = logging.getLogger(__name__) # pylint: disable=unused-argument def get_devices(hass, config): """ Find and return Vera switches. """ + + base_url = config.get('vera_controller_url') + if not base_url: + _LOGGER.error( + "The required parameter 'vera_controller_url'" + " was not found in config" + ) + return False + + device_data = config.get('device_data', None) + + vera_controller = veraApi.VeraController(base_url) + devices = [] try: - base_url = config.get('vera_controller_url') - if not base_url: - _LOGGER.error( - "The required parameter 'vera_controller_url'" - " was not found in config" - ) - return False - - device_data = config.get('device_data', None) - - vera_controller = veraApi.VeraController(base_url) devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) - - vera_switches = [] - for device in devices: - extra_data = get_extra_device_data(device_data, device.deviceId) - exclude = False - if extra_data: - exclude = extra_data.get('exclude', False) - - if exclude is not True: - vera_switches.append(VeraSwitch(device, extra_data)) - # pylint: disable=broad-except except Exception as inst: _LOGGER.error("Could not find Vera switches: %s", inst) return False + vera_switches = [] + for device in devices: + extra_data = get_extra_device_data(device_data, device.deviceId) + exclude = False + if extra_data: + exclude = extra_data.get('exclude', False) + + if exclude is not True: + vera_switches.append(VeraSwitch(device, extra_data)) + return vera_switches From a2f438c6ef97b1bbe1323d5eefff557401a6bf5d Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 07:11:35 +1100 Subject: [PATCH 15/22] now using ATTR_BATTERY_LEVEL --- homeassistant/components/light/vera.py | 4 ++-- homeassistant/components/sensor/vera.py | 3 ++- homeassistant/components/switch/vera.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index ae63777cb8d..322ff97c38a 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -59,7 +59,7 @@ it should be set to "true" if you want this device excluded """ import logging import time - +from homeassistant.const import ATTR_BATTERY_LEVEL from homeassistant.helpers import ToggleDevice # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -138,7 +138,7 @@ class VeraLight(ToggleDevice): attr = super().state_attributes if self.vera_device.has_battery: - attr['Battery'] = self.vera_device.battery_level + '%' + attr[ATTR_BATTERY_LEVEL] = self.vera_device.battery_level + '%' if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 385b5165bb1..63584f85025 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -57,6 +57,7 @@ import logging import time from homeassistant.helpers import Device +from homeassistant.const import ATTR_BATTERY_LEVEL # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -143,7 +144,7 @@ class VeraSensor(Device): def state_attributes(self): attr = super().state_attributes if self.vera_device.has_battery: - attr['Battery'] = self.vera_device.battery_level + '%' + attr[ATTR_BATTERY_LEVEL] = self.vera_device.battery_level + '%' if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 7af893d851f..e6cbe613ad6 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -57,6 +57,7 @@ import logging import time from homeassistant.helpers import ToggleDevice +from homeassistant.const import ATTR_BATTERY_LEVEL # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -138,7 +139,7 @@ class VeraSwitch(ToggleDevice): attr = super().state_attributes if self.vera_device.has_battery: - attr['Battery'] = self.vera_device.battery_level + '%' + attr[ATTR_BATTERY_LEVEL] = self.vera_device.battery_level + '%' if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') From 7772d5af6266b53e113f9c443dab06555dfba8c1 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 07:15:41 +1100 Subject: [PATCH 16/22] moved setting name to constructor --- homeassistant/components/light/vera.py | 7 ++++--- homeassistant/components/sensor/vera.py | 7 ++++--- homeassistant/components/switch/vera.py | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 322ff97c38a..9211577f825 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -125,13 +125,14 @@ class VeraLight(ToggleDevice): def __init__(self, vera_device, extra_data=None): self.vera_device = vera_device self.extra_data = extra_data + if self.extra_data and self.extra_data.get('name'): + self._name = self.extra_data.get('name') + self._name = self.vera_device.name @property def name(self): """ Get the mame of the light. """ - if self.extra_data and self.extra_data.get('name'): - return self.extra_data.get('name') - return self.vera_device.name + return self._name @property def state_attributes(self): diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 63584f85025..bd36ad16bff 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -125,6 +125,9 @@ class VeraSensor(Device): def __init__(self, vera_device, extra_data=None): self.vera_device = vera_device self.extra_data = extra_data + if self.extra_data and self.extra_data.get('name'): + self._name = self.extra_data.get('name') + self._name = self.vera_device.name def __str__(self): return "%s %s %s" % (self.name, self.vera_device.deviceId, self.state) @@ -136,9 +139,7 @@ class VeraSensor(Device): @property def name(self): """ Get the mame of the sensor. """ - if self.extra_data and self.extra_data.get('name'): - return self.extra_data.get('name') - return self.vera_device.name + return self._name @property def state_attributes(self): diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index e6cbe613ad6..70865b84fa5 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -126,13 +126,14 @@ class VeraSwitch(ToggleDevice): def __init__(self, vera_device, extra_data=None): self.vera_device = vera_device self.extra_data = extra_data + if self.extra_data and self.extra_data.get('name'): + self._name = self.extra_data.get('name') + self._name = self.vera_device.name @property def name(self): """ Get the mame of the switch. """ - if self.extra_data and self.extra_data.get('name'): - return self.extra_data.get('name') - return self.vera_device.name + return self._name @property def state_attributes(self): From 6dc18ba603bea8ed6b54c328a2bcbc0a0e0f674c Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 07:24:34 +1100 Subject: [PATCH 17/22] removed the VeraLight class and just switched it to using VeraSwitch instead --- homeassistant/components/light/vera.py | 75 +------------------------- 1 file changed, 2 insertions(+), 73 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 9211577f825..e744252ced4 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -58,9 +58,7 @@ it should be set to "true" if you want this device excluded """ import logging -import time -from homeassistant.const import ATTR_BATTERY_LEVEL -from homeassistant.helpers import ToggleDevice +from homeassistant.components.switch.vera import VeraSwitch # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -98,7 +96,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): exclude = extra_data.get('exclude', False) if exclude is not True: - lights.append(VeraLight(device, extra_data)) + lights.append(VeraSwitch(device, extra_data)) add_devices_callback(lights) @@ -113,72 +111,3 @@ def get_extra_device_data(device_data, device_id): return item return None - - -class VeraLight(ToggleDevice): - """ Represents a Vera light """ - is_on_status = False - # for debouncing status check after command is sent - last_command_send = 0 - extra_data = None - - def __init__(self, vera_device, extra_data=None): - self.vera_device = vera_device - self.extra_data = extra_data - if self.extra_data and self.extra_data.get('name'): - self._name = self.extra_data.get('name') - self._name = self.vera_device.name - - @property - def name(self): - """ Get the mame of the light. """ - return self._name - - @property - def state_attributes(self): - attr = super().state_attributes - - if self.vera_device.has_battery: - attr[ATTR_BATTERY_LEVEL] = self.vera_device.battery_level + '%' - - if self.vera_device.is_armable: - armed = self.vera_device.refresh_value('Armed') - attr['Armed'] = 'True' if armed == '1' else 'False' - - if self.vera_device.is_trippable: - last_tripped = self.vera_device.refresh_value('LastTrip') - trip_time_str = time.strftime( - "%Y-%m-%d %H:%M", - time.localtime(int(last_tripped)) - ) - - attr['Last Tripped'] = trip_time_str - - tripped = self.vera_device.refresh_value('Tripped') - attr['Tripped'] = 'True' if tripped == '1' else 'False' - - attr['Vera Device Id'] = self.vera_device.vera_device_id - - return attr - - def turn_on(self, **kwargs): - self.last_command_send = time.time() - self.vera_device.switch_on() - self.is_on_status = True - - def turn_off(self, **kwargs): - self.last_command_send = time.time() - self.vera_device.switch_off() - self.is_on_status = False - - @property - def is_on(self): - """ True if device is on. """ - self.update() - return self.is_on_status - - def update(self): - # We need to debounce the status call after turning light on or off - # because the vera has some lag in updating the device status - if (self.last_command_send + 5) < time.time(): - self.is_on_status = self.vera_device.is_switched_on() From 38fbc3595a9e61afd8ef6a066f6ec697a38cf67d Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 07:46:26 +1100 Subject: [PATCH 18/22] Added spcific exception type for failure to communicate with Vera controller --- homeassistant/components/light/vera.py | 4 ++-- homeassistant/components/sensor/vera.py | 4 ++-- homeassistant/components/switch/vera.py | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index e744252ced4..8f73b3400a7 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -83,8 +83,8 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): devices = [] try: devices = controller.get_devices('Switch') - # pylint: disable=broad-except - except Exception as inst: + except IOError as inst: + # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera lights: %s", inst) return False diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index bd36ad16bff..8f9ede0182d 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -83,8 +83,8 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(categories) - # pylint: disable=broad-except - except Exception as inst: + except IOError as inst: + # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera sensors: %s", inst) return False diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 70865b84fa5..16613648580 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -82,8 +82,8 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) - # pylint: disable=broad-except - except Exception as inst: + except IOError as inst: + # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera switches: %s", inst) return False @@ -175,7 +175,6 @@ class VeraSwitch(ToggleDevice): @property def is_on(self): """ True if device is on. """ - self.update() return self.is_on_status def update(self): From 7dc3198320e7e3a2725af7d6541c976fd67dfce6 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 08:10:31 +1100 Subject: [PATCH 19/22] Added constants for armed, tripped and tripped time --- .coveragerc | 3 +++ homeassistant/components/sensor/vera.py | 9 +++++---- homeassistant/components/switch/vera.py | 11 +++++------ homeassistant/const.py | 10 ++++++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.coveragerc b/.coveragerc index 2ea0f11a6bd..f0953f49cd5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -24,6 +24,9 @@ omit = homeassistant/components/device_tracker/tomato.py homeassistant/components/device_tracker/netgear.py homeassistant/components/device_tracker/nmap_tracker.py + homeassistant/components/light/vera.py + homeassistant/components/sensor/vera.py + homeassistant/components/switch/vera.py [report] diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 8f9ede0182d..6fd978ccd20 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -57,7 +57,8 @@ import logging import time from homeassistant.helpers import Device -from homeassistant.const import ATTR_BATTERY_LEVEL +from homeassistant.const import ( + ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME) # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -149,7 +150,7 @@ class VeraSensor(Device): if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') - attr['Armed'] = 'True' if armed == '1' else 'False' + attr[ATTR_ARMED] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') @@ -157,9 +158,9 @@ class VeraSensor(Device): "%Y-%m-%d %H:%M", time.localtime(int(last_tripped)) ) - attr['Last Tripped'] = trip_time_str + attr[ATTR_LAST_TRIP_TIME] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') - attr['Tripped'] = 'True' if tripped == '1' else 'False' + attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False' attr['Vera Device Id'] = self.vera_device.vera_device_id return attr diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 16613648580..0811ac3b0b9 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -57,7 +57,8 @@ import logging import time from homeassistant.helpers import ToggleDevice -from homeassistant.const import ATTR_BATTERY_LEVEL +from homeassistant.const import ( + ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME) # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -144,7 +145,7 @@ class VeraSwitch(ToggleDevice): if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') - attr['Armed'] = 'True' if armed == '1' else 'False' + attr[ATTR_ARMED] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') @@ -152,11 +153,9 @@ class VeraSwitch(ToggleDevice): "%Y-%m-%d %H:%M", time.localtime(int(last_tripped)) ) - - attr['Last Tripped'] = trip_time_str - + attr[ATTR_LAST_TRIP_TIME] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') - attr['Tripped'] = 'True' if tripped == '1' else 'False' + attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False' attr['Vera Device Id'] = self.vera_device.vera_device_id diff --git a/homeassistant/const.py b/homeassistant/const.py index e90f1338b83..ed74f1edf4f 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -73,6 +73,16 @@ ATTR_LOCATION = "location" ATTR_BATTERY_LEVEL = "battery_level" +# For devices which support an armed state +ATTR_ARMED = "device_armed" + +# For sensors that support 'tripping', eg. motion and door sensors +ATTR_TRIPPED = "device_tripped" + +# For sensors that support 'tripping' this holds the most recent +# time the device was tripped +ATTR_LAST_TRIP_TIME = "last_tripped_time" + # #### SERVICES #### SERVICE_HOMEASSISTANT_STOP = "stop" From 95852db18db22818774e220175990c35911bd7e0 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 08:34:06 +1100 Subject: [PATCH 20/22] Changed the configuration to use hashes instead of searching array --- homeassistant/components/light/vera.py | 29 +++++----------------- homeassistant/components/sensor/vera.py | 33 ++++++------------------- homeassistant/components/switch/vera.py | 31 ++++++----------------- 3 files changed, 22 insertions(+), 71 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 8f73b3400a7..50dc86dfdb5 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -13,12 +13,10 @@ light: platform: vera vera_controller_url: http://YOUR_VERA_IP:3480/ device_data: - - - vera_id: 12 + 12: name: My awesome switch exclude: true - - - vera_id: 13 + 13: name: Another switch VARIABLES: @@ -34,16 +32,12 @@ device_data *Optional This contains an array additional device info for your Vera devices. It is not required and if not specified all lights configured in your Vera controller -will be added with default values. +will be added with default values. You should use the id of your vera device +as the key for the device within device_data These are the variables for the device_data array: -vera_id -*Required -The Vera device id you wish these configuration options to be applied to - - name *Optional This parameter allows you to override the name of your Vera device in the HA @@ -77,7 +71,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): ) return False - device_data = config.get('device_data', None) + device_data = config.get('device_data', {}) controller = veraApi.VeraController(base_url) devices = [] @@ -90,7 +84,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): lights = [] for device in devices: - extra_data = get_extra_device_data(device_data, device.deviceId) + extra_data = device_data.get(device.deviceId, None) exclude = False if extra_data: exclude = extra_data.get('exclude', False) @@ -100,14 +94,3 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): add_devices_callback(lights) - -def get_extra_device_data(device_data, device_id): - """ Gets the additional configuration data by Vera device Id """ - if not device_data: - return None - - for item in device_data: - if item.get('vera_id') == device_id: - return item - - return None diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 6fd978ccd20..78e5528c792 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -9,12 +9,10 @@ sensor: platform: vera vera_controller_url: http://YOUR_VERA_IP:3480/ device_data: - - - vera_id: 12 + 12: name: My awesome sensor exclude: true - - - vera_id: 13 + 13: name: Another sensor VARIABLES: @@ -30,16 +28,11 @@ device_data *Optional This contains an array additional device info for your Vera devices. It is not required and if not specified all sensors configured in your Vera controller -will be added with default values. - +will be added with default values. You should use the id of your vera device +as the key for the device within device_data These are the variables for the device_data array: -vera_id -*Required -The Vera device id you wish these configuration options to be applied to - - name *Optional This parameter allows you to override the name of your Vera device in the HA @@ -77,7 +70,7 @@ def get_devices(hass, config): ) return False - device_data = config.get('device_data', None) + device_data = config.get('device_data', {}) vera_controller = veraApi.VeraController(base_url) categories = ['Temperature Sensor', 'Light Sensor', 'Sensor'] @@ -91,7 +84,7 @@ def get_devices(hass, config): vera_sensors = [] for device in devices: - extra_data = get_extra_device_data(device_data, device.deviceId) + extra_data = device_data.get(device.deviceId, None) exclude = False if extra_data: exclude = extra_data.get('exclude', False) @@ -107,17 +100,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(get_devices(hass, config)) -def get_extra_device_data(device_data, device_id): - """ Gets the additional configuration data by Vera device Id """ - if not device_data: - return None - - for item in device_data: - if item.get('vera_id') == device_id: - return item - return None - - class VeraSensor(Device): """ Represents a Vera Sensor """ extra_data = None @@ -128,7 +110,8 @@ class VeraSensor(Device): self.extra_data = extra_data if self.extra_data and self.extra_data.get('name'): self._name = self.extra_data.get('name') - self._name = self.vera_device.name + else: + self._name = self.vera_device.name def __str__(self): return "%s %s %s" % (self.name, self.vera_device.deviceId, self.state) diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 0811ac3b0b9..e6906e9c075 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -9,12 +9,10 @@ switch: platform: vera vera_controller_url: http://YOUR_VERA_IP:3480/ device_data: - - - vera_id: 12 + 12: name: My awesome switch exclude: true - - - vera_id: 13 + 13: name: Another Switch VARIABLES: @@ -30,15 +28,12 @@ device_data *Optional This contains an array additional device info for your Vera devices. It is not required and if not specified all lights configured in your Vera controller -will be added with default values. +will be added with default values. You should use the id of your vera device +as the key for the device within device_data These are the variables for the device_data array: -vera_id -*Required -The Vera device id you wish these configuration options to be applied to - name *Optional @@ -77,7 +72,7 @@ def get_devices(hass, config): ) return False - device_data = config.get('device_data', None) + device_data = config.get('device_data', {}) vera_controller = veraApi.VeraController(base_url) devices = [] @@ -90,7 +85,7 @@ def get_devices(hass, config): vera_switches = [] for device in devices: - extra_data = get_extra_device_data(device_data, device.deviceId) + extra_data = device_data.get(device.deviceId, None) exclude = False if extra_data: exclude = extra_data.get('exclude', False) @@ -101,17 +96,6 @@ def get_devices(hass, config): return vera_switches -def get_extra_device_data(device_data, device_id): - """ Gets the additional configuration data by Vera device Id """ - if not device_data: - return None - - for item in device_data: - if item.get('vera_id') == device_id: - return item - return None - - def setup_platform(hass, config, add_devices, discovery_info=None): """ Find and return Vera lights. """ add_devices(get_devices(hass, config)) @@ -129,7 +113,8 @@ class VeraSwitch(ToggleDevice): self.extra_data = extra_data if self.extra_data and self.extra_data.get('name'): self._name = self.extra_data.get('name') - self._name = self.vera_device.name + else: + self._name = self.vera_device.name @property def name(self): From 7ee37648d878b05816a1f0c797327236bf49497f Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 08:45:20 +1100 Subject: [PATCH 21/22] Updated exception type for errors when connecting to vera --- homeassistant/components/light/vera.py | 4 ++-- homeassistant/components/sensor/vera.py | 3 ++- homeassistant/components/switch/vera.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 50dc86dfdb5..e3173c8c88d 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -52,6 +52,7 @@ it should be set to "true" if you want this device excluded """ import logging +from requests.exceptions import RequestException from homeassistant.components.switch.vera import VeraSwitch # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -77,7 +78,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): devices = [] try: devices = controller.get_devices('Switch') - except IOError as inst: + except RequestException as inst: # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera lights: %s", inst) return False @@ -93,4 +94,3 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): lights.append(VeraSwitch(device, extra_data)) add_devices_callback(lights) - diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 78e5528c792..0f4170fa806 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -48,6 +48,7 @@ it should be set to "true" if you want this device excluded """ import logging import time +from requests.exceptions import RequestException from homeassistant.helpers import Device from homeassistant.const import ( @@ -77,7 +78,7 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(categories) - except IOError as inst: + except RequestException as inst: # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera sensors: %s", inst) return False diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index e6906e9c075..828212d70d2 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -50,6 +50,7 @@ it should be set to "true" if you want this device excluded """ import logging import time +from requests.exceptions import RequestException from homeassistant.helpers import ToggleDevice from homeassistant.const import ( @@ -78,7 +79,7 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) - except IOError as inst: + except RequestException as inst: # There was a network related error connecting to the vera controller _LOGGER.error("Could not find Vera switches: %s", inst) return False From 56622596e70b7c962af6994c8d85912033521040 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 9 Mar 2015 09:11:59 +1100 Subject: [PATCH 22/22] Changed exception logging, and updated excluded device logic --- homeassistant/components/light/vera.py | 10 ++++------ homeassistant/components/sensor/vera.py | 10 ++++------ homeassistant/components/switch/vera.py | 10 ++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index e3173c8c88d..46fd3b54bb4 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -78,17 +78,15 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): devices = [] try: devices = controller.get_devices('Switch') - except RequestException as inst: + except RequestException: # There was a network related error connecting to the vera controller - _LOGGER.error("Could not find Vera lights: %s", inst) + _LOGGER.exception("Error communicating with Vera API") return False lights = [] for device in devices: - extra_data = device_data.get(device.deviceId, None) - exclude = False - if extra_data: - exclude = extra_data.get('exclude', False) + extra_data = device_data.get(device.deviceId, {}) + exclude = extra_data.get('exclude', False) if exclude is not True: lights.append(VeraSwitch(device, extra_data)) diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 0f4170fa806..71531253207 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -78,17 +78,15 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(categories) - except RequestException as inst: + except RequestException: # There was a network related error connecting to the vera controller - _LOGGER.error("Could not find Vera sensors: %s", inst) + _LOGGER.exception("Error communicating with Vera API") return False vera_sensors = [] for device in devices: - extra_data = device_data.get(device.deviceId, None) - exclude = False - if extra_data: - exclude = extra_data.get('exclude', False) + extra_data = device_data.get(device.deviceId, {}) + exclude = extra_data.get('exclude', False) if exclude is not True: vera_sensors.append(VeraSensor(device, extra_data)) diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 828212d70d2..800913e6850 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -79,17 +79,15 @@ def get_devices(hass, config): devices = [] try: devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) - except RequestException as inst: + except RequestException: # There was a network related error connecting to the vera controller - _LOGGER.error("Could not find Vera switches: %s", inst) + _LOGGER.exception("Error communicating with Vera API") return False vera_switches = [] for device in devices: - extra_data = device_data.get(device.deviceId, None) - exclude = False - if extra_data: - exclude = extra_data.get('exclude', False) + extra_data = device_data.get(device.deviceId, {}) + exclude = extra_data.get('exclude', False) if exclude is not True: vera_switches.append(VeraSwitch(device, extra_data))