(function(d,S,O,f,p,a,h,g,V,x){"use strict";consts={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",MIN_UPDATE_INTERVAL:3,MAX_RETRY_ATTEMPTS:3,RETRY_DELAY:5e3,LFM_API_BASE_URL:"https://ws.audioscrobbler.com/2.0",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"],DEFAULT_SETTINGS:{username:"",apiKey:"",appName:"Music",timeInterval:5,showTimestamp:!0,listeningTo:!0,ignoreSpotify:!0,verboseLogging:!1},GITHUB_URL:"https://github.com/kmmiio99o/letup",GITHUB_COMMITS_URL:"https://github.com/kmmiio99o/letup/commits/main/"};functionb(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}function_(e,t){for(varn=0;n<t.length;n++){varc=t[n];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"inc&&(c.writable=!0),Object.defineProperty(e,c.key,c)}}functionN(e,t,n){returnt&&_(e.prototype,t),n&&_(e,n),e}g.findByProps("SET_ACTIVITY");constB=g.findByProps("getAssetIds"),$=g.findByStoreName("SelfPresenceStore"),P=g.findByStoreName("UserStore");functionv(){returnk(null)}functionk(e){o.pluginStopped&&(F(),e=null),o.lastActivity=e,a.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:e,pid:2312,socketId:"Last.fm@Vendetta"})}asyncfunctionY(e,t=s.APPLICATION_ID){if(!e?.length)return[];try{returnawaitB.fetchAssetIds(t,e)}catch(n){returnconsole.error("[Last.fm] Failed to fetch assets:",n),[]}}constA={};A.componentMountErrors=[],A.componentMountCount=0,A.settingsLoadAttempts=0;functionT(e,t){A[e]=t}constU=function(){functione(){b(this,e)}returnN(e,[{key:"validateSettings",value:function(){if(!i.username)thrownewError("Last.fm username is not set");if(!i.apiKey)thrownewError("Last.fm API key is not set")}},{key:"handleError",value:asyncfunction(t){this.lastError=t.error;constn={2:"Invalid API key",6:"User not found",11:"Service temporarily unavailable",16:"Service temporarily unavailable",29:"Rate limit exceeded"}[t.error]||t.message||"Unknown error";throwp.showToast(`Last.fm Error: ${n}`,f.getAssetIDByName("Small")),newError(`Last.fm API Error ${t.error}: ${n}`)}},{key:"makeRequest",value:asyncfunction(t){constn=newURLSearchParams({...t,api_key:i.apiKey,format:"json"}).toString(),c=awaitfetch(`${s.LFM_API_BASE_URL}?${n}`),r=awaitc.json();return(!c.ok||r.error)&&awaitthis.handleError(r),r}},{key:"fetchLatestScrobble",value:asyncfunction(){try{this.validateSettings();constt=(awaitthis.makeRequest({method:"user.getrecenttracks",user:i.username,limit:"1",extended:"1"}))?.recenttracks?.track?.[0];if(T("lastAPIResponse",t),!t)thrownewError("No tracks found");returnthis.retryCount=0,{name:t.name,artist:t.artist.name,album:t.album["#text"],albumArt:awaitthis.handleAlbumCover(t.image?.find(function(n){returnn.size==="large"})?.["#text"]),url:t.url,date:t.date?.["#text"]??"now",nowPlaying:!!t["@attr"]?.nowplaying,loved:t.loved==="1"}}catch(t){if(this.retryCount++,this.retryCount>s.MAX_RETRY_ATTEMPTS)throwthis.retryCount=0,t;returnawaitnewPromise(function(n){returnsetTimeout(n,s.RETRY_DELAY)}),this.fetchLatestScrobble()}}},{key:"handleAlbumCover",value:asyncfunction(t){return!t||s.LFM_DEFAULT_COVER_HASHES.some(function(n){returnt.includes(n)})?null:t}},{key:"getLastError",value:function(){returnthis.lastError}},{key:"resetRetryCount",value:function(){this.retryCount=0}}],[{key:"getInstance",value:function(){returne.instance||(e.instance=newe),e.instance}}]),e}().getInstance();varK=function(e){returne[e.PLAYING=0]="PLAYING",e[e.STREAMING=1]="STREAMING",e[e.LISTENING=2]="LISTENING",e[e.COMPETING=5]="COMPETING",e}(K||{});constl=function(...e){returni.verboseLogging&&console.log("[Last.fm]",...e)},C=function(){functione(){b(this,e)}returnN(e,[{key:"updateActivity",value:asyncfunction(){if(o.pluginStopped){l("Plugin is stopped, skipping update"),this.stopUpdates();return}l("Fetching last track...");try{if(!i.username||!i.apiKey)thrownewError("Username or API key not set");if(i.ignoreSpotify){if($.findActivity(function(c){returnc.sync_id})){l("Spotifyiscurrentlyplaying,cl