homeassistant-config/www/custom_ui/mini-graph-card-bundle.js

2 lines
74 KiB
JavaScript

(function(){"use strict";function a(){const b=E(["\n <div class=\"info__item\">\n <span class=\"info__item__type\">","</span>\n <span class=\"info__item__value\">\n "," ","\n </span>\n <span class=\"info__item__time\">\n ","\n </span>\n </div>\n "]);return a=function(){return b},b}function b(){const a=E(["\n <div class=\"info flex\">\n ","\n </div>\n "]);return b=function(){return a},a}function c(){const a=E(["\n <div class=\"graph__labels flex\">\n <span class=\"label--max\">","</span>\n <span class=\"label--min\">","</span>\n </div>\n "]);return c=function(){return a},a}function d(){const a=E(["\n <svg width='100%' height="," viewBox='0 0 500 ","'\n @click=",">\n <g>\n <defs>\n ","\n </defs>\n ","\n ","\n ","\n ","\n </g>\n ","\n </svg>"]);return d=function(){return a},a}function e(){const a=E(["<g class='bars' ?anim=",">","</g>"]);return e=function(){return a},a}function f(){const a=E(["\n <rect class='bar' x="," y=","\n height="," width="," fill=","\n @mouseover=","\n @mouseout=",">\n ","\n </rect>"]);return f=function(){return a},a}function g(){const a=E(["\n <animate attributeName='y' from="," to="," dur='1s' fill='remove'\n calcMode='spline' keyTimes='0; 1' keySplines='0.215 0.61 0.355 1'>\n </animate>"]);return g=function(){return a},a}function h(){const a=E(["\n <rect class='line--rect'\n ?inactive=","\n id=","\n fill="," height=\"100%\" width=\"100%\"\n mask=","\n />"]);return h=function(){return a},a}function i(){const a=E(["",""]);return i=function(){return a},a}function j(){const a=E(["\n <stop stop-color="," offset="," />\n "]);return j=function(){return a},a}function k(){const a=E(["\n <linearGradient id="," gradientTransform=\"rotate(90)\">\n ","\n </linearGradient>"]);return k=function(){return a},a}function l(){const a=E(["\n <g class='line--points'\n ?tooltip=","\n ?inactive=","\n ?init=","\n anim=","\n style=\"animation-delay: ","\"\n fill=","\n stroke=","\n stroke-width=",">\n ","\n </g>"]);return l=function(){return a},a}function m(){const a=E(["\n <circle\n class='line--point'\n ?inactive=","\n style=","\n stroke=","\n fill=","\n cx="," cy="," r=","\n @mouseover=","\n @mouseout=","\n />\n "]);return m=function(){return a},a}function n(){const a=E(["\n <mask id=",">\n ","\n </mask>\n "]);return n=function(){return a},a}function o(){const a=E(["\n <path\n class='line'\n .id=","\n anim="," ?init=","\n style=\"animation-delay: ","\"\n fill='none'\n stroke-dasharray="," stroke-dashoffset=","\n stroke=","\n stroke-width=","\n d=","\n />"]);return o=function(){return a},a}function p(){const a=E(["\n <defs>\n <linearGradient id="," x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\">\n <stop stop-color="," offset='0%' stop-opacity='1'/>\n <stop stop-color="," offset='100%' stop-opacity='.15'/>\n </linearGradient>\n </defs>\n <path class='line--fill'\n ?inactive=","\n type=","\n .id="," anim="," ?init=","\n style=\"animation-delay: ","\"\n fill=","\n stroke=","\n stroke-width=","\n d=","\n />"]);return p=function(){return a},a}function q(){const a=E(["\n <svg width='10' height='10'>\n <rect width='10' height='10' fill="," />\n </svg>\n "]);return q=function(){return a},a}function r(){const a=E(["\n <div class=\"graph__legend__item\"\n @click=","\n @mouseover=","\n @mouseout=",">\n ","\n <span class=\"ellipsis\">","</span>\n </div>\n "]);return r=function(){return a},a}function s(){const a=E(["\n <div class=\"graph__legend\">\n ","\n </div>\n "]);return s=function(){return a},a}function t(){const a=E(["\n <div class=\"graph\">\n <div class=\"graph__container\">\n ","\n <div class=\"graph__container__svg\">\n ","\n </div>\n </div>\n ","\n </div>"]);return t=function(){return a},a}function u(){const a=E(["\n <span>","</span> -\n <span>","</span>\n "]);return u=function(){return a},a}function v(){const a=E(["\n <span>","</span>\n "]);return v=function(){return a},a}function w(){const a=E(["\n <div class=\"state__time\">\n ","\n </div>\n "]);return w=function(){return a},a}function x(){const a=E(["\n <div\n class=\"state state--small\"\n style=",">\n ","\n <span class=\"state__value ellipsis\">\n ","\n </span>\n <span class=\"state__uom ellipsis\">\n ","\n </span>\n </div>\n "]);return x=function(){return a},a}function y(){const a=E(["\n <div class=\"states flex\" loc=",">\n <div class=\"state\">\n <span class=\"state__value ellipsis\" style=",">\n ","\n </span>\n <span class=\"state__uom ellipsis\" style=",">\n ","\n </span>\n ","\n </div>\n <div class=\"states--secondary\">","</div>\n ","\n </div>\n "]);return y=function(){return a},a}function z(){const a=E(["\n <div class=\"name flex\">\n <span class=\"ellipsis\" style=",">","</span>\n </div>\n "]);return z=function(){return a},a}function A(){const a=E(["\n <div class=\"icon\" loc=","\n style=",">\n <ha-icon .icon=","></ha-icon>\n </div>\n "]);return A=function(){return a},a}function B(){const a=E(["\n <div class=\"header flex\" loc="," style=\"font-size: ","px;\">\n "," ","\n </div>\n "]);return B=function(){return a},a}function C(){const a=E(["\n <ha-card\n class=\"flex\"\n ?group=","\n ?fill=","\n ?points=","\n ?labels=","\n ?gradient=","\n ?more-info=","\n style=\"font-size: ","px;\"\n @click=","\n >\n "," "," "," ","\n </ha-card>\n "]);return C=function(){return a},a}function D(){const a=E(["\n :host {\n display: flex;\n flex-direction: column;\n }\n ha-card {\n flex-direction: column;\n flex: 1;\n padding: 16px 0;\n position: relative;\n overflow: hidden;\n }\n ha-card > div {\n padding: 0px 16px 16px 16px;\n }\n ha-card > div:last-child {\n padding-bottom: 0;\n }\n ha-card[points] .line--points,\n ha-card[labels] .graph__labels {\n opacity: 0;\n transition: opacity .25s;\n animation: none;\n }\n ha-card[points]:hover .line--points,\n ha-card:hover .graph__labels {\n opacity: 1;\n }\n ha-card[fill] {\n padding-bottom: 0;\n }\n ha-card[fill] .graph {\n padding: 0;\n order: 10;\n }\n ha-card[fill] path {\n stroke-linecap: initial;\n stroke-linejoin: initial;\n }\n ha-card[fill] .graph__legend {\n order: -1;\n padding: 0 16px 8px 16px;\n }\n ha-card[fill] .info {\n padding-bottom: 16px;\n }\n ha-card[group] {\n box-shadow: none;\n padding: 0;\n }\n ha-card[group] > div {\n padding-left: 0;\n padding-right: 0;\n }\n ha-card[group] .graph__legend {\n padding-left: 0;\n padding-right: 0;\n }\n ha-card[more-info] {\n cursor: pointer;\n }\n .flex {\n display: flex;\n display: -webkit-flex;\n min-width: 0;\n }\n .header {\n justify-content: space-between;\n }\n .header[loc=\"center\"] {\n justify-content: space-around;\n }\n .header[loc=\"left\"] {\n align-self: flex-start;\n }\n .header[loc=\"right\"] {\n align-self: flex-end;\n }\n .name {\n align-items: center;\n min-width: 0;\n opacity: .8;\n letter-spacing: .05em;\n }\n .name > span {\n font-size: 1.2em;\n font-weight: 400;\n max-height: 1.4em;\n min-height: 1.4em;\n opacity: .75;\n }\n .icon {\n color: var(--paper-item-icon-color, #44739e);\n display: inline-block;\n flex: 0 0 1.7em;\n text-align: center;\n }\n .icon > ha-icon {\n height: 1.7em;\n width: 1.7em;\n }\n .icon[loc=\"left\"] {\n order: -1;\n margin-right: .6em;\n margin-left: 0;\n }\n .icon[loc=\"state\"] {\n align-self: center;\n }\n .states {\n align-items: flex-start;\n font-weight: 300;\n justify-content: space-between;\n flex-wrap: nowrap;\n }\n .states .icon {\n align-self: center;\n margin-left: 0;\n }\n .states[loc=\"center\"] {\n justify-content: space-evenly;\n }\n .states[loc=\"right\"] > .state {\n margin-left: auto;\n order: 2;\n }\n .states[loc=\"center\"] .states--secondary,\n .states[loc=\"right\"] .states--secondary {\n margin-left: 0;\n }\n .states[loc=\"center\"] .states--secondary {\n align-items: center;\n }\n .states[loc=\"right\"] .states--secondary {\n align-items: flex-start;\n }\n .states[loc=\"center\"] .state__time {\n left: 50%;\n transform: translateX(-50%);\n }\n .states > .icon > ha-icon {\n height: 2em !important;\n width: 2em !important;\n }\n .states--secondary {\n display: flex;\n flex-flow: column;\n flex-wrap: wrap;\n align-items: flex-end;\n margin-left: 1rem;\n min-width: 0;\n margin-left: 1.4em;\n }\n .states--secondary:empty {\n display: none;\n }\n .state {\n position: relative;\n display: flex;\n flex-wrap: wrap;\n max-width: 100%;\n min-width: 0;\n }\n .state--small {\n font-size: .6em;\n margin-bottom: .6rem;\n flex-wrap: nowrap;\n }\n .state--small > svg {\n position: absolute;\n left: -1.6em;\n align-self: center;\n height: 1em;\n width: 1em;\n border-radius: 100%;\n margin-right: 1em;\n }\n .state--small:last-child {\n margin-bottom: 0;\n }\n .states--secondary > :only-child {\n font-size: 1em;\n margin-bottom: 0;\n }\n .states--secondary > :only-child svg {\n display: none;\n }\n .state__value {\n display: inline-block;\n font-size: 2.4em;\n line-height: 1em;\n margin-right: .25rem;\n }\n .state__uom {\n align-self: flex-end;\n display: inline-block;\n font-size: 1.4em;\n font-weight: 400;\n line-height: 1.2em;\n margin-top: .1em;\n opacity: .6;\n vertical-align: bottom;\n }\n .state--small .state__uom {\n flex: 1;\n }\n .state__time {\n font-size: .95rem;\n font-weight: 500;\n bottom: -1.1rem;\n left: 0;\n opacity: .75;\n position: absolute;\n white-space: nowrap;\n }\n .states[loc=\"right\"] .state__time {\n left: initial;\n right: 0;\n }\n .graph {\n align-self: flex-end;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n margin-top: auto;\n width: 100%;\n }\n .graph__container {\n display: flex;\n flex-direction: row;\n position: relative;\n }\n .graph__container__svg {\n cursor: default;\n flex: 1;\n }\n svg {\n overflow: hidden;\n }\n path {\n stroke-linecap: round;\n stroke-linejoin: round;\n }\n .line--fill[anim=\"false\"] {\n animation: reveal .25s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .line--fill[anim=\"false\"][type=\"fade\"] {\n animation: reveal-2 .25s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .line--points[anim=\"false\"],\n .line[anim=\"false\"] {\n animation: pop .25s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .line--points[inactive],\n .line--rect[inactive],\n .line--fill[inactive] {\n opacity: 0 !important;\n animation: none !important;\n transition: all .15s !important;\n }\n .line--points[inactive] {\n }\n .line--points[tooltip] .line--point[inactive] {\n opacity: 0;\n }\n .line--point {\n cursor: pointer;\n fill: var(--paper-card-background-color, white);\n stroke-width: inherit;\n }\n .line--point:hover {\n fill: var(--mcg-hover, inherit) !important;\n }\n .bars {\n animation: pop .25s cubic-bezier(0.215, 0.61, 0.355, 1);\n }\n .bars[anim] {\n animation: bars .5s cubic-bezier(0.215, 0.61, 0.355, 1);\n }\n .bar {\n transition: opacity .25s cubic-bezier(0.215, 0.61, 0.355, 1);\n }\n .bar:hover {\n opacity: .5;\n cursor: pointer;\n }\n ha-card[gradient] .line--point:hover {\n fill: var(--primary-text-color, white);\n }\n path,\n .line--points,\n .line--fill {\n opacity: 0;\n }\n .line--points[anim=\"true\"][init] {\n animation: pop .5s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .line--fill[anim=\"true\"][init] {\n animation: reveal .5s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .line--fill[anim=\"true\"][init][type=\"fade\"] {\n animation: reveal-2 .5s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .line[anim=\"true\"][init] {\n animation: dash 1s cubic-bezier(0.215, 0.61, 0.355, 1) forwards;\n }\n .graph__labels {\n align-items: flex-start;\n flex-direction: column;\n font-size: calc(.15em + 8.5px);\n font-weight: 400;\n justify-content: space-between;\n margin-right: 10px;\n padding: .6em;\n position: absolute;\n pointer-events: none;\n top: 0; bottom: 0;\n opacity: .75;\n }\n .graph__labels > span {\n cursor: pointer;\n background: var(--primary-background-color, white);\n border-radius: 1em;\n padding: .2em .6em;\n box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.24);\n }\n .graph__legend {\n display: flex;\n flex-direction: row;\n justify-content: space-evenly;\n padding-top: 16px;\n flex-wrap: wrap;\n }\n .graph__legend__item {\n cursor: pointer;\n display: flex;\n min-width: 0;\n margin: .4em;\n align-items: center\n }\n .graph__legend__item span {\n opacity: .75;\n margin-left: .4em;\n }\n .graph__legend__item svg {\n border-radius: 100%;\n }\n .info {\n justify-content: space-between;\n align-items: middle;\n }\n .info__item {\n display: flex;\n flex-flow: column;\n align-items: flex-end;\n text-align: right;\n }\n .info__item:first-child {\n align-items: flex-start;\n text-align: left;\n }\n .info__item__type {\n text-transform: capitalize;\n font-weight: 500;\n opacity: .9;\n }\n .info__item__time,\n .info__item__value {\n opacity: .75;\n }\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n @keyframes reveal {\n 0% { opacity: 0; }\n 100% { opacity: .15; }\n }\n @keyframes reveal-2 {\n 0% { opacity: 0; }\n 100% { opacity: .4; }\n }\n @keyframes pop {\n 0% { opacity: 0; }\n 100% { opacity: 1; }\n }\n @keyframes bars {\n 0% { opacity: 0; }\n 50% { opacity: 0; }\n 100% { opacity: 1; }\n }\n @keyframes dash {\n 0% {\n opacity: 0;\n }\n 25% {\n opacity: 1;\n }\n 100% {\n opacity: 1;\n stroke-dashoffset: 0;\n }\n }"]);return D=function(){return a},a}function E(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function F(a){for(var b=1;b<arguments.length;b++){var c=null==arguments[b]?{}:arguments[b],d=Object.keys(c);"function"==typeof Object.getOwnPropertySymbols&&(d=d.concat(Object.getOwnPropertySymbols(c).filter(function(a){return Object.getOwnPropertyDescriptor(c,a).enumerable}))),d.forEach(function(b){G(a,b,c[b])})}return a}function G(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function H(a){return K(a)||J(a)||I()}function I(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function J(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function K(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b():"function"==typeof define&&define.amd?define(b):b()})(this,function(){var ta=Number.isNaN,ua=Math.max,va=Math.min,wa=Math.ceil,xa=Math.abs;function E(a){let b=_a.get(a.type);void 0===b&&(b={stringsArray:new WeakMap,keyString:new Map},_a.set(a.type,b));let c=b.stringsArray.get(a.strings);if(void 0!==c)return c;const d=a.strings.join(Fa);return c=b.keyString.get(d),void 0===c&&(c=new Ja(a,a.getTemplateElement()),b.keyString.set(d,c)),b.stringsArray.set(a.strings,c),c}function G(a,b){const{element:{content:d},parts:c}=a,e=document.createTreeWalker(d,eb,null,!1);let f=gb(c),g=c[f],h=-1,i=0;const j=[];for(let d=null;e.nextNode();){h++;const a=e.currentNode;for(a.previousSibling===d&&(d=null),b.has(a)&&(j.push(a),null===d&&(d=a)),null!==d&&i++;g!==void 0&&g.index===h;)g.index=null===d?g.index-i:-1,f=gb(c,f),g=c[f]}j.forEach(a=>a.parentNode.removeChild(a))}function I(a,b,c=null){const{element:{content:e},parts:d}=a;if(null===c||void 0===c)return void e.appendChild(b);const f=document.createTreeWalker(e,eb,null,!1);let g=gb(d),h=0,i=-1;for(;f.nextNode();){i++;const a=f.currentNode;for(a===c&&(h=fb(b),c.parentNode.insertBefore(b,c));-1!==g&&d[g].index===i;){if(0<h){for(;-1!==g;)d[g].index+=h,g=gb(d,g);return}g=gb(d,g)}}}function J(a,b=[]){for(let c=0,d=a.length;c<d;c++){const d=a[c];Array.isArray(d)?J(d,b):b.push(d)}return b}function K(a,b){a=a||[],b=b||{};try{return new Blob(a,b)}catch(f){if("TypeError"!==f.name)throw f;for(var c="undefined"==typeof BlobBuilder?"undefined"==typeof MSBlobBuilder?"undefined"==typeof MozBlobBuilder?WebKitBlobBuilder:MozBlobBuilder:MSBlobBuilder:BlobBuilder,d=new c,e=0;e<a.length;e+=1)d.append(a[e]);return d.getBlob(b.type)}}function L(a,b){b&&a.then(function(a){b(null,a)},function(a){b(a)})}function M(a,b,c){"function"==typeof b&&a.then(b),"function"==typeof c&&a.catch(c)}function N(a){return"string"!=typeof a&&(console.warn("".concat(a," used as a key, but it is not a string.")),a+=""),a}function O(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function P(a){for(var b=a.length,c=new ArrayBuffer(b),d=new Uint8Array(c),e=0;e<b;e++)d[e]=a.charCodeAt(e);return c}function Q(a){return new Promise(function(b){var c=a.transaction(Gb,Lb),d=K([""]);c.objectStore(Gb).put(d,"key"),c.onabort=function(a){a.preventDefault(),a.stopPropagation(),b(!1)},c.oncomplete=function(){var a=navigator.userAgent.match(/Chrome\/(\d+)/),c=navigator.userAgent.match(/Edge\//);b(c||!a||43<=parseInt(a[1],10))}}).catch(function(){return!1})}function R(a){return"boolean"==typeof Hb?Promise.resolve(Hb):Q(a).then(function(a){return Hb=a,Hb})}function S(a){var b=Ib[a.name],c={};c.promise=new Promise(function(a,b){c.resolve=a,c.reject=b}),b.deferredOperations.push(c),b.dbReady=b.dbReady?b.dbReady.then(function(){return c.promise}):c.promise}function T(a){var b=Ib[a.name],c=b.deferredOperations.pop();if(c)return c.resolve(),c.promise}function U(a,b){var c=Ib[a.name],d=c.deferredOperations.pop();if(d)return d.reject(b),d.promise}function W(a,b){return new Promise(function(c,d){if(Ib[a.name]=Ib[a.name]||ga(),a.db)if(b)S(a),a.db.close();else return c(a.db);var e=[a.name];b&&e.push(a.version);var f=Fb.open.apply(Fb,e);b&&(f.onupgradeneeded=function(b){var c=f.result;try{c.createObjectStore(a.storeName),1>=b.oldVersion&&c.createObjectStore(Gb)}catch(c){if("ConstraintError"===c.name)console.warn("The database \""+a.name+"\" has been upgraded from version "+b.oldVersion+" to version "+b.newVersion+", but the storage \""+a.storeName+"\" already exists.");else throw c}}),f.onerror=function(a){a.preventDefault(),d(f.error)},f.onsuccess=function(){c(f.result),T(a)}})}function Z(a){return W(a,!1)}function $(a){return W(a,!0)}function _(a,b){if(!a.db)return!0;var c=!a.db.objectStoreNames.contains(a.storeName),d=a.version<a.db.version,e=a.version>a.db.version;if(d&&(a.version!==b&&console.warn("The database \""+a.name+"\" can't be downgraded from version "+a.db.version+" to version "+a.version+"."),a.version=a.db.version),e||c){if(c){var f=a.db.version+1;f>a.version&&(a.version=f)}return!0}return!1}function aa(a){return new Promise(function(b,c){var d=new FileReader;d.onerror=c,d.onloadend=function(c){var d=btoa(c.target.result||"");b({__local_forage_encoded_blob:!0,data:d,type:a.type})},d.readAsBinaryString(a)})}function ba(a){var b=P(atob(a.data));return K([b],{type:a.type})}function ca(a){return a&&a.__local_forage_encoded_blob}function da(a){var b=this,c=b._initReady().then(function(){var a=Ib[b._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return M(c,a,a),c}function ea(a){S(a);for(var b=Ib[a.name],c=b.forages,d=0;d<c.length;d++){const a=c[d];a._dbInfo.db&&(a._dbInfo.db.close(),a._dbInfo.db=null)}return a.db=null,Z(a).then(b=>(a.db=b,_(a)?$(a):b)).then(d=>{a.db=b.db=d;for(var e=0;e<c.length;e++)c[e]._dbInfo.db=d}).catch(b=>{throw U(a,b),b})}function fa(a,b,c,d){d===void 0&&(d=1);try{var e=a.db.transaction(a.storeName,b);c(null,e)}catch(e){if(0<d&&(!a.db||"InvalidStateError"===e.name||"NotFoundError"===e.name))return Promise.resolve().then(()=>{if(!a.db||"NotFoundError"===e.name&&!a.db.objectStoreNames.contains(a.storeName)&&a.version<=a.db.version)return a.db&&(a.version=a.db.version+1),$(a)}).then(()=>ea(a).then(function(){fa(a,b,c,d-1)})).catch(c);c(e)}}function ga(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function ha(a){var b,c,d,e,f,g=.75*a.length,h=a.length,j=0;"="===a[a.length-1]&&(g--,"="===a[a.length-2]&&g--);var k=new ArrayBuffer(g),l=new Uint8Array(k);for(b=0;b<h;b+=4)c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[b]),d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[b+1]),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[b+2]),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[b+3]),l[j++]=c<<2|d>>4,l[j++]=(15&d)<<4|e>>2,l[j++]=(3&e)<<6|63&f;return k}function ia(a){var b,c=new Uint8Array(a),d="";for(b=0;b<c.length;b+=3)d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c[b]>>2],d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&c[b])<<4|c[b+1]>>4],d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&c[b+1])<<2|c[b+2]>>6],d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&c[b+2]];return 2==c.length%3?d=d.substring(0,d.length-1)+"=":1==c.length%3&&(d=d.substring(0,d.length-2)+"=="),d}function ja(a,b,c,d){a.executeSql("CREATE TABLE IF NOT EXISTS ".concat(b.storeName," ")+"(id INTEGER PRIMARY KEY, key unique, value)",[],c,d)}function ka(a,b,c,d,e,f){a.executeSql(c,d,e,function(a,g){g.code===g.SYNTAX_ERR?a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[b.storeName],function(a,h){h.rows.length?f(a,g):ja(a,b,function(){a.executeSql(c,d,e,f)},f)},f):f(a,g)},f)}function la(a,b,c,d){var e=this;a=N(a);var f=new Promise(function(f,g){e.ready().then(function(){void 0===b&&(b=null);var h=b,i=e._dbInfo;i.serializer.serialize(b,function(b,j){j?g(j):i.db.transaction(function(c){ka(c,i,"INSERT OR REPLACE INTO ".concat(i.storeName," ")+"(key, value) VALUES (?, ?)",[a,b],function(){f(h)},function(a,b){g(b)})},function(b){if(b.code===b.QUOTA_ERR){if(0<d)return void f(la.apply(e,[a,h,c,d-1]));g(b)}})})}).catch(g)});return L(f,c),f}function ma(a){return new Promise(function(b,c){a.transaction(function(d){d.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(c,d){for(var e=[],f=0;f<d.rows.length;f++)e.push(d.rows.item(f).name);b({db:a,storeNames:e})},function(a,b){c(b)})},function(a){c(a)})})}function na(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(a){return!1}}function oa(a,b){var c=a.name+"/";return a.storeName!==b.storeName&&(c+=a.storeName+"/"),c}function pa(){try{return localStorage.setItem("_localforage_support_test",!0),localStorage.removeItem("_localforage_support_test"),!1}catch(a){return!0}}function qa(){return!pa()||0<localStorage.length}function ra(a,b){a[b]=function(){const c=arguments;return a.ready().then(function(){return a[b].apply(a,c)})}}function sa(){for(let a=1;a<arguments.length;a++){const b=arguments[a];if(b)for(let a in b)b.hasOwnProperty(a)&&(arguments[0][a]=Wb(b[a])?b[a].slice():b[a])}return arguments[0]}const ya=new WeakMap,za=a=>"function"==typeof a&&ya.has(a),Aa=window.customElements!==void 0&&window.customElements.polyfillWrapFlushCallback!==void 0,Ba=(a,b,c=null,d=null)=>{for(let e=b;e!==c;){const b=e.nextSibling;a.insertBefore(e,d),e=b}},Ca=(a,b,c=null)=>{for(let d=b;d!==c;){const b=d.nextSibling;a.removeChild(d),d=b}},Da={},Ea={},Fa="{{lit-".concat((Math.random()+"").slice(2),"}}"),Ga="<!--".concat(Fa,"-->"),Ha=new RegExp("".concat(Fa,"|").concat(Ga)),Ia="$lit$";class Ja{constructor(a,b){this.parts=[],this.element=b;let c=-1,d=0;const e=[],f=b=>{const g=b.content,h=document.createTreeWalker(g,133,null,!1);for(let g=0;h.nextNode();){c++;const b=h.currentNode;if(1===b.nodeType){if(b.hasAttributes()){const e=b.attributes;let f=0;for(let a=0;a<e.length;a++)0<=e[a].value.indexOf(Fa)&&f++;for(;0<f--;){const e=a.strings[d],f=Ma.exec(e)[2],g=f.toLowerCase()+Ia,h=b.getAttribute(g),i=h.split(Ha);this.parts.push({type:"attribute",index:c,name:f,strings:i}),b.removeAttribute(g),d+=i.length-1}}"TEMPLATE"===b.tagName&&f(b)}else if(3===b.nodeType){const a=b.data;if(0<=a.indexOf(Fa)){const f=b.parentNode,g=a.split(Ha),h=g.length-1;for(let a=0;a<h;a++)f.insertBefore(""===g[a]?La():document.createTextNode(g[a]),b),this.parts.push({type:"node",index:++c});""===g[h]?(f.insertBefore(La(),b),e.push(b)):b.data=g[h],d+=h}}else if(8===b.nodeType)if(b.data===Fa){const a=b.parentNode;(null===b.previousSibling||c===g)&&(c++,a.insertBefore(La(),b)),g=c,this.parts.push({type:"node",index:c}),null===b.nextSibling?b.data="":(e.push(b),c--),d++}else for(let a=-1;-1!==(a=b.data.indexOf(Fa,a+1));)this.parts.push({type:"node",index:-1})}};f(b);for(const c of e)c.parentNode.removeChild(c)}}const Ka=a=>-1!==a.index,La=()=>document.createComment(""),Ma=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F \x09\x0a\x0c\x0d"'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class Na{constructor(a,b,c){this._parts=[],this.template=a,this.processor=b,this.options=c}update(a){let b=0;for(const c of this._parts)void 0!==c&&c.setValue(a[b]),b++;for(const b of this._parts)void 0!==b&&b.commit()}_clone(){const a=Aa?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),b=this.template.parts;let c=0,d=0;const e=a=>{const f=document.createTreeWalker(a,133,null,!1);for(let h=f.nextNode();c<b.length&&null!==h;){const a=b[c];if(!Ka(a))this._parts.push(void 0),c++;else if(d===a.index){if("node"===a.type){const a=this.processor.handleTextExpression(this.options);a.insertAfterNode(h.previousSibling),this._parts.push(a)}else{var g;(g=this._parts).push.apply(g,H(this.processor.handleAttributeExpressions(h,a.name,a.strings,this.options)))}c++}else d++,"TEMPLATE"===h.nodeName&&e(h.content),h=f.nextNode()}};return e(a),Aa&&(document.adoptNode(a),customElements.upgrade(a)),a}}class Oa{constructor(a,b,c,d){this.strings=a,this.values=b,this.type=c,this.processor=d}getHTML(){const a=this.strings.length-1;let b="";for(let c=0;c<a;c++){const a=this.strings[c],d=Ma.exec(a);b+=d?a.substr(0,d.index)+d[1]+d[2]+Ia+d[3]+Fa:a+Ga}return b+this.strings[a]}getTemplateElement(){const a=document.createElement("template");return a.innerHTML=this.getHTML(),a}}class Pa extends Oa{getHTML(){return"<svg>".concat(super.getHTML(),"</svg>")}getTemplateElement(){const a=super.getTemplateElement(),b=a.content,c=b.firstChild;return b.removeChild(c),Ba(b,c.firstChild),a}}const Qa=a=>null===a||"object"!=typeof a&&"function"!=typeof a;class Ra{constructor(a,b,c){this.dirty=!0,this.element=a,this.name=b,this.strings=c,this.parts=[];for(let d=0;d<c.length-1;d++)this.parts[d]=this._createPart()}_createPart(){return new Sa(this)}_getValue(){const a=this.strings,b=a.length-1;let c="";for(let d=0;d<b;d++){c+=a[d];const b=this.parts[d];if(void 0!==b){const a=b.value;if(null!=a&&(Array.isArray(a)||"string"!=typeof a&&a[Symbol.iterator]))for(const b of a)c+="string"==typeof b?b:b+"";else c+="string"==typeof a?a:a+""}}return c+=a[b],c}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class Sa{constructor(a){this.value=void 0,this.committer=a}setValue(a){a===Da||Qa(a)&&a===this.value||(this.value=a,!za(a)&&(this.committer.dirty=!0))}commit(){for(;za(this.value);){const a=this.value;this.value=Da,a(this)}this.value===Da||this.committer.commit()}}class Ta{constructor(a){this.value=void 0,this._pendingValue=void 0,this.options=a}appendInto(a){this.startNode=a.appendChild(La()),this.endNode=a.appendChild(La())}insertAfterNode(a){this.startNode=a,this.endNode=a.nextSibling}appendIntoPart(a){a._insert(this.startNode=La()),a._insert(this.endNode=La())}insertAfterPart(a){a._insert(this.startNode=La()),this.endNode=a.endNode,a.endNode=this.startNode}setValue(a){this._pendingValue=a}commit(){for(;za(this._pendingValue);){const a=this._pendingValue;this._pendingValue=Da,a(this)}const a=this._pendingValue;a===Da||(Qa(a)?a!==this.value&&this._commitText(a):a instanceof Oa?this._commitTemplateResult(a):a instanceof Node?this._commitNode(a):Array.isArray(a)||a[Symbol.iterator]?this._commitIterable(a):a===Ea?(this.value=Ea,this.clear()):this._commitText(a))}_insert(a){this.endNode.parentNode.insertBefore(a,this.endNode)}_commitNode(a){this.value===a||(this.clear(),this._insert(a),this.value=a)}_commitText(a){const b=this.startNode.nextSibling;a=null==a?"":a,b===this.endNode.previousSibling&&3===b.nodeType?b.data=a:this._commitNode(document.createTextNode("string"==typeof a?a:a+"")),this.value=a}_commitTemplateResult(a){const b=this.options.templateFactory(a);if(this.value instanceof Na&&this.value.template===b)this.value.update(a.values);else{const c=new Na(b,a.processor,this.options),d=c._clone();c.update(a.values),this._commitNode(d),this.value=c}}_commitIterable(a){Array.isArray(this.value)||(this.value=[],this.clear());const b=this.value;let c,d=0;for(const e of a)c=b[d],void 0===c&&(c=new Ta(this.options),b.push(c),0==d?c.appendIntoPart(this):c.insertAfterPart(b[d-1])),c.setValue(e),c.commit(),d++;d<b.length&&(b.length=d,this.clear(c&&c.endNode))}clear(a=this.startNode){Ca(this.startNode.parentNode,a.nextSibling,this.endNode)}}class Ua{constructor(a,b,c){if(this.value=void 0,this._pendingValue=void 0,2!==c.length||""!==c[0]||""!==c[1])throw new Error("Boolean attributes can only contain a single expression");this.element=a,this.name=b,this.strings=c}setValue(a){this._pendingValue=a}commit(){for(;za(this._pendingValue);){const a=this._pendingValue;this._pendingValue=Da,a(this)}if(this._pendingValue!==Da){const a=!!this._pendingValue;this.value!==a&&(a?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name)),this.value=a,this._pendingValue=Da}}}class Va extends Ra{constructor(a,b,c){super(a,b,c),this.single=2===c.length&&""===c[0]&&""===c[1]}_createPart(){return new Wa(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class Wa extends Sa{}let Xa=!1;try{const a={get capture(){return Xa=!0,!1}};window.addEventListener("test",a,a),window.removeEventListener("test",a,a)}catch(a){}class Ya{constructor(a,b,c){this.value=void 0,this._pendingValue=void 0,this.element=a,this.eventName=b,this.eventContext=c,this._boundHandleEvent=a=>this.handleEvent(a)}setValue(a){this._pendingValue=a}commit(){for(;za(this._pendingValue);){const a=this._pendingValue;this._pendingValue=Da,a(this)}if(this._pendingValue===Da)return;const a=this._pendingValue,b=this.value,c=null==a||null!=b&&(a.capture!==b.capture||a.once!==b.once||a.passive!==b.passive);c&&this.element.removeEventListener(this.eventName,this._boundHandleEvent,this._options),null!=a&&(null==b||c)&&(this._options=Za(a),this.element.addEventListener(this.eventName,this._boundHandleEvent,this._options)),this.value=a,this._pendingValue=Da}handleEvent(a){"function"==typeof this.value?this.value.call(this.eventContext||this.element,a):this.value.handleEvent(a)}}const Za=a=>a&&(Xa?{capture:a.capture,passive:a.passive,once:a.once}:a.capture);const $a=new class{handleAttributeExpressions(a,b,c,d){const e=b[0];if("."===e){const d=new Va(a,b.slice(1),c);return d.parts}if("@"===e)return[new Ya(a,b.slice(1),d.eventContext)];if("?"===e)return[new Ua(a,b.slice(1),c)];const f=new Ra(a,b,c);return f.parts}handleTextExpression(a){return new Ta(a)}},_a=new Map,ab=new WeakMap,bb=(a,b,c)=>{let d=ab.get(b);d===void 0&&(Ca(b,b.firstChild),ab.set(b,d=new Ta(Object.assign({templateFactory:E},c))),d.appendInto(b)),d.setValue(a),d.commit()};(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const cb=(a,...b)=>new Oa(a,b,"html",$a),db=(a,...b)=>new Pa(a,b,"svg",$a),eb=133,fb=a=>{let b=11===a.nodeType?0:1;for(const c=document.createTreeWalker(a,eb,null,!1);c.nextNode();)b++;return b},gb=(a,b=-1)=>{for(let c=b+1;c<a.length;c++){const b=a[c];if(Ka(b))return c}return-1},hb=(a,b)=>"".concat(a,"--").concat(b);let ib=!0;"undefined"==typeof window.ShadyCSS?ib=!1:"undefined"==typeof window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected.Please update to at least @webcomponents/webcomponentsjs@2.0.2 and@webcomponents/shadycss@1.3.1."),ib=!1);const jb=a=>b=>{const c=hb(b.type,a);let d=_a.get(c);void 0===d&&(d={stringsArray:new WeakMap,keyString:new Map},_a.set(c,d));let e=d.stringsArray.get(b.strings);if(void 0!==e)return e;const f=b.strings.join(Fa);if(e=d.keyString.get(f),void 0===e){const c=b.getTemplateElement();ib&&window.ShadyCSS.prepareTemplateDom(c,a),e=new Ja(b,c),d.keyString.set(f,e)}return d.stringsArray.set(b.strings,e),e},kb=["html","svg"],lb=a=>{kb.forEach(b=>{const c=_a.get(hb(b,a));c!==void 0&&c.keyString.forEach(a=>{const{element:{content:b}}=a,c=new Set;Array.from(b.querySelectorAll("style")).forEach(a=>{c.add(a)}),G(a,c)})})},mb=new Set,nb=(a,b,c)=>{mb.add(c);const d=a.querySelectorAll("style");if(0===d.length)return void window.ShadyCSS.prepareTemplateStyles(b.element,c);const e=document.createElement("style");for(let f=0;f<d.length;f++){const a=d[f];a.parentNode.removeChild(a),e.textContent+=a.textContent}if(lb(c),I(b,e,b.element.content.firstChild),window.ShadyCSS.prepareTemplateStyles(b.element,c),window.ShadyCSS.nativeShadow){const c=b.element.content.querySelector("style");a.insertBefore(c.cloneNode(!0),a.firstChild)}else{b.element.content.insertBefore(e,b.element.content.firstChild);const a=new Set;a.add(e),G(b,a)}},ob=(a,b,c)=>{const d=c.scopeName,e=ab.has(b),f=b instanceof ShadowRoot&&ib&&a instanceof Oa,g=f&&!mb.has(d),h=g?document.createDocumentFragment():b;if(bb(a,h,Object.assign({templateFactory:jb(d)},c)),g){const a=ab.get(h);ab.delete(h),a.value instanceof Na&&nb(h,a.value.template,d),Ca(b,b.firstChild),b.appendChild(h),ab.set(b,a)}!e&&f&&window.ShadyCSS.styleElement(b.host)};window.JSCompiler_renameProperty=a=>a;const pb={toAttribute(a,b){return b===Boolean?a?"":null:b===Object||b===Array?null==a?a:JSON.stringify(a):a},fromAttribute(a,b){return b===Boolean?null!==a:b===Number?null===a?null:+a:b===Object||b===Array?JSON.parse(a):a}},qb=(a,b)=>b!==a&&(b===b||a===a),rb={attribute:!0,type:String,converter:pb,reflect:!1,hasChanged:qb},sb=Promise.resolve(!0),tb=1,ub=4,vb=8,wb=16,xb=32;class yb extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=sb,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const a=[];return this._classProperties.forEach((b,c)=>{const d=this._attributeNameForProperty(c,b);void 0!==d&&(this._attributeToPropertyMap.set(d,c),a.push(d))}),a}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const a=Object.getPrototypeOf(this)._classProperties;a!==void 0&&a.forEach((a,b)=>this._classProperties.set(b,a))}}static createProperty(a,b=rb){if(this._ensureClassProperties(),this._classProperties.set(a,b),b.noAccessor||this.prototype.hasOwnProperty(a))return;const c="symbol"==typeof a?Symbol():"__".concat(a);Object.defineProperty(this.prototype,a,{get(){return this[c]},set(b){const d=this[a];this[c]=b,this._requestUpdate(a,d)},configurable:!0,enumerable:!0})}static finalize(){if(!(this.hasOwnProperty(JSCompiler_renameProperty("finalized",this))&&this.finalized)){const a=Object.getPrototypeOf(this);if("function"==typeof a.finalize&&a.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const a=this.properties,b=[].concat(H(Object.getOwnPropertyNames(a)),H("function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(a):[]));for(const c of b)this.createProperty(c,a[c])}}}static _attributeNameForProperty(a,b){const c=b.attribute;return!1===c?void 0:"string"==typeof c?c:"string"==typeof a?a.toLowerCase():void 0}static _valueHasChanged(a,b,c=qb){return c(a,b)}static _propertyValueFromAttribute(a,b){const c=b.type,d=b.converter||pb,e="function"==typeof d?d:d.fromAttribute;return e?e(a,c):a}static _propertyValueToAttribute(a,b){if(void 0===b.reflect)return;const c=b.type,d=b.converter,e=d&&d.toAttribute||pb.toAttribute;return e(a,c)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((a,b)=>{if(this.hasOwnProperty(b)){const a=this[b];delete this[b],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(b,a)}})}_applyInstanceProperties(){this._instanceProperties.forEach((a,b)=>this[b]=a),this._instanceProperties=void 0}connectedCallback(){this._updateState|=xb,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(a,b,c){b!==c&&this._attributeToProperty(a,c)}_propertyToAttribute(a,b,c=rb){const d=this.constructor,e=d._attributeNameForProperty(a,c);if(e!==void 0){const a=d._propertyValueToAttribute(b,c);if(a===void 0)return;this._updateState|=vb,null==a?this.removeAttribute(e):this.setAttribute(e,a),this._updateState&=~vb}}_attributeToProperty(a,b){if(this._updateState&vb)return;const c=this.constructor,d=c._attributeToPropertyMap.get(a);if(d!==void 0){const a=c._classProperties.get(d)||rb;this._updateState|=wb,this[d]=c._propertyValueFromAttribute(b,a),this._updateState&=~wb}}_requestUpdate(a,b){let c=!0;if(a!==void 0){const d=this.constructor,e=d._classProperties.get(a)||rb;d._valueHasChanged(this[a],b,e.hasChanged)?(!this._changedProperties.has(a)&&this._changedProperties.set(a,b),!0===e.reflect&&!(this._updateState&wb)&&(this._reflectingProperties===void 0&&(this._reflectingProperties=new Map),this._reflectingProperties.set(a,e))):c=!1}!this._hasRequestedUpdate&&c&&this._enqueueUpdate()}requestUpdate(a,b){return this._requestUpdate(a,b),this.updateComplete}async _enqueueUpdate(){this._updateState|=ub;let a,b;const c=this._updatePromise;this._updatePromise=new Promise((c,d)=>{a=c,b=d});try{await c}catch(a){}this._hasConnected||(await new Promise(a=>this._hasConnectedResolver=a));try{const a=this.performUpdate();null!=a&&(await a)}catch(a){b(a)}a(!this._hasRequestedUpdate)}get _hasConnected(){return this._updateState&xb}get _hasRequestedUpdate(){return this._updateState&ub}get hasUpdated(){return this._updateState&tb}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let a=!1;const b=this._changedProperties;try{a=this.shouldUpdate(b),a&&this.update(b)}catch(b){throw a=!1,b}finally{this._markUpdated()}a&&(!(this._updateState&tb)&&(this._updateState|=tb,this.firstUpdated(b)),this.updated(b))}_markUpdated(){this._changedProperties=new Map,this._updateState&=~ub}get updateComplete(){return this._updatePromise}shouldUpdate(a){return!0}update(a){this._reflectingProperties!==void 0&&0<this._reflectingProperties.size&&(this._reflectingProperties.forEach((a,b)=>this._propertyToAttribute(b,this[b],a)),this._reflectingProperties=void 0)}updated(a){}firstUpdated(a){}}yb.finalized=!0;const zb="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ab=Symbol();class Bb{constructor(a,b){if(b!==Ab)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=a}get styleSheet(){return void 0===this._styleSheet&&(zb?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Cb=a=>{if(a instanceof Bb)return a.cssText;throw new Error("Value passed to 'css' function must be a 'css' function result: ".concat(a,". Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security."))};(window.litElementVersions||(window.litElementVersions=[])).push("2.0.1");const Db=a=>a.flat?a.flat(1/0):J(a);class Eb extends yb{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const a=this.styles,b=[];if(Array.isArray(a)){const c=Db(a),d=c.reduceRight((a,b)=>(a.add(b),a),new Set);d.forEach(a=>b.unshift(a))}else a&&b.push(a);return b}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const a=this.constructor._styles;0===a.length||(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow?zb?this.renderRoot.adoptedStyleSheets=a.map(a=>a.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(a.map(a=>a.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this)}update(a){super.update(a);const b=this.render();b instanceof Oa&&this.constructor.render(b,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(a=>{const b=document.createElement("style");b.textContent=a.cssText,this.renderRoot.appendChild(b)}))}render(){}}Eb.finalized=!0,Eb.render=ob;var Fb=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(a){}}();"undefined"==typeof Promise&&require("lie/polyfill");const Gb="local-forage-detect-blob-support";let Hb;const Ib={},Jb=Object.prototype.toString,Kb="readonly",Lb="readwrite";var Mb={_driver:"asyncStorage",_initStorage:function(a){function b(){return Promise.resolve()}var c=this,d={db:null};if(a)for(var e in a)d[e]=a[e];var f=Ib[d.name];f||(f=ga(),Ib[d.name]=f),f.forages.push(c),c._initReady||(c._initReady=c.ready,c.ready=da);for(var g,h=[],i=0;i<f.forages.length;i++)g=f.forages[i],g!==c&&h.push(g._initReady().catch(b));var l=f.forages.slice(0);return Promise.all(h).then(function(){return d.db=f.db,Z(d)}).then(function(a){return d.db=a,_(d,c._defaultConfig.version)?$(d):a}).then(function(a){d.db=f.db=a,c._dbInfo=d;for(var b,e=0;e<l.length;e++)b=l[e],b!==c&&(b._dbInfo.db=d.db,b._dbInfo.version=d.version)})},_support:function(){try{if(!Fb)return!1;var a="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),b="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!a||b)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(a){return!1}}(),iterate:function(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){fa(c._dbInfo,Kb,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.openCursor(),i=1;h.onsuccess=function(){var c=h.result;if(c){var d=c.value;ca(d)&&(d=ba(d));var e=a(d,c.key,i++);void 0===e?c.continue():b(e)}else b()},h.onerror=function(){d(h.error)}}catch(a){d(a)}})}).catch(d)});return L(d,b),d},getItem:function(a,b){var c=this;a=N(a);var d=new Promise(function(b,d){c.ready().then(function(){fa(c._dbInfo,Kb,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.get(a);h.onsuccess=function(){var a=h.result;void 0===a&&(a=null),ca(a)&&(a=ba(a)),b(a)},h.onerror=function(){d(h.error)}}catch(a){d(a)}})}).catch(d)});return L(d,b),d},setItem:function(a,b,c){var d=this;a=N(a);var e=new Promise(function(c,f){var g;d.ready().then(function(){return g=d._dbInfo,"[object Blob]"===Jb.call(b)?R(g.db).then(function(a){return a?b:aa(b)}):b}).then(function(b){fa(d._dbInfo,Lb,function(e,g){if(e)return f(e);try{var h=g.objectStore(d._dbInfo.storeName);null===b&&(b=void 0);var i=h.put(b,a);g.oncomplete=function(){void 0===b&&(b=null),c(b)},g.onabort=g.onerror=function(){var a=i.error?i.error:i.transaction.error;f(a)}}catch(a){f(a)}})}).catch(f)});return L(e,c),e},removeItem:function(a,b){var c=this;a=N(a);var d=new Promise(function(b,d){c.ready().then(function(){fa(c._dbInfo,Lb,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=g.delete(a);f.oncomplete=function(){b()},f.onerror=function(){d(h.error)},f.onabort=function(){var a=h.error?h.error:h.transaction.error;d(a)}}catch(a){d(a)}})}).catch(d)});return L(d,b),d},clear:function(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){fa(b._dbInfo,Lb,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.clear();e.oncomplete=function(){a()},e.onabort=e.onerror=function(){var a=g.error?g.error:g.transaction.error;c(a)}}catch(a){c(a)}})}).catch(c)});return L(c,a),c},length:function(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){fa(b._dbInfo,Kb,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.count();g.onsuccess=function(){a(g.result)},g.onerror=function(){c(g.error)}}catch(a){c(a)}})}).catch(c)});return L(c,a),c},key:function(a,b){var c=this,d=new Promise(function(b,d){return 0>a?void b(null):void c.ready().then(function(){fa(c._dbInfo,Kb,function(e,f){if(e)return d(e);try{var g=f.objectStore(c._dbInfo.storeName),h=!1,i=g.openCursor();i.onsuccess=function(){var c=i.result;return c?void(0===a?b(c.key):h?b(c.key):(h=!0,c.advance(a))):void b(null)},i.onerror=function(){d(i.error)}}catch(a){d(a)}})}).catch(d)});return L(d,b),d},keys:function(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){fa(b._dbInfo,Kb,function(d,e){if(d)return c(d);try{var f=e.objectStore(b._dbInfo.storeName),g=f.openCursor(),h=[];g.onsuccess=function(){var b=g.result;return b?void(h.push(b.key),b.continue()):void a(h)},g.onerror=function(){c(g.error)}}catch(a){c(a)}})}).catch(c)});return L(c,a),c},dropInstance:function(a,b){b=O.apply(this,arguments);var c=this.config();a="function"!=typeof a&&a||{},a.name||(a.name=a.name||c.name,a.storeName=a.storeName||c.storeName);var d,e=this;if(!a.name)d=Promise.reject("Invalid arguments");else{const b=a.name===c.name&&e._dbInfo.db,f=b?Promise.resolve(e._dbInfo.db):Z(a).then(b=>{const c=Ib[a.name],d=c.forages;c.db=b;for(var e=0;e<d.length;e++)d[e]._dbInfo.db=b;return b});d=a.storeName?f.then(b=>{if(!b.objectStoreNames.contains(a.storeName))return;const c=b.version+1;S(a);const d=Ib[a.name],e=d.forages;b.close();for(let a=0;a<e.length;a++){const b=e[a];b._dbInfo.db=null,b._dbInfo.version=c}const f=new Promise((b,d)=>{const e=Fb.open(a.name,c);e.onerror=a=>{const b=e.result;b.close(),d(a)},e.onupgradeneeded=()=>{var b=e.result;b.deleteObjectStore(a.storeName)},e.onsuccess=()=>{const a=e.result;a.close(),b(a)}});return f.then(a=>{d.db=a;for(let b=0;b<e.length;b++){const c=e[b];c._dbInfo.db=a,T(c._dbInfo)}}).catch(b=>{throw(U(a,b)||Promise.resolve()).catch(()=>{}),b})}):f.then(b=>{S(a);const c=Ib[a.name],d=c.forages;b.close();for(var e=0;e<d.length;e++){const a=d[e];a._dbInfo.db=null}const f=new Promise((b,c)=>{var d=Fb.deleteDatabase(a.name);d.onerror=d.onblocked=a=>{const b=d.result;b&&b.close(),c(a)},d.onsuccess=()=>{const a=d.result;a&&a.close(),b(a)}});return f.then(a=>{c.db=a;for(var b=0;b<d.length;b++){const a=d[b];T(a._dbInfo)}}).catch(b=>{throw(U(a,b)||Promise.resolve()).catch(()=>{}),b})})}return L(d,b),d}},Nb=/^~~local_forage_type~([^~]+)~/,Ob="__lfsc__:".length,Pb=Ob+"arbf".length,Qb=Object.prototype.toString,Rb={serialize:function(a,b){var c="";if(a&&(c=Qb.call(a)),a&&("[object ArrayBuffer]"===c||a.buffer&&"[object ArrayBuffer]"===Qb.call(a.buffer))){var d,e="__lfsc__:";a instanceof ArrayBuffer?(d=a,e+="arbf"):(d=a.buffer,"[object Int8Array]"===c?e+="si08":"[object Uint8Array]"===c?e+="ui08":"[object Uint8ClampedArray]"===c?e+="uic8":"[object Int16Array]"===c?e+="si16":"[object Uint16Array]"===c?e+="ur16":"[object Int32Array]"===c?e+="si32":"[object Uint32Array]"===c?e+="ui32":"[object Float32Array]"===c?e+="fl32":"[object Float64Array]"===c?e+="fl64":b(new Error("Failed to get type for BinaryArray"))),b(e+ia(d))}else if("[object Blob]"===c){var f=new FileReader;f.onload=function(){var c="~~local_forage_type~"+a.type+"~"+ia(this.result);b("__lfsc__:blob"+c)},f.readAsArrayBuffer(a)}else try{b(JSON.stringify(a))}catch(c){console.error("Couldn't convert value into a JSON string: ",a),b(null,c)}},deserialize:function(a){if(a.substring(0,Ob)!=="__lfsc__:")return JSON.parse(a);var b,c=a.substring(Pb),d=a.substring(Ob,Pb);if(d==="blob"&&Nb.test(c)){var e=c.match(Nb);b=e[1],c=c.substring(e[0].length)}var f=ha(c);switch(d){case"arbf":return f;case"blob":return K([f],{type:b});case"si08":return new Int8Array(f);case"ui08":return new Uint8Array(f);case"uic8":return new Uint8ClampedArray(f);case"si16":return new Int16Array(f);case"ur16":return new Uint16Array(f);case"si32":return new Int32Array(f);case"ui32":return new Uint32Array(f);case"fl32":return new Float32Array(f);case"fl64":return new Float64Array(f);default:throw new Error("Unkown type: "+d);}},stringToBuffer:ha,bufferToString:ia},Sb={_driver:"webSQLStorage",_initStorage:function(a){var b=this,c={db:null};if(a)for(var d in a)c[d]="string"==typeof a[d]?a[d]:a[d].toString();var e=new Promise(function(a,d){try{c.db=openDatabase(c.name,c.version+"",c.description,c.size)}catch(a){return d(a)}c.db.transaction(function(e){ja(e,c,function(){b._dbInfo=c,a()},function(a,b){d(b)})},d)});return c.serializer=Rb,e},_support:function(){return"function"==typeof openDatabase}(),iterate:function(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){ka(c,e,"SELECT * FROM ".concat(e.storeName),[],function(c,d){for(var f=d.rows,g=f.length,h=0;h<g;h++){var j=f.item(h),k=j.value;if(k&&(k=e.serializer.deserialize(k)),k=a(k,j.key,h+1),void 0!==k)return void b(k)}b()},function(a,b){d(b)})})}).catch(d)});return L(d,b),d},getItem:function(a,b){var c=this;a=N(a);var d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){ka(c,e,"SELECT * FROM ".concat(e.storeName," WHERE key = ? LIMIT 1"),[a],function(a,c){var d=c.rows.length?c.rows.item(0).value:null;d&&(d=e.serializer.deserialize(d)),b(d)},function(a,b){d(b)})})}).catch(d)});return L(d,b),d},setItem:function(a,b,c){return la.apply(this,[a,b,c,1])},removeItem:function(a,b){var c=this;a=N(a);var d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){ka(c,e,"DELETE FROM ".concat(e.storeName," WHERE key = ?"),[a],function(){b()},function(a,b){d(b)})})}).catch(d)});return L(d,b),d},clear:function(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){ka(b,d,"DELETE FROM ".concat(d.storeName),[],function(){a()},function(a,b){c(b)})})}).catch(c)});return L(c,a),c},length:function(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){ka(b,d,"SELECT COUNT(key) as c FROM ".concat(d.storeName),[],function(b,c){var d=c.rows.item(0).c;a(d)},function(a,b){c(b)})})}).catch(c)});return L(c,a),c},key:function(a,b){var c=this,d=new Promise(function(b,d){c.ready().then(function(){var e=c._dbInfo;e.db.transaction(function(c){ka(c,e,"SELECT key FROM ".concat(e.storeName," WHERE id = ? LIMIT 1"),[a+1],function(a,c){var d=c.rows.length?c.rows.item(0).key:null;b(d)},function(a,b){d(b)})})}).catch(d)});return L(d,b),d},keys:function(a){var b=this,c=new Promise(function(a,c){b.ready().then(function(){var d=b._dbInfo;d.db.transaction(function(b){ka(b,d,"SELECT key FROM ".concat(d.storeName),[],function(b,c){for(var d=[],e=0;e<c.rows.length;e++)d.push(c.rows.item(e).key);a(d)},function(a,b){c(b)})})}).catch(c)});return L(c,a),c},dropInstance:function(a,b){b=O.apply(this,arguments);var c=this.config();a="function"!=typeof a&&a||{},a.name||(a.name=a.name||c.name,a.storeName=a.storeName||c.storeName);var d,e=this;return d=a.name?new Promise(function(b){var d;d=a.name===c.name?e._dbInfo.db:openDatabase(a.name,"","",0),a.storeName?b({db:d,storeNames:[a.storeName]}):b(ma(d))}).then(function(a){return new Promise(function(b,c){a.db.transaction(function(d){function e(a){return new Promise(function(b,c){d.executeSql("DROP TABLE IF EXISTS ".concat(a),[],function(){b()},function(a,b){c(b)})})}for(var f=[],g=0,h=a.storeNames.length;g<h;g++)f.push(e(a.storeNames[g]));Promise.all(f).then(function(){b()}).catch(function(a){c(a)})},function(a){c(a)})})}):Promise.reject("Invalid arguments"),L(d,b),d}},Tb={_driver:"localStorageWrapper",_initStorage:function(a){var b=this,c={};if(a)for(var d in a)c[d]=a[d];return(c.keyPrefix=oa(a,b._defaultConfig),!qa())?Promise.reject():(b._dbInfo=c,c.serializer=Rb,Promise.resolve())},_support:na(),iterate:function(a,b){var c=this,d=c.ready().then(function(){for(var b,d=c._dbInfo,e=d.keyPrefix,f=e.length,g=localStorage.length,h=1,j=0;j<g;j++)if(b=localStorage.key(j),0===b.indexOf(e)){var k=localStorage.getItem(b);if(k&&(k=d.serializer.deserialize(k)),k=a(k,b.substring(f),h++),void 0!==k)return k}});return L(d,b),d},getItem:function(a,b){var c=this;a=N(a);var d=c.ready().then(function(){var b=c._dbInfo,d=localStorage.getItem(b.keyPrefix+a);return d&&(d=b.serializer.deserialize(d)),d});return L(d,b),d},setItem:function(a,b,c){var d=this;a=N(a);var e=d.ready().then(function(){void 0===b&&(b=null);var c=b;return new Promise(function(e,f){var g=d._dbInfo;g.serializer.serialize(b,function(b,d){if(d)f(d);else try{localStorage.setItem(g.keyPrefix+a,b),e(c)}catch(a){("QuotaExceededError"===a.name||"NS_ERROR_DOM_QUOTA_REACHED"===a.name)&&f(a),f(a)}})})});return L(e,c),e},removeItem:function(a,b){var c=this;a=N(a);var d=c.ready().then(function(){var b=c._dbInfo;localStorage.removeItem(b.keyPrefix+a)});return L(d,b),d},clear:function(a){var b=this,c=b.ready().then(function(){for(var a,c=b._dbInfo.keyPrefix,d=localStorage.length-1;0<=d;d--)a=localStorage.key(d),0===a.indexOf(c)&&localStorage.removeItem(a)});return L(c,a),c},length:function(a){var b=this,c=b.keys().then(function(a){return a.length});return L(c,a),c},key:function(a,b){var c=this,d=c.ready().then(function(){var b,d=c._dbInfo;try{b=localStorage.key(a)}catch(a){b=null}return b&&(b=b.substring(d.keyPrefix.length)),b});return L(d,b),d},keys:function(a){var b=this,c=b.ready().then(function(){for(var a,c=b._dbInfo,d=localStorage.length,e=[],f=0;f<d;f++)a=localStorage.key(f),0===a.indexOf(c.keyPrefix)&&e.push(a.substring(c.keyPrefix.length));return e});return L(c,a),c},dropInstance:function(a,b){if(b=O.apply(this,arguments),a="function"!=typeof a&&a||{},!a.name){var c=this.config();a.name=a.name||c.name,a.storeName=a.storeName||c.storeName}var d,e=this;return d=a.name?new Promise(function(b){a.storeName?b(oa(a,e._defaultConfig)):b("".concat(a.name,"/"))}).then(function(a){for(var b,c=localStorage.length-1;0<=c;c--)b=localStorage.key(c),0===b.indexOf(a)&&localStorage.removeItem(b)}):Promise.reject("Invalid arguments"),L(d,b),d}};const Ub=(a,b)=>a===b||"number"==typeof a&&"number"==typeof b&&isNaN(a)&&isNaN(b),Vb=(a,b)=>{const c=a.length;for(let d=0;d<c;){if(Ub(a[d],b))return!0;d++}return!1},Wb=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},Xb={},Yb={},Zb={INDEXEDDB:Mb,WEBSQL:Sb,LOCALSTORAGE:Tb},$b=[Zb.INDEXEDDB._driver,Zb.WEBSQL._driver,Zb.LOCALSTORAGE._driver],_b=["dropInstance"],ac=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(_b),bc={description:"",driver:$b.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};class cc{constructor(a){for(let b in Zb)if(Zb.hasOwnProperty(b)){const a=Zb[b],c=a._driver;this[b]=c,Xb[c]||this.defineDriver(a)}this._defaultConfig=sa({},bc),this._config=sa({},this._defaultConfig,a),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(()=>{})}config(a){if("object"==typeof a){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(let b in a){if("storeName"==b&&(a[b]=a[b].replace(/\W/g,"_")),"version"==b&&"number"!=typeof a[b])return new Error("Database version must be a number.");this._config[b]=a[b]}return!("driver"in a&&a.driver)||this.setDriver(this._config.driver)}return"string"==typeof a?this._config[a]:this._config}defineDriver(a,b,c){const d=new Promise(function(b,c){try{const d=a._driver,e=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!a._driver)return void c(e);const f=ac.concat("_initStorage");for(let b=0,d=f.length;b<d;b++){const d=f[b],g=!Vb(_b,d);if((g||a[d])&&"function"!=typeof a[d])return void c(e)}(function(){const b=function(a){return function(){const b=new Error("Method ".concat(a," is not implemented by the current driver")),c=Promise.reject(b);return L(c,arguments[arguments.length-1]),c}};for(let c=0,d=_b.length;c<d;c++){const d=_b[c];a[d]||(a[d]=b(d))}})();const g=function(c){Xb[d]&&console.info("Redefining LocalForage driver: ".concat(d)),Xb[d]=a,Yb[d]=c,b()};"_support"in a?a._support&&"function"==typeof a._support?a._support().then(g,c):g(!!a._support):g(!0)}catch(a){c(a)}});return M(d,b,c),d}driver(){return this._driver||null}getDriver(a,b,c){const d=Xb[a]?Promise.resolve(Xb[a]):Promise.reject(new Error("Driver not found."));return M(d,b,c),d}getSerializer(a){const b=Promise.resolve(Rb);return M(b,a),b}ready(a){const b=this,c=b._driverSet.then(()=>(null===b._ready&&(b._ready=b._initDriver()),b._ready));return M(c,a,a),c}setDriver(a,b,c){function d(){g._config.driver=g.driver()}function e(a){return g._extend(a),d(),g._ready=g._initStorage(g._config),g._ready}function f(a){return function(){function b(){for(;c<a.length;){let d=a[c];return c++,g._dbInfo=null,g._ready=null,g.getDriver(d).then(e).catch(b)}d();const f=new Error("No available storage method found.");return g._driverSet=Promise.reject(f),g._driverSet}let c=0;return b()}}const g=this;Wb(a)||(a=[a]);const h=this._getSupportedDrivers(a),i=null===this._driverSet?Promise.resolve():this._driverSet.catch(()=>Promise.resolve());return this._driverSet=i.then(()=>{const a=h[0];return g._dbInfo=null,g._ready=null,g.getDriver(a).then(a=>{g._driver=a._driver,d(),g._wrapLibraryMethodsWithReady(),g._initDriver=f(h)})}).catch(()=>{d();const a=new Error("No available storage method found.");return g._driverSet=Promise.reject(a),g._driverSet}),M(this._driverSet,b,c),this._driverSet}supports(a){return!!Yb[a]}_extend(a){sa(this,a)}_getSupportedDrivers(a){const b=[];for(let c=0,d=a.length;c<d;c++){const d=a[c];this.supports(d)&&b.push(d)}return b}_wrapLibraryMethodsWithReady(){for(let a=0,b=ac.length;a<b;a++)ra(this,ac[a])}createInstance(a){return new cc(a)}}var dc=new cc;const ec="https://github.com/kalkih/mini-graph-card/blob/master/README.md",fc=14,gc=96,hc={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",battery:"hass:battery"},ic=["var(--accent-color)","#3498db","#e74c3c","#9b59b6","#f1c40f","#2ecc71"],jc=["entity","line","length","fill","points","tooltip","abs"],kc={name:!0,icon:!0,state:!0,graph:"line",labels:"hover",extrema:!1,legend:!0,fill:!0,points:"hover"},lc=0,X=1,Y=2,V=(a,b)=>a.reduce((a,c)=>+c[b]<+a[b]?c:a,a[0]),mc=(a,b)=>a.reduce((a,c)=>+c[b]>+a[b]?c:a,a[0]),nc=(a,b,c="en-US")=>a.toLocaleString(c,F({hour:"numeric",minute:"numeric"},b)),oc=a=>a*3600*1000,pc=(c,a,b)=>{const d=+c.replace("#","0x"),e=d>>16,f=255&d>>8,g=255&d,h=+a.replace("#","0x");return"#".concat((0|16777216+(e+b*((h>>16)-e)<<16)+(f+b*((255&h>>8)-f)<<8)+(g+b*((255&h)-g))).toString(16).slice(1))};class qc{constructor(a,b,c,d=24,e=1){this.coords=[],this.width=a-2*c[lc],this.height=b-2*c[X],this.margin=c,this._max=0,this._min=0,this.points=e,this.hours=d}get max(){return this._max}set max(a){this._max=a}get min(){return this._min}set min(a){this._min=a}update(a){const b=new Date().getTime(),c=(a,c)=>{var d=Math.floor;const e=b-new Date(c.last_changed).getTime(),f=e/3600000*this.points-this.hours*this.points,g=d(xa(f));return a[g]||(a[g]=[]),a[g].push(c),a},d=a.reduce((a,b)=>c(a,b),[]);d.length=wa(this.hours*this.points),this.coords=this._calcPoints(d),this.min=va.apply(Math,H(this.coords.map(a=>+a[Y]))),this.max=ua.apply(Math,H(this.coords.map(a=>+a[Y])))}_calcPoints(a){var b=Number.isFinite;const c=[];let d=this.width/(this.hours*this.points-1);d=b(d)?d:this.width;const e=a.filter(Boolean)[0];let f=[this._average(e),this._last(e)];const g=(a,b)=>{const e=d*b+this.margin[lc];return a&&(f=[this._average(a),this._last(a)]),c.push([e,0,a?f[0]:f[1]])};for(let b=0;b<a.length;b+=1)g(a[b],b);return 1===c.length&&(c[1]=[this.width+this.margin[lc],0,c[0][Y]]),c}_calcY(a){const b=(this.max-this.min)/this.height||1;return a.map(a=>[a[lc],this.height-(a[Y]-this.min)/b+1*this.margin[X],a[Y]])}getPoints(){const a=this._calcY(this.coords);let b,c,d=a[0];a.shift();const e=a.map((a,e)=>{b=a,c=this._midPoint(d[lc],d[X],b[lc],b[X]);const f=(b[Y]+d[Y])/2;return d=b,[c[lc],c[X],f,e+1]});return e}getPath(){const a=this._calcY(this.coords);let b,c,d="",e=a[0];return d+="M".concat(e[lc],",").concat(e[X]),a.forEach(a=>{b=a,c=this._midPoint(e[lc],e[X],b[lc],b[X]),d+=" ".concat(c[lc],",").concat(c[X]),d+=" Q ".concat(b[lc],",").concat(b[X]),e=b}),d+=" ".concat(b[lc],",").concat(b[X]),d}computeGradient(a){const b=this._max-this._min;return a.map((a,c,d)=>{let e;if(a.value>this._max&&d[c+1]){const b=(this._max-d[c+1].value)/(a.value-d[c+1].value);e=pc(d[c+1].color,a.color,b)}else if(a.value<this._min&&d[c-1]){const b=(d[c-1].value-this._min)/(d[c-1].value-a.value);e=pc(d[c-1].color,a.color,b)}return{color:e||a.color,offset:(this._max-a.value)*(100/b)}})}getFill(a){const b=this.height+2*this.margin[X];let c=a;return c+=" L ".concat(this.width-2*this.margin[lc],", ").concat(b),c+=" L ".concat(this.coords[0][lc],", ").concat(b," z"),c}getBars(a,b){const c=this._calcY(this.coords),d=4,e=(this.width-d)/wa(this.hours*this.points)/b;return c.map((c,f)=>({x:e*f*b+e*a+d,y:c[X],height:this.height-c[X]+3*this.margin[X],width:e-d,value:c[Y]}))}_midPoint(a,b,c,d){return[(a-c)/2+c,(b-d)/2+d]}_average(a){return a.reduce((a,b)=>a+parseFloat(b.state),0)/a.length}_last(a){return parseFloat(a[a.length-1].state)||0}}const rc=((a,...b)=>{const c=b.reduce((b,c,d)=>b+Cb(c)+a[d+1],a[0]);return new Bb(c,Ab)})(D());dc.config({name:"mini-graph-card",version:1,storeName:"entity_history_cache",description:"Mini graph card uses caching for the entity history"});class sc extends Eb{constructor(){super(),this.id=Math.random().toString(36).substr(2,9),this.bound=[0,0],this.abs=[],this.length=[],this.entity=[],this.line=[],this.bar=[],this.fill=[],this.points=[],this.gradient=[],this.tooltip={},this.updateQueue=[],this.updating=!1,this.stateChanged=!1}static get styles(){return rc}set hass(a){this._hass=a;let b=!1;this.config.entities.forEach((c,d)=>{const e=a.states[c.entity];e&&this.entity[d]!==e&&(this.entity[d]=e,this.updateQueue.push(e.entity_id),b=!0)}),b&&(this.entity=H(this.entity),this.config.update_interval||this.updating?this.stateChanged=!0:this.updateData())}static get properties(){return{id:String,_hass:{},config:{},entity:[],Graph:[],line:[],shadow:[],length:Number,bound:[],abs:[],tooltip:{},updateQueue:[],color:String}}setConfig(a){if(a.entity)throw new Error("The \"entity\" option was removed, please use \"entities\".\n See ".concat(ec));if(!Array.isArray(a.entities))throw new Error("Please provide the \"entities\" option as a list.\n See ".concat(ec));if(a.line_color_above||a.line_color_below)throw new Error("\"line_color_above/line_color_below\" was removed, please use \"color_thresholds\".\n See ".concat(ec));const b=F({animate:!1,hour24:!1,font_size:fc,font_size_header:14,height:100,hours_to_show:24,points_per_hour:.5,line_color:[].concat(ic),color_thresholds:[],color_thresholds_transition:"smooth",line_width:5,more_info:!0},a,{show:F({},kc,a.show)});b.entities.forEach((a,c)=>{"string"==typeof a&&(b.entities[c]={entity:a})}),"string"==typeof a.line_color&&(b.line_color=[a.line_color].concat(ic)),b.font_size=a.font_size/100*fc||fc,b.color_thresholds=this.computeThresholds(b.color_thresholds,b.color_thresholds_transition);const c=24<b.hours_to_show?{day:"numeric",weekday:"short"}:{};if(b.format=F({hour12:!b.hour24},c),"bar"===b.show.graph){const a=b.entities.length;b.hours_to_show*b.points_per_hour*a>gc&&(b.points_per_hour=gc/(b.hours_to_show*a),console.warn("mini-graph-card: Not enough space, adjusting points_per_hour to ",b.points_per_hour))}this.Graph||(this.Graph=b.entities.map(()=>new qc(500,b.height,[b.show.fill?0:b.line_width,b.line_width],b.hours_to_show,b.points_per_hour))),this.config=b}connectedCallback(){super.connectedCallback(),this.config.update_interval&&(this.updateOnInterval(),this.interval=setInterval(()=>this.updateOnInterval(),1e3*this.config.update_interval))}disconnectedCallback(){this.interval&&clearInterval(this.interval),super.disconnectedCallback()}shouldUpdate(a){return!!this.entity[0]&&(jc.some(b=>a.has(b))?(this.color=this.intColor(this.tooltip.value||this.entity[0].state,this.tooltip.entity||0),!0):void 0)}updated(a){this.config.animate&&a.has("line")&&(this.length.length<this.entity.length?(this.shadowRoot.querySelectorAll("svg path.line").forEach(a=>{this.length[a.id]=a.getTotalLength()}),this.length=H(this.length)):this.length=Array(this.entity.length).fill("none"))}render({config:a}=this){return cb(C(),a.group,a.show.graph&&a.show.fill,"hover"===a.show.points,"hover"===a.show.labels,0<a.color_thresholds.length,a.more_info,a.font_size,a=>this.handlePopup(a,this.entity[0]),this.renderHeader(),this.renderStates(),this.renderGraph(),this.renderInfo())}renderHeader(){const{show:a,align_icon:b,align_header:c,font_size_header:d}=this.config;return a.name||a.icon&&"state"!==b?cb(B(),c,d,this.renderName(),"state"===b?"":this.renderIcon()):""}renderIcon(){const{icon:a,icon_adaptive_color:b}=this.config.show;return a?cb(A(),this.config.align_icon,b?"color: ".concat(this.color,";"):"",this.computeIcon(this.entity[0])):""}renderName(){if(!this.config.show.name)return;const a=this.tooltip.entity===void 0?this.config.name||this.computeName(0):this.computeName(this.tooltip.entity),b=this.config.show.name_adaptive_color?"opacity: 1; color: ".concat(this.color,";"):"";return cb(z(),b,a)}renderStates(){const{entity:a,value:b}=this.tooltip,c=b===void 0?this.entity[0].state:b,d=this.config.entities[0].state_adaptive_color?"color: ".concat(this.color,";"):"";if(this.config.show.state)return cb(y(),this.config.align_state,d,this.computeState(c),d,this.computeUom(a||0),this.renderStateTime(),this.config.entities.map((a,b)=>this.renderState(a,b)),"state"===this.config.align_icon?this.renderIcon():"")}renderState(a,b){if(a.show_state&&0!==b){const{state:c}=this.entity[b];return cb(x(),a.state_adaptive_color?"color: ".concat(this.computeColor(c,b),";"):"",a.show_indicator?this.renderIndicator(c,b):"",this.computeState(c),this.computeUom(b))}}renderStateTime(){return void 0===this.tooltip.value?void 0:cb(w(),this.tooltip.label?cb(v(),this.tooltip.label):cb(u(),this.tooltip.time[0],this.tooltip.time[1]))}renderGraph(){return this.config.show.graph?cb(t(),this.renderLabels(),this.renderSvg(),this.renderLegend()):""}renderLegend(){return 1>=this.config.entities.length||!this.config.show.legend?void 0:cb(s(),this.entity.map((a,b)=>cb(r(),b=>this.handlePopup(b,a),()=>this.setTooltip(b,-1,this.entity[b].state,"Current"),()=>this.tooltip={},this.renderIndicator(a.state,b),this.computeName(b))))}renderIndicator(a,b){return db(q(),this.computeColor(a,b))}renderSvgFill(a,b){if(!a)return;const c=this.intColor(this.entity[b].state,b),d="fade"===this.config.show.fill,e=d?"url(#fill-grad-".concat(this.id,"-").concat(b,")"):c;return db(p(),"fill-grad-".concat(this.id,"-").concat(b),c,c,this.tooltip.entity!==void 0&&this.tooltip.entity!==b,this.config.show.fill,b,this.config.animate,this.length[b],this.config.animate?"".concat(.5*b,"s"):"0s",e,e,this.config.line_width,this.fill[b])}renderSvgLine(a,b){if(a){const a=db(o(),b,this.config.animate,this.length[b],this.config.animate?"".concat(.5*b,"s"):"0s",this.length[b]||"none",this.length[b]||"none","white",this.config.line_width,this.line[b]);return db(n(),"line-".concat(this.id,"-").concat(b),a)}}renderSvgPoint(a,b){const c=this.gradient[b]?this.computeColor(a[Y],b):"inherit";return db(m(),this.tooltip.index!==a[3],"--mcg-hover: ".concat(c,";"),c,c,a[lc],a[X],this.config.line_width,()=>this.setTooltip(b,a[3],a[Y]),()=>this.tooltip={})}renderSvgPoints(a,b){if(a){const c=this.computeColor(this.entity[b].state,b);return db(l(),this.tooltip.entity===b,void 0!==this.tooltip.entity&&this.tooltip.entity!==b,this.length[b],this.config.animate&&"hover"!==this.config.show.points,this.config.animate?"".concat(.5*b+.5,"s"):"0s",c,c,this.config.line_width/2,a.map(a=>this.renderSvgPoint(a,b)))}}renderSvgGradient(a){if(a){const b=a.map((a,b)=>a?db(k(),"grad-".concat(this.id,"-").concat(b),a.map(a=>db(j(),a.color,"".concat(a.offset,"%")))):void 0);return db(i(),b)}}renderSvgRect(a,b){if(a){const a=this.gradient[b]?"url(#grad-".concat(this.id,"-").concat(b,")"):this.computeColor(this.entity[b].state,b);return db(h(),void 0!==this.tooltip.entity&&this.tooltip.entity!==b,"rect-".concat(this.id,"-").concat(b),a,"url(#line-".concat(this.id,"-").concat(b,")"))}}renderSvgBars(a,b){if(a){const c=a.map((a,c)=>{const d=this.config.animate?db(g(),this.config.height,a.y):"",e=this.computeColor(a.value,b);return db(f(),a.x,a.y,a.height,a.width,e,()=>this.setTooltip(b,c,a.value),()=>this.tooltip={},d)});return db(e(),this.config.animate,c)}}renderSvg(){const{height:a}=this.config;return db(d(),0===a?0:"100%",a,a=>a.stopPropagation(),this.renderSvgGradient(this.gradient),this.line.map((a,b)=>this.renderSvgLine(a,b)),this.fill.map((a,b)=>this.renderSvgFill(a,b)),this.line.map((a,b)=>this.renderSvgRect(a,b)),this.bar.map((a,b)=>this.renderSvgBars(a,b)),this.points.map((a,b)=>this.renderSvgPoints(a,b)))}setTooltip(a,b,c,d=null){const{points_per_hour:e,hours_to_show:f,format:g}=this.config,h=1>f&&1>e?e*f:1/e,i=xa(b+1-wa(f*e)),j=new Date;j.setMilliseconds(j.getMilliseconds()-oc(h*i));const k=nc(j,{hour12:!this.config.hour24},this._hass.language);j.setMilliseconds(j.getMilliseconds()-oc(h));const l=nc(j,g,this._hass.language);this.tooltip={value:c,id:i,entity:a,time:[l,k],index:b,label:d}}renderLabels(){return this.config.show.labels?cb(c(),this.computeState(this.bound[1]),this.computeState(this.bound[0])):void 0}renderInfo(){return this.config.show.extrema?cb(b(),this.abs.map(b=>cb(a(),b.type,this.computeState(b.state),this.computeUom(0),nc(new Date(b.last_changed),this.config.format,this._hass.language)))):void 0}handlePopup(a,b){a.stopPropagation(),this.config.more_info&&this.fire("hass-more-info",{entityId:b.entity_id})}fire(a,b,c){const d=c||{},f=null===b||void 0===b?{}:b,g=new Event(a,{bubbles:void 0===d.bubbles||d.bubbles,cancelable:!!d.cancelable,composed:void 0===d.composed||d.composed});return g.detail=f,this.dispatchEvent(g),g}computeThresholds(a,b){if(a.sort((c,a)=>a.value-c.value),"smooth"===b)return a;else{var c;const b=(c=[]).concat.apply(c,H(a.map((b,c)=>[b,{value:b.value-1e-4,color:a[c+1]?a[c+1].color:b.color}])));return b}}computeColor(a,b){const{color_thresholds:c,line_color:d}=this.config,e=F({color:d[b]||d[0]},c.slice(-1)[0],c.find(b=>b.value<(+a||0)));return this.config.entities[b].color||e.color}intColor(a,b){const{color_thresholds:c,line_color:d}=this.config,e=+a||0;let f;if(0<c.length)if("bar"===this.config.show.graph){const{color:a}=c.find(a=>a.value<e)||c.slice(-1)[0];f=a}else{f=c[0].color;const b=c.findIndex(a=>a.value<e),d=c[b],g=c[b-1];if(g){const b=(g.value-a)/(g.value-d.value);f=pc(g.color,d.color,b)}}return this.config.entities[b].color||f||d[b]||d[0]}computeName(a){return this.config.entities[a].name||this.entity[a].attributes.friendly_name}computeIcon(a){return this.config.icon||a.attributes.icon||hc[a.attributes.device_class]||hc.temperature}computeUom(a){return this.config.entities[a].unit||this.config.unit||this.entity[a].attributes.unit_of_measurement||""}computeState(a){var b=Math.round;const c=+a,d=this.config.decimals;if(d===void 0||ta(d)||ta(c))return b(100*c)/100;const e=10**d;return(b(c*e)/e).toFixed(d)}updateOnInterval(){this.stateChanged&&!this.updating&&(this.stateChanged=!1,this.updateData())}async updateData({config:a}=this){this.updating=!0;const b=new Date,c=new Date;c.setMilliseconds(b.getMilliseconds()-oc(a.hours_to_show));try{const a=this.entity.map((a,d)=>this.updateEntity(a,d,c,b));await Promise.all(a)}finally{this.updating=!1}this.updateQueue=[],this.bound=[a.lower_bound===void 0?va.apply(Math,H(this.Graph.map(a=>a.min)))||this.bound[0]:a.lower_bound,a.upper_bound===void 0?ua.apply(Math,H(this.Graph.map(a=>a.max)))||this.bound[1]:a.upper_bound],a.show.graph&&(this.entity.forEach((b,c)=>{b&&0!==this.Graph[c].coords.length&&([this.Graph[c].min,this.Graph[c].max]=[this.bound[0],this.bound[1]],"bar"===a.show.graph?this.bar[c]=this.Graph[c].getBars(c,a.entities.length):(this.line[c]=this.Graph[c].getPath(),a.show.fill&&(this.fill[c]=this.Graph[c].getFill(this.line[c])),a.show.points&&(this.points[c]=this.Graph[c].getPoints()),0<a.color_thresholds.length&&!a.entities[c].color&&(this.gradient[c]=this.Graph[c].computeGradient(a.color_thresholds))))}),this.line=H(this.line))}async updateEntity(a,b,c,d){if(!a||!this.updateQueue.includes(a.entity_id))return;let e=[],f=c,g=!1;const h=await dc.getItem(a.entity_id);if(h&&h.hours_to_show===this.config.hours_to_show){e=h.data,e=e.filter(a=>new Date(a.last_updated)>c),0<e.length&&(g=!0);const a=new Date(h.last_fetched);a>f&&(f=new Date(a-1))}let i=await this.fetchRecent(a.entity_id,f,d,g);i[0]&&0<i[0].length&&(i=i[0].filter(a=>!ta(parseFloat(a.state))),e=[].concat(H(e),H(i)),dc.setItem(a.entity_id,{hours_to_show:this.config.hours_to_show,last_fetched:d,data:e}).catch(a=>{console.warn("mini-graph-card: Failed to cache: ",a),dc.clear()}));0===e.length||(a.entity_id===this.entity[0].entity_id&&(this.abs=[F({type:"min"},V(e,"state")),F({type:"max"},mc(e,"state"))]),this.Graph[b].update(e))}async fetchRecent(a,b,c,d){let e="history/period";return b&&(e+="/".concat(b.toISOString())),e+="?filter_entity_id=".concat(a),c&&(e+="&end_time=".concat(c.toISOString())),d&&(e+="&skip_initial_state"),this._hass.callApi("GET",e)}getCardSize(){return 3}}customElements.define("mini-graph-card",sc)})})();