(function(f,a,y,D,o,v,S,h,m,_,A){"use strict";constu={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",LFM_API_KEY:"014ffe8a614370f000d85d95ec30e1be",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"]};A.findByProps("SET_ACTIVITY");constF=A.findByProps("getAssetIds"),C=A.findByStoreName("SelfPresenceStore"),k=A.findByStoreName("UserStore");functionp(){returnw(null)}functionw(e){r.pluginStopped&&(g(!0),e=null),r.lastActivity=e,a.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:e,pid:2312,socketId:"Last.fm@Vendetta"})}asyncfunctionU(e){lett=arguments.length>1&&arguments[1]!==void0?arguments[1]:u.APPLICATION_ID;returne?awaitF.fetchAssetIds(t,e):[]}letR;constL={};functionc(e,t){L[e]=t,R?.()}functionM(){return[,R]=h.useReducer(function(e){return~e},0),JSON.stringify(L,null,4)}asyncfunctionO(){conste=newURLSearchParams({method:"user.getrecenttracks",user:s.username,api_key:u.LFM_API_KEY,format:"json",limit:"1",extended:"1"}).toString(),t=awaitfetch(`https://ws.audioscrobbler.com/2.0/?${e}`);if(!t.ok)thrownewError(`Failed to fetch the latest scrobble: ${t.statusText}`);constn=awaitt.json(),l=n?.recenttracks?.track?.[0];if(c("lastAPIResponse",l),!l)thrown;return{name:l.name,artist:l.artist.name,album:l.album["#text"],albumArt:awaitV(l.image?.find(function(K){returnK.size==="large"})?.["#text"]),url:l.url,date:l.date?.["#text"]??"now",nowPlaying:!!l["@attr"]?.nowplaying,loved:l.loved==="1"}}asyncfunctionV(e){returnu.LFM_DEFAULT_COVER_HASHES.some(function(t){returne.includes(t)})?null:e}varx=function(e){returne[e.PLAYING=0]="PLAYING",e[e.STREAMING=1]="STREAMING",e[e.LISTENING=2]="LISTENING",e[e.COMPETING=5]="COMPETING",e}(x||{});consti=function(){for(vare=arguments.length,t=newArray(e),n=0;n<e;n++)t[n]=arguments[n];returns.verboseLogging&&console.log(...t)};asyncfunctionP(){if(r.pluginStopped){i("--> Plugin is unloaded, aborting update()..."),g();return}if(i("--> Fetching last track..."),!s.username)throwS.showToast("Last.fm username is not set!",o.getAssetIDByName("Small")),g(),newError("Username is not set");if(s.ignoreSpotify)if(C.findActivity(function(n){returnn.sync_id})){i("--> Spotify is currently playing, aborting..."),c("isSpotifyIgnored",!0),p();return}elsec("isSpotifyIgnored",!1);elsec("isSpotifyIgnored",void0);conste=awaitO().catch(asyncfunction(n){throwi("--> An error occurred while fetching the last track, aborting..."),p(),n});if(c("lastTrack",e),!e.nowPlaying){i("--> Last track is not currently playing, aborting..."),p();return}if(i("--> Track fetched!"),r.lastTrackUrl===e.url){i("--> Last track is the same as the previous one, aborting...");return}constt={name:s.appName||u.DEFAULT_APP_NAME,flags:0,type:s.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,application_id:u.APPLICATION_ID};if(r.lastTrackUrl=e.url,t.name.includes("{{"))for(constnine)t.name=t.name.replace(`{{${n}}}`,e[n]);if(s.showTimestamp&&(t.timestamps={start:Date.now()|0}),e.album){constn=awaitU([e.albumArt]);t.assets={large_image:n[0],large_text:`on ${e.album}`}}i("--> Setting activity..."),c("lastActivity",t),i(t);try{w(t)}catch(n){throwi("--> An error occurred while setting the activity"),p(),n}i("--> Successfully set activity!")}functiong(){lete=arguments.length>0&&arguments[0]!==void0?arguments[0]:!1;r.lastActivity=null,r.lastTrackUrl=null,r.updateInterval&&clearInterval(r.updateInterval),!e&&p()}asyncfunctionb(){if(r.pluginStopped)thrownewError("Plugin is already stopped!");g();lete=0;awaitP().catch(function(t){console.error(t),e++}),r.updateInterval=setInterval(function(){returnP().then(function(){e=0}).catch(function(t){console.error(t),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),g())})},(Number(s.timeInterval)||u.DEFAULT_TIME_INTERVAL)*1e3)}constr={};_.plugin.storage.ignoreSpotify??=!0;consts={..._.plugin.storage};varB={settings:h.lazy(function(){returnPromise.resolve().then(function(){returnH})}),onLoad(){if(r.pluginStopped=!1,k.getCurrent