function f(...e){return window.enmity.modules.getByProps(...e)}function le(...e){return window.enmity.modules.getByName(...e)}window.enmity.modules.common;function se(e){window.enmity.plugins.registerPlugin(e)}function me(e){return window.enmity.patcher.create(e)}const s=window.enmity.modules.common.Constants;window.enmity.modules.common.Clipboard,window.enmity.modules.common.Assets,window.enmity.modules.common.Messages,window.enmity.modules.common.Clyde,window.enmity.modules.common.Avatars,window.enmity.modules.common.Native;const t=window.enmity.modules.common.React;window.enmity.modules.common.Dispatcher,window.enmity.modules.common.Storage;const z=window.enmity.modules.common.Toasts,B=window.enmity.modules.common.Dialog;window.enmity.modules.common.Token,window.enmity.modules.common.REST,window.enmity.modules.common.Settings,window.enmity.modules.common.Users,window.enmity.modules.common.Navigation,window.enmity.modules.common.NavigationNative,window.enmity.modules.common.NavigationStack,window.enmity.modules.common.Theme,window.enmity.modules.common.Linking;const _=window.enmity.modules.common.StyleSheet;window.enmity.modules.common.ColorMap,window.enmity.modules.common.Components,window.enmity.modules.common.Locale;const ce=window.enmity.modules.common.Profiles;window.enmity.modules.common.Lodash,window.enmity.modules.common.Logger,window.enmity.modules.common.Flux,window.enmity.modules.common.SVG,window.enmity.modules.common.Scenes,window.enmity.modules.common.Moment;function K(e,o,n){window.enmity.settings.set(e,o,n)}function T(e,o,n){return window.enmity.settings.getBoolean(e,o,n)}function d(e){return window.enmity.assets.getIDByName(e)}var C={Failed:d("Small"),Delete:d("ic_message_delete"),Copy:d("toast_copy_link"),Open:d("ic_leave_stage"),Clipboard:d("pending-alert"),Clock:d("clock"),Pronoun:d("ic_accessibility_24px"),Settings:{Toasts:{Settings:d("ic_selection_checked_24px"),Failed:d("ic_close_circle_24px")},Initial:d("coffee"),Update:d("discover"),Locale:d("ic_locale_24px"),External:d("ic_raised_hand_list"),Edit:d("ic_edit_24px")}};const de=(e=.1)=>({shadowColor:"#000",shadowOffset:{width:1,height:4},shadowOpacity:e,shadowRadius:4.65,elevation:8}),ue=(e,o)=>{z.open({content:o=="clipboard"?`Copied ${e} to clipboard.`:e,source:o=="clipboard"?C.Clipboard:C.Settings.Initial})};var x={shadow:de,displayToast:ue},v="PronounDB",F="1.2.3",pe="stable",he="Displays a Pronoun from PronounDB next to your name in the chat :3",ge=[{name:"Acquite<3",id:"581573474296791211",profile:"https://github.com/acquitelol"}],D={download:"https://raw.githubusercontent.com/acquitelol/enmity-pronoun-db/main/dist/PronounDB.js",repo:"https://github.com/acquitelol/enmity-pronoun-db",pronoundb:"https://pronoundb.org/",build:"patch-1.4.56",hash:"5c5391d6"},ye="#ff91ff",I={name:v,version:F,release:pe,description:he,authors:ge,plugin:D,color:ye},M=(e,o,n,r,a)=>{try{return e(...o)}catch(m){console.warn(`[${n}] The following error happened when trying to ${r} ${a!=null?a:"unspecificied label"}: ${m}`);return}};const Q=(e,o,n,r)=>M(()=>{if(e){e.length++,n++;for(let a=e.length-1;a>=n;a--)e[a]=e[a-1];return e[n-1]=o,e.length}},[e,o,n],v,"insert an item at",r),we=(e,o,n)=>M(()=>{let r=[];for(let a=0;a{B.show({title:"Update found",body:`A newer ${n} is available for ${v}. ${n=="build"?` The version will remain at ${F}, but the build will update to ${o}.`:""} Would you like to install ${n} \`${o}\` now?`,confirmText:"Update",cancelText:"Not now",onConfirm:()=>Se(e,o,n)})},ve=(e,[o,n])=>{console.log(`[${e}] Plugin is on the latest update, which is version ${o} and build ${n}`),B.show({title:"Already on latest",body:`${e} is already updated to the latest version. Version: \`${o}\` Build: \`${n}\``,confirmText:"Okay"})},Ee=(e,[o,n])=>{console.log(`[${e}] Plugin failed to update to the latest version and build, remaining at ${o} and ${n}`),B.show({title:"Failed",body:`${e} to find a new version or build. The current versions will remain as follows: Version: \`${o}\` Build: \`${n}\``,confirmText:"Okay"})};async function Se(e,o,n){await M(async function(){window.enmity.plugins.installPlugin(e,({data:r})=>{r=="installed_plugin"||r=="overridden_plugin"?B.show({title:`Updated ${v}`,body:`Successfully updated to ${n} \`${o}\`. Would you like to reload Discord now?`,confirmText:"Reload",cancelText:"Not now",onConfirm:()=>fe()}):console.log(`[${v}] Plugin failed to update to ${n} ${o}.`)})},[e,o,n],v,"installing plugin at","new version available")}var Ce={checkForUpdates:be},u={map:{},queue:[],fetching:!1,referenceMap:{hh:"he/him",hi:"he/it",hs:"he/she",ht:"he/they",ih:"it/him",ii:"it/its",is:"it/she",it:"it/they",shh:"she/he",sh:"she/her",si:"she/it",st:"she/they",th:"they/he",ti:"they/it",ts:"they/she",tt:"they/them",any:"any",other:"other",ask:"ask",avoid:"avoid pronouns, use name",unspecified:"unspecified"},async updateQueuedPronouns(){if(this.queue.length<=0||this.fetching)return;const e=this.queue.splice(0,49),o=a=>this.queue.length<=0?a:this.map[a]?o(this.queue.shift()):a;for(const a of e)this.map[a]&&(e[a]=o(a));this.fetching=!0;const n=await(await fetch(`https://pronoundb.org/api/v1/lookup-bulk?platform=discord&ids=${e.join(",")}`,{method:"GET",headers:{Accept:"application/json","X-PronounDB-Source":"Enmity"}})).json(),r=Object.fromEntries(Object.entries(n).filter(([a,m])=>!isNaN(+a)));Object.assign(this.map,r),this.fetching=!1,this.queue.length>0&&this.updateQueuedPronouns()}};const{components:i}=window.enmity;i.Alert,i.Button,i.FlatList;const V=i.Image;i.ImageBackground,i.KeyboardAvoidingView,i.Modal,i.Pressable,i.RefreshControl;const xe=i.ScrollView;i.SectionList,i.StatusBar,i.StyleSheet,i.Switch;const S=i.Text;i.TextInput,i.TouchableHighlight;const O=i.TouchableOpacity;i.TouchableWithoutFeedback,i.Touchable;const g=i.View;i.VirtualizedList,i.Form,i.FormArrow,i.FormCTA,i.FormCTAButton,i.FormCardSection,i.FormCheckbox;const H=i.FormDivider;i.FormHint,i.FormIcon,i.FormInput,i.FormLabel,i.FormRadio;const p=i.FormRow;i.FormSection,i.FormSelect,i.FormSubLabel;const Z=i.FormSwitch;i.FormTernaryCheckBox,i.FormText,i.FormTextColors,i.FormTextSizes;var ee,te;const Re=(te=(ee=f("View","Text"))==null?void 0:ee.Dimensions)==null?void 0:te.get("window").width;var oe=({style:e,source:o})=>{const[n,r]=t.useState({width:0,height:0}),[a,m]=t.useState(0),w=()=>{const l=R=>typeof R=="string"?parseInt(R.replace("%",""))*Re/100:R,c=l(e.width);if(!e.maxWidth)return c;const E=l(e.maxWidth);return c>E?E:c};return t.useEffect(()=>{V.getSize(o,(l,c)=>{r({width:l,height:c})},l=>{console.error(`[${I.name}] ${l} when fetching ${o}`)}),m(w())},[]),t.createElement(V,{style:[...Array.isArray(e)?e:[e],{height:a*(n.height/n.width)}],source:{uri:o},resizeMode:"stretch"})};const{Animated:N}=window.enmity.modules.common.Components.General,ne=f("transitionToGuild"),Y=f("getUser","getCurrentUser"),h=_.createThemedStyleSheet({container:{marginTop:25,marginLeft:"5%",marginBottom:-15,flexDirection:"row"},textContainer:{paddingLeft:15,paddingTop:5,flexDirection:"column",flexWrap:"wrap",...x.shadow()},image:{width:75,height:75,borderRadius:10,...x.shadow()},mainText:{opacity:.975,letterSpacing:.25},header:{color:s.ThemeColorMap.HEADER_PRIMARY,fontFamily:s.Fonts.DISPLAY_BOLD,fontSize:25,letterSpacing:.25},subHeader:{color:s.ThemeColorMap.HEADER_SECONDARY,fontSize:12.75}});var Pe=({name:e,version:o,plugin:n,authors:r})=>{var a,m;const w=t.useRef(new N.Value(1)).current,l=()=>N.spring(w,{toValue:1.1,duration:10,useNativeDriver:!0}).start(),c=()=>N.spring(w,{toValue:1,duration:250,useNativeDriver:!0}).start(),E=()=>ce.showUserProfile({userId:Y.getCurrentUser().id}),R={transform:[{scale:w}]};return t.createElement(t.Fragment,null,t.createElement(g,{style:h.container},t.createElement(O,{onPress:E,onPressIn:l,onPressOut:c},t.createElement(N.View,{style:R},t.createElement(V,{style:[h.image],source:{uri:(m=(a=Y==null?void 0:Y.getCurrentUser())==null?void 0:a.getAvatarURL())==null?void 0:m.replace("webp","png")}}))),t.createElement(g,{style:h.textContainer},t.createElement(O,{onPress:()=>ne.openURL(n.repo)},t.createElement(S,{style:[h.mainText,h.header]},e)),t.createElement(g,{style:{flexDirection:"row"}},t.createElement(S,{style:[h.mainText,h.subHeader]},"A project by"),X.mapItem(r,(b,P,$)=>t.createElement(O,{onPress:()=>ne.openURL(b.profile)},t.createElement(S,{style:[h.mainText,h.subHeader,{paddingLeft:4,fontFamily:s.Fonts.DISPLAY_BOLD,flexDirection:"row"}]},b.name,P<$.length-1?",":null)))),t.createElement(g,null,t.createElement(O,{style:{flexDirection:"row"}},t.createElement(S,{style:[h.mainText,h.subHeader]},"Version:"),t.createElement(S,{style:[h.mainText,h.subHeader,{paddingLeft:4,fontFamily:s.Fonts.DISPLAY_BOLD}]},o))))))};const ie=_.createThemedStyleSheet({text:{color:s.ThemeColorMap.HEADER_SECONDARY,paddingLeft:"5.5%",paddingRight:10,marginBottom:10,letterSpacing:.25,fontFamily:s.Fonts.PRIMARY_BOLD,fontSize:12}});var G=({label:e,children:o,style:n})=>t.createElement(g,{style:[n,{marginTop:10}]},t.createElement(S,{style:[ie.text,ie.optionText]},e.toUpperCase()),o);const ae=f("transitionToGuild","openURL"),k=parseInt(Te.split(".")[0])>163?15:0,y=_.createThemedStyleSheet({icon:{color:s.ThemeColorMap.INTERACTIVE_NORMAL},item:{color:s.ThemeColorMap.TEXT_MUTED,fontFamily:s.Fonts.PRIMARY_MEDIUM},container:{width:"90%",marginLeft:"5%",borderRadius:10,backgroundColor:s.ThemeColorMap.BACKGROUND_MOBILE_SECONDARY,...x.shadow()},subheaderText:{color:s.ThemeColorMap.HEADER_SECONDARY,textAlign:"center",margin:10,marginBottom:50,letterSpacing:.25,fontFamily:s.Fonts.PRIMARY_BOLD,fontSize:14},image:{width:"100%",maxWidth:350,borderRadius:10}});var $e=({manifest:e})=>{const[o,n]=t.useState(T(e.name,"isTimestamp",!1)),[r,a]=t.useState(T(e.name,"isRole",!0));return t.createElement(xe,null,t.createElement(Pe,{name:e.name,version:e.version,plugin:e.plugin,authors:e.authors}),t.createElement(g,{style:{marginTop:20}},t.createElement(G,{label:"Preferences"},t.createElement(g,{style:[y.container]},t.createElement(p,{label:"Timestamps",subLabel:"Use Timestamps instead of OP Tag for the pronoun in the chat area.",onLongPress:()=>x.displayToast(`By default, ${e.name} will use the OP tag to display pronouns. Toggling this option will always use Timestamps instead of OP tag for pronouns.`,"tooltip"),leading:t.createElement(p.Icon,{style:y.icon,source:C.Settings.Locale}),trailing:t.createElement(Z,{value:T(e.name,"isTimestamp",!1),style:{marginLeft:-k},onValueChange:()=>{K(e.name,"isTimestamp",!T(e.name,"isTimestamp",!1)),n(T(e.name,"isTimestamp",!1))}})}),t.createElement(H,null),t.createElement(p,{label:"Roles",subLabel:"Show the pronoun styled as a role instead of plain text inside of profiles.",onLongPress:()=>x.displayToast(`With this option enabled, ${e.name} will style pronouns as roles in profiles. Otherwise, it will style them as plain text.`,"tooltip"),leading:t.createElement(p.Icon,{style:y.icon,source:C.Settings.Edit}),trailing:t.createElement(Z,{value:T(e.name,"isRole",!0),style:{marginLeft:-k},onValueChange:()=>{K(e.name,"isRole",!T(e.name,"isRole",!0)),a(T(e.name,"isRole",!0))}})}))),t.createElement(G,{label:"Previews"},t.createElement(g,{style:{...y.container,maxWidth:350}},t.createElement(oe,{style:y.image,source:`https://cdn.discordapp.com/attachments/${o?"1011346757214543875/1075007230337896448/pronoun-timestamp.png":"1011346757214543875/1075007230107193374/pronoun-tag.png"}`})),t.createElement(g,{style:{...y.container,marginTop:10,maxWidth:350}},t.createElement(oe,{style:y.image,source:`https://cdn.discordapp.com/attachments/${r?"1011346757214543875/1075007778399199282/profile-role.png":"1011346757214543875/1075007778067841044/profile-plain.png"}`}))),t.createElement(G,{label:"Source"},t.createElement(g,{style:y.container},t.createElement(p,{label:"Check for Updates",subLabel:`Search for any ${e.name} updates and notify you if an update is available.`,onLongPress:()=>x.displayToast(`Search GitHub for any new version or build of ${e.name} and prompts you to update, and then prompts you to restart Enmity afterwards.`,"tooltip"),leading:t.createElement(p.Icon,{style:y.icon,source:C.Settings.Update}),trailing:()=>t.createElement(p.Arrow,{style:{marginLeft:-k}}),onPress:async function(){await Ce.checkForUpdates()}}),t.createElement(H,null),t.createElement(p,{label:"Source",subLabel:`Open the repository of ${e.name} externally.`,onLongPress:()=>x.displayToast(`Opens the repository of ${e.name} on GitHub in an external page to view any source code of the plugin.`,"tooltip"),leading:t.createElement(p.Icon,{style:y.icon,source:C.Open}),trailing:()=>t.createElement(p.Arrow,null),onPress:()=>{ae.openURL(e.plugin.repo)}}),t.createElement(H,null),t.createElement(p,{label:"PronounDB",subLabel:`Open the ${e.name} website externally at \`https://pronoundb.org\`.`,onLongPress:()=>x.displayToast("Opens the PronounDB website in an external page which allows you to link your Discord account to PronounDB.","tooltip"),leading:t.createElement(p.Icon,{style:y.icon,source:C.Settings.External}),trailing:()=>t.createElement(p.Arrow,{style:{marginLeft:-k}}),onPress:()=>{ae.openURL(e.plugin.pronoundb)}})))),t.createElement(S,{style:y.subheaderText},`Build: (${e.plugin.hash}) Release: (${e.release})`))};function De(e,o,n){return window.enmity.utilities.findInReactTree(e,o,n)}const{useThemeContext:Ie}=f("useThemeContext"),{meta:{resolveSemanticColor:Ae}}=f("colors","meta"),_e=le("UserProfileSection"),{UserProfileGradientCard:Fe}=f("UserProfileGradientCard"),{triggerHaptic:Le}=f("triggerHaptic"),A=_.createThemedStyleSheet({container:{alignSelf:"flex-start",padding:1,borderRadius:9,width:"100%",marginTop:-4,marginRight:-12},innerContainer:{paddingHorizontal:6,paddingVertical:8,overflow:"hidden",flexDirection:"row",justifyContent:"center",alignItems:"center"},circle:{width:10,height:10,borderRadius:10/2,marginRight:6},fallback:{color:s.ThemeColorMap.BACKGROUND_SECONDARY_ALT},text:{fontFamily:s.Fonts.DISPLAY_NORMAL}});var Oe=({pronoun:e})=>{const o=Ie(),n=Ae(o.theme,s.ThemeColorMap.TEXT_NORMAL);return t.createElement(_e,{title:"Pronouns"},t.createElement(O,{onPress:()=>{z.open({content:e,source:C.Pronoun}),Le()},style:T(I.name,"isRole",!0)?{justifyContent:"center",alignItems:"center"}:{}},T(I.name,"isRole",!0)?t.createElement(Fe,{style:A.container,fallbackBackground:A.fallback.color},t.createElement(g,{style:A.innerContainer},t.createElement(g,{style:[A.circle,{backgroundColor:n}]}),t.createElement(S,{style:[A.text,{color:n}]},e))):t.createElement(S,{style:[A.text,{fontSize:16,color:n}]},e)))};const U=me("pronoun-db"),Be=f("PRIMARY_INFO_TOP_OFFSET","SECONDARY_INFO_TOP_MARGIN","SIDE_PADDING"),Me=f("getUser"),q=f("View"),{DCDChatManager:Ne}=q.NativeModules,re=_.createThemedStyleSheet({opTagBackgroundColor:{color:s.ThemeColorMap.HEADER_PRIMARY},opTagTextColor:{color:s.ThemeColorMap.BACKGROUND_PRIMARY},mention:{color:s.ThemeColorMap.BACKGROUND_MENTIONED_HOVER}}),ke={...I,onStart(){U.before(Me,"getUser",(e,o,n)=>{const r=o[0];u.map[r]||X.insertItem(u.queue,r,u.queue.length,"user id pronoun queue"),u.updateQueuedPronouns()}),U.after(Be.default,"type",(e,o,n)=>{var r,a,m,w,l;const c=(a=(r=De(n,b=>{var P,$;return((P=b==null?void 0:b.type)==null?void 0:P.displayName)==="View"&&(($=b==null?void 0:b.props)==null?void 0:$.children.findIndex(j=>{var W;return((W=j==null?void 0:j.type)==null?void 0:W.name)==="UserProfileBio"}))!==-1}))==null?void 0:r.props)==null?void 0:a.children;if(!c)return n;const{userId:E}=(l=(w=(m=c==null?void 0:c.find(b=>{var P,$;return typeof(($=(P=b==null?void 0:b.props)==null?void 0:P.displayProfile)==null?void 0:$.userId)=="string"}))==null?void 0:m.props)==null?void 0:w.displayProfile)!=null?l:{};if(!E||!u.map[E]||u.referenceMap[u.map[E]]==="unspecified")return n;const R=u.referenceMap[u.map[E]];c.unshift(t.createElement(Oe,{pronoun:R}))}),U.before(Ne,"updateRows",(e,o,n)=>{var r,a,m;const w=JSON.parse(o[1]);for(const l of w){if(l.type!==1||!((r=l==null?void 0:l.message)!=null&&r.authorId)||!u.map[(a=l==null?void 0:l.message)==null?void 0:a.authorId]||u.referenceMap[u.map[(m=l==null?void 0:l.message)==null?void 0:m.authorId]]==="unspecified")continue;const c=u.referenceMap[u.map[l.message.authorId]];if(T(I.name,"isTimestamp",!1)&&l.message.timestamp){l.message.timestamp+=" \u2022 "+c;continue}l.message.opTagText&&(l.message.tagText=l.message.tagText?l.message.tagText+" \u2022 ":""+l.message.opTagText),l.message.opTagText=c,l.message.opTagTextColor=q.processColor(re.opTagTextColor.color),l.message.opTagBackgroundColor=q.processColor(re.opTagBackgroundColor.color)}o[1]=JSON.stringify(w)})},onStop(){U.unpatchAll()},getSettingsPanel(){return t.createElement($e,{manifest:I})}};se(ke);