From c8959fa70df4a694c8f7a62c604fad4f90ed94d9 Mon Sep 17 00:00:00 2001 From: FL550 Date: Thu, 28 Jan 2021 07:49:42 +0100 Subject: [PATCH] Fixes typo in README and updates language files --- README.md | 2 +- dist/spotify-card.js | 10 +++++----- dist/spotify-card.js.map | 2 +- src/localize/languages/de.json | 5 +++-- src/localize/languages/en.json | 1 - 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2ee60d1..7ae8617 100755 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Follow the HACS instructions when installing it. #### Manually -Copy the content of the `dist` folder to `www/community/spotify_card/` in your Home Assistant configuration directory. Create these folders if they do not exist. +Copy the content of the `dist` folder to `www/community/spotify-card/` in your Home Assistant configuration directory. Create these folders if they do not exist. Then you have to add spotify card to your resources. This can be done via `Settings -> Lovelace Dashboards -> Resources`. Add this path: diff --git a/dist/spotify-card.js b/dist/spotify-card.js index a05e5cf..cfec1af 100644 --- a/dist/spotify-card.js +++ b/dist/spotify-card.js @@ -145,7 +145,7 @@ class{handleAttributeExpressions(e,t,i,s){const n=t[0];if("."===n){return new k( * 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 - */,z=(e,t)=>`${e}--${t}`;let L=!0;void 0===window.ShadyCSS?L=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),L=!1);const U=e=>t=>{const i=z(t.type,e);let n=N.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},N.set(i,n));let a=n.stringsArray.get(t.strings);if(void 0!==a)return a;const r=t.strings.join(s);if(a=n.keyString.get(r),void 0===a){const i=t.getTemplateElement();L&&window.ShadyCSS.prepareTemplateDom(i,e),a=new o(t,i),n.keyString.set(r,a)}return n.stringsArray.set(t.strings,a),a},j=["html","svg"],R=new Set,Y=(e,t,i)=>{R.add(e);const s=i?i.element:document.createElement("template"),n=t.querySelectorAll("style"),{length:a}=n;if(0===a)return void window.ShadyCSS.prepareTemplateStyles(s,e);const o=document.createElement("style");for(let e=0;e{j.forEach(t=>{const i=N.get(z(t,e));void 0!==i&&i.keyString.forEach(e=>{const{element:{content:t}}=e,i=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{i.add(e)}),h(e,i)})})})(e);const r=s.content;i?function(e,t,i=null){const{element:{content:s},parts:n}=e;if(null==i)return void s.appendChild(t);const a=document.createTreeWalker(s,133,null,!1);let o=u(n),r=0,l=-1;for(;a.nextNode();)for(l++,a.currentNode===i&&(r=p(t),i.parentNode.insertBefore(t,i));-1!==o&&n[o].index===l;){if(r>0){for(;-1!==o;)n[o].index+=r,o=u(n,o);return}o=u(n,o)}}(i,o,r.firstChild):r.insertBefore(o,r.firstChild),window.ShadyCSS.prepareTemplateStyles(s,e);const l=r.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(i){r.insertBefore(o,r.firstChild);const e=new Set;e.add(o),h(i,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const F={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},W=(e,t)=>t!==e&&(t==t||e==e),I={attribute:!0,type:String,converter:F,reflect:!1,hasChanged:W};class q extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=new Promise(e=>this._enableUpdatingResolver=e),this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,i)=>{const s=this._attributeNameForProperty(i,t);void 0!==s&&(this._attributeToPropertyMap.set(s,i),e.push(s))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=I){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(i){const s=this[e];this[t]=i,this._requestUpdate(e,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||I}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const i of t)this.createProperty(i,e[i])}}static _attributeNameForProperty(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,i=W){return i(e,t)}static _propertyValueFromAttribute(e,t){const i=t.type,s=t.converter||F,n="function"==typeof s?s:s.fromAttribute;return n?n(e,i):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const i=t.type,s=t.converter;return(s&&s.toAttribute||F.toAttribute)(e,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,i){t!==i&&this._attributeToProperty(e,i)}_propertyToAttribute(e,t,i=I){const s=this.constructor,n=s._attributeNameForProperty(e,i);if(void 0!==n){const e=s._propertyValueToAttribute(t,i);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(n):this.setAttribute(n,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(e);if(void 0!==s){const e=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}_requestUpdate(e,t){let i=!0;if(void 0!==e){const s=this.constructor,n=s.getPropertyOptions(e);s._valueHasChanged(this[e],t,n.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,n))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,t){return this._requestUpdate(e,t),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const e=this.performUpdate();return null!=e&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e?this.update(t):this._markUpdated()}catch(t){throw e=!1,this._markUpdated(),t}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}}q.finalized=!0; + */,z=(e,t)=>`${e}--${t}`;let L=!0;void 0===window.ShadyCSS?L=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),L=!1);const U=e=>t=>{const i=z(t.type,e);let n=N.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},N.set(i,n));let a=n.stringsArray.get(t.strings);if(void 0!==a)return a;const r=t.strings.join(s);if(a=n.keyString.get(r),void 0===a){const i=t.getTemplateElement();L&&window.ShadyCSS.prepareTemplateDom(i,e),a=new o(t,i),n.keyString.set(r,a)}return n.stringsArray.set(t.strings,a),a},j=["html","svg"],R=new Set,Y=(e,t,i)=>{R.add(e);const s=i?i.element:document.createElement("template"),n=t.querySelectorAll("style"),{length:a}=n;if(0===a)return void window.ShadyCSS.prepareTemplateStyles(s,e);const o=document.createElement("style");for(let e=0;e{j.forEach(t=>{const i=N.get(z(t,e));void 0!==i&&i.keyString.forEach(e=>{const{element:{content:t}}=e,i=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{i.add(e)}),h(e,i)})})})(e);const r=s.content;i?function(e,t,i=null){const{element:{content:s},parts:n}=e;if(null==i)return void s.appendChild(t);const a=document.createTreeWalker(s,133,null,!1);let o=u(n),r=0,l=-1;for(;a.nextNode();)for(l++,a.currentNode===i&&(r=p(t),i.parentNode.insertBefore(t,i));-1!==o&&n[o].index===l;){if(r>0){for(;-1!==o;)n[o].index+=r,o=u(n,o);return}o=u(n,o)}}(i,o,r.firstChild):r.insertBefore(o,r.firstChild),window.ShadyCSS.prepareTemplateStyles(s,e);const l=r.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(i){r.insertBefore(o,r.firstChild);const e=new Set;e.add(o),h(i,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const F={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},W=(e,t)=>t!==e&&(t==t||e==e),I={attribute:!0,type:String,converter:F,reflect:!1,hasChanged:W};class G extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=new Promise(e=>this._enableUpdatingResolver=e),this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,i)=>{const s=this._attributeNameForProperty(i,t);void 0!==s&&(this._attributeToPropertyMap.set(s,i),e.push(s))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=I){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(i){const s=this[e];this[t]=i,this._requestUpdate(e,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||I}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const i of t)this.createProperty(i,e[i])}}static _attributeNameForProperty(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,i=W){return i(e,t)}static _propertyValueFromAttribute(e,t){const i=t.type,s=t.converter||F,n="function"==typeof s?s:s.fromAttribute;return n?n(e,i):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const i=t.type,s=t.converter;return(s&&s.toAttribute||F.toAttribute)(e,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,i){t!==i&&this._attributeToProperty(e,i)}_propertyToAttribute(e,t,i=I){const s=this.constructor,n=s._attributeNameForProperty(e,i);if(void 0!==n){const e=s._propertyValueToAttribute(t,i);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(n):this.setAttribute(n,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(e);if(void 0!==s){const e=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}_requestUpdate(e,t){let i=!0;if(void 0!==e){const s=this.constructor,n=s.getPropertyOptions(e);s._valueHasChanged(this[e],t,n.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,n))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,t){return this._requestUpdate(e,t),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const e=this.performUpdate();return null!=e&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e?this.update(t):this._markUpdated()}catch(t){throw e=!1,this._markUpdated(),t}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}}G.finalized=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -159,7 +159,7 @@ class{handleAttributeExpressions(e,t,i,s){const n=t[0];if("."===n){return new k( * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const G=e=>t=>"function"==typeof t?((e,t)=>(window.customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:i,elements:s}=t;return{kind:i,elements:s,finisher(t){window.customElements.define(e,t)}}})(e,t),B=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?Object.assign(Object.assign({},t),{finisher(i){i.createProperty(t.key,e)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}};function Z(e){return(t,i)=>void 0!==i?((e,t,i)=>{t.constructor.createProperty(i,e)})(e,t,i):B(e,t)}function J(e){return Z({attribute:!1,hasChanged:null==e?void 0:e.hasChanged})} +const q=e=>t=>"function"==typeof t?((e,t)=>(window.customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:i,elements:s}=t;return{kind:i,elements:s,finisher(t){window.customElements.define(e,t)}}})(e,t),B=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?Object.assign(Object.assign({},t),{finisher(i){i.createProperty(t.key,e)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}};function Z(e){return(t,i)=>void 0!==i?((e,t,i)=>{t.constructor.createProperty(i,e)})(e,t,i):B(e,t)}function J(e){return Z({attribute:!1,hasChanged:null==e?void 0:e.hasChanged})} /** @license Copyright (c) 2019 The Polymer Project Authors. All rights reserved. @@ -183,7 +183,7 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");const te={};class ie extends q{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(void 0===e)this._styles=[];else if(Array.isArray(e)){const t=(e,i)=>e.reduceRight((e,i)=>Array.isArray(i)?t(i,e):(e.add(i),e),i),i=t(e,new Set),s=[];i.forEach(e=>s.unshift(e)),this._styles=s}else this._styles=[e]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==te&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return te}}ie.finalized=!0,ie.render=(e,t,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,a=A.has(t),o=L&&11===t.nodeType&&!!t.host,r=o&&!R.has(n),l=r?document.createDocumentFragment():t;if(((e,t,s)=>{let n=A.get(t);void 0===n&&(i(t,t.firstChild),A.set(t,n=new $(Object.assign({templateFactory:E},s))),n.appendInto(t)),n.setValue(e),n.commit()})(e,l,Object.assign({templateFactory:U(n)},s)),r){const e=A.get(l);A.delete(l);const s=e.value instanceof f?e.value.template:void 0;Y(n,l,s),i(t,t.firstChild),t.appendChild(l),A.set(t,e)}!a&&o&&window.ShadyCSS.styleElement(t.host)};var se,ne,ae;function oe(e){return"currently_playing_type"in e}!function(e){e.Grid="grid",e.List="list"}(se||(se={})),function(e){e.default="default",e.featured="featured",e.discover_weekly="discover-weekly"}(ne||(ne={})),function(e){e[e.Name=0]="Name",e[e.Account=1]="Account",e[e.Spotify_Entity=2]="Spotify_Entity",e[e.Country_Code=3]="Country_Code",e[e.Limit=4]="Limit",e[e.Playlist_Type=5]="Playlist_Type",e[e.Always_Play_Random_Song=6]="Always_Play_Random_Song",e[e.Height=7]="Height",e[e.Display_Style=8]="Display_Style",e[e.Grid_Covers_Per_Row=9]="Grid_Covers_Per_Row",e[e.Grid_Center_Covers=10]="Grid_Center_Covers",e[e.Grid_Show_Title=11]="Grid_Show_Title",e[e.Hide_Warning=12]="Hide_Warning",e[e.Default_Device=13]="Default_Device",e[e.Filter_Devices=14]="Filter_Devices",e[e.Hide_Connect_Devices=15]="Hide_Connect_Devices",e[e.Hide_Chromecast_Devices=16]="Hide_Chromecast_Devices",e[e.Hide_Top_Header=17]="Hide_Top_Header",e[e.Hide_Currently_Playing=18]="Hide_Currently_Playing",e[e.Hide_Playback_Controls=19]="Hide_Playback_Controls"}(ae||(ae={}));var re=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,le="[^\\s]+",ce=/\[([^]*?)\]/gm;function de(e,t){for(var i=[],s=0,n=e.length;s-1?s:null}};function pe(e){for(var t=[],i=1;i3?0:(e-e%10!=10?1:0)*e%10]}},me=pe({},_e),fe=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+fe(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+fe(Math.floor(Math.abs(t)/60),2)+":"+fe(Math.abs(t)%60,2)}},we=function(e){return+e-1},be=[null,"[1-9]\\d?"],Se=[null,le],Ce=["isPm",le,function(e,t){var i=e.toLowerCase();return i===t.amPm[0]?0:i===t.amPm[1]?1:null}],xe=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var i=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?i:-i}return 0}],$e=(he("monthNamesShort"),he("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Pe=function(e,t,i){if(void 0===t&&(t=$e.default),void 0===i&&(i={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var s=[];t=(t=$e[t]||t).replace(ce,(function(e,t){return s.push(t),"@@@"}));var n=pe(pe({},me),i);return(t=t.replace(re,(function(t){return ye[t](e,n)}))).replace(/@@@/g,(function(){return s.shift()}))},ke=(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}(),{version:"Version",description:"A custom card for displaying Spotify-Playlist and starting playback",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_missing_spotcast:"Spotcast integration has to be installed for this component to work",show_missing_spotify:"Spotify integration has to be installed for playback information",choose_player:"Choose player"}),De={general:"General",general_description:"General settings for this card",appearance:"Appearance",appearance_description:"Customize the style, icon, etc",advanced:"Advanced",advanced_description:"Customize advanced settings",hide_warning:"Hide warnings",playlist_type:"Playlist Type",limit:"Amount of playlists shown",height:"Height of card",country_code:"Country Code",always_play_random_song:"Always play random song when starting playback",title:"Title of card",display_style:"Display Style",grid_covers_per_row:"Number of covers per row",grid_center_covers:"Center Covers",grid_show_title:"Show album title in grid view",account:"Account",filter_out_cast_devices:"Filter out chromecast devices",spotify_entity:"Spotify media player entity",default_device:"Default device name",filter_devices:"Hide devices (see documentation under 'Advanced usage')",hide_connect_devices:"Hide all Spotify Connect Devices",hide_chromecast_devices:"Hide all Chromecast Devices",hide_top_header:"Hide header",hide_currently_playing:"Hide currently playing",hide_playback_controls:"Hide playback controls"},Ve={common:ke,settings:De},Me={version:"Version",description:"Eine Karte um Spotify-Playlist anzuzeigen und abzuspielen",invalid_configuration:"Ungültige Konfiguration",show_warning:"Warnung",show_missing_spotcast:"Die Spotcast-Integration muss installiert sein, damit diese Karte funktioniert",show_missing_spotify:"Die Spotify-Integration muss installiert sein, damit der Spotify-Status angezeigt werden kann",choose_player:"Player auswählen"},Te={general:"Generell",general_description:"Generelle Einstellungen",appearance:"Aussehen",appearance_description:"Passe den Stil und anderes an",hide_warning:"Verstecke Warnhinweise",playlist_type:"Playlist Typ",limit:"Anzahl an angezeigten Playlisten",height:"Höhe der Karte",country_code:"Länder-Code für die Featured-Playlist",always_play_random_song:"Spiele immer einen zufälligen Song beim Starten der Wiedergabe ab",title:"Titel der Karte",display_style:"Anzeige-Stil",grid_covers_per_row:"Anzahl an Albenbildern pro Reihe",grid_show_title:"Zeige Albumtitel in Grid-View",account:"Account",filter_out_cast_devices:"Filter Chromecast Geräte aus",spotify_entity:"Spotify media player entity",default_device:"Standart Gerätename",filter_devices:"Verstecke Geräte (siehe Dokumentation unter 'Advanced usage')",hide_top_header:"Verstecke Kopfzeile",hide_currently_playing:"Verstecke die Anzeige des aktuellen Liedes",hide_playback_controls:"Verstecke Wiedergabesteuerung"},Ee={common:Me,settings:Te},Ne={version:"Version",description:"A custom card for displaying Spotify-Playlist and starting playback",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_missing_spotcast:"Spotcast integration has to be installed for this component to work",show_missing_spotify:"Spotify integration has to be installed for playback information"},Ae={general:"General",general_description:"General settings for this card",appearance:"Appearance",appearance_description:"Customize the style, icon, etc",hide_warning:"Hide warnings",playlist_type:"Playlist Type",limit:"Amount of playlists shown",height:"Height of card",country_code:"Country Code for featured playlists",always_play_random_song:"Always play random song when starting playback",title:"Title of card",display_style:"Display Style",grid_covers_per_row:"Number of covers per row",account:"Account",filter_out_cast_devices:"Filter out chromecast devices",spotify_entity:"Spotify media player entity",default_device:"Default device name"},Oe={common:Ne,settings:Ae};const He={en:Object.freeze({__proto__:null,common:ke,settings:De,default:Ve}),de:Object.freeze({__proto__:null,common:Me,settings:Te,default:Ee}),se:Object.freeze({__proto__:null,common:Ne,settings:Ae,default:Oe})};function ze(e,t="",i=""){const s=e.split(".")[0],n=e.split(".")[1],a=(localStorage.getItem("selectedLanguage")||navigator.language.split("-")[0]||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=He[a][s][n]}catch(e){o=He.en[s][n]}return void 0===o&&(o=He.en[s][n]),""!==t&&""!==i&&(o=o.replace(t,i)),o}const Le={general:{icon:"tune",name:ze("settings.general"),secondary:ze("settings.general_description"),show:!0},appearance:{icon:"palette",name:ze("settings.appearance"),secondary:ze("settings.appearance_description"),show:!1},advanced:{icon:"pencil",name:ze("settings.advanced"),secondary:ze("settings.advanced_description"),show:!1}};let Ue=class extends ie{constructor(){super(...arguments),this.accounts=[],this.chromecast_devices=[]}async connectedCallback(){super.connectedCallback();const e=await this.hass.callWS({type:"spotcast/accounts"});this.accounts=e;const t=await this.hass.callWS({type:"spotcast/castdevices"});this.chromecast_devices=null==t?void 0:t.map(e=>e.friendly_name)}setConfig(e){this.config=e}getMediaPlayerEntities(){return Object.values(this.hass.states).filter(e=>e.entity_id.match("media_player[.]")).map(e=>e.entity_id)}_toggleOption(e){this._toggleThing(e,Le)}_toggleThing(e,t){const i=!t[e.target.option].show;for(const[e]of Object.entries(t));t[e.target.option].show=i,this._toggle=!this._toggle}valueChanged(e){if(!this.config||!this.hass||null===e.target.offsetParent)return;const{target:t}=e;if(!t.value||this["_"+t.configValue]!==t.value){if(t.configValue)if(!1===t.checked||""===t.value){const e=Object.assign({},this.config);delete e[t.configValue],this.config=e}else{let e=t.value;"height"==t.configValue||"limit"==t.configValue?e=Number(e):"filter_devices"==t.configValue&&(e=e.split(",").map(e=>e.trim()).filter(e=>""!=e)),this.config=Object.assign(Object.assign({},this.config),{[t.configValue]:void 0!==t.checked?t.checked:e})}!function(e,t,i,s){s=s||{},i=null==i?{}:i;var n=new Event(t,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});n.detail=i,e.dispatchEvent(n)}(this,"config-changed",{config:this.config})}}getValue(e){var t,i,s,n,a,o,r,l,c,d,h,p,u,g,v,_,m,f,y,w,b,S,C,x,$,P,k,D,V,M,T,E,N,A,O,H,z,L,U;switch(e){case ae.Name:return null!==(i=null===(t=this.config)||void 0===t?void 0:t.name)&&void 0!==i?i:"";case ae.Account:return null!==(n=null===(s=this.config)||void 0===s?void 0:s.account)&&void 0!==n?n:"default";case ae.Spotify_Entity:const e=this.getMediaPlayerEntities().filter(e=>e.includes("spotify"));return null!==(o=null===(a=this.config)||void 0===a?void 0:a.spotify_entity)&&void 0!==o?o:e.length>0?e[0]:"";case ae.Country_Code:return null!==(l=null===(r=this.config)||void 0===r?void 0:r.country_code)&&void 0!==l?l:"";case ae.Limit:return null!==(d=null===(c=this.config)||void 0===c?void 0:c.limit)&&void 0!==d?d:10;case ae.Playlist_Type:return null!==(p=null===(h=this.config)||void 0===h?void 0:h.playlist_type)&&void 0!==p?p:"default";case ae.Always_Play_Random_Song:return null!==(g=null===(u=this.config)||void 0===u?void 0:u.always_play_random_song)&&void 0!==g&&g;case ae.Height:return null!==(_=null===(v=this.config)||void 0===v?void 0:v.height)&&void 0!==_?_:"";case ae.Display_Style:return null!==(f=null===(m=this.config)||void 0===m?void 0:m.display_style)&&void 0!==f?f:"list";case ae.Grid_Covers_Per_Row:return null!==(w=null===(y=this.config)||void 0===y?void 0:y.grid_covers_per_row)&&void 0!==w?w:5;case ae.Grid_Center_Covers:return null!==(S=null===(b=this.config)||void 0===b?void 0:b.grid_center_covers)&&void 0!==S&&S;case ae.Hide_Warning:return null!==(x=null===(C=this.config)||void 0===C?void 0:C.hide_warning)&&void 0!==x&&x;case ae.Default_Device:return null!==(P=null===($=this.config)||void 0===$?void 0:$.default_device)&&void 0!==P?P:"";case ae.Filter_Devices:return null!==(V=null===(D=null===(k=this.config)||void 0===k?void 0:k.filter_devices)||void 0===D?void 0:D.toString())&&void 0!==V?V:"";case ae.Hide_Connect_Devices:return null!==(T=null===(M=this.config)||void 0===M?void 0:M.hide_connect_devices)&&void 0!==T&&T;case ae.Hide_Chromecast_Devices:return null!==(N=null===(E=this.config)||void 0===E?void 0:E.hide_chromecast_devices)&&void 0!==N&&N;case ae.Hide_Top_Header:return null!==(O=null===(A=this.config)||void 0===A?void 0:A.hide_top_header)&&void 0!==O&&O;case ae.Hide_Currently_Playing:return null!==(z=null===(H=this.config)||void 0===H?void 0:H.hide_currently_playing)&&void 0!==z&&z;case ae.Hide_Playback_Controls:return null!==(U=null===(L=this.config)||void 0===L?void 0:L.hide_playback_controls)&&void 0!==U&&U}}renderGeneral(){const e=this.getMediaPlayerEntities();return H` +(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");const te={};class ie extends G{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(void 0===e)this._styles=[];else if(Array.isArray(e)){const t=(e,i)=>e.reduceRight((e,i)=>Array.isArray(i)?t(i,e):(e.add(i),e),i),i=t(e,new Set),s=[];i.forEach(e=>s.unshift(e)),this._styles=s}else this._styles=[e]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==te&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return te}}ie.finalized=!0,ie.render=(e,t,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,a=A.has(t),o=L&&11===t.nodeType&&!!t.host,r=o&&!R.has(n),l=r?document.createDocumentFragment():t;if(((e,t,s)=>{let n=A.get(t);void 0===n&&(i(t,t.firstChild),A.set(t,n=new $(Object.assign({templateFactory:E},s))),n.appendInto(t)),n.setValue(e),n.commit()})(e,l,Object.assign({templateFactory:U(n)},s)),r){const e=A.get(l);A.delete(l);const s=e.value instanceof f?e.value.template:void 0;Y(n,l,s),i(t,t.firstChild),t.appendChild(l),A.set(t,e)}!a&&o&&window.ShadyCSS.styleElement(t.host)};var se,ne,ae;function oe(e){return"currently_playing_type"in e}!function(e){e.Grid="grid",e.List="list"}(se||(se={})),function(e){e.default="default",e.featured="featured",e.discover_weekly="discover-weekly"}(ne||(ne={})),function(e){e[e.Name=0]="Name",e[e.Account=1]="Account",e[e.Spotify_Entity=2]="Spotify_Entity",e[e.Country_Code=3]="Country_Code",e[e.Limit=4]="Limit",e[e.Playlist_Type=5]="Playlist_Type",e[e.Always_Play_Random_Song=6]="Always_Play_Random_Song",e[e.Height=7]="Height",e[e.Display_Style=8]="Display_Style",e[e.Grid_Covers_Per_Row=9]="Grid_Covers_Per_Row",e[e.Grid_Center_Covers=10]="Grid_Center_Covers",e[e.Grid_Show_Title=11]="Grid_Show_Title",e[e.Hide_Warning=12]="Hide_Warning",e[e.Default_Device=13]="Default_Device",e[e.Filter_Devices=14]="Filter_Devices",e[e.Hide_Connect_Devices=15]="Hide_Connect_Devices",e[e.Hide_Chromecast_Devices=16]="Hide_Chromecast_Devices",e[e.Hide_Top_Header=17]="Hide_Top_Header",e[e.Hide_Currently_Playing=18]="Hide_Currently_Playing",e[e.Hide_Playback_Controls=19]="Hide_Playback_Controls"}(ae||(ae={}));var re=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,le="[^\\s]+",ce=/\[([^]*?)\]/gm;function de(e,t){for(var i=[],s=0,n=e.length;s-1?s:null}};function pe(e){for(var t=[],i=1;i3?0:(e-e%10!=10?1:0)*e%10]}},me=pe({},_e),fe=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+fe(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+fe(Math.floor(Math.abs(t)/60),2)+":"+fe(Math.abs(t)%60,2)}},we=function(e){return+e-1},be=[null,"[1-9]\\d?"],Se=[null,le],Ce=["isPm",le,function(e,t){var i=e.toLowerCase();return i===t.amPm[0]?0:i===t.amPm[1]?1:null}],xe=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var i=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?i:-i}return 0}],$e=(he("monthNamesShort"),he("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Pe=function(e,t,i){if(void 0===t&&(t=$e.default),void 0===i&&(i={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var s=[];t=(t=$e[t]||t).replace(ce,(function(e,t){return s.push(t),"@@@"}));var n=pe(pe({},me),i);return(t=t.replace(re,(function(t){return ye[t](e,n)}))).replace(/@@@/g,(function(){return s.shift()}))},ke=(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}(),{version:"Version",description:"A custom card for displaying Spotify-Playlist and starting playback",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_missing_spotcast:"Spotcast integration has to be installed for this component to work",show_missing_spotify:"Spotify integration has to be installed for playback information",choose_player:"Choose player"}),De={general:"General",general_description:"General settings for this card",appearance:"Appearance",appearance_description:"Customize the style, icon, etc",advanced:"Advanced",advanced_description:"Customize advanced settings",hide_warning:"Hide warnings",playlist_type:"Playlist Type",limit:"Amount of playlists shown",height:"Height of card",country_code:"Country Code",always_play_random_song:"Always play random song when starting playback",title:"Title of card",display_style:"Display Style",grid_covers_per_row:"Number of covers per row",grid_center_covers:"Center Covers",grid_show_title:"Show album title in grid view",account:"Account",spotify_entity:"Spotify media player entity",default_device:"Default device name",filter_devices:"Hide devices (see documentation under 'Advanced usage')",hide_connect_devices:"Hide all Spotify Connect Devices",hide_chromecast_devices:"Hide all Chromecast Devices",hide_top_header:"Hide header",hide_currently_playing:"Hide currently playing",hide_playback_controls:"Hide playback controls"},Ve={common:ke,settings:De},Me={version:"Version",description:"Eine Karte um Spotify-Playlist anzuzeigen und abzuspielen",invalid_configuration:"Ungültige Konfiguration",show_warning:"Warnung",show_missing_spotcast:"Die Spotcast-Integration muss installiert sein, damit diese Karte funktioniert",show_missing_spotify:"Die Spotify-Integration muss installiert sein, damit der Spotify-Status angezeigt werden kann",choose_player:"Player auswählen"},Te={general:"Generell",general_description:"Generelle Einstellungen",appearance:"Aussehen",appearance_description:"Passe den Stil und anderes an",hide_warning:"Verstecke Warnhinweise",playlist_type:"Playlist Typ",limit:"Anzahl an angezeigten Playlisten",height:"Höhe der Karte",country_code:"Länder-Code",always_play_random_song:"Spiele immer einen zufälligen Song beim Starten der Wiedergabe ab",title:"Titel der Karte",display_style:"Anzeige-Stil",grid_covers_per_row:"Anzahl an Albenbildern pro Reihe",grid_show_title:"Zeige Albumtitel in Grid-View",account:"Account",spotify_entity:"Spotify media player entity",default_device:"Standart Gerätename",filter_devices:"Verstecke Geräte (siehe Dokumentation unter 'Advanced usage')",hide_connect_devices:"Verstecke alle Spotify Connect Geräte",hide_chromecast_devices:"Verstecke alle Chromecast Geräte",hide_top_header:"Verstecke Kopfzeile",hide_currently_playing:"Verstecke die Anzeige des aktuellen Liedes",hide_playback_controls:"Verstecke Wiedergabesteuerung"},Ee={common:Me,settings:Te},Ne={version:"Version",description:"A custom card for displaying Spotify-Playlist and starting playback",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_missing_spotcast:"Spotcast integration has to be installed for this component to work",show_missing_spotify:"Spotify integration has to be installed for playback information"},Ae={general:"General",general_description:"General settings for this card",appearance:"Appearance",appearance_description:"Customize the style, icon, etc",hide_warning:"Hide warnings",playlist_type:"Playlist Type",limit:"Amount of playlists shown",height:"Height of card",country_code:"Country Code for featured playlists",always_play_random_song:"Always play random song when starting playback",title:"Title of card",display_style:"Display Style",grid_covers_per_row:"Number of covers per row",account:"Account",filter_out_cast_devices:"Filter out chromecast devices",spotify_entity:"Spotify media player entity",default_device:"Default device name"},Oe={common:Ne,settings:Ae};const He={en:Object.freeze({__proto__:null,common:ke,settings:De,default:Ve}),de:Object.freeze({__proto__:null,common:Me,settings:Te,default:Ee}),se:Object.freeze({__proto__:null,common:Ne,settings:Ae,default:Oe})};function ze(e,t="",i=""){const s=e.split(".")[0],n=e.split(".")[1],a=(localStorage.getItem("selectedLanguage")||navigator.language.split("-")[0]||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=He[a][s][n]}catch(e){o=He.en[s][n]}return void 0===o&&(o=He.en[s][n]),""!==t&&""!==i&&(o=o.replace(t,i)),o}const Le={general:{icon:"tune",name:ze("settings.general"),secondary:ze("settings.general_description"),show:!0},appearance:{icon:"palette",name:ze("settings.appearance"),secondary:ze("settings.appearance_description"),show:!1},advanced:{icon:"pencil",name:ze("settings.advanced"),secondary:ze("settings.advanced_description"),show:!1}};let Ue=class extends ie{constructor(){super(...arguments),this.accounts=[],this.chromecast_devices=[]}async connectedCallback(){super.connectedCallback();const e=await this.hass.callWS({type:"spotcast/accounts"});this.accounts=e;const t=await this.hass.callWS({type:"spotcast/castdevices"});this.chromecast_devices=null==t?void 0:t.map(e=>e.friendly_name)}setConfig(e){this.config=e}getMediaPlayerEntities(){return Object.values(this.hass.states).filter(e=>e.entity_id.match("media_player[.]")).map(e=>e.entity_id)}_toggleOption(e){this._toggleThing(e,Le)}_toggleThing(e,t){const i=!t[e.target.option].show;for(const[e]of Object.entries(t))t[e].show=!1;t[e.target.option].show=i,this._toggle=!this._toggle}valueChanged(e){if(!this.config||!this.hass||null===e.target.offsetParent)return;const{target:t}=e;if(!t.value||this["_"+t.configValue]!==t.value){if(t.configValue)if(!1===t.checked||""===t.value){const e=Object.assign({},this.config);delete e[t.configValue],this.config=e}else{let e=t.value;"height"==t.configValue||"limit"==t.configValue?e=Number(e):"filter_devices"==t.configValue&&(e=e.split(",").map(e=>e.trim()).filter(e=>""!=e)),this.config=Object.assign(Object.assign({},this.config),{[t.configValue]:void 0!==t.checked?t.checked:e})}!function(e,t,i,s){s=s||{},i=null==i?{}:i;var n=new Event(t,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});n.detail=i,e.dispatchEvent(n)}(this,"config-changed",{config:this.config})}}getValue(e){var t,i,s,n,a,o,r,l,c,d,h,p,u,g,v,_,m,f,y,w,b,S,C,x,$,P,k,D,V,M,T,E,N,A,O,H,z,L,U;switch(e){case ae.Name:return null!==(i=null===(t=this.config)||void 0===t?void 0:t.name)&&void 0!==i?i:"";case ae.Account:return null!==(n=null===(s=this.config)||void 0===s?void 0:s.account)&&void 0!==n?n:"default";case ae.Spotify_Entity:const e=this.getMediaPlayerEntities().filter(e=>e.includes("spotify"));return null!==(o=null===(a=this.config)||void 0===a?void 0:a.spotify_entity)&&void 0!==o?o:e.length>0?e[0]:"";case ae.Country_Code:return null!==(l=null===(r=this.config)||void 0===r?void 0:r.country_code)&&void 0!==l?l:"";case ae.Limit:return null!==(d=null===(c=this.config)||void 0===c?void 0:c.limit)&&void 0!==d?d:10;case ae.Playlist_Type:return null!==(p=null===(h=this.config)||void 0===h?void 0:h.playlist_type)&&void 0!==p?p:"default";case ae.Always_Play_Random_Song:return null!==(g=null===(u=this.config)||void 0===u?void 0:u.always_play_random_song)&&void 0!==g&&g;case ae.Height:return null!==(_=null===(v=this.config)||void 0===v?void 0:v.height)&&void 0!==_?_:"";case ae.Display_Style:return null!==(f=null===(m=this.config)||void 0===m?void 0:m.display_style)&&void 0!==f?f:"list";case ae.Grid_Covers_Per_Row:return null!==(w=null===(y=this.config)||void 0===y?void 0:y.grid_covers_per_row)&&void 0!==w?w:5;case ae.Grid_Center_Covers:return null!==(S=null===(b=this.config)||void 0===b?void 0:b.grid_center_covers)&&void 0!==S&&S;case ae.Hide_Warning:return null!==(x=null===(C=this.config)||void 0===C?void 0:C.hide_warning)&&void 0!==x&&x;case ae.Default_Device:return null!==(P=null===($=this.config)||void 0===$?void 0:$.default_device)&&void 0!==P?P:"";case ae.Filter_Devices:return null!==(V=null===(D=null===(k=this.config)||void 0===k?void 0:k.filter_devices)||void 0===D?void 0:D.toString())&&void 0!==V?V:"";case ae.Hide_Connect_Devices:return null!==(T=null===(M=this.config)||void 0===M?void 0:M.hide_connect_devices)&&void 0!==T&&T;case ae.Hide_Chromecast_Devices:return null!==(N=null===(E=this.config)||void 0===E?void 0:E.hide_chromecast_devices)&&void 0!==N&&N;case ae.Hide_Top_Header:return null!==(O=null===(A=this.config)||void 0===A?void 0:A.hide_top_header)&&void 0!==O&&O;case ae.Hide_Currently_Playing:return null!==(z=null===(H=this.config)||void 0===H?void 0:H.hide_currently_playing)&&void 0!==z&&z;case ae.Hide_Playback_Controls:return null!==(U=null===(L=this.config)||void 0===L?void 0:L.hide_playback_controls)&&void 0!==U&&U}}renderGeneral(){const e=this.getMediaPlayerEntities();return H`
0))throw new Error("No device available for playback");{const t=this.parent.devices[0].name;this.startPlaybackOnDevice(t,e)}}}}startPlaybackOnDevice(e,t){const i=this.parent.devices.filter(t=>t.name==e);if(i.length>0)return this.playUriOnConnectDevice(i[0].id,t);{const i=this.parent.chromecast_devices.filter(t=>t.friendly_name==e);if(i.length>0)return this.playUriOnCastDevice(i[0].friendly_name,t);throw new Error("Could not find device: "+e)}}transferPlaybackToCastDevice(e){this.parent.hass.callService("spotcast","start",{device_name:e,force_playback:!0,account:this.parent.config.account})}transferPlaybackToConnectDevice(e){this.parent.hass.callService("spotcast","start",{spotify_device_id:e,force_playback:!0,account:this.parent.config.account})}playUriOnCastDevice(e,t){const i=Object.assign(Object.assign({},this.getPlaybackOptions(t)),{device_name:e});this.parent.hass.callService("spotcast","start",i)}playUriOnConnectDevice(e,t){const i=Object.assign(Object.assign({},this.getPlaybackOptions(t)),{spotify_device_id:e});this.parent.hass.callService("spotcast","start",i)}async updateState(){if(!((new Date).getTime()-this.last_state_update_time{let t=[];function i(i,s){e=s?i:Object.assign(Object.assign({},e),i);let n=t;for(let t=0;t(t.push(e),()=>{!function(e){let i=[];for(let s=0;s{if(e[t])return e[t];let n,a=0,o=Re();const r=()=>i(e).then(e=>o.setState(e,!0)),l=()=>r().catch(t=>{if(e.connected)throw t});return e[t]={get state(){return o.state},refresh:r,subscribe(t){a++,1===a&&(s&&(n=s(e,o)),e.addEventListener("ready",l),l());const i=o.subscribe(t);return void 0!==o.state&&setTimeout(()=>t(o.state),0),()=>{i(),a--,a||(n&&n.then(e=>{e()}),e.removeEventListener("ready",r))}}},e[t]},Fe=e=>e.sendMessagePromise({type:"get_states"});function We(e,t){if(void 0===e)return null;const{domain:i,service:s}=t.data;return{[i]:Object.assign({},e[i],{[s]:{description:"",fields:{}}})}}function Ie(e,t){if(void 0===e)return null;const{domain:i,service:s}=t.data,n=e[i];if(!n||!(s in n))return null;const a={};return Object.keys(n).forEach(e=>{e!==s&&(a[e]=n[e])}),{[i]:a}}const qe=e=>e.sendMessagePromise({type:"get_services"}),Ge=(e,t)=>Promise.all([e.subscribeEvents(t.action(We),"service_registered"),e.subscribeEvents(t.action(Ie),"service_removed")]).then(e=>()=>e.forEach(e=>e()));async function Be(e){const t=await Fe(e),i={};for(let e=0;ee.subscribeEvents(e=>function(e,t){const i=e.state;if(void 0===i)return;const{entity_id:s,new_state:n}=t.data;if(n)e.setState({[n.entity_id]:n});else{const t=Object.assign({},i);delete t[s],e.setState(t,!0)}}(t,e),"state_changed"),Je=(e,t)=>(e=>Ye(e,"_ent",Be,Ze))(e).subscribe(t);var Ke;function Qe(e,t){if(!t||!oe(t)&&!oe(e)&&e.length!=t.length)return!0;for(const i in e)if(e[i].id!=t[i].id)return!0;return!1}function Xe(e,t){return!t||(e.state!=t.state||e.attributes.shuffle!=t.attributes.shuffle||e.attributes.media_title!=t.attributes.media_title||e.attributes.media_artist!=t.attributes.media_artist||e.attributes.volume_level!=t.attributes.volume_level)}console.info(`%c SPOTIFY-CARD \n%c ${ze("common.version")} 2.3.7 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"spotify-card",name:"Spotify Card",description:ze("common.description"),preview:!0});let et=Ke=class extends ie{constructor(){super(),this.playlists=[],this.devices=[],this.chromecast_devices=[],this._spotify_installed=!1,this._fetch_time_out=0,this._last_volume_set_time=0,this.spotcast_connector=new je(this)}static async getConfigElement(){return document.createElement("spotify-card-editor")}static getStubConfig(){return{}}setConfig(e){let t="";if(e.playlist_type&&!Object.values(ne).includes(e.playlist_type.toLowerCase())&&(t="playlist_type"),e.display_style&&!Object.values(se).includes(e.display_style.toLowerCase())&&(t="display_style"),e.show_error||""!=t)throw new Error(ze("common.invalid_configuration")+": "+t);this.config=e}connectedCallback(){super.connectedCallback(),this.doSubscribeEntities(),this.updateSpotcast()}doSubscribeEntities(){var e;(null===(e=this.hass)||void 0===e?void 0:e.connection)&&!this._unsubscribe_entitites&&this.isConnected&&(this._unsubscribe_entitites=Je(this.hass.connection,e=>this.entitiesUpdated(e)))}entitiesUpdated(e){let t=!1;for(const i in e)i.startsWith("media_player")&&((i.startsWith("media_player.spotify")||i==this.config.spotify_entity)&&(this._spotify_installed=!0,this._spotify_state=e[i]),t=!0);t&&!document.hidden&&this.updateSpotcast()}updateSpotcast(){this._fetch_time_out&&clearTimeout(this._fetch_time_out),this._fetch_time_out=setTimeout(async()=>{this.hass&&this.isSpotcastInstalled()&&!this.spotcast_connector.is_loading()&&(await this.spotcast_connector.updateState(),await this.spotcast_connector.fetchPlaylists())},500)}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribe_entitites&&(this._unsubscribe_entitites(),this._unsubscribe_entitites=void 0)}updated(e){super.updated(e),this.updateComplete.then(()=>{for(const e of this.renderRoot.querySelectorAll("[data-spotify-image-url]")){const t=new Image;t.onload=function(t){var i;null===(i=e.firstElementChild)||void 0===i||i.replaceWith(t.srcElement)},e.dataset.spotifyImageUrl&&(t.src=e.dataset.spotifyImageUrl)}})}getDisplayStyle(){var e;return"grid"==(null===(e=this.config.display_style)||void 0===e?void 0:e.toLowerCase())?se.Grid:se.List}getPlayingState(){var e,t;return null!==(t="playing"==(null===(e=this._spotify_state)||void 0===e?void 0:e.state))&&void 0!==t&&t}getShuffleState(){var e,t;return null!==(t=null===(e=this.player)||void 0===e?void 0:e.shuffle_state)&&void 0!==t&&t}getSpotifyEntityState(){return this._spotify_state?this._spotify_state.state:""}isSpotcastInstalled(){var e,t;return!(!(null===(e=this.hass)||void 0===e?void 0:e.connection)||void 0===(t=this.hass.connection,Ye(t,"_srv",qe,Ge)).state.spotcast)}checkIfAllowedToShow(e){var t,i;const s=null!==(i=null===(t=this.config.filter_devices)||void 0===t?void 0:t.map(e=>new RegExp(e+"$")))&&void 0!==i?i:[];for(const t of s)if(t.test("name"in e?e.name:e.friendly_name))return!1;return!0}getDefaultDevice(){let[e,t]=this.getFilteredDevices();if(e=e.filter(e=>e.name==this.config.default_device),t=t.filter(e=>e.friendly_name==this.config.default_device),e.length>0||t.length>0)return this.config.default_device}getFilteredDevices(){return[this.config.hide_connect_devices?[]:this.devices.filter(this.checkIfAllowedToShow,this),this.config.hide_chromecast_devices?[]:this.chromecast_devices.filter(this.checkIfAllowedToShow,this)]}getPlaylists(){return this.playlists}isThisPlaylistPlaying(e){var t;return(null===(t=this._spotify_state)||void 0===t?void 0:t.attributes.media_playlist)===e.name}startUri(e,t){var i;const s=e.target;let n;switch(s.localName){case"img":n=null===(i=s.parentElement)||void 0===i?void 0:i.parentElement;break;case"div":n=s;break;case"p":n=s.parentElement;break;default:console.log(s)}n.classList.add("loading"),setTimeout(()=>{n.classList.remove("loading")},1e4),this.spotcast_connector.playUri(t)}onShuffleSelect(e){var t,i;this.hass.callService("media_player","shuffle_set",{entity_id:null===(t=this._spotify_state)||void 0===t?void 0:t.entity_id,shuffle:!(null===(i=this.player)||void 0===i?void 0:i.shuffle_state)});let s=e.target.parentElement;"svg"==(null==s?void 0:s.localName)&&(s=s.parentElement),(null==s?void 0:s.classList.contains("shuffle"))?s.classList.remove("shuffle"):null==s||s.classList.add("shuffle")}handleMediaEvent(e,t){e.stopPropagation(),this._spotify_state&&this.hass.callService("media_player",t,{entity_id:this._spotify_state.entity_id})}getVolume(){var e,t;return 100*(null===(t=null===(e=this._spotify_state)||void 0===e?void 0:e.attributes)||void 0===t?void 0:t.volume_level)}shouldUpdate(e){let t=!0;return e.forEach((e,i)=>{if("_spotify_state"==i){(new Date).getTime()-this._last_volume_set_time<500&&(t=!1)}}),t}handleVolumeChanged(e){if(e.stopPropagation(),this._spotify_state){this.hass.callService("media_player","volume_set",{entity_id:this._spotify_state.entity_id,volume_level:e.target.value/100});const t=new Date;this._last_volume_set_time=t.getTime()}}confirmDeviceSelection(e){var t;const i=e.target;null===(t=null==i?void 0:i.parentElement)||void 0===t||t.classList.add("dropdown-content-hide"),setTimeout(()=>{var e;null===(e=null==i?void 0:i.parentElement)||void 0===e||e.classList.remove("dropdown-content-hide")},1e3)}spotifyDeviceSelected(e,t){this.confirmDeviceSelection(e);if(this.spotcast_connector.getCurrentPlayer())return this.spotcast_connector.transferPlaybackToConnectDevice(t.id);const i=this.playlists[0];console.log("spotifyDeviceSelected playing first playlist"),this.spotcast_connector.playUriOnConnectDevice(t.id,i.uri)}chromecastDeviceSelected(e,t){this.confirmDeviceSelection(e);if(this.spotcast_connector.getCurrentPlayer())return this.spotcast_connector.transferPlaybackToCastDevice(t.friendly_name);const i=this.playlists[0];console.log("chromecastDeviceSelected playing first playlist"),this.spotcast_connector.playUriOnCastDevice(t.friendly_name,i.uri)}getCurrentPlayer(){return this.spotcast_connector.getCurrentPlayer()}render(){var e,t,i,s,n,a,o,r;let l=H``;this.isSpotcastInstalled()||(l=this.showWarning(ze("common.show_missing_spotcast")));let c=H`
Loading...
`;if(this.spotcast_connector.is_loaded())switch(this.getDisplayStyle()){case se.Grid:c=this.generateGridView();break;default:c=this.generateListView()}const d=H`