13 lines
50 KiB
JavaScript
13 lines
50 KiB
JavaScript
(function(D,ie,se,k,V,de,P,f,a,e,X,O,le,ue,ge){"use strict";function fe(t){const{metro:{findByProps:c,findByStoreName:l,common:{lodash:{merge:d}}}}=t,i=c("_sendMessage"),{createBotMessage:n}=c("createBotMessage"),o=c("BOT_AVATARS"),{getChannelId:s}=l("SelectedChannelStore");return function(r,y){if(r.channelId??=s(),[null,void 0].includes(r.channelId))throw new Error("No channel id to receive the message into (channelId)");let u=r;if(r.really){typeof y=="object"&&(u=d(u,y));const p=[u,{}];p[0].tts??=!1;for(const w of["allowedMentions","messageReference"])w in p[0]&&(p[1][w]=p[0][w],delete p[0][w]);const h="overwriteSendMessageArg2";return h in p[0]&&(p[1]=p[0][h],delete p[0][h]),i._sendMessage(r.channelId,...p)}return y!==!0&&(u=n(u)),typeof y=="object"&&(u=d(u,y),typeof y.author=="object"&&function(){const p=y.author;typeof p.avatarURL=="string"&&(o.BOT_AVATARS[p.avatar??p.avatarURL]=p.avatarURL,p.avatar??=p.avatarURL,delete p.avatarURL)}()),i.receiveMessage(u.channel_id,u),u}}function he(t,c=27){if(typeof t!="string")throw new Error("Passed chars isn't a string");if(t?.length<=0)throw new Error("Invalid chars length");let l="";for(let d=0;d<c;d++)l+=t[Math.floor(Math.random()*t.length)];return l}const ye={command:"https://cdn.discordapp.com/attachments/1099116247364407337/1112129955053187203/command.png"},q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",K=q.replace("+/","_-");function pe(t,c){if(typeof t!="number")throw new Error(`Passed data isn't a number (received: ${typeof t})`);let l="";for(;t>0;)l=(c?K:q).charAt(t%64)+l,t=Math.floor(t/64);return l}const F=[],we=1e3;function g(t,c,l=null){const d={timestamp:new Date().toISOString(),type:t,message:c,data:l};F.unshift(d),F.length>we&&F.pop(),a.storage?.settings?.enableUnsafeFeatures&&console.log(`[AccountSwitcher] ${t.toUpperCase()}: ${c}`,l||"")}function J(){return F}function be(){F.length=0,g("info","Logs cleared")}function Z(t){let c=0;if(t.length===0)return c.toString();for(let l=0;l<t.length;l++){const d=t.charCodeAt(l);c=(c<<5)-c+d,c=c&c}return Math.abs(c).toString(36)}function Re({dialogInfo:t,onCancel:c,onSuccess:l,storage:d}){const[i,n]=e.React.useState(""),o=function(){if(!i.trim()){f.showToast("Please enter the password",1);return}Z(i)===d.settings.exportPasswordHash?(g("info","Password verification successful",{type:t.type}),l()):(g("warn","Incorrect password attempt",{type:t.type}),f.showToast("Incorrect password",1))};return e.React.createElement(e.ReactNative.View,{style:{flex:1,backgroundColor:"#2f3136"}},[e.React.createElement(e.ReactNative.View,{key:"pwd-header",style:{flexDirection:"row",alignItems:"center",padding:16,backgroundColor:"#202225",borderBottomWidth:1,borderBottomColor:"#40444b"}},[e.React.createElement(e.ReactNative.TouchableOpacity,{key:"back",onPress:c,style:{marginRight:16}},e.React.createElement(e.ReactNative.Text,{style:{color:"#7289da",fontSize:16}},"\u2190 Cancel")),e.React.createElement(e.ReactNative.Text,{key:"title",style:{color:"white",fontSize:18,fontWeight:"bold"}},t.title)]),e.React.createElement(e.ReactNative.View,{key:"pwd-content",style:{flex:1,padding:16,justifyContent:"center"}},[e.React.createElement(e.ReactNative.Text,{key:"message",style:{color:"#b9bbbe",fontSize:16,marginBottom:20,textAlign:"center"}},t.message),e.React.createElement(e.ReactNative.TextInput,{key:"password-input",placeholder:"Enter password",placeholderTextColor:"#72767d",value:i,onChangeText:n,secureTextEntry:!0,style:{backgroundColor:"#40444b",color:"white",padding:16,borderRadius:8,marginBottom:20,fontSize:16}}),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"confirm-btn",onPress:o,style:{backgroundColor:"#7289da",paddingVertical:16,paddingHorizontal:20,borderRadius:8,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:18,fontWeight:"bold"}},"Confirm"))])])}k.findByStoreName("UserStore");const ve=k.findByProps("getToken"),ke=async function(t,c){(function(l){t.settings?.exportPasswordHash?c({type:"export",title:"Enter Export Password",message:"Enter your password to export accounts",callback:l}):l()})(function(){O.showConfirmationAlert({title:"\u26A0\uFE0F Export Accounts - Security Warning",content:"Exporting accounts is UNSAFE and may lead to account takeover if shared with others. The export contains sensitive authentication tokens that give full access to your accounts. Only proceed if you understand the risks and will keep the data secure.",confirmText:"I Understand - Export",cancelText:"Cancel",confirmColor:"brand",onConfirm:async function(){try{g("info","Starting account export");const l=t.accounts||{},d=Object.values(l).map(function(n){return{username:n.username,discriminator:n.discriminator,avatar:n.avatar,id:n.id,token:n.token,addedAt:n.addedAt||Date.now()}}),i={accounts:d,exportPasswordHash:t.settings?.exportPasswordHash||null,exportedAt:Date.now(),version:"2.0"};e.clipboard.setString(JSON.stringify(i,null,2)),g("info","Accounts exported successfully",{count:d.length}),f.showToast(`Exported ${d.length} accounts to clipboard`,0)}catch(l){g("error","Failed to export accounts",{error:l.message}),console.error("Export error:",l),f.showToast("Failed to export accounts",1)}}})})},Te=async function(t,c,l){(function(d){t.settings?.exportPasswordHash?c({type:"import",title:"Enter Import Password",message:"Enter your password to import accounts",callback:d}):d()})(function(){O.showConfirmationAlert({title:"\u26A0\uFE0F Import Accounts - Security Warning",content:"Importing accounts is UNSAFE and may compromise your security if the data comes from untrusted sources. Only import data you exported yourself or from sources you completely trust. Malicious imports could lead to account takeover.",confirmText:"I Understand - Import",cancelText:"Cancel",confirmColor:"brand",onConfirm:async function(){try{g("info","Starting account import");let d=l.trim();if(!d)try{d=await e.clipboard.getString()}catch(r){g("error","Failed to get clipboard data",{error:r.message}),f.showToast("No data in clipboard or input field",1);return}if(!d){g("warn","No data to import"),f.showToast("No data to import",1);return}const i=JSON.parse(d);let n;if(i.accounts&&Array.isArray(i.accounts)){if(i.exportPasswordHash&&(!t.settings?.exportPasswordHash||t.settings.exportPasswordHash!==i.exportPasswordHash)){g("error","Import password mismatch"),f.showToast("Import password mismatch or not set locally",1);return}n=i.accounts,i.exportPasswordHash&&!t.settings?.exportPasswordHash&&(t.settings.exportPasswordHash=i.exportPasswordHash,g("info","Import password hash set from import data"))}else if(Array.isArray(i))n=i,g("debug","Using legacy import format");else{g("error","Invalid import format"),f.showToast("Invalid import format",1);return}let o=0,s=0;n.forEach(function(r){r.id&&r.token&&r.username&&(t.accounts[r.id]?s++:(t.accounts[r.id]={id:r.id,username:r.username,discriminator:r.discriminator||"0",avatar:r.avatar||null,displayName:r.displayName||r.username,token:r.token,addedAt:r.addedAt||Date.now()},t.accountOrder.includes(r.id)||t.accountOrder.push(r.id),o++))}),g("info","Import completed",{imported:o,skipped:s}),f.showToast(`Imported ${o} accounts, skipped ${s} duplicates`,0)}catch(d){g("error","Import failed",{error:d.message}),console.error("Import error:",d),f.showToast("Failed to import - invalid format or password mismatch",1)}}})})},me=function(t,c,l,d,i){if(!c.trim()){f.showToast("Please enter a password",1);return}if(c!==l){f.showToast("Passwords don't match",1);return}const n=Z(c);t.settings.exportPasswordHash=n,d(""),i(""),g("info","Export password set successfully"),f.showToast("Export password set successfully",0)},Se=function(t,c){(function(l){c({type:"remove",title:"Enter Password to Remove",message:"Enter your current password to remove protection",callback:l})})(function(){O.showConfirmationAlert({title:"Remove Export Password",content:"Are you sure you want to remove the export password? This will make exports/imports less secure.",confirmText:"Remove Password",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){delete t.settings.exportPasswordHash,g("info","Export password removed"),f.showToast("Export password removed",0)}})})},Ee=async function(t,c,l,d){if(t.settings.enableUnsafeFeatures){d(!0),g("info","Starting token account addition");try{let i=c.trim();if(i||(i=ve.getToken(),g("debug","Using current account token")),!i.startsWith("Bot ")&&!i.match(/^[A-Za-z0-9_-]{24,}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27,}$/)){g("error","Invalid token format provided"),f.showToast("Invalid token format",1),d(!1);return}g("debug","Fetching user info from Discord API");const n=await fetch("https://discord.com/api/v9/users/@me",{headers:{Authorization:i,"Content-Type":"application/json"}});if(!n.ok){g("error","Discord API request failed",{status:n.status,statusText:n.statusText}),f.showToast("Invalid or expired token",1),d(!1);return}const o=await n.json();g("info","Successfully retrieved user info",{username:o.username,id:o.id});const s={id:o.id,username:o.username,discriminator:o.discriminator,avatar:o.avatar,displayName:o.global_name||o.username};if(t.accounts[s.id]){g("warn","Account already exists",{username:s.username}),f.showToast(`Account ${s.username} already saved`,1),d(!1);return}const r={...s,token:i,addedAt:Date.now()};t.accounts[s.id]=r,t.accountOrder.includes(s.id)||t.accountOrder.push(s.id),l(""),g("info","Account added successfully via token",{username:s.username}),f.showToast(`Account ${s.username} added!`,0)}catch(i){g("error","Failed to add account via token",{error:i.message,stack:i.stack}),console.error("Add account error:",i),f.showToast("Failed to add account",1)}d(!1)}},xe=async function(){O.showConfirmationAlert({title:"Force Logout",content:"This will logout your current session by using an invalid token. Your saved accounts will remain intact. Continue?",confirmText:"Force Logout",cancelText:"Cancel",confirmColor:"brand",onConfirm:async function(){try{g("info","Starting force logout");const t="MTExMTExMTExMTExMTExMTEx.GxxxXx.xXxXxXxXxXxXxXxXxXxXxXxXxXxXx";await k.findByProps("login","logout","switchAccountToken").switchAccountToken(t),g("info","Force logout completed successfully"),f.showToast("Force logout successful - you can now login to a different account",0)}catch(t){g("warn","Force logout completed with error",{error:t.message}),console.error("Force logout error:",t),f.showToast("Force logout completed",0)}}})},Ce=async function(t,c,l,d,i,n,o){if(!c.trim()||!l.trim()){f.showToast("Please enter both email and password",1);return}o(!0),g("info","Starting credential-based account addition",{email:c.trim()});try{const s=await fetch("https://discord.com/api/v9/auth/login",{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"},body:JSON.stringify({login:c.trim(),password:l.trim()})}),r=await s.json();if(!s.ok||!r.token){g("error","Discord login failed",{status:s.status,message:r.message,errors:r.errors,captchaRequired:!!r.captcha_key});let h="Login failed";if(r.captcha_key)h="Captcha required - please login through Discord first";else if(r.message){const w=r.message.toLowerCase();w.includes("invalid")&&(w.includes("email")||w.includes("phone")||w.includes("login"))?h="Invalid email or username":w.includes("password")?h="Invalid password":w.includes("account")?h="Account issue - check your credentials":w.includes("rate limit")||w.includes("too many")?h="Too many attempts - please wait and try again":w.includes("mfa")||w.includes("2fa")||w.includes("verification")?h="2FA/MFA accounts not supported via credentials":h="Login failed - check your credentials"}else if(r.errors){const w=r.errors;w.login?h="Invalid email or username":w.password?h="Invalid password":h="Invalid credentials"}else s.status===401?h="Invalid credentials":s.status===429?h="Rate limited - please wait and try again":s.status>=500&&(h="Discord servers are having issues - try again later");f.showToast(h,1),o(!1);return}g("debug","Login successful, fetching user info");const y=await fetch("https://discord.com/api/v9/users/@me",{headers:{Authorization:r.token}});if(!y.ok){g("error","Failed to get user info after login",{status:y.status}),f.showToast("Login succeeded but failed to get user info - check logs",1),o(!1);return}const u=await y.json();if(t.accounts[u.id]){g("warn","Account already exists",{username:u.username}),f.showToast(`Account ${u.username} already saved`,1),o(!1);return}const p={id:u.id,username:u.username,discriminator:u.discriminator,avatar:u.avatar,displayName:u.global_name||u.username,token:r.token,addedAt:Date.now()};t.accounts[u.id]=p,t.accountOrder.includes(u.id)||t.accountOrder.push(u.id),d(""),i(""),n(!1),g("info","Account added successfully via credentials",{username:u.username}),f.showToast(`Account ${u.username} added successfully!`,0)}catch(s){g("error","Credential login failed",{error:s.message,stack:s.stack}),console.error("Login error:",s);let r="Login failed - check logs for more info";s.message.includes("network")||s.message.includes("fetch")?r="Network error - check your connection":s.message.includes("timeout")&&(r="Request timed out - try again"),f.showToast(r,1)}o(!1)},Y=k.findByStoreName("UserStore"),Q=k.findByProps("getToken");a.storage.accounts||(a.storage.accounts={}),a.storage.accountOrder||(a.storage.accountOrder=[]),a.storage.settings?(a.storage.settings.enableUnsafeFeatures===void 0&&(a.storage.settings.enableUnsafeFeatures=!1),a.storage.settings.enableCLI===void 0&&(a.storage.settings.enableCLI=a.storage.settings.showAccountNames!==!1),a.storage.settings.confirmBeforeDelete===void 0&&(a.storage.settings.confirmBeforeDelete=!0),a.storage.settings.addToSidebar===void 0&&(a.storage.settings.addToSidebar=!0),a.storage.settings.showAccountNames!==void 0&&delete a.storage.settings.showAccountNames):a.storage.settings={enableCLI:!0,confirmBeforeDelete:!0,enableUnsafeFeatures:!1,addToSidebar:!0},g("info","AccountSwitcher plugin initialized",{accountsCount:Object.keys(a.storage.accounts).length,cliEnabled:a.storage.settings.enableCLI,unsafeFeaturesEnabled:a.storage.settings.enableUnsafeFeatures});function Ae({onBack:t}){X.useProxy(a.storage);const[c,l]=e.React.useState(""),[d,i]=e.React.useState(!1),[n,o]=e.React.useState(""),[s,r]=e.React.useState(null),[y,u]=e.React.useState(""),[p,h]=e.React.useState(""),w=function(v,B){const x={...a.storage.settings,[v]:B};a.storage.settings=x,g("info",`Setting updated: ${v}`,{newValue:B})},C=function(){const v=J(),B=v.map(function(x){return`[${x.timestamp}] ${x.type.toUpperCase()}: ${x.message}${x.data?" | Data: "+JSON.stringify(x.data):""}`}).join(`
|
|
`);e.clipboard.setString(B),g("info","Logs copied to clipboard",{count:v.length}),f.showToast(`Copied ${v.length} log entries to clipboard`,0)},j=function(v){v?O.showConfirmationAlert({title:"\u26A0\uFE0F Enable Unsafe Features - Security Warning",content:"Unsafe features include token copying, manual token adding, and detailed logging. These features can compromise your account security if misused. Tokens provide full access to accounts and should never be shared. Only enable if you understand the security implications.",confirmText:"I Understand - Enable",cancelText:"Cancel",confirmColor:"brand",onConfirm:function(){return w("enableUnsafeFeatures",!0)}}):w("enableUnsafeFeatures",!1)},_=function(){r(null)},G=function(){const v=s.callback;r(null),v()};return s?e.React.createElement(Re,{dialogInfo:s,onCancel:_,onSuccess:G,storage:a.storage}):e.React.createElement(e.ReactNative.View,{style:{flex:1,backgroundColor:"#2f3136"}},[e.React.createElement(e.ReactNative.View,{key:"header",style:{flexDirection:"row",alignItems:"center",padding:16,backgroundColor:"#202225",borderBottomWidth:1,borderBottomColor:"#40444b"}},[e.React.createElement(e.ReactNative.TouchableOpacity,{key:"back",onPress:t,style:{marginRight:16}},e.React.createElement(e.ReactNative.Text,{style:{color:"#7289da",fontSize:16}},"\u2190 Back to Accounts")),e.React.createElement(e.ReactNative.Text,{key:"title",style:{color:"white",fontSize:18,fontWeight:"bold"}},"Settings")]),e.React.createElement(e.ReactNative.ScrollView,{key:"content",style:{flex:1,padding:16},contentContainerStyle:{paddingBottom:100}},[e.React.createElement(e.ReactNative.View,{key:"export-import",style:{marginBottom:24}},[e.React.createElement(e.ReactNative.Text,{key:"export-title",style:{color:"#b9bbbe",fontSize:14,fontWeight:"bold",marginBottom:12}},"BACKUP & RESTORE"),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"export-btn",onPress:function(){return ke(a.storage,r)},style:{backgroundColor:"#7289da",paddingVertical:12,paddingHorizontal:16,borderRadius:8,marginBottom:12,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:16,fontWeight:"bold"}},"\u{1F4E4} Export Accounts to Clipboard")),e.React.createElement(e.ReactNative.TextInput,{key:"import-input",placeholder:"Paste exported account data here (or leave empty to use clipboard)...",placeholderTextColor:"#72767d",value:n,onChangeText:o,multiline:!0,numberOfLines:4,style:{backgroundColor:"#40444b",color:"white",padding:12,borderRadius:8,marginBottom:12,fontSize:14,textAlignVertical:"top"}}),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"import-btn",onPress:function(){return Te(a.storage,r,n)},style:{backgroundColor:"#43b581",paddingVertical:12,paddingHorizontal:16,borderRadius:8,marginBottom:12,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:16,fontWeight:"bold"}},"\u{1F4E5} Import Accounts")),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"force-logout-btn",onPress:xe,style:{backgroundColor:"#f04747",paddingVertical:12,paddingHorizontal:16,borderRadius:8,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:16,fontWeight:"bold"}},"\u{1F6AA} Force Logout"))]),e.React.createElement(e.ReactNative.View,{key:"export-password",style:{marginBottom:24}},[e.React.createElement(e.ReactNative.Text,{key:"password-title",style:{color:"#b9bbbe",fontSize:14,fontWeight:"bold",marginBottom:12}},"EXPORT PASSWORD PROTECTION"),a.storage.settings.exportPasswordHash?e.React.createElement(e.ReactNative.View,{key:"password-set"},[e.React.createElement(e.ReactNative.Text,{key:"status",style:{color:"#43b581",fontSize:16,marginBottom:12}},"\u2713 Export password is set (hashed)"),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"remove-pwd",onPress:function(){return Se(a.storage,r)},style:{backgroundColor:"#f04747",paddingVertical:12,paddingHorizontal:16,borderRadius:8,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:16,fontWeight:"bold"}},"Remove Password"))]):e.React.createElement(e.ReactNative.View,{key:"password-unset"},[e.React.createElement(e.ReactNative.Text,{key:"desc",style:{color:"#72767d",fontSize:14,marginBottom:12}},"Set a password to protect your account exports and imports (will be hashed for security)"),e.React.createElement(e.ReactNative.TextInput,{key:"new-password",placeholder:"New password",placeholderTextColor:"#72767d",value:y,onChangeText:u,secureTextEntry:!0,style:{backgroundColor:"#40444b",color:"white",padding:12,borderRadius:8,marginBottom:8,fontSize:14}}),e.React.createElement(e.ReactNative.TextInput,{key:"confirm-password",placeholder:"Confirm password",placeholderTextColor:"#72767d",value:p,onChangeText:h,secureTextEntry:!0,style:{backgroundColor:"#40444b",color:"white",padding:12,borderRadius:8,marginBottom:12,fontSize:14}}),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"set-password",onPress:function(){return me(a.storage,y,p,u,h)},style:{backgroundColor:"#7289da",paddingVertical:12,paddingHorizontal:16,borderRadius:8,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:16,fontWeight:"bold"}},"Set Password"))])]),e.React.createElement(e.ReactNative.View,{key:"unsafe",style:{marginBottom:24}},[e.React.createElement(e.ReactNative.Text,{key:"unsafe-title",style:{color:"#f04747",fontSize:14,fontWeight:"bold",marginBottom:12}},"UNSAFE FEATURES"),e.React.createElement(e.ReactNative.View,{key:"enable-unsafe",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,backgroundColor:"#36393f",paddingHorizontal:16,borderRadius:8,marginBottom:8}},[e.React.createElement(e.ReactNative.View,{key:"text-container",style:{flex:1}},[e.React.createElement(e.ReactNative.Text,{key:"label",style:{color:"white",fontSize:16}},"Enable Unsafe Features"),e.React.createElement(e.ReactNative.Text,{key:"desc",style:{color:"#72767d",fontSize:12,marginTop:2}},"Allows token operations, detailed logging, and troubleshooting")]),e.React.createElement(e.ReactNative.Switch,{key:"toggle",value:a.storage.settings.enableUnsafeFeatures,onValueChange:j,trackColor:{false:"#72767d",true:"#f04747"},thumbColor:"white"})]),a.storage.settings.enableUnsafeFeatures&&e.React.createElement(e.ReactNative.View,{key:"unsafe-features",style:{marginTop:16}},[e.React.createElement(e.ReactNative.Text,{key:"logging-title",style:{color:"#b9bbbe",fontSize:14,fontWeight:"bold",marginBottom:8}},"TROUBLESHOOTING & LOGGING"),e.React.createElement(e.ReactNative.View,{key:"log-actions",style:{flexDirection:"row",gap:8,marginBottom:16}},[e.React.createElement(e.ReactNative.TouchableOpacity,{key:"copy-logs",onPress:C,style:{flex:1,backgroundColor:"#7289da",paddingVertical:10,paddingHorizontal:12,borderRadius:6,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:14,fontWeight:"bold"}},`Copy Logs (${J().length})`)),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"clear-logs",onPress:be,style:{flex:1,backgroundColor:"#f04747",paddingVertical:10,paddingHorizontal:12,borderRadius:6,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:14,fontWeight:"bold"}},"Clear Logs"))]),e.React.createElement(e.ReactNative.Text,{key:"token-title",style:{color:"#b9bbbe",fontSize:14,fontWeight:"bold",marginBottom:8}},"ADD ACCOUNT VIA TOKEN"),e.React.createElement(e.ReactNative.TextInput,{key:"token-input",placeholder:"Paste account token here (leave empty to add current account)...",placeholderTextColor:"#72767d",value:c,onChangeText:l,secureTextEntry:!0,style:{backgroundColor:"#40444b",color:"white",padding:12,borderRadius:8,marginBottom:12,fontSize:14}}),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"add-btn",onPress:function(){return Ee(a.storage,c,l,i)},disabled:d,style:{backgroundColor:d?"#5c6bc0":"#7289da",paddingVertical:12,paddingHorizontal:20,borderRadius:8,alignItems:"center",opacity:d?.6:1}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:16,fontWeight:"bold"}},d?"Adding...":c.trim()?"Add Account":"Add Current Account"))])]),e.React.createElement(e.ReactNative.View,{key:"general",style:{marginBottom:24}},[e.React.createElement(e.ReactNative.Text,{key:"general-title",style:{color:"#b9bbbe",fontSize:14,fontWeight:"bold",marginBottom:12}},"GENERAL"),e.React.createElement(e.ReactNative.View,{key:"enable-cli",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,backgroundColor:"#36393f",paddingHorizontal:16,borderRadius:8,marginBottom:8}},[e.React.createElement(e.ReactNative.Text,{key:"label",style:{color:"white",fontSize:16}},"Enable CLI Interface"),e.React.createElement(e.ReactNative.Switch,{key:"toggle",value:a.storage.settings.enableCLI,onValueChange:function(v){return w("enableCLI",v)},trackColor:{false:"#72767d",true:"#7289da"},thumbColor:"white"})]),e.React.createElement(e.ReactNative.View,{key:"add-to-sidebar",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,backgroundColor:"#36393f",paddingHorizontal:16,borderRadius:8,marginBottom:8}},[e.React.createElement(e.ReactNative.View,{key:"text-container",style:{flex:1}},[e.React.createElement(e.ReactNative.Text,{key:"label",style:{color:"white",fontSize:16}},"Add to Settings Sidebar"),e.React.createElement(e.ReactNative.Text,{key:"desc",style:{color:"#72767d",fontSize:12,marginTop:2}},"Show Account Switcher in Revenge settings menu")]),e.React.createElement(e.ReactNative.Switch,{key:"toggle",value:a.storage.settings.addToSidebar,onValueChange:function(v){w("addToSidebar",v),v?f.showToast("Sidebar enabled - restart app to see changes",0):f.showToast("Sidebar disabled - restart app to remove",0)},trackColor:{false:"#72767d",true:"#7289da"},thumbColor:"white"})]),e.React.createElement(e.ReactNative.View,{key:"confirm-delete",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,backgroundColor:"#36393f",paddingHorizontal:16,borderRadius:8}},[e.React.createElement(e.ReactNative.Text,{key:"label",style:{color:"white",fontSize:16}},"Confirm Before Delete"),e.React.createElement(e.ReactNative.Switch,{key:"toggle",value:a.storage.settings.confirmBeforeDelete,onValueChange:function(v){return w("confirmBeforeDelete",v)},trackColor:{false:"#72767d",true:"#7289da"},thumbColor:"white"})])])])])}function ee(t){X.useProxy(a.storage);const[c,l]=e.React.useState(!1),[d,i]=e.React.useState(null),[n,o]=e.React.useState(!1),[s,r]=e.React.useState(""),[y,u]=e.React.useState(""),[p,h]=e.React.useState(!1),w=Y.getCurrentUser()?.id,C=function(b){const R=a.storage.accounts[b];if(!R)return;const T=b===w,E=R.username;g("info","Attempting to remove account",{username:E,isCurrent:T});const $=function(){delete a.storage.accounts[b],a.storage.accountOrder=a.storage.accountOrder.filter(function(U){return U!==b})},oe=function(){$(),g("info","Account removed from switcher only",{username:E}),f.showToast(`Account ${E} removed from switcher`,0)},ce=async function(){try{g("info","Starting account removal and logout",{username:E});const U=Q.getToken();await k.findByProps("login","logout","switchAccountToken").switchAccountToken(R.token),g("debug","Switched to account for logout"),await k.findByProps("login","logout").logout(),g("debug","Account logged out from Discord"),setTimeout(async function(){try{await k.findByProps("login","logout","switchAccountToken").switchAccountToken(U),g("debug","Switched back to original account")}catch(We){g("warn","Could not switch back to original account",{error:We.message})}},100)}catch(U){g("error","Failed to logout account from Discord",{error:U.message}),f.showToast("Failed to logout, but removed from switcher",1)}$(),g("info","Account removed and logged out",{username:E}),f.showToast(`Account ${E} removed and logged out`,0)};a.storage.settings.confirmBeforeDelete?e.ReactNative.Alert.alert(T?"Remove Current Account":"Remove Account",T?"Do you want to remove the current account from the switcher? (To logout, use Force Logout in settings)":`What do you want to do with ${E}?`,[{text:"Cancel",style:"cancel"},{text:"Delete from switcher only",onPress:oe},!T&&{text:"Delete and logout",onPress:ce}].filter(Boolean)):T?oe():ce()},j=async function(b){const R=a.storage.accounts[b];if(R){i(b),g("info","Starting account switch",{username:R.username});try{f.showToast(`Switching to ${R.username}...`,0),await k.findByProps("login","logout","switchAccountToken").switchAccountToken(R.token),g("info","Account switch successful",{username:R.username}),f.showToast(`Switched to ${R.username}!`,0)}catch(T){g("error","Account switch failed",{username:R.username,error:T.message}),console.error("Switch error:",T),f.showToast(`Failed to switch: ${T.message}`,1)}i(null)}},_=function(b){if(!a.storage.settings.enableUnsafeFeatures)return;const R=a.storage.accounts[b];R&&(e.clipboard.setString(R.token),g("info","Token copied to clipboard",{username:R.username}),f.showToast(`Token for ${R.username} copied`,0))},G=async function(){h(!0),g("info","Adding current account");try{const b=Q.getToken(),R=Y.getCurrentUser();if(!R||a.storage.accounts[R.id]){const E=a.storage.accounts[R.id]?"Current account already saved":"Failed to get current user";g("warn",E,{userId:R?.id}),f.showToast(E,1),h(!1);return}const T={id:R.id,username:R.username,discriminator:R.discriminator,avatar:R.avatar,displayName:R.globalName||R.username,token:b,addedAt:Date.now()};a.storage.accounts[R.id]=T,a.storage.accountOrder.includes(R.id)||a.storage.accountOrder.push(R.id),o(!1),g("info","Current account added successfully",{username:R.username}),f.showToast(`Current account ${R.username} added!`,0)}catch(b){g("error","Failed to add current account",{error:b.message}),console.error("Add current account error:",b),f.showToast("Failed to add current account",1)}h(!1)},v=async function(){await Ce(a.storage,s,y,r,u,o,h)},B=function(b){return new Date(b).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},x=a.storage.accountOrder.filter(function(b){return a.storage.accounts[b]}).map(function(b){return a.storage.accounts[b]});return c?e.React.createElement(Ae,{onBack:function(){return l(!1)}}):n?e.React.createElement(e.ReactNative.View,{style:{flex:1,backgroundColor:"#2f3136"}},[e.React.createElement(e.ReactNative.View,{key:"add-header",style:{flexDirection:"row",alignItems:"center",padding:16,backgroundColor:"#202225",borderBottomWidth:1,borderBottomColor:"#40444b"}},[e.React.createElement(e.ReactNative.TouchableOpacity,{key:"back",onPress:function(){o(!1),r(""),u("")},style:{marginRight:16}},e.React.createElement(e.ReactNative.Text,{style:{color:"#7289da",fontSize:16}},"\u2190 Back")),e.React.createElement(e.ReactNative.Text,{key:"title",style:{color:"white",fontSize:18,fontWeight:"bold"}},"Add Account")]),e.React.createElement(e.ReactNative.ScrollView,{key:"add-content",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:100}},[e.React.createElement(e.ReactNative.Text,{key:"instruction",style:{color:"#b9bbbe",fontSize:16,marginBottom:20,textAlign:"center"}},"Enter your Discord account credentials or add your current account"),e.React.createElement(e.ReactNative.TextInput,{key:"email-input",placeholder:"Email address",placeholderTextColor:"#72767d",value:s,onChangeText:r,keyboardType:"email-address",autoCapitalize:"none",style:{backgroundColor:"#40444b",color:"white",padding:16,borderRadius:8,marginBottom:12,fontSize:16}}),e.React.createElement(e.ReactNative.TextInput,{key:"password-input",placeholder:"Password",placeholderTextColor:"#72767d",value:y,onChangeText:u,secureTextEntry:!0,style:{backgroundColor:"#40444b",color:"white",padding:16,borderRadius:8,marginBottom:20,fontSize:16}}),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"login-btn",onPress:v,disabled:p,style:{backgroundColor:p?"#5c6bc0":"#7289da",paddingVertical:16,paddingHorizontal:20,borderRadius:8,alignItems:"center",marginBottom:12,opacity:p?.6:1}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:18,fontWeight:"bold"}},p?"Adding Account...":"Add Account with Email & Password")),e.React.createElement(e.ReactNative.View,{key:"divider",style:{height:1,backgroundColor:"#40444b",marginVertical:16}}),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"add-current-btn",onPress:G,disabled:p,style:{backgroundColor:p?"#5c6bc0":"#43b581",paddingVertical:16,paddingHorizontal:20,borderRadius:8,alignItems:"center",opacity:p?.6:1}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:18,fontWeight:"bold"}},p?"Adding...":"Add Current Account"))])]):e.React.createElement(e.ReactNative.View,{style:{flex:1,backgroundColor:"#2f3136"}},[e.React.createElement(e.ReactNative.View,{key:"header",style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,backgroundColor:"#202225",borderBottomWidth:1,borderBottomColor:"#40444b"}},[e.React.createElement(e.ReactNative.Text,{key:"title",style:{color:"white",fontSize:20,fontWeight:"bold"}},"Account Switcher"),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"settings-btn",onPress:function(){return l(!0)},style:{padding:8,borderRadius:6,backgroundColor:"#4f545c"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:18}},"\u2699\uFE0F"))]),e.React.createElement(e.ReactNative.View,{key:"accounts-section",style:{flex:1,padding:16}},[e.React.createElement(e.ReactNative.Text,{key:"section-title",style:{color:"#b9bbbe",fontSize:14,fontWeight:"bold",marginBottom:12}},`SAVED ACCOUNTS (${x.length})`),x.length===0?e.React.createElement(e.ReactNative.View,{key:"empty",style:{alignItems:"center",justifyContent:"center",paddingVertical:40}},[e.React.createElement(e.ReactNative.Text,{key:"empty-text",style:{color:"#72767d",fontSize:16,marginBottom:8}},"No accounts saved yet"),e.React.createElement(e.ReactNative.Text,{key:"empty-hint",style:{color:"#72767d",fontSize:14,textAlign:"center"}},"Access the switcher by pressing the logout button on the main settings page.")]):e.React.createElement(e.ReactNative.ScrollView,{key:"accounts-scroll",style:{flex:1},contentContainerStyle:{paddingBottom:100}},x.map(function(b,R){const T=b.id===w,E=d===b.id;let $="https://cdn.discordapp.com/embed/avatars/1.png";return b.avatar&&($=`https://cdn.discordapp.com/avatars/${b.id}/${b.avatar}.png?size=48`),e.React.createElement(e.ReactNative.View,{key:b.id,style:{flexDirection:"row",alignItems:"center",backgroundColor:T?"#7289da20":"#36393f",borderWidth:T?2:0,borderColor:"#7289da",borderRadius:12,padding:12,marginBottom:12}},[e.React.createElement(e.ReactNative.TouchableOpacity,{key:"avatar",onPress:function(){return j(b.id)},disabled:T||E,style:{marginRight:12}},e.React.createElement(e.ReactNative.Image,{source:{uri:$},style:{width:48,height:48,borderRadius:24,opacity:T||E?.7:1}})),e.React.createElement(e.ReactNative.View,{key:"info",style:{flex:1}},[e.React.createElement(e.ReactNative.Text,{key:"name",style:{color:"white",fontSize:16,fontWeight:"bold"}},`${R+1}. ${a.storage.settings.enableCLI?`${b.username}${b.discriminator!=="0"?`#${b.discriminator}`:""}`:b.displayName}`),e.React.createElement(e.ReactNative.Text,{key:"status",style:{color:T?"#43b581":"#72767d",fontSize:12,marginTop:2}},T?"\u2713 Current Account":E?"Switching...":"Tap avatar to switch"),e.React.createElement(e.ReactNative.Text,{key:"date",style:{color:"#72767d",fontSize:11,marginTop:2}},`Added: ${B(b.addedAt||Date.now())}`)]),e.React.createElement(e.ReactNative.View,{key:"actions",style:{flexDirection:"column",alignItems:"flex-end"}},[a.storage.settings.enableUnsafeFeatures&&e.React.createElement(e.ReactNative.TouchableOpacity,{key:"copy",onPress:function(){return _(b.id)},style:{backgroundColor:"#4f545c",paddingHorizontal:12,paddingVertical:6,borderRadius:6,minWidth:80,alignItems:"center",marginBottom:6}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:12,fontWeight:"bold"}},"Copy Token")),e.React.createElement(e.ReactNative.TouchableOpacity,{key:"remove",onPress:function(){return C(b.id)},style:{backgroundColor:"#f04747",paddingHorizontal:12,paddingVertical:6,borderRadius:6,minWidth:80,alignItems:"center"}},e.React.createElement(e.ReactNative.Text,{style:{color:"white",fontSize:12,fontWeight:"bold"}},"Remove"))])])}))]),e.React.createElement(e.ReactNative.View,{key:"bottom-actions",style:{position:"absolute",bottom:0,left:0,right:0,backgroundColor:"#202225",borderTopWidth:1,borderTopColor:"#40444b",paddingVertical:12,paddingHorizontal:16,paddingBottom:40}},e.React.createElement(e.ReactNative.TouchableOpacity,{key:"add",onPress:function(){return o(!0)},style:{backgroundColor:"#7289da",paddingVertical:16,paddingHorizontal:20,borderRadius:8,alignItems:"center",flexDirection:"row",justifyContent:"center"}},[e.React.createElement(e.ReactNative.Text,{key:"add-icon",style:{color:"white",fontSize:20,marginRight:8}},"+"),e.React.createElement(e.ReactNative.Text,{key:"add-text",style:{color:"white",fontSize:18,fontWeight:"bold"}},"Add Account")]))])}const{FormSection:Ne,FormRow:W}=ue.Forms,{TableRowIcon:Ie}=k.findByProps("TableRowIcon"),z=window.bunny,te=z?.metro?.findByPropsLazy("getRootNavigationRef"),M=z?.metro?.findByPropsLazy("SETTING_RENDERER_CONFIG"),ae=z?.metro?.findByNameLazy("SettingsOverviewScreen",!1),re=z.metro.findByPropsLazy("createList");function Be({tabs:t}){const c=e.NavigationNative.useNavigation();return e.React.createElement(W,{label:t.title(),leading:e.React.createElement(W.Icon,{source:t.icon}),trailing:e.React.createElement(e.React.Fragment,{},[t.trailing?t.trailing():null,e.React.createElement(W.Arrow,{key:"arrow"})]),onPress:function(){const l=t.page;c.navigate("VendettaCustomPage",{title:t.title(),render:function(){return e.React.createElement(l)}})}})}function Pe(t,c){try{c.push(P.after("default",z?.metro?.findByNameLazy("UserSettingsOverviewWrapper",!1),function(l,d){const i=V.findInReactTree(d.props.children,function(n){return n.type?.name==="UserSettingsOverview"});i&&c.push(P.after("render",i.type.prototype,function(n,o){const s=V.findInReactTree(o.props.children,function(r){return r?.children?.[1]?.type===Ne})?.children;if(s){const r=s.findIndex(function(y){return["BILLING_SETTINGS","PREMIUM_SETTINGS"].includes(y?.props?.label)});s.splice(-~r||4,0,e.React.createElement(Be,{key:t.key,tabs:t}))}}))},!0))}catch(l){ge.logger.info("Panel UI patch failed graciously \u{1F494}",l)}}function Oe(t,c){if(!M||!ae||!te){console.warn("[AccountSwitcher] Missing required constants for tabs UI patch");return}const l={};l[t.key]={type:"pressable",title:t.title,icon:t.icon,IconComponent:t.icon&&function(){const n=typeof t.icon=="object"&&t.icon.uri!==void 0?t.icon.uri:t.icon;return e.React.createElement(Ie,{source:n})},usePredicate:t.predicate,useTrailing:t.trailing,onPress:function(){const n=te.getRootNavigationRef(),o=t.page;n.navigate("VendettaCustomPage",{title:t.title(),render:function(){return e.React.createElement(o)}})},withArrow:!0};let d=M.SETTING_RENDERER_CONFIG;Object.defineProperty(M,"SETTING_RENDERER_CONFIG",{enumerable:!0,configurable:!0,get:function(){return{...d,...l}},set:function(n){return d=n}});const i=Symbol("AccountSwitcher-pinToSettings");try{if(!re)return;c.push(P.after("createList",re,function(n,o){if(!n[0][i]){n[0][i]=!0;const[s]=n,r=s.sections,y=r?.find(function(u){return["Bunny","Kettu","Revenge"].includes(u?.label)});y||Boolean(r?.find(function(u){return u.settings.includes("ACCOUNT")}))&&r.unshift({label:a.manifest.name,title:a.manifest.name,settings:[t.key]}),y?.settings&&(y.settings=[...y.settings,t.key])}}))}catch{c.push(P.after("default",ae,function(n,o){if(!n[0][i]){n[0][i]=!0;const{sections:s}=V.findInReactTree(o,function(y){return y.props?.sections}).props,r=s?.find(function(y){return["Bunny","Kettu","Revenge"].includes(y?.label)});r||Boolean(s?.find(function(y){return y.settings.includes("ACCOUNT")}))&&s.unshift({label:a.manifest.name,title:a.manifest.name,settings:[t.key]}),r?.settings&&(r.settings=[...r.settings,t.key])}}))}}function Fe(t){const c=[];let l=!1;const d=t.predicate||function(){return!0};return t.predicate=function(){return l?!1:d()},Pe(t,c),Oe(t,c),c.push(function(){return l=!0}),function(){for(const i of c)i()}}function ze(){if(!a.storage.settings?.addToSidebar)return console.log("[AccountSwitcher] Sidebar disabled in settings"),function(){};console.log("[AccountSwitcher] Patching sidebar using custom patchSettingsPin...");try{const t=Fe({key:"AccountSwitcher",icon:le.getAssetIDByName("UserIcon"),title:function(){return"Account Switcher"},predicate:function(){return a.storage.settings?.addToSidebar===!0},page:ee});return console.log("[AccountSwitcher] Successfully patched sidebar"),t}catch(t){return console.error("[AccountSwitcher] Failed to patch sidebar:",t),function(){}}}const{meta:{resolveSemanticColor:$e}}=k.findByProps("colors","meta"),Ue=k.findByStoreName("ThemeStore"),A=k.findByStoreName("UserStore"),m=function(){return parseInt($e(Ue.theme,ie.semanticColors.BACKGROUND_SECONDARY).slice(1),16)},I={author:{username:"AccountSwitcher",avatar:"command",avatarURL:ye?.command}};a.storage.accounts||(a.storage.accounts={}),a.storage.accountOrder||(a.storage.accountOrder=[]),a.storage.settings?(a.storage.settings.enableUnsafeFeatures===void 0&&(a.storage.settings.enableUnsafeFeatures=!1),a.storage.settings.enableCLI===void 0&&(a.storage.settings.enableCLI=a.storage.settings.showAccountNames!==!1),a.storage.settings.confirmBeforeDelete===void 0&&(a.storage.settings.confirmBeforeDelete=!0),a.storage.settings.addToSidebar===void 0&&(a.storage.settings.addToSidebar=!0),a.storage.settings.showAccountNames!==void 0&&delete a.storage.settings.showAccountNames):a.storage.settings={enableCLI:!0,confirmBeforeDelete:!0,enableUnsafeFeatures:!1,addToSidebar:!0};let H;function S(){return window.sendMessage?window.sendMessage?.(...arguments):(H||(H=fe?.(vendetta)),H?.(...arguments))}function N(t){return!t||!t.username?"Unknown Account":t.username}function ne(t){const c=a.storage.accounts||{},l=a.storage.accountOrder||[],d=parseInt(t);if(!isNaN(d)&&d>=1&&d<=l.length){const i=l[d-1];return c[i]?[i,c[i]]:null}return Object.entries(c).find(function([i,n]){return n.username.toLowerCase()===t.toLowerCase()||N(n).toLowerCase()===t.toLowerCase()})}function L(t){const c=(a.storage.accountOrder||[]).indexOf(t);return c>=0?c+1:null}function De(t){a.storage.accountOrder||(a.storage.accountOrder=[]),a.storage.accountOrder.includes(t)||a.storage.accountOrder.push(t)}function Ve(t){a.storage.accountOrder||(a.storage.accountOrder=[]);const c=a.storage.accountOrder.indexOf(t);c>-1&&a.storage.accountOrder.splice(c,1)}var Le={meta:vendetta.plugin,settings:ee,patches:[],onUnload(){this.patches.forEach(function(t){return t()}),this.patches=[]},onLoad(){const t=ze();this.patches.push(t);const c="Copy Token",l=P.before("render",k.findByProps("ScrollView").View,function(i){try{if(!a.storage.settings?.enableUnsafeFeatures)return;let n=V.findInReactTree(i,function(u){return u.key===".$UserProfileOverflow"});if(!n||!n.props||n.props.sheetKey!=="UserProfileOverflow")return;const o=n.props.content.props;if(o.options.some(function(u){return u?.label===c}))return;const s=A.getCurrentUser()?.id,r=Object.keys(n._owner.stateNode._keyChildMapping).find(function(u){return n._owner.stateNode._keyChildMapping[u]&&u.match(/(?<=\$UserProfile)\d+/)})?.slice?.(13)||s,y=k.findByProps("getToken").getToken();o.options.unshift({isDestructive:!0,label:c,onPress:function(){try{f.showToast(r===s?"Copied your token":`Copied token of ${o.header.title}`),de.setString(r===s?y:[Buffer.from(r).toString("base64").replaceAll("=",""),pe?.(+Date.now()-129384e4,!0)||"dummy",he?.(K,27)||"dummy"].join(".")),o.hideActionSheet()}catch(u){console.error(u),f.showToast("Failed to copy token",1)}}})}catch(n){console.error("Context menu patch error:",n)}});this.patches.push(l);const d={async mainCommand(i,n){try{const o={...I,interaction:{name:"/accswitcher",user:A.getCurrentUser()}};S?.({loggingName:"AccSwitcher main message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u{1F4F1} Account Switcher",description:a.storage.settings.addToSidebar?"Account Manager is available in your settings sidebar!\n\nQuick commands:\n\u2022 `/accswitcher login <#>` - Switch to account\n\u2022 `/accswitcher add` - Add current account\n\u2022 `/accswitcher list` - Show all accounts":"Opening Account Manager...\n\nQuick commands:\n\u2022 `/accswitcher login <#>` - Switch to account\n\u2022 `/accswitcher add` - Add current account\n\u2022 `/accswitcher list` - Show all accounts",footer:{text:a.storage.settings.addToSidebar?"Check your settings sidebar for Account Switcher":"Check plugin settings for the Account Manager interface"}}]},o),f.showToast(a.storage.settings.addToSidebar?"Check settings sidebar for Account Switcher":"Check plugin settings to access Account Manager",0)}catch(o){console.error("Main command error:",o),f.showToast("Check plugin settings to access Account Manager",1)}},async addAccount(i,n){try{const o={...I,interaction:{name:"/accswitcher add",user:A.getCurrentUser()}},s=k.findByProps("getToken").getToken(),r=A.getCurrentUser();if(!r){S?.({loggingName:"Add account error message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u274C Failed to Get Current User",description:"Could not retrieve current user information."}]},o);return}if(a.storage.accounts[r.id]){const p=L(r.id);S?.({loggingName:"Add account warning message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u26A0\uFE0F Account Already Saved",description:`Your current account **${p}. ${r.username}** is already saved.`}]},o);return}const y={id:r.id,username:r.username,discriminator:r.discriminator,avatar:r.avatar,displayName:r.globalName||r.username,token:s,addedAt:Date.now()};a.storage.accounts[r.id]=y,De(r.id);const u=L(r.id);S?.({loggingName:"Add account success message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u2705 Account Added Successfully",description:`**${u}. ${r.username}** has been saved.`,footer:{text:`Total accounts: ${Object.keys(a.storage.accounts).length}`}}]},o)}catch(o){console.error("Add account error:",o),f.showToast("Failed to add account",1)}},async login(i,n){try{const o={...I,interaction:{name:"/accswitcher login",user:A.getCurrentUser()}},s=new Map(i.map(function(h){return[h.name,h]})).get("account")?.value;if(!s){S?.({loggingName:"Login error message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u274C No Account Specified",description:"Please specify an account number, username, or ID."}]},o);return}const r=ne(s);if(!r){const h=(a.storage.accountOrder||[]).filter(function(w){return a.storage.accounts[w]}).map(function(w,C){return`${C+1}. ${N(a.storage.accounts[w])}`}).join(`
|
|
`);S?.({loggingName:"Login error message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u274C Account Not Found",description:`Could not find account "${s}".${h?`
|
|
|
|
**Available accounts:**
|
|
${h}`:"\n\nNo accounts saved yet. Use `/accswitcher add` first."}`}]},o);return}const[y,u]=r,p=L(y);S?.({loggingName:"Login process message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:`\u{1F504} Switching to ${p}. ${N(u)}...`}]},o);try{await k.findByProps("login","logout","switchAccountToken").switchAccountToken(u.token),f.showToast(`Switched to ${p}. ${N(u)}!`,0)}catch(h){console.error("Switch error:",h),S?.({loggingName:"Login failure message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u274C Failed to switch accounts",description:`Error: ${h.message}`}]},o)}}catch(o){console.error("Login command error:",o),f.showToast("Failed to execute login command",1)}},listAccounts(i,n){try{const o={...I,interaction:{name:"/accswitcher list",user:A.getCurrentUser()}},s=a.storage.accounts||{},r=Object.keys(s).length;if(r===0){S?.({loggingName:"List accounts empty message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u{1F4DD} No Saved Accounts",description:"Use `/accswitcher add` to save your current account."}]},o);return}const y=(a.storage.accountOrder||[]).filter(function(u){return s[u]}).map(function(u,p){const h=s[u],w=N(h),C=new Date(h.addedAt).toLocaleDateString();return`**${p+1}.** ${w} - Added: ${C}`}).join(`
|
|
`);S?.({loggingName:"List accounts message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:`\u{1F4DD} Saved Accounts (${r})`,description:y,footer:{text:"Use /accswitcher login <number or username> to switch accounts"}}]},o)}catch(o){console.error("List accounts error:",o),f.showToast("Failed to list accounts",1)}},removeAccount(i,n){try{const o={...I,interaction:{name:"/accswitcher remove",user:A.getCurrentUser()}},s=new Map(i.map(function(h){return[h.name,h]})).get("account")?.value;if(!s){S?.({loggingName:"Remove account error message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u274C No Account Specified",description:"Please specify an account number, username, or ID to remove."}]},o);return}const r=ne(s);if(!r){const h=(a.storage.accountOrder||[]).filter(function(w){return a.storage.accounts[w]}).map(function(w,C){return`${C+1}. ${N(a.storage.accounts[w])}`}).join(`
|
|
`);S?.({loggingName:"Remove account error message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u274C Account Not Found",description:`Could not find account "${s}".${h?`
|
|
|
|
**Available accounts:**
|
|
${h}`:`
|
|
|
|
No accounts saved yet.`}`}]},o);return}const[y,u]=r,p=`${L(y)}. ${N(u)}`;delete a.storage.accounts[y],Ve(y),S?.({loggingName:"Remove account success message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u{1F5D1}\uFE0F Account Removed",description:`**${p}** has been removed from saved accounts.`,footer:{text:`Remaining accounts: ${Object.keys(a.storage.accounts).length}`}}]},o)}catch(o){console.error("Remove account error:",o),f.showToast("Failed to remove account",1)}},getCurrentToken(i,n){try{const o={...I,interaction:{name:"/accswitcher token",user:A.getCurrentUser()}};if(!a.storage.settings?.enableUnsafeFeatures){S?.({loggingName:"Get token disabled message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u{1F512} Unsafe Features Disabled",description:"Token access is disabled. Enable 'Unsafe Features' in plugin settings to use this command."}]},o);return}const{getToken:s}=k.findByProps("getToken"),r=s();S?.({loggingName:"Get token message",channelId:n.channel.id,embeds:[{color:m(),type:"rich",title:"\u{1F511} Current Account Token",description:`\`${r}\``,footer:{text:"\u26A0\uFE0F Keep your token secure and never share it!"}}]},o)}catch(o){console.error("Get token error:",o),f.showToast("Failed to get current token",1)}}};try{[{type:1,inputType:1,applicationId:"-1",execute:d.mainCommand,name:"accswitcher",description:"Open Account Switcher (check plugin settings)",options:[]},{type:1,inputType:1,applicationId:"-1",execute:d.addAccount,name:"accswitcher add",description:"Add your current account to saved accounts",options:[]},{type:1,inputType:1,applicationId:"-1",execute:d.login,name:"accswitcher login",description:"Switch to a saved account",options:[{required:!0,type:3,name:"account",description:"Account number, username, or ID to switch to"}]},{type:1,inputType:1,applicationId:"-1",execute:d.listAccounts,name:"accswitcher list",description:"Show all saved accounts",options:[]},{type:1,inputType:1,applicationId:"-1",execute:d.removeAccount,name:"accswitcher remove",description:"Remove a saved account",options:[{required:!0,type:3,name:"account",description:"Account number, username, or ID to remove"}]},{type:1,inputType:1,applicationId:"-1",execute:d.getCurrentToken,name:"accswitcher token",description:"Get your current account token (requires unsafe features)",options:[]}].forEach(function(i){try{se.registerCommand(i)}catch(n){console.error(`Failed to register command ${i.name}:`,n)}}),console.log("Account Switcher plugin loaded successfully")}catch(i){console.error("Failed to register commands:",i)}}};return D.EMBED_COLOR=m,D.default=Le,Object.defineProperty(D,"__esModule",{value:!0}),D})({},vendetta.ui,vendetta.commands,vendetta.metro,vendetta.utils,vendetta.metro.common.clipboard,vendetta.patcher,vendetta.ui.toasts,vendetta.plugin,vendetta.metro.common,vendetta.storage,vendetta.ui.alerts,vendetta.ui.assets,vendetta.ui.components,vendetta);
|