var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(a){return a.raw=a};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;return a};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};
$jscomp.arrayFromIterator=function(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c};$jscomp.arrayFromIterable=function(a){return a instanceof Array?a:$jscomp.arrayFromIterator($jscomp.makeIterator(a))};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b){var c=$jscomp.propertyToPolyfillSymbol[b];if(null==c)return a[b];c=a[c];return void 0!==c?c:a[b]};
$jscomp.polyfill=function(a,b,c,d){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,d):$jscomp.polyfillUnisolated(a,b,c,d))};$jscomp.polyfillUnisolated=function(a,b,c,d){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))return;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})};
$jscomp.polyfillIsolated=function(a,b,c,d){var e=a.split(".");a=1===e.length;d=e[0];d=!a&&d in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<e.length-1;f++){var g=e[f];if(!(g in d))return;d=d[g]}e=e[e.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&"es6"===c?d[e]:null;b=b(c);null!=b&&(a?$jscomp.defineProperty($jscomp.polyfills,e,{configurable:!0,writable:!0,value:b}):b!==c&&($jscomp.propertyToPolyfillSymbol[e]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(e):$jscomp.POLYFILL_PREFIX+e,e=
$jscomp.propertyToPolyfillSymbol[e],$jscomp.defineProperty(d,e,{configurable:!0,writable:!0,value:b})))};$jscomp.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(c){}return!1};$jscomp.setPrototypeOf=$jscomp.TRUST_ES6_POLYFILLS&&"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf:$jscomp.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;$jscomp.generator={};
$jscomp.generator.ensureIteratorResultIsObject_=function(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");};$jscomp.generator.Context=function(){this.isRunning_=!1;this.yieldAllIterator_=null;this.yieldResult=void 0;this.nextAddress=1;this.finallyAddress_=this.catchAddress_=0;this.finallyContexts_=this.abruptCompletion_=null};
$jscomp.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0};$jscomp.generator.Context.prototype.stop_=function(){this.isRunning_=!1};$jscomp.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_};$jscomp.generator.Context.prototype.next_=function(a){this.yieldResult=a};
$jscomp.generator.Context.prototype.throw_=function(a){this.abruptCompletion_={exception:a,isException:!0};this.jumpToErrorHandler_()};$jscomp.generator.Context.prototype["return"]=function(a){this.abruptCompletion_={"return":a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.jumpThroughFinallyBlocks=function(a){this.abruptCompletion_={jumpTo:a};this.nextAddress=this.finallyAddress_};$jscomp.generator.Context.prototype.yield=function(a,b){this.nextAddress=b;return{value:a}};
$jscomp.generator.Context.prototype.yieldAll=function(a,b){var c=$jscomp.makeIterator(a),d=c.next();$jscomp.generator.ensureIteratorResultIsObject_(d);if(d.done)this.yieldResult=d.value,this.nextAddress=b;else return this.yieldAllIterator_=c,this.yield(d.value,b)};$jscomp.generator.Context.prototype.jumpTo=function(a){this.nextAddress=a};$jscomp.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0};
$jscomp.generator.Context.prototype.setCatchFinallyBlocks=function(a,b){this.catchAddress_=a;void 0!=b&&(this.finallyAddress_=b)};$jscomp.generator.Context.prototype.setFinallyBlock=function(a){this.catchAddress_=0;this.finallyAddress_=a||0};$jscomp.generator.Context.prototype.leaveTryBlock=function(a,b){this.nextAddress=a;this.catchAddress_=b||0};
$jscomp.generator.Context.prototype.enterCatchBlock=function(a){this.catchAddress_=a||0;a=this.abruptCompletion_.exception;this.abruptCompletion_=null;return a};$jscomp.generator.Context.prototype.enterFinallyBlock=function(a,b,c){c?this.finallyContexts_[c]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_];this.catchAddress_=a||0;this.finallyAddress_=b||0};
$jscomp.generator.Context.prototype.leaveFinallyBlock=function(a,b){var c=this.finallyContexts_.splice(b||0)[0];if(c=this.abruptCompletion_=this.abruptCompletion_||c){if(c.isException)return this.jumpToErrorHandler_();void 0!=c.jumpTo&&this.finallyAddress_<c.jumpTo?(this.nextAddress=c.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=a};$jscomp.generator.Context.prototype.forIn=function(a){return new $jscomp.generator.Context.PropertyIterator(a)};
$jscomp.generator.Context.PropertyIterator=function(a){this.object_=a;this.properties_=[];for(var b in a)this.properties_.push(b);this.properties_.reverse()};$jscomp.generator.Context.PropertyIterator.prototype.getNext=function(){for(;0<this.properties_.length;){var a=this.properties_.pop();if(a in this.object_)return a}return null};$jscomp.generator.Engine_=function(a){this.context_=new $jscomp.generator.Context;this.program_=a};
$jscomp.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(c){return{value:c,done:!0}},a,this.context_["return"]);this.context_["return"](a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_["throw"],a,this.context_.next_);this.context_.throw_(a);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.yieldAllStep_=function(a,b,c){try{var d=a.call(this.context_.yieldAllIterator_,b);$jscomp.generator.ensureIteratorResultIsObject_(d);if(!d.done)return this.context_.stop_(),d;var e=d.value}catch(f){return this.context_.yieldAllIterator_=null,this.context_.throw_(f),this.nextStep_()}this.context_.yieldAllIterator_=null;c.call(this.context_,e);return this.nextStep_()};
$jscomp.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a["return"],done:!0}}return{value:void 0,done:!0}};
$jscomp.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this["throw"]=function(b){return a.throw_(b)};this["return"]=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}};$jscomp.generator.createGenerator=function(a,b){var c=new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(b));$jscomp.setPrototypeOf&&a.prototype&&$jscomp.setPrototypeOf(c,a.prototype);return c};
$jscomp.asyncExecutePromiseGenerator=function(a){function b(d){return a.next(d)}function c(d){return a["throw"](d)}return new Promise(function(d,e){function f(g){g.done?d(g.value):Promise.resolve(g.value).then(b,c).then(f,e)}f(a.next())})};$jscomp.asyncExecutePromiseGeneratorFunction=function(a){return $jscomp.asyncExecutePromiseGenerator(a())};$jscomp.asyncExecutePromiseGeneratorProgram=function(a){return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(a)))};
var injectAPIS="isPlayingOnOtherDevice isEnterHome playAD waitForSelector search play stop subscribePlayerStateForCurrentConvert getPlayState getSpotifyToken".split(" ");
if(!injectAPIS.every(function(a){return"function"===typeof window[a]})){var getReactComponment=function(a){for(var b in a)if(b.startsWith("__reactInternalInstance$"))return a[b]},getReactEvent=function(a){for(var b in a)if(b.startsWith("__reactEventHandlers$"))return a[b]},isAbort=!1,currentConvertUri="",isPlayingAD=!1,isSubscribed=!1;window.playFromAPI=function(a){return new Promise(function(b,c){var d=_getCosMos();if(d){var e=window.navigator.userAgent.match(/(Spotify\/)([0-9.]*)/);d.post("sp://player/v2/main/play",
{context:{uri:a,url:"context://".concat(a),metadata:{}},play_origin:{feature_identifier:"desktop-client-x",feature_version:e&&e.pop()||"unknown"},options:{}}).then(function(f){console.log("playFromAPI r:",f);b(!0)})["catch"](function(f){console.error("playFromAPI e:",f);b(!1)})}else console.error("playFromAPI cosmos not found."),b(!1)})};window._getCosMosPlayer=function(){var a=null;try{var b=document.querySelector("div.Root"),c=getReactComponment(b);do{if(c&&c.memoizedProps&&c.memoizedProps.transport&&
c.memoizedProps.store){a=c.memoizedProps;break}c=c["return"]}while(c)}catch(d){console.error("_getCosMosPlayer error:",d),a=null}return a};window._getCosMos=function(){var a=null;try{a=_getCosMosPlayer().libraryAPIInstance._cosmos}catch(b){console.error("_getCosMos error:",b),a=null}return a};window._getPlayer=function(){var a=null;try{var b=document.querySelector("div.player-bar-wrapper"),c=function(f){return Object.keys(f).find(function(g){return g.includes("__ko__")})},d=c(b),e=c(b[d]);a=b[d][e].context.$parent._cosmosPlayer}catch(f){a=
null}return a};window.getSpotifyToken=function(){return new Promise(function(a){var b="";try{var c=_getPlayer();if(c)c._resolver.get("sp://webgate/v1/token",function(e,f){b=f.getJSONBody();console.log("token:",b);a(JSON.stringify({error:!1,data:b.accessToken}))});else{var d=_getCosMosPlayer();d&&d.transport&&"function"===typeof d.transport.getLastToken&&(b=d.transport.getLastToken());a(JSON.stringify({error:!1,data:b}))}}catch(e){console.error("stop play catch error:",e),a(JSON.stringify({error:!0,
errorDetail:e.stack.toString()}))}})};window._stopPlay=function(){return new Promise(function(a){try{var b=_getPlayer();b?b.pause(function(c,d){var e=[200,403];a(!c||e.includes(d._status))}):(b=_getCosMos())?b.post("sp://player/v2/main/pause").then(function(c){return a(!0)})["catch"](function(c){return a(c.message.includes("403"))}):a(!1)}catch(c){console.error("stop play catch error:",c),a(!1)}})};window._resumePlay=function(){return new Promise(function(a,b){try{var c=_getPlayer();c?c.resume(function(d,
e){var f=[200,403];a(!d||f.includes(e._status))}):(console.error("stop play, ko player not found. try cosmos."),(c=_getCosMos())?c.post("sp://player/v2/main/resume").then(function(d){return a(!0)})["catch"](function(d){return a(d.message.includes("403"))}):a(!1))}catch(d){console.error("resume play catch error:",d),a(!1)}})};window.__isPodcast=function(a){return a.includes("episode")};window.__getSearchResultTable=function(a){var b=__isPodcast(a);a=b?"table.tracklist-podcast":"table.Table__table";
b?(b=document.querySelector(a),b||(b=(b=document.querySelector("iframe#app-show"))?b.contentDocument.querySelector(a):null)):b=document.querySelector(a);console.log("[__getSearchResultTable] result table:",b);return b};window.__getTrackTrFromTable=function(a,b){var c=null;a&&(c=Array.from(a.rows).find(function(d){return d&&(d.getAttribute("data-ta-uri")===b||d.getAttribute("data-uri")===b)}));return c};window.isPlayingOnOtherDevice=function(){console.log("[isPlayingOnOtherDevice] enter.");var a=!1,
b=document.getElementById("remote-playback-bar");b&&(a=[].concat($jscomp.arrayFromIterable(b.classList)).includes("visible"));console.log("[isPlayingOnOtherDevice] result:",a);return a};window._isPaused=function(){var a;return $jscomp.asyncExecutePromiseGeneratorProgram(function(b){if(1==b.nextAddress)return console.log("_isPaused"),b.yield(getState(),2);a=b.yieldResult;console.log("_isPaused state:",a?JSON.stringify(a):"no state");return b["return"](a&&a.is_paused)})};window.__sleep=function(a){return new Promise(function(b,
c){return setTimeout(function(){return b()},a||1E3)})};window.waitForSelector=function(a){return new Promise(function(b,c){document.documentElement.querySelector(a)?b(!0):(new MutationObserver(function(d,e){var f=[];d.forEach(function(g){f.push.apply(f,$jscomp.arrayFromIterable(g.addedNodes))});f.find(function(g){return g.parentElement&&g.parentElement.querySelector&&g.parentElement.querySelector(a)})&&(e.disconnect(),b(!0))})).observe(document.documentElement,{childList:!0,subtree:!0})})};window.isEnterHome=
function(){return["button#player-button-play","button.control-button.control-button--circled"].some(function(a){return!!document.querySelector(a)})};window.search=function(a){var b,c,d,e,f,g;return $jscomp.asyncExecutePromiseGeneratorProgram(function(h){switch(h.nextAddress){case 1:isAbort=!1;if(_getCosMos())return console.warn("[Search] new version no need search."),h["return"](JSON.stringify({error:!1}));b=$jscomp.makeIterator([null,0,!1]);c=b.next().value;d=b.next().value;e=b.next().value;h.setCatchFinallyBlocks(2);
case 4:return 0===d%10&&(console.warn("[Search] load uri:",a),window.location.href=a),h.yield(__sleep(1E3),7);case 7:if(c=__getSearchResultTable(a))(f=__getTrackTrFromTable(c,a))&&console.log("[Search] tr found from table."),e=!!f;++d;if(!e&&30>d&&!isAbort){h.jumpTo(4);break}h.leaveTryBlock(3);break;case 2:g=h.enterCatchBlock(),console.log("[Search] Error:",g),e=!1;case 3:return console.log(e?"search ok.":"search failed."),e=e?{error:!1}:{error:!0,hasGlobalPlay:!!document.querySelector("button#player-button-play"),
hasTable:!!c},h["return"](JSON.stringify(e))}})};window.playAD=function(){return $jscomp.asyncExecutePromiseGeneratorProgram(function(a){console.log("resume play ad");isPlayingAD=!0;_resumePlay();a.jumpToEnd()})};window.play=function(a){var b,c,d,e,f,g;return $jscomp.asyncExecutePromiseGeneratorProgram(function(h){if(1==h.nextAddress){currentConvertUri=a;if(!_getCosMos())return h.jumpTo(2);console.warn("[Play] new version play from api.");return h.yield(playFromAPI(a),3)}if(2!=h.nextAddress)return h["return"](h.yieldResult);
b=isAbort=!1;try{if(c=__getSearchResultTable(a))d=__getTrackTrFromTable(c,a),console.log("[Play] Enter:",d,a),__isPodcast(a)?(e=d.querySelector("button"),console.info("[Play] Podcast click play btn:",!!e),e&&e.click()):(console.info("[Play] Other click tr."),d.dispatchEvent(new MouseEvent("dblclick",{view:window,bubbles:!0,cancelable:!0})));else if(console.log("[Play] table not found, double click track row."),f=getTrackRow(a))console.log("[Play] got row."),(g=getReactEvent(f))&&"function"===typeof g.onDoubleClick&&
(console.log("[Play] row double clicked."),g.onDoubleClick());b=!0}catch(k){console.error("[Play] Error:",k),b=!1}return h["return"](b)})};window.getPlayState=function(){var a,b;return $jscomp.asyncExecutePromiseGeneratorProgram(function(c){return 1==c.nextAddress?(a=JSON,b=a.stringify,c.yield(getState(),2)):c["return"](b.call(a,c.yieldResult))})};window.getState=function(){return new Promise(function(a,b){try{var c=_getPlayer();c?c.getState(function(d,e){d?(console.error("[getState] error:",d),a()):
a(e.getJSONBody())}):_getCosMos().get("sp://player/v2/main").then(a)["catch"](function(d){console.error("cosmos get state error:",d);a()})}catch(d){console.error("[getState] catch error:",d),a()}})};window.subscribePlayerStateForCurrentConvert=function(){if(isSubscribed)console.log("[subscribePlayerState] already subscribed, return.");else{isSubscribed=!0;console.warn("[subscribePlayerState] start subscribe player state.");var a=function(c){try{var d=c.track,e=c.is_paused;console.log("track: "+(d?
d.uri:"no track found.")+", is_buffering: "+c.is_buffering+", is_paused: "+e+", is_playing: "+c.is_playing+", convert uri:"+currentConvertUri);!isPlayingAD&&currentConvertUri&&!e&&d&&d.uri&&d.uri!==currentConvertUri&&(console.log("[INJECTED]","preload call _stopPlay"),_stopPlay())}catch(f){console.error("[subscribePlayerState] error:",f)}},b=null;try{(b=_getPlayer())?b.subscribe(function(c,d){c?console.error("[subscribePlayerState] subscribe error:",c):a(d.getJSONBody())}):(b=_getCosMos())?b.sub("sp://player/v2/main",
a):console.error("[subscribePlayerState] cosmos player not found.")}catch(c){console.error("subscribePlayerStateForCurrentConvert error:",c)}}};window.stop=function(){var a,b,c,d;return $jscomp.asyncExecutePromiseGeneratorProgram(function(e){switch(e.nextAddress){case 1:return console.log("stop"),currentConvertUri="",e.yield(_isPaused(),2);case 2:if(e.yieldResult)return console.log("stop already paused, return."),e["return"](!0);isAbort=!0;a=$jscomp.makeIterator([0,5,!1]);b=a.next().value;c=a.next().value;
d=a.next().value;case 3:return console.log("_stopPlay:",b),e.yield(_stopPlay(),6);case 6:return e.yield(_isPaused(),7);case 7:d=e.yieldResult;console.log("_stopPlay:",b,d);if(d){e.jumpTo(5);break}return e.yield(__sleep(500),9);case 9:b++;case 5:if(!d&&b<c)e.jumpTo(3);else return console.log("[stop] result:",d),e["return"](d)}})};window.getTrackRow=function(a){console.log("getTrackRow:",a);var b=null;try{var c=document.querySelectorAll('[data-testid="tracklist-row"]');if(c)for(var d=!1,e=0;e<c.length&&
!d;e++){var f=c[e],g=getReactComponment(f);if(g&&g["return"]){var h=g["return"];do{if(h.memoizedProps&&h.memoizedProps.uri&&h.memoizedProps.uri===a){b=f;d=!0;break}h=h["return"]}while(h)}}}catch(k){console.error("getTrackRow error:",k),b=null}return b}}injectAPIS.every(function(a){return"function"===typeof window[a]});