dotfiles/.config/spicetify/CustomApps/better-local-files/extension.js

1 line
No EOL
22 KiB
JavaScript

!async function(){for(;!Spicetify.React||!Spicetify.ReactDOM;)await new Promise(t=>setTimeout(t,10));var t,e,D,a,F,c,U,R,r,$,o,i,n,H,s,J,u,l,g,L,B,K,V,h,f,Y,p,d,W,m,X,q,G,Q,Z,b,tt,et,rt,it,nt,ot,y,v,w,S,st,at;D=Object.create,a=Object.defineProperty,F=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,U=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty,t={"../../node_modules/pixelmatch/index.js"(t,e){"use strict";var m={threshold:.1,includeAA:!(e.exports=function(r,i,n,o,s,a){if(!b(r)||!b(i)||n&&!b(n))throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");if(r.length!==i.length||n&&n.length!==r.length)throw new Error("Image sizes do not match.");if(r.length!==o*s*4)throw new Error("Image data size does not match width/height.");a=Object.assign({},m,a);var e=o*s,c=new Uint32Array(r.buffer,r.byteOffset,e),u=new Uint32Array(i.buffer,i.byteOffset,e);let l=!0;for(let t=0;t<e;t++)if(c[t]!==u[t]){l=!1;break}if(l){if(n&&!a.diffMask)for(let t=0;t<e;t++)S(r,4*t,a.alpha,n);return 0}var h=35215*a.threshold*a.threshold;let f=0;for(let e=0;e<s;e++)for(let t=0;t<o;t++){var p=4*(e*o+t),d=w(r,i,p,p);Math.abs(d)>h?a.includeAA||!y(r,t,e,o,s,i)&&!y(i,t,e,o,s,r)?(n&&v(n,p,...d<0&&a.diffColorAlt||a.diffColor),f++):n&&!a.diffMask&&v(n,p,...a.aaColor):n&&!a.diffMask&&S(r,p,a.alpha,n)}return f}),alpha:.1,aaColor:[255,255,0],diffColor:[255,0,0],diffColorAlt:null,diffMask:!1};function b(t){return ArrayBuffer.isView(t)&&1===t.constructor.BYTES_PER_ELEMENT}function y(r,i,n,o,t,e){var s=Math.max(i-1,0),a=Math.max(n-1,0),c=Math.min(i+1,o-1),u=Math.min(n+1,t-1),l=4*(n*o+i);let h=i===s||i===c||n===a||n===u?1:0,f=0,p=0,d,m,b,y;for(let e=s;e<=c;e++)for(let t=a;t<=u;t++)if(e!==i||t!==n){var v=w(r,r,l,4*(t*o+e),!0);if(0===v){if(2<++h)return}else v<f?(f=v,d=e,m=t):v>p&&(p=v,b=e,y=t)}return 0!==f&&0!==p&&(g(r,d,m,o,t)&&g(e,d,m,o,t)||g(r,b,y,o,t)&&g(e,b,y,o,t))}function g(r,i,n,o,t){var s=Math.max(i-1,0),a=Math.max(n-1,0),c=Math.min(i+1,o-1),u=Math.min(n+1,t-1),l=4*(n*o+i);let h=i===s||i===c||n===a||n===u?1:0;for(let e=s;e<=c;e++)for(let t=a;t<=u;t++)if(e!==i||t!==n){var f=4*(t*o+e);if(r[l]===r[f]&&r[1+l]===r[1+f]&&r[2+l]===r[2+f]&&r[3+l]===r[3+f]&&h++,2<h)return!0}return!1}function w(t,e,r,i,n){let o=t[r+0],s=t[r+1],a=t[r+2];t=t[r+3];let c=e[i+0],u=e[i+1],l=e[i+2];r=e[i+3];if(t===r&&o===c&&s===u&&a===l)return 0;t<255&&(t/=255,o=d(o,t),s=d(s,t),a=d(a,t)),r<255&&(r/=255,c=d(c,r),u=d(u,r),l=d(l,r));var e=h(o,s,a),i=h(c,u,l),t=e-i;return!n&&(t=.5053*t*t+.299*(r=f(o,s,a)-f(c,u,l))*r+.1957*(n=p(o,s,a)-p(c,u,l))*n,i<e)?-t:t}function h(t,e,r){return.29889531*t+.58662247*e+.11448223*r}function f(t,e,r){return.59597799*t-.2741761*e-.32180189*r}function p(t,e,r){return.21147017*t-.52261711*e+.31114694*r}function d(t,e){return 255+(t-255)*e}function v(t,e,r,i,n){t[e+0]=r,t[e+1]=i,t[e+2]=n,t[e+3]=255}function S(t,e,r,i){r=d(h(t[e+0],t[e+1],t[e+2]),r*t[e+3]/255);v(i,e,r,r,r)}}},r=function(){return e||(0,t[c(t)[0]])((e={exports:{}}).exports,e),e.exports},$=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,o=t=>{if("string"!=typeof t)throw new TypeError("Invalid argument expected string");var e=t.match($);if(e)return e.shift(),e;throw new Error(`Invalid argument not valid semver ('${t}' received)`)},i=t=>"*"===t||"x"===t||"X"===t,n=t=>{var e=parseInt(t,10);return isNaN(e)?t:e},H=(t,e)=>{return i(t)||i(e)?0:([t,e]=(t=n(t),e=n(e),typeof t!=typeof e?[String(t),String(e)]:[t,e]),e<t?1:t<e?-1:0)},s=(e,r)=>{for(let t=0;t<Math.max(e.length,r.length);t++){var i=H(e[t]||"0",r[t]||"0");if(0!==i)return i}return 0},J=(t,e,r)=>{var i=r;if("string"!=typeof i)throw new TypeError("Invalid operator type, expected string but got "+typeof i);if(-1===l.indexOf(i))throw new Error("Invalid operator, expected one of "+l.join("|"));i=e,e=o(e=t),i=o(i),t=e.pop(),n=i.pop();var n,i=0!==(e=s(e,i))?e:t&&n?s(t.split("."),n.split(".")):t||n?t?-1:1:0;return u[r].includes(i)},u={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},l=Object.keys(u),g=class{constructor(t,e,r){this.uri=t,this.name=e,this.image=r,this.artists=[],this.discs=new Map}artists;discs;getTracks(){const r=[];return this.discs.forEach((t,e)=>r.push(...t)),r}getDuration(){return this.getTracks().map(t=>t.duration).reduce((t,e)=>t+e)}},L=class{constructor(t,e){this.name=t,this.image=e,this.uri="spotify:local:"+t}uri},B=class{constructor(t,e,r){this.localTrack=t,this.album=e,this.artists=r}get addedAt(){return this.localTrack.addedAt}get uri(){return this.localTrack.uri}get name(){return this.localTrack.name}get duration(){return this.localTrack.duration.milliseconds}get discNumber(){return this.localTrack.discNumber}get trackNumber(){return this.localTrack.trackNumber}},K=((t,e,r)=>{r=null!=t?D(U(t)):{};var i=!e&&t&&t.__esModule?r:a(r,"default",{value:t,enumerable:!0}),n=t,o=void 0,s=void 0;if(n&&"object"==typeof n||"function"==typeof n)for(let t of c(n))R.call(i,t)||t===o||a(i,t,{get:()=>n[t],enumerable:!(s=F(n,t))||s.enumerable});return i})(r()),V=function(t,e){return(V=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}))(t,e)},h=ft(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}),I.prototype.unsubscribe=function(){var e,t,r;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var n=ht(i),o=n.next();!o.done;o=n.next())o.value.remove(this)}catch(t){a={error:t}}finally{try{o&&!o.done&&(s=n.return)&&s.call(n)}finally{if(a)throw a.error}}else i.remove(this);var s=this.initialTeardown;if(T(s))try{s()}catch(t){r=t instanceof h?t.errors:[t]}var a=this._finalizers;if(a){this._finalizers=null;try{for(var c=ht(a),u=c.next();!u.done;u=c.next()){var l=u.value;try{mt(l)}catch(t){r=null!=r?r:[],t instanceof h?r=O(O([],k(r)),k(t.errors)):r.push(t)}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}}if(r)throw new h(r)}},I.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)mt(t);else{if(t instanceof I){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!=(e=this._finalizers)?e:[]).push(t)}},I.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},I.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},I.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&pt(e,t)},I.prototype.remove=function(t){var e=this._finalizers;e&&pt(e,t),t instanceof I&&t._removeParent(this)},I.EMPTY=((r=new I).closed=!0,r),Y=(f=I).EMPTY,p={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},d={setTimeout:function(t,e){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var n=d.delegate;return null!=n&&n.setTimeout?n.setTimeout.apply(n,O([t,e],k(r))):setTimeout.apply(void 0,O([t,e],k(r)))},clearTimeout:function(t){var e=d.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0},W=yt("C",void 0,void 0),m=null,x(E,X=f),E.create=function(t,e,r){return new b(t,e,r)},E.prototype.next=function(t){this.isStopped?wt(yt("N",t,void 0),this):this._next(t)},E.prototype.error=function(t){this.isStopped?wt(yt("E",void 0,t),this):(this.isStopped=!0,this._error(t))},E.prototype.complete=function(){this.isStopped?wt(W,this):(this.isStopped=!0,this._complete())},E.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,X.prototype.unsubscribe.call(this),this.destination=null)},E.prototype._next=function(t){this.destination.next(t)},E.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},E.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},q=E,G=Function.prototype.bind,N.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){C(t)}},N.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){C(t)}else C(t)},N.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){C(t)}},Q=N,x(gt,Z=q),b=gt,tt={closed:!0,next:bt,error:function(t){throw t},complete:bt},r="function"==typeof Symbol&&Symbol.observable||"@@observable",j.prototype.lift=function(t){var e=new j;return e.source=this,e.operator=t,e},j.prototype.subscribe=function(t,e,r){var i,n=this,o=(i=t)&&i instanceof q||function(t){return t&&T(t.next)&&T(t.error)&&T(t.complete)}(i)&&dt(i)?t:new b(t,e,r);return A(function(){var t=n.operator,e=n.source;o.add(t?t.call(o,e):e?n._subscribe(o):n._trySubscribe(o))}),o},j.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},j.prototype.forEach=function(i,t){var n=this;return new(t=_t(t))(function(t,e){var r=new b({next:function(t){try{i(t)}catch(t){e(t),r.unsubscribe()}},error:e,complete:t});n.subscribe(r)})},j.prototype._subscribe=function(t){var e;return null==(e=this.source)?void 0:e.subscribe(t)},j.prototype[r]=function(){return this},j.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?St:1===e.length?e[0]:function(t){return e.reduce(function(t,e){return e(t)},t)})(this)},j.prototype.toPromise=function(t){var i=this;return new(t=_t(t))(function(t,e){var r;i.subscribe(function(t){return r=t},function(t){return e(t)},function(){return t(r)})})},j.create=function(t){return new j(t)},et=j,it=ft(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),x(P,rt=et),P.prototype.lift=function(t){var e=new ot(this,this);return e.operator=t,e},P.prototype._throwIfClosed=function(){if(this.closed)throw new it},P.prototype.next=function(n){var o=this;A(function(){var e,t;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var r=ht(o.currentObservers),i=r.next();!i.done;i=r.next())i.value.next(n)}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}}})},P.prototype.error=function(e){var r=this;A(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var t=r.observers;t.length;)t.shift().error(e)}})},P.prototype.complete=function(){var e=this;A(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},P.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(P.prototype,"observed",{get:function(){var t;return 0<(null==(t=this.observers)?void 0:t.length)},enumerable:!1,configurable:!0}),P.prototype._trySubscribe=function(t){return this._throwIfClosed(),rt.prototype._trySubscribe.call(this,t)},P.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},P.prototype._innerSubscribe=function(t){var e=this,r=this.hasError,i=this.isStopped,n=this.observers;return r||i?Y:(this.currentObservers=null,n.push(t),new f(function(){e.currentObservers=null,pt(n,t)}))},P.prototype._checkFinalizedStatuses=function(t){var e=this.hasError,r=this.thrownError,i=this.isStopped;e?t.error(r):i&&t.complete()},P.prototype.asObservable=function(){var t=new et;return t.source=this,t},P.create=function(t,e){return new ot(t,e)},x(M,nt=r=P),M.prototype.next=function(t){var e,r;null!=(r=null==(e=this.destination)?void 0:e.next)&&r.call(e,t)},M.prototype.error=function(t){var e,r;null!=(r=null==(e=this.destination)?void 0:e.error)&&r.call(e,t)},M.prototype.complete=function(){var t,e;null!=(e=null==(t=this.destination)?void 0:t.complete)&&e.call(t)},M.prototype._subscribe=function(t){var e;return null!=(e=null==(e=this.source)?void 0:e.subscribe(t))?e:Y},ot=M,x(z,y=r),Object.defineProperty(z.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),z.prototype._subscribe=function(t){var e=y.prototype._subscribe.call(this,t);return e.closed||t.next(this._value),e},z.prototype.getValue=function(){var t=this.hasError,e=this.thrownError,r=this._value;if(t)throw e;return this._throwIfClosed(),r},z.prototype.next=function(t){y.prototype.next.call(this,this._value=t)},v=z,w="local-files:has-cache",S="local-files:merged-albums",st=class{get hasCache(){let t=localStorage.getItem(w);var e;return null===t&&(e=JSON.stringify(!0),localStorage.setItem(w,e),t=e),JSON.parse(t)}set hasCache(t){localStorage.setItem(w,JSON.stringify(t))}get cache(){let t=localStorage.getItem(S);var e;return null===t&&(e=JSON.stringify([]),localStorage.setItem(S,e),t=e),JSON.parse(t)}set cache(t){localStorage.setItem(S,JSON.stringify(t))}},at=class{storageService=new st;isInitializedSubject=new v(!1);isInitializing=!1;isReady$=this.isInitializedSubject.asObservable();get isReady(){return this.isInitializedSubject.value}tracks=new Map;albums=new Map;artists=new Map;getTracks(){return this.tracks}getAlbums(){return this.albums}getArtists(){return this.artists}processedAlbumsSubject=new v(0);processedAlbums$=this.processedAlbumsSubject.asObservable();albumCountSubject=new v(0);albumCount$=this.albumCountSubject.asObservable();getArtistTracks(e){return Array.from(this.tracks.values()).filter(t=>t.artists.some(t=>t.uri===e)).sort((t,e)=>_(t.album.name,e.album.name,"ascending")||_(t.discNumber,e.discNumber,"ascending")||_(t.trackNumber,e.trackNumber,"ascending"))}getDisplayName(t){return""===t?"Untitled":t}albumKeyFromName(t){return"spotify:uri:"+t.toLowerCase().replace(/\s/g,"+")}async clearCache(){this.isInitializedSubject.next(!1),this.storageService.cache=[],this.storageService.hasCache=!0,await this.init()}async reset(){this.isInitializedSubject.next(!1),this.storageService.cache=[],this.storageService.hasCache=!1,await this.init()}async init(){if(!this.isReady&&!this.isInitializing){this.isInitializing=!0,this.tracks=new Map,this.albums=new Map,this.artists=new Map;try{await this.processLocalTracks(),await this.postProcessAlbums()}catch(t){console.error("Error while processing",t);let e="Error while processing local files; clearing the cache";t instanceof Error&&(e+=": "+t.message),Spicetify.showNotification(e,!0,5e3),this.storageService.cache=[],this.storageService.hasCache=!0}this.isInitializedSubject.next(!0),this.isInitializing=!1}}async processLocalTracks(){for(const i of await(await ut("LocalFilesAPI")).getTracks()){let e;var t=this.getDisplayName(i.album.name),r=this.albumKeyFromName(t),t=(this.albums.has(r)?e=this.albums.get(r):(e=new g(r,t,this.getImageUrlFromAlbum(i.album)),this.albums.set(r,e)),i.artists.flatMap(t=>this.getArtistsFromString(t.name,e.image)));for(const n of t)this.artists.has(n.uri)||this.artists.set(n.uri,n),e.artists.some(t=>t.uri===n.uri)||e.artists.push(n);r=new B(i,e,t);this.tracks.set(r.uri,r),e.discs.has(i.discNumber)||e.discs.set(i.discNumber,[]),e.discs.get(i.discNumber)?.push(r)}}async postProcessAlbums(){var t,e,r=this.storageService.hasCache,i=[],n=[],o=[];this.albumCountSubject.next(this.albums.size);let s=0;for([t,e]of this.albums.entries()){this.processedAlbumsSubject.next(s+1),s++;var a=await this.postProcessAlbum(t,e);if(!(a.length<=1)){n.push(t);for(var[c,u]of a.entries())if(0!==u.tracks.length){var l=u.tracks[0],c=this.albumKeyFromName(e.name+" "+c),h=new g(c,e.name,this.getImageUrlFromAlbum(l.localTrack.album));for(const d of l.artists)h.artists.some(t=>t.uri===d.uri)||h.artists.push(d);for(const m of u.tracks)(m.album=h).discs.has(m.localTrack.discNumber)||h.discs.set(m.localTrack.discNumber,[]),h.discs.get(m.localTrack.discNumber)?.push(m);o.push(h)}i.push({uri:t,tracks:a.map(t=>t.tracks.map(t=>t.uri))})}}r||(this.storageService.cache=i,this.storageService.hasCache=!0);for(const b of n)this.albums.delete(b);for(const y of o)this.albums.set(y.uri,y);for(const v of this.albums.values())for(var[f,p]of v.discs.entries())v.discs.set(f,p.toSorted((t,e)=>_(t.trackNumber,e.trackNumber,"ascending")))}async postProcessAlbum(e,t){var r=this.storageService.hasCache,i=this.storageService.cache;let n=[];if(r){r=i.find(t=>t.uri===e);void 0!==r&&(n=r.tracks.map(t=>({cover:null,tracks:t.filter(t=>this.tracks.has(t)).map(t=>this.tracks.get(t))})))}else{if(t.artists.length<=1)return[];i=t.getTracks();if(i.length<=1)return[];var o=new Map;for(const c of i){var s=c.artists.map(t=>t.name).join(", ");o.has(s)?o.get(s)?.push(c):o.set(s,[c])}if(1===o.size)return[];for(const u of o.values()){var a=this.getImageUrlFromAlbum(u[0].localTrack.album);let t;try{t=await this.getImage(a)}catch(t){console.error(`Couldn't load image "${a}"`,t),n.push({tracks:u,cover:null});continue}const l=this.getImageDataFromCanvas(t);a=n.find(t=>0===this.getImageDifferenceWithPixelMatch(t.cover,l));void 0===a?n.push({tracks:u,cover:l}):a.tracks.push(...u)}}return n}getArtistsFromString(t,e){return t.split(/[;,]/).map(t=>new L(this.getDisplayName(t.trim()),e))}async getImage(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t(r)},r.onerror=t=>{e(t)},r.src=i})}getImageDataFromCanvas(t){var e=document.createElement("canvas"),e=(e.width=50,e.height=50,e.style.width="50px",e.style.height="50px",e.getContext("2d"));return e.drawImage(t,0,0,t.width,t.height,0,0,50,50),e.getImageData(0,0,50,50)}getImageDifferenceWithPixelMatch(t,e){return(0,K.default)(t.data,e.data,null,t.width,t.height,{threshold:.1})}getImageUrlFromAlbum(t){return 0===t.images.length?"":t.images[0].url}},(async()=>{for(window.localTracksService=new at;!Spicetify?.Platform;)await new Promise(t=>setTimeout(t,100));await 0;var t=await ut("History");const e=new Spicetify.Menu.Item("Rebuild local album cache",!1,async()=>{await window.localTracksService.reset()}),r=new Spicetify.Menu.Item("Clear local album cache",!1,async()=>{await window.localTracksService.clearCache()}),i=t=>{t.includes("better-local-files")?(e.register(),r.register()):(e.deregister(),r.deregister())};i(t.location.pathname),t.listen(t=>{i(t.pathname)}),async function(t,r){var i=await ut("History");const n=async()=>{await lt(t,r)||Spicetify.showNotification("📢 A new version of the custom app is available.",!1,5e3)};if(i.location.pathname==="/"+r)await n();else{let e=null;e=i.listen(async t=>{t.pathname==="/"+r&&(await n(),e?.())})}}("2.0.2","better-local-files")})();function ct(t){return Spicetify.Platform?.[t]}async function ut(t){return async function(t){let e=t();for(;void 0===e;)await new Promise(t=>setTimeout(t,100)),e=t();return e}(()=>ct(t))}async function lt(t,e){e=await(await(await fetch(`https://raw.githubusercontent.com/Pithaya/spicetify-apps/main/custom-apps/${e}/package.json`)).json()).version;return J(t,e,">=")}function _(t,e,r){r="descending"===r?-1:1;return e<t?r:t<e?-1*r:0}function x(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}V(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function ht(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&i>=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function O(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||((i=i||Array.prototype.slice.call(e,0,n))[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function T(t){return"function"==typeof t}function ft(t){t=t(function(t){Error.call(t),t.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t}function pt(t,e){t&&0<=(e=t.indexOf(e))&&t.splice(e,1)}function I(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}function dt(t){return t instanceof f||t&&"closed"in t&&T(t.remove)&&T(t.add)&&T(t.unsubscribe)}function mt(t){T(t)?t():t.unsubscribe()}function bt(){}function yt(t,e,r){return{kind:t,value:e,error:r}}function A(t){if(p.useDeprecatedSynchronousErrorHandling){var e=!m;if(e&&(m={errorThrown:!1,error:null}),t(),e){var e=m,r=e.errorThrown,e=e.error;if(m=null,r)throw e}}else t()}function E(t){var e=X.call(this)||this;return e.isStopped=!1,t?dt(e.destination=t)&&t.add(e):e.destination=tt,e}function vt(t,e){return G.call(t,e)}function N(t){this.partialObserver=t}function gt(t,e,r){var i=Z.call(this)||this;return r=T(t)||!t?{next:null!=t?t:void 0,error:null!=e?e:void 0,complete:null!=r?r:void 0}:i&&p.useDeprecatedNextContext?((e=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},{next:t.next&&vt(t.next,e),error:t.error&&vt(t.error,e),complete:t.complete&&vt(t.complete,e)}):t,i.destination=new Q(r),i}function C(t){var e,r;p.useDeprecatedSynchronousErrorHandling?(r=t,p.useDeprecatedSynchronousErrorHandling&&m&&(m.errorThrown=!0,m.error=r)):(e=t,d.setTimeout(function(){var t=p.onUnhandledError;if(!t)throw e;t(e)}))}function wt(t,e){var r=p.onStoppedNotification;r&&d.setTimeout(function(){return r(t,e)})}function St(t){return t}function j(t){t&&(this._subscribe=t)}function _t(t){return null!=(t=null!=t?t:p.Promise)?t:Promise}function P(){var t=rt.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}function M(t,e){var r=nt.call(this)||this;return r.destination=t,r.source=e,r}function z(t){var e=y.call(this)||this;return e._value=t,e}}();