You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlexMeetsHomeAssistant/dist/plex-meets-homeassistant.js

668 lines
201 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,i=(function(e,i){(function(){var n,s="Expected a function",r="__lodash_hash_undefined__",a="__lodash_placeholder__",o=16,l=32,h=64,c=128,u=256,d=1/0,p=9007199254740991,f=NaN,y=4294967295,m=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",l],["partialRight",h],["rearg",u]],g="[object Arguments]",v="[object Array]",x="[object Boolean]",E="[object Date]",b="[object Error]",w="[object Function]",S="[object GeneratorFunction]",_="[object Map]",C="[object Number]",T="[object Object]",k="[object Promise]",z="[object RegExp]",L="[object Set]",$="[object String]",P="[object Symbol]",M="[object WeakMap]",N="[object ArrayBuffer]",I="[object DataView]",A="[object Float32Array]",R="[object Float64Array]",B="[object Int8Array]",H="[object Int16Array]",D="[object Int32Array]",q="[object Uint8Array]",U="[object Uint8ClampedArray]",O="[object Uint16Array]",W="[object Uint32Array]",j=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,F=/(__e\(.*?\)|\b__t\)) \+\n'';/g,X=/&(?:amp|lt|gt|quot|#39);/g,Y=/[&<>"']/g,K=RegExp(X.source),G=RegExp(Y.source),Z=/<%-([\s\S]+?)%>/g,J=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,et=/^\w*$/,it=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nt=/[\\^$.*+?()[\]{}|]/g,st=RegExp(nt.source),rt=/^\s+/,at=/\s/,ot=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,lt=/\{\n\/\* \[wrapped with (.+)\] \*/,ht=/,? & /,ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ut=/[()=,{}\[\]\/\s]/,dt=/\\(\\)?/g,pt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ft=/\w*$/,yt=/^[-+]0x[0-9a-f]+$/i,mt=/^0b[01]+$/i,gt=/^\[object .+?Constructor\]$/,vt=/^0o[0-7]+$/i,xt=/^(?:0|[1-9]\d*)$/,Et=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,bt=/($^)/,wt=/['\n\r\u2028\u2029\\]/g,St="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",_t="\\u2700-\\u27bf",Ct="a-z\\xdf-\\xf6\\xf8-\\xff",Tt="A-Z\\xc0-\\xd6\\xd8-\\xde",kt="\\ufe0e\\ufe0f",zt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Lt="[']",$t="[\\ud800-\\udfff]",Pt="["+zt+"]",Mt="["+St+"]",Nt="\\d+",It="[\\u2700-\\u27bf]",At="["+Ct+"]",Rt="[^\\ud800-\\udfff"+zt+Nt+_t+Ct+Tt+"]",Bt="\\ud83c[\\udffb-\\udfff]",Ht="[^\\ud800-\\udfff]",Dt="(?:\\ud83c[\\udde6-\\uddff]){2}",qt="[\\ud800-\\udbff][\\udc00-\\udfff]",Ut="["+Tt+"]",Ot="(?:"+At+"|"+Rt+")",Wt="(?:"+Ut+"|"+Rt+")",jt="(?:['](?:d|ll|m|re|s|t|ve))?",Vt="(?:['](?:D|LL|M|RE|S|T|VE))?",Ft="(?:"+Mt+"|"+Bt+")?",Xt="[\\ufe0e\\ufe0f]?",Yt=Xt+Ft+"(?:\\u200d(?:"+[Ht,Dt,qt].join("|")+")"+Xt+Ft+")*",Kt="(?:"+[It,Dt,qt].join("|")+")"+Yt,Gt="(?:"+[Ht+Mt+"?",Mt,Dt,qt,$t].join("|")+")",Zt=RegExp(Lt,"g"),Jt=RegExp(Mt,"g"),Qt=RegExp(Bt+"(?="+Bt+")|"+Gt+Yt,"g"),te=RegExp([Ut+"?"+At+"+"+jt+"(?="+[Pt,Ut,"$"].join("|")+")",Wt+"+"+Vt+"(?="+[Pt,Ut+Ot,"$"].join("|")+")",Ut+"?"+Ot+"+"+jt,Ut+"+"+Vt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Nt,Kt].join("|"),"g"),ee=RegExp("[\\u200d\\ud800-\\udfff"+St+kt+"]"),ie=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ne=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],se=-1,re={};re[A]=re[R]=re[B]=re[H]=re[D]=re[q]=re[U]=re[O]=re[W]=!0,re[g]=re[v]=re[N]=re[x]=re[I]=re[E]=re[b]=re[w]=re[_]=re[C]=re[T]=re[z]=re[L]=re[$]=re[M]=!1;var ae={};ae[g]=ae[v]=ae[N]=ae[I]=ae[x]=ae[E]=ae[A]=ae[R]=ae[B]=ae[H]=ae[D]=ae[_]=ae[C]=ae[T]=ae[z]=ae[L]=ae[$]=ae[P]=ae[q]=ae[U]=ae[O]=ae[W]=!0,ae[b]=ae[w]=ae[M]=!1;var oe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},le=parseFloat,he=parseInt,ce="object"==typeof t&&t&&t.Object===Object&&t,ue="object"==typeof self&&self&&self.Object===Object&&self,de=ce||ue||Function("return this")(),pe=i&&!i.nodeType&&i,fe=pe&&e&&!e.nodeType&&e,ye=fe&&fe.exports===pe,me=ye&&ce.process,ge=function(){try{var t=fe&&fe.require&&fe.require("util").types;return t||me&&me.binding&&me.binding("util")}catch(t){}}(),ve=ge&&ge.isArrayBuffer,xe=ge&&ge.isDate,Ee=ge&&ge.isMap,be=ge&&ge.isRegExp,we=ge&&ge.isSet,Se=ge&&ge.isTypedArray;function _e(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}function Ce(t,e,i,n){for(var s=-1,r=null==t?0:t.length;++s<r;){var a=t[s];e(n,a,i(a),t)}return n}function Te(t,e){for(var i=-1,n=null==t?0:t.length;++i<n&&!1!==e(t[i],i,t););return t}function ke(t,e){for(var i=null==t?0:t.length;i--&&!1!==e(t[i],i,t););return t}function ze(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(!e(t[i],i,t))return!1;return!0}function Le(t,e){for(var i=-1,n=null==t?0:t.length,s=0,r=[];++i<n;){var a=t[i];e(a,i,t)&&(r[s++]=a)}return r}function $e(t,e){return!(null==t||!t.length)&&qe(t,e,0)>-1}function Pe(t,e,i){for(var n=-1,s=null==t?0:t.length;++n<s;)if(i(e,t[n]))return!0;return!1}function Me(t,e){for(var i=-1,n=null==t?0:t.length,s=Array(n);++i<n;)s[i]=e(t[i],i,t);return s}function Ne(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t}function Ie(t,e,i,n){var s=-1,r=null==t?0:t.length;for(n&&r&&(i=t[++s]);++s<r;)i=e(i,t[s],s,t);return i}function Ae(t,e,i,n){var s=null==t?0:t.length;for(n&&s&&(i=t[--s]);s--;)i=e(i,t[s],s,t);return i}function Re(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1}var Be=je("length");function He(t,e,i){var n;return i(t,(function(t,i,s){if(e(t,i,s))return n=i,!1})),n}function De(t,e,i,n){for(var s=t.length,r=i+(n?1:-1);n?r--:++r<s;)if(e(t[r],r,t))return r;return-1}function qe(t,e,i){return e==e?function(t,e,i){for(var n=i-1,s=t.length;++n<s;)if(t[n]===e)return n;return-1}(t,e,i):De(t,Oe,i)}function Ue(t,e,i,n){for(var s=i-1,r=t.length;++s<r;)if(n(t[s],e))return s;return-1}function Oe(t){return t!=t}function We(t,e){var i=null==t?0:t.length;return i?Xe(t,e)/i:f}function je(t){return function(e){return null==e?n:e[t]}}function Ve(t){return function(e){return null==t?n:t[e]}}function Fe(t,e,i,n,s){return s(t,(function(t,s,r){i=n?(n=!1,t):e(i,t,s,r)})),i}function Xe(t,e){for(var i,s=-1,r=t.length;++s<r;){var a=e(t[s]);a!==n&&(i=i===n?a:i+a)}return i}function Ye(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n}function Ke(t){return t?t.slice(0,pi(t)+1).replace(rt,""):t}function Ge(t){return function(e){return t(e)}}function Ze(t,e){return Me(e,(function(e){return t[e]}))}function Je(t,e){return t.has(e)}function Qe(t,e){for(var i=-1,n=t.length;++i<n&&qe(e,t[i],0)>-1;);return i}function ti(t,e){for(var i=t.length;i--&&qe(e,t[i],0)>-1;);return i}function ei(t,e){for(var i=t.length,n=0;i--;)t[i]===e&&++n;return n}var ii=Ve({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),ni=Ve({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function si(t){return"\\"+oe[t]}function ri(t){return ee.test(t)}function ai(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i}function oi(t,e){return function(i){return t(e(i))}}function li(t,e){for(var i=-1,n=t.length,s=0,r=[];++i<n;){var o=t[i];o!==e&&o!==a||(t[i]=a,r[s++]=i)}return r}function hi(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i}function ci(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=[t,t]})),i}function ui(t){return ri(t)?function(t){for(var e=Qt.lastIndex=0;Qt.test(t);)++e;return e}(t):Be(t)}function di(t){return ri(t)?function(t){return t.match(Qt)||[]}(t):function(t){return t.split("")}(t)}function pi(t){for(var e=t.length;e--&&at.test(t.charAt(e)););return e}var fi=Ve({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),yi=function t(e){var i,at=(e=null==e?de:yi.defaults(de.Object(),e,yi.pick(de,ne))).Array,St=e.Date,_t=e.Error,Ct=e.Function,Tt=e.Math,kt=e.Object,zt=e.RegExp,Lt=e.String,$t=e.TypeError,Pt=at.prototype,Mt=Ct.prototype,Nt=kt.prototype,It=e["__core-js_shared__"],At=Mt.toString,Rt=Nt.hasOwnProperty,Bt=0,Ht=(i=/[^.]+$/.exec(It&&It.keys&&It.keys.IE_PROTO||""))?"Symbol(src)_1."+i:"",Dt=Nt.toString,qt=At.call(kt),Ut=de._,Ot=zt("^"+At.call(Rt).replace(nt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Wt=ye?e.Buffer:n,jt=e.Symbol,Vt=e.Uint8Array,Ft=Wt?Wt.allocUnsafe:n,Xt=oi(kt.getPrototypeOf,kt),Yt=kt.create,Kt=Nt.propertyIsEnumerable,Gt=Pt.splice,Qt=jt?jt.isConcatSpreadable:n,ee=jt?jt.iterator:n,oe=jt?jt.toStringTag:n,ce=function(){try{var t=pr(kt,"defineProperty");return t({},"",{}),t}catch(t){}}(),ue=e.clearTimeout!==de.clearTimeout&&e.clearTimeout,pe=St&&St.now!==de.Date.now&&St.now,fe=e.setTimeout!==de.setTimeout&&e.setTimeout,me=Tt.ceil,ge=Tt.floor,Be=kt.getOwnPropertySymbols,Ve=Wt?Wt.isBuffer:n,mi=e.isFinite,gi=Pt.join,vi=oi(kt.keys,kt),xi=Tt.max,Ei=Tt.min,bi=St.now,wi=e.parseInt,Si=Tt.random,_i=Pt.reverse,Ci=pr(e,"DataView"),Ti=pr(e,"Map"),ki=pr(e,"Promise"),zi=pr(e,"Set"),Li=pr(e,"WeakMap"),$i=pr(kt,"create"),Pi=Li&&new Li,Mi={},Ni=qr(Ci),Ii=qr(Ti),Ai=qr(ki),Ri=qr(zi),Bi=qr(Li),Hi=jt?jt.prototype:n,Di=Hi?Hi.valueOf:n,qi=Hi?Hi.toString:n;function Ui(t){if(no(t)&&!Fa(t)&&!(t instanceof Vi)){if(t instanceof ji)return t;if(Rt.call(t,"__wrapped__"))return Ur(t)}return new ji(t)}var Oi=function(){function t(){}return function(e){if(!io(e))return{};if(Yt)return Yt(e);t.prototype=e;var i=new t;return t.prototype=n,i}}();function Wi(){}function ji(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function Vi(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=y,this.__views__=[]}function Fi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Xi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Yi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}function Ki(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Yi;++e<i;)this.add(t[e])}function Gi(t){var e=this.__data__=new Xi(t);this.size=e.size}function Zi(t,e){var i=Fa(t),n=!i&&Va(t),s=!i&&!n&&Ga(t),r=!i&&!n&&!s&&uo(t),a=i||n||s||r,o=a?Ye(t.length,Lt):[],l=o.length;for(var h in t)!e&&!Rt.call(t,h)||a&&("length"==h||s&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Er(h,l))||o.push(h);return o}function Ji(t){var e=t.length;return e?t[Gn(0,e-1)]:n}function Qi(t,e){return Br(Ps(t),hn(e,0,t.length))}function tn(t){return Br(Ps(t))}function en(t,e,i){(i!==n&&!Oa(t[e],i)||i===n&&!(e in t))&&on(t,e,i)}function nn(t,e,i){var s=t[e];Rt.call(t,e)&&Oa(s,i)&&(i!==n||e in t)||on(t,e,i)}function sn(t,e){for(var i=t.length;i--;)if(Oa(t[i][0],e))return i;return-1}function rn(t,e,i,n){return fn(t,(function(t,s,r){e(n,t,i(t),r)})),n}function an(t,e){return t&&Ms(e,Io(e),t)}function on(t,e,i){"__proto__"==e&&ce?ce(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function ln(t,e){for(var i=-1,s=e.length,r=at(s),a=null==t;++i<s;)r[i]=a?n:Lo(t,e[i]);return r}function hn(t,e,i){return t==t&&(i!==n&&(t=t<=i?t:i),e!==n&&(t=t>=e?t:e)),t}function cn(t,e,i,s,r,a){var o,l=1&e,h=2&e,c=4&e;if(i&&(o=r?i(t,s,r,a):i(t)),o!==n)return o;if(!io(t))return t;var u=Fa(t);if(u){if(o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Rt.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!l)return Ps(t,o)}else{var d=mr(t),p=d==w||d==S;if(Ga(t))return Cs(t,l);if(d==T||d==g||p&&!r){if(o=h||p?{}:vr(t),!l)return h?function(t,e){return Ms(t,yr(t),e)}(t,function(t,e){return t&&Ms(e,Ao(e),t)}(o,t)):function(t,e){return Ms(t,fr(t),e)}(t,an(o,t))}else{if(!ae[d])return r?t:{};o=function(t,e,i){var n,s=t.constructor;switch(e){case N:return Ts(t);case x:case E:return new s(+t);case I:return function(t,e){var i=e?Ts(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case A:case R:case B:case H:case D:case q:case U:case O:case W:return ks(t,i);case _:return new s;case C:case $:return new s(t);case z:return function(t){var e=new t.constructor(t.source,ft.exec(t));return e.lastIndex=t.lastIndex,e}(t);case L:return new s;case P:return n=t,Di?kt(Di.call(n)):{}}}(t,d,l)}}a||(a=new Gi);var f=a.get(t);if(f)return f;a.set(t,o),lo(t)?t.forEach((function(n){o.add(cn(n,e,i,n,t,a))})):so(t)&&t.forEach((function(n,s){o.set(s,cn(n,e,i,s,t,a))}));var y=u?n:(c?h?ar:rr:h?Ao:Io)(t);return Te(y||t,(function(n,s){y&&(n=t[s=n]),nn(o,s,cn(n,e,i,s,t,a))})),o}function un(t,e,i){var s=i.length;if(null==t)return!s;for(t=kt(t);s--;){var r=i[s],a=e[r],o=t[r];if(o===n&&!(r in t)||!a(o))return!1}return!0}function dn(t,e,i){if("function"!=typeof t)throw new $t(s);return Nr((function(){t.apply(n,i)}),e)}function pn(t,e,i,n){var s=-1,r=$e,a=!0,o=t.length,l=[],h=e.length;if(!o)return l;i&&(e=Me(e,Ge(i))),n?(r=Pe,a=!1):e.length>=200&&(r=Je,a=!1,e=new Ki(e));t:for(;++s<o;){var c=t[s],u=null==i?c:i(c);if(c=n||0!==c?c:0,a&&u==u){for(var d=h;d--;)if(e[d]===u)continue t;l.push(c)}else r(e,u,n)||l.push(c)}return l}Ui.templateSettings={escape:Z,evaluate:J,interpolate:Q,variable:"",imports:{_:Ui}},Ui.prototype=Wi.prototype,Ui.prototype.constructor=Ui,ji.prototype=Oi(Wi.prototype),ji.prototype.constructor=ji,Vi.prototype=Oi(Wi.prototype),Vi.prototype.constructor=Vi,Fi.prototype.clear=function(){this.__data__=$i?$i(null):{},this.size=0},Fi.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Fi.prototype.get=function(t){var e=this.__data__;if($i){var i=e[t];return i===r?n:i}return Rt.call(e,t)?e[t]:n},Fi.prototype.has=function(t){var e=this.__data__;return $i?e[t]!==n:Rt.call(e,t)},Fi.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=$i&&e===n?r:e,this},Xi.prototype.clear=function(){this.__data__=[],this.size=0},Xi.prototype.delete=function(t){var e=this.__data__,i=sn(e,t);return!(i<0||(i==e.length-1?e.pop():Gt.call(e,i,1),--this.size,0))},Xi.prototype.get=function(t){var e=this.__data__,i=sn(e,t);return i<0?n:e[i][1]},Xi.prototype.has=function(t){return sn(this.__data__,t)>-1},Xi.prototype.set=function(t,e){var i=this.__data__,n=sn(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Yi.prototype.clear=function(){this.size=0,this.__data__={hash:new Fi,map:new(Ti||Xi),string:new Fi}},Yi.prototype.delete=function(t){var e=ur(this,t).delete(t);return this.size-=e?1:0,e},Yi.prototype.get=function(t){return ur(this,t).get(t)},Yi.prototype.has=function(t){return ur(this,t).has(t)},Yi.prototype.set=function(t,e){var i=ur(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this},Ki.prototype.add=Ki.prototype.push=function(t){return this.__data__.set(t,r),this},Ki.prototype.has=function(t){return this.__data__.has(t)},Gi.prototype.clear=function(){this.__data__=new Xi,this.size=0},Gi.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},Gi.prototype.get=function(t){return this.__data__.get(t)},Gi.prototype.has=function(t){return this.__data__.has(t)},Gi.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Xi){var n=i.__data__;if(!Ti||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Yi(n)}return i.set(t,e),this.size=i.size,this};var fn=As(wn),yn=As(Sn,!0);function mn(t,e){var i=!0;return fn(t,(function(t,n,s){return i=!!e(t,n,s)})),i}function gn(t,e,i){for(var s=-1,r=t.length;++s<r;){var a=t[s],o=e(a);if(null!=o&&(l===n?o==o&&!co(o):i(o,l)))var l=o,h=a}return h}function vn(t,e){var i=[];return fn(t,(function(t,n,s){e(t,n,s)&&i.push(t)})),i}function xn(t,e,i,n,s){var r=-1,a=t.length;for(i||(i=xr),s||(s=[]);++r<a;){var o=t[r];e>0&&i(o)?e>1?xn(o,e-1,i,n,s):Ne(s,o):n||(s[s.length]=o)}return s}var En=Rs(),bn=Rs(!0);function wn(t,e){return t&&En(t,e,Io)}function Sn(t,e){return t&&bn(t,e,Io)}function _n(t,e){return Le(e,(function(e){return Qa(t[e])}))}function Cn(t,e){for(var i=0,s=(e=bs(e,t)).length;null!=t&&i<s;)t=t[Dr(e[i++])];return i&&i==s?t:n}function Tn(t,e,i){var n=e(t);return Fa(t)?n:Ne(n,i(t))}function kn(t){return null==t?t===n?"[object Undefined]":"[object Null]":oe&&oe in kt(t)?function(t){var e=Rt.call(t,oe),i=t[oe];try{t[oe]=n;var s=!0}catch(t){}var r=Dt.call(t);return s&&(e?t[oe]=i:delete t[oe]),r}(t):function(t){return Dt.call(t)}(t)}function zn(t,e){return t>e}function Ln(t,e){return null!=t&&Rt.call(t,e)}function $n(t,e){return null!=t&&e in kt(t)}function Pn(t,e,i){for(var s=i?Pe:$e,r=t[0].length,a=t.length,o=a,l=at(a),h=1/0,c=[];o--;){var u=t[o];o&&e&&(u=Me(u,Ge(e))),h=Ei(u.length,h),l[o]=!i&&(e||r>=120&&u.length>=120)?new Ki(o&&u):n}u=t[0];var d=-1,p=l[0];t:for(;++d<r&&c.length<h;){var f=u[d],y=e?e(f):f;if(f=i||0!==f?f:0,!(p?Je(p,y):s(c,y,i))){for(o=a;--o;){var m=l[o];if(!(m?Je(m,y):s(t[o],y,i)))continue t}p&&p.push(y),c.push(f)}}return c}function Mn(t,e,i){var s=null==(t=Lr(t,e=bs(e,t)))?t:t[Dr(Jr(e))];return null==s?n:_e(s,t,i)}function Nn(t){return no(t)&&kn(t)==g}function In(t,e,i,s,r){return t===e||(null==t||null==e||!no(t)&&!no(e)?t!=t&&e!=e:function(t,e,i,s,r,a){var o=Fa(t),l=Fa(e),h=o?v:mr(t),c=l?v:mr(e),u=(h=h==g?T:h)==T,d=(c=c==g?T:c)==T,p=h==c;if(p&&Ga(t)){if(!Ga(e))return!1;o=!0,u=!1}if(p&&!u)return a||(a=new Gi),o||uo(t)?nr(t,e,i,s,r,a):function(t,e,i,n,s,r,a){switch(i){case I:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case N:return!(t.byteLength!=e.byteLength||!r(new Vt(t),new Vt(e)));case x:case E:case C:return Oa(+t,+e);case b:return t.name==e.name&&t.message==e.message;case z:case $:return t==e+"";case _:var o=ai;case L:var l=1&n;if(o||(o=hi),t.size!=e.size&&!l)return!1;var h=a.get(t);if(h)return h==e;n|=2,a.set(t,e);var c=nr(o(t),o(e),n,s,r,a);return a.delete(t),c;case P:if(Di)return Di.call(t)==Di.call(e)}return!1}(t,e,h,i,s,r,a);if(!(1&i)){var f=u&&Rt.call(t,"__wrapped__"),y=d&&Rt.call(e,"__wrapped__");if(f||y){var m=f?t.value():t,w=y?e.value():e;return a||(a=new Gi),r(m,w,i,s,a)}}return!!p&&(a||(a=new Gi),function(t,e,i,s,r,a){var o=1&i,l=rr(t),h=l.length,c=rr(e).length;if(h!=c&&!o)return!1;for(var u=h;u--;){var d=l[u];if(!(o?d in e:Rt.call(e,d)))return!1}var p=a.get(t),f=a.get(e);if(p&&f)return p==e&&f==t;var y=!0;a.set(t,e),a.set(e,t);for(var m=o;++u<h;){var g=t[d=l[u]],v=e[d];if(s)var x=o?s(v,g,d,e,t,a):s(g,v,d,t,e,a);if(!(x===n?g===v||r(g,v,i,s,a):x)){y=!1;break}m||(m="constructor"==d)}if(y&&!m){var E=t.constructor,b=e.constructor;E==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof E&&E instanceof E&&"function"==typeof b&&b instanceof b||(y=!1)}return a.delete(t),a.delete(e),y}(t,e,i,s,r,a))}(t,e,i,s,In,r))}function An(t,e,i,s){var r=i.length,a=r,o=!s;if(null==t)return!a;for(t=kt(t);r--;){var l=i[r];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++r<a;){var h=(l=i[r])[0],c=t[h],u=l[1];if(o&&l[2]){if(c===n&&!(h in t))return!1}else{var d=new Gi;if(s)var p=s(c,u,h,t,e,d);if(!(p===n?In(u,c,3,s,d):p))return!1}}return!0}function Rn(t){return!(!io(t)||(e=t,Ht&&Ht in e))&&(Qa(t)?Ot:gt).test(qr(t));var e}function Bn(t){return"function"==typeof t?t:null==t?al:"object"==typeof t?Fa(t)?Wn(t[0],t[1]):On(t):yl(t)}function Hn(t){if(!Cr(t))return vi(t);var e=[];for(var i in kt(t))Rt.call(t,i)&&"constructor"!=i&&e.push(i);return e}function Dn(t){if(!io(t))return function(t){var e=[];if(null!=t)for(var i in kt(t))e.push(i);return e}(t);var e=Cr(t),i=[];for(var n in t)("constructor"!=n||!e&&Rt.call(t,n))&&i.push(n);return i}function qn(t,e){return t<e}function Un(t,e){var i=-1,n=Ya(t)?at(t.length):[];return fn(t,(function(t,s,r){n[++i]=e(t,s,r)})),n}function On(t){var e=dr(t);return 1==e.length&&e[0][2]?kr(e[0][0],e[0][1]):function(i){return i===t||An(i,t,e)}}function Wn(t,e){return wr(t)&&Tr(e)?kr(Dr(t),e):function(i){var s=Lo(i,t);return s===n&&s===e?$o(i,t):In(e,s,3)}}function jn(t,e,i,s,r){t!==e&&En(e,(function(a,o){if(r||(r=new Gi),io(a))!function(t,e,i,s,r,a,o){var l=Pr(t,i),h=Pr(e,i),c=o.get(h);if(c)en(t,i,c);else{var u=a?a(l,h,i+"",t,e,o):n,d=u===n;if(d){var p=Fa(h),f=!p&&Ga(h),y=!p&&!f&&uo(h);u=h,p||f||y?Fa(l)?u=l:Ka(l)?u=Ps(l):f?(d=!1,u=Cs(h,!0)):y?(d=!1,u=ks(h,!0)):u=[]:ao(h)||Va(h)?(u=l,Va(l)?u=Eo(l):io(l)&&!Qa(l)||(u=vr(h))):d=!1}d&&(o.set(h,u),r(u,h,s,a,o),o.delete(h)),en(t,i,u)}}(t,e,o,i,jn,s,r);else{var l=s?s(Pr(t,o),a,o+"",t,e,r):n;l===n&&(l=a),en(t,o,l)}}),Ao)}function Vn(t,e){var i=t.length;if(i)return Er(e+=e<0?i:0,i)?t[e]:n}function Fn(t,e,i){e=e.length?Me(e,(function(t){return Fa(t)?function(e){return Cn(e,1===t.length?t[0]:t)}:t})):[al];var n=-1;return e=Me(e,Ge(cr())),function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t}(Un(t,(function(t,i,s){return{criteria:Me(e,(function(e){return e(t)})),index:++n,value:t}})),(function(t,e){return function(t,e,i){for(var n=-1,s=t.criteria,r=e.criteria,a=s.length,o=i.length;++n<a;){var l=zs(s[n],r[n]);if(l)return n>=o?l:l*("desc"==i[n]?-1:1)}return t.index-e.index}(t,e,i)}))}function Xn(t,e,i){for(var n=-1,s=e.length,r={};++n<s;){var a=e[n],o=Cn(t,a);i(o,a)&&es(r,bs(a,t),o)}return r}function Yn(t,e,i,n){var s=n?Ue:qe,r=-1,a=e.length,o=t;for(t===e&&(e=Ps(e)),i&&(o=Me(t,Ge(i)));++r<a;)for(var l=0,h=e[r],c=i?i(h):h;(l=s(o,c,l,n))>-1;)o!==t&&Gt.call(o,l,1),Gt.call(t,l,1);return t}function Kn(t,e){for(var i=t?e.length:0,n=i-1;i--;){var s=e[i];if(i==n||s!==r){var r=s;Er(s)?Gt.call(t,s,1):ps(t,s)}}return t}function Gn(t,e){return t+ge(Si()*(e-t+1))}function Zn(t,e){var i="";if(!t||e<1||e>p)return i;do{e%2&&(i+=t),(e=ge(e/2))&&(t+=t)}while(e);return i}function Jn(t,e){return Ir(zr(t,e,al),t+"")}function Qn(t){return Ji(Wo(t))}function ts(t,e){var i=Wo(t);return Br(i,hn(e,0,i.length))}function es(t,e,i,s){if(!io(t))return t;for(var r=-1,a=(e=bs(e,t)).length,o=a-1,l=t;null!=l&&++r<a;){var h=Dr(e[r]),c=i;if("__proto__"===h||"constructor"===h||"prototype"===h)return t;if(r!=o){var u=l[h];(c=s?s(u,h,l):n)===n&&(c=io(u)?u:Er(e[r+1])?[]:{})}nn(l,h,c),l=l[h]}return t}var is=Pi?function(t,e){return Pi.set(t,e),t}:al,ns=ce?function(t,e){return ce(t,"toString",{configurable:!0,enumerable:!1,value:nl(e),writable:!0})}:al;function ss(t){return Br(Wo(t))}function rs(t,e,i){var n=-1,s=t.length;e<0&&(e=-e>s?0:s+e),(i=i>s?s:i)<0&&(i+=s),s=e>i?0:i-e>>>0,e>>>=0;for(var r=at(s);++n<s;)r[n]=t[n+e];return r}function as(t,e){var i;return fn(t,(function(t,n,s){return!(i=e(t,n,s))})),!!i}function os(t,e,i){var n=0,s=null==t?n:t.length;if("number"==typeof e&&e==e&&s<=2147483647){for(;n<s;){var r=n+s>>>1,a=t[r];null!==a&&!co(a)&&(i?a<=e:a<e)?n=r+1:s=r}return s}return ls(t,e,al,i)}function ls(t,e,i,s){var r=0,a=null==t?0:t.length;if(0===a)return 0;for(var o=(e=i(e))!=e,l=null===e,h=co(e),c=e===n;r<a;){var u=ge((r+a)/2),d=i(t[u]),p=d!==n,f=null===d,y=d==d,m=co(d);if(o)var g=s||y;else g=c?y&&(s||p):l?y&&p&&(s||!f):h?y&&p&&!f&&(s||!m):!f&&!m&&(s?d<=e:d<e);g?r=u+1:a=u}return Ei(a,4294967294)}function hs(t,e){for(var i=-1,n=t.length,s=0,r=[];++i<n;){var a=t[i],o=e?e(a):a;if(!i||!Oa(o,l)){var l=o;r[s++]=0===a?0:a}}return r}function cs(t){return"number"==typeof t?t:co(t)?f:+t}function us(t){if("string"==typeof t)return t;if(Fa(t))return Me(t,us)+"";if(co(t))return qi?qi.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ds(t,e,i){var n=-1,s=$e,r=t.length,a=!0,o=[],l=o;if(i)a=!1,s=Pe;else if(r>=200){var h=e?null:Zs(t);if(h)return hi(h);a=!1,s=Je,l=new Ki}else l=e?[]:o;t:for(;++n<r;){var c=t[n],u=e?e(c):c;if(c=i||0!==c?c:0,a&&u==u){for(var d=l.length;d--;)if(l[d]===u)continue t;e&&l.push(u),o.push(c)}else s(l,u,i)||(l!==o&&l.push(u),o.push(c))}return o}function ps(t,e){return null==(t=Lr(t,e=bs(e,t)))||delete t[Dr(Jr(e))]}function fs(t,e,i,n){return es(t,e,i(Cn(t,e)),n)}function ys(t,e,i,n){for(var s=t.length,r=n?s:-1;(n?r--:++r<s)&&e(t[r],r,t););return i?rs(t,n?0:r,n?r+1:s):rs(t,n?r+1:0,n?s:r)}function ms(t,e){var i=t;return i instanceof Vi&&(i=i.value()),Ie(e,(function(t,e){return e.func.apply(e.thisArg,Ne([t],e.args))}),i)}function gs(t,e,i){var n=t.length;if(n<2)return n?ds(t[0]):[];for(var s=-1,r=at(n);++s<n;)for(var a=t[s],o=-1;++o<n;)o!=s&&(r[s]=pn(r[s]||a,t[o],e,i));return ds(xn(r,1),e,i)}function vs(t,e,i){for(var s=-1,r=t.length,a=e.length,o={};++s<r;){var l=s<a?e[s]:n;i(o,t[s],l)}return o}function xs(t){return Ka(t)?t:[]}function Es(t){return"function"==typeof t?t:al}function bs(t,e){return Fa(t)?t:wr(t,e)?[t]:Hr(bo(t))}var ws=Jn;function Ss(t,e,i){var s=t.length;return i=i===n?s:i,!e&&i>=s?t:rs(t,e,i)}var _s=ue||function(t){return de.clearTimeout(t)};function Cs(t,e){if(e)return t.slice();var i=t.length,n=Ft?Ft(i):new t.constructor(i);return t.copy(n),n}function Ts(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}function ks(t,e){var i=e?Ts(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}function zs(t,e){if(t!==e){var i=t!==n,s=null===t,r=t==t,a=co(t),o=e!==n,l=null===e,h=e==e,c=co(e);if(!l&&!c&&!a&&t>e||a&&o&&h&&!l&&!c||s&&o&&h||!i&&h||!r)return 1;if(!s&&!a&&!c&&t<e||c&&i&&r&&!s&&!a||l&&i&&r||!o&&r||!h)return-1}return 0}function Ls(t,e,i,n){for(var s=-1,r=t.length,a=i.length,o=-1,l=e.length,h=xi(r-a,0),c=at(l+h),u=!n;++o<l;)c[o]=e[o];for(;++s<a;)(u||s<r)&&(c[i[s]]=t[s]);for(;h--;)c[o++]=t[s++];return c}function $s(t,e,i,n){for(var s=-1,r=t.length,a=-1,o=i.length,l=-1,h=e.length,c=xi(r-o,0),u=at(c+h),d=!n;++s<c;)u[s]=t[s];for(var p=s;++l<h;)u[p+l]=e[l];for(;++a<o;)(d||s<r)&&(u[p+i[a]]=t[s++]);return u}function Ps(t,e){var i=-1,n=t.length;for(e||(e=at(n));++i<n;)e[i]=t[i];return e}function Ms(t,e,i,s){var r=!i;i||(i={});for(var a=-1,o=e.length;++a<o;){var l=e[a],h=s?s(i[l],t[l],l,i,t):n;h===n&&(h=t[l]),r?on(i,l,h):nn(i,l,h)}return i}function Ns(t,e){return function(i,n){var s=Fa(i)?Ce:rn,r=e?e():{};return s(i,t,cr(n,2),r)}}function Is(t){return Jn((function(e,i){var s=-1,r=i.length,a=r>1?i[r-1]:n,o=r>2?i[2]:n;for(a=t.length>3&&"function"==typeof a?(r--,a):n,o&&br(i[0],i[1],o)&&(a=r<3?n:a,r=1),e=kt(e);++s<r;){var l=i[s];l&&t(e,l,s,a)}return e}))}function As(t,e){return function(i,n){if(null==i)return i;if(!Ya(i))return t(i,n);for(var s=i.length,r=e?s:-1,a=kt(i);(e?r--:++r<s)&&!1!==n(a[r],r,a););return i}}function Rs(t){return function(e,i,n){for(var s=-1,r=kt(e),a=n(e),o=a.length;o--;){var l=a[t?o:++s];if(!1===i(r[l],l,r))break}return e}}function Bs(t){return function(e){var i=ri(e=bo(e))?di(e):n,s=i?i[0]:e.charAt(0),r=i?Ss(i,1).join(""):e.slice(1);return s[t]()+r}}function Hs(t){return function(e){return Ie(tl(Fo(e).replace(Zt,"")),t,"")}}function Ds(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var i=Oi(t.prototype),n=t.apply(i,e);return io(n)?n:i}}function qs(t){return function(e,i,s){var r=kt(e);if(!Ya(e)){var a=cr(i,3);e=Io(e),i=function(t){return a(r[t],t,r)}}var o=t(e,i,s);return o>-1?r[a?e[o]:o]:n}}function Us(t){return sr((function(e){var i=e.length,r=i,a=ji.prototype.thru;for(t&&e.reverse();r--;){var o=e[r];if("function"!=typeof o)throw new $t(s);if(a&&!l&&"wrapper"==lr(o))var l=new ji([],!0)}for(r=l?r:i;++r<i;){var h=lr(o=e[r]),c="wrapper"==h?or(o):n;l=c&&Sr(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[lr(c[0])].apply(l,c[3]):1==o.length&&Sr(o)?l[h]():l.thru(o)}return function(){var t=arguments,n=t[0];if(l&&1==t.length&&Fa(n))return l.plant(n).value();for(var s=0,r=i?e[s].apply(this,t):n;++s<i;)r=e[s].call(this,r);return r}}))}function Os(t,e,i,s,r,a,o,l,h,u){var d=e&c,p=1&e,f=2&e,y=24&e,m=512&e,g=f?n:Ds(t);return function n(){for(var c=arguments.length,v=at(c),x=c;x--;)v[x]=arguments[x];if(y)var E=hr(n),b=ei(v,E);if(s&&(v=Ls(v,s,r,y)),a&&(v=$s(v,a,o,y)),c-=b,y&&c<u){var w=li(v,E);return Ks(t,e,Os,n.placeholder,i,v,w,l,h,u-c)}var S=p?i:this,_=f?S[t]:t;return c=v.length,l?v=$r(v,l):m&&c>1&&v.reverse(),d&&h<c&&(v.length=h),this&&this!==de&&this instanceof n&&(_=g||Ds(_)),_.apply(S,v)}}function Ws(t,e){return function(i,n){return function(t,e,i,n){return wn(t,(function(t,s,r){e(n,i(t),s,r)})),n}(i,t,e(n),{})}}function js(t,e){return function(i,s){var r;if(i===n&&s===n)return e;if(i!==n&&(r=i),s!==n){if(r===n)return s;"string"==typeof i||"string"==typeof s?(i=us(i),s=us(s)):(i=cs(i),s=cs(s)),r=t(i,s)}return r}}function Vs(t){return sr((function(e){return e=Me(e,Ge(cr())),Jn((function(i){var n=this;return t(e,(function(t){return _e(t,n,i)}))}))}))}function Fs(t,e){var i=(e=e===n?" ":us(e)).length;if(i<2)return i?Zn(e,t):e;var s=Zn(e,me(t/ui(e)));return ri(e)?Ss(di(s),0,t).join(""):s.slice(0,t)}function Xs(t){return function(e,i,s){return s&&"number"!=typeof s&&br(e,i,s)&&(i=s=n),e=mo(e),i===n?(i=e,e=0):i=mo(i),function(t,e,i,n){for(var s=-1,r=xi(me((e-t)/(i||1)),0),a=at(r);r--;)a[n?r:++s]=t,t+=i;return a}(e,i,s=s===n?e<i?1:-1:mo(s),t)}}function Ys(t){return function(e,i){return"string"==typeof e&&"string"==typeof i||(e=xo(e),i=xo(i)),t(e,i)}}function Ks(t,e,i,s,r,a,o,c,u,d){var p=8&e;e|=p?l:h,4&(e&=~(p?h:l))||(e&=-4);var f=[t,e,r,p?a:n,p?o:n,p?n:a,p?n:o,c,u,d],y=i.apply(n,f);return Sr(t)&&Mr(y,f),y.placeholder=s,Ar(y,t,e)}function Gs(t){var e=Tt[t];return function(t,i){if(t=xo(t),(i=null==i?0:Ei(go(i),292))&&mi(t)){var n=(bo(t)+"e").split("e");return+((n=(bo(e(n[0]+"e"+(+n[1]+i)))+"e").split("e"))[0]+"e"+(+n[1]-i))}return e(t)}}var Zs=zi&&1/hi(new zi([,-0]))[1]==d?function(t){return new zi(t)}:ul;function Js(t){return function(e){var i=mr(e);return i==_?ai(e):i==L?ci(e):function(t,e){return Me(e,(function(e){return[e,t[e]]}))}(e,t(e))}}function Qs(t,e,i,r,d,p,f,y){var m=2&e;if(!m&&"function"!=typeof t)throw new $t(s);var g=r?r.length:0;if(g||(e&=-97,r=d=n),f=f===n?f:xi(go(f),0),y=y===n?y:go(y),g-=d?d.length:0,e&h){var v=r,x=d;r=d=n}var E=m?n:or(t),b=[t,e,i,r,d,v,x,p,f,y];if(E&&function(t,e){var i=t[1],n=e[1],s=i|n,r=s<131,o=n==c&&8==i||n==c&&i==u&&t[7].length<=e[8]||384==n&&e[7].length<=e[8]&&8==i;if(!r&&!o)return t;1&n&&(t[2]=e[2],s|=1&i?0:4);var l=e[3];if(l){var h=t[3];t[3]=h?Ls(h,l,e[4]):l,t[4]=h?li(t[3],a):e[4]}(l=e[5])&&(h=t[5],t[5]=h?$s(h,l,e[6]):l,t[6]=h?li(t[5],a):e[6]),(l=e[7])&&(t[7]=l),n&c&&(t[8]=null==t[8]?e[8]:Ei(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=s}(b,E),t=b[0],e=b[1],i=b[2],r=b[3],d=b[4],!(y=b[9]=b[9]===n?m?0:t.length:xi(b[9]-g,0))&&24&e&&(e&=-25),e&&1!=e)w=8==e||e==o?function(t,e,i){var s=Ds(t);return function r(){for(var a=arguments.length,o=at(a),l=a,h=hr(r);l--;)o[l]=arguments[l];var c=a<3&&o[0]!==h&&o[a-1]!==h?[]:li(o,h);return(a-=c.length)<i?Ks(t,e,Os,r.placeholder,n,o,c,n,n,i-a):_e(this&&this!==de&&this instanceof r?s:t,this,o)}}(t,e,y):e!=l&&33!=e||d.length?Os.apply(n,b):function(t,e,i,n){var s=1&e,r=Ds(t);return function e(){for(var a=-1,o=arguments.length,l=-1,h=n.length,c=at(h+o),u=this&&this!==de&&this instanceof e?r:t;++l<h;)c[l]=n[l];for(;o--;)c[l++]=arguments[++a];return _e(u,s?i:this,c)}}(t,e,i,r);else var w=function(t,e,i){var n=1&e,s=Ds(t);return function e(){return(this&&this!==de&&this instanceof e?s:t).apply(n?i:this,arguments)}}(t,e,i);return Ar((E?is:Mr)(w,b),t,e)}function tr(t,e,i,s){return t===n||Oa(t,Nt[i])&&!Rt.call(s,i)?e:t}function er(t,e,i,s,r,a){return io(t)&&io(e)&&(a.set(e,t),jn(t,e,n,er,a),a.delete(e)),t}function ir(t){return ao(t)?n:t}function nr(t,e,i,s,r,a){var o=1&i,l=t.length,h=e.length;if(l!=h&&!(o&&h>l))return!1;var c=a.get(t),u=a.get(e);if(c&&u)return c==e&&u==t;var d=-1,p=!0,f=2&i?new Ki:n;for(a.set(t,e),a.set(e,t);++d<l;){var y=t[d],m=e[d];if(s)var g=o?s(m,y,d,e,t,a):s(y,m,d,t,e,a);if(g!==n){if(g)continue;p=!1;break}if(f){if(!Re(e,(function(t,e){if(!Je(f,e)&&(y===t||r(y,t,i,s,a)))return f.push(e)}))){p=!1;break}}else if(y!==m&&!r(y,m,i,s,a)){p=!1;break}}return a.delete(t),a.delete(e),p}function sr(t){return Ir(zr(t,n,Xr),t+"")}function rr(t){return Tn(t,Io,fr)}function ar(t){return Tn(t,Ao,yr)}var or=Pi?function(t){return Pi.get(t)}:ul;function lr(t){for(var e=t.name+"",i=Mi[e],n=Rt.call(Mi,e)?i.length:0;n--;){var s=i[n],r=s.func;if(null==r||r==t)return s.name}return e}function hr(t){return(Rt.call(Ui,"placeholder")?Ui:t).placeholder}function cr(){var t=Ui.iteratee||ol;return t=t===ol?Bn:t,arguments.length?t(arguments[0],arguments[1]):t}function ur(t,e){var i,n,s=t.__data__;return("string"==(n=typeof(i=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?s["string"==typeof e?"string":"hash"]:s.map}function dr(t){for(var e=Io(t),i=e.length;i--;){var n=e[i],s=t[n];e[i]=[n,s,Tr(s)]}return e}function pr(t,e){var i=function(t,e){return null==t?n:t[e]}(t,e);return Rn(i)?i:n}var fr=Be?function(t){return null==t?[]:(t=kt(t),Le(Be(t),(function(e){return Kt.call(t,e)})))}:vl,yr=Be?function(t){for(var e=[];t;)Ne(e,fr(t)),t=Xt(t);return e}:vl,mr=kn;function gr(t,e,i){for(var n=-1,s=(e=bs(e,t)).length,r=!1;++n<s;){var a=Dr(e[n]);if(!(r=null!=t&&i(t,a)))break;t=t[a]}return r||++n!=s?r:!!(s=null==t?0:t.length)&&eo(s)&&Er(a,s)&&(Fa(t)||Va(t))}function vr(t){return"function"!=typeof t.constructor||Cr(t)?{}:Oi(Xt(t))}function xr(t){return Fa(t)||Va(t)||!!(Qt&&t&&t[Qt])}function Er(t,e){var i=typeof t;return!!(e=null==e?p:e)&&("number"==i||"symbol"!=i&&xt.test(t))&&t>-1&&t%1==0&&t<e}function br(t,e,i){if(!io(i))return!1;var n=typeof e;return!!("number"==n?Ya(i)&&Er(e,i.length):"string"==n&&e in i)&&Oa(i[e],t)}function wr(t,e){if(Fa(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!co(t))||et.test(t)||!tt.test(t)||null!=e&&t in kt(e)}function Sr(t){var e=lr(t),i=Ui[e];if("function"!=typeof i||!(e in Vi.prototype))return!1;if(t===i)return!0;var n=or(i);return!!n&&t===n[0]}(Ci&&mr(new Ci(new ArrayBuffer(1)))!=I||Ti&&mr(new Ti)!=_||ki&&mr(ki.resolve())!=k||zi&&mr(new zi)!=L||Li&&mr(new Li)!=M)&&(mr=function(t){var e=kn(t),i=e==T?t.constructor:n,s=i?qr(i):"";if(s)switch(s){case Ni:return I;case Ii:return _;case Ai:return k;case Ri:return L;case Bi:return M}return e});var _r=It?Qa:xl;function Cr(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Nt)}function Tr(t){return t==t&&!io(t)}function kr(t,e){return function(i){return null!=i&&i[t]===e&&(e!==n||t in kt(i))}}function zr(t,e,i){return e=xi(e===n?t.length-1:e,0),function(){for(var n=arguments,s=-1,r=xi(n.length-e,0),a=at(r);++s<r;)a[s]=n[e+s];s=-1;for(var o=at(e+1);++s<e;)o[s]=n[s];return o[e]=i(a),_e(t,this,o)}}function Lr(t,e){return e.length<2?t:Cn(t,rs(e,0,-1))}function $r(t,e){for(var i=t.length,s=Ei(e.length,i),r=Ps(t);s--;){var a=e[s];t[s]=Er(a,i)?r[a]:n}return t}function Pr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Mr=Rr(is),Nr=fe||function(t,e){return de.setTimeout(t,e)},Ir=Rr(ns);function Ar(t,e,i){var n=e+"";return Ir(t,function(t,e){var i=e.length;if(!i)return t;var n=i-1;return e[n]=(i>1?"& ":"")+e[n],e=e.join(i>2?", ":" "),t.replace(ot,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Te(m,(function(i){var n="_."+i[0];e&i[1]&&!$e(t,n)&&t.push(n)})),t.sort()}(function(t){var e=t.match(lt);return e?e[1].split(ht):[]}(n),i)))}function Rr(t){var e=0,i=0;return function(){var s=bi(),r=16-(s-i);if(i=s,r>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(n,arguments)}}function Br(t,e){var i=-1,s=t.length,r=s-1;for(e=e===n?s:e;++i<e;){var a=Gn(i,r),o=t[a];t[a]=t[i],t[i]=o}return t.length=e,t}var Hr=function(t){var e=Ra(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(it,(function(t,i,n,s){e.push(n?s.replace(dt,"$1"):i||t)})),e}));function Dr(t){if("string"==typeof t||co(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function qr(t){if(null!=t){try{return At.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Ur(t){if(t instanceof Vi)return t.clone();var e=new ji(t.__wrapped__,t.__chain__);return e.__actions__=Ps(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var Or=Jn((function(t,e){return Ka(t)?pn(t,xn(e,1,Ka,!0)):[]})),Wr=Jn((function(t,e){var i=Jr(e);return Ka(i)&&(i=n),Ka(t)?pn(t,xn(e,1,Ka,!0),cr(i,2)):[]})),jr=Jn((function(t,e){var i=Jr(e);return Ka(i)&&(i=n),Ka(t)?pn(t,xn(e,1,Ka,!0),n,i):[]}));function Vr(t,e,i){var n=null==t?0:t.length;if(!n)return-1;var s=null==i?0:go(i);return s<0&&(s=xi(n+s,0)),De(t,cr(e,3),s)}function Fr(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var r=s-1;return i!==n&&(r=go(i),r=i<0?xi(s+r,0):Ei(r,s-1)),De(t,cr(e,3),r,!0)}function Xr(t){return null!=t&&t.length?xn(t,1):[]}function Yr(t){return t&&t.length?t[0]:n}var Kr=Jn((function(t){var e=Me(t,xs);return e.length&&e[0]===t[0]?Pn(e):[]})),Gr=Jn((function(t){var e=Jr(t),i=Me(t,xs);return e===Jr(i)?e=n:i.pop(),i.length&&i[0]===t[0]?Pn(i,cr(e,2)):[]})),Zr=Jn((function(t){var e=Jr(t),i=Me(t,xs);return(e="function"==typeof e?e:n)&&i.pop(),i.length&&i[0]===t[0]?Pn(i,n,e):[]}));function Jr(t){var e=null==t?0:t.length;return e?t[e-1]:n}var Qr=Jn(ta);function ta(t,e){return t&&t.length&&e&&e.length?Yn(t,e):t}var ea=sr((function(t,e){var i=null==t?0:t.length,n=ln(t,e);return Kn(t,Me(e,(function(t){return Er(t,i)?+t:t})).sort(zs)),n}));function ia(t){return null==t?t:_i.call(t)}var na=Jn((function(t){return ds(xn(t,1,Ka,!0))})),sa=Jn((function(t){var e=Jr(t);return Ka(e)&&(e=n),ds(xn(t,1,Ka,!0),cr(e,2))})),ra=Jn((function(t){var e=Jr(t);return e="function"==typeof e?e:n,ds(xn(t,1,Ka,!0),n,e)}));function aa(t){if(!t||!t.length)return[];var e=0;return t=Le(t,(function(t){if(Ka(t))return e=xi(t.length,e),!0})),Ye(e,(function(e){return Me(t,je(e))}))}function oa(t,e){if(!t||!t.length)return[];var i=aa(t);return null==e?i:Me(i,(function(t){return _e(e,n,t)}))}var la=Jn((function(t,e){return Ka(t)?pn(t,e):[]})),ha=Jn((function(t){return gs(Le(t,Ka))})),ca=Jn((function(t){var e=Jr(t);return Ka(e)&&(e=n),gs(Le(t,Ka),cr(e,2))})),ua=Jn((function(t){var e=Jr(t);return e="function"==typeof e?e:n,gs(Le(t,Ka),n,e)})),da=Jn(aa),pa=Jn((function(t){var e=t.length,i=e>1?t[e-1]:n;return i="function"==typeof i?(t.pop(),i):n,oa(t,i)}));function fa(t){var e=Ui(t);return e.__chain__=!0,e}function ya(t,e){return e(t)}var ma=sr((function(t){var e=t.length,i=e?t[0]:0,s=this.__wrapped__,r=function(e){return ln(e,t)};return!(e>1||this.__actions__.length)&&s instanceof Vi&&Er(i)?((s=s.slice(i,+i+(e?1:0))).__actions__.push({func:ya,args:[r],thisArg:n}),new ji(s,this.__chain__).thru((function(t){return e&&!t.length&&t.push(n),t}))):this.thru(r)})),ga=Ns((function(t,e,i){Rt.call(t,i)?++t[i]:on(t,i,1)})),va=qs(Vr),xa=qs(Fr);function Ea(t,e){return(Fa(t)?Te:fn)(t,cr(e,3))}function ba(t,e){return(Fa(t)?ke:yn)(t,cr(e,3))}var wa=Ns((function(t,e,i){Rt.call(t,i)?t[i].push(e):on(t,i,[e])})),Sa=Jn((function(t,e,i){var n=-1,s="function"==typeof e,r=Ya(t)?at(t.length):[];return fn(t,(function(t){r[++n]=s?_e(e,t,i):Mn(t,e,i)})),r})),_a=Ns((function(t,e,i){on(t,i,e)}));function Ca(t,e){return(Fa(t)?Me:Un)(t,cr(e,3))}var Ta=Ns((function(t,e,i){t[i?0:1].push(e)}),(function(){return[[],[]]})),ka=Jn((function(t,e){if(null==t)return[];var i=e.length;return i>1&&br(t,e[0],e[1])?e=[]:i>2&&br(e[0],e[1],e[2])&&(e=[e[0]]),Fn(t,xn(e,1),[])})),za=pe||function(){return de.Date.now()};function La(t,e,i){return e=i?n:e,e=t&&null==e?t.length:e,Qs(t,c,n,n,n,n,e)}function $a(t,e){var i;if("function"!=typeof e)throw new $t(s);return t=go(t),function(){return--t>0&&(i=e.apply(this,arguments)),t<=1&&(e=n),i}}var Pa=Jn((function(t,e,i){var n=1;if(i.length){var s=li(i,hr(Pa));n|=l}return Qs(t,n,e,i,s)})),Ma=Jn((function(t,e,i){var n=3;if(i.length){var s=li(i,hr(Ma));n|=l}return Qs(e,n,t,i,s)}));function Na(t,e,i){var r,a,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof t)throw new $t(s);function y(e){var i=r,s=a;return r=a=n,u=e,l=t.apply(s,i)}function m(t){return u=t,h=Nr(v,e),d?y(t):l}function g(t){var i=t-c;return c===n||i>=e||i<0||p&&t-u>=o}function v(){var t=za();if(g(t))return x(t);h=Nr(v,function(t){var i=e-(t-c);return p?Ei(i,o-(t-u)):i}(t))}function x(t){return h=n,f&&r?y(t):(r=a=n,l)}function E(){var t=za(),i=g(t);if(r=arguments,a=this,c=t,i){if(h===n)return m(c);if(p)return _s(h),h=Nr(v,e),y(c)}return h===n&&(h=Nr(v,e)),l}return e=xo(e)||0,io(i)&&(d=!!i.leading,o=(p="maxWait"in i)?xi(xo(i.maxWait)||0,e):o,f="trailing"in i?!!i.trailing:f),E.cancel=function(){h!==n&&_s(h),u=0,r=c=a=h=n},E.flush=function(){return h===n?l:x(za())},E}var Ia=Jn((function(t,e){return dn(t,1,e)})),Aa=Jn((function(t,e,i){return dn(t,xo(e)||0,i)}));function Ra(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new $t(s);var i=function(){var n=arguments,s=e?e.apply(this,n):n[0],r=i.cache;if(r.has(s))return r.get(s);var a=t.apply(this,n);return i.cache=r.set(s,a)||r,a};return i.cache=new(Ra.Cache||Yi),i}function Ba(t){if("function"!=typeof t)throw new $t(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Ra.Cache=Yi;var Ha=ws((function(t,e){var i=(e=1==e.length&&Fa(e[0])?Me(e[0],Ge(cr())):Me(xn(e,1),Ge(cr()))).length;return Jn((function(n){for(var s=-1,r=Ei(n.length,i);++s<r;)n[s]=e[s].call(this,n[s]);return _e(t,this,n)}))})),Da=Jn((function(t,e){var i=li(e,hr(Da));return Qs(t,l,n,e,i)})),qa=Jn((function(t,e){var i=li(e,hr(qa));return Qs(t,h,n,e,i)})),Ua=sr((function(t,e){return Qs(t,u,n,n,n,e)}));function Oa(t,e){return t===e||t!=t&&e!=e}var Wa=Ys(zn),ja=Ys((function(t,e){return t>=e})),Va=Nn(function(){return arguments}())?Nn:function(t){return no(t)&&Rt.call(t,"callee")&&!Kt.call(t,"callee")},Fa=at.isArray,Xa=ve?Ge(ve):function(t){return no(t)&&kn(t)==N};function Ya(t){return null!=t&&eo(t.length)&&!Qa(t)}function Ka(t){return no(t)&&Ya(t)}var Ga=Ve||xl,Za=xe?Ge(xe):function(t){return no(t)&&kn(t)==E};function Ja(t){if(!no(t))return!1;var e=kn(t);return e==b||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!ao(t)}function Qa(t){if(!io(t))return!1;var e=kn(t);return e==w||e==S||"[object AsyncFunction]"==e||"[object Proxy]"==e}function to(t){return"number"==typeof t&&t==go(t)}function eo(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}function io(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function no(t){return null!=t&&"object"==typeof t}var so=Ee?Ge(Ee):function(t){return no(t)&&mr(t)==_};function ro(t){return"number"==typeof t||no(t)&&kn(t)==C}function ao(t){if(!no(t)||kn(t)!=T)return!1;var e=Xt(t);if(null===e)return!0;var i=Rt.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&At.call(i)==qt}var oo=be?Ge(be):function(t){return no(t)&&kn(t)==z},lo=we?Ge(we):function(t){return no(t)&&mr(t)==L};function ho(t){return"string"==typeof t||!Fa(t)&&no(t)&&kn(t)==$}function co(t){return"symbol"==typeof t||no(t)&&kn(t)==P}var uo=Se?Ge(Se):function(t){return no(t)&&eo(t.length)&&!!re[kn(t)]},po=Ys(qn),fo=Ys((function(t,e){return t<=e}));function yo(t){if(!t)return[];if(Ya(t))return ho(t)?di(t):Ps(t);if(ee&&t[ee])return function(t){for(var e,i=[];!(e=t.next()).done;)i.push(e.value);return i}(t[ee]());var e=mr(t);return(e==_?ai:e==L?hi:Wo)(t)}function mo(t){return t?(t=xo(t))===d||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function go(t){var e=mo(t),i=e%1;return e==e?i?e-i:e:0}function vo(t){return t?hn(go(t),0,y):0}function xo(t){if("number"==typeof t)return t;if(co(t))return f;if(io(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=io(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ke(t);var i=mt.test(t);return i||vt.test(t)?he(t.slice(2),i?2:8):yt.test(t)?f:+t}function Eo(t){return Ms(t,Ao(t))}function bo(t){return null==t?"":us(t)}var wo=Is((function(t,e){if(Cr(e)||Ya(e))Ms(e,Io(e),t);else for(var i in e)Rt.call(e,i)&&nn(t,i,e[i])})),So=Is((function(t,e){Ms(e,Ao(e),t)})),_o=Is((function(t,e,i,n){Ms(e,Ao(e),t,n)})),Co=Is((function(t,e,i,n){Ms(e,Io(e),t,n)})),To=sr(ln),ko=Jn((function(t,e){t=kt(t);var i=-1,s=e.length,r=s>2?e[2]:n;for(r&&br(e[0],e[1],r)&&(s=1);++i<s;)for(var a=e[i],o=Ao(a),l=-1,h=o.length;++l<h;){var c=o[l],u=t[c];(u===n||Oa(u,Nt[c])&&!Rt.call(t,c))&&(t[c]=a[c])}return t})),zo=Jn((function(t){return t.push(n,er),_e(Bo,n,t)}));function Lo(t,e,i){var s=null==t?n:Cn(t,e);return s===n?i:s}function $o(t,e){return null!=t&&gr(t,e,$n)}var Po=Ws((function(t,e,i){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),t[e]=i}),nl(al)),Mo=Ws((function(t,e,i){null!=e&&"function"!=typeof e.toString&&(e=Dt.call(e)),Rt.call(t,e)?t[e].push(i):t[e]=[i]}),cr),No=Jn(Mn);function Io(t){return Ya(t)?Zi(t):Hn(t)}function Ao(t){return Ya(t)?Zi(t,!0):Dn(t)}var Ro=Is((function(t,e,i){jn(t,e,i)})),Bo=Is((function(t,e,i,n){jn(t,e,i,n)})),Ho=sr((function(t,e){var i={};if(null==t)return i;var n=!1;e=Me(e,(function(e){return e=bs(e,t),n||(n=e.length>1),e})),Ms(t,ar(t),i),n&&(i=cn(i,7,ir));for(var s=e.length;s--;)ps(i,e[s]);return i})),Do=sr((function(t,e){return null==t?{}:function(t,e){return Xn(t,e,(function(e,i){return $o(t,i)}))}(t,e)}));function qo(t,e){if(null==t)return{};var i=Me(ar(t),(function(t){return[t]}));return e=cr(e),Xn(t,i,(function(t,i){return e(t,i[0])}))}var Uo=Js(Io),Oo=Js(Ao);function Wo(t){return null==t?[]:Ze(t,Io(t))}var jo=Hs((function(t,e,i){return e=e.toLowerCase(),t+(i?Vo(e):e)}));function Vo(t){return Qo(bo(t).toLowerCase())}function Fo(t){return(t=bo(t))&&t.replace(Et,ii).replace(Jt,"")}var Xo=Hs((function(t,e,i){return t+(i?"-":"")+e.toLowerCase()})),Yo=Hs((function(t,e,i){return t+(i?" ":"")+e.toLowerCase()})),Ko=Bs("toLowerCase"),Go=Hs((function(t,e,i){return t+(i?"_":"")+e.toLowerCase()})),Zo=Hs((function(t,e,i){return t+(i?" ":"")+Qo(e)})),Jo=Hs((function(t,e,i){return t+(i?" ":"")+e.toUpperCase()})),Qo=Bs("toUpperCase");function tl(t,e,i){return t=bo(t),(e=i?n:e)===n?function(t){return ie.test(t)}(t)?function(t){return t.match(te)||[]}(t):function(t){return t.match(ct)||[]}(t):t.match(e)||[]}var el=Jn((function(t,e){try{return _e(t,n,e)}catch(t){return Ja(t)?t:new _t(t)}})),il=sr((function(t,e){return Te(e,(function(e){e=Dr(e),on(t,e,Pa(t[e],t))})),t}));function nl(t){return function(){return t}}var sl=Us(),rl=Us(!0);function al(t){return t}function ol(t){return Bn("function"==typeof t?t:cn(t,1))}var ll=Jn((function(t,e){return function(i){return Mn(i,t,e)}})),hl=Jn((function(t,e){return function(i){return Mn(t,i,e)}}));function cl(t,e,i){var n=Io(e),s=_n(e,n);null!=i||io(e)&&(s.length||!n.length)||(i=e,e=t,t=this,s=_n(e,Io(e)));var r=!(io(i)&&"chain"in i&&!i.chain),a=Qa(t);return Te(s,(function(i){var n=e[i];t[i]=n,a&&(t.prototype[i]=function(){var e=this.__chain__;if(r||e){var i=t(this.__wrapped__),s=i.__actions__=Ps(this.__actions__);return s.push({func:n,args:arguments,thisArg:t}),i.__chain__=e,i}return n.apply(t,Ne([this.value()],arguments))})})),t}function ul(){}var dl=Vs(Me),pl=Vs(ze),fl=Vs(Re);function yl(t){return wr(t)?je(Dr(t)):function(t){return function(e){return Cn(e,t)}}(t)}var ml=Xs(),gl=Xs(!0);function vl(){return[]}function xl(){return!1}var El,bl=js((function(t,e){return t+e}),0),wl=Gs("ceil"),Sl=js((function(t,e){return t/e}),1),_l=Gs("floor"),Cl=js((function(t,e){return t*e}),1),Tl=Gs("round"),kl=js((function(t,e){return t-e}),0);return Ui.after=function(t,e){if("function"!=typeof e)throw new $t(s);return t=go(t),function(){if(--t<1)return e.apply(this,arguments)}},Ui.ary=La,Ui.assign=wo,Ui.assignIn=So,Ui.assignInWith=_o,Ui.assignWith=Co,Ui.at=To,Ui.before=$a,Ui.bind=Pa,Ui.bindAll=il,Ui.bindKey=Ma,Ui.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Fa(t)?t:[t]},Ui.chain=fa,Ui.chunk=function(t,e,i){e=(i?br(t,e,i):e===n)?1:xi(go(e),0);var s=null==t?0:t.length;if(!s||e<1)return[];for(var r=0,a=0,o=at(me(s/e));r<s;)o[a++]=rs(t,r,r+=e);return o},Ui.compact=function(t){for(var e=-1,i=null==t?0:t.length,n=0,s=[];++e<i;){var r=t[e];r&&(s[n++]=r)}return s},Ui.concat=function(){var t=arguments.length;if(!t)return[];for(var e=at(t-1),i=arguments[0],n=t;n--;)e[n-1]=arguments[n];return Ne(Fa(i)?Ps(i):[i],xn(e,1))},Ui.cond=function(t){var e=null==t?0:t.length,i=cr();return t=e?Me(t,(function(t){if("function"!=typeof t[1])throw new $t(s);return[i(t[0]),t[1]]})):[],Jn((function(i){for(var n=-1;++n<e;){var s=t[n];if(_e(s[0],this,i))return _e(s[1],this,i)}}))},Ui.conforms=function(t){return function(t){var e=Io(t);return function(i){return un(i,t,e)}}(cn(t,1))},Ui.constant=nl,Ui.countBy=ga,Ui.create=function(t,e){var i=Oi(t);return null==e?i:an(i,e)},Ui.curry=function t(e,i,s){var r=Qs(e,8,n,n,n,n,n,i=s?n:i);return r.placeholder=t.placeholder,r},Ui.curryRight=function t(e,i,s){var r=Qs(e,o,n,n,n,n,n,i=s?n:i);return r.placeholder=t.placeholder,r},Ui.debounce=Na,Ui.defaults=ko,Ui.defaultsDeep=zo,Ui.defer=Ia,Ui.delay=Aa,Ui.difference=Or,Ui.differenceBy=Wr,Ui.differenceWith=jr,Ui.drop=function(t,e,i){var s=null==t?0:t.length;return s?rs(t,(e=i||e===n?1:go(e))<0?0:e,s):[]},Ui.dropRight=function(t,e,i){var s=null==t?0:t.length;return s?rs(t,0,(e=s-(e=i||e===n?1:go(e)))<0?0:e):[]},Ui.dropRightWhile=function(t,e){return t&&t.length?ys(t,cr(e,3),!0,!0):[]},Ui.dropWhile=function(t,e){return t&&t.length?ys(t,cr(e,3),!0):[]},Ui.fill=function(t,e,i,s){var r=null==t?0:t.length;return r?(i&&"number"!=typeof i&&br(t,e,i)&&(i=0,s=r),function(t,e,i,s){var r=t.length;for((i=go(i))<0&&(i=-i>r?0:r+i),(s=s===n||s>r?r:go(s))<0&&(s+=r),s=i>s?0:vo(s);i<s;)t[i++]=e;return t}(t,e,i,s)):[]},Ui.filter=function(t,e){return(Fa(t)?Le:vn)(t,cr(e,3))},Ui.flatMap=function(t,e){return xn(Ca(t,e),1)},Ui.flatMapDeep=function(t,e){return xn(Ca(t,e),d)},Ui.flatMapDepth=function(t,e,i){return i=i===n?1:go(i),xn(Ca(t,e),i)},Ui.flatten=Xr,Ui.flattenDeep=function(t){return null!=t&&t.length?xn(t,d):[]},Ui.flattenDepth=function(t,e){return null!=t&&t.length?xn(t,e=e===n?1:go(e)):[]},Ui.flip=function(t){return Qs(t,512)},Ui.flow=sl,Ui.flowRight=rl,Ui.fromPairs=function(t){for(var e=-1,i=null==t?0:t.length,n={};++e<i;){var s=t[e];n[s[0]]=s[1]}return n},Ui.functions=function(t){return null==t?[]:_n(t,Io(t))},Ui.functionsIn=function(t){return null==t?[]:_n(t,Ao(t))},Ui.groupBy=wa,Ui.initial=function(t){return null!=t&&t.length?rs(t,0,-1):[]},Ui.intersection=Kr,Ui.intersectionBy=Gr,Ui.intersectionWith=Zr,Ui.invert=Po,Ui.invertBy=Mo,Ui.invokeMap=Sa,Ui.iteratee=ol,Ui.keyBy=_a,Ui.keys=Io,Ui.keysIn=Ao,Ui.map=Ca,Ui.mapKeys=function(t,e){var i={};return e=cr(e,3),wn(t,(function(t,n,s){on(i,e(t,n,s),t)})),i},Ui.mapValues=function(t,e){var i={};return e=cr(e,3),wn(t,(function(t,n,s){on(i,n,e(t,n,s))})),i},Ui.matches=function(t){return On(cn(t,1))},Ui.matchesProperty=function(t,e){return Wn(t,cn(e,1))},Ui.memoize=Ra,Ui.merge=Ro,Ui.mergeWith=Bo,Ui.method=ll,Ui.methodOf=hl,Ui.mixin=cl,Ui.negate=Ba,Ui.nthArg=function(t){return t=go(t),Jn((function(e){return Vn(e,t)}))},Ui.omit=Ho,Ui.omitBy=function(t,e){return qo(t,Ba(cr(e)))},Ui.once=function(t){return $a(2,t)},Ui.orderBy=function(t,e,i,s){return null==t?[]:(Fa(e)||(e=null==e?[]:[e]),Fa(i=s?n:i)||(i=null==i?[]:[i]),Fn(t,e,i))},Ui.over=dl,Ui.overArgs=Ha,Ui.overEvery=pl,Ui.overSome=fl,Ui.partial=Da,Ui.partialRight=qa,Ui.partition=Ta,Ui.pick=Do,Ui.pickBy=qo,Ui.property=yl,Ui.propertyOf=function(t){return function(e){return null==t?n:Cn(t,e)}},Ui.pull=Qr,Ui.pullAll=ta,Ui.pullAllBy=function(t,e,i){return t&&t.length&&e&&e.length?Yn(t,e,cr(i,2)):t},Ui.pullAllWith=function(t,e,i){return t&&t.length&&e&&e.length?Yn(t,e,n,i):t},Ui.pullAt=ea,Ui.range=ml,Ui.rangeRight=gl,Ui.rearg=Ua,Ui.reject=function(t,e){return(Fa(t)?Le:vn)(t,Ba(cr(e,3)))},Ui.remove=function(t,e){var i=[];if(!t||!t.length)return i;var n=-1,s=[],r=t.length;for(e=cr(e,3);++n<r;){var a=t[n];e(a,n,t)&&(i.push(a),s.push(n))}return Kn(t,s),i},Ui.rest=function(t,e){if("function"!=typeof t)throw new $t(s);return Jn(t,e=e===n?e:go(e))},Ui.reverse=ia,Ui.sampleSize=function(t,e,i){return e=(i?br(t,e,i):e===n)?1:go(e),(Fa(t)?Qi:ts)(t,e)},Ui.set=function(t,e,i){return null==t?t:es(t,e,i)},Ui.setWith=function(t,e,i,s){return s="function"==typeof s?s:n,null==t?t:es(t,e,i,s)},Ui.shuffle=function(t){return(Fa(t)?tn:ss)(t)},Ui.slice=function(t,e,i){var s=null==t?0:t.length;return s?(i&&"number"!=typeof i&&br(t,e,i)?(e=0,i=s):(e=null==e?0:go(e),i=i===n?s:go(i)),rs(t,e,i)):[]},Ui.sortBy=ka,Ui.sortedUniq=function(t){return t&&t.length?hs(t):[]},Ui.sortedUniqBy=function(t,e){return t&&t.length?hs(t,cr(e,2)):[]},Ui.split=function(t,e,i){return i&&"number"!=typeof i&&br(t,e,i)&&(e=i=n),(i=i===n?y:i>>>0)?(t=bo(t))&&("string"==typeof e||null!=e&&!oo(e))&&!(e=us(e))&&ri(t)?Ss(di(t),0,i):t.split(e,i):[]},Ui.spread=function(t,e){if("function"!=typeof t)throw new $t(s);return e=null==e?0:xi(go(e),0),Jn((function(i){var n=i[e],s=Ss(i,0,e);return n&&Ne(s,n),_e(t,this,s)}))},Ui.tail=function(t){var e=null==t?0:t.length;return e?rs(t,1,e):[]},Ui.take=function(t,e,i){return t&&t.length?rs(t,0,(e=i||e===n?1:go(e))<0?0:e):[]},Ui.takeRight=function(t,e,i){var s=null==t?0:t.length;return s?rs(t,(e=s-(e=i||e===n?1:go(e)))<0?0:e,s):[]},Ui.takeRightWhile=function(t,e){return t&&t.length?ys(t,cr(e,3),!1,!0):[]},Ui.takeWhile=function(t,e){return t&&t.length?ys(t,cr(e,3)):[]},Ui.tap=function(t,e){return e(t),t},Ui.throttle=function(t,e,i){var n=!0,r=!0;if("function"!=typeof t)throw new $t(s);return io(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),Na(t,e,{leading:n,maxWait:e,trailing:r})},Ui.thru=ya,Ui.toArray=yo,Ui.toPairs=Uo,Ui.toPairsIn=Oo,Ui.toPath=function(t){return Fa(t)?Me(t,Dr):co(t)?[t]:Ps(Hr(bo(t)))},Ui.toPlainObject=Eo,Ui.transform=function(t,e,i){var n=Fa(t),s=n||Ga(t)||uo(t);if(e=cr(e,4),null==i){var r=t&&t.constructor;i=s?n?new r:[]:io(t)&&Qa(r)?Oi(Xt(t)):{}}return(s?Te:wn)(t,(function(t,n,s){return e(i,t,n,s)})),i},Ui.unary=function(t){return La(t,1)},Ui.union=na,Ui.unionBy=sa,Ui.unionWith=ra,Ui.uniq=function(t){return t&&t.length?ds(t):[]},Ui.uniqBy=function(t,e){return t&&t.length?ds(t,cr(e,2)):[]},Ui.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?ds(t,n,e):[]},Ui.unset=function(t,e){return null==t||ps(t,e)},Ui.unzip=aa,Ui.unzipWith=oa,Ui.update=function(t,e,i){return null==t?t:fs(t,e,Es(i))},Ui.updateWith=function(t,e,i,s){return s="function"==typeof s?s:n,null==t?t:fs(t,e,Es(i),s)},Ui.values=Wo,Ui.valuesIn=function(t){return null==t?[]:Ze(t,Ao(t))},Ui.without=la,Ui.words=tl,Ui.wrap=function(t,e){return Da(Es(e),t)},Ui.xor=ha,Ui.xorBy=ca,Ui.xorWith=ua,Ui.zip=da,Ui.zipObject=function(t,e){return vs(t||[],e||[],nn)},Ui.zipObjectDeep=function(t,e){return vs(t||[],e||[],es)},Ui.zipWith=pa,Ui.entries=Uo,Ui.entriesIn=Oo,Ui.extend=So,Ui.extendWith=_o,cl(Ui,Ui),Ui.add=bl,Ui.attempt=el,Ui.camelCase=jo,Ui.capitalize=Vo,Ui.ceil=wl,Ui.clamp=function(t,e,i){return i===n&&(i=e,e=n),i!==n&&(i=(i=xo(i))==i?i:0),e!==n&&(e=(e=xo(e))==e?e:0),hn(xo(t),e,i)},Ui.clone=function(t){return cn(t,4)},Ui.cloneDeep=function(t){return cn(t,5)},Ui.cloneDeepWith=function(t,e){return cn(t,5,e="function"==typeof e?e:n)},Ui.cloneWith=function(t,e){return cn(t,4,e="function"==typeof e?e:n)},Ui.conformsTo=function(t,e){return null==e||un(t,e,Io(e))},Ui.deburr=Fo,Ui.defaultTo=function(t,e){return null==t||t!=t?e:t},Ui.divide=Sl,Ui.endsWith=function(t,e,i){t=bo(t),e=us(e);var s=t.length,r=i=i===n?s:hn(go(i),0,s);return(i-=e.length)>=0&&t.slice(i,r)==e},Ui.eq=Oa,Ui.escape=function(t){return(t=bo(t))&&G.test(t)?t.replace(Y,ni):t},Ui.escapeRegExp=function(t){return(t=bo(t))&&st.test(t)?t.replace(nt,"\\$&"):t},Ui.every=function(t,e,i){var s=Fa(t)?ze:mn;return i&&br(t,e,i)&&(e=n),s(t,cr(e,3))},Ui.find=va,Ui.findIndex=Vr,Ui.findKey=function(t,e){return He(t,cr(e,3),wn)},Ui.findLast=xa,Ui.findLastIndex=Fr,Ui.findLastKey=function(t,e){return He(t,cr(e,3),Sn)},Ui.floor=_l,Ui.forEach=Ea,Ui.forEachRight=ba,Ui.forIn=function(t,e){return null==t?t:En(t,cr(e,3),Ao)},Ui.forInRight=function(t,e){return null==t?t:bn(t,cr(e,3),Ao)},Ui.forOwn=function(t,e){return t&&wn(t,cr(e,3))},Ui.forOwnRight=function(t,e){return t&&Sn(t,cr(e,3))},Ui.get=Lo,Ui.gt=Wa,Ui.gte=ja,Ui.has=function(t,e){return null!=t&&gr(t,e,Ln)},Ui.hasIn=$o,Ui.head=Yr,Ui.identity=al,Ui.includes=function(t,e,i,n){t=Ya(t)?t:Wo(t),i=i&&!n?go(i):0;var s=t.length;return i<0&&(i=xi(s+i,0)),ho(t)?i<=s&&t.indexOf(e,i)>-1:!!s&&qe(t,e,i)>-1},Ui.indexOf=function(t,e,i){var n=null==t?0:t.length;if(!n)return-1;var s=null==i?0:go(i);return s<0&&(s=xi(n+s,0)),qe(t,e,s)},Ui.inRange=function(t,e,i){return e=mo(e),i===n?(i=e,e=0):i=mo(i),function(t,e,i){return t>=Ei(e,i)&&t<xi(e,i)}(t=xo(t),e,i)},Ui.invoke=No,Ui.isArguments=Va,Ui.isArray=Fa,Ui.isArrayBuffer=Xa,Ui.isArrayLike=Ya,Ui.isArrayLikeObject=Ka,Ui.isBoolean=function(t){return!0===t||!1===t||no(t)&&kn(t)==x},Ui.isBuffer=Ga,Ui.isDate=Za,Ui.isElement=function(t){return no(t)&&1===t.nodeType&&!ao(t)},Ui.isEmpty=function(t){if(null==t)return!0;if(Ya(t)&&(Fa(t)||"string"==typeof t||"function"==typeof t.splice||Ga(t)||uo(t)||Va(t)))return!t.length;var e=mr(t);if(e==_||e==L)return!t.size;if(Cr(t))return!Hn(t).length;for(var i in t)if(Rt.call(t,i))return!1;return!0},Ui.isEqual=function(t,e){return In(t,e)},Ui.isEqualWith=function(t,e,i){var s=(i="function"==typeof i?i:n)?i(t,e):n;return s===n?In(t,e,n,i):!!s},Ui.isError=Ja,Ui.isFinite=function(t){return"number"==typeof t&&mi(t)},Ui.isFunction=Qa,Ui.isInteger=to,Ui.isLength=eo,Ui.isMap=so,Ui.isMatch=function(t,e){return t===e||An(t,e,dr(e))},Ui.isMatchWith=function(t,e,i){return i="function"==typeof i?i:n,An(t,e,dr(e),i)},Ui.isNaN=function(t){return ro(t)&&t!=+t},Ui.isNative=function(t){if(_r(t))throw new _t("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Rn(t)},Ui.isNil=function(t){return null==t},Ui.isNull=function(t){return null===t},Ui.isNumber=ro,Ui.isObject=io,Ui.isObjectLike=no,Ui.isPlainObject=ao,Ui.isRegExp=oo,Ui.isSafeInteger=function(t){return to(t)&&t>=-9007199254740991&&t<=p},Ui.isSet=lo,Ui.isString=ho,Ui.isSymbol=co,Ui.isTypedArray=uo,Ui.isUndefined=function(t){return t===n},Ui.isWeakMap=function(t){return no(t)&&mr(t)==M},Ui.isWeakSet=function(t){return no(t)&&"[object WeakSet]"==kn(t)},Ui.join=function(t,e){return null==t?"":gi.call(t,e)},Ui.kebabCase=Xo,Ui.last=Jr,Ui.lastIndexOf=function(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var r=s;return i!==n&&(r=(r=go(i))<0?xi(s+r,0):Ei(r,s-1)),e==e?function(t,e,i){for(var n=i+1;n--;)if(t[n]===e)return n;return n}(t,e,r):De(t,Oe,r,!0)},Ui.lowerCase=Yo,Ui.lowerFirst=Ko,Ui.lt=po,Ui.lte=fo,Ui.max=function(t){return t&&t.length?gn(t,al,zn):n},Ui.maxBy=function(t,e){return t&&t.length?gn(t,cr(e,2),zn):n},Ui.mean=function(t){return We(t,al)},Ui.meanBy=function(t,e){return We(t,cr(e,2))},Ui.min=function(t){return t&&t.length?gn(t,al,qn):n},Ui.minBy=function(t,e){return t&&t.length?gn(t,cr(e,2),qn):n},Ui.stubArray=vl,Ui.stubFalse=xl,Ui.stubObject=function(){return{}},Ui.stubString=function(){return""},Ui.stubTrue=function(){return!0},Ui.multiply=Cl,Ui.nth=function(t,e){return t&&t.length?Vn(t,go(e)):n},Ui.noConflict=function(){return de._===this&&(de._=Ut),this},Ui.noop=ul,Ui.now=za,Ui.pad=function(t,e,i){t=bo(t);var n=(e=go(e))?ui(t):0;if(!e||n>=e)return t;var s=(e-n)/2;return Fs(ge(s),i)+t+Fs(me(s),i)},Ui.padEnd=function(t,e,i){t=bo(t);var n=(e=go(e))?ui(t):0;return e&&n<e?t+Fs(e-n,i):t},Ui.padStart=function(t,e,i){t=bo(t);var n=(e=go(e))?ui(t):0;return e&&n<e?Fs(e-n,i)+t:t},Ui.parseInt=function(t,e,i){return i||null==e?e=0:e&&(e=+e),wi(bo(t).replace(rt,""),e||0)},Ui.random=function(t,e,i){if(i&&"boolean"!=typeof i&&br(t,e,i)&&(e=i=n),i===n&&("boolean"==typeof e?(i=e,e=n):"boolean"==typeof t&&(i=t,t=n)),t===n&&e===n?(t=0,e=1):(t=mo(t),e===n?(e=t,t=0):e=mo(e)),t>e){var s=t;t=e,e=s}if(i||t%1||e%1){var r=Si();return Ei(t+r*(e-t+le("1e-"+((r+"").length-1))),e)}return Gn(t,e)},Ui.reduce=function(t,e,i){var n=Fa(t)?Ie:Fe,s=arguments.length<3;return n(t,cr(e,4),i,s,fn)},Ui.reduceRight=function(t,e,i){var n=Fa(t)?Ae:Fe,s=arguments.length<3;return n(t,cr(e,4),i,s,yn)},Ui.repeat=function(t,e,i){return e=(i?br(t,e,i):e===n)?1:go(e),Zn(bo(t),e)},Ui.replace=function(){var t=arguments,e=bo(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Ui.result=function(t,e,i){var s=-1,r=(e=bs(e,t)).length;for(r||(r=1,t=n);++s<r;){var a=null==t?n:t[Dr(e[s])];a===n&&(s=r,a=i),t=Qa(a)?a.call(t):a}return t},Ui.round=Tl,Ui.runInContext=t,Ui.sample=function(t){return(Fa(t)?Ji:Qn)(t)},Ui.size=function(t){if(null==t)return 0;if(Ya(t))return ho(t)?ui(t):t.length;var e=mr(t);return e==_||e==L?t.size:Hn(t).length},Ui.snakeCase=Go,Ui.some=function(t,e,i){var s=Fa(t)?Re:as;return i&&br(t,e,i)&&(e=n),s(t,cr(e,3))},Ui.sortedIndex=function(t,e){return os(t,e)},Ui.sortedIndexBy=function(t,e,i){return ls(t,e,cr(i,2))},Ui.sortedIndexOf=function(t,e){var i=null==t?0:t.length;if(i){var n=os(t,e);if(n<i&&Oa(t[n],e))return n}return-1},Ui.sortedLastIndex=function(t,e){return os(t,e,!0)},Ui.sortedLastIndexBy=function(t,e,i){return ls(t,e,cr(i,2),!0)},Ui.sortedLastIndexOf=function(t,e){if(null!=t&&t.length){var i=os(t,e,!0)-1;if(Oa(t[i],e))return i}return-1},Ui.startCase=Zo,Ui.startsWith=function(t,e,i){return t=bo(t),i=null==i?0:hn(go(i),0,t.length),e=us(e),t.slice(i,i+e.length)==e},Ui.subtract=kl,Ui.sum=function(t){return t&&t.length?Xe(t,al):0},Ui.sumBy=function(t,e){return t&&t.length?Xe(t,cr(e,2)):0},Ui.template=function(t,e,i){var s=Ui.templateSettings;i&&br(t,e,i)&&(e=n),t=bo(t),e=_o({},e,s,tr);var r,a,o=_o({},e.imports,s.imports,tr),l=Io(o),h=Ze(o,l),c=0,u=e.interpolate||bt,d="__p += '",p=zt((e.escape||bt).source+"|"+u.source+"|"+(u===Q?pt:bt).source+"|"+(e.evaluate||bt).source+"|$","g"),f="//# sourceURL="+(Rt.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++se+"]")+"\n";t.replace(p,(function(e,i,n,s,o,l){return n||(n=s),d+=t.slice(c,l).replace(wt,si),i&&(r=!0,d+="' +\n__e("+i+") +\n'"),o&&(a=!0,d+="';\n"+o+";\n__p += '"),n&&(d+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),c=l+e.length,e})),d+="';\n";var y=Rt.call(e,"variable")&&e.variable;if(y){if(ut.test(y))throw new _t("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(a?d.replace(j,""):d).replace(V,"$1").replace(F,"$1;"),d="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(r?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var m=el((function(){return Ct(l,f+"return "+d).apply(n,h)}));if(m.source=d,Ja(m))throw m;return m},Ui.times=function(t,e){if((t=go(t))<1||t>p)return[];var i=y,n=Ei(t,y);e=cr(e),t-=y;for(var s=Ye(n,e);++i<t;)e(i);return s},Ui.toFinite=mo,Ui.toInteger=go,Ui.toLength=vo,Ui.toLower=function(t){return bo(t).toLowerCase()},Ui.toNumber=xo,Ui.toSafeInteger=function(t){return t?hn(go(t),-9007199254740991,p):0===t?t:0},Ui.toString=bo,Ui.toUpper=function(t){return bo(t).toUpperCase()},Ui.trim=function(t,e,i){if((t=bo(t))&&(i||e===n))return Ke(t);if(!t||!(e=us(e)))return t;var s=di(t),r=di(e);return Ss(s,Qe(s,r),ti(s,r)+1).join("")},Ui.trimEnd=function(t,e,i){if((t=bo(t))&&(i||e===n))return t.slice(0,pi(t)+1);if(!t||!(e=us(e)))return t;var s=di(t);return Ss(s,0,ti(s,di(e))+1).join("")},Ui.trimStart=function(t,e,i){if((t=bo(t))&&(i||e===n))return t.replace(rt,"");if(!t||!(e=us(e)))return t;var s=di(t);return Ss(s,Qe(s,di(e))).join("")},Ui.truncate=function(t,e){var i=30,s="...";if(io(e)){var r="separator"in e?e.separator:r;i="length"in e?go(e.length):i,s="omission"in e?us(e.omission):s}var a=(t=bo(t)).length;if(ri(t)){var o=di(t);a=o.length}if(i>=a)return t;var l=i-ui(s);if(l<1)return s;var h=o?Ss(o,0,l).join(""):t.slice(0,l);if(r===n)return h+s;if(o&&(l+=h.length-l),oo(r)){if(t.slice(l).search(r)){var c,u=h;for(r.global||(r=zt(r.source,bo(ft.exec(r))+"g")),r.lastIndex=0;c=r.exec(u);)var d=c.index;h=h.slice(0,d===n?l:d)}}else if(t.indexOf(us(r),l)!=l){var p=h.lastIndexOf(r);p>-1&&(h=h.slice(0,p))}return h+s},Ui.unescape=function(t){return(t=bo(t))&&K.test(t)?t.replace(X,fi):t},Ui.uniqueId=function(t){var e=++Bt;return bo(t)+e},Ui.upperCase=Jo,Ui.upperFirst=Qo,Ui.each=Ea,Ui.eachRight=ba,Ui.first=Yr,cl(Ui,(El={},wn(Ui,(function(t,e){Rt.call(Ui.prototype,e)||(El[e]=t)})),El),{chain:!1}),Ui.VERSION="4.17.21",Te(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){Ui[t].placeholder=Ui})),Te(["drop","take"],(function(t,e){Vi.prototype[t]=function(i){i=i===n?1:xi(go(i),0);var s=this.__filtered__&&!e?new Vi(this):this.clone();return s.__filtered__?s.__takeCount__=Ei(i,s.__takeCount__):s.__views__.push({size:Ei(i,y),type:t+(s.__dir__<0?"Right":"")}),s},Vi.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Te(["filter","map","takeWhile"],(function(t,e){var i=e+1,n=1==i||3==i;Vi.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:cr(t,3),type:i}),e.__filtered__=e.__filtered__||n,e}})),Te(["head","last"],(function(t,e){var i="take"+(e?"Right":"");Vi.prototype[t]=function(){return this[i](1).value()[0]}})),Te(["initial","tail"],(function(t,e){var i="drop"+(e?"":"Right");Vi.prototype[t]=function(){return this.__filtered__?new Vi(this):this[i](1)}})),Vi.prototype.compact=function(){return this.filter(al)},Vi.prototype.find=function(t){return this.filter(t).head()},Vi.prototype.findLast=function(t){return this.reverse().find(t)},Vi.prototype.invokeMap=Jn((function(t,e){return"function"==typeof t?new Vi(this):this.map((function(i){return Mn(i,t,e)}))})),Vi.prototype.reject=function(t){return this.filter(Ba(cr(t)))},Vi.prototype.slice=function(t,e){t=go(t);var i=this;return i.__filtered__&&(t>0||e<0)?new Vi(i):(t<0?i=i.takeRight(-t):t&&(i=i.drop(t)),e!==n&&(i=(e=go(e))<0?i.dropRight(-e):i.take(e-t)),i)},Vi.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Vi.prototype.toArray=function(){return this.take(y)},wn(Vi.prototype,(function(t,e){var i=/^(?:filter|find|map|reject)|While$/.test(e),s=/^(?:head|last)$/.test(e),r=Ui[s?"take"+("last"==e?"Right":""):e],a=s||/^find/.test(e);r&&(Ui.prototype[e]=function(){var e=this.__wrapped__,o=s?[1]:arguments,l=e instanceof Vi,h=o[0],c=l||Fa(e),u=function(t){var e=r.apply(Ui,Ne([t],o));return s&&d?e[0]:e};c&&i&&"function"==typeof h&&1!=h.length&&(l=c=!1);var d=this.__chain__,p=!!this.__actions__.length,f=a&&!d,y=l&&!p;if(!a&&c){e=y?e:new Vi(this);var m=t.apply(e,o);return m.__actions__.push({func:ya,args:[u],thisArg:n}),new ji(m,d)}return f&&y?t.apply(this,o):(m=this.thru(u),f?s?m.value()[0]:m.value():m)})})),Te(["pop","push","shift","sort","splice","unshift"],(function(t){var e=Pt[t],i=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);Ui.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var s=this.value();return e.apply(Fa(s)?s:[],t)}return this[i]((function(i){return e.apply(Fa(i)?i:[],t)}))}})),wn(Vi.prototype,(function(t,e){var i=Ui[e];if(i){var n=i.name+"";Rt.call(Mi,n)||(Mi[n]=[]),Mi[n].push({name:e,func:i})}})),Mi[Os(n,2).name]=[{name:"wrapper",func:n}],Vi.prototype.clone=function(){var t=new Vi(this.__wrapped__);return t.__actions__=Ps(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ps(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ps(this.__views__),t},Vi.prototype.reverse=function(){if(this.__filtered__){var t=new Vi(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Vi.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,i=Fa(t),n=e<0,s=i?t.length:0,r=function(t,e,i){for(var n=-1,s=i.length;++n<s;){var r=i[n],a=r.size;switch(r.type){case"drop":t+=a;break;case"dropRight":e-=a;break;case"take":e=Ei(e,t+a);break;case"takeRight":t=xi(t,e-a)}}return{start:t,end:e}}(0,s,this.__views__),a=r.start,o=r.end,l=o-a,h=n?o:a-1,c=this.__iteratees__,u=c.length,d=0,p=Ei(l,this.__takeCount__);if(!i||!n&&s==l&&p==l)return ms(t,this.__actions__);var f=[];t:for(;l--&&d<p;){for(var y=-1,m=t[h+=e];++y<u;){var g=c[y],v=g.iteratee,x=g.type,E=v(m);if(2==x)m=E;else if(!E){if(1==x)continue t;break t}}f[d++]=m}return f},Ui.prototype.at=ma,Ui.prototype.chain=function(){return fa(this)},Ui.prototype.commit=function(){return new ji(this.value(),this.__chain__)},Ui.prototype.next=function(){this.__values__===n&&(this.__values__=yo(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},Ui.prototype.plant=function(t){for(var e,i=this;i instanceof Wi;){var s=Ur(i);s.__index__=0,s.__values__=n,e?r.__wrapped__=s:e=s;var r=s;i=i.__wrapped__}return r.__wrapped__=t,e},Ui.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Vi){var e=t;return this.__actions__.length&&(e=new Vi(this)),(e=e.reverse()).__actions__.push({func:ya,args:[ia],thisArg:n}),new ji(e,this.__chain__)}return this.thru(ia)},Ui.prototype.toJSON=Ui.prototype.valueOf=Ui.prototype.value=function(){return ms(this.__wrapped__,this.__actions__)},Ui.prototype.first=Ui.prototype.head,ee&&(Ui.prototype[ee]=function(){return this}),Ui}();fe?((fe.exports=yi)._=yi,pe._=yi):de._=yi}).call(t)}(e={exports:{}},e.exports),e.exports);const n={ratio:1.471,minimumWidth:138,expandedWidth:220,expandedHeight:324,episodeRatio:.563,minimumEpisodeWidth:300},s={kodi:["movie","episode","epg"],androidtv:["movie","show","season","episode","clip","track","artist","album"],plexPlayer:["movie","show","season","episode","clip","track","artist","album"],cast:["movie","episode","artist","album","track"],vlcTelnet:["track"],sonos:["track","artist","album"]};var r=function(t,e){return function(){for(var i=new Array(arguments.length),n=0;n<i.length;n++)i[n]=arguments[n];return t.apply(e,i)}},a=Object.prototype.toString;function o(t){return"[object Array]"===a.call(t)}function l(t){return void 0===t}function h(t){return null!==t&&"object"==typeof t}function c(t){if("[object Object]"!==a.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function u(t){return"[object Function]"===a.call(t)}function d(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),o(t))for(var i=0,n=t.length;i<n;i++)e.call(null,t[i],i,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}var p={isArray:o,isArrayBuffer:function(t){return"[object ArrayBuffer]"===a.call(t)},isBuffer:function(t){return null!==t&&!l(t)&&null!==t.constructor&&!l(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:h,isPlainObject:c,isUndefined:l,isDate:function(t){return"[object Date]"===a.call(t)},isFile:function(t){return"[object File]"===a.call(t)},isBlob:function(t){return"[object Blob]"===a.call(t)},isFunction:u,isStream:function(t){return h(t)&&u(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:d,merge:function t(){var e={};function i(i,n){c(e[n])&&c(i)?e[n]=t(e[n],i):c(i)?e[n]=t({},i):o(i)?e[n]=i.slice():e[n]=i}for(var n=0,s=arguments.length;n<s;n++)d(arguments[n],i);return e},extend:function(t,e,i){return d(e,(function(e,n){t[n]=i&&"function"==typeof e?r(e,i):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}};function f(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var y=function(t,e,i){if(!e)return t;var n;if(i)n=i(e);else if(p.isURLSearchParams(e))n=e.toString();else{var s=[];p.forEach(e,(function(t,e){null!=t&&(p.isArray(t)?e+="[]":t=[t],p.forEach(t,(function(t){p.isDate(t)?t=t.toISOString():p.isObject(t)&&(t=JSON.stringify(t)),s.push(f(e)+"="+f(t))})))})),n=s.join("&")}if(n){var r=t.indexOf("#");-1!==r&&(t=t.slice(0,r)),t+=(-1===t.indexOf("?")?"?":"&")+n}return t};function m(){this.handlers=[]}m.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},m.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},m.prototype.forEach=function(t){p.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var g=m,v=function(t,e,i){return p.forEach(i,(function(i){t=i(t,e)})),t},x=function(t){return!(!t||!t.__CANCEL__)},E=function(t,e){p.forEach(t,(function(i,n){n!==e&&n.toUpperCase()===e.toUpperCase()&&(t[e]=i,delete t[n])}))},b=function(t,e,i,n,s){return function(t,e,i,n,s){return t.config=e,i&&(t.code=i),t.request=n,t.response=s,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}(new Error(t),e,i,n,s)},w=p.isStandardBrowserEnv()?{write:function(t,e,i,n,s,r){var a=[];a.push(t+"="+encodeURIComponent(e)),p.isNumber(i)&&a.push("expires="+new Date(i).toGMTString()),p.isString(n)&&a.push("path="+n),p.isString(s)&&a.push("domain="+s),!0===r&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},S=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],_=p.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a");function n(t){var n=t;return e&&(i.setAttribute("href",n),n=i.href),i.setAttribute("href",n),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}return t=n(window.location.href),function(e){var i=p.isString(e)?n(e):e;return i.protocol===t.protocol&&i.host===t.host}}():function(){return!0},C=function(t){return new Promise((function(e,i){var n=t.data,s=t.headers;p.isFormData(n)&&delete s["Content-Type"];var r=new XMLHttpRequest;if(t.auth){var a=t.auth.username||"",o=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";s.Authorization="Basic "+btoa(a+":"+o)}var l,h,c=(l=t.baseURL,h=t.url,l&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(h)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(l,h):h);if(r.open(t.method.toUpperCase(),y(c,t.params,t.paramsSerializer),!0),r.timeout=t.timeout,r.onreadystatechange=function(){if(r&&4===r.readyState&&(0!==r.status||r.responseURL&&0===r.responseURL.indexOf("file:"))){var n,s,a,o,l,h="getAllResponseHeaders"in r?(n=r.getAllResponseHeaders(),l={},n?(p.forEach(n.split("\n"),(function(t){if(o=t.indexOf(":"),s=p.trim(t.substr(0,o)).toLowerCase(),a=p.trim(t.substr(o+1)),s){if(l[s]&&S.indexOf(s)>=0)return;l[s]="set-cookie"===s?(l[s]?l[s]:[]).concat([a]):l[s]?l[s]+", "+a:a}})),l):l):null,c={data:t.responseType&&"text"!==t.responseType?r.response:r.responseText,status:r.status,statusText:r.statusText,headers:h,config:t,request:r};!function(t,e,i){var n=i.config.validateStatus;i.status&&n&&!n(i.status)?e(b("Request failed with status code "+i.status,i.config,null,i.request,i)):t(i)}(e,i,c),r=null}},r.onabort=function(){r&&(i(b("Request aborted",t,"ECONNABORTED",r)),r=null)},r.onerror=function(){i(b("Network Error",t,null,r)),r=null},r.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),i(b(e,t,"ECONNABORTED",r)),r=null},p.isStandardBrowserEnv()){var u=(t.withCredentials||_(c))&&t.xsrfCookieName?w.read(t.xsrfCookieName):void 0;u&&(s[t.xsrfHeaderName]=u)}if("setRequestHeader"in r&&p.forEach(s,(function(t,e){void 0===n&&"content-type"===e.toLowerCase()?delete s[e]:r.setRequestHeader(e,t)})),p.isUndefined(t.withCredentials)||(r.withCredentials=!!t.withCredentials),t.responseType)try{r.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&r.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&r.upload&&r.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){r&&(r.abort(),i(t),r=null)})),n||(n=null),r.send(n)}))},T={"Content-Type":"application/x-www-form-urlencoded"};function k(t,e){!p.isUndefined(t)&&p.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var z,L={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(z=C),z),transformRequest:[function(t,e){return E(e,"Accept"),E(e,"Content-Type"),p.isFormData(t)||p.isArrayBuffer(t)||p.isBuffer(t)||p.isStream(t)||p.isFile(t)||p.isBlob(t)?t:p.isArrayBufferView(t)?t.buffer:p.isURLSearchParams(t)?(k(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):p.isObject(t)?(k(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300}};L.headers={common:{Accept:"application/json, text/plain, */*"}},p.forEach(["delete","get","head"],(function(t){L.headers[t]={}})),p.forEach(["post","put","patch"],(function(t){L.headers[t]=p.merge(T)}));var $=L;function P(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var M=function(t){return P(t),t.headers=t.headers||{},t.data=v(t.data,t.headers,t.transformRequest),t.headers=p.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),p.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||$.adapter)(t).then((function(e){return P(t),e.data=v(e.data,e.headers,t.transformResponse),e}),(function(e){return x(e)||(P(t),e&&e.response&&(e.response.data=v(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},N=function(t,e){e=e||{};var i={},n=["url","method","data"],s=["headers","auth","proxy","params"],r=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function o(t,e){return p.isPlainObject(t)&&p.isPlainObject(e)?p.merge(t,e):p.isPlainObject(e)?p.merge({},e):p.isArray(e)?e.slice():e}function l(n){p.isUndefined(e[n])?p.isUndefined(t[n])||(i[n]=o(void 0,t[n])):i[n]=o(t[n],e[n])}p.forEach(n,(function(t){p.isUndefined(e[t])||(i[t]=o(void 0,e[t]))})),p.forEach(s,l),p.forEach(r,(function(n){p.isUndefined(e[n])?p.isUndefined(t[n])||(i[n]=o(void 0,t[n])):i[n]=o(void 0,e[n])})),p.forEach(a,(function(n){n in e?i[n]=o(t[n],e[n]):n in t&&(i[n]=o(void 0,t[n]))}));var h=n.concat(s).concat(r).concat(a),c=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===h.indexOf(t)}));return p.forEach(c,l),i};function I(t){this.defaults=t,this.interceptors={request:new g,response:new g}}I.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=N(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[M,void 0],i=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)i=i.then(e.shift(),e.shift());return i},I.prototype.getUri=function(t){return t=N(this.defaults,t),y(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},p.forEach(["delete","get","head","options"],(function(t){I.prototype[t]=function(e,i){return this.request(N(i||{},{method:t,url:e,data:(i||{}).data}))}})),p.forEach(["post","put","patch"],(function(t){I.prototype[t]=function(e,i,n){return this.request(N(n||{},{method:t,url:e,data:i}))}}));var A=I;function R(t){this.message=t}R.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},R.prototype.__CANCEL__=!0;var B=R;function H(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var i=this;t((function(t){i.reason||(i.reason=new B(t),e(i.reason))}))}H.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},H.source=function(){var t;return{token:new H((function(e){t=e})),cancel:t}};var D=H;function q(t){var e=new A(t),i=r(A.prototype.request,e);return p.extend(i,A.prototype,e),p.extend(i,e),i}var U=q($);U.Axios=A,U.create=function(t){return q(N(U.defaults,t))},U.Cancel=B,U.CancelToken=D,U.isCancel=x,U.all=function(t){return Promise.all(t)},U.spread=function(t){return function(e){return t.apply(null,e)}},U.isAxiosError=function(t){return"object"==typeof t&&!0===t.isAxiosError};var O=U,W=U;O.default=W;var j=O;class V{constructor(t,e=!1,n,s="http",r="titleSort:asc"){this.serverInfo={},this.clients=[],this.requestTimeout=1e4,this.sections=[],this.providers=[],this.livetv={},this.livetvepg={},this.collections=!1,this.playlists=[],this.init=async()=>{await Promise.all([this.getSections(),this.getClients(),this.getServerID()])},this.getClients=async()=>{const t=this.authorizeURL(`${this.getBasicURL()}/clients`);try{const e=await j.get(t,{timeout:this.requestTimeout});this.clients=e.data.MediaContainer.Server}catch(e){throw Error(`${e.message} while requesting URL "${t}".`)}return this.clients},this.getProviders=async()=>{if(i.isEmpty(this.providers)){const t=this.authorizeURL(`${this.getBasicURL()}/media/providers`),e=await j.get(t,{timeout:this.requestTimeout});this.providers=e.data.MediaContainer.MediaProvider}return this.providers},this.getLiveTV=async()=>{if(i.isEmpty(this.livetv)){const t={},e=await this.getProviders(),n=[],s=[];i.forEach(e,(t=>{if(i.isEqual(t.protocols,"livetv")){const e=this.authorizeURL(`${this.getBasicURL()}/${t.identifier}/tags?type=310`);n.push(j.get(e,{timeout:this.requestTimeout})),s.push(t.title)}}));const r=await Promise.all(n);i.forEach(r,((e,i)=>{t[s[i]]=e.data.MediaContainer.Directory})),this.livetv=t}return this.livetv},this.getEPG=async()=>{if(i.isEmpty(this.livetvepg)){const t={},e=await this.getProviders(),n=[],s=[];i.forEach(e,(t=>{if(i.isEqual(t.protocols,"livetv")){let e=this.authorizeURL(`${this.getBasicURL()}/${t.identifier}/grid?type=1&sort=beginsAt`);e+=`&endsAt>=${Math.floor(Date.now()/1e3)}`,e+=`&beginsAt<=${Math.floor(Date.now()/1e3)}`,n.push(j.get(e,{timeout:this.requestTimeout})),s.push(t.title)}}));const r=await Promise.all(n);i.forEach(r,((e,n)=>{t[s[n]]={},i.forEach(e.data.MediaContainer.Metadata,(e=>{t[s[n]][e.Media[0].channelCallSign]=e}))})),this.livetvepg=t}return this.livetvepg},this.getServerID=async()=>(i.isEmpty(this.serverInfo)&&await this.getServerInfo(),this.serverInfo.machineIdentifier),this.getServerInfo=async()=>{const t=this.authorizeURL(`${this.getBasicURL()}/`);return this.serverInfo=(await j.get(t,{timeout:this.requestTimeout})).data.MediaContainer,this.serverInfo},this.getSections=async()=>{if(i.isEmpty(this.sections)){const t=this.authorizeURL(`${this.getBasicURL()}/library/sections`),e=await j.get(t,{timeout:this.requestTimeout});this.sections=e.data.MediaContainer.Directory}return this.sections},this.getCollections=async()=>{if(!i.isArray(this.collections)){const t=await this.getSections(),e=[];i.forEach(t,(t=>{e.push(this.getCollection(t.key))}));const n=await Promise.all(e),s=[];i.forEach(n,(t=>{i.forEach(t,(t=>{s.push(t)}))})),this.collections=s}return this.collections},this.getPlaylists=async()=>{if(i.isEmpty(this.playlists)){this.playlists=[];const t=this.authorizeURL(`${this.getBasicURL()}/playlists`),e=await j.get(t,{timeout:this.requestTimeout});this.playlists=e.data.MediaContainer.Metadata}return this.playlists},this.getCollection=async t=>{const e=this.authorizeURL(`${this.getBasicURL()}/library/sections/${t}/collections`),n=await j.get(e,{timeout:this.requestTimeout});return i.isNil(n.data.MediaContainer.Metadata)?[]:n.data.MediaContainer.Metadata},this.getSectionData=async(t,e=!1)=>this.exportSectionsData([await this.getSectionDataWithoutProcessing(t,e)]),this.getChildren=async t=>{let e=this.authorizeURL(`${this.getBasicURL()}${t}`);e+=`&sort=${this.sort}`;let n={};try{n=await j.get(e,{timeout:this.requestTimeout})}catch(s){if(!i.includes(s.message,"Request failed with status code 500"))throw s;{e+="&X-Plex-Container-Start=0&X-Plex-Container-Size=50",n=await j.get(e,{timeout:this.requestTimeout});const{totalSize:s}=n.data.MediaContainer;let r=50;const a=[];for(;r<s;)a.push(j.get(this.authorizeURL(`${this.getBasicURL()}${t}?sort=${this.sort}&X-Plex-Container-Start=${r}&X-Plex-Container-Size=50`),{timeout:this.requestTimeout})),r+=50;const o=await Promise.all(a);i.forEach(o,(t=>{n.data.MediaContainer.Metadata=i.concat(n.data.MediaContainer.Metadata,t.data.MediaContainer.Metadata)}))}}return n.data.MediaContainer.Metadata},this.getCollectionData=async t=>this.getChildren(t),this.getPlaylistData=async t=>this.getChildren(t),this.getSectionDataWithoutProcessing=async(t,e=!1)=>{let n=`${this.getBasicURL()}/library/sections/${t}`;e?i.isEqual(e,"folder")?n+="/folder":(n+="/all",n+=`?type=${e}`):n+="/all",n=this.authorizeURL(n),n+=`&sort=${this.sort}`,n+="&includeCollections=1&includeExternalMedia=1&includeAdvanced=1&includeMeta=1";let s={};try{s=await j.get(n,{timeout:this.requestTimeout})}catch(e){if(!i.includes(e.message,"Request failed with status code 500"))throw e;{n+="&X-Plex-Container-Start=0&X-Plex-Container-Size=50",s=await j.get(n,{timeout:this.requestTimeout});const{totalSize:e}=s.data.MediaContainer;let r=50;const a=[];for(;r<e;)a.push(j.get(this.authorizeURL(`${this.getBasicURL()}/library/sections/${t}/all?sort=${this.sort}&X-Plex-Container-Start=${r}&X-Plex-Container-Size=50`),{timeout:this.requestTimeout})),r+=50;const o=await Promise.all(a);i.forEach(o,(t=>{s.data.MediaContainer.Metadata=i.concat(s.data.MediaContainer.Metadata,t.data.MediaContainer.Metadata)}))}}return s},this.getSectionsData=async()=>{const t=await this.getSections(),e=[];return i.forEach(t,(t=>{e.push(this.getSectionDataWithoutProcessing(t.key))})),this.exportSectionsData(await Promise.all(e))},this.getRecentyAdded=async(t=!1)=>{if(t){const t=await this.getHubs();let e={};return i.forEach(t.Hub,(t=>{if(i.isEqual(t.key,"/hubs/home/recentlyAdded?type=2"))return e=t,!1})),e}const e=this.authorizeURL(`${this.getBasicURL()}/hubs/home/recentlyAdded?type=2&X-Plex-Container-Start=0&X-Plex-Container-Size=50`);return(await j.get(e,{timeout:this.requestTimeout})).data.MediaContainer},this.getHubs=async()=>{const t=this.authorizeURL(`${this.getBasicURL()}/hubs?includeEmpty=1&count=50&includeFeaturedTags=1&includeTypeFirst=1&includeStations=1&includeExternalMetadata=1&excludePlaylists=1`);return(await j.get(t,{timeout:this.requestTimeout})).data.MediaContainer},this.getWatchNext=async()=>{const t=await this.getSections();let e="";i.forEach(t,(t=>{e+=`${t.key},`})),e=e.slice(0,-1);const n=this.authorizeURL(`${this.getBasicURL()}/hubs/continueWatching/items?contentDirectoryID=${e}`);return(await j.get(n,{timeout:this.requestTimeout})).data.MediaContainer},this.tune=async(t,e)=>{e="PlexMeetsHomeAssistant3",console.log(t);let n=this.authorizeURL(`${this.getBasicURL()}/livetv/dvrs/12/channels/${t}/tune?X-Plex-Language=en-us`);console.log("Starting tune process..."),n=`${this.getBasicURL()}/livetv/dvrs/12/channels/`,n+=`${t}`,n+="/tune",n+=`?X-Plex-Client-Identifier=${e}`,n+=`&X-Plex-Session-Identifier=${e}`;const s=(await j.post(this.authorizeURL(n),{timeout:this.requestTimeout})).data.MediaContainer;console.log("Tuning started.");let r=`${this.getBasicURL()}/video/:/transcode/universal/start.mpd`;r+="?hasMDE=1",r+=`&path=${encodeURIComponent(s.MediaSubscription[0].MediaGrabOperation[0].Metadata.key)}`,r+="&mediaIndex=0",r+="&partIndex=0",r+="&protocol=dash",r+="&fastSeek=1",r+="&directPlay=0",r+="&directStream=1",r+="&subtitleSize=100",r+="&audioBoost=100",r+="&location=lan",r+="&addDebugOverlay=0",r+="&autoAdjustQuality=0",r+="&directStreamAudio=1",r+="&mediaBufferSize=102400",r+=`&session=${e}`,r+="&subtitles=burn",r+="&copyts=0",r+="&Accept-Language=en-GB",r+=`&X-Plex-Session-Identifier=${e}`,r+="&X-Plex-Client-Profile-Extra=append-transcode-target-codec%28type%3DvideoProfile%26context%3Dstreaming%26audioCodec%3Daac%26protocol%3Ddash%29",r+="&X-Plex-Incomplete-Segments=1",r+="&X-Plex-Product=Plex%20Web",r+="&X-Plex-Version=4.59.2",r+=`&X-Plex-Client-Identifier=${e}`,r+="&X-Plex-Platform=Chrome",r+="&X-Plex-Platform-Version=92.0",r+="&X-Plex-Sync-Version=2",r+="&X-Plex-Features=external-media%2Cindirect-media",r+="&X-Plex-Model=bundled",r+="&X-Plex-Device=OSX",r+="&X-Plex-Device-Name=Chrome",r+="&X-Plex-Device-Screen-Resolution=1792x444%2C1792x1120",r+="&X-Plex-Language=en-GB";let a=`${this.getBasicURL()}/video/:/transcode/universal/decision`;a+="?advancedSubtitles=text",a+="&audioBoost=100",a+="&autoAdjustQuality=0",a+="&directPlay=1",a+="&directStream=1",a+="&directStreamAudio=1",a+="&fastSeek=1",a+="&hasMDE=1",a+="&location=lan",a+="&mediaIndex=0",a+="&partIndex=0",a+=`&path=${s.MediaSubscription[0].MediaGrabOperation[0].Metadata.key}`,a+="&protocol=*",a+=`&session=${e}`,a+="&skipSubtitles=1",a+="&videoBitrate=200000",a+="&videoQuality=100",a+=`&X-Plex-Client-Identifier=${e}`,a+="&X-Plex-Platform=Android";const o=this.authorizeURL(`${this.getBasicURL()}${s.MediaSubscription[0].MediaGrabOperation[0].Metadata.key}?includeBandwidths=1&offset=-1&X-Plex-Incomplete-Segments=1&X-Plex-Session-Identifier=${e}`);console.log("Getting info about channel stream...");const l=await j.get(o,{timeout:6e4});if(console.log(l.data),i.isNil(l.data.MediaContainer.Metadata[0].Media[0].TranscodeSession)){console.log("NOT STARTED - Starting...");const t=await j.get(this.authorizeURL(r),{timeout:6e4});console.log(t),console.log("____")}const h=async t=>new Promise((e=>setTimeout(e,t)));console.log("Deciding...");let c=await j.get(this.authorizeURL(a),{timeout:this.requestTimeout});for(;parseFloat(c.data.MediaContainer.Metadata[0].Media[0].Part[0].key.split("offset=")[1].split("&")[0])<3;)await h(500),c=await j.get(this.authorizeURL(a),{timeout:this.requestTimeout}),console.log("Waiting for new url...");return c.data.MediaContainer.Metadata[0].Media[0].Part[0].key},this.getContinueWatching=async()=>{const t=await this.getHubs();let e={};return i.forEach(t.Hub,(t=>{if(i.isEqual(t.key,"/hubs/home/continueWatching"))return e=t,!1})),e},this.getOnDeck=async()=>{const t=await this.getHubs();let e={};return i.forEach(t.Hub,(t=>{if(i.isEqual(t.key,"/hubs/home/onDeck"))return e=t,!1})),e},this.getBasicURL=()=>`${this.protocol}://${this.ip}${!1===this.port?"":`:${this.port}`}`,this.authorizeURL=t=>i.includes(t,"X-Plex-Token")?t:i.includes(t,"?")?`${t}&X-Plex-Token=${this.token}`:`${t}?X-Plex-Token=${this.token}`,this.getDetails=async t=>{const e=this.authorizeURL(`${this.getBasicURL()}/library/metadata/${t}?includeConcerts=1&includeExtras=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeReviews=1&includeChapters=1&includeStations=1&includeExternalMedia=1&asyncAugmentMetadata=1&asyncCheckFiles=1&asyncRefreshAnalysis=1&asyncRefreshLocalMediaAgent=1`);return(await j.get(e,{timeout:this.requestTimeout})).data.MediaContainer.Metadata[0]},this.getLibraryData=async t=>{const e=this.authorizeURL(`${this.getBasicURL()}${t}`);return(await j.get(e,{timeout:this.requestTimeout})).data.MediaContainer.Metadata},this.exportSectionsData=t=>{const e=[];return i.forEach(t,(t=>{e.push(t.data.MediaContainer)})),e},this.ip=t,this.port=e,this.token=n,this.protocol=s,this.sort=r}}const F=t=>t?t.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):"",X=()=>{const t=document.createElement("ha-textfield");return t.style.width="100%",t.style.marginTop="10px",t.style.marginBottom="10px",t},Y=t=>t.sendMessagePromise({type:"config/entity_registry/list"}),K=t=>Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight),G=t=>{let e=0,n=0;for(;t&&t.offsetParent&&!i.isNaN(t.offsetLeft)&&!i.isNaN(t.offsetTop);){e+=t.offsetLeft-t.scrollLeft,n+=t.offsetTop-t.scrollTop;const i=t.offsetParent;i&&(t=i)}return{top:n,left:e}},Z=t=>{const e=t.getElementsByClassName("videoPlayer")[0].children[0];if(!e)return!1;const i=document.getElementsByTagName("body")[0];return e.offsetWidth===i.offsetWidth&&e.offsetHeight===i.offsetHeight||t.videoElem&&t.videoElem.classList.contains("simulatedFullScreen")},J=t=>`PlexMeetsHomeAssistant: 404 Error requesting library feed for ${t}. Plex API might have changed or using outdated server. Library ${t} will not work.`,Q=async t=>new Promise((e=>setTimeout(e,t))),tt=async(t,e)=>t.callApi("GET",`states/${e}`),et=(t,e)=>{let i=`${t}`;for(;i.length<e;)i=`0${i}`;return i},it=(t,e,n,s,r,a)=>{const o=s/4,l=document.createElement("tr");l.classList.add("trackContainer"),a?l.classList.add("even"):l.classList.add("odd");const h=document.createElement("td");h.className="trackIndexElem",h.innerHTML=`<span class="trackIndex">${F(n.index)}</span>`,h.style.fontSize=`${s}px`,h.style.lineHeight=`${s}px`,h.style.marginBottom=`${o}px`;const c=document.createElement("div");if(c.className="trackInteractiveArea",t){const e=t.getPlayButton(n.type);e.addEventListener("click",(e=>{e.stopPropagation(),t.play(n,!0)})),t.isPlaySupported(n)&&e.classList.remove("disabled"),c.append(e)}h.append(c),l.append(h);const u=document.createElement("td");u.className="trackTitleElem",i.isEmpty(n.title)?i.isEmpty(n.titleSort)||(u.innerHTML=F(n.titleSort)):u.innerHTML=F(n.title),u.style.fontSize=`${s}px`,u.style.lineHeight=`${s}px`,u.style.marginBottom=`${o}px`,l.append(u);const d=i.get(n,"Media[0].duration"),p=document.createElement("td");if(p.className="trackLengthElem",p.style.fontSize=`${s}px`,p.style.lineHeight=`${s}px`,p.style.marginBottom=`${o}px`,d){const t=Math.floor(d/60/1e3),e=Math.round((d-1e3*t)/6e3);p.innerHTML=F(`${et(t,2)}:${et(e,2)}`)}return l.append(p),l.addEventListener("click",(t=>{t.stopPropagation()})),l},nt=(t,e,i,s,r)=>{const a=document.createElement("div");a.className="episodeContainer",a.style.width=`${n.episodeWidth}px`;const o=e.authorizeURL(`${e.getBasicURL()}/photo/:/transcode?width=${n.episodeWidth}&height=${n.episodeHeight}&minSize=1&upscale=1&url=${i.thumb}`),l=document.createElement("div");if(l.className="episodeElem",l.style.width=`${n.episodeWidth}px`,l.style.height=`${n.episodeHeight}px`,l.style.backgroundImage=`url('${o}')`,l.dataset.clicked="false",void 0===i.lastViewedAt){const t=document.createElement("div");t.className="toViewEpisode",l.appendChild(t)}const h=document.createElement("div");if(h.className="interactiveArea",t){const e=t.getPlayButton(i.type);e.addEventListener("click",(e=>{e.stopPropagation(),t.play(i,!0)})),t.isPlaySupported(i)&&e.classList.remove("disabled"),h.append(e)}l.append(h),a.append(l);const c=document.createElement("div");c.className="episodeTitleElem",c.innerHTML=F(i.title);const u=s/4,d=r/4;c.style.fontSize=`${s}px`,c.style.lineHeight=`${s}px`,c.style.marginBottom=`${u}px`,a.append(c);const p=document.createElement("div");if(p.className="episodeNumber",p.style.fontSize=`${r}px`,p.style.lineHeight=`${r}px`,p.style.marginTop=`${d}px`,p.style.marginBottom=`${d}px`,"episode"===i.type)p.innerHTML=F(`Episode ${F(i.index)}`);else if("clip"===i.type){let t="";switch(i.subtype){case"behindTheScenes":t="Behind the Scenes";break;case"trailer":t="Trailer";break;case"scene":case"sceneOrSample":t="Scene";break;default:t=i.subtype}p.innerHTML=F(t)}return a.append(p),a.addEventListener("click",(t=>{t.stopPropagation()})),a};class st{constructor(t,e,n,r,a,o,l,h,c){this.playButtons=[],this.readyPlayersForType={},this.entityStates={},this.plexPlayerEntity="",this.runBefore=!1,this.runAfter=!1,this.supported=s,this.playActionButton=document.createElement("button"),this.playActionClickFunction=!1,this.entityRegistry=[],this.shuffle=!1,this.getKodiSearchResults=async()=>JSON.parse((await tt(this.hass,"sensor.kodi_media_sensor_search")).attributes.data),this.getKodiSearch=async(t,e=!1)=>{await this.hass.callService("kodi_media_sensors","call_method",{entity_id:"sensor.kodi_media_sensor_search",method:"search",item:{media_type:"all",value:t}});const n=await this.getKodiSearchResults();let s={};if(i.forEach(n,(e=>i.isEqual(e.title,t)||i.isEqual(e.label,t)?(s=e,!1):void 0)),i.isEmpty(s)&&!e)throw alert(`Title ${t} not found in Kodi.`),Error(`Title ${t} not found in Kodi.`);return s},this.getKodiTVShowSeason=async(t,e)=>{await this.hass.callService("kodi_media_sensors","call_method",{entity_id:"sensor.kodi_media_sensor_search",method:"search",item:{media_type:"tvshow",value:t}});let n={};const s=await this.getKodiSearchResults();if(i.forEach(s,(t=>{if(i.isEqual(t.season,e))return n=t,!1})),i.isEmpty(n))throw Error(`Season ${e} not found in Kodi for TV Show ${t}.`);return n},this.play=async(t,e=!1)=>{if(i.isArray(this.runBefore)){const t=`${this.runBefore[0]}.${this.runBefore[1]}`;await this.hass.callService(this.runBefore[0],this.runBefore[1],{});const e=await tt(this.hass,t);i.isEqual(e.state,"on")&&await(async(t,e,i)=>{let n=await tt(t,e);for(;n.state!==i;)n=await tt(t,e),await Q(1e3)})(this.hass,t,"off")}const n=this.getPlayService(t,!0);let s,r=t;switch(i.isEqual(t.type,"epg")&&(r=t.epg,s=""),n.key){case"kodi":await this.playViaKodi(n.value,t,t.type);break;case"vlcTelnet":await this.playViaVLCTelnet(n.value,t,t.type);break;case"androidtv":if(i.isEqual(t.type,"epg")){const i=`${Math.floor(Date.now()/1e3)}`,r=await this.plex.tune(t.channelIdentifier,i);await this.playViaAndroidTV(n.value,r,e,s)}else await this.playViaAndroidTV(n.value,r.key,e,s);break;case"plexPlayer":await this.playViaPlexPlayer(n.value,r.key.split("/")[3]);break;case"cast":case"sonos":if(i.isEqual(t.type,"epg")){const e=`PlexMeetsHomeAssistant-${Math.floor(Date.now()/1e3)}`,i=await this.plex.tune(t.channelIdentifier,e);this.playViaCast(n.value,`${i}`,"epg")}else if(this.hass.services.plex){const t=i.isNil(r.librarySectionTitle)?this.libraryName:r.librarySectionTitle;try{switch(r.type){case"artist":await this.playViaCastPlex(n.value,"MUSIC",{library_name:t,artist_name:r.title,shuffle:this.shuffle?1:0});break;case"album":await this.playViaCastPlex(n.value,"MUSIC",{library_name:t,artist_name:r.parentTitle,album_name:r.title,shuffle:this.shuffle?1:0});break;case"track":await this.playViaCastPlex(n.value,"MUSIC",{library_name:t,artist_name:r.grandparentTitle,album_name:r.parentTitle,track_name:r.title,shuffle:this.shuffle?1:0});break;case"movie":await this.playViaCastPlex(n.value,"movie",{library_name:t,title:r.title});break;case"episode":await this.playViaCastPlex(n.value,"EPISODE",{library_name:t,show_name:r.grandparentTitle,season_number:r.parentIndex,episode_number:r.index});break;default:i.isNil(r.Media)?console.error("Casting this content directly is not possible. Consider using Plex integration."):this.playViaCast(n.value,r.Media[0].Part[0].key)}}catch(t){console.log(t),this.playViaCast(n.value,r.Media[0].Part[0].key)}}else{if(i.isNil(i.get(r,"Media[0].Part[0].key")))throw Error(`No service available to play ${r.title}!`);this.playViaCast(n.value,i.get(r,"Media[0].Part[0].key"))}break;default:throw Error(`No service available to play ${r.title}!`)}i.isArray(this.runAfter)&&await this.hass.callService(this.runAfter[0],this.runAfter[1],{})},this.plexPlayerCreateQueue=async(t,e,i,n=!1,s=!1,r=!1)=>{const a=`${e.getBasicURL()}/playQueues?type=${i}&shuffle=${n?"1":"0"}&repeat=${s?"1":"0"}&continuous=${r?"1":"0"}&own=1&uri=server://${await e.getServerID()}/com.plexapp.plugins.library${t}`,o=await j({method:"post",url:a,headers:{"X-Plex-Token":e.token,"X-Plex-Client-Identifier":"PlexMeetsHomeAssistant"}});if(200!==o.status)throw Error("Error reaching Plex to generate queue");return{playQueueID:o.data.MediaContainer.playQueueID,playQueueSelectedMetadataItemID:o.data.MediaContainer.playQueueSelectedMetadataItemID}},this.playViaPlexPlayer=async(t,e)=>{const n=this.getPlexPlayerMachineIdentifier(t);let{plex:s}=this;i.isObject(t)&&!i.isNil(t.plex)&&(s=t.plex);const{playQueueID:r,playQueueSelectedMetadataItemID:a}=await this.plexPlayerCreateQueue(`/library/metadata/${e}`,this.plex,"video");let o=s.getBasicURL();o+="/player/playback/playMedia",o+="?type=video",o+="&commandID=1",o+="&providerIdentifier=com.plexapp.plugins.library",o+=`&containerKey=/playQueues/${r}`,o+=`&key=/library/metadata/${a}`,o+="&offset=0",o+=`&machineIdentifier=${await this.plex.getServerID()}`,o+=`&protocol=${this.plex.protocol}`,o+=`&address=${this.plex.ip}`,o+=`&port=${this.plex.port}`,o+=`&token=${this.plex.token}`,o=s.authorizeURL(o);try{const t=await j({method:"get",url:o,headers:{"X-Plex-Target-Client-Identifier":n,"X-Plex-Client-Identifier":"PlexMeetsHomeAssistant"}});if(200!==t.status)throw Error("Error while asking plex to play a movie - server request error.");if(!i.includes(t.data,'status="OK"'))throw Error("Error while asking plex to play a movie - target device not available.")}catch(t){try{await this.hass.callService("rest_command","pmha_playmedia",{url:o,target_client_identifier:n,client_identifier:"PlexMeetsHomeAssistant"})}catch(t){}throw i.includes(t.message,"404")?Error("Defined plexPlayer is currently not available for playback."):t}},this.playViaKodi=async(t,e,n)=>{if("epg"===n)try{const n=await this.getKodiSearch(i.get(e,"channelCallSign"),!0);await this.hass.callService("kodi","call_method",{entity_id:t,method:"Player.Open",item:{channelid:n.channelid}})}catch(i){const n=`${this.plex.getBasicURL()}${await this.plex.tune(e.channelIdentifier,"todo")}`;await this.hass.callService("kodi","call_method",{entity_id:t,method:"Player.Open",item:{file:n}})}else if("movie"===n){const i=await this.getKodiSearch(e.title);await this.hass.callService("kodi","call_method",{entity_id:t,method:"Player.Open",item:{movieid:i.movieid}})}else{if("episode"!==n)throw Error(`Plex type ${n} is not supported in Kodi.`);{const n=await this.getKodiSearch(e.grandparentTitle),s=await this.getKodiTVShowSeason(n.tvshowid,e.parentIndex);let r={};if(i.forEach(s.episodes,(t=>{if(i.isEqual(t.episode,e.index))return r=t,!1})),i.isEmpty(r))throw Error(`Episode ${e.index} not found in Kodi for TV Show ${e.grandparentTitle} (id: ${n.tvshowid}) season ${e.parentIndex}.`);await this.hass.callService("kodi","call_method",{entity_id:t,method:"Player.Open",item:{episodeid:r.episodeid}})}}},this.playViaVLCTelnet=async(t,e,i)=>{switch(i){case"track":this.hass.callService("media_player","play_media",{entity_id:t,media_content_type:"music",media_content_id:this.plex.authorizeURL(`${this.plex.getBasicURL()}${e.Media[0].Part[0].key}`)});break;default:console.error(`Type ${i} is not supported on entity ${t}.`)}},this.playViaCast=(t,e,n="video")=>{if(i.isEqual(n,"video"))this.hass.callService("media_player","play_media",{entity_id:t,media_content_type:n,media_content_id:this.plex.authorizeURL(`${this.plex.getBasicURL()}${e}`)});else if(i.isEqual(n,"epg")){const i={entity_id:t,media_content_type:"application/vnd.apple.mpegurl",media_content_id:e=this.plex.authorizeURL(`${this.plex.getBasicURL()}${e}`)};this.hass.callService("media_player","play_media",i)}},this.playViaCastPlex=(t,e,n)=>{const s=i.get(this.plex,"serverInfo.friendlyName"),r=i.clone(n);return s&&(r.plex_server=s),this.hass.callService("media_player","play_media",{entity_id:t,media_content_type:e,media_content_id:`plex://${JSON.stringify(r)}`})},this.playViaAndroidTV=async(t,e,i=!1,n="com.plexapp.plugins.library")=>{let s="am start";i&&(s+=' --ez "android.intent.extra.START_PLAYBACK" true'),s+=` -a android.intent.action.VIEW 'plex://server://${await this.plex.getServerID()}/${n}${e}'`,this.hass.callService("androidtv","adb_command",{entity_id:t,command:"HOME"}),this.hass.callService("androidtv","adb_command",{entity_id:t,command:s})},this.getPlayButton=t=>{const e=document.createElement("button");return e.name="playButton",e.classList.add("disabled"),this.isTouchDevice()&&e.classList.add("touchDevice"),e.setAttribute("data-mediaType",t),this.playButtons.push(e),e},this.setPlayActionDisplay=t=>{this.updateDetailPlayAction().style.display=t},this.setPlayActionButtonType=t=>{const e=this.updateDetailPlayAction();e.setAttribute("data-mediaType",t);const n={type:t};i.isEmpty(this.getPlayService(n))?e.classList.add("disabled"):e.classList.remove("disabled")},this.updateDetailPlayAction=()=>(this.card.getElementsByClassName("detailPlayAction").length>0&&(this.playActionButton=this.card.getElementsByClassName("detailPlayAction")[0]),this.playActionButton),this.setPlayButtonClickFunction=t=>{const e=this.updateDetailPlayAction();this.playActionClickFunction&&e.removeEventListener("click",this.playActionClickFunction),e.addEventListener("click",t),this.playActionClickFunction=t},this.getPlayActionButton=()=>this.playActionButton,this.isTouchDevice=()=>"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,this.refreshAvailableServicesPeriodically=async()=>{const t=async t=>new Promise((e=>setTimeout(e,t)));for(;;){await this.refreshStates();const e=i.clone(this.readyPlayersForType);i.forEach(this.readyPlayersForType,((t,n)=>{const s={type:n};this.getPlayService(s,!0),i.isEqual(e,this.readyPlayersForType)||i.forEach(this.playButtons,(t=>{const e=t.getAttribute("data-mediaType");i.isEmpty(this.readyPlayersForType[e])?t.classList.add("disabled"):t.classList.remove("disabled")}));const r=this.getPlayActionButton(),a=r.getAttribute("data-mediaType");a&&(i.isEmpty(this.readyPlayersForType[a])?r.classList.add("disabled"):r.classList.remove("disabled"))})),await t(1e3)}},this.exportEntity=(t,e)=>{const n=[];if(i.isEqual(e,"inputSelect")||i.isEqual(e,"inputText"))if(i.isArray(t))for(let e=0;e<t.length;e+=1){const s=i.get(this.entityStates[t[e]],"state");let r="plexPlayer";i.forEach(this.entityRegistry,(t=>{i.isEqual(t.entity_id,s)&&(r=t.platform)})),n.push({value:s,key:r})}else{const e=i.get(this.entityStates[t],"state");let s="plexPlayer";i.forEach(this.entityRegistry,(t=>{i.isEqual(t.entity_id,e)&&(s=t.platform)})),n.push({value:e,key:s})}else i.isArray(t)?i.forEach(t,(t=>{n.push({value:t,key:e})})):n.push({value:t,key:e});return n},this.getPlayService=(t,e=!1)=>{if(!i.isNil(this.readyPlayersForType[t.type])&&!1===e)return this.readyPlayersForType[t.type];let n={};return i.forEach(this.entity,((e,s)=>{if(i.isEmpty(n)){const r=this.exportEntity(e,s);i.forEach(r,(e=>{if(i.includes(this.supported[e.key],t.type)&&("kodi"===e.key&&this.isKodiSupported(e.value)||"androidtv"===e.key&&this.isAndroidTVSupported(e.value)||"plexPlayer"===e.key&&this.isPlexPlayerSupported(e.value)||"cast"===e.key&&this.isCastSupported(e.value)||"vlcTelnet"===e.key&&this.isVLCTelnetSupported(e.value)||"sonos"===e.key&&this.isSonosSupported(e.value)))return n={key:e.key,value:e.value},!1}))}})),this.readyPlayersForType[t.type]=n,this.readyPlayersForType[t.type]},this.init=async()=>{if(!i.isNil(this.entity.plexPlayer))if(i.isArray(this.entity.plexPlayer)){for(let t=0;t<this.entity.plexPlayer.length;t+=1)if(i.isObjectLike(this.entity.plexPlayer[t])&&!i.isNil(this.entity.plexPlayer[t].server)){let e=!1;i.isNil(this.entity.plexPlayer[t].server.port)||(e=this.entity.plexPlayer[t].server.port);let n="http";i.isNil(this.entity.plexPlayer[t].server.protocol)||(n=this.entity.plexPlayer[t].server.protocol),this.entity.plexPlayer[t].plex=new V(this.entity.plexPlayer[t].server.ip,e,this.entity.plexPlayer[t].server.token,n),await this.entity.plexPlayer[t].plex.getClients()}}else if(!i.isNil(this.entity.plexPlayer.server)&&!i.isNil(this.entity.plexPlayer.server.ip)&&!i.isNil(this.entity.plexPlayer.server.token)){let t=!1;i.isNil(this.entity.plexPlayer.server.port)||(t=this.entity.plexPlayer.server.port);let e="http";i.isNil(this.entity.plexPlayer.server.protocol)||(e=this.entity.plexPlayer.server.protocol),this.entity.plexPlayer.plex=new V(this.entity.plexPlayer.server.ip,t,this.entity.plexPlayer.server.token,e),await this.entity.plexPlayer.plex.getClients()}await this.refreshStates()},this.refreshStates=async()=>{for(const[,t]of Object.entries(this.entity)){const e=t;if(i.isArray(e)){for(const t of e)if(!i.isNil(this.hass.states[t]))try{this.entityStates[t]=await tt(this.hass,t)}catch(t){}}else try{i.isNil(this.hass.states[e])||(this.entityStates[e]=await tt(this.hass,e))}catch(t){}}try{this.hass.states["sensor.kodi_media_sensor_search"]&&(this.entityStates["sensor.kodi_media_sensor_search"]=await tt(this.hass,"sensor.kodi_media_sensor_search"))}catch(t){}for(const[t,e]of Object.entries(this.entity))if(i.isEqual(t,"inputSelect")||i.isEqual(t,"inputText")){const n=this.exportEntity(e,t);for(const t of n)if(!i.isNil(this.hass.states[t.value]))try{this.entityStates[t.value]=await tt(this.hass,t.value)}catch(t){}}return this.entityStates},this.getPlexPlayerMachineIdentifier=t=>{i.isString(t)&&i.isEqual(t.split(" | ").length,4)&&([,,,t]=t.split(" | "));let e="",{plex:n}=this,s="";return i.isString(t)?s=t.trim():i.isObjectLike(t)&&!i.isNil(t.identifier)&&(s=t.identifier.trim(),!i.isNil(t.plex)&&t.plex&&(n=t.plex)),i.forEach(n.clients,(t=>{if(i.isEqual(t.machineIdentifier,s)||i.isEqual(t.product,s)||i.isEqual(t.name,s)||i.isEqual(t.host,s)||i.isEqual(t.address,s))return e=t.machineIdentifier,!1})),e},this.isPlaySupported=t=>!i.isEmpty(this.getPlayService(t)),this.isPlexPlayerSupported=t=>{let e=!1;return this.getPlexPlayerMachineIdentifier(t)&&(e=!0),e||!i.isEqual(this.runBefore,!1)},this.isKodiSupported=t=>{if(t){const e=this.entityStates["sensor.kodi_media_sensor_search"]&&"unavailable"!==this.entityStates["sensor.kodi_media_sensor_search"].state;return this.entityStates[t]&&"off"!==this.entityStates[t].state&&"unavailable"!==this.entityStates[t].state&&e||!i.isEqual(this.runBefore,!1)&&e}return!1},this.isVLCTelnetSupported=t=>this.entityStates[t]&&!i.isNil(this.entityStates[t].attributes)&&"unavailable"!==this.entityStates[t].state||!i.isEqual(this.runBefore,!1),this.isSonosSupported=t=>this.entityStates[t]&&!i.isNil(this.entityStates[t].attributes)&&"unavailable"!==this.entityStates[t].state||!i.isEqual(this.runBefore,!1),this.isCastSupported=t=>this.entityStates[t]&&!i.isNil(this.entityStates[t].attributes)&&"unavailable"!==this.entityStates[t].state||!i.isEqual(this.runBefore,!1),this.isAndroidTVSupported=t=>this.entityStates[t]&&!i.isEqual(this.entityStates[t].state,"off")&&this.entityStates[t].attributes&&void 0!==this.entityStates[t].attributes.adb_response||!i.isEqual(this.runBefore,!1),this.entityRegistry=h,this.card=t,this.hass=e,this.plex=n,this.entity=r,this.shuffle=c,this.libraryName=l,!i.isEmpty(a)&&this.hass.states[a]&&(this.runBefore=a.split(".")),!i.isEmpty(o)&&this.hass.states[o]&&(this.runAfter=o.split(".")),this.refreshAvailableServicesPeriodically(),this.playActionButton.classList.add("detailPlayAction"),this.playActionButton.innerText="Play"}}class rt extends HTMLElement{constructor(){super(...arguments),this.plexPort=!1,this.plexProtocol="http",this.config={},this.ip=X(),this.token=X(),this.port=X(),this.maxCount=X(),this.maxRows=X(),this.displayTitleMain=document.createElement("select"),this.displaySubtitleMain=document.createElement("select"),this.useHorizontalScroll=document.createElement("select"),this.useShuffle=document.createElement("select"),this.minWidth=X(),this.minEpisodeWidth=X(),this.minExpandedWidth=X(),this.minExpandedHeight=X(),this.fontSize1=X(),this.fontSize2=X(),this.fontSize3=X(),this.fontSize4=X(),this.cardTitle=X(),this.libraryName=document.createElement("select"),this.protocol=document.createElement("select"),this.tabs=document.createElement("paper-tabs"),this.sort=document.createElement("select"),this.displayTypeData={},this.displayType=document.createElement("select"),this.sortOrder=document.createElement("select"),this.playTrailer=document.createElement("select"),this.showExtras=document.createElement("select"),this.showSearch=document.createElement("select"),this.runBefore=document.createElement("select"),this.runAfter=document.createElement("select"),this.entitiesSection=document.createElement("div"),this.devicesTabs=0,this.entities=[],this.scriptEntities=[],this.sections=[],this.collections=[],this.playlists=[],this.clients={},this.entitiesRegistry=!1,this.plexValidSection=document.createElement("div"),this.loaded=!1,this.livetv={},this.fireEvent=(t,e,i,n={})=>{i=null==i?{}:i;const s=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return s.detail=i,t.dispatchEvent(s),s},this.generateTitle=t=>{const e=document.createElement("h4");return e.innerText=t,e.style.marginBottom="0",e.style.marginTop="0",e.style.paddingTop="0",e.style.paddingBottom="0",e.style.color="rgb(225, 225, 225)",e.style.fontWeight="300",e.style.fontSize="12px",e},this.valueUpdated=()=>{const t=i.clone(this.config);if(this.config.protocol=this.protocol.value,this.config.ip=this.ip.value.replace(/^https?:\/\//i,"").replace(/\/$/,""),this.config.token=this.token.value,this.config.port=this.port.value,this.loaded&&(this.config.entity||(this.config.entity=[]),!i.isEmpty(this.libraryName.value))){this.config.libraryName=this.libraryName.value;let t="";i.isEqual(this.sortOrder.value,"Ascending")?t="asc":i.isEqual(this.sortOrder.value,"Descending")&&(t="desc"),i.isEmpty(t)||i.isEmpty(this.sort.value)?this.config.sort="":this.config.sort=`${this.sort.value}:${t}`,this.config.displayType=this.displayTypeData[this.displayType.value],i.isEmpty(this.maxCount.value)?this.config.maxCount="":this.config.maxCount=this.maxCount.value,i.isEmpty(this.maxRows.value)?this.config.maxRows="":this.config.maxRows=this.maxRows.value,i.isEmpty(this.useHorizontalScroll.value)?this.config.useHorizontalScroll="No":this.config.useHorizontalScroll=this.useHorizontalScroll.value,i.isEmpty(this.useShuffle.value)?this.config.useShuffle="No":this.config.useShuffle=this.useShuffle.value,i.isEmpty(this.displayTitleMain.value)?this.config.displayTitleMain="Yes":this.config.displayTitleMain=this.displayTitleMain.value,i.isEmpty(this.displaySubtitleMain.value)?this.config.displaySubtitleMain="Yes":this.config.displaySubtitleMain=this.displaySubtitleMain.value,i.isEmpty(this.minWidth.value)?this.config.minWidth="":this.config.minWidth=this.minWidth.value,i.isEmpty(this.minEpisodeWidth.value)?this.config.minEpisodeWidth="":this.config.minEpisodeWidth=this.minEpisodeWidth.value,i.isEmpty(this.minExpandedWidth.value)?this.config.minExpandedWidth="":this.config.minExpandedWidth=this.minExpandedWidth.value,i.isEmpty(this.fontSize1.value)?this.config.fontSize1="":this.config.fontSize1=this.fontSize1.value,i.isEmpty(this.fontSize2.value)?this.config.fontSize2="":this.config.fontSize2=this.fontSize2.value,i.isEmpty(this.fontSize3.value)?this.config.fontSize3="":this.config.fontSize3=this.fontSize3.value,i.isEmpty(this.fontSize4.value)?this.config.fontSize4="":this.config.fontSize4=this.fontSize4.value,i.isEmpty(this.minExpandedHeight.value)?this.config.minExpandedHeight="":this.config.minExpandedHeight=this.minExpandedHeight.value,i.isEmpty(this.cardTitle.value)?this.config.title="":this.config.title=this.cardTitle.value,i.isEmpty(this.entities)||(this.config.entity=[],i.forEach(this.entities,(t=>{i.isEmpty(t.value)||i.includes(this.config.entity,t.value)||this.config.entity.push(t.value)}))),i.isEqual(this.playTrailer.value,"Yes")?this.config.playTrailer=!0:i.isEqual(this.playTrailer.value,"No")?this.config.playTrailer=!1:i.isEqual(this.playTrailer.value,"Muted")&&(this.config.playTrailer="muted"),i.isEqual(this.showExtras.value,"Yes")?this.config.showExtras=!0:i.isEqual(this.showExtras.value,"No")&&(this.config.showExtras=!1),i.isEqual(this.showSearch.value,"Yes")?this.config.showSearch=!0:i.isEqual(this.showSearch.value,"No")&&(this.config.showSearch=!1),this.config.runBefore=this.runBefore.value,this.config.runAfter=this.runAfter.value}i.isEqual(this.config,t)||this.fireEvent(this,"config-changed",{config:this.config})},this.render=async()=>{const t=(t,e="",n=!1)=>{i.isEmpty(e)&&(e=t);const s=document.createElement("option");return s.innerHTML=e.replace(/ /g,"&nbsp;"),s.label=t,s.value=t,n&&(s.disabled=!0),s},e=(e,n)=>{if(this.entitiesRegistry){const s=document.createElement("div"),r=document.createElement("select");r.appendChild(t(""));const a=[];return i.forEach(this.entitiesRegistry,(e=>{if(i.isEqual(e.platform,"cast")||i.isEqual(e.platform,"kodi")||i.isEqual(e.platform,"androidtv")||i.isEqual(e.platform,"input_select")||i.isEqual(e.platform,"input_text")||i.isEqual(e.platform,"vlc_telnet")||i.isEqual(e.platform,"sonos")){const i=`${e.platform} | ${e.entity_id}`;r.appendChild(t(i)),a.push(i)}})),i.forEach(this.clients,(e=>{const i=`plexPlayer | ${e.name} | ${e.address} | ${e.machineIdentifier}`;r.appendChild(t(i)),a.push(i)})),i.isArray(this.config.entity)&&i.forEach(this.config.entity,(e=>{i.includes(a,e)||(r.appendChild(t(e)),a.push(e))})),r.label="Entity",r.value=e,r.style.width="100%",r.style.height="40px",r.className="entitiesDropDown",r.addEventListener("change",n),this.entities.push(r),s.appendChild(this.generateTitle("Entity")),s.appendChild(r),s}return!1};this.content&&this.content.remove(),this.hassObj&&!this.entitiesRegistry&&(i.forOwn(this.hassObj.states,((t,e)=>{i.startsWith(e,"script.")&&this.scriptEntities.push(e)})),this.entitiesRegistry=await Y(this.hassObj.connection)),this.entities=[],this.content=document.createElement("div");const n=document.createElement("h2");n.innerHTML="Plex Configuration",n.style.margin="0px",n.style.padding="0px",this.content.appendChild(n),this.content.appendChild(this.generateTitle("Plex Protocol")),this.protocol.innerHTML="";const s=location.protocol;i.isEqual(s,"http:")&&this.protocol.appendChild(t("http")),this.protocol.appendChild(t("https")),this.protocol.style.width="100%",this.protocol.style.height="40px",this.protocol.addEventListener("change",this.valueUpdated),i.isEmpty(this.config.protocol)?i.isEqual(s,"http:")?this.protocol.value="http":this.protocol.value="https":this.protocol.value=this.config.protocol,this.content.appendChild(this.protocol),this.ip.style.width="100%",this.ip.style.marginTop="10px",this.ip.style.marginBottom="10px",this.ip.label="Plex IP Address / Hostname",this.config.ip?this.ip.value=this.config.ip.replace(/^https?:\/\//i,"").replace(/\/$/,""):this.ip.value=this.config.ip,this.ip.addEventListener("change",this.valueUpdated),this.content.appendChild(this.ip),this.port.label="Plex Port (Optional)",this.port.value=this.config.port,this.port.type="number",this.port.addEventListener("change",this.valueUpdated),this.content.appendChild(this.port),this.token.label="Plex Token",this.token.value=this.config.token,this.token.addEventListener("change",this.valueUpdated),this.content.appendChild(this.token),this.content.appendChild(this.generateTitle("Plex Library")),this.libraryName.innerHTML="",this.libraryName.appendChild(t("Smart Libraries","",!0)),this.libraryName.appendChild(t("Continue Watching")),this.libraryName.appendChild(t("Deck")),this.libraryName.appendChild(t("Recently Added")),this.libraryName.appendChild(t("Watch Next")),this.libraryName.disabled=!0,this.libraryName.style.width="100%",this.libraryName.style.height="40px",this.libraryName.addEventListener("change",this.valueUpdated);const r=document.createElement("div");r.style.color="red",this.content.appendChild(this.libraryName),this.content.appendChild(r),this.appendChild(this.content),this.plex=new V(this.config.ip.replace(/^https?:\/\//i,"").replace(/\/$/,""),this.plexPort,this.config.token,this.plexProtocol,this.config.sort),this.sections=await this.plex.getSections(),i.forEach(this.sections,(e=>!i.isEqual(e.title,this.config.libraryName)||!i.isEqual(e.type,"artist")||(this.content.appendChild(this.generateTitle("Use shuffle when playing")),this.useShuffle.innerHTML="",this.useShuffle.appendChild(t("Yes")),this.useShuffle.appendChild(t("No")),this.useShuffle.slot="dropdown-content",this.useShuffle.label="Use shuffle when playing",this.useShuffle.style.width="100%",this.useShuffle.style.height="40px",this.useShuffle.addEventListener("change",this.valueUpdated),i.isEmpty(this.config.useShuffle)?this.useShuffle.value="No":this.useShuffle.value=this.config.useShuffle,this.content.appendChild(this.useShuffle),!1))),this.livetv=await this.plex.getLiveTV(),this.collections=await this.plex.getCollections(),this.playlists=await this.plex.getPlaylists(),this.clients=await this.plex.getClients(),this.plexValidSection.style.display="none",this.plexValidSection.innerHTML="";let a=!0,o=!0;if(i.isArray(this.config.entity))i.forEach(this.config.entity,(t=>{if(i.isObjectLike(t))return o=!i.includes(i.keys(this.config.entity),"plexPlayer"),a=!1,!1}));else if(i.isObjectLike(this.config.entity)&&(o=!i.includes(i.keys(this.config.entity),"plexPlayer"),a=!1,o)){const t=[];a=!0,i.isObjectLike(this.config.entity)&&i.forOwn(this.config.entity,(e=>{i.isString(e)?t.push(e):i.isArray(e)&&i.forEach(e,(e=>{t.push(e)}))})),this.config.entity=t}const l=document.createElement("h2");if(l.innerHTML="Devices Configuration",l.style.lineHeight="29px",l.style.marginBottom="0px",l.style.marginTop="20px",a){const t=document.createElement("button");t.style.float="right",t.style.fontSize="20px",t.style.cursor="pointer",t.innerHTML="+",t.addEventListener("click",(()=>{const t=e("",this.valueUpdated);t&&this.entitiesSection.appendChild(t)})),l.appendChild(t)}if(this.plexValidSection.appendChild(l),this.entitiesSection.innerHTML="",this.plexValidSection.appendChild(this.entitiesSection),a)i.isString(this.config.entity)&&(this.config.entity=[this.config.entity]),i.isArray(this.config.entity)&&i.forEach(this.config.entity,(t=>{if(i.isString(t)){const i=e(t,this.valueUpdated);i&&this.entitiesSection.appendChild(i)}}));else{const t=document.createElement("div");t.innerHTML="Devices configuration is not available when using plexPlayer client device.<br/>You can edit any other settings through UI and use <b>Show code editor</b> to edit entities.<br/><br/>If you are not using server settings for plexPlayer with <b>identifier</b> and <b>server</b> key, you can migrate your settings to UI by removing plexPlayer section and readd through UI.",this.plexValidSection.appendChild(t)}const h=document.createElement("h2");if(h.innerHTML="View Configuration",h.style.lineHeight="29px",h.style.marginBottom="0px",h.style.marginTop="20px",this.plexValidSection.appendChild(h),this.displayType.innerHTML="",this.displayType.style.width="100%",this.displayType.style.height="40px",this.displayType.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.generateTitle("Display Type (Optional)")),this.plexValidSection.appendChild(this.displayType),this.cardTitle.label="Card title (Optional)",this.cardTitle.value=this.config.title,this.cardTitle.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.cardTitle),this.maxCount.label="Maximum number of items to display (Optional)",this.maxCount.value=this.config.maxCount,this.maxCount.type="number",this.maxCount.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.maxCount),this.useHorizontalScroll.innerHTML="",this.plexValidSection.appendChild(this.generateTitle("Use horizontal scroll")),this.useHorizontalScroll.appendChild(t("Yes")),this.useHorizontalScroll.appendChild(t("No")),this.useHorizontalScroll.style.width="100%",this.useHorizontalScroll.style.height="40px",this.useHorizontalScroll.addEventListener("change",this.valueUpdated),i.isEmpty(this.config.useHorizontalScroll)?this.useHorizontalScroll.value="No":this.useHorizontalScroll.value=this.config.useHorizontalScroll,this.plexValidSection.appendChild(this.useHorizontalScroll),this.maxRows.label="Maximum number of rows to display (Optional)",this.maxRows.value=this.config.maxRows,this.maxRows.type="number",this.maxRows.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.maxRows),this.sort.innerHTML="",this.sort.style.width="100%",this.sort.style.height="40px",this.sort.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.generateTitle("Sort")),this.plexValidSection.appendChild(this.sort),this.sortOrder.innerHTML="",this.sortOrder.appendChild(t("Ascending")),this.sortOrder.appendChild(t("Descending")),this.plexValidSection.appendChild(this.generateTitle("Sort Order")),this.sortOrder.style.width="100%",this.sortOrder.style.height="40px",this.sortOrder.addEventListener("change",this.valueUpdated),i.isEmpty(this.config.sort))this.sortOrder.value="Ascending";else{const t=this.config.sort.split(":")[1];i.isEmpty(t)||i.isEqual(t,"asc")?this.sortOrder.value="Ascending":i.isEqual(t,"desc")&&(this.sortOrder.value="Descending")}this.plexValidSection.appendChild(this.sortOrder),this.plexValidSection.appendChild(this.generateTitle("Play Trailer")),this.playTrailer.innerHTML="",this.playTrailer.appendChild(t("Yes")),this.playTrailer.appendChild(t("Muted")),this.playTrailer.appendChild(t("No")),this.playTrailer.style.width="100%",this.playTrailer.style.height="40px",this.playTrailer.addEventListener("change",this.valueUpdated);let c="Yes";i.isEqual(this.config.playTrailer,"muted")?c="Muted":this.config.playTrailer||(c="No"),this.playTrailer.value=c,this.plexValidSection.appendChild(this.playTrailer),this.showExtras.innerHTML="",this.showExtras.appendChild(t("Yes")),this.showExtras.appendChild(t("No")),this.plexValidSection.appendChild(this.generateTitle("Show Extras")),this.showExtras.style.width="100%",this.showExtras.style.height="40px",this.showExtras.addEventListener("change",this.valueUpdated);let u="Yes";this.config.showExtras||(u="No"),this.showExtras.value=u,this.plexValidSection.appendChild(this.showExtras),this.showSearch.innerHTML="",this.showSearch.appendChild(t("Yes")),this.showSearch.appendChild(t("No")),this.plexValidSection.appendChild(this.generateTitle("Show Search")),this.showSearch.style.width="100%",this.showSearch.style.height="40px",this.showSearch.addEventListener("change",this.valueUpdated);let d="Yes";this.config.showSearch||(d="No"),this.showSearch.value=d,this.plexValidSection.appendChild(this.showSearch),this.runBefore.innerHTML="",this.runBefore.appendChild(t("")),i.forEach(this.scriptEntities,(e=>{this.runBefore.appendChild(t(e))})),this.plexValidSection.appendChild(this.generateTitle("Script to execute before starting the media (Optional)")),this.runBefore.style.width="100%",this.runBefore.style.height="40px",this.runBefore.addEventListener("change",this.valueUpdated),this.runBefore.value=this.config.runBefore,this.plexValidSection.appendChild(this.runBefore),this.runAfter.innerHTML="",this.runAfter.appendChild(t("")),i.forEach(this.scriptEntities,(e=>{this.runAfter.appendChild(t(e))})),this.plexValidSection.appendChild(this.generateTitle("Script to execute after starting the media (Optional)")),this.runAfter.style.width="100%",this.runAfter.style.height="40px",this.runAfter.addEventListener("change",this.valueUpdated),this.runAfter.value=this.config.runAfter,this.plexValidSection.appendChild(this.runAfter);const p=document.createElement("h2");if(p.innerHTML="Style Configuration",p.style.lineHeight="29px",p.style.marginBottom="0px",p.style.marginTop="20px",this.plexValidSection.appendChild(p),this.minWidth.label="Minimum width of the card (Optional)",this.minWidth.value=this.config.minWidth,this.minWidth.type="number",this.minWidth.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.minWidth),this.minExpandedWidth.label="Expanded width of the card (Optional)",this.minExpandedWidth.value=this.config.minExpandedWidth,this.minExpandedWidth.type="number",this.minExpandedWidth.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.minExpandedWidth),this.minExpandedHeight.label="Expanded height of the card (Optional)",this.minExpandedHeight.value=this.config.minExpandedHeight,this.minExpandedHeight.type="number",this.minExpandedHeight.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.minExpandedHeight),this.minEpisodeWidth.label="Minimum width of the episode card (Optional)",this.minEpisodeWidth.value=this.config.minEpisodeWidth,this.minEpisodeWidth.type="number",this.minEpisodeWidth.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.minEpisodeWidth),this.displayTitleMain.innerHTML="",this.displayTitleMain.appendChild(t("Yes")),this.displayTitleMain.appendChild(t("No")),this.plexValidSection.appendChild(this.generateTitle("Display title under poster")),this.displayTitleMain.style.width="100%",this.displayTitleMain.style.height="40px",this.displayTitleMain.addEventListener("change",this.valueUpdated),i.isEmpty(this.config.displayTitleMain)?this.displayTitleMain.value="Yes":this.displayTitleMain.value=this.config.displayTitleMain,this.plexValidSection.appendChild(this.displayTitleMain),this.fontSize1.label="Font size used in titles under cards (Optional)",this.fontSize1.value=this.config.fontSize1,this.fontSize1.type="number",this.fontSize1.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.fontSize1),this.displaySubtitleMain.innerHTML="",this.displaySubtitleMain.appendChild(t("Yes")),this.displaySubtitleMain.appendChild(t("No")),this.plexValidSection.appendChild(this.generateTitle("Display sub-title under poster")),this.displaySubtitleMain.style.width="100%",this.displaySubtitleMain.style.height="40px",this.displaySubtitleMain.addEventListener("change",this.valueUpdated),i.isEmpty(this.config.displaySubtitleMain)?this.displaySubtitleMain.value="Yes":this.displaySubtitleMain.value=this.config.displaySubtitleMain,this.plexValidSection.appendChild(this.displaySubtitleMain),this.fontSize2.label="Font size used in sub-titles under cards (Optional)",this.fontSize2.value=this.config.fontSize2,this.fontSize2.type="number",this.fontSize2.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.fontSize2),this.fontSize3.label="Font size used in title of the opened content (Optional)",this.fontSize3.value=this.config.fontSize3,this.fontSize3.type="number",this.fontSize3.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.fontSize3),this.fontSize4.label="Font size used in sub-titles, to-view count and description of the opened content (Optional)",this.fontSize4.value=this.config.fontSize4,this.fontSize4.type="number",this.fontSize4.addEventListener("change",this.valueUpdated),this.plexValidSection.appendChild(this.fontSize4),i.isEmpty(this.livetv)||(this.libraryName.appendChild(t("Live TV","",!0)),i.forEach(i.keys(this.livetv),(e=>{i.isEqual(this.config.libraryName,e)&&(r.innerHTML=`Warning: ${this.config.libraryName} play action currently only supported with Kodi.<br/>You might also need custom build of kodi-media-sensors, see <a href="https://github.com/JurajNyiri/PlexMeetsHomeAssistant/blob/main/DETAILED_CONFIGURATION.md#kodi" target="_blank">detailed configuration</a> for more information.`),this.libraryName.appendChild(t(e))}))),!i.isEmpty(this.sections)){this.libraryName.appendChild(t("Libraries","",!0)),i.forEach(this.sections,(e=>{this.libraryName.appendChild(t(e.title))})),i.isEmpty(this.collections)||(this.libraryName.appendChild(t("Collections","",!0)),i.forEach(this.collections,(e=>{this.libraryName.appendChild(t(e.title))}))),i.isEmpty(this.playlists)||(this.libraryName.appendChild(t("Playlists","",!0)),i.forEach(this.playlists,(e=>{this.libraryName.appendChild(t(e.title))}))),this.libraryName.disabled=!1,this.libraryName.value=this.config.libraryName;let e="";if(i.forEach(this.sections,(t=>{if(i.isEqual(t.title,this.libraryName.value))return e=t.key,!1})),i.isEmpty(e))this.displayType.style.display="none",this.config.displayType="",this.displayType.value="",this.sort.style.display="none",this.sortOrder.style.display="none",this.config.sort="";else{const n=await this.plex.getSectionData(e),s=i.get(n,"[0].Meta.Type");if(!i.isNil(s)&&s.length>1){let e=0;this.displayType.appendChild(t("",""));let r=!1;i.forEach(s,(s=>{if("track"!==s.type&&"episode"!==s.type&&("folder"!==s.type||"folder"===s.type&&i.isEqual(i.get(n,"[0].viewGroup"),"artist"))){let n=s.key.split("type=")[1];"folder"===s.type&&(n="folder"),i.isEqual(n,this.config.displayType)&&(r=!0),this.displayTypeData[s.title]=n,this.displayType.appendChild(t(s.title)),e+=1}})),e>1?(this.displayType.style.display="block",i.isEmpty(this.config.displayType)||!r?this.displayType.value="":i.forEach(this.displayTypeData,((t,e)=>{i.isEqual(t,this.config.displayType)&&(this.displayType.value=e)}))):(this.displayType.style.display="none",this.config.displayType="",this.displayType.value="")}else this.displayType.style.display="none",this.config.displayType="",this.displayType.value="";let r=0;this.config.displayType&&i.forEach(s,((t,e)=>{t.key.split("type=")[1]===parseInt(this.config.displayType,10)&&(r=parseInt(e,10))}));const a=i.get(n,`[0].Meta.Type[${r}].Sort`);!i.isNil(a)&&a.length>0&&"folder"!==this.config.displayType?(i.forEach(a,(e=>{this.sort.appendChild(t(e.key))})),this.sort.style.display="block",this.sortOrder.style.display="block"):(this.sort.style.display="none",this.sortOrder.style.display="none",this.config.sort="")}if(i.isEmpty(this.config.sort))this.sort.value="",this.sortOrder.value="";else{this.sort.value=this.config.sort.split(":")[0];const t=this.config.sort.split(":")[1];i.isEmpty(t)||i.isEqual(t,"asc")?this.sortOrder.value="Ascending":i.isEqual(t,"desc")&&(this.sortOrder.value="Descending")}this.plexValidSection.style.display="block"}this.loaded=!0,this.content.appendChild(this.plexValidSection)},this.setConfig=t=>{this.config=JSON.parse(JSON.stringify(t)),t.port&&!i.isEqual(t.port,"")?this.plexPort=t.port:this.plexPort=!1;const e=location.protocol;t.protocol?this.plexProtocol=t.protocol:i.isEqual(e,"http:")?this.config.protocol="http":this.config.protocol="https",t.sort||(this.config.sort="titleSort:asc"),t.displayType||(this.config.displayType=""),i.isNil(t.playTrailer)?this.config.playTrailer=!0:this.config.playTrailer=t.playTrailer,i.isNil(t.showExtras)?this.config.showExtras=!0:this.config.showExtras=t.showExtras,i.isNil(t.showSearch)?this.config.showSearch=!0:this.config.showSearch=t.showSearch,i.isNil(t.runBefore)||(this.config.runBefore=t.runBefore),i.isNil(t.runAfter)||(this.config.runAfter=t.runAfter),i.isNil(t.title)||(this.config.title=t.title),i.isNumber(this.config.maxCount)&&(this.config.maxCount=`${this.config.maxCount}`),i.isNumber(this.config.maxRows)&&(this.config.maxRows=`${this.config.maxRows}`),i.isNil(this.config.useHorizontalScroll)||(this.config.useHorizontalScroll=`${this.config.useHorizontalScroll}`),i.isNil(this.config.useShuffle)||(this.config.useShuffle=`${this.config.useShuffle}`),i.isNil(this.config.displayTitleMain)||(this.config.displayTitleMain=`${this.config.displayTitleMain}`),i.isNil(this.config.displaySubtitleMain)||(this.config.displaySubtitleMain=`${this.config.displaySubtitleMain}`),i.isNumber(this.config.minWidth)&&(this.config.minWidth=`${this.config.minWidth}`),i.isNumber(this.config.minEpisodeWidth)&&(this.config.minEpisodeWidth=`${this.config.minEpisodeWidth}`),i.isNumber(this.config.minExpandedWidth)&&(this.config.minExpandedWidth=`${this.config.minExpandedWidth}`),i.isNumber(this.config.fontSize1)&&(this.config.fontSize1=`${this.config.fontSize1}`),i.isNumber(this.config.fontSize2)&&(this.config.fontSize2=`${this.config.fontSize2}`),i.isNumber(this.config.fontSize3)&&(this.config.fontSize3=`${this.config.fontSize3}`),i.isNumber(this.config.fontSize4)&&(this.config.fontSize4=`${this.config.fontSize4}`),i.isNumber(this.config.minExpandedHeight)&&(this.config.minExpandedHeight=`${this.config.minExpandedHeight}`),this.render()},this.configChanged=t=>{const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e)}}set hass(t){this.hassObj=t}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/String(Math.random()).slice(2),
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/
window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t});
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/
let at=!1;(()=>{try{const t={get capture(){return at=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})(),
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/
"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.0")
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/,void 0===window.ShadyCSS||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.")
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/,window.JSCompiler_renameProperty=(t,e)=>t
/**
@license
Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt 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
*/;const ot=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,lt=Symbol();class ht{constructor(t,e){if(e!==lt)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(ot?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* 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
*/
(window.litElementVersions||(window.litElementVersions=[])).push("2.5.0");const ct=document.createElement("style");ct.textContent=((t,...e)=>{const i=e.reduce(((e,i,n)=>e+(t=>{if(t instanceof ht)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[n+1]),t[0]);return new ht(i,lt)})`
.maxZIndex {
z-index: 6 !important;
}
.transparent {
visibility: hidden !important;
}
.detailPlayAction {
color: rgb(15 17 19);
font-weight: bold;
float: left;
padding: 7px 10px;
border-radius: 5px;
cursor: pointer;
position: relative;
background: orange;
border: none;
margin-right: 10px;
}
.detailPlayAction.disabled {
cursor: default;
background-color: gray;
color: white;
}
.detailPlayTrailerAction {
color: rgb(15 17 19);
font-weight: bold;
float: left;
padding: 7px 10px;
border-radius: 5px;
cursor: pointer;
position: relative;
background: orange;
border: none;
visibility: hidden;
}
.seasons {
z-index: 5;
position: absolute;
top: ${n.expandedHeight+16}px;
width: calc(100% - 22px);
left: 0;
padding: 16px;
display: none;
}
.episodes {
z-index: 5;
position: absolute;
top: ${n.expandedHeight+16}px;
width: calc(100% - 22px);
left: 0;
padding: 16px;
display: none;
}
.additionalElem {
color: hsla(0, 0%, 100%, 0.45);
position: relative;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.ratingDetail {
background: #ffffff24;
padding: 5px 10px;
border-radius: 5px;
white-space: nowrap;
margin-bottom: 10px;
float: left;
margin-right: 10px;
}
.contentRatingDetail {
background: #ffffff24;
padding: 5px 10px;
border-radius: 5px;
margin-right: 10px;
white-space: nowrap;
float: left;
margin-bottom: 10px;
}
.clear {
clear: both;
}
.minutesDetail {
background: #ffffff24;
padding: 5px 10px;
border-radius: 5px;
margin-right: 10px;
white-space: nowrap;
float: left;
margin-bottom: 10px;
}
.detail .metaInfo {
display: block;
float: left;
}
.detail h2 {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
position: relative;
margin: 5px 0px 10px 0px;
font-size: 16px;
}
.detail h1 {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
position: relative;
padding: 5px 0px;
margin: 16px 0 10px 0;
}
.detail::-webkit-scrollbar {
display: none;
}
.detail {
-ms-overflow-style: none;
scrollbar-width: none;
}
.searchContainer {
position: relative;
z-index: 2;
padding-right: 8px;
}
.searchContainer input {
width: calc(100% - 26px);
padding: 10px;
margin-bottom: 10px;
}
.detail {
visibility: hidden;
max-height: ${n.expandedHeight+16}px;
display: block;
overflow: scroll;
text-overflow: ellipsis;
}
.detailDesc {
position: relative;
}
.lds-ring {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ring div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid orange;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: orange transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
animation-delay: -0.15s;
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.trackContainer {
width: 100%;
}
.trackContainer.odd:hover,
.trackContainer.even:hover {
background-color: rgba(255, 255, 255, 0.2);
}
.trackInteractiveArea {
width: 14px;
height: 14px;
}
.trackInteractiveArea button[name='playButton'] {
width: 30px;
height: 30px;
top: inherit;
left: inherit;
margin-top: -7px;
margin-left: -3px;
}
.trackContainer.odd:hover .trackIndexElem .trackIndex,
.trackContainer.even:hover .trackIndexElem .trackIndex {
display: none;
}
.trackContainer.odd:hover .trackIndexElem .trackInteractiveArea,
.trackContainer.even:hover .trackIndexElem .trackInteractiveArea {
display: block;
}
.trackContainer.odd .trackIndexElem .trackInteractiveArea,
.trackContainer.even .trackIndexElem .trackInteractiveArea {
display: none;
}
.trackContainer.odd {
background-color: rgba(255, 255, 255, 0.08);
}
.trackContainer.even {
background-color: rgba(255, 255, 255, 0.04);
}
.trackLengthElem {
position: relative;
padding: 15px 20px 15px 10px;
}
.trackIndexElem {
position: relative;
padding: 15px 20px 15px 10px;
}
.trackTitleElem {
width: 100%;
}
.detail {
position: absolute;
left: 247px;
width: calc(100% - 267px);
z-index: 5;
transition: 0.5s;
color: rgba(255, 255, 255, 0);
}
.contentbg {
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0);
z-index: 0;
transition: 0.5s;
left: 0;
top: 0;
background-size: cover;
display: none;
}
.stop-scrolling {
height: 100%;
overflow: hidden;
}
.contentArt {
position: absolute;
background-color: rgba(0, 0, 0, 0);
z-index: 2;
left: 0;
top: 0;
background-size: cover;
display: none;
-webkit-animation: fadein 0.5s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 0.5s; /* Firefox < 16 */
-ms-animation: fadein 0.5s; /* Internet Explorer */
-o-animation: fadein 0.5s; /* Opera < 12.1 */
animation: fadein 0.5s;
}
.yearElem {
color: hsla(0, 0%, 100%, 0.45);
position: relative;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.viewProgress {
background: #e5a00d;
height: 3px;
bottom: 0;
position: absolute;
}
.toViewEpisode {
position: relative;
height: 28px;
width: 28px;
float: right;
display: block;
background: #e5a00d;
font-weight: bold;
color: black;
transition: 0.5s;
right: -14px;
top: -14px;
transform: rotate(45deg);
}
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Firefox < 16 */
@-moz-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Safari, Chrome and Opera > 12.1 */
@-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Internet Explorer */
@-ms-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Opera < 12.1 */
@-o-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.toViewSeason {
position: relative;
top: 5px;
right: 5px;
float: right;
display: block;
border-radius: 5px;
background: #e5a00d;
font-weight: bold;
color: black;
padding: 1px 6px;
transition: 0.5s;
}
.seasonTitleElem {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
position: relative;
font-weight: bold;
margin-top: 5px;
transition: 0.5s;
color: white;
}
.episodeTitleElem {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
position: relative;
font-weight: bold;
margin-top: 5px;
transition: 0.5s;
color: white;
}
.seasonEpisodesCount {
transition: 0.5s;
color: white;
}
.episodeNumber {
color: white;
}
.titleElem {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
position: relative;
min-width: 100% !important;
}
.seasonContainer {
position: relative;
float: left;
margin-right: 10px;
margin-bottom: 15px;
transition: 0.5s;
}
.episodeContainer {
position: relative;
float: left;
margin-right: 10px;
margin-bottom: 15px;
transition: 0.5s;
}
.metaInfoDetails {
color: hsla(0, 0%, 98%, 0.45);
text-transform: uppercase;
margin-top: 10px;
}
.simulatedFullScreen {
background: black;
height: 100%;
}
.episodeElem {
background-repeat: no-repeat;
background-size: contain;
border-radius: 5px;
transition: 0.5s;
background: black;
overflow: hidden;
}
.seasonElem {
background-repeat: no-repeat;
background-size: contain;
border-radius: 5px;
transition: 0.5s;
}
.contentContainer {
overflow: hidden;
}
.movieElem {
margin-bottom: 5px;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
border-radius: 5px;
transition: 0.5s;
position: relative;
z-index: 1;
}
.plexMeetsContainer {
z-index: 1;
float: left;
margin-right: 10px;
transition: 0.5s;
}
.no-transparency {
background-color: rgba(0, 0, 0, 1) !important;
}
.videobg1 {
position: absolute;
background-image: linear-gradient(rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.2));
height: 50%;
top: 0;
width: 100%;
}
.videobg2 {
position: absolute;
background-image: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 1));
height: 50%;
top: 50%;
width: 100%;
}
.video {
position: absolute;
z-index: 3;
visibility: hidden;
}
.movieExtras {
z-index: 5;
position: absolute;
top: 340px;
width: calc(100% - 32px);
left: 0;
padding: 16px;
}
.interactiveArea {
position: relative;
width: 100%;
height: 100%;
transition: 0.5s;
}
.interactiveArea:hover {
background: rgba(0, 0, 0, 0.3);
}
.movieElem .interactiveArea button[name='playButton'].touchDevice,
.seasonElem .interactiveArea button[name='playButton'].touchDevice,
button[name='playButton'].disabled {
display: none !important;
}
.episodeElem .interactiveArea button[name='playButton'].touchDevice {
display: block;
outline: 0;
background: orange !important;
border: 2px solid orange !important;
box-shadow: 0 0 0 3px orange !important;
}
button[name='playButton'] {
width: 40px;
height: 40px;
border: 2px solid white;
border-radius: 100%;
cursor: pointer;
transition: 0.2s;
margin: 0 auto;
left: calc(50% - 20px);
display: block;
top: calc(50% - 20px);
position: absolute;
}
button[name='playButton']:hover {
background: orange !important;
border: 2px solid orange !important;
}
button[name='playButton']:focus {
outline: 0;
background: orange !important;
border: 2px solid orange !important;
box-shadow: 0 0 0 3px orange !important;
}
button[name='playButton']::after {
content: '';
display: inline-block;
position: relative;
top: 1px;
left: 2px;
border-style: solid;
border-width: 6px 0 6px 12px;
border-color: transparent transparent transparent white;
transition: 0.2s;
}
.interactiveArea button[name='playButton'] {
background: rgba(0, 0, 0, 0);
border: 2px solid rgba(255, 255, 255, 0);
}
.interactiveArea:hover button[name='playButton'] {
background: rgba(0, 0, 0, 0.4);
border: 2px solid rgba(255, 255, 255, 1);
}
.interactiveArea button[name='playButton']:after {
border-color: transparent transparent transparent rgba(255, 255, 255, 0);
}
.episodeElem > .interactiveArea > button[name='playButton'].touchDevice:after {
border-color: transparent transparent transparent rgba(255, 255, 255, 1);
}
.interactiveArea:hover button[name='playButton']:after {
border-color: transparent transparent transparent rgba(255, 255, 255, 1);
}
button[name='playButton']:hover:after {
border-color: transparent transparent transparent black !important;
}
button[name='playButton']:focus:after {
border-color: transparent transparent transparent black !important;
}
`.cssText;class ut extends HTMLElement{constructor(){super(...arguments),this.renderPageRetries=0,this.searchInputElem=document.createElement("input"),this.plexProtocol="http",this.displayType=!1,this.useHorizontalScroll=!1,this.useShuffle=!1,this.displayTitleMain=!0,this.displaySubtitleMain=!0,this.plexPort=!1,this.epgData={},this.detailsShown=!1,this.entityRegistry=[],this.runBefore="",this.playTrailer=!0,this.showExtras=!0,this.isVisible=!0,this.showSearch=!0,this.previousPageWidth=0,this.runAfter="",this.columnsCount=0,this.renderedRows=0,this.renderedItems=0,this.maxRenderCount=!1,this.minWidth=n.minimumWidth,this.minEpisodeWidth=n.minimumEpisodeWidth,this.minExpandedWidth=n.expandedWidth,this.minExpandedHeight=n.expandedHeight,this.fontSize1=14,this.fontSize2=14,this.fontSize3=28,this.fontSize4=16,this.seasonContainerClickEnabled=!0,this.looseSearch=!1,this.movieElems=[],this.searchValue="",this.activeMovieElemData={},this.seasonElemFreshlyLoaded=!1,this.episodesElemFreshlyLoaded=!1,this.seasonsElemHidden=!0,this.episodesElemHidden=!0,this.data={},this.config={},this.loading=!1,this.maxCount=!1,this.maxRows=!1,this.error="",this.contentBGHeight=0,this.initialDataLoaded=!1,this.haWindow=ut.querySelectorAllShadows("hui-view")[0],this.renderNewElementsIfNeeded=()=>{const t=K(this.content);let{scrollTop:e}=this.haWindow;e<window.scrollY&&(e=window.scrollY),!this.detailsShown&&window.innerHeight+e>t-300&&this.renderedItems>0&&this.renderedItems<this.data[this.config.libraryName].length&&(!this.maxCount||this.renderedItems<this.maxCount)&&(!this.maxRows||this.renderedRows<this.config.maxRows)&&i.isEmpty(this.searchValue)&&(this.maxRenderCount=this.renderedItems+4*this.columnsCount,this.renderMovieElems(),this.calculatePositions())},this.resizeHandler=()=>{if(this.isVisible){if(!this.detailsShown){let t=!1;if(this.getElementsByClassName("videoPlayer")[0].children.length>0&&(t=Z(this)),this.card&&this.movieElems.length>0&&!t&&this.previousPageWidth!==this.card.offsetWidth){this.previousPageWidth=this.card.offsetWidth,this.renderPage();const t=this.getElementsByClassName("contentbg");this.contentBGHeight=K(t[0])}}this.renderNewElementsIfNeeded()}},this.loadInitialData=async()=>{this.initialDataLoaded=!0,setInterval((()=>{const t=!i.isNull(this.offsetParent);t&&!this.isVisible&&this.renderPage(),this.isVisible=t}),100),this.hassObj&&(this.entityRegistry=await Y(this.hassObj.connection));const t=()=>{if(this.detailsShown&&this.activeMovieElem&&!Z(this)&&this.isVisible){const t=this.getElementsByClassName("seasonContainer"),e=this.getElementsByClassName("episodeContainer"),n=this.getElementsByClassName("seasonElem");let s=this.activeMovieElem;i.forEach(n,(t=>{if(i.isEqual(t.dataset.clicked,"true"))return s=t,!1}));const r=parseInt(G(s).top,10)-70,a=((t,e,i)=>{const n=t[t.length-1],s=e[e.length-1];let r=!1;return t.length>0&&parseInt(i.style.top,10)>0?r=K(n)+parseInt(G(n).top,10)+10:e.length>0&&(r=K(s)+parseInt(G(s).top,10)+10),r})(t,e,s);this.getTop()<r?(window.scroll({top:r}),this.children[0].classList.add("stop-scrolling")):a&&(window.innerHeight<a-r?a&&this.getTop()+window.innerHeight>a&&(window.scroll({top:a-window.innerHeight}),this.children[0].classList.add("stop-scrolling")):-70!==r&&-10!==a&&(window.scroll({top:r}),this.children[0].classList.add("stop-scrolling")))}this.renderNewElementsIfNeeded()};this.haWindow.addEventListener("scroll",t),window.addEventListener("scroll",t),window.addEventListener("wheel",t),window.addEventListener("touchmove",t),window.addEventListener("resize",(()=>{this.resizeHandler()})),this.card&&(this.previousPageWidth=this.card.offsetWidth),this.resizeBackground()},this.renderInitialData=async()=>{let{entity:t}=JSON.parse(JSON.stringify(this.config));const e=(t,e)=>{let n=e,s=!1;i.startsWith(e,"plexPlayer | ")?(n=e.split(" | ")[3],s=!0):i.isPlainObject(e)?n=e[Object.keys(e)[0]]:(i.startsWith(e,"androidtv | ")||i.startsWith(e,"kodi | ")||i.startsWith(e,"cast | ")||i.startsWith(e,"input_select | ")||i.startsWith(e,"input_text | ")||i.startsWith(e,"vlc_telnet | ")||i.startsWith(e,"sonos | "))&&(n=e.split(" | ")[1],s=!1),s?(i.isNil(t.plexPlayer)&&(t.plexPlayer=[]),t.plexPlayer.push(n)):i.forEach(this.entityRegistry,(e=>{if(i.isEqual(e.entity_id,n))switch(e.platform){case"cast":i.isNil(t.cast)&&(t.cast=[]),t.cast.push(e.entity_id);break;case"androidtv":i.isNil(t.androidtv)&&(t.androidtv=[]),t.androidtv.push(e.entity_id);break;case"kodi":i.isNil(t.kodi)&&(t.kodi=[]),t.kodi.push(e.entity_id);break;case"input_select":i.isNil(t.inputSelect)&&(t.inputSelect=[]),t.inputSelect.push(e.entity_id);break;case"input_text":i.isNil(t.inputText)&&(t.inputText=[]),t.inputText.push(e.entity_id);break;case"vlc_telnet":i.isNil(t.vlcTelnet)&&(t.vlcTelnet=[]),t.vlcTelnet.push(e.entity_id);break;case"sonos":i.isNil(t.sonos)&&(t.sonos=[]),t.sonos.push(e.entity_id);break;default:console.error(`Entity ${e.entity_id} is not supported.`)}}))},n=t;i.isString(n)?(t={},e(t,n)):i.isArray(n)&&(t={},i.forEach(n,(i=>{e(t,i)}))),this.loading=!0,this.renderPage();try{if(this.plex&&this.hassObj){this.playController=new st(this,this.hassObj,this.plex,t,this.runBefore,this.runAfter,this.config.libraryName,this.entityRegistry,this.useShuffle),this.playController&&await this.playController.init(),await this.plex.init();const e=await this.plex.getSections(),n=async()=>{if(this.plex)try{const t=await this.plex.getOnDeck();this.data.Deck=t.Metadata}catch(t){if(!i.includes(t.message,"Request failed with status code 404"))throw t;console.warn(J("Deck"))}},s=async()=>{if(this.plex)try{const t=await this.plex.getContinueWatching();this.data["Continue Watching"]=t.Metadata}catch(t){if(!i.includes(t.message,"Request failed with status code 404"))throw t;console.warn(J("Continue Watching"))}},r=async()=>{if(this.plex)try{const t=await this.plex.getWatchNext();this.data["Watch Next"]=t.Metadata}catch(t){if(!i.includes(t.message,"Request failed with status code 404"))throw t;console.warn(J("Watch Next"))}},a=async()=>{if(this.plex)try{const t=await this.plex.getRecentyAdded();this.data["Recently Added"]=t.Metadata}catch(t){if(!i.includes(t.message,"Request failed with status code 404"))throw t;try{console.warn("PlexMeetsHomeAssistant: Using old endpoint for recently added tv shows. Consider updating your Plex server.");const t=await this.plex.getRecentyAdded(!0);this.data["Recently Added"]=t.Metadata}catch(t){if(!i.includes(t.message,"Request failed with status code 404"))throw t;console.warn(J("Recently Added"))}}},o=async()=>{if(this.plex){const t=await this.plex.getLiveTV();i.forEach(t,((t,e)=>{this.data[e]=t,i.forEach(this.data[e],((t,i)=>{this.data[e][i].type="epg"}))}))}},l=async()=>{this.plex&&(this.epgData=await this.plex.getEPG())};let h=!1;i.forEach(e,(t=>!i.isEqual(t.title,this.config.libraryName)||(h=t.key,!1)));const c=[];h&&c.push(this.plex.getSectionData(h,this.displayType)),i.isEqual(this.config.libraryName,"Deck")?c.push(n()):i.isEqual(this.config.libraryName,"Continue Watching")?c.push(s()):i.isEqual(this.config.libraryName,"Watch Next")?c.push(r()):i.isEqual(this.config.libraryName,"Recently Added")&&c.push(a()),c.push(o()),c.push(l());const[u]=await Promise.all(c);i.forEach(this.epgData,((t,e)=>{i.forEach(this.data[e],((t,n)=>{i.isNil(this.epgData[e][t.channelCallSign])||(this.data[e][n].epg=this.epgData[e][t.channelCallSign])}))})),u&&h&&i.forEach(u,(t=>{this.data[t.librarySectionTitle]=t.Metadata}));const d=await this.plex.getCollections();let p={};i.forEach(d,(t=>{this.plex&&i.isEqual(t.title,this.config.libraryName)&&(p=t)})),i.isNil(p.key)||(this.data[p.title]=await this.plex.getCollectionData(p.key));const f=await this.plex.getPlaylists();let y={};i.forEach(f,(t=>{this.plex&&i.isEqual(t.title,this.config.libraryName)&&(y=t)})),i.isNil(y.key)||(this.data[y.title]=await this.plex.getPlaylistData(y.key)),void 0===this.data[this.config.libraryName]&&(this.error=`Library name ${this.config.libraryName} does not exist.`),this.loading=!1,this.render()}else setTimeout((()=>{this.renderInitialData()}),250)}catch(t){this.error=`Plex server did not respond.<br/>Details of the error: ${F(t.message)}`,this.renderPage()}},this.render=()=>{this.renderPage()},this.searchInput=()=>{const t=document.createElement("div");return t.className="searchContainer",this.searchInputElem=document.createElement("input"),this.searchInputElem.type="text",this.searchInputElem.value=this.searchValue,this.searchInputElem.placeholder=`Search ${this.config.libraryName}...`,this.searchInputElem.addEventListener("keyup",(()=>{i.isEqual(this.searchInputElem.value,this.searchValue)||(this.searchValue=this.searchInputElem.value,this.renderPage(),this.focus())})),t.appendChild(this.searchInputElem),t},this.renderMovieElems=()=>{const t=(t,e,n,s)=>{const r=this.renderedRows,a=this.renderedItems,o=this.columnsCount;let l=0;this.contentContainer.style.width="";let h=0,c=(!this.maxCount||this.renderedItems<this.maxCount)&&(!this.maxRenderCount||this.renderedItems<this.maxRenderCount)&&(!this.maxRows||this.renderedRows<=this.maxRows),u=0;i.forEach(this.data[this.config.libraryName],(r=>{if(c=(!this.maxCount||this.renderedItems<this.maxCount)&&(!this.maxRenderCount||this.renderedItems<this.maxRenderCount)&&(!this.maxRows||this.renderedRows<=this.maxRows),c){const a=this.getMovieElement(r,e);let o=!1;if(this.looseSearch){let t=!1;i.forEach(n,(e=>{if(!i.isEmpty(e)&&i.includes(i.toUpper(r.title),i.toUpper(e))||i.includes(i.toUpper(r.parentTitle),i.toUpper(e))||i.includes(i.toUpper(r.grandparentTitle),i.toUpper(e)))return t=!0,!1})),(t||i.isEmpty(n[0]))&&(o=!0)}else(i.includes(i.toUpper(r.title),i.toUpper(this.searchValue))||i.includes(i.toUpper(r.parentTitle),i.toUpper(this.searchValue))||i.includes(i.toUpper(r.grandparentTitle),i.toUpper(this.searchValue))||i.includes(i.toUpper(r.tag),i.toUpper(this.searchValue))||i.includes(i.toUpper(i.get(r,"epg.title")),i.toUpper(this.searchValue)))&&(o=!0);if(o&&(u+=1,u>this.renderedItems)){if(t&&this.contentContainer.appendChild(a),this.useHorizontalScroll){this.renderedItems>0&&this.renderedItems%s==0&&(this.renderedRows+=1,a.style.clear="both");const t=10;(1===this.renderedRows||!this.maxRows||this.maxRows<2)&&(h+=parseFloat(a.style.width)+t)}this.renderedItems+=1}return t&&o&&l!==a.getBoundingClientRect().top&&!this.useHorizontalScroll&&(this.renderedRows+=1,0!==l&&0===this.columnsCount&&(this.columnsCount=this.renderedItems-1),l=a.getBoundingClientRect().top,!(t=>{const e=t.getBoundingClientRect(),i=e.top,n=e.bottom;return i>=0&&n<=window.innerHeight})(a)&&!this.maxRenderCount&&this.renderedItems>0&&(this.maxRenderCount=this.renderedItems-1+2*this.columnsCount)),this.maxRows&&this.renderedRows>this.maxRows&&!this.useHorizontalScroll&&a.remove(),!0}return!1}));const d={renderedItems:this.renderedItems};return t||(this.renderedRows=r,this.renderedItems=a,this.columnsCount=o),t&&h>0&&(this.contentContainer.style.width=`${h}px`),d},e=(!this.maxCount||this.renderedItems<this.maxCount)&&(!this.maxRenderCount||this.renderedItems<this.maxRenderCount)&&(!this.maxRows||this.renderedRows<=this.maxRows);if(this.data[this.config.libraryName]&&this.renderedItems<this.data[this.config.libraryName].length&&e){let e=this.data[this.config.libraryName].length,n=this.data[this.config.libraryName].length;this.maxCount&&(e=this.maxCount),n=e,this.maxRows&&(n=Math.ceil(e/this.maxRows));const s=i.split(this.searchValue," "),r=(t=>{let e=!1;return i.forEach(t,(t=>{if(i.isEqual(t.type,"episode"))return e=!0,!1})),e})(this.data[this.config.libraryName]),{renderedItems:a}=t(!1,r,s,n);n=a,this.maxRows&&(n=Math.ceil(a/this.maxRows)),t(!0,r,s,n)}const n=this.getElementsByClassName("contentbg")[0];this.contentBGHeight=K(n)},this.renderPage=()=>{if(this.searchInputElem.placeholder=`Search ${this.config.libraryName}...`,this.showSearch?this.searchInputElem.style.display="block":this.searchInputElem.style.display="none",this.card){const t=()=>this.card?this.card.getBoundingClientRect().width-parseInt(this.card.style.paddingRight,10)-parseInt(this.card.style.paddingLeft,10):0,e=t(),i=Math.floor(e/this.minWidth);if(e>0){const s=Math.floor(e/this.minEpisodeWidth);let r=11;i>7?r=10.3:i>3&&(r=10.7),n.width=e/i-r,n.height=n.width*n.ratio,n.episodeWidth=Math.floor(e/s-r),n.episodeHeight=Math.round(n.episodeWidth*n.episodeRatio),setTimeout((()=>{if(this.card){t()!==e&&this.renderPage()}}),1)}else this.renderPageRetries<10&&setTimeout((()=>{this.renderPageRetries+=1,this.renderPage()}),250)}this.renderedItems=0,this.renderedRows=0;const t=document.createElement("div");if(t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.innerHTML='<div class="lds-ring"><div></div><div></div><div></div><div></div></div>',this.content&&this.content.remove(),!this.card){this.card=document.createElement("ha-card"),this.card.style.transition="0.5s",this.card.style.overflow="hidden",this.card.style.padding="16px",this.card.style.paddingRight="6px";const t=document.createElement("h1");t.classList.add("card-header"),t.style.paddingRight="0px",t.style.paddingLeft="0px",t.style.paddingTop="0px",t.style.paddingBottom="0px";const e=document.createElement("div");e.classList.add("name"),e.textContent=this.config.title,t.appendChild(e),i.isNil(this.config.title)||i.isEmpty(this.config.title)?t.style.display="none":t.style.display="block",this.card.appendChild(t),this.card.appendChild(this.searchInput()),this.showSearch?this.searchInputElem.style.display="block":this.searchInputElem.style.display="none",this.appendChild(this.card)}this.content=document.createElement("div"),this.content.innerHTML=this.loadCustomStyles(),this.useHorizontalScroll&&(this.content.style.overflowX="auto",this.content.style.whiteSpace="nowrap"),""!==this.error?this.content.innerHTML+=`Error: ${this.error}`:this.data[this.config.libraryName]&&0===this.data[this.config.libraryName].length?this.content.innerHTML+=`Library ${F(this.config.libraryName)} has no items.`:this.loading&&(this.content.style.padding="16px 16px 16px",this.content.appendChild(t)),this.card.appendChild(this.content),this.contentContainer=document.createElement("div"),this.contentContainer.className="contentContainer",this.content.appendChild(this.contentContainer);const e=document.createElement("div");e.className="contentbg",this.contentContainer.appendChild(e);const s=document.createElement("div");s.className="contentArt";const r=document.createElement("div");r.className="videobg1",s.appendChild(r);const a=document.createElement("div");if(a.className="videobg2",s.appendChild(a),this.contentContainer.appendChild(s),this.detailElem=document.createElement("div"),this.detailElem.className="detail",this.detailElem.innerHTML="<h1 class='detailsTitle'></h1>\n\t\t\t<h2 class='detailsYear'></h2>\n\t\t\t<span class='metaInfo'></span>",this.playController){const t=this.playController.getPlayActionButton();t.style.fontSize=`${this.fontSize4}px`,t.style.lineHeight=`${this.fontSize4}px`,t.style.marginTop=this.fontSize4/4+"px",t.style.marginBottom=this.fontSize4/4+"px",t.style.marginRight=this.fontSize4/4+"px",t.style.padding=`${this.fontSize4/2}px ${this.fontSize4}px`,this.detailElem.appendChild(t)}this.detailElem.innerHTML+=`\n\t\t\t<button class='detailPlayTrailerAction'>Fullscreen Trailer</button>\n\t\t\t<div class='clear'></div>\n\t\t\t<span class='detailDesc'></span>\n\t\t\t<div class='clear'></div>\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='metaInfoDetails' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px;'>\n\t\t\t\t\t\tDirected by\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='metaInfoDetailsData'>\n\t\t\t\t\t\t...\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='metaInfoDetails' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px;'>\n\t\t\t\t\t\tWritten by\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='metaInfoDetailsData'>\n\t\t\t\t\t\t...\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='metaInfoDetails' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px;'>\n\t\t\t\t\t\tStudio\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='metaInfoDetailsData'>\n\t\t\t\t\t\t...\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='metaInfoDetails' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px;'>\n\t\t\t\t\t\tGenre\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='metaInfoDetailsData'>\n\t\t\t\t\t\t...\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>`,this.detailElem.addEventListener("click",(()=>{this.hideBackground(),this.minimizeAll()})),this.contentContainer.appendChild(this.detailElem);this.getElementsByClassName("detailPlayTrailerAction")[0].addEventListener("click",(t=>{if(t.stopPropagation(),this.videoElem){const t=this.getElementsByClassName("videoPlayer")[0].children[0];if(t.requestFullscreen)t.requestFullscreen();else if(t.webkitRequestFullscreen)t.webkitRequestFullscreen();else if(t.msRequestFullscreen)t.msRequestFullscreen();else{const e=this.getElementsByClassName("videobg1"),i=this.getElementsByClassName("videobg2");for(const t of e)t.classList.add("transparent");for(const t of i)t.classList.add("transparent");this.videoElem.classList.add("maxZIndex"),this.videoElem.classList.add("simulatedFullScreen"),t.controls=!0}}})),this.seasonsElem=document.createElement("div"),this.seasonsElem.className="seasons",this.seasonsElem.addEventListener("click",(()=>{this.hideBackground(),this.minimizeAll()})),this.contentContainer.appendChild(this.seasonsElem),this.episodesElem=document.createElement("div"),this.episodesElem.className="episodes",this.episodesElem.addEventListener("click",(()=>{this.hideBackground(),this.minimizeAll()})),this.contentContainer.appendChild(this.episodesElem),this.videoElem=document.createElement("div"),this.videoElem.className="video",this.videoElem.addEventListener("click",(t=>{const e=this.getElementsByClassName("videoPlayer")[0].children[0];if(Z(this)){t.stopPropagation(),this.videoElem&&(this.videoElem.classList.remove("maxZIndex"),this.videoElem.classList.remove("simulatedFullScreen"));const i=this.getElementsByClassName("videobg1"),n=this.getElementsByClassName("videobg2");for(const t of i)t.classList.remove("transparent");for(const t of n)t.classList.remove("transparent");e.controls=!1}else this.hideBackground(),this.minimizeAll()}));const o=document.createElement("div");o.className="videobg1",this.videoElem.appendChild(o);const l=document.createElement("div");l.className="videobg2",this.videoElem.appendChild(l);const h=document.createElement("div");h.className="videoPlayer",this.videoElem.appendChild(h),this.contentContainer.appendChild(this.videoElem),setTimeout((()=>{e.addEventListener("click",(()=>{this.hideBackground(),this.minimizeAll()})),s.addEventListener("click",(()=>{this.hideBackground(),this.minimizeAll()}))}),1);const c=document.createElement("div");c.className="clear",this.contentContainer.appendChild(c),this.renderMovieElems(),this.calculatePositions(),this.loadCustomStyles()},this.calculatePositions=()=>{const t=setInterval((()=>{this.movieElems=this.getElementsByClassName("movieElem");for(let e=0;e<this.movieElems.length&&0!==this.movieElems[e].offsetLeft;e+=1)clearInterval(t)}),100)},this.minimizeSeasons=()=>{this.seasonsElemHidden=!1,this.seasonsElem&&i.forEach(this.seasonsElem.childNodes,(t=>{const e=t.children[0],s=t.children[1],r=t.children[2];e.style.display="block",void 0!==e.children[0].children[0]&&(e.children[0].children[0].style.display="block");const a=t=>{const a=t;a.style.marginTop="0",i.isEqual(e.dataset.type,"album")?(a.style.width=`${n.width}px`,a.style.height=`${n.width}px`):(a.style.width=`${n.width}px`,a.style.height=n.height-3+"px"),a.style.zIndex="3",a.style.marginLeft="0px",a.dataset.clicked="false",s.style.display="block",r.style.display="block",this.seasonTitleColorTimeout=setTimeout((()=>{s.style.color="rgba(255,255,255,1)",r.style.color="rgba(255,255,255,1)"}),500)};"true"===e.dataset.clicked?a(e):this.moveElemTimeout=setTimeout((()=>{a(e)}),100)}))},this.hideVideo=()=>{if(this.videoElem){this.getElementsByClassName("videoPlayer")[0].innerHTML="",this.videoElem.classList.remove("maxZIndex"),this.videoElem.classList.remove("simulatedFullScreen");const t=this.getElementsByClassName("videobg1"),e=this.getElementsByClassName("videobg2");for(const e of t)e.classList.remove("transparent");for(const t of e)t.classList.remove("transparent")}},this.minimizeAll=()=>{this.detailsShown=!1,this.activeMovieElem&&(this.activeMovieElem.style.display="block"),this.activeMovieElem=void 0;for(let t=0;t<this.movieElems.length;t+=1)(i.isEqual(parseInt(this.movieElems[t].style.width,10),this.minExpandedWidth)&&i.isEqual(parseInt(this.movieElems[t].style.height,10),this.minExpandedHeight)||i.isEqual(parseInt(this.movieElems[t].style.width,10),this.minExpandedWidth)&&i.isEqual(parseInt(this.movieElems[t].style.height,10),this.minExpandedWidth))&&(i.isEqual(this.movieElems[t].style.width,this.movieElems[t].style.height)?(this.movieElems[t].style.width=`${n.width}px`,this.movieElems[t].style.height=`${n.width}px`):(this.movieElems[t].style.width=`${n.width}px`,this.movieElems[t].style.height=`${n.height}px`),this.movieElems[t].style.left=`${this.movieElems[t].dataset.left}px`,this.movieElems[t].style.top=`${this.movieElems[t].dataset.top}px`,setTimeout((()=>{this.movieElems[t].style.transition="0s",this.movieElems[t].style["z-index"]=1,this.movieElems[t].style.position="relative",this.movieElems[t].style.left="0px",this.movieElems[t].style.top="0px",this.movieElems[t].dataset.clicked=!1,setTimeout((()=>{this.movieElems[t].style.transition="0.5s"}),10)}),510));this.hideSeasons(),this.hideEpisodes(),this.hideDetails(),this.hideVideo(),clearInterval(this.showDetailsTimeout),clearInterval(this.showSeasonElemTimeout),clearInterval(this.seasonTitleColorTimeout),clearInterval(this.moveElemTimeout),clearInterval(this.scrollDownInactiveSeasonsTimeout),clearInterval(this.episodesLoadTimeout),clearInterval(this.episodesElemFreshlyLoadedTimeout),clearInterval(this.seasonElemFreshlyLoadedTimeout)},this.hideSeasons=()=>{if(this.seasonsElem){this.seasonsElemHidden=!0;const t=this.getTop();this.seasonsElem.style.top=`${t+2e3}px`,clearInterval(this.hideSeasonsTimeout),this.hideSeasonsTimeout=setTimeout((()=>{this.seasonsElem&&!this.seasonElemFreshlyLoaded&&(this.seasonsElem.innerHTML="",this.seasonsElem.style.display="none",this.resizeBackground())}),700)}},this.hideEpisodes=()=>{if(this.episodesElem){this.episodesElemHidden=!0;const t=this.getTop();this.episodesElem.style.top=`${t+2e3}px`,clearInterval(this.hideEpisodesTimeout),this.hideEpisodesTimeout=setTimeout((()=>{this.episodesElem&&!this.episodesElemFreshlyLoaded&&(this.episodesElem.innerHTML="",this.episodesElem.style.display="none",this.resizeBackground())}),700)}},this.scrollDownInactiveSeasons=()=>{this.seasonsElem&&(this.seasonsElemHidden=!0,i.forEach(this.seasonsElem.childNodes,(t=>{const e=t.children[0],i=t.children[1],n=t.children[2];"false"===e.dataset.clicked&&(e.style.marginTop="1000px",e.style.marginLeft="0px",this.scrollDownInactiveSeasonsTimeout=setTimeout((()=>{e.style.display="none",i.style.display="none",n.style.display="none"}),500))})))},this.hideDetails=()=>{const t=this.getTop();this.detailElem&&(this.detailElem.style.top=t-1e3+"px",this.detailElem.style.color="rgba(255,255,255,0)",this.detailElem.style.zIndex="0",this.detailElem.style.visibility="hidden"),clearTimeout(this.renderNewElementsIfNeededTimeout),this.renderNewElementsIfNeededTimeout=setTimeout((()=>{this.renderNewElementsIfNeeded()}),1e3);this.getElementsByClassName("detailPlayTrailerAction")[0].style.visibility="hidden"},this.showDetails=async t=>{this.detailsShown=!0;const e=this.getTop();if(this.detailElem&&(this.playController&&(this.playController.setPlayActionButtonType(t.type),this.playController.setPlayButtonClickFunction((e=>{e.preventDefault(),e.stopPropagation(),this.playController&&this.playController.play(t,!0)}))),this.detailElem.style.transition="0s",this.detailElem.style.top=e-1e3+"px",i.isEmpty(i.get(t,"thumb"))?this.detailElem.style.left="16px":this.detailElem.style.left=`${this.minExpandedWidth+30}px`,clearInterval(this.showDetailsTimeout),this.showDetailsTimeout=setTimeout((async()=>{if(this.detailElem&&this.plex){this.detailElem.style.visibility="visible",this.detailElem.style.transition="0.7s",this.detailElem.style.top=`${e}px`;let n=t;i.isEqual(t.type,"season")&&(n=await this.plex.getDetails(t.parentKey.split("/")[3]),n.title=`${n.title} - ${t.title}`);const s=this.getElementsByClassName("metaInfoDetailsData")[0];s.style.fontSize=`${this.fontSize4}px`,s.style.lineHeight=`${this.fontSize4}px`,s.style.marginTop=this.fontSize4/4+"px",s.style.marginBottom=this.fontSize4/4+"px",s.style.display="block",s.parentElement&&(n.Director&&n.Director.length>0?(s.innerHTML=F(n.Director[0].tag),s.parentElement.style.display="table-row"):s.parentElement.style.display="none");const r=this.getElementsByClassName("metaInfoDetailsData")[1];r.style.fontSize=`${this.fontSize4}px`,r.style.lineHeight=`${this.fontSize4}px`,r.style.marginTop=this.fontSize4/4+"px",r.style.marginBottom=this.fontSize4/4+"px",r.style.display="block",r.parentElement&&(n.Writer&&n.Writer.length>0?(r.innerHTML=F(n.Writer[0].tag),r.parentElement.style.display="table-row"):r.parentElement.style.display="none");const a=this.getElementsByClassName("metaInfoDetailsData")[2];a.style.fontSize=`${this.fontSize4}px`,a.style.lineHeight=`${this.fontSize4}px`,a.style.marginTop=this.fontSize4/4+"px",a.style.marginBottom=this.fontSize4/4+"px",a.style.display="block",a.parentElement&&(n.studio?(a.innerHTML=F(n.studio),a.parentElement.style.display="table-row"):a.parentElement.style.display="none");const o=this.getElementsByClassName("metaInfoDetailsData")[3];if(o.style.fontSize=`${this.fontSize4}px`,o.style.lineHeight=`${this.fontSize4}px`,o.style.marginTop=this.fontSize4/4+"px",o.style.marginBottom=this.fontSize4/4+"px",o.style.display="block",o.parentElement)if(n.Genre&&n.Genre.length>0){let t="";i.forEach(n.Genre,(e=>{t+=`${e.tag}, `})),o.innerHTML=F(t.slice(0,-2)),o.parentElement.style.display="table-row"}else o.parentElement.style.display="none";const l=this.getElementsByClassName("detailsTitle")[0];i.isNil(n.channelCallSign)?l.innerHTML=F(n.title):l.innerHTML=F(n.channelCallSign),l.style.lineHeight=`${this.fontSize3}px`,l.style.fontSize=`${this.fontSize3}px`,l.style.marginBottom=this.fontSize3/4+"px";const h=this.getElementsByClassName("detailsYear")[0];h.style.display="block",h.style.fontSize=`${this.fontSize4}px`,h.style.lineHeight=`${this.fontSize4}px`,h.style.marginTop="0px",h.style.marginBottom=this.fontSize4/4+"px",i.isNil(n.year)?i.isNil(n.epg)||i.isNil(n.epg.title)?(h.style.display="none",h.innerHTML=""):h.innerHTML=F(n.epg.title):h.innerHTML=F(n.year),this.getElementsByClassName("metaInfo")[0].innerHTML=(void 0!==n.duration?`<span class='minutesDetail' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px; padding:${this.fontSize4/2}px ${this.fontSize4}px;'>${Math.round(parseInt(F(n.duration),10)/60/1e3)} min</span>`:"")+(void 0!==n.contentRating?`<span class='contentRatingDetail' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px; padding:${this.fontSize4/2}px ${this.fontSize4}px;'>${F(n.contentRating)}</span>`:"")+(void 0!==n.rating?`<span class='ratingDetail' style='font-size:${this.fontSize4}px; line-height:${this.fontSize4}px; margin-top:${this.fontSize4/4}px; margin-bottom:${this.fontSize4/4}px; margin-right:${this.fontSize4/4}px; padding:${this.fontSize4/2}px ${this.fontSize4}px;'>${n.rating<5?"&#128465;":"&#11088;"}&nbsp;${Math.round(10*parseFloat(F(n.rating)))/10}</span>`:"")+"<div class='clear'></div>";const c=this.getElementsByClassName("detailDesc")[0];c.style.fontSize=`${this.fontSize4}px`,c.style.lineHeight=`${this.fontSize4}px`,c.style.marginTop=this.fontSize4/4+"px",c.style.marginBottom=this.fontSize4/4+"px",c.style.display="block",i.isNil(n.summary)?i.isNil(n.epg)||i.isNil(n.epg.summary)?(c.innerHTML="",c.style.display="none"):c.innerHTML=F(n.epg.summary):c.innerHTML=F(n.summary),this.detailElem.style.color="rgba(255,255,255,1)",this.detailElem.style.zIndex="4",this.detailElem.style.width=`calc(100% - ${this.minExpandedWidth+30+20}px)`,this.activeMovieElem?this.detailElem.style.maxHeight=`${K(this.activeMovieElem)+40}px`:this.detailElem.style.maxHeight=`${this.minExpandedHeight+20}px`}}),200)),this.plex){let s={};i.isEqual(t.type,"episode")?s=await this.plex.getLibraryData(`${t.grandparentKey}/children`):(t.childCount>0||i.isEqual(t.type,"artist")||i.isEqual(t.type,"album")||i.includes(t.key,"folder"))&&(s=await this.plex.getLibraryData(t.key)),this.playController&&(i.includes(t.key,"folder")?this.playController.setPlayActionDisplay("none"):this.playController.setPlayActionDisplay("block"));let r={};if(!i.isNil(t.key)&&(i.includes(t.key,"folder")||(r=await this.plex.getDetails(t.key.split("/")[3])),this.videoElem)){const n=this.plex.authorizeURL(this.plex.getBasicURL()+t.art);if(""===(t=>{let e="";return t.Extras&&t.Extras.Metadata&&t.Extras.Metadata.length>0&&i.forEach(t.Extras.Metadata,(t=>{if("trailer"===t.subtype)return e=t.Media[0].Part[0].key,!1})),e})(r)||i.isEqual(this.playTrailer,!1)){if(!i.isEmpty(n)){const t=this.getElementsByClassName("contentArt")[0],i=this.getElementsByClassName("contentbg")[0];t.style.width=`${window.innerWidth}px`,t.style.height=`${window.innerHeight}px`,t.style.backgroundImage=`url('${n}')`,t.style.top=e-8+"px",t.style.transition="0.5s",t.style.display="block",i.classList.add("no-transparency")}}else{const t=this.getElementsByClassName("videoPlayer")[0],n=document.createElement("video");n.style.height="100%",n.style.width="100%",n.controls=!1,i.isEqual(this.playTrailer,"muted")&&(n.muted=!0);const s=document.createElement("source");s.type="video/mp4",s.src=this.plex.authorizeURL(`${this.plex.getBasicURL()}${r.Extras.Metadata[0].Media[0].Part[0].key}`),n.appendChild(s),t.appendChild(n),n.load(),n.play();let a=!1;const o=this.getElementsByClassName("videobg1"),l=this.getElementsByClassName("videobg2");n.addEventListener("click",(t=>{Z(this)&&t.stopPropagation()}));const h=()=>{if(this.videoElem)if(Z(this)){for(const t of o)t.classList.add("transparent");for(const t of l)t.classList.add("transparent");this.videoElem.classList.add("maxZIndex"),n.controls=!0,n.muted=!1}else{for(const t of o)t.classList.remove("transparent");for(const t of l)t.classList.remove("transparent");this.videoElem.classList.remove("maxZIndex"),n.controls=!1,window.scroll({top:G(this.activeMovieElem).top-70,behavior:"smooth"}),i.isEqual(this.playTrailer,"muted")&&(n.muted=!0)}};n.addEventListener("fullscreenchange",h),n.addEventListener("mozfullscreenchange",h),n.addEventListener("webkitfullscreenchange",h),n.addEventListener("msfullscreenchange",h),n.addEventListener("playing",(()=>{if(this.videoElem&&!a){const t=this.getElementsByClassName("contentbg")[0],i=this.getElementsByClassName("detailPlayTrailerAction")[0];i.style.fontSize=`${this.fontSize4}px`,i.style.lineHeight=`${this.fontSize4}px`,i.style.marginTop=this.fontSize4/4+"px",i.style.marginBottom=this.fontSize4/4+"px",i.style.marginRight=this.fontSize4/4+"px",i.style.padding=`${this.fontSize4/2}px ${this.fontSize4}px`,i.style.visibility="visible",t.classList.add("no-transparency"),a=!0,this.videoElem.style.width=`${this.getElementsByClassName("searchContainer")[0].offsetWidth}px`,this.videoElem.style.visibility="visible",this.videoElem.style.top=`${e}px`}}))}}if(i.isEmpty(s)){if(this.episodesElemFreshlyLoaded=!0,this.episodesElem){if(this.episodesElemHidden=!1,this.episodesElem.style.display="block",this.episodesElem.innerHTML="",this.episodesElem.style.transition="0s",this.episodesElem.style.top=`${e+2e3}px`,i.isEqual(t.type,"season")){const e=await this.plex.getLibraryData(t.key);i.forEach(e,(t=>{this.episodesElem&&this.playController&&this.plex&&this.episodesElem.append(nt(this.playController,this.plex,t,this.fontSize1,this.fontSize2))}))}else if(this.showExtras&&!i.isNil(r.Extras)){const t=r.Extras.Metadata;i.forEach(t,(t=>{this.episodesElem&&this.playController&&this.plex&&this.episodesElem.append(nt(this.playController,this.plex,t,this.fontSize1,this.fontSize2))}))}clearInterval(this.episodesLoadTimeout),this.episodesLoadTimeout=setTimeout((()=>{this.episodesElem&&(this.episodesElem.style.transition="0.7s",this.episodesElem.style.top=`${e+this.minExpandedHeight+16}px`,this.resizeBackground())}),200),clearInterval(this.episodesElemFreshlyLoadedTimeout),this.episodesElemFreshlyLoadedTimeout=setTimeout((()=>{this.episodesElemFreshlyLoaded=!1}),700)}}else if(this.seasonElemFreshlyLoaded=!0,this.seasonsElem&&(this.seasonsElem.style.display="block",this.seasonsElem.innerHTML="",this.seasonsElem.style.transition="0s",this.seasonsElem.style.top=`${e+2e3}px`),i.isEqual(i.get(s[0],"type"),"track")){if(this.episodesElem){this.episodesElemHidden=!1,this.episodesElem.style.display="block",this.episodesElem.innerHTML="",this.episodesElem.style.transition="0s",this.episodesElem.style.top=`${e+2e3}px`;const n=document.createElement("table");n.style.width="calc(100% - 10px)",n.style.border="none",n.cellSpacing="0",n.cellPadding="0",this.episodesElem.append(n);let r=!1;i.forEach(s,(t=>{this.episodesElem&&this.playController&&this.plex&&(i.isEqual(t.type,"track")?(n.append(it(this.playController,this.plex,t,this.fontSize1,this.fontSize2,r)),r=!r):this.episodesElem.append(nt(this.playController,this.plex,t,this.fontSize1,this.fontSize2)))})),clearInterval(this.episodesLoadTimeout),this.episodesLoadTimeout=setTimeout((()=>{this.episodesElem&&(this.episodesElem.style.transition="0.7s",this.activeMovieElem?i.isEmpty(i.get(t,"thumb"))?this.detailElem?this.episodesElem.style.top=`${e+K(this.detailElem)}px`:this.episodesElem.style.top=`${e}px`:this.episodesElem.style.top=`${e+K(this.activeMovieElem)+32}px`:this.episodesElem.style.top=`${e+this.minExpandedHeight+16}px`,this.resizeBackground())}),200),clearInterval(this.episodesElemFreshlyLoadedTimeout),this.episodesElemFreshlyLoadedTimeout=setTimeout((()=>{this.episodesElemFreshlyLoaded=!1}),700)}}else i.forEach(s,(t=>{if(this.seasonsElem&&this.plex){this.seasonsElemHidden=!1;const s=document.createElement("div");s.className="seasonContainer",s.style.width=`${n.width}px`;const r=`${this.plex.getBasicURL()}/photo/:/transcode?width=${this.minExpandedWidth}&height=${this.minExpandedHeight}&minSize=1&upscale=1&url=${t.thumb}&X-Plex-Token=${this.config.token}`,a=document.createElement("div");a.className="seasonElem",a.style.width=`${n.width}px`,i.isEqual(t.type,"album")?a.style.height=`${n.width}px`:a.style.height=n.height-3+"px",a.style.backgroundImage=`url('${r}')`,a.dataset.clicked="false",this.playController&&!this.playController.isPlaySupported(t)&&(a.style.cursor="pointer");const o=document.createElement("div");if(o.className="interactiveArea",t.leafCount-t.viewedLeafCount>0){const e=document.createElement("div");e.className="toViewSeason",e.innerHTML=(t.leafCount-t.viewedLeafCount).toString(),e.style.fontSize=`${this.fontSize4}px`,e.style.lineHeight=`${this.fontSize4}px`,e.style.padding=this.fontSize4/2+"px",o.appendChild(e)}if(this.playController){const e=this.playController.getPlayButton(t.type);this.playController.isPlaySupported(t)&&e.classList.remove("disabled"),e.addEventListener("click",(e=>{e.stopPropagation(),this.plex&&this.playController&&this.playController.play(t,!0)})),o.append(e)}a.append(o),s.append(a);const l=document.createElement("div");l.className="seasonTitleElem",l.innerHTML=F(t.title),l.style.fontSize=`${this.fontSize1}px`,l.style.lineHeight=`${this.fontSize1}px`,s.append(l);const h=document.createElement("div");h.className="seasonEpisodesCount",t.leafCount>0?h.innerHTML=`${F(t.leafCount)} episodes`:i.isNil(t.year)||(h.innerHTML=`${F(t.year)} `),h.style.fontSize=`${this.fontSize2}px`,h.style.lineHeight=`${this.fontSize2}px`,s.append(h),s.addEventListener("click",(n=>{if(n.stopPropagation(),this.seasonContainerClickEnabled&&(this.seasonContainerClickEnabled=!1,setTimeout((()=>{this.seasonContainerClickEnabled=!0}),500),this.activeMovieElem))if("false"===a.dataset.clicked)this.playController&&(this.playController.setPlayActionButtonType(t.type),this.playController.setPlayButtonClickFunction((e=>{e.preventDefault(),e.stopPropagation(),this.playController&&this.playController.play(t,!0)}))),void 0!==a.children[0].children[0]&&(a.children[0].children[0].style.display="none"),a.dataset.clicked="true",this.activeMovieElem.style.top=e-1e3+"px",setTimeout((()=>{this.activeMovieElem&&(this.activeMovieElem.style.display="none")}),500),this.scrollDownInactiveSeasons(),this.activeMovieElem?s.style.top=-K(this.activeMovieElem)+"px":s.style.top=-this.minExpandedHeight+"px",a.dataset.type=t.type,a.style.width=`${this.minExpandedWidth}px`,i.isEqual(t.type,"album")?a.style.height=`${this.minExpandedWidth}px`:a.style.height=this.minExpandedHeight-6+"px",a.style.zIndex="3",a.style.marginLeft=`-${G(a).left-G(this.activeMovieElem).left}px`,l.style.color="rgba(255,255,255,0)",h.style.color="rgba(255,255,255,0)",this.detailElem&&(this.detailElem.children[1].innerHTML=t.title),(async()=>{if(this.plex&&(t.leafCount>0||i.isEqual(t.type,"album"))){this.episodesElemFreshlyLoaded=!0;const n=await this.plex.getLibraryData(t.key);if(this.episodesElem){this.episodesElemHidden=!1,this.episodesElem.style.display="block",this.episodesElem.innerHTML="",this.episodesElem.style.transition="0s",this.episodesElem.style.top=`${e+2e3}px`;const s=document.createElement("table");s.style.width="calc(100% - 10px)",s.style.border="none",s.cellSpacing="0",s.cellPadding="0",i.isEqual(t.type,"album")&&this.episodesElem.append(s);let r=!1;i.forEach(n,(t=>{this.episodesElem&&this.playController&&this.plex&&(i.isEqual(t.type,"track")?(s.append(it(this.playController,this.plex,t,this.fontSize1,this.fontSize2,r)),r=!r):this.episodesElem.append(nt(this.playController,this.plex,t,this.fontSize1,this.fontSize2)))})),clearInterval(this.episodesLoadTimeout),this.episodesLoadTimeout=setTimeout((()=>{this.episodesElem&&(this.episodesElem.style.transition="0.7s",this.activeMovieElem?this.episodesElem.style.top=`${e+K(this.activeMovieElem)+32}px`:this.episodesElem.style.top=`${e+this.minExpandedHeight+16}px`,this.resizeBackground())}),200),clearInterval(this.episodesElemFreshlyLoadedTimeout),this.episodesElemFreshlyLoadedTimeout=setTimeout((()=>{this.episodesElemFreshlyLoaded=!1}),700)}}})();else if(this.playController&&this.playController.setPlayActionButtonType(t.type),s.style.top=`${s.dataset.top}px`,this.minimizeSeasons(),this.hideEpisodes(),this.activeMovieElem.style.display="block",setTimeout((()=>{this.activeMovieElem&&(this.activeMovieElem.style.top=`${e+16}px`)}),10),this.detailElem&&this.detailElem.children[1]){const{year:t}=this.detailElem.children[1].dataset;t&&(this.detailElem.children[1].innerHTML=t)}})),this.seasonsElem.append(s)}})),i.forEach(this.seasonsElem.children,(t=>{const e=t,i=e.offsetLeft,n=e.offsetTop;e.style.left=`${i}px`,e.dataset.left=`${i}`,e.style.top=`${n}px`,e.dataset.top=`${n}`})),i.forEach(this.seasonsElem.children,(t=>{t.style.position="absolute"})),clearInterval(this.seasonElemFreshlyLoadedTimeout),this.seasonElemFreshlyLoadedTimeout=setTimeout((()=>{this.seasonElemFreshlyLoaded=!1}),700),clearInterval(this.showSeasonElemTimeout),this.showSeasonElemTimeout=setTimeout((()=>{this.seasonsElem&&(this.seasonsElem.style.transition="0.7s",this.activeMovieElem?this.seasonsElem.style.top=`${e+K(this.activeMovieElem)+32}px`:this.seasonsElem.style.top=`${e+this.minExpandedHeight+16}px`,this.resizeBackground())}),200)}},this.resizeBackground=()=>{if(this.seasonsElem&&this.episodesElem&&this.card){const t=this.getElementsByClassName("contentbg")[0];this.contentBGHeight=K(t);const e=parseInt(this.seasonsElem.style.top.replace("px",""),10)+this.seasonsElem.scrollHeight,i=parseInt(this.episodesElem.style.top.replace("px",""),10)+this.episodesElem.scrollHeight;e>this.contentBGHeight&&!this.seasonsElemHidden?this.card.style.height=`${e+16}px`:i>this.contentBGHeight&&!this.episodesElemHidden?this.card.style.height=`${i+16}px`:this.card.style.height="100%"}},this.showBackground=()=>{const t=this.getElementsByClassName("contentbg");t[0].style.zIndex="2",t[0].style.backgroundColor="rgba(0,0,0,0.9)",t[0].style.display="block"},this.hideBackground=()=>{const t=this.getElementsByClassName("contentbg")[0];t.classList.remove("no-transparency"),t.style.zIndex="1",t.style.backgroundColor="rgba(0,0,0,0)",t.style.display="none";this.getElementsByClassName("contentArt")[0].style.display="none"},this.activateMovieElem=t=>{const e=t;if("true"===t.dataset.clicked)this.minimizeAll(),this.activeMovieElem=void 0,this.hideDetails(),setTimeout((()=>{e.dataset.clicked="false"}),500),this.hideBackground();else{const n=this.getTop();e.style.transition="0s",e.style.left=e.offsetLeft-this.content.scrollLeft+"px",e.style.top=`${e.offsetTop}px`,e.style.position="absolute",e.dataset.left=`${e.offsetLeft}`,e.dataset.top=`${e.offsetTop}`,e.style.zIndex="3",setTimeout((()=>{e.style.transition="0.5s",this.showDetails(this.activeMovieElemData),this.showBackground(),i.isEqual(t.style.width,t.style.height)?(e.style.width=`${this.minExpandedWidth}px`,e.style.height=`${this.minExpandedWidth}px`):(e.style.width=`${this.minExpandedWidth}px`,e.style.height=`${this.minExpandedHeight}px`),e.style.left="16px",e.style.top=`${n+16}px`,e.dataset.clicked="true",this.activeMovieElem=e}),1)}},this.getTop=()=>{if(this.card){const t=document.documentElement,e=(window.pageYOffset||t.scrollTop)-(t.clientTop||0),i=G(this.card).top;return e<i-64?0:e-i+64}return 0},this.getMovieElement=(t,e=!1)=>{let s="";this.plex&&(s=i.isEqual(t.type,"episode")?`${this.plex.getBasicURL()}/photo/:/transcode?width=${this.minExpandedWidth}&height=${this.minExpandedHeight}&minSize=1&upscale=1&url=${t.grandparentThumb}&X-Plex-Token=${this.config.token}`:`${this.plex.getBasicURL()}/photo/:/transcode?width=${this.minExpandedWidth}&height=${this.minExpandedHeight}&minSize=1&upscale=1&url=${t.thumb}&X-Plex-Token=${this.config.token}`);const r=document.createElement("div");r.className="plexMeetsContainer",r.style.width=`${n.width}px`,this.displayTitleMain||this.displaySubtitleMain?r.style.marginBottom="10px":r.style.marginBottom="5px",i.isNil(t.channelCallSign)||(r.style.marginBottom="10px");const a=document.createElement("div");a.className="movieElem",a.style.width=`${n.width}px`,a.style.height=`${n.height}px`,(!i.isNil(t.channelCallSign)||i.isEqual(t.type,"artist")||i.isEqual(t.type,"album")||i.includes(t.key,"folder"))&&(i.isEqual(t.type,"artist")||i.isEqual(t.type,"album")||i.includes(t.key,"folder")||(a.style.backgroundSize="80%"),a.style.backgroundColor="rgba(0,0,0,0.2)",a.style.backgroundPosition="center",a.style.height=`${n.width}px`),a.style.backgroundImage=`url('${s}')`,this.playController&&!this.playController.isPlaySupported(t)&&(a.style.cursor="pointer"),a.addEventListener("click",(()=>{this.activeMovieElemData=t,this.activateMovieElem(a)}));const o=document.createElement("div");if(!(t.viewCount&&t.viewCount>0)&&"movie"===t.type){const t=document.createElement("div");t.className="toViewEpisode",o.appendChild(t)}if(t.leafCount-t.viewedLeafCount>0&&"show"===t.type){const e=document.createElement("div");e.className="toViewSeason",e.innerHTML=(t.leafCount-t.viewedLeafCount).toString(),e.style.fontSize=`${this.fontSize4}px`,e.style.lineHeight=`${this.fontSize4}px`,e.style.padding=this.fontSize4/2+"px",o.appendChild(e)}if(t.viewOffset>0&&t.duration>0){const e=document.createElement("div");e.className="viewProgress",e.style.width=t.viewOffset/t.duration*100+"%",o.appendChild(e)}if(o.className="interactiveArea",this.playController){const e=this.playController.getPlayButton(t.type);this.playController.isPlaySupported(t)&&e.classList.remove("disabled"),o.append(e),((t,e,i)=>{let n=!1,s=null;const r=t=>{t.stopPropagation(),null!==s&&(clearTimeout(s),s=null)},a=t=>{t.stopPropagation(),"click"===t.type&&0!==t.button||(n=!1,s=setTimeout((()=>{i(t),n=!0}),1e3))};t.addEventListener("mousedown",a),t.addEventListener("touchstart",a),t.addEventListener("click",(t=>(t.stopPropagation(),null!==s&&(clearTimeout(s),s=null),!n&&(e(t),!0)))),t.addEventListener("mouseout",r),t.addEventListener("touchend",r),t.addEventListener("touchleave",r),t.addEventListener("touchcancel",r)})(e,(e=>{e.stopPropagation(),this.hassObj&&this.playController&&this.playController.play(t,!0)}),(t=>{console.log("Play version... will be here!"),t.stopPropagation()}))}a.append(o);const l=document.createElement("div");i.isEqual(t.type,"episode")?l.innerHTML=F(t.grandparentTitle):i.isNil(t.channelCallSign)?l.innerHTML=F(t.title):l.innerHTML=F(t.channelCallSign);const h=this.fontSize1/4,c=this.fontSize2/4;l.className="titleElem",i.isNil(t.channelCallSign)?l.style.marginTop=`${h}px`:l.style.marginTop="0px",l.style.fontSize=`${this.fontSize1}px`,l.style.marginBottom=`${h}px`,l.style.lineHeight=`${this.fontSize1}px`;const u=document.createElement("div");i.isEqual(t.type,"episode")?u.innerHTML=F(t.title):i.isNil(t.year)?i.isNil(t.epg)?u.innerHTML="&nbsp;":u.innerHTML=F(t.epg.title):u.innerHTML=F(t.year),u.className="yearElem",u.style.fontSize=`${this.fontSize2}px`,u.style.lineHeight=`${this.fontSize2}px`,u.style.marginTop=`${c}px`,u.style.marginBottom=`${c}px`;const d=document.createElement("div");return i.isEqual(t.type,"episode")&&(d.innerHTML=F(`S${t.parentIndex} E${t.index}`),d.className="additionalElem",d.style.fontSize=`${this.fontSize2}px`,d.style.lineHeight=`${this.fontSize2}px`,d.style.marginTop=`${c}px`,d.style.marginBottom=`${c}px`),r.appendChild(a),this.displayTitleMain&&r.appendChild(l),this.displaySubtitleMain&&(r.appendChild(u),r.appendChild(d)),r},this.loadCustomStyles=()=>`<style>${ct.innerHTML}</style>`,this.setConfig=t=>{if(this.plexProtocol="http",!t.ip)throw new Error("You need to define a Plex IP Address");if(!t.token)throw new Error("You need to define a Plex Token");if(!t.libraryName)throw new Error("You need to define a libraryName");if(!t.entity||0===t.entity.length)throw new Error("You need to define at least one entity");if(i.isPlainObject(t.entity)){let e=!1;if(i.forEach(t.entity,((t,i)=>{if(s[i])return e=!0,!1})),!e)throw new Error("You need to define at least one supported entity")}else if(!i.isString(t.entity)&&!i.isArray(t.entity))throw new Error("You need to define at least one supported entity");this.config=t,t.protocol&&(this.plexProtocol=t.protocol),t.displayType&&!i.isEmpty(t.displayType)&&(this.displayType=t.displayType),t.useHorizontalScroll&&i.isEqual(t.useHorizontalScroll,"Yes")&&(this.useHorizontalScroll=!0),t.useShuffle&&i.isEqual(t.useShuffle,"Yes")&&(this.useShuffle=!0),t.displayTitleMain&&i.isEqual(t.displayTitleMain,"No")&&(this.displayTitleMain=!1),t.displaySubtitleMain&&i.isEqual(t.displaySubtitleMain,"No")&&(this.displaySubtitleMain=!1),t.port&&!i.isEqual(t.port,"")?this.plexPort=t.port:this.plexPort=!1,t.maxCount&&""!==t.maxCount&&(this.maxCount=t.maxCount),t.maxRows&&""!==t.maxRows&&"0"!==t.maxRows&&0!==t.maxRows?this.maxRows=t.maxRows:this.maxRows=!1,t.minWidth&&""!==t.minWidth&&"0"!==t.minWidth&&0!==t.minWidth&&(this.minWidth=parseInt(t.minWidth,10)),t.minEpisodeWidth&&""!==t.minEpisodeWidth&&"0"!==t.minEpisodeWidth&&0!==t.minEpisodeWidth&&(this.minEpisodeWidth=parseInt(t.minEpisodeWidth,10)),t.minExpandedWidth&&""!==t.minExpandedWidth&&"0"!==t.minExpandedWidth&&0!==t.minExpandedWidth&&(this.minExpandedWidth=parseInt(t.minExpandedWidth,10)),t.fontSize1&&""!==t.fontSize1&&"0"!==t.fontSize1&&0!==t.fontSize1&&(this.fontSize1=parseInt(t.fontSize1,10)),t.fontSize2&&""!==t.fontSize2&&"0"!==t.fontSize2&&0!==t.fontSize2&&(this.fontSize2=parseInt(t.fontSize2,10)),t.fontSize3&&""!==t.fontSize3&&"0"!==t.fontSize3&&0!==t.fontSize3&&(this.fontSize3=parseInt(t.fontSize3,10)),t.fontSize4&&""!==t.fontSize4&&"0"!==t.fontSize4&&0!==t.fontSize4&&(this.fontSize4=parseInt(t.fontSize4,10)),t.minExpandedHeight&&""!==t.minExpandedHeight&&"0"!==t.minExpandedHeight&&0!==t.minExpandedHeight&&(this.minExpandedHeight=parseInt(t.minExpandedHeight,10)),t.runBefore&&!i.isEqual(t.runBefore,"")&&(this.runBefore=t.runBefore),t.runAfter&&!i.isEqual(t.runAfter,"")&&(this.runAfter=t.runAfter),i.isNil(t.playTrailer)||(this.playTrailer=t.playTrailer),i.isNil(t.showExtras)||(this.showExtras=t.showExtras),i.isNil(t.showSearch)||(this.showSearch=t.showSearch),this.plex=new V(this.config.ip,this.plexPort,this.config.token,this.plexProtocol,this.config.sort),this.data={},this.error="",this.renderInitialData()},this.getCardSize=()=>3}set hass(t){this.hassObj=t,this.initialDataLoaded||this.loadInitialData()}static getConfigElement(){return document.createElement("plex-meets-homeassistant-editor")}}ut.querySelectorAllShadows=(t,e=document.body)=>{const i=Array.from(e.querySelectorAll("*")).map((t=>t.shadowRoot)).filter(Boolean).map((e=>ut.querySelectorAllShadows(t,e)));return Array.from(e.querySelectorAll(t)).concat(i).flat()},customElements.define("plex-meets-homeassistant-editor",rt),customElements.define("plex-meets-homeassistant",ut),window.customCards=window.customCards||[],window.customCards.push({type:"plex-meets-homeassistant",name:"Plex meets Home Assistant",preview:!1,description:"Integrates Plex into Home Assistant. Browse and launch media with a simple click."});
//# sourceMappingURL=plex-meets-homeassistant.js.map