!function(e,t,n,a,r,o,i,l,s){"use strict";letc={DEFAULT_APP_NAME:"Music",DEFAULT_TIME_INTERVAL:5,APPLICATION_ID:"1054951789318909972",LFM_API_KEY:"615322f0047e12aedbc610d9d71f7430",LFM_DEFAULT_COVER_HASHES:["2a96cbd8b46e442fc41c2b86b821562f","c6f59c1e5e7240a4c0d427abd71f3dbb"]},u=n.findByProps("getAssetIds");asyncfunctiong(){lete=newURLSearchParams({method:"user.getrecenttracks",user:S.username,api_key:c.LFM_API_KEY,format:"json",limit:"1",extended:"1"}).toString(),t=awaitfetch(`https://ws.audioscrobbler.com/2.0/?${e}`);if(!t.ok)throwError(`Failed to fetch the latest scrobble: ${t.statusText}`);letn=awaitt.json(),a=n?.recenttracks?.track?.[0];if(!a)thrown;return{name:a.name,artist:a.artist.name,album:a.album["#text"],albumArt:awaitm(a.image[3]["#text"]),url:a.url,date:a.date?.["#text"]??"now",nowPlaying:Boolean(a["@attr"]?.nowplaying),loved:"1"===a.loved}}asyncfunctionm(e){returnc.LFM_DEFAULT_COVER_HASHES.some(function(t){returne.includes(t)})?null:e}functiond(){returnR.lastActivity&&F("--> Clearing activity..."),f(null)}functionf(e){R.pluginStopped&&(console.log("--> Plugin is unloaded, aborting..."),R.updateInterval&&clearInterval(R.updateInterval),e=null),R.lastActivity=e,a.FluxDispatcher.dispatch({type:"LOCAL_ACTIVITY_UPDATE",activity:e})}asyncfunctionp(e){lett=arguments.length>1&&void0!==arguments[1]?arguments[1]:c.APPLICATION_ID;if(!e)returnnull;if("string"==typeofe){letn=awaitu.getAssetIds(t,[e]);returnn[0]}returnawaitu.getAssetIds(t,e)}asyncfunctionh(){if(F("--> Fetching last track..."),!S.username)throws.showToast("Last.fm username is not set!",i.getAssetIDByName("Small")),y(),Error("Username is not set");lete=awaitg().catch(asyncfunction(e){throwF("--> An error occurred while fetching the last track, aborting..."),d(),e});if(!e.nowPlaying){F("--> Last track is not currently playing, aborting..."),d();return}if(F("--> Track fetched!"),R.lastTrackUrl===e.url){F("--> Last track is the same as the previous one, aborting...");return}lett={name:S.appName||c.DEFAULT_APP_NAME,flags:0,type:S.listeningTo?2:0,details:e.name,state:`by ${e.artist}`,application_id:c.APPLICATION_ID};if(R.lastTrackUrl=e.url,t.name.includes("{{"))for(letnine)t.name=t.name.replace(`{{${n}}}`,e[n]);S.showTimestamp&&(t.timestamps={start:Date.now()/1e3|0}),e.album&&(t.assets={large_image:awaitp(e.albumArt),large_text:`on ${e.album}`}),F("--> Setting activity..."),F(t);try{f(t)}catch(e){throwF("--> An error occurred while setting the activity"),d(),e}F("--> Successfully set activity!")}functiony(){console.log("--> Flushing..."),R.lastActivity=null,R.lastTrackUrl=null,R.updateInterval&&clearInterval(R.updateInterval),d()}asyncfunctionT(){if(console.log("--> Initializing..."),R.pluginStopped)throwError("Plugin is already stopped!");y();lete=0;awaith().catch(function(t){console.error(t),e++}),R.updateInterval=setInterval(function(){returnh().then(function(){e=0}).catch(function(t){console.error(t),++e>3&&(console.error("Failed to fetch/set activity 3 times, aborting..."),y())})},1e3*(S.timeInterval||c.DEFAULT_TIME_INTERVAL))}let{ScrollView:E,TouchableOpacity:v,Text:A}=a.ReactNative,{FormInput:I,FormDivider:b,FormSwitchRow:_,FormText:L,FormIcon:w}=l.Forms;functionN(){asyncfunctione(){for(leteinr.storage)(!1===r.storage[e]||r.storage[e])&&(S[e]=r.storage[e]);console.log("Applying settings..."),awaitT(),s.showToast("Settings updated!",i.getAssetIDByName("Check"))}returna.React.createElement(v,{onPress:e},a.React.createElement(L,{style:{marginRight:12}},"UPDATE"))}functionP(){lete=o.useProxy(r.storage),t=a.NavigationNative.useNavigation();returna.React.useEffect(function(){t.setOptions({title:"Last.fm Configuration",headerRight:N})},[]),a.React.createElement(E,null,a.React.createElement(I,{value:e.appName||void0,onChangeText:function(t){returne.appName=t.trim()},title:"Discord Application Name",placeholder:c.DEFAULT_APP_NAME,returnKeyType:"done"}),a.React.createElement(b,null),a.React.createElement(I,{required:!0,value:e.username||void0,onChangeText:function(t){returne.username=t.trim()},titl