diff --git a/dist/spotify-card.js b/dist/spotify-card.js index 3ea29fb..35580bc 100644 --- a/dist/spotify-card.js +++ b/dist/spotify-card.js @@ -92,7 +92,7 @@ class v{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * 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 - */;function V(t){let e=D.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},D.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(s);return i=e.keyString.get(n),void 0===i&&(i=new r(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const D=new Map,E=new WeakMap; + */;function V(t){let e=E.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},E.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(s);return i=e.keyString.get(n),void 0===i&&(i=new r(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const E=new Map,D=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -145,7 +145,7 @@ class{handleAttributeExpressions(t,e,i,s){const n=e[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 - */,U=(t,e)=>`${t}--${e}`;let j=!0;void 0===window.ShadyCSS?j=!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."),j=!1);const H=t=>e=>{const i=U(e.type,t);let n=D.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},D.set(i,n));let o=n.stringsArray.get(e.strings);if(void 0!==o)return o;const a=e.strings.join(s);if(o=n.keyString.get(a),void 0===o){const i=e.getTemplateElement();j&&window.ShadyCSS.prepareTemplateDom(i,t),o=new r(e,i),n.keyString.set(a,o)}return n.stringsArray.set(e.strings,o),o},Y=["html","svg"],R=new Set,q=(t,e,i)=>{R.add(t);const s=i?i.element:document.createElement("template"),n=e.querySelectorAll("style"),{length:o}=n;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(s,t);const r=document.createElement("style");for(let t=0;t{Y.forEach(e=>{const i=D.get(U(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),h(t,i)})})})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:n}=t;if(null==i)return void s.appendChild(e);const o=document.createTreeWalker(s,133,null,!1);let r=u(n),a=0,c=-1;for(;o.nextNode();){c++;for(o.currentNode===i&&(a=p(e),i.parentNode.insertBefore(e,i));-1!==r&&n[r].index===c;){if(a>0){for(;-1!==r;)n[r].index+=a,r=u(n,r);return}r=u(n,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(s,t);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)e.insertBefore(c.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),h(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const L={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},F=(t,e)=>e!==t&&(e==e||t==t),W={attribute:!0,type:String,converter:L,reflect:!1,hasChanged:F};class I extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const s=this._attributeNameForProperty(i,e);void 0!==s&&(this._attributeToPropertyMap.set(s,i),t.push(s))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=W){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(i){const s=this[t];this[e]=i,this._requestUpdate(t,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||W}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=F){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||L,n="function"==typeof s?s:s.fromAttribute;return n?n(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||L.toAttribute)(t,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=W){const s=this.constructor,n=s._attributeNameForProperty(t,i);if(void 0!==n){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(n):this.setAttribute(n,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(t);if(void 0!==s){const t=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}_requestUpdate(t,e){let i=!0;if(void 0!==t){const s=this.constructor,n=s.getPropertyOptions(t);s._valueHasChanged(this[t],e,n.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,n))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this._requestUpdate(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}I.finalized=!0; + */,U=(t,e)=>`${t}--${e}`;let j=!0;void 0===window.ShadyCSS?j=!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."),j=!1);const H=t=>e=>{const i=U(e.type,t);let n=E.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},E.set(i,n));let o=n.stringsArray.get(e.strings);if(void 0!==o)return o;const a=e.strings.join(s);if(o=n.keyString.get(a),void 0===o){const i=e.getTemplateElement();j&&window.ShadyCSS.prepareTemplateDom(i,t),o=new r(e,i),n.keyString.set(a,o)}return n.stringsArray.set(e.strings,o),o},Y=["html","svg"],R=new Set,q=(t,e,i)=>{R.add(t);const s=i?i.element:document.createElement("template"),n=e.querySelectorAll("style"),{length:o}=n;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(s,t);const r=document.createElement("style");for(let t=0;t{Y.forEach(e=>{const i=E.get(U(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),h(t,i)})})})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:n}=t;if(null==i)return void s.appendChild(e);const o=document.createTreeWalker(s,133,null,!1);let r=u(n),a=0,c=-1;for(;o.nextNode();){c++;for(o.currentNode===i&&(a=p(e),i.parentNode.insertBefore(e,i));-1!==r&&n[r].index===c;){if(a>0){for(;-1!==r;)n[r].index+=a,r=u(n,r);return}r=u(n,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(s,t);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)e.insertBefore(c.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),h(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const L={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},F=(t,e)=>e!==t&&(e==e||t==t),W={attribute:!0,type:String,converter:L,reflect:!1,hasChanged:F};class I extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const s=this._attributeNameForProperty(i,e);void 0!==s&&(this._attributeToPropertyMap.set(s,i),t.push(s))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=W){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(i){const s=this[t];this[e]=i,this._requestUpdate(t,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||W}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=F){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||L,n="function"==typeof s?s:s.fromAttribute;return n?n(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||L.toAttribute)(t,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=W){const s=this.constructor,n=s._attributeNameForProperty(t,i);if(void 0!==n){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(n):this.setAttribute(n,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(t);if(void 0!==s){const t=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}_requestUpdate(t,e){let i=!0;if(void 0!==t){const s=this.constructor,n=s.getPropertyOptions(t);s._valueHasChanged(this[t],e,n.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,n))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this._requestUpdate(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}I.finalized=!0; /** * @license * Copyright (c) 2017 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 et={};class it extends I{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(void 0===t)this._styles=[];else if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),s=[];i.forEach(t=>s.unshift(t)),this._styles=s}else this._styles=[t]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==et&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return et}}it.finalized=!0,it.render=(t,e,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,o=E.has(e),r=j&&11===e.nodeType&&!!e.host,a=r&&!R.has(n),c=a?document.createDocumentFragment():e;if(((t,e,s)=>{let n=E.get(e);void 0===n&&(i(e,e.firstChild),E.set(e,n=new C(Object.assign({templateFactory:V},s))),n.appendInto(e)),n.setValue(t),n.commit()})(t,c,Object.assign({templateFactory:H(n)},s)),a){const t=E.get(c);E.delete(c);const s=t.value instanceof v?t.value.template:void 0;q(n,c,s),i(e,e.firstChild),e.appendChild(c),E.set(e,t)}!o&&r&&window.ShadyCSS.styleElement(e.host)};var st=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,nt="[^\\s]+",ot=/\[([^]*?)\]/gm;function rt(t,e){for(var i=[],s=0,n=t.length;s-1?s:null}};function ct(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},ut=ct({},pt),gt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+gt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+gt(Math.floor(Math.abs(e)/60),2)+":"+gt(Math.abs(e)%60,2)}},ft=function(t){return+t-1},mt=[null,"[1-9]\\d?"],vt=[null,nt],yt=["isPm",nt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],wt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],bt=(at("monthNamesShort"),at("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 St=function(t,e,i){if(void 0===e&&(e=bt.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];e=(e=bt[e]||e).replace(ot,(function(t,e){return s.push(e),"@@@"}));var n=ct(ct({},ut),i);return(e=e.replace(st,(function(e){return _t[e](t,n)}))).replace(/@@@/g,(function(){return s.shift()}))},xt=(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}(),function(t,e,i,s){s=s||{},i=null==i?{}:i;var n=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return n.detail=i,t.dispatchEvent(n),n});const $t=t=>{let e=[];function i(i,s){t=s?i:Object.assign(Object.assign({},t),i);let n=e;for(let e=0;e(e.push(t),()=>{!function(t){let i=[];for(let s=0;s{if(t[e])return t[e];let n,o=0,r=$t();const a=()=>i(t).then(t=>r.setState(t,!0)),c=()=>a().catch(e=>{if(t.connected)throw e});return t[e]={get state(){return r.state},refresh:a,subscribe(e){o++,1===o&&(s&&(n=s(t,r)),t.addEventListener("ready",c),c());const i=r.subscribe(e);return void 0!==r.state&&setTimeout(()=>e(r.state),0),()=>{i(),o--,o||(n&&n.then(t=>{t()}),t.removeEventListener("ready",a))}}},t[e]},Pt=t=>t.sendMessagePromise({type:"get_states"});function kt(t,e){if(void 0===t)return null;const{domain:i,service:s}=e.data;return{[i]:Object.assign({},t[i],{[s]:{description:"",fields:{}}})}}function Mt(t,e){if(void 0===t)return null;const{domain:i,service:s}=e.data,n=t[i];if(!n||!(s in n))return null;const o={};return Object.keys(n).forEach(t=>{t!==s&&(o[t]=n[t])}),{[i]:o}}const Nt=t=>t.sendMessagePromise({type:"get_services"}),Tt=(t,e)=>Promise.all([t.subscribeEvents(e.action(kt),"service_registered"),t.subscribeEvents(e.action(Mt),"service_removed")]).then(t=>()=>t.forEach(t=>t()));async function Ot(t){const e=await Pt(t),i={};for(let t=0;tt.subscribeEvents(t=>function(t,e){const i=t.state;if(void 0===i)return;const{entity_id:s,new_state:n}=e.data;if(n)t.setState({[n.entity_id]:n});else{const e=Object.assign({},i);delete e[s],t.setState(e,!0)}}(e,t),"state_changed"),Dt=(t,e)=>(t=>Ct(t,"_ent",Ot,Vt))(t).subscribe(e);var Et={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"},At={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 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"},zt={common:Et,settings:At},Ut={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"},jt={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:"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"},Ht={common:Ut,settings:jt},Yt={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"},Rt={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"},qt={common:Yt,settings:Rt};const Lt={en:Object.freeze({__proto__:null,common:Et,settings:At,default:zt}),de:Object.freeze({__proto__:null,common:Ut,settings:jt,default:Ht}),se:Object.freeze({__proto__:null,common:Yt,settings:Rt,default:qt})};function Ft(t,e="",i=""){const s=t.split(".")[0],n=t.split(".")[1],o=(localStorage.getItem("selectedLanguage")||navigator.language.split("-")[0]||"en").replace(/['"]+/g,"").replace("-","_");let r;try{r=Lt[o][s][n]}catch(t){r=Lt.en[s][n]}return void 0===r&&(r=Lt.en[s][n]),""!==e&&""!==i&&(r=r.replace(e,i)),r}const Wt={general:{icon:"tune",name:Ft("settings.general"),secondary:Ft("settings.general_description"),show:!0},appearance:{icon:"palette",name:Ft("settings.appearance"),secondary:Ft("settings.appearance_description"),show:!1},advanced:{icon:"pencil",name:Ft("settings.advanced"),secondary:Ft("settings.advanced_description"),show:!1}},It=["Default","featured","discover-weekly"],Bt=["List","Grid"];let Gt=class extends it{constructor(){super(...arguments),this.accounts=[],this.hidden_cast_devices=[],this.chromecast_devices=[]}async connectedCallback(){super.connectedCallback();const t=await this.hass.callWS({type:"spotcast/accounts"});this.accounts=t;const e=await this.hass.callWS({type:"spotcast/castdevices"});this.chromecast_devices=e.map(t=>t.friendly_name),this.requestUpdate()}setConfig(t){this._config=t}get _name(){return this._config&&this._config.name||""}get _account(){return this._config?this._config.account||"default":""}get _spotify_entity(){if(this._config){const t=this.getMediaPlayerEntities().filter(t=>t.entity_id.includes("spotify"));return this._config.spotify_entity||(t.length>0?t[0].entity_id:"")}return""}get _country_code(){return this._config&&this._config.country_code||""}get _limit(){return this._config&&this._config.limit||10}get _playlist_type(){return this._config?this._config.playlist_type||"Default":""}get _always_play_random_song(){return this._config&&this._config.always_play_random_song||!1}get _height(){return this._config&&this._config.height||""}get _display_style(){return this._config&&this._config.display_style||"List"}get _grid_covers_per_row(){return this._config&&this._config.grid_covers_per_row||5}get _grid_center_covers(){return this._config&&this._config.grid_center_covers||!1}get _hidden_cast_devices(){return this._config&&this._config.hidden_cast_devices||[]}get _hide_warning(){return this._config&&this._config.hide_warning||!1}get _show_warning(){return this._config&&this._config.show_warning||!1}get _show_error(){return this._config&&this._config.show_error||!1}get _default_device(){return this._config&&this._config.default_device||""}getMediaPlayerEntities(){return Object.keys(this.hass.states).map(t=>this.hass.states[t]).filter(t=>t.entity_id.match("media_player[.]"))}renderGeneral(){const t=this.getMediaPlayerEntities().map(t=>t.entity_id);return z` +(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");const et={};class it extends I{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(void 0===t)this._styles=[];else if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),s=[];i.forEach(t=>s.unshift(t)),this._styles=s}else this._styles=[t]}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==et&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return et}}it.finalized=!0,it.render=(t,e,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,o=D.has(e),r=j&&11===e.nodeType&&!!e.host,a=r&&!R.has(n),c=a?document.createDocumentFragment():e;if(((t,e,s)=>{let n=D.get(e);void 0===n&&(i(e,e.firstChild),D.set(e,n=new C(Object.assign({templateFactory:V},s))),n.appendInto(e)),n.setValue(t),n.commit()})(t,c,Object.assign({templateFactory:H(n)},s)),a){const t=D.get(c);D.delete(c);const s=t.value instanceof v?t.value.template:void 0;q(n,c,s),i(e,e.firstChild),e.appendChild(c),D.set(e,t)}!o&&r&&window.ShadyCSS.styleElement(e.host)};var st=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,nt="[^\\s]+",ot=/\[([^]*?)\]/gm;function rt(t,e){for(var i=[],s=0,n=t.length;s-1?s:null}};function ct(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},ut=ct({},pt),gt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+gt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+gt(Math.floor(Math.abs(e)/60),2)+":"+gt(Math.abs(e)%60,2)}},ft=function(t){return+t-1},mt=[null,"[1-9]\\d?"],vt=[null,nt],yt=["isPm",nt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],wt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],bt=(at("monthNamesShort"),at("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 St=function(t,e,i){if(void 0===e&&(e=bt.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];e=(e=bt[e]||e).replace(ot,(function(t,e){return s.push(e),"@@@"}));var n=ct(ct({},ut),i);return(e=e.replace(st,(function(e){return _t[e](t,n)}))).replace(/@@@/g,(function(){return s.shift()}))},xt=(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}(),function(t,e,i,s){s=s||{},i=null==i?{}:i;var n=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return n.detail=i,t.dispatchEvent(n),n});const $t=t=>{let e=[];function i(i,s){t=s?i:Object.assign(Object.assign({},t),i);let n=e;for(let e=0;e(e.push(t),()=>{!function(t){let i=[];for(let s=0;s{if(t[e])return t[e];let n,o=0,r=$t();const a=()=>i(t).then(t=>r.setState(t,!0)),c=()=>a().catch(e=>{if(t.connected)throw e});return t[e]={get state(){return r.state},refresh:a,subscribe(e){o++,1===o&&(s&&(n=s(t,r)),t.addEventListener("ready",c),c());const i=r.subscribe(e);return void 0!==r.state&&setTimeout(()=>e(r.state),0),()=>{i(),o--,o||(n&&n.then(t=>{t()}),t.removeEventListener("ready",a))}}},t[e]},Pt=t=>t.sendMessagePromise({type:"get_states"});function kt(t,e){if(void 0===t)return null;const{domain:i,service:s}=e.data;return{[i]:Object.assign({},t[i],{[s]:{description:"",fields:{}}})}}function Mt(t,e){if(void 0===t)return null;const{domain:i,service:s}=e.data,n=t[i];if(!n||!(s in n))return null;const o={};return Object.keys(n).forEach(t=>{t!==s&&(o[t]=n[t])}),{[i]:o}}const Nt=t=>t.sendMessagePromise({type:"get_services"}),Tt=(t,e)=>Promise.all([t.subscribeEvents(e.action(kt),"service_registered"),t.subscribeEvents(e.action(Mt),"service_removed")]).then(t=>()=>t.forEach(t=>t()));async function Ot(t){const e=await Pt(t),i={};for(let t=0;tt.subscribeEvents(t=>function(t,e){const i=t.state;if(void 0===i)return;const{entity_id:s,new_state:n}=e.data;if(n)t.setState({[n.entity_id]:n});else{const e=Object.assign({},i);delete e[s],t.setState(e,!0)}}(e,t),"state_changed"),Et=(t,e)=>(t=>Ct(t,"_ent",Ot,Vt))(t).subscribe(e);var Dt={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"},At={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 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"},zt={common:Dt,settings:At},Ut={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"},jt={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:"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"},Ht={common:Ut,settings:jt},Yt={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"},Rt={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"},qt={common:Yt,settings:Rt};const Lt={en:Object.freeze({__proto__:null,common:Dt,settings:At,default:zt}),de:Object.freeze({__proto__:null,common:Ut,settings:jt,default:Ht}),se:Object.freeze({__proto__:null,common:Yt,settings:Rt,default:qt})};function Ft(t,e="",i=""){const s=t.split(".")[0],n=t.split(".")[1],o=(localStorage.getItem("selectedLanguage")||navigator.language.split("-")[0]||"en").replace(/['"]+/g,"").replace("-","_");let r;try{r=Lt[o][s][n]}catch(t){r=Lt.en[s][n]}return void 0===r&&(r=Lt.en[s][n]),""!==e&&""!==i&&(r=r.replace(e,i)),r}const Wt={general:{icon:"tune",name:Ft("settings.general"),secondary:Ft("settings.general_description"),show:!0},appearance:{icon:"palette",name:Ft("settings.appearance"),secondary:Ft("settings.appearance_description"),show:!1},advanced:{icon:"pencil",name:Ft("settings.advanced"),secondary:Ft("settings.advanced_description"),show:!1}},It=["Default","featured","discover-weekly"],Bt=["List","Grid"];let Gt=class extends it{constructor(){super(...arguments),this.accounts=[],this.hidden_cast_devices=[],this.chromecast_devices=[]}async connectedCallback(){super.connectedCallback();const t=await this.hass.callWS({type:"spotcast/accounts"});this.accounts=t;const e=await this.hass.callWS({type:"spotcast/castdevices"});this.chromecast_devices=e.map(t=>t.friendly_name),this.requestUpdate()}setConfig(t){this._config=t}get _name(){return this._config&&this._config.name||""}get _account(){return this._config?this._config.account||"default":""}get _spotify_entity(){if(this._config){const t=this.getMediaPlayerEntities().filter(t=>t.entity_id.includes("spotify"));return this._config.spotify_entity||(t.length>0?t[0].entity_id:"")}return""}get _country_code(){return this._config&&this._config.country_code||""}get _limit(){return this._config&&this._config.limit||10}get _playlist_type(){return this._config?this._config.playlist_type||"Default":""}get _always_play_random_song(){return this._config&&this._config.always_play_random_song||!1}get _height(){return this._config&&this._config.height||""}get _display_style(){return this._config&&this._config.display_style||"List"}get _grid_covers_per_row(){return this._config&&this._config.grid_covers_per_row||5}get _grid_center_covers(){return this._config&&this._config.grid_center_covers||!1}get _hidden_cast_devices(){return this._config&&this._config.hidden_cast_devices||[]}get _hide_warning(){return this._config&&this._config.hide_warning||!1}get _show_warning(){return this._config&&this._config.show_warning||!1}get _show_error(){return this._config&&this._config.show_error||!1}get _default_device(){return this._config&&this._config.default_device||""}getMediaPlayerEntities(){return Object.keys(this.hass.states).map(t=>this.hass.states[t]).filter(t=>t.entity_id.match("media_player[.]"))}renderGeneral(){const t=this.getMediaPlayerEntities().map(t=>t.entity_id);return z`
t.name==e);if(i.length>0)return this.playUriOnConnectDevice(i[0].id,t);{const i=this.chromecast_devices.filter(t=>t.friendly_name==e);if(i.length>0)return this.playUriOnCastDevice(i[0].friendly_name,t);console.error("Could not find default_device:"+e)}}console.error("No active device")}}transferPlaybackToCastDevice(t){this.parent.hass.callService("spotcast","start",{device_name:t,force_playback:!0,account:this.parent.config.account})}transferPlaybackToConnectDevice(t){this.parent.hass.callService("spotcast","start",{spotify_device_id:t,force_playback:!0,account:this.parent.config.account})}playUriOnCastDevice(t,e){const i=Object.assign(Object.assign({},this.getPlaybackOptions(e)),{device_name:t});this.parent.hass.callService("spotcast","start",i)}playUriOnConnectDevice(t,e){const i=Object.assign(Object.assign({},this.getPlaybackOptions(e)),{spotify_device_id:t});this.parent.hass.callService("spotcast","start",i)}async updateState(){if((new Date).getTime()-this.last_state_update_time{this.unsubscribe_entitites=Dt(this.hass.connection,t=>this.entitiesUpdated(t))},1e3)}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribe_entitites&&this.unsubscribe_entitites()}entitiesUpdated(t){let e=!1;for(const i in t)i.startsWith("media_player")&&((i.startsWith("media_player.spotify_")||i==this.config.spotify_entity)&&(this.spotify_installed=!0,this.spotify_state=t[i]),e=!0);e&&!document.hidden&&(this.fetch_time_out&&clearTimeout(this.fetch_time_out),this.fetch_time_out=setTimeout(()=>{this.spotcast_connector.updateState().then(()=>{this.requestUpdate()})},500))}getSpotifyEntityState(){return this.spotify_state?this.spotify_state.state:""}setConfig(t){let e="";if(t.limit&&"number"!=typeof t.limit&&(e="limit"),t.playlist_type&&!It.includes(t.playlist_type)&&(e="playlist_type"),t.country_code&&"string"!=typeof t.country_code&&(e="country_code"),t.height&&"number"!=typeof t.height&&(e="height"),t.display_style&&!Bt.includes(t.display_style)&&(e="display_style"),t.darkmode&&"boolean"!=typeof t.darkmode&&(e="darkmode"),t.show_error||""!=e)throw new Error(Ft("common.invalid_configuration")+": "+e);t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this.config=Object.assign({},t)}spotifyDeviceSelected(t){if(this.spotcast_connector.getCurrentPlayer())return this.spotcast_connector.transferPlaybackToConnectDevice(t.id);const e=this.spotcast_connector.playlists[0];console.log("spotifyDeviceSelected playing first playlist"),this.spotcast_connector.playUriOnConnectDevice(t.id,e.uri)}chromecastDeviceSelected(t){if(this.spotcast_connector.getCurrentPlayer())return this.spotcast_connector.transferPlaybackToCastDevice(t.friendly_name);const e=this.spotcast_connector.playlists[0];console.log("chromecastDeviceSelected playing first playlist"),this.spotcast_connector.playUriOnCastDevice(t.friendly_name,e.uri)}onShuffleSelect(){var t,e;"playing"==(null===(t=this.spotify_state)||void 0===t?void 0:t.state)&&this.hass.callService("media_player","shuffle_set",{entity_id:this.spotify_state.entity_id,shuffle:!(null===(e=this.spotcast_connector.player)||void 0===e?void 0:e.shuffle_state)})}handlePlayPauseEvent(t,e){t.stopPropagation(),this.spotify_state&&this.hass.callService("media_player",e,{entity_id:this.spotify_state.entity_id})}onPauseSelect(t){this.handlePlayPauseEvent(t,"media_pause")}onResumeSelect(t){this.handlePlayPauseEvent(t,"media_play")}render(){var t,e,i,s;let n=z``;var o;this.spotcast_installed||this.hass.connection&&void 0!==(o=this.hass.connection,Ct(o,"_srv",Nt,Tt)).state.spotcast&&(this.spotcast_installed=!0),this.config.show_warning&&(n=this.showWarning(Ft("common.show_warning"))),this.spotcast_installed||(n=this.showWarning(Ft("common.show_missing_spotcast"))),this.spotify_installed||(n=this.showWarning(Ft("common.show_missing_spotify")));let r=z`
Loading...
`;!this.spotcast_connector.is_loading()&&this.spotcast_installed?this.spotcast_connector.fetchPlaylists().then(()=>{this.requestUpdate()}):r="grid"==(null===(t=this.config.display_style)||void 0===t?void 0:t.toLowerCase())?this.generateGridView():this.generateListView();const a=this.spotcast_connector.getCurrentPlayer(),c=null!==(e=null==a?void 0:a.name)&&void 0!==e?e:Ft("common.choose_player");return z` + `}};t([J({type:Object})],Gt.prototype,"hass",void 0),t([Z()],Gt.prototype,"_config",void 0),t([Z()],Gt.prototype,"_toggle",void 0),Gt=t([B("spotify-card-editor")],Gt);class Jt{constructor(t){this.playlists=[],this.devices=[],this.chromecast_devices=[],this.state_ttl=4e3,this.last_state_update_time=0,this.loading=!1,this.parent=t}is_loading(){return setTimeout(this.set_loading_off,100),this.loading}set_loading_off(){this.loading=!1}is_loaded(){return void 0!==this.playlists.length}getPlaybackOptions(t){return{uri:t,force_playback:"playing"==this.parent.getSpotifyEntityState(),random_song:this.parent.config.always_play_random_song||!1,account:this.parent.config.account}}playUri(t){const e=this.getCurrentPlayer();if(e)this.playUriOnConnectDevice(e.id,t);else{const e=this.parent.config.default_device;if(e){const i=this.devices.filter(t=>t.name==e);if(i.length>0)return this.playUriOnConnectDevice(i[0].id,t);{const i=this.chromecast_devices.filter(t=>t.friendly_name==e);if(i.length>0)return this.playUriOnCastDevice(i[0].friendly_name,t);console.error("Could not find default_device:"+e)}}console.error("No active device")}}transferPlaybackToCastDevice(t){this.parent.hass.callService("spotcast","start",{device_name:t,force_playback:!0,account:this.parent.config.account})}transferPlaybackToConnectDevice(t){this.parent.hass.callService("spotcast","start",{spotify_device_id:t,force_playback:!0,account:this.parent.config.account})}playUriOnCastDevice(t,e){const i=Object.assign(Object.assign({},this.getPlaybackOptions(e)),{device_name:t});this.parent.hass.callService("spotcast","start",i)}playUriOnConnectDevice(t,e){const i=Object.assign(Object.assign({},this.getPlaybackOptions(e)),{spotify_device_id:t});this.parent.hass.callService("spotcast","start",i)}async updateState(){if((new Date).getTime()-this.last_state_update_timethis.entitiesUpdated(t))}connectedCallback(){super.connectedCallback(),this.spotcast_connector=new Jt(this),this.hass.connection?this.doSubscribeEntities():setTimeout(()=>this.doSubscribeEntities(),1e3)}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribe_entitites&&this.unsubscribe_entitites()}entitiesUpdated(t){let e=!1;for(const i in t)i.startsWith("media_player")&&((i.startsWith("media_player.spotify_")||i==this.config.spotify_entity)&&(this.spotify_installed=!0,this.spotify_state=t[i]),e=!0);e&&!document.hidden&&(this.fetch_time_out&&clearTimeout(this.fetch_time_out),this.fetch_time_out=setTimeout(()=>{this.spotcast_connector.updateState().then(()=>{this.requestUpdate()})},500))}getSpotifyEntityState(){return this.spotify_state?this.spotify_state.state:""}setConfig(t){let e="";if(t.limit&&"number"!=typeof t.limit&&(e="limit"),t.playlist_type&&!It.includes(t.playlist_type)&&(e="playlist_type"),t.country_code&&"string"!=typeof t.country_code&&(e="country_code"),t.height&&"number"!=typeof t.height&&(e="height"),t.display_style&&!Bt.includes(t.display_style)&&(e="display_style"),t.darkmode&&"boolean"!=typeof t.darkmode&&(e="darkmode"),t.show_error||""!=e)throw new Error(Ft("common.invalid_configuration")+": "+e);t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this.config=Object.assign({},t)}spotifyDeviceSelected(t){if(this.spotcast_connector.getCurrentPlayer())return this.spotcast_connector.transferPlaybackToConnectDevice(t.id);const e=this.spotcast_connector.playlists[0];console.log("spotifyDeviceSelected playing first playlist"),this.spotcast_connector.playUriOnConnectDevice(t.id,e.uri)}chromecastDeviceSelected(t){if(this.spotcast_connector.getCurrentPlayer())return this.spotcast_connector.transferPlaybackToCastDevice(t.friendly_name);const e=this.spotcast_connector.playlists[0];console.log("chromecastDeviceSelected playing first playlist"),this.spotcast_connector.playUriOnCastDevice(t.friendly_name,e.uri)}onShuffleSelect(){var t,e;"playing"==(null===(t=this.spotify_state)||void 0===t?void 0:t.state)&&this.hass.callService("media_player","shuffle_set",{entity_id:this.spotify_state.entity_id,shuffle:!(null===(e=this.spotcast_connector.player)||void 0===e?void 0:e.shuffle_state)})}handlePlayPauseEvent(t,e){t.stopPropagation(),this.spotify_state&&this.hass.callService("media_player",e,{entity_id:this.spotify_state.entity_id})}onPauseSelect(t){this.handlePlayPauseEvent(t,"media_pause")}onResumeSelect(t){this.handlePlayPauseEvent(t,"media_play")}render(){var t,e,i,s;let n=z``;var o;this.spotcast_installed||this.hass.connection&&void 0!==(o=this.hass.connection,Ct(o,"_srv",Nt,Tt)).state.spotcast&&(this.spotcast_installed=!0),this.config.show_warning&&(n=this.showWarning(Ft("common.show_warning"))),this.spotcast_installed||(n=this.showWarning(Ft("common.show_missing_spotcast"))),this.spotify_installed||(n=this.showWarning(Ft("common.show_missing_spotify")));let r=z`
Loading...
`;!this.spotcast_connector.is_loading()&&this.spotcast_installed?this.spotcast_connector.fetchPlaylists().then(()=>{this.requestUpdate()}):r="grid"==(null===(t=this.config.display_style)||void 0===t?void 0:t.toLowerCase())?this.generateGridView():this.generateListView();const a=this.spotcast_connector.getCurrentPlayer(),c=null!==(e=null==a?void 0:a.name)&&void 0!==e?e:Ft("common.choose_player");return z` ${this.config.hide_warning?"":n}