mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
1 line
40 KiB
JavaScript
1 line
40 KiB
JavaScript
!async function(){for(;!Spicetify.React||!Spicetify.ReactDOM;)await new Promise(t=>setTimeout(t,10));var I,o,M,A,$,z,t,e,n,r,F,q,U,W,J,K,H,Q,G,Y,Z,V,X,h,s,tt,i,a,et,c,nt,u,rt,it,st,l,at,f,d,p,ot,ct,ut,b,lt,ht,g,ft,dt,pt,bt,gt,yt,vt,y,v,mt,wt,St,xt,Bt,Pt,Et,_t,kt,Ct,Dt,m,w,Rt,jt,S,Nt,Ot,Tt;I=Object.create,o=Object.defineProperty,M=Object.getOwnPropertyDescriptor,A=Object.getOwnPropertyNames,$=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty,e=(t,e,n)=>{n=null!=t?I($(t)):{};var r=!e&&t&&t.__esModule?n:o(n,"default",{value:t,enumerable:!0}),i=t,s=void 0,a=void 0;if(i&&"object"==typeof i||"function"==typeof i)for(let t of A(i))z.call(r,t)||t===s||o(r,t,{get:()=>i[t],enumerable:!(a=M(i,t))||a.enumerable});return r},n=(t,e,n)=>{var r;return r=n,(e="symbol"!=typeof e?e+"":e)in(t=t)?o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,n},r=(t=(t,e)=>function(){return e||(0,t[A(t)[0]])((e={exports:{}}).exports,e),e.exports})({"external-global-plugin:react"(t,e){e.exports=Spicetify.React}}),F=e(t({"external-global-plugin:react-dom"(t,e){e.exports=Spicetify.ReactDOM}})()),q=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,U=t=>{if("string"!=typeof t)throw new TypeError("Invalid argument expected string");var e=t.match(q);if(e)return e.shift(),e;throw new Error(`Invalid argument not valid semver ('${t}' received)`)},W=t=>"*"===t||"x"===t||"X"===t,J=t=>{var e=parseInt(t,10);return isNaN(e)?t:e},K=(t,e)=>{return W(t)||W(e)?0:([t,e]=(t=J(t),e=J(e),typeof t!=typeof e?[String(t),String(e)]:[t,e]),e<t?1:t<e?-1:0)},H=(e,n)=>{for(let t=0;t<Math.max(e.length,n.length);t++){var r=K(e[t]||"0",n[t]||"0");if(0!==r)return r}return 0},Q=(t,e,n)=>{var r=n;if("string"!=typeof r)throw new TypeError("Invalid operator type, expected string but got "+typeof r);if(-1===Y.indexOf(r))throw new Error("Invalid operator, expected one of "+Y.join("|"));r=e,e=U(e=t),r=U(r),t=e.pop(),i=r.pop();var i,r=0!==(e=H(e,r))?e:t&&i?H(t.split("."),i.split(".")):t||i?t?-1:1:0;return G[n].includes(r)},G={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},Y=Object.keys(G),Z=class{analysis;constructor(t){t={bars:t.bars.map(t=>this.toRemixed(t)),beats:t.beats.map(t=>this.toRemixed(t)),sections:t.sections.map(t=>this.toRemixedSection(t)),segments:t.segments.map(t=>this.toRemixedSegment(t)),tatums:t.tatums.map(t=>this.toRemixed(t))};this.analysis=t}toRemixed(t){return{...t,firstOverlappingSegment:void 0,overlappingSegments:[],children:[],parent:void 0,indexInParent:0,prev:void 0,next:void 0,index:0}}toRemixedSection(t){return{...t,children:[],prev:void 0,next:void 0,index:0}}toRemixedSegment(t){return{...t,parent:void 0,indexInParent:0,prev:void 0,next:void 0,index:0}}remixTrack(){return this.preprocessTrack()}preprocessTrack(){for(const r of["sections","bars","beats","tatums","segments"]){var t,e,n=this.analysis[r];for([t,e]of n.entries())0<(e.index=t)?e.prev=n[t-1]:e.prev=null,t<n.length-1?e.next=n[t+1]:e.next=null}return this.connectQuanta(this.analysis.sections,this.analysis.bars),this.connectQuanta(this.analysis.bars,this.analysis.beats),this.connectQuanta(this.analysis.beats,this.analysis.tatums),this.connectQuanta(this.analysis.tatums,this.analysis.segments),this.connectFirstOverlappingSegment(this.analysis,this.analysis.bars),this.connectFirstOverlappingSegment(this.analysis,this.analysis.beats),this.connectFirstOverlappingSegment(this.analysis,this.analysis.tatums),this.connectAllOverlappingSegments(this.analysis,this.analysis.bars),this.connectAllOverlappingSegments(this.analysis,this.analysis.beats),this.connectAllOverlappingSegments(this.analysis,this.analysis.tatums),this.analysis}connectQuanta(t,e){let n=0;for(const i of t){i.children=[];for(let t=n;t<e.length;t++){var r=e[t];if(r.start>=i.start&&r.start<i.start+i.duration)r.parent=i,r.indexInParent=i.children.length,i.children.push(r),n=t;else if(r.start>i.start)break}}}connectFirstOverlappingSegment(t,e){let n=0;var r=t.segments;for(const s of e)for(let t=n;t<r.length;t++){var i=r[t];if(i.start>=s.start){s.firstOverlappingSegment=i,n=t;break}}}connectAllOverlappingSegments(t,e){let n=0;var r=t.segments;for(const s of e){s.overlappingSegments=[];for(let t=n;t<r.length;t++){var i=r[t];if(!(i.start+i.duration<s.start)){if(i.start>s.start+s.duration)break;n=t,s.overlappingSegments.push(i)}}}}},V=class{beatsPlayed=0;startTime=0;track;analysis;graph;currentRandomBranchChance=0;constructor(t,e,n){this.track=t,this.analysis=e,this.graph=n,this.currentRandomBranchChance=window.jukebox.settings.minRandomBranchChance,this.startTime=(new Date).getTime()}},X=function(t,e){return(X=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)},h=Ut(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}}),C.prototype.unsubscribe=function(){var e,t,n;if(!this.closed){this.closed=!0;var r=this._parentage;if(r)if(this._parentage=null,Array.isArray(r))try{for(var i=B(r),s=i.next();!s.done;s=i.next())s.value.remove(this)}catch(t){o={error:t}}finally{try{s&&!s.done&&(a=i.return)&&a.call(i)}finally{if(o)throw o.error}}else r.remove(this);var a=this.initialTeardown;if(k(a))try{a()}catch(t){n=t instanceof h?t.errors:[t]}var o=this._finalizers;if(o){this._finalizers=null;try{for(var c=B(o),u=c.next();!u.done;u=c.next()){var l=u.value;try{Kt(l)}catch(t){n=null!=n?n:[],t instanceof h?n=E(E([],P(n)),P(t.errors)):n.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(n)throw new h(n)}},C.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Kt(t);else{if(t instanceof C){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!=(e=this._finalizers)?e:[]).push(t)}},C.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},C.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},C.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Wt(e,t)},C.prototype.remove=function(t){var e=this._finalizers;e&&Wt(e,t),t instanceof C&&t._removeParent(this)},C.EMPTY=((t=new C).closed=!0,t),tt=(s=C).EMPTY,i={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},a={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=a.delegate;return null!=i&&i.setTimeout?i.setTimeout.apply(i,E([t,e],P(n))):setTimeout.apply(void 0,E([t,e],P(n)))},clearTimeout:function(t){var e=a.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0},et=Gt("C",void 0,void 0),c=null,x(R,nt=s),R.create=function(t,e,n){return new l(t,e,n)},R.prototype.next=function(t){this.isStopped?Xt(Gt("N",t,void 0),this):this._next(t)},R.prototype.error=function(t){this.isStopped?Xt(Gt("E",void 0,t),this):(this.isStopped=!0,this._error(t))},R.prototype.complete=function(){this.isStopped?Xt(et,this):(this.isStopped=!0,this._complete())},R.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,nt.prototype.unsubscribe.call(this),this.destination=null)},R.prototype._next=function(t){this.destination.next(t)},R.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},R.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},u=R,rt=Function.prototype.bind,j.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){Vt(t)}},j.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){Vt(t)}else Vt(t)},j.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){Vt(t)}},it=j,x(Zt,st=u),l=Zt,at={closed:!0,next:Qt,error:function(t){throw t},complete:Qt},f="function"==typeof Symbol&&Symbol.observable||"@@observable",N.prototype.lift=function(t){var e=new N;return e.source=this,e.operator=t,e},N.prototype.subscribe=function(t,e,n){var r,i=this,s=(r=t)&&r instanceof u||function(t){return t&&k(t.next)&&k(t.error)&&k(t.complete)}(r)&&Jt(r)?t:new l(t,e,n);return D(function(){var t=i.operator,e=i.source;s.add(t?t.call(s,e):e?i._subscribe(s):i._trySubscribe(s))}),s},N.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},N.prototype.forEach=function(r,t){var i=this;return new(t=ee(t))(function(t,e){var n=new l({next:function(t){try{r(t)}catch(t){e(t),n.unsubscribe()}},error:e,complete:t});i.subscribe(n)})},N.prototype._subscribe=function(t){var e;return null==(e=this.source)?void 0:e.subscribe(t)},N.prototype[f]=function(){return this},N.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(0===(e=t).length?te:1===e.length?e[0]:function(t){return e.reduce(function(t,e){return e(t)},t)})(this)},N.prototype.toPromise=function(t){var r=this;return new(t=ee(t))(function(t,e){var n;r.subscribe(function(t){return n=t},function(t){return e(t)},function(){return t(n)})})},N.create=function(t){return new N(t)},d=N,x(ie,p=u),ie.prototype.unsubscribe=function(){var t;this.shouldUnsubscribe&&!this.shouldUnsubscribe()||(t=this.closed,p.prototype.unsubscribe.call(this),t)||null==(t=this.onFinalize)||t.call(this)},ot=ie,ut=Ut(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),x(O,ct=d),O.prototype.lift=function(t){var e=new ht(this,this);return e.operator=t,e},O.prototype._throwIfClosed=function(){if(this.closed)throw new ut},O.prototype.next=function(i){var s=this;D(function(){var e,t;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var n=B(s.currentObservers),r=n.next();!r.done;r=n.next())r.value.next(i)}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}}})},O.prototype.error=function(e){var n=this;D(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var t=n.observers;t.length;)t.shift().error(e)}})},O.prototype.complete=function(){var e=this;D(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},O.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(O.prototype,"observed",{get:function(){var t;return 0<(null==(t=this.observers)?void 0:t.length)},enumerable:!1,configurable:!0}),O.prototype._trySubscribe=function(t){return this._throwIfClosed(),ct.prototype._trySubscribe.call(this,t)},O.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},O.prototype._innerSubscribe=function(t){var e=this,n=this.hasError,r=this.isStopped,i=this.observers;return n||r?tt:(this.currentObservers=null,i.push(t),new s(function(){e.currentObservers=null,Wt(i,t)}))},O.prototype._checkFinalizedStatuses=function(t){var e=this.hasError,n=this.thrownError,r=this.isStopped;e?t.error(n):r&&t.complete()},O.prototype.asObservable=function(){var t=new d;return t.source=this,t},O.create=function(t,e){return new ht(t,e)},x(T,lt=b=O),T.prototype.next=function(t){var e,n;null!=(n=null==(e=this.destination)?void 0:e.next)&&n.call(e,t)},T.prototype.error=function(t){var e,n;null!=(n=null==(e=this.destination)?void 0:e.error)&&n.call(e,t)},T.prototype.complete=function(){var t,e;null!=(e=null==(t=this.destination)?void 0:t.complete)&&e.call(t)},T.prototype._subscribe=function(t){var e;return null!=(e=null==(e=this.source)?void 0:e.subscribe(t))?e:tt},ht=T,x(L,g=b),Object.defineProperty(L.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),L.prototype._subscribe=function(t){var e=g.prototype._subscribe.call(this,t);return e.closed||t.next(this._value),e},L.prototype.getValue=function(){var t=this.hasError,e=this.thrownError,n=this._value;if(t)throw e;return this._throwIfClosed(),n},L.prototype.next=function(t){g.prototype.next.call(this,this._value=t)},ft=L,dt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t},pt="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator",bt=Array.isArray,gt=["addListener","removeListener"],yt=["addEventListener","removeEventListener"],vt=["on","off"],n(v=y=class{maxBranchDistance=y.defaultBranchDistance;useDynamicBranchDistance=!1;minRandomBranchChance=y.defaultMinRandomBranchChance;maxRandomBranchChance=y.defaultMaxRandomBranchChance;randomBranchChanceDelta=y.defaultRandomBranchChanceDelta;maxJukeboxPlayTime=0;addLastEdge=!0;justBackwards=!1;justLongBranches=!1;removeSequentialBranches=!1;alwaysFollowLastBranch=!0;static fromPartial(t){var e=new y;return e.maxBranchDistance=t.maxBranchDistance,e.useDynamicBranchDistance=t.useDynamicBranchDistance,e.minRandomBranchChance=t.minRandomBranchChance,e.maxRandomBranchChance=t.maxRandomBranchChance,e.randomBranchChanceDelta=t.randomBranchChanceDelta,e.addLastEdge=t.addLastEdge,e.justBackwards=t.justBackwards,e.justLongBranches=t.justLongBranches,e.removeSequentialBranches=t.removeSequentialBranches,e.alwaysFollowLastBranch=t.alwaysFollowLastBranch,e.maxJukeboxPlayTime=t.maxJukeboxPlayTime,e}toPartial(){return{maxBranchDistance:this.maxBranchDistance,useDynamicBranchDistance:this.useDynamicBranchDistance,minRandomBranchChance:this.minRandomBranchChance,maxRandomBranchChance:this.maxRandomBranchChance,randomBranchChanceDelta:this.randomBranchChanceDelta,addLastEdge:this.addLastEdge,justBackwards:this.justBackwards,justLongBranches:this.justLongBranches,removeSequentialBranches:this.removeSequentialBranches,alwaysFollowLastBranch:this.alwaysFollowLastBranch,maxJukeboxPlayTime:this.maxJukeboxPlayTime}}},"minBeatsBeforeBranching",5),n(v,"rangeMinBranchDistance",2),n(v,"rangeMaxBranchDistance",80),n(v,"defaultBranchDistance",30),n(v,"defaultMinRandomBranchChance",.18),n(v,"defaultMaxRandomBranchChance",.5),n(v,"minRandomBranchChanceDelta",0),n(v,"maxRandomBranchChanceDelta",.2),n(v,"defaultRandomBranchChanceDelta",.018),mt=class{beats=[];lastBranchPoint=0;longestReach=0;constructor(t=[]){this.beats=t}},wt=class{get id(){return this.source.index+"-"+this.destination.index}source;destination;distance;isPlaying;deleted;constructor(t,e,n){this.source=t,this.destination=e,this.distance=n,this.isPlaying=!1,this.deleted=!1}},St=class{index;isPlaying=!1;next=null;previous=null;neighbours=[];start;duration;playCount=0;get end(){return this.start+this.duration}constructor(t,e,n){this.index=t,this.start=e,this.duration=n}toString(){return`[${this.index}]: ${this.start} - ${this.end} (${this.duration})`}isInBeat(t){return t>=this.start&&t<=this.end}},xt=class{constructor(t,e){this.settings=t,this.beats=e,this.graph=new mt,this.allNeighbours=e.map(()=>[]),this.minLongBranch=e.length/5}graph;allEdges=[];allNeighbours=[];minLongBranch=0;computedMaxBranchDistance=0;maxBranches=4;generateGraph(){var t,e,n=this.beats.map(t=>new St(t.index,1e3*t.start,1e3*t.duration));for([t,e]of n.entries())t<n.length-1&&(e.next=n[t+1]),0<t&&(e.previous=n[t-1]);return this.graph=new mt(n),this.precalculateNearestNeighbors(),this.settings.useDynamicBranchDistance?this.dynamicCollectNearestNeighbors():(this.collectNearestNeighbors(this.settings.maxBranchDistance),this.computedMaxBranchDistance=this.settings.maxBranchDistance),this.postProcessNearestNeighbors(),this.graph}dynamicCollectNearestNeighbors(){var t=this.beats.length/6;let e;for(e=10;e<v.rangeMaxBranchDistance&&!(t<=this.collectNearestNeighbors(e));e+=5);this.computedMaxBranchDistance=e}precalculateNearestNeighbors(){if(0===this.allEdges.length)for(const t of this.beats)this.calculateNearestNeighborsForBeat(t)}calculateNearestNeighborsForBeat(n){var t,r,e=this.maxBranches,i=v.rangeMaxBranchDistance,s=[];for([t,r]of this.beats.entries())if(t!==n.index){let e=0;for(var[a,o]of n.overlappingSegments.entries()){let t=100;a<r.overlappingSegments.length&&(a=r.overlappingSegments[a],t=o.index===a.index?100:this.getSegmentsDistance(o,a)),e+=t}var c=n.indexInParent===r.indexInParent?0:100,c=e/n.overlappingSegments.length+c;c<i&&(c=new wt(this.graph.beats[n.index],this.graph.beats[t],c),s.push(c))}s.sort((t,e)=>t.distance>e.distance?1:e.distance>t.distance?-1:0);for(let t=0;t<e&&t<s.length;t++){var u=s[t];this.allNeighbours[n.index].push(u),this.allEdges.push(u)}}getSegmentsDistance(t,e){return+this.getEuclideanDistance(t.timbre,e.timbre)+10*this.getEuclideanDistance(t.pitches,e.pitches)+ +Math.abs(t.loudness_start-e.loudness_start)+ +Math.abs(t.loudness_max-e.loudness_max)+100*Math.abs(t.duration-e.duration)+ +Math.abs(t.confidence-e.confidence)}getEuclideanDistance(e,n){let r=0;for(let t=0;t<e.length;t++){var i=n[t]-e[t];r+=i*i}return Math.sqrt(r)}collectNearestNeighbors(t){let e=0;for(var[n,r]of this.graph.beats.entries())r.neighbours=this.filterNearestNeighbors(n,t),0<r.neighbours.length&&(e+=1);return e}filterNearestNeighbors(e,n){return this.allNeighbours[e].filter(t=>!t.deleted&&!(this.settings.justBackwards&&t.destination.index>e||this.settings.justLongBranches&&Math.abs(t.destination.index-e)<this.minLongBranch)&&t.distance<=n)}postProcessNearestNeighbors(){this.settings.addLastEdge&&this.insertBestBackwardBranch(this.computedMaxBranchDistance,this.longestBackwardBranch()<50?65:55),this.graph.lastBranchPoint=this.findBestLastBeat(),this.filterOutBadBranches(),this.settings.removeSequentialBranches&&this.filterOutSequentialBranches()}longestBackwardBranch(){let t=0;for(const n of this.graph.beats)for(const r of n.neighbours){var e=n.index-r.destination.index;e>t&&(t=e)}return 100*t/this.beats.length}insertBestBackwardBranch(t,e){var n,r,i,s,a=[];for([n,r]of this.graph.beats.entries())for(const l of this.allNeighbours[n]){var o=l.destination.index,c=l.distance,u=n-o;0<u&&c<e&&(c=100*u/this.graph.beats.length,a.push({percentDistance:c,beatIndex:n,otherBeatIndex:o,currentBeat:r,edge:l}))}0!==a.length&&(a.sort((t,e)=>t.percentDistance-e.percentDistance),a.reverse(),s=(i=a[0]).currentBeat,t<(t=i.edge).distance)&&s.neighbours.push(t)}calculateReachability(){const n=this.graph.beats.map(t=>0);this.graph.beats.forEach((t,e)=>{n[e]=this.graph.beats.length-e});for(let t=0;t<1e3;t++){let e=0;for(var[r,i]of this.graph.beats.entries()){let t=!1;for(const a of i.neighbours){var s=n[a.destination.index];s>n[r]&&(n[r]=s,t=!0)}if(r<this.graph.beats.length-1&&(i=n[r+1])>n[r]&&(n[r]=i,t=!0),t){e++;for(let t=0;t<r;t++)n[t]<n[r]&&(n[t]=n[r])}}if(0===e)break}return n}findBestLastBeat(){var e=this.calculateReachability();let n=0,r=0;for(let t=this.graph.beats.length-1;0<=t;t--){var i=this.graph.beats[t],s=this.graph.beats.length-t,s=100*(e[t]-s)/this.beats.length;if(s>r&&0<i.neighbours.length&&(r=s,n=t,50<=s))break}return this.graph.longestReach=r,n}filterOutBadBranches(){const e=this.graph.lastBranchPoint;for(let t=0;t<e;t++){var n=this.graph.beats[t];n.neighbours=n.neighbours.filter(t=>t.destination.index<e)}}filterOutSequentialBranches(){for(let t=this.graph.beats.length-1;1<=t;t--){const e=this.graph.beats[t];e.neighbours=e.neighbours.filter(t=>!this.hasSequentialBranch(e,t))}}hasSequentialBranch(t,e){if(t.index!==this.graph.lastBranchPoint){var n=t.previous;if(null!==n){var r=t.index-e.destination.index;for(const i of n.neighbours)if(r==n.index-i.destination.index)return!0}}return!1}},Bt=class{constructor(t,e){this.songState=t,this.settings=e}playerSubscription=new s;currentBeat=null;bouncing=!1;bounceSeed=null;bounceCount=0;lastBranch=null;isSeekingResolver=null;beatsSinceLastBranch=0;onProgressSubject=new b;onProgress$=this.onProgressSubject.asObservable();start(){this.logDebug("Driver started."),document.addEventListener("keydown",this.onBounceKeyDown),document.addEventListener("keyup",this.onBounceKeyUp);var t=le(Spicetify.Player,"onprogress").pipe(oe(t=>t.data),fe()).subscribe(t=>{this.process(t)});this.playerSubscription.add(t)}onBounceKeyDown=t=>{"Shift"===t.key&&(this.bouncing=!0)};onBounceKeyUp=t=>{"Shift"===t.key&&(this.bouncing=!1)};async process(t){if(null!==this.isSeekingResolver){if(this.logDebug(`Is seeking... ${t} -> `+this.currentBeat?.start),!this.isSeekingResolver(t))return;this.isSeekingResolver=null}if(this.logDebug(`Processing with current beat: ${this.currentBeat?.toString()}, player time: `+Spicetify.Player.getProgress()),null!==this.lastBranch&&this.setLastBranchPlaying(!1),null!==this.currentBeat){if(this.currentBeat.isInBeat(t))return;this.currentBeat.isPlaying=!1}this.beatsSinceLastBranch++;var e=this.currentBeat?.next?.end,n=this.currentBeat?.previous?.start,e=null!=e&&e<t||null!=n&&t<n,n=(e&&console.error(`Out of sync ! ${t} - `+this.currentBeat?.toString()),this.currentBeat);this.currentBeat=this.getNextBeat(t,e),null!==this.currentBeat&&(this.logDebug(`Got next beat: ${this.currentBeat?.index}, with time: ${this.currentBeat?.start} - ${this.currentBeat?.end}, player time: `+Spicetify.Player.getProgress()),await this.playBeat(n,this.currentBeat,t,e),this.currentBeat.playCount+=1,this.songState.beatsPlayed+=1,null!==n&&(n.isPlaying=!1),this.currentBeat.isPlaying=!0,this.onProgressSubject.next())}async playBeat(t,e,n,r){if(null!==t&&t.index+1!==e.index&&!r){r=Spicetify.Player.getProgress()-t.end;const i=e.start+r;this.logDebug(`Seek to: ${i}ms, from ${n}ms, with offset `+r);t=i>Spicetify.Player.getProgress();this.isSeekingResolver=t?t=>t>=i:t=>t<=i+1e3,this.logDebug(`Time to get there: ${Math.abs(Spicetify.Player.getProgress()-n)}ms`),await Mt("PlayerAPI").seekTo(i)}}getNextBeat(t,e){if(null===this.currentBeat||e){for(const n of this.songState.graph.beats)if(t>=n.start&&t<=n.end)return n;return this.songState.graph.beats[0]}return this.bouncing?(null===this.bounceSeed&&(this.bounceSeed=this.currentBeat,this.bounceCount=0),this.bounceCount++%2==1?this.selectNextNeighbor(this.bounceSeed):this.bounceSeed):null!=this.bounceSeed?(e=this.bounceSeed,this.bounceSeed=null,e):(e=this.currentBeat.index+1)>=this.songState.graph.beats.length?(this.stop(),null):this.selectRandomNextBeat(this.songState.graph.beats[e])}selectRandomNextBeat(t){var e;return 0!==t.neighbours.length&&this.shouldRandomBranch(t)?(e=t.neighbours.shift(),t.neighbours.push(e),this.beatsSinceLastBranch=0,this.lastBranch=e,this.setLastBranchPlaying(!0),e.destination):t}setLastBranchPlaying(t){null!==this.lastBranch&&(this.lastBranch.isPlaying=t,this.lastBranch.source.isPlaying=t,this.lastBranch.destination.isPlaying=t)}selectNextNeighbor(t){var e;return 0===t.neighbours.length?t:(e=t.neighbours.shift(),t.neighbours.push(e),this.lastBranch=e,this.setLastBranchPlaying(!0),e.destination)}shouldRandomBranch(t){if(t.index===this.songState.graph.lastBranchPoint&&this.settings.alwaysFollowLastBranch)return!0;if(this.beatsSinceLastBranch<=v.minBeatsBeforeBranching)return!1;t=(new Date).getTime()-this.songState.startTime;if(0<this.settings.maxJukeboxPlayTime&&t>this.settings.maxJukeboxPlayTime)return this.songState.currentRandomBranchChance=0,!1;this.songState.currentRandomBranchChance=Math.min(this.songState.currentRandomBranchChance+this.settings.randomBranchChanceDelta,this.settings.maxRandomBranchChance);t=Math.random()<this.songState.currentRandomBranchChance;return t&&(this.songState.currentRandomBranchChance=this.settings.minRandomBranchChance),t}stop(){this.playerSubscription.unsubscribe(),this.playerSubscription=new s,document.removeEventListener("keydown",this.onBounceKeyDown),document.removeEventListener("keyup",this.onBounceKeyUp)}logDebug(t){}},n(Et=Pt=class{static get settings(){return v.fromPartial(Pt.storedSettings)}static set settings(t){Pt.storedSettings=t.toPartial()}static get storedSettings(){var t=Spicetify.LocalStorage.get(this.settingId);return null==t?(new v).toPartial():JSON.parse(t)}static set storedSettings(t){Spicetify.LocalStorage.set(this.settingId,JSON.stringify(t))}},"settingId","jukebox:settings"),_t=class extends Error{},Dt=class{_songState=null;songStateSubject=new ft(null);songState$=this.songStateSubject.asObservable();get songState(){return this._songState}set songState(t){this._songState=t,this.songStateSubject.next(t)}settings;driver=null;get isEnabled(){return this.stateChangedSubject.value}async setEnabled(t){t?await this.enable():this.disable()}songChangedSubscription=new s;driverProcessSubscription=new s;statsChangedSubject=new b;statsChanged$=this.statsChangedSubject.asObservable();stateChangedSubject=new ft(!1);stateChanged$=this.stateChangedSubject.asObservable();constructor(){this.settings=Et.settings}async reloadSettings(){this.settings=Et.settings,this.isEnabled&&(this.stop(),await this.start())}async enable(){this.stateChangedSubject.next(!0);var t=le(Spicetify.Player,"songchange").subscribe(()=>{this.stop(),this.start()});this.songChangedSubscription.add(t),await this.start()}disable(){this.stop(),this.songChangedSubscription.unsubscribe(),this.songChangedSubscription=new s,this.stateChangedSubject.next(!1)}stop(){this.driver?.stop(),this.driver=null,this.driverProcessSubscription.unsubscribe(),this.driverProcessSubscription=new s,this.songState=null}async start(){var e=Spicetify.Player.data.item;if(void 0!==e){Spicetify.showNotification("Fetching analysis for song...");var n=Spicetify.URI.fromString(e.uri);if(Spicetify.URI.isLocalTrack(n))this.disableWithError("No analysis available for local tracks.");else if(Spicetify.URI.isEpisode(n))this.disableWithError("No analysis available for shows.");else{var r,n=pe(n);if(null===n)this.disableWithError("Couldn't get track id.");else{let t=null;try{t=await be(n)}catch{}null===t||0===t.beats.length?this.disableWithError("No analysis available for this track."):(n=new Z(t).remixTrack(),r=new xt(this.settings,n.beats).generateGraph(),this.songState=new V(e,n,r),this.driver=new Bt(this.songState,this.settings),this.driverProcessSubscription.add(this.driver.onProgress$.subscribe(()=>{this.statsChangedSubject.next({beatsPlayed:this.songState?.beatsPlayed??0,currentRandomBranchChance:this.songState?.currentRandomBranchChance??0,listenTime:null!==this.songState?(new Date).getTime()-this.songState.startTime:0})})),this.driver.start())}}}}disableWithError(t){Spicetify.showNotification(t,!0),this.disable()}},m=e(r()),w=e(r()),Rt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},kt="Infinity",Ct=[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]],(t=(0,w.forwardRef)(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,...a},o)=>(0,w.createElement)("svg",{ref:o,...Rt,width:e,height:e,stroke:t,strokeWidth:r?24*Number(n)/Number(e):n,className:["lucide","lucide-"+kt.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),i].join(" "),...a},[...Ct.map(([t,e])=>(0,w.createElement)(t,e)),...Array.isArray(s)?s:[s]]))).displayName=""+kt,jt=t,S=e(r(),1),Nt=(()=>"undefined"==typeof window?S.useEffect:S.useLayoutEffect)(),Ot=t=>t[1]?.next?t[1]:{next:t[1],error:t[2],complete:t[3]},Tt=e(r()),(async()=>{for(window.jukebox=new Dt;!Spicetify?.Platform;)await new Promise(t=>setTimeout(t,100));await 0;try{i=".player-controls__right",a=null,o=!(s=5e3);var t=await new Promise((t,e)=>{let n=document.querySelector(i);if(null!==n)o&&console.log("found element in querySelector"),t(n);else{const r=new MutationObserver(()=>{null!==(n=document.querySelector(i))&&(o&&console.log("found element in observer"),t(n),r.disconnect())});null===a&&(a=document.body),r.observe(a,{childList:!0,subtree:!0}),setTimeout(()=>{null===n&&(o&&console.log("trying to find element from querySelector again"),r.disconnect(),null!==(n=document.querySelector(i))?t(n):e(new Error(`Couldn't find the element "${i}".`)))},s)}});e=Tt.default.createElement(ye,null),n=t,r=F.default.createRoot(document.createElement("div")),e=F.default.createPortal(e,n),r.render(e),async function(t,n){var r=await It("History");const i=async()=>{await At(t,n)||Spicetify.showNotification("📢 A new version of the custom app is available.",!1,5e3)};if(r.location.pathname==="/"+n)await i();else{let e=null;e=r.listen(async t=>{t.pathname==="/"+n&&(await i(),e?.())})}}("1.0.0-beta.3","eternal-jukebox")}catch(t){console.error(t),Spicetify.showNotification("Failed to register the eternal jukebox playbar button",!0)}var e,n,r,i,s,a,o})();function Lt(t){return Spicetify.Platform?.[t]}async function It(t){return async function(t){let e=t();for(;void 0===e;)await new Promise(t=>setTimeout(t,100)),e=t();return e}(()=>Lt(t))}function Mt(t){var e=Lt(t);if(void 0===e)throw new Error(`Platform API "${t}" is not available`);return e}async function At(t,e){e=await(await(await fetch(`https://raw.githubusercontent.com/Pithaya/spicetify-apps/main/custom-apps/${e}/package.json`)).json()).version;return Q(t,e,">=")}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 n(){this.constructor=t}X(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function $t(t,a,o,c){return new(o=o||Promise)(function(n,e){function r(t){try{s(c.next(t))}catch(t){e(t)}}function i(t){try{s(c.throw(t))}catch(t){e(t)}}function s(t){var e;t.done?n(t.value):((e=t.value)instanceof o?e:new o(function(t){t(e)})).then(r,i)}s((c=c.apply(t,a||[])).next())})}function zt(r,i){var s,a,o,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function t(n){return function(t){var e=[n,t];if(s)throw new TypeError("Generator is already executing.");for(;c=u&&e[u=0]?0:c;)try{if(s=1,a&&(o=2&e[0]?a.return:e[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,e[1])).done)return o;switch(a=0,(e=o?[2&e[0],o.value]:e)[0]){case 0:case 1:o=e;break;case 4:return c.label++,{value:e[1],done:!1};case 5:c.label++,a=e[1],e=[0];continue;case 7:e=c.ops.pop(),c.trys.pop();continue;default:if(!(o=0<(o=c.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){c=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3]))c.label=e[1];else if(6===e[0]&&c.label<o[1])c.label=o[1],o=e;else{if(!(o&&c.label<o[2])){o[2]&&c.ops.pop(),c.trys.pop();continue}c.label=o[2],c.ops.push(e)}}e=i.call(r,c)}catch(t){e=[6,t],a=0}finally{s=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function B(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function P(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(r=s.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function E(t,e,n){if(n||2===arguments.length)for(var r,i=0,s=e.length;i<s;i++)!r&&i in e||((r=r||Array.prototype.slice.call(e,0,i))[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function _(t){return this instanceof _?(this.v=t,this):new _(t)}function Ft(t,e,n){var i,s,a;if(Symbol.asyncIterator)return i=n.apply(t,e||[]),s=[],a={},r("next"),r("throw"),r("return"),a[Symbol.asyncIterator]=function(){return this},a;throw new TypeError("Symbol.asyncIterator is not defined.");function r(r){i[r]&&(a[r]=function(n){return new Promise(function(t,e){1<s.push([r,n,t,e])||o(r,n)})})}function o(t,e){try{(n=i[t](e)).value instanceof _?Promise.resolve(n.value.v).then(c,u):l(s[0][2],n)}catch(t){l(s[0][3],t)}var n}function c(t){o("next",t)}function u(t){o("throw",t)}function l(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}}function qt(a){var t,e;if(Symbol.asyncIterator)return(t=a[Symbol.asyncIterator])?t.call(a):(a=B(a),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);throw new TypeError("Symbol.asyncIterator is not defined.");function n(s){e[s]=a[s]&&function(i){return new Promise(function(t,e){var n,r;i=a[s](i),n=t,t=e,r=i.done,e=i.value,Promise.resolve(e).then(function(t){n({value:t,done:r})},t)})}}}function k(t){return"function"==typeof t}function Ut(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 Wt(t,e){t&&0<=(e=t.indexOf(e))&&t.splice(e,1)}function C(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}function Jt(t){return t instanceof s||t&&"closed"in t&&k(t.remove)&&k(t.add)&&k(t.unsubscribe)}function Kt(t){k(t)?t():t.unsubscribe()}function Ht(e){a.setTimeout(function(){var t=i.onUnhandledError;if(!t)throw e;t(e)})}function Qt(){}function Gt(t,e,n){return{kind:t,value:e,error:n}}function D(t){if(i.useDeprecatedSynchronousErrorHandling){var e=!c;if(e&&(c={errorThrown:!1,error:null}),t(),e){var e=c,n=e.errorThrown,e=e.error;if(c=null,n)throw e}}else t()}function R(t){var e=nt.call(this)||this;return e.isStopped=!1,t?Jt(e.destination=t)&&t.add(e):e.destination=at,e}function Yt(t,e){return rt.call(t,e)}function j(t){this.partialObserver=t}function Zt(t,e,n){var r=st.call(this)||this;return n=k(t)||!t?{next:null!=t?t:void 0,error:null!=e?e:void 0,complete:null!=n?n:void 0}:r&&i.useDeprecatedNextContext?((e=Object.create(t)).unsubscribe=function(){return r.unsubscribe()},{next:t.next&&Yt(t.next,e),error:t.error&&Yt(t.error,e),complete:t.complete&&Yt(t.complete,e)}):t,r.destination=new it(n),r}function Vt(t){var e;i.useDeprecatedSynchronousErrorHandling?(e=t,i.useDeprecatedSynchronousErrorHandling&&c&&(c.errorThrown=!0,c.error=e)):Ht(t)}function Xt(t,e){var n=i.onStoppedNotification;n&&a.setTimeout(function(){return n(t,e)})}function te(t){return t}function N(t){t&&(this._subscribe=t)}function ee(t){return null!=(t=null!=t?t:i.Promise)?t:Promise}function ne(n){return function(t){if(k(null==(e=t)?void 0:e.lift))return t.lift(function(t){try{return n(t,this)}catch(t){this.error(t)}});var e;throw new TypeError("Unable to lift unknown Observable type")}}function re(t,e,n,r,i){return new ot(t,e,n,r,i)}function ie(e,n,t,r,i,s){var a=p.call(this,e)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,a._next=n?function(t){try{n(t)}catch(t){e.error(t)}}:p.prototype._next,a._error=r?function(t){try{r(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:p.prototype._error,a._complete=t?function(){try{t()}catch(t){e.error(t)}finally{this.unsubscribe()}}:p.prototype._complete,a}function O(){var t=ct.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}function T(t,e){var n=lt.call(this)||this;return n.destination=t,n.source=e,n}function L(t){var e=g.call(this)||this;return e._value=t,e}function se(t){if(t instanceof d)return t;if(null!=t){if(k(t[f]))return i=t,new d(function(t){var e=i[f]();if(k(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(dt(t))return r=t,new d(function(t){for(var e=0;e<r.length&&!t.closed;e++)t.next(r[e]);t.complete()});if(k(null==(e=t)?void 0:e.then))return n=t,new d(function(e){n.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Ht)});if(e=t,Symbol.asyncIterator&&k(null==e?void 0:e[Symbol.asyncIterator]))return ae(t);if(k(null==(e=t)?void 0:e[pt]))return a=t,new d(function(t){var e,n;try{for(var r=B(a),i=r.next();!i.done;i=r.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}t.complete()});if(k(null==(e=t)?void 0:e.getReader))return ae(function(i){return Ft(this,arguments,function(){var e,n,r;return zt(this,function(t){switch(t.label){case 0:e=i.getReader(),t.label=1;case 1:t.trys.push([1,,9,10]),t.label=2;case 2:return[4,_(e.read())];case 3:return(n=t.sent(),r=n.value,n.done)?[4,_(void 0)]:[3,5];case 4:return[2,t.sent()];case 5:return[4,_(r)];case 6:return[4,t.sent()];case 7:return t.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}(t))}var a,n,r,i,e;throw e=t,new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ae(t){return new d(function(e){!function(n,r){var i,s,a,o;return $t(this,void 0,void 0,function(){var e;return zt(this,function(t){switch(t.label){case 0:t.trys.push([0,5,6,11]),i=qt(n),t.label=1;case 1:return[4,i.next()];case 2:if((s=t.sent()).done)return[3,4];if(e=s.value,r.next(e),r.closed)return[2];t.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return e=t.sent(),a={error:e},[3,11];case 6:return(t.trys.push([6,,9,10]),s&&!s.done&&(o=i.return))?[4,o.call(i)]:[3,8];case 7:t.sent(),t.label=8;case 8:return[3,10];case 9:if(a)throw a.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}(t,e).catch(function(t){return e.error(t)})})}function oe(r,i){return ne(function(t,e){var n=0;t.subscribe(re(e,function(t){e.next(r.call(i,t,n++))}))})}function ce(n){return oe(function(t){return e=n,bt(t=t)?e.apply(void 0,E([],P(t))):e(t);var e})}function ue(t,a,n,r,i,s,o,e){var c=[],u=0,l=0,h=function(){c.length||u||a.complete()},f=function(t){return u<r?d(t):c.push(t)},d=function(t){s&&a.next(t),u++;var e=!1;se(n(t,l++)).subscribe(re(a,function(t){null!=i&&i(t),s?f(t):a.next(t)},function(){e=!0},void 0,function(){if(e)try{u--;for(;c.length&&u<r;)!function(){var t,e,n,r,i,s=c.shift();o?(t=a,n=function(){d(s)},void 0===r&&(r=0),void 0===i&&(i=!1),e=(e=o).schedule(function(){n(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r),t.add(e)):d(s)}();h()}catch(t){a.error(t)}}))};return t.subscribe(re(a,f,function(){h()})),function(){null!=e&&e()}}function le(n,r,i,t){if(k(i)&&(t=i,i=void 0),t)return le(n,r,i).pipe(ce(t));var t=P(k((t=n).addEventListener)&&k(t.removeEventListener)?yt.map(function(e){return function(t){return n[e](r,t,i)}}):k((t=n).addListener)&&k(t.removeListener)?gt.map(he(n,r)):k((t=n).on)&&k(t.off)?vt.map(he(n,r)):[],2),e=t[0],s=t[1];if(!e&&dt(n))return function t(i,s,n){return void 0===n&&(n=1/0),k(s)?t(function(n,r){return oe(function(t,e){return s(n,t,r,e)})(se(i(n,r)))},n):("number"==typeof s&&(n=s),ne(function(t,e){return ue(t,e,i,n)}))}(function(t){return le(t,r,i)})(se(n));if(e)return new d(function(n){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.next(1<t.length?t:t[0])}return e(t),function(){return s(t)}});throw new TypeError("Invalid event target")}function he(n,r){return function(e){return function(t){return n[e](r,t)}}}function fe(s,a){return void 0===a&&(a=te),s=null!=s?s:de,ne(function(t,n){var r,i=!0;t.subscribe(re(n,function(t){var e=a(t);!i&&s(r,e)||(i=!1,r=e,n.next(t))}))})}function de(t,e){return t===e}function pe(t){return t._base62Id??t.id??null}async function be(e){try{return n="https://api.spotify.com/v1/audio-analysis/"+e,t=await It("Session"),await(await fetch(n,{headers:{Authorization:"Bearer "+t.accessToken}})).json()}catch(t){return(e=t)instanceof _t&&console.error(e.message),void 0!==(n=e).status&&void 0!==n.message?console.error(e.message):console.error("Unknown error.",e),null}var n,t}function ge(t,e,n,r){{var i=S.useEffect,s=[t,e,n,r];const a=(0,S.useRef)(s),o=(0,S.useRef)(),c=(0,S.useRef)();Nt(()=>{a.current=s,o.current=Ot(s)}),i(()=>{const e=a.current[0],t=(o.current||(o.current=Ot(a.current)),e.subscribe({next:t=>{e===a.current[0]&&o.current.next?.(t)},error:t=>{e===a.current[0]&&(o.current.error?o.current:console).error(t)},complete:()=>{e===a.current[0]&&o.current.complete?.()}}));return c.current=t,()=>{t.unsubscribe()}},[s[0]]),c}}function ye(){var[t,e]=(0,m.useState)(!1);return ge(window.jukebox.stateChanged$,e),m.default.createElement(Spicetify.ReactComponent.TooltipWrapper,{label:"Enable jukebox",showDelay:100,renderInline:!1},m.default.createElement("button",{className:"main-repeatButton-button "+(t?"main-repeatButton-active":""),onClick:async function(){await window.jukebox.setEnabled(!window.jukebox.isEnabled)}},m.default.createElement(jt,{size:24})))}}(); |