Files
VRCX/html/app.js
2020-04-07 11:53:54 +09:00

1 line
90 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
!function(e){var t={};function r(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(i,a,function(t){return e[t]}.bind(null,a));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1),e.exports=r(2)},function(e,t){CefSharp.BindObjectAsync("VRCX","VRCXStorage","SQLite","LogWatcher","Discord").then((function(){document.addEventListener("keyup",(function(e){e.ctrlKey&&(e.shiftKey&&"KeyI"===e.code?VRCX.ShowDevTools():"KeyR"===e.code&&location.reload())})),VRCXStorage.GetBool=function(e){return"true"===this.Get(e)},VRCXStorage.SetBool=function(e,t){this.Set(e,t?"true":"false")},VRCXStorage.GetInt=function(e){return parseInt(this.Get(e),10)||0},VRCXStorage.SetInt=function(e,t){this.Set(e,String(t))},VRCXStorage.GetFloat=function(e){return parseFloat(this.Get(e),10)||0},VRCXStorage.SetFloat=function(e,t){this.Set(e,String(t))},VRCXStorage.GetArray=function(e){try{var t=JSON.parse(this.Get(e));if(Array.isArray(t))return t}catch(e){console.error(e)}return[]},VRCXStorage.SetArray=function(e,t){this.Set(e,JSON.stringify(t))},VRCXStorage.GetObject=function(e){try{var t=JSON.parse(this.Get(e));if(t===Object(t))return t}catch(e){console.error(e)}return{}},VRCXStorage.SetObject=function(e,t){this.Set(e,JSON.stringify(t))},setInterval((function(){VRCXStorage.Flush()}),3e5),Noty.overrideDefaults({layout:"bottomLeft",theme:"mint",timeout:6e3});var e=function(e,t){for(var{length:r}=e,i=0;i<r;++i)if(e[i]===t)return e.splice(i,1),!0;return!1},t=function(e){return String(e).replace(/["&'<>]/g,e=>`&#${e.charCodeAt(0)};`)};Vue.filter("escapeTag",t);Vue.filter("commaNumber",(function(e){return String(Number(e)).replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")}));var r=function(e,r){var i=new Date(e);if(isNaN(i))return t(e);var a=i.getHours(),s={YYYY:String(1e4+i.getFullYear()).substr(-4),MM:String(101+i.getMonth()).substr(-2),DD:String(100+i.getDate()).substr(-2),HH24:String(100+a).substr(-2),HH:String(100+(a>12?a-12:a)).substr(-2),MI:String(100+i.getMinutes()).substr(-2),SS:String(100+i.getSeconds()).substr(-2),AMPM:a>=12?"PM":"AM"};return r.replace(/YYYY|MM|DD|HH24|HH|MI|SS|AMPM/g,e=>s[e]||e)};Vue.filter("formatDate",r);Vue.filter("textToHex",(function(e){return String(e).split("").map(e=>e.charCodeAt(0).toString(16)).join(" ")}));var i=function(e){var r=Number(e);if(isNaN(r))return t(e);var i=[];return(r=Math.floor(r/1e3))<0&&(r=-r),r>=86400&&(i.push(`${Math.floor(r/86400)}d`),r%=86400),r>=3600&&(i.push(`${Math.floor(r/3600)}h`),r%=3600),r>=60&&(i.push(`${Math.floor(r/60)}m`),r%=60),(r||0===i.length)&&i.push(`${r}s`),i.join(" ")};Vue.filter("timeToText",i),Vue.use(VueLazyload,{preLoad:1,observer:!0,observerOptions:{rootMargin:"0px",threshold:.1}}),Vue.use(DataTables.DataTables),ELEMENT.locale(ELEMENT.lang.en);var a=document.createElement("link");a.disabled=!0,a.rel="stylesheet",a.href=`app.dark.css?_=${Date.now()}`,document.head.appendChild(a);var s={eng:"English",kor:"한국어",rus:"Русский",spa:"Español",por:"Português",zho:"中文",deu:"Deutsch",jpn:"日本語",fra:"Français",swe:"Svenska",nld:"Nederlands",pol:"Polski",dan:"Dansk",nor:"Norsk",ita:"Italiano",tha:"ภาษาไทย",fin:"Suomi",hun:"Magyar",ces:"Čeština",tur:"Türkçe",ara:"العربية"},o={eng:"us",kor:"kr",rus:"ru",spa:"es",por:"pt",zho:"cn",deu:"de",jpn:"jp",fra:"fr",swe:"se",nld:"nl",pol:"pl",dan:"dk",nor:"no",ita:"it",tha:"th",fin:"fi",hun:"hu",ces:"cz",tur:"tr",ara:"ae"},n={};n.eventHandlers=new Map,n.$emit=function(e,...t){var r=this.eventHandlers.get(e);if(void 0!==r)try{for(var i of r)i.apply(this,t)}catch(e){console.error(e)}},n.$on=function(e,t){var r=this.eventHandlers.get(e);void 0===r&&(r=[],this.eventHandlers.set(e,r)),r.push(t)},n.$off=function(e,t){var r=this.eventHandlers.get(e);if(void 0!==r)for(var{length:i}=r,a=0;a<i;++a)if(r[a]===t){i>1?r.splice(a,1):this.eventHandlers.delete(e);break}},n.pendingGetRequests=new Map,n.call=function(e,r){var i=`https://api.vrchat.cloud/api/1/${e}`,a={method:"GET",mode:"cors",credentials:"include",cache:"no-cache",redirect:"follow",referrerPolicy:"no-referrer",...r},{params:s}=a,o="GET"===a.method;if(o){if(s===Object(s)){var n=new URL(i),{searchParams:d}=n;for(var l in s)d.set(l,s[l]);i=n.toString()}if(void 0!==(c=this.pendingGetRequests.get(i)))return c}else a.headers={"Content-Type":"application/json;charset=utf-8",...a.headers},a.body=s===Object(s)?JSON.stringify(s):"{}";var c=fetch(i,a).catch(e=>{this.$throw(0,e)}).then(e=>e.json().catch(()=>{e.ok&&this.$throw(0,"Invalid JSON response"),this.$throw(e.status)}).then(r=>e.ok?(r.success===Object(r.success)&&new Noty({type:"success",text:t(r.success.message)}).show(),r):(r===Object(r)&&(r.error===Object(r.error)?this.$throw(r.error.status_code||e.status,r.error.message,r.error.data):"string"==typeof r.error&&this.$throw(r.status_code||e.status,r.error)),this.$throw(e.status,r),r)));return o&&(c.finally(()=>{this.pendingGetRequests.delete(i)}),this.pendingGetRequests.set(i,c)),c},n.statusCodes={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required",520:"Web server returns an unknown error",521:"Web server is down",522:"Connection timed out",523:"Origin is unreachable",524:"A timeout occurred",525:"SSL handshake failed",526:"Invalid SSL certificate",527:"Railgun Listener to origin error"},n.$throw=function(e,r,i){var a=[];if(e>0){var s=this.statusCodes[e];void 0===s?a.push(`${e}`):a.push(`${e} ${s}`)}throw void 0!==r&&a.push(JSON.stringify(r)),void 0!==i&&a.push(JSON.stringify(i)),(a=a.map(e=>t(e)).join("<br>")).length&&new Noty({type:"error",text:a}).show(),new Error(a)},n.$bulk=function(e,t){return void 0!==e.handle&&e.handle.call(this,t,e),t.json.length>0&&(e.params.offset+=t.json.length,e.N>0?e.N>e.params.offset:e.N<0?t.json.length:e.params.n===t.json.length)?this.bulk(e):void 0!==e.done&&e.done.call(this,!0,e),t},n.bulk=function(e){this[e.fn](e.params).catch(t=>{throw void 0!==e.done&&e.done.call(this,!1,e),t}).then(t=>this.$bulk(e,t))},n.cachedConfig={},n.$on("CONFIG",(function(e){e.ref=this.applyConfig(e.json)})),n.applyConfig=function(e){var t={clientApiKey:"",...e};return this.cachedConfig=t,t},n.getConfig=function(){return this.call("config",{method:"GET"}).then(e=>{var t={json:e};return this.$emit("CONFIG",t),t})},n.parseLocation=function(e){var t={tag:e=String(e||""),isOffline:!1,isPrivate:!1,worldId:"",instanceId:"",instanceName:"",accessType:"",userId:null,hiddenId:null,privateId:null,friendsId:null,canRequestInvite:!1};if("offline"===e)t.isOffline=!0;else if("private"===e)t.isPrivate=!0;else if(!1===e.startsWith("local")){var r=e.indexOf(":");r>=0?(t.worldId=e.substr(0,r),t.instanceId=e.substr(r+1),t.instanceId.split("~").forEach((e,r)=>{if(r){var i=e.indexOf("("),a=i>=0?e.lastIndexOf(")"):-1,s=a>=0?e.substr(0,i):e,o=i<a?e.substr(i+1,a-i-1):"";"hidden"===s?t.hiddenId=o:"private"===s?t.privateId=o:"friends"===s?t.friendsId=o:"canRequestInvite"===s&&(t.canRequestInvite=!0)}else t.instanceName=e}),t.accessType="public",null!==t.privateId?(t.canRequestInvite?t.accessType="invite+":t.accessType="invite",t.userId=t.privateId):null!==t.friendsId?(t.accessType="friends",t.userId=t.friendsId):null!==t.hiddenId&&(t.accessType="friends+",t.userId=t.hiddenId)):t.worldId=e}return t},Vue.component("launch",{template:'<el-button @click="confirm" size="mini" icon="el-icon-link" circle></el-button>',props:{location:String},methods:{parse(){var e=n.parseLocation(this.location);this.$el.style.display=e.isOffline||e.isPrivate?"none":""},confirm(){n.$emit("SHOW_LAUNCH_DIALOG",this.location)}},watch:{location(){this.parse()}},mounted(){this.parse()}}),Vue.component("location",{template:'<span @click="showWorldDialog" :class="{ \'x-link\': link }">{{ text }}<slot></slot></span>',props:{location:String,link:{type:Boolean,default:!0}},data(){return{text:this.location}},methods:{parse(){var e=n.parseLocation(this.location);if(e.isOffline)this.text="Offline";else if(e.isPrivate)this.text="Private";else if(e.worldId){var t=n.cachedWorlds.get(e.worldId);void 0===t?n.getWorld({worldId:e.worldId}).then(t=>(e.tag===this.location&&(e.instanceId?this.text=`${t.json.name} #${e.instanceName} ${e.accessType}`:this.text=t.json.name),t)):e.instanceId?this.text=`${t.name} #${e.instanceName} ${e.accessType}`:this.text=t.name}},showWorldDialog(){this.link&&n.$emit("SHOW_WORLD_DIALOG",this.location)}},watch:{location(){this.parse()}},created(){this.parse()}}),n.isLoggedIn=!1,n.cachedUsers=new Map,n.currentUser={},n.$on("LOGOUT",(function(){VRCX.DeleteAllCookies(),this.isLoggedIn=!1})),n.$on("USER:CURRENT",(function(e){e.ref=this.applyCurrentUser(e.json)})),n.$on("USER:CURRENT:SAVE",(function(e){this.$emit("USER:CURRENT",e)})),n.$on("USER",(function(e){e.ref=this.applyUser(e.json)})),n.$on("USER:LIST",(function(e){for(var t of e.json)this.$emit("USER",{json:t,params:{userId:t.id}})})),n.logout=function(){return this.call("logout",{method:"PUT"}).finally(()=>{this.$emit("LOGOUT")})},n.login=function(e){var t=`${e.username}:${e.password}`;return t=(t=(t=encodeURIComponent(t)).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))).replace("%","%25"),t=btoa(t),this.call(`auth/user?apiKey=${this.cachedConfig.clientApiKey}`,{method:"GET",headers:{Authorization:`Basic ${t}`}}).then(t=>{var r={json:t,params:e,origin:!0};return t.requiresTwoFactorAuth?this.$emit("USER:2FA",r):this.$emit("USER:CURRENT",r),r})},n.loginWithSteam=function(e){return this.call(`auth/steam?apiKey=${this.cachedConfig.clientApiKey}`,{method:"POST",params:e}).then(t=>{var r={json:t,params:e,origin:!0};return t.requiresTwoFactorAuth?this.$emit("USER:2FA",r):this.$emit("USER:CURRENT",r),r})},n.verifyOTP=function(e){return this.call("auth/twofactorauth/otp/verify",{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("OTP",r),r})},n.verifyTOTP=function(e){return this.call("auth/twofactorauth/totp/verify",{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("TOTP",r),r})},n.applyUserTrustLevel=function(e){e.$isModerator=e.developerType&&"none"!==e.developerType,e.$isTroll=!1;var{tags:t}=e;t.includes("admin_moderator")&&(e.$isModerator=!0),(t.includes("system_troll")||t.includes("system_probable_troll"))&&(e.$isTroll=!0),t.includes("system_legend")?(e.$trustLevel="Legendary User",e.$trustClass="x-tag-legendary"):t.includes("system_trust_legend")?(e.$trustLevel="Veteran User",e.$trustClass="x-tag-legend"):t.includes("system_trust_veteran")?(e.$trustLevel="Trusted User",e.$trustClass="x-tag-veteran"):t.includes("system_trust_trusted")?(e.$trustLevel="Known User",e.$trustClass="x-tag-trusted"):t.includes("system_trust_known")?(e.$trustLevel="User",e.$trustClass="x-tag-known"):t.includes("system_trust_basic")?(e.$trustLevel="New User",e.$trustClass="x-tag-basic"):(e.$trustLevel="Visitor",e.$trustClass="x-tag-untrusted"),e.$isModerator?(e.$trustLevel="VRChat Team",e.$trustClass="x-tag-vip"):e.$isTroll&&(e.$trustLevel="Nuisance",e.$trustClass="x-tag-troll")},n.applyUserLanguage=function(e){e.$languages=[];var{tags:t}=e;for(var r of t)if(!1!==r.startsWith("language_")){var i=r.substr(9),a=s[i];void 0!==a&&e.$languages.push({key:i,value:a})}},n.applyCurrentUser=function(e){var t=this.currentUser;return this.isLoggedIn?(Object.assign(t,e),t.homeLocation!==t.$homeLocation.tag&&(t.$homeLocation=this.parseLocation(t.homeLocation)),this.applyUserTrustLevel(t),this.applyUserLanguage(t)):((t={id:"",username:"",displayName:"",bio:"",bioLinks:[],pastDisplayNames:[],friends:[],currentAvatarImageUrl:"",currentAvatarThumbnailImageUrl:"",currentAvatar:"",homeLocation:"",twoFactorAuthEnabled:!1,status:"",statusDescription:"",state:"",tags:[],developerType:"",last_login:"",last_platform:"",allowAvatarCopying:!1,friendKey:"",onlineFriends:[],activeFriends:[],offlineFriends:[],$homeLocation:{},$isModerator:!1,$isTroll:!1,$trustLevel:"Visitor",$trustClass:"x-tag-untrusted",$languages:[],...e}).$homeLocation=this.parseLocation(t.homeLocation),this.applyUserTrustLevel(t),this.applyUserLanguage(t),this.currentUser=t,this.isLoggedIn=!0,this.$emit("LOGIN",{json:e,ref:t})),VRCXStorage.SetObject("currentUser",t),t},n.getCurrentUser=function(){return this.call(`auth/user?apiKey=${this.cachedConfig.clientApiKey}`,{method:"GET"}).then(e=>{var t={json:e,origin:!0};return e.requiresTwoFactorAuth?this.$emit("USER:2FA",t):this.$emit("USER:CURRENT",t),t})};var d=[],l=null;n.applyUser=function(e){var t,r=this.cachedUsers.get(e.id);if(void 0===r)(r={id:"",username:"",displayName:"",bio:"",bioLinks:[],currentAvatarImageUrl:"",currentAvatarThumbnailImageUrl:"",status:"",statusDescription:"",state:"",tags:[],developerType:"",last_login:"",last_platform:"",allowAvatarCopying:!1,isFriend:!1,friendKey:"",location:"",worldId:"",instanceId:"",$location:{},$location_at:Date.now(),$isModerator:!1,$isTroll:!1,$trustLevel:"Visitor",$trustClass:"x-tag-untrusted",$languages:[],...e}).$location=this.parseLocation(r.location),this.applyUserTrustLevel(r),this.applyUserLanguage(r),this.cachedUsers.set(r.id,r);else{var i={};for(var a in r)r[a]!==Object(r[a])&&(i[a]=!0);var s={...r};for(var a in Object.assign(r,e),r.location!==r.$location.tag&&(r.$location=this.parseLocation(r.location)),this.applyUserTrustLevel(r),this.applyUserLanguage(r),r)r[a]!==Object(r[a])&&(i[a]=!0);var o=!1;for(var a in i){var c=s[a],u=r[a];c===u?delete i[a]:(o=!0,i[a]=[u,c])}if(o&&"offline"!==r.status&&"offline"!==s.status){if(i.location){var h=Date.now();i.location.push(h-r.$location_at),r.$location_at=h}t={ref:r,props:i},d.push(t),null===l&&(l=setTimeout((function(){l=null;for(var{length:e}=d,t=0;t<e;++t)n.$emit("USER:UPDATE",d[t]);d.length=0}),1))}}return r},n.getUser=function(e){return this.call(`users/${e.userId}`,{method:"GET"}).then(t=>{var r={json:t,params:e};return this.$emit("USER",r),r})},n.getCachedUser=function(e){return new Promise((t,r)=>{var i=this.cachedUsers.get(e.userId);void 0===i?this.getUser(e).catch(r).then(t):t({cache:!0,json:i,params:e,ref:i})})},n.getUsers=function(e){return this.call("users",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("USER:LIST",r),r})},n.saveCurrentUser=function(e){return this.call(`users/${this.currentUser.id}`,{method:"PUT",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("USER:CURRENT:SAVE",r),r})},n.addUserTags=function(e){return this.call(`users/${this.currentUser.id}/addTags`,{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("USER:CURRENT:SAVE",r),r})},n.removeUserTags=function(e){return this.call(`users/${this.currentUser.id}/removeTags`,{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("USER:CURRENT:SAVE",r),r})},n.cachedWorlds=new Map,n.$on("WORLD",(function(e){e.ref=this.applyWorld(e.json)})),n.$on("WORLD:LIST",(function(e){for(var t of e.json)this.$emit("WORLD",{json:t,params:{worldId:t.id}})})),n.applyWorld=function(e){var t=this.cachedWorlds.get(e.id);return void 0===t?(t={id:"",name:"",description:"",authorId:"",authorName:"",capacity:0,tags:[],releaseStatus:"",imageUrl:"",thumbnailImageUrl:"",assetUrl:"",assetUrlObject:{},pluginUrl:"",pluginUrlObject:{},unityPackageUrl:"",unityPackageUrlObject:{},unityPackages:[],version:0,favorites:0,created_at:"",updated_at:"",publicationDate:"",labsPublicationDate:"",visits:0,popularity:0,heat:0,publicOccupants:0,privateOccupants:0,occupants:0,instances:[],$isLabs:!1,...e},this.cachedWorlds.set(t.id,t)):Object.assign(t,e),t.$isLabs=t.tags.includes("system_labs"),t},n.getWorld=function(e){return this.call(`worlds/${e.worldId}`,{method:"GET"}).then(t=>{var r={json:t,params:e};return this.$emit("WORLD",r),r})},n.getCachedWorld=function(e){return new Promise((t,r)=>{var i=this.cachedWorlds.get(e.worldId);void 0===i?this.getWorld(e).catch(r).then(t):t({cache:!0,json:i,params:e,ref:i})})},n.getWorlds=function(e,t){var r="worlds";return void 0!==t&&(r=`worlds/${t}`),this.call(r,{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("WORLD:LIST",r),r})},n.friends200=new Set,n.friends404=new Map,n.isFriendsLoading=!1,n.$on("LOGIN",(function(){this.friends200.clear(),this.friends404.clear(),this.isFriendsLoading=!1})),n.$on("FRIEND:LIST",(function(e){for(var t of e.json)this.$emit("USER",{json:t,params:{userId:t.id}}),this.friends200.add(t.id),this.friends404.delete(t.id)})),n.isAllFriendsRetrived=function(e){if(e){for(var t of this.currentUser.friends)if(!1===this.friends200.has(t)){var r=this.friends404.get(t)||0;r<2&&this.friends404.set(t,r+1)}}else for(var t of this.currentUser.friends)if(!1===this.friends200.has(t)||this.friends404.get(t)<2)return!1;return!0},n.refreshFriends=function(){var e={n:100,offset:0,offline:!1},t=this.currentUser.onlineFriends.length;if(0===t){if(0===(t=this.currentUser.friends.length)||this.isAllFriendsRetrived(!1))return;e.offline=!0}this.isFriendsLoading||(this.isFriendsLoading=!0,this.bulk({fn:"getFriends",N:t,params:e,done(t,r){if(this.isAllFriendsRetrived(e.offline))this.isFriendsLoading=!1;else{var{length:i}=this.currentUser.friends;r.N=i-e.offset,r.N<=0&&(r.N=i),e.offset=0,e.offline=!0,this.bulk(r)}}}))},n.getFriends=function(e){return this.call("auth/user/friends",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FRIEND:LIST",r),r})},n.deleteFriend=function(e){return this.call(`auth/user/friends/${e.userId}`,{method:"DELETE"}).then(t=>{var r={json:t,params:e};return this.$emit("FRIEND:DELETE",r),r})},n.sendFriendRequest=function(e){return this.call(`user/${e.userId}/friendRequest`,{method:"POST"}).then(t=>{var r={json:t,params:e};return this.$emit("FRIEND:REQUEST",r),r})},n.cancelFriendRequest=function(e){return this.call(`user/${e.userId}/friendRequest`,{method:"DELETE"}).then(t=>{var r={json:t,params:e};return this.$emit("FRIEND:REQUEST:CANCEL",r),r})},n.getFriendStatus=function(e){return this.call(`user/${e.userId}/friendStatus`,{method:"GET"}).then(t=>{var r={json:t,params:e};return this.$emit("FRIEND:STATUS",r),r})},n.cachedAvatars=new Map,n.$on("AVATAR",(function(e){e.ref=this.applyAvatar(e.json)})),n.$on("AVATAR:LIST",(function(e){for(var t of e.json)this.$emit("AVATAR",{json:t,params:{avatarId:t.id}})})),n.$on("AVATAR:SELECT",(function(e){this.$emit("USER:CURRENT",e)})),n.applyAvatar=function(e){var t=this.cachedAvatars.get(e.id);return void 0===t?(t={id:"",name:"",description:"",authorId:"",authorName:"",tags:[],assetUrl:"",assetUrlObject:{},imageUrl:"",thumbnailImageUrl:"",releaseStatus:"",version:0,unityPackages:[],unityPackageUrl:"",unityPackageUrlObject:{},created_at:"",updated_at:"",...e},this.cachedAvatars.set(t.id,t)):Object.assign(t,e),t},n.getAvatar=function(e){return this.call(`avatars/${e.avatarId}`,{method:"GET"}).then(t=>{var r={json:t,params:e};return this.$emit("AVATAR",r),r})},n.getCachedAvatar=function(e){return new Promise((t,r)=>{var i=this.cachedAvatars.get(e.avatarId);void 0===i?this.getAvatar(e).catch(r).then(t):t({cache:!0,json:i,params:e,ref:i})})},n.getAvatars=function(e){return this.call("avatars",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("AVATAR:LIST",r),r})},n.selectAvatar=function(e){return this.call(`avatars/${e.avatarId}/select`,{method:"PUT",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("AVATAR:SELECT",r),r})},n.cachedNotifications=new Map,n.isNotificationsLoading=!1,n.$on("LOGIN",(function(){this.cachedNotifications.clear(),this.isNotificationsLoading=!1})),n.$on("NOTIFICATION",(function(e){e.ref=this.applyNotification(e.json)})),n.$on("NOTIFICATION:LIST",(function(e){for(var t of e.json)this.$emit("NOTIFICATION",{json:t,params:{notificationId:t.id}})})),n.$on("NOTIFICATION:ACCEPT",(function(e){var t=this.cachedNotifications.get(e.params.notificationId);void 0===t||t.$isDeleted||(e.ref=t,t.$isDeleted=!0,this.$emit("NOTIFICATION:@DELETE",{ref:t,params:{notificationId:t.id}}),this.$emit("FRIEND:ADD",{params:{userId:t.senderUserId}}))})),n.$on("NOTIFICATION:HIDE",(function(e){var t=this.cachedNotifications.get(e.params.notificationId);void 0===t&&t.$isDeleted||(e.ref=t,t.$isDeleted=!0,this.$emit("NOTIFICATION:@DELETE",{ref:t,params:{notificationId:t.id}}))})),n.applyNotification=function(e){var t=this.cachedNotifications.get(e.id);if(void 0===t?(t={id:"",senderUserId:"",senderUsername:"",type:"",message:"",details:{},seen:!1,created_at:"",$isDeleted:!1,$isExpired:!1,...e},this.cachedNotifications.set(t.id,t)):(Object.assign(t,e),t.$isExpired=!1),t.details!==Object(t.details)){var r={};if("{}"!==t.details)try{var i=JSON.parse(t.details);i===Object(i)&&(r=i)}catch(e){}t.details=r}return t},n.expireNotifications=function(){for(var e of this.cachedNotifications.values())e.$isExpired=!0},n.deleteExpiredNotifcations=function(){for(var e of this.cachedNotifications.values())e.$isDeleted||!1===e.$isExpired||(e.$isDeleted=!0,this.$emit("NOTIFICATION:@DELETE",{ref:e,params:{notificationId:e.id}}))},n.refreshNotifications=function(){this.isNotificationsLoading||(this.isNotificationsLoading=!0,this.expireNotifications(),this.bulk({fn:"getNotifications",N:-1,params:{n:100,offset:0},done(e){e&&this.deleteExpiredNotifcations(),this.isNotificationsLoading=!1}}))},n.getNotifications=function(e){return this.call("auth/user/notifications",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("NOTIFICATION:LIST",r),r})},n.clearNotifications=function(){return this.call("auth/user/notifications/clear",{method:"PUT"}).then(e=>{var t={json:e};return this.$emit("NOTIFICATION:CLEAR",t),t})},n.sendNotification=function(e){return this.call(`user/${e.receiverUserId}/notification`,{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("NOTIFICATION:SEND",r),r})},n.acceptNotification=function(e){return this.call(`auth/user/notifications/${e.notificationId}/accept`,{method:"PUT"}).then(t=>{var r={json:t,params:e};return this.$emit("NOTIFICATION:ACCEPT",r),r})},n.hideNotification=function(e){return this.call(`auth/user/notifications/${e.notificationId}/hide`,{method:"PUT"}).then(t=>{var r={json:t,params:e};return this.$emit("NOTIFICATION:HIDE",r),r})},n.getFriendRequest=function(e){for(var t of this.cachedNotifications.values())if(!1===t.$isDeleted&&"friendRequest"===t.type&&t.senderUserId===e)return t.id;return""},n.parseInviteLocation=function(e){try{var t=n.parseLocation(e.details.worldId);return t.worldId&&t.instanceId?`${e.details.worldName} #${t.instanceName} ${t.accessType}`:e.message||e.details.worldId||e.details.worldName}catch(e){return""}},n.cachedPlayerModerations=new Map,n.isPlayerModerationsLoading=!1,n.$on("LOGIN",(function(){this.cachedPlayerModerations.clear(),this.isPlayerModerationsLoading=!1})),n.$on("PLAYER-MODERATION",(function(e){e.ref=this.applyPlayerModeration(e.json)})),n.$on("PLAYER-MODERATION:LIST",(function(e){for(var t of e.json)this.$emit("PLAYER-MODERATION",{json:t,params:{playerModerationId:t.id}})})),n.$on("PLAYER-MODERATION:SEND",(function(e){this.$emit("PLAYER-MODERATION",{json:e.json,params:{playerModerationId:e.json.id}})})),n.$on("PLAYER-MODERATION:DELETE",(function(e){var{type:t,moderated:r}=e.param,i=this.currentUser.id;for(var a of this.cachedPlayerModerations.values())!1===a.$isDeleted&&a.type===t&&a.targetUserId===r&&a.sourceUserId===i&&(a.$isDeleted=!0,this.$emit("PLAYER-MODERATION:@DELETE",{ref:a,params:{playerModerationId:a.id}}))})),n.applyPlayerModeration=function(e){var t=this.cachedPlayerModerations.get(e.id);return void 0===t?(t={id:"",type:"",sourceUserId:"",sourceDisplayName:"",targetUserId:"",targetDisplayName:"",created:"",$isDeleted:!1,$isExpired:!1,...e},this.cachedPlayerModerations.set(t.id,t)):(Object.assign(t,e),t.$isExpired=!1),t},n.expirePlayerModerations=function(){for(var e of this.cachedPlayerModerations.values())e.$isExpired=!0},n.deleteExpiredPlayerModerations=function(){for(var e of this.cachedPlayerModerations.values())e.$isDeleted||!1===e.$isExpired||(e.$isDeleted=!0,this.$emit("PLAYER-MODERATION:@DELETE",{ref:e,params:{playerModerationId:e.id}}))},n.refreshPlayerModerations=function(){this.isPlayerModerationsLoading||(this.isPlayerModerationsLoading=!0,this.expirePlayerModerations(),Promise.all([this.getPlayerModerations(),this.getPlayerModerationsAgainstMe()]).finally(()=>{this.isPlayerModerationsLoading=!1}).then(()=>{this.deleteExpiredPlayerModerations()}))},n.getPlayerModerations=function(){return this.call("auth/user/playermoderations",{method:"GET"}).then(e=>{var t={json:e};return this.$emit("PLAYER-MODERATION:LIST",t),t})},n.getPlayerModerationsAgainstMe=function(){return this.call("auth/user/playermoderated",{method:"GET"}).then(e=>{var t={json:e};return this.$emit("PLAYER-MODERATION:LIST",t),t})},n.sendPlayerModeration=function(e){return this.call("auth/user/playermoderations",{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("PLAYER-MODERATION:SEND",r),r})},n.deletePlayerModeration=function(e){return this.call("auth/user/unplayermoderate",{method:"PUT",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("PLAYER-MODERATION:DELETE",r),r})},n.cachedFavorites=new Map,n.cachedFavoritesByObjectId=new Map,n.cachedFavoriteGroups=new Map,n.cachedFavoriteGroupsByTypeName=new Map,n.favoriteFriendGroups=[],n.favoriteWorldGroups=[],n.favoriteAvatarGroups=[],n.isFavoriteLoading=!1,n.isFavoriteGroupLoading=!1,n.$on("LOGIN",(function(){this.cachedFavorites.clear(),this.cachedFavoritesByObjectId.clear(),this.cachedFavoriteGroups.clear(),this.cachedFavoriteGroupsByTypeName.clear(),this.favoriteFriendGroups=[],this.favoriteWorldGroups=[],this.favoriteAvatarGroups=[],this.isFavoriteLoading=!1,this.isFavoriteGroupLoading=!1,this.refreshFavorites()})),n.$on("FAVORITE",(function(e){var t=this.applyFavorite(e.json);t.$isDeleted||(e.ref=t)})),n.$on("FAVORITE:@DELETE",(function(e){var{ref:t}=e;null!==t.$groupRef&&--t.$groupRef.count})),n.$on("FAVORITE:LIST",(function(e){for(var t of e.json)this.$emit("FAVORITE",{json:t,params:{favoriteId:t.id}})})),n.$on("FAVORITE:ADD",(function(e){this.$emit("FAVORITE",{json:e.json,params:{favoriteId:e.json.id}})})),n.$on("FAVORITE:DELETE",(function(e){var t=this.cachedFavoritesByObjectId.get(e.params.objectId);void 0!==t&&(this.cachedFavoritesByObjectId.delete(e.params.objectId),t.$isDeleted||(e.ref=t,t.$isDeleted=!0,n.$emit("FAVORITE:@DELETE",{ref:t,params:{favoriteId:t.id}})))})),n.$on("FAVORITE:GROUP",(function(e){var t=this.applyFavoriteGroup(e.json);t.$isDeleted||(e.ref=t,null!==t.$groupRef&&(t.$groupRef.displayName=t.displayName))})),n.$on("FAVORITE:GROUP:LIST",(function(e){for(var t of e.json)this.$emit("FAVORITE:GROUP",{json:t,params:{favoriteGroupId:t.id}})})),n.$on("FAVORITE:GROUP:SAVE",(function(e){this.$emit("FAVORITE:GROUP",{json:e.json,params:{favoriteGroupId:e.json.id}})})),n.$on("FAVORITE:GROUP:CLEAR",(function(e){var t=`${e.params.type}:${e.params.group}`;for(var r of this.cachedFavorites.values())r.$isDeleted||r.$groupKey!==t||(this.cachedFavoritesByObjectId.delete(r.favoriteId),r.$isDeleted=!0,n.$emit("FAVORITE:@DELETE",{ref:r,params:{favoriteId:r.id}}))})),n.$on("FAVORITE:FRIEND:LIST",(function(e){for(var t of e.json)this.$emit("USER",{json:t,params:{userId:t.id}})})),n.$on("FAVORITE:WORLD:LIST",(function(e){for(var t of e.json)"???"!==t.id&&this.$emit("WORLD",{json:t,params:{worldId:t.id}})})),n.$on("FAVORITE:AVATAR:LIST",(function(e){for(var t of e.json)"hidden"!==t.releaseStatus&&this.$emit("AVATAR",{json:t,params:{avatarId:t.id}})})),n.applyFavorite=function(e){var t=this.cachedFavorites.get(e.id);if(void 0===t?(t={id:"",type:"",favoriteId:"",tags:[],$isDeleted:!1,$isExpired:!1,$groupKey:"",$groupRef:null,...e},this.cachedFavorites.set(t.id,t),this.cachedFavoritesByObjectId.set(t.favoriteId,t)):(Object.assign(t,e),t.$isExpired=!1),t.$groupKey=`${t.type}:${String(t.tags[0])}`,!1===t.$isDeleted&&null===t.$groupRef){var r=this.cachedFavoriteGroupsByTypeName.get(t.$groupKey);void 0!==r&&(t.$groupRef=r,++r.count)}return t},n.expireFavorites=function(){for(var e of this.cachedFavorites.values())e.$isExpired=!0},n.deleteExpiredFavorites=function(){for(var e of this.cachedFavorites.values())e.$isDeleted||!1===e.$isExpired||(e.$isDeleted=!0,this.$emit("FAVORITE:@DELETE",{ref:e,params:{favoriteId:e.id}}))},n.refreshFavoriteItems=function(){var e={friend:[0,"getFavoriteFriends"],world:[0,"getFavoriteWorlds"],avatar:[0,"getFavoriteAvatars"]};for(var t of this.cachedFavorites.values()){if(!t.$isDeleted)void 0!==(r=e[t.type])&&++r[0]}for(var r in e){var[i,a]=e[r];i>0&&this.bulk({fn:a,N:i,params:{n:100,offset:0}})}},n.refreshFavorites=function(){this.isFavoriteLoading||(this.isFavoriteLoading=!0,this.expireFavorites(),this.bulk({fn:"getFavorites",N:-1,params:{n:100,offset:0},done(e){e&&this.deleteExpiredFavorites(),this.refreshFavoriteItems(),this.refreshFavoriteGroups(),this.isFavoriteLoading=!1}}))},n.applyFavoriteGroup=function(e){var t=this.cachedFavoriteGroups.get(e.id);return void 0===t?(t={id:"",ownerId:"",ownerDisplayName:"",name:"",displayName:"",type:"",visibility:"",tags:[],$isDeleted:!1,$isExpired:!1,$groupRef:null,...e},this.cachedFavoriteGroups.set(t.id,t)):(Object.assign(t,e),t.$isExpired=!1),t},n.buildFavoriteGroups=function(){this.favoriteFriendGroups=[];for(var e=0;e<3;++e)this.favoriteFriendGroups.push({assign:!1,key:`friend:group_${e}`,type:"friend",name:`group_${e}`,displayName:`Group ${e+1}`,capacity:32,count:0});this.favoriteWorldGroups=[];for(e=0;e<4;++e)this.favoriteWorldGroups.push({assign:!1,key:`world:worlds${e+1}`,type:"world",name:`worlds${e+1}`,displayName:`Group ${e+1}`,capacity:32,count:0});this.favoriteAvatarGroups=[];for(e=0;e<1;++e)this.favoriteAvatarGroups.push({assign:!1,key:`avatar:avatars${e+1}`,type:"avatar",name:`avatars${e+1}`,displayName:`Group ${e+1}`,capacity:16,count:0});var t={friend:this.favoriteFriendGroups,world:this.favoriteWorldGroups,avatar:this.favoriteAvatarGroups},r=new Set;for(var i of this.cachedFavoriteGroups.values()){if(!i.$isDeleted)if(void 0!==(s=t[i.type]))for(var a of s)if(!1===a.assign&&a.name===i.name){a.assign=!0,a.displayName=i.displayName,i.$groupRef=a,r.add(i.id);break}}for(var i of this.cachedFavoriteGroups.values()){var s;if(!i.$isDeleted&&!r.has(i.id))if(void 0!==(s=t[i.type]))for(var a of s)if(!1===a.assign){a.assign=!0,a.key=`${a.type}:${i.name}`,a.name=i.name,a.displayName=i.displayName,i.$groupRef=a,r.add(i.id);break}}for(var o in this.cachedFavoriteGroupsByTypeName.clear(),t)for(var a of t[o])this.cachedFavoriteGroupsByTypeName.set(a.key,a);for(var i of this.cachedFavorites.values()){if(i.$groupRef=null,!i.$isDeleted)void 0!==(a=this.cachedFavoriteGroupsByTypeName.get(i.$groupKey))&&(i.$groupRef=a,++a.count)}},n.expireFavoriteGroups=function(){for(var e of this.cachedFavoriteGroups.values())e.$isExpired=!0},n.deleteExpiredFavoriteGroups=function(){for(var e of this.cachedFavoriteGroups.values())e.$isDeleted||!1===e.$isExpired||(e.$isDeleted=!0,this.$emit("FAVORITE:GROUP:@DELETE",{ref:e,params:{favoriteGroupId:e.id}}))},n.refreshFavoriteGroups=function(){this.isFavoriteGroupLoading||(this.isFavoriteGroupLoading=!0,this.expireFavoriteGroups(),this.bulk({fn:"getFavoriteGroups",N:-1,params:{n:100,offset:0},done(e){e&&(this.deleteExpiredFavoriteGroups(),this.buildFavoriteGroups()),this.isFavoriteGroupLoading=!1}}))},n.getFavorites=function(e){return this.call("favorites",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:LIST",r),r})},n.addFavorite=function(e){return this.call("favorites",{method:"POST",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:ADD",r),r})},n.deleteFavorite=function(e){return this.call(`favorites/${e.objectId}`,{method:"DELETE"}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:DELETE",r),r})},n.getFavoriteGroups=function(e){return this.call("favorite/groups",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:GROUP:LIST",r),r})},n.saveFavoriteGroup=function(e){return this.call(`favorite/group/${e.type}/${e.group}/${this.currentUser.id}`,{method:"PUT",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:GROUP:SAVE",r),r})},n.clearFavoriteGroup=function(e){return this.call(`favorite/group/${e.type}/${e.group}/${this.currentUser.id}`,{method:"DELETE",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:GROUP:CLEAR",r),r})},n.getFavoriteFriends=function(e){return this.call("auth/user/friends/favorite",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:FRIEND:LIST",r),r})},n.getFavoriteWorlds=function(e){return this.call("worlds/favorites",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:WORLD:LIST",r),r})},n.getFavoriteAvatars=function(e){return this.call("avatars/favorites",{method:"GET",params:e}).then(t=>{var r={json:t,params:e};return this.$emit("FAVORITE:AVATAR:LIST",r),r})},n.webSocket=null,n.$on("LOGOUT",(function(){this.closeWebSocket()})),n.$on("USER:CURRENT",(function(){null===this.webSocket&&this.getAuth()})),n.$on("AUTH",(function(e){e.json.ok&&this.connectWebSocket(e.json.token)})),n.$on("PIPELINE",(function(e){var{type:t,content:r}=e.json;switch(t){case"notification":this.$emit("NOTIFICATION",{json:r,params:{notificationId:r.id}});break;case"friend-add":this.$emit("USER",{json:r.user,params:{userId:r.userId}}),this.$emit("FRIEND:ADD",{params:{userId:r.userId}});break;case"friend-delete":this.$emit("FRIEND:DELETE",{params:{userId:r.userId}});break;case"friend-online":"private"!==r.location&&this.$emit("WORLD",{json:r.world,params:{worldId:r.world.id}}),this.$emit("USER",{json:{location:r.location,...r.user},params:{userId:r.userId}}),this.$emit("FRIEND:STATE",{json:{state:"online"},params:{userId:r.userId}});break;case"friend-active":this.$emit("USER",{json:r.user,params:{userId:r.userId}}),this.$emit("FRIEND:STATE",{json:{state:"active"},params:{userId:r.userId}});break;case"friend-offline":this.$emit("FRIEND:STATE",{json:{state:"offline"},params:{userId:r.userId}});break;case"friend-update":this.$emit("USER",{json:r.user,params:{userId:r.userId}});break;case"friend-location":"private"!==r.location&&this.$emit("WORLD",{json:r.world,params:{worldId:r.world.id}}),r.userId===this.currentUser.id?this.$emit("USER",{json:r.user,params:{userId:r.userId}}):this.$emit("USER",{json:{location:r.location,...r.user},params:{userId:r.userId}});break;case"user-update":this.$emit("USER:CURRENT",{json:r.user,params:{userId:r.userId}});break;case"user-location":r.world===Object(r.world)&&this.$emit("WORLD",{json:r.world,params:{worldId:r.world.id}}),this.$emit("USER",{json:{id:r.userId,location:r.location},params:{userId:r.userId}})}})),n.getAuth=function(){return this.call("auth",{method:"GET"}).then(e=>{var t={json:e};return this.$emit("AUTH",t),t})},n.connectWebSocket=function(e){if(null===this.webSocket){var t=new WebSocket(`wss://pipeline.vrchat.cloud/?auth=${e}`);t.onclose=()=>{this.webSocket===t&&(this.webSocket=null);try{t.close()}catch(e){}},t.onerror=t.onclose,t.onmessage=({data:e})=>{try{var t=JSON.parse(e);t.content=JSON.parse(t.content),this.$emit("PIPELINE",{json:t})}catch(e){console.error(e)}},this.webSocket=t}},n.closeWebSocket=function(){var e=this.webSocket;if(null!==e){this.webSocket=null;try{e.close()}catch(e){}}},n.getVisits=function(){return this.call("visits",{method:"GET"}).then(e=>{var t={json:e};return this.$emit("VISITS",t),t})};var c=e=>{var t=String(e).match(/file_[0-9A-Za-z-]+/);return t?t[0]:""},u=e=>{var t=[];for(var r in e){var i=e[r];Array.isArray(i)?t.push({children:i.map((e,t)=>e===Object(e)?{children:u(e),key:t}:{key:t,value:e}),key:r}):i===Object(i)?t.push({children:u(i),key:r}):t.push({key:r,value:String(i)})}return t.sort((function(e,t){var r=String(e.key).toUpperCase(),i=String(t.key).toUpperCase();return r<i?-1:r>i?1:0})),t},h=[];Vue.component("timer",{template:'<span v-text="text"></span>',props:{epoch:{type:Number,default:()=>Date.now()}},data:()=>({text:""}),methods:{update(){this.text=i(Date.now()-this.epoch)}},watch:{date(){this.update()}},mounted(){h.push(this),this.update()},destroyed(){e(h,this)}}),setInterval((function(){for(var e of h)e.update()}),5e3);var f={data:{API:n,VRCX:VRCX,nextRefresh:0,isGameRunning:!1,appVersion:"VRCX 2020.04.07",latestAppVersion:"",ossDialog:!1},computed:{},methods:{},watch:{},el:"#x-app",mounted(){LogWatcher.Reset().then(()=>{n.$on("SHOW_WORLD_DIALOG",e=>this.showWorldDialog(e)),n.$on("SHOW_LAUNCH_DIALOG",e=>this.showLaunchDialog(e)),setInterval(()=>this.update(),1e3),this.update(),this.$nextTick((function(){this.$el.style.display="",this.loginForm.loading=!0,n.getConfig().catch(e=>{throw this.loginForm.loading=!1,e}).then(e=>(n.getCurrentUser().finally(()=>{this.loginForm.loading=!1}),e))}))}),this.checkAppVersion()}};f.methods.openExternalLink=function(e){this.$confirm(`${e}`,"Open External Link",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&VRCX.OpenLink(e)}})},f.methods.languageClass=function(e){var t={},r=o[e];return void 0!==r&&(t[r]=!0),t},f.methods.checkAppVersion=function(){fetch("https://api.github.com/repos/pypy-vrc/VRCX/releases/latest").then(e=>e.json()).then(e=>{e===Object(e)&&e.name&&e.published_at?(this.latestAppVersion=`${e.name} (${r(e.published_at,"YYYY-MM-DD HH24:MI:SS")})`,e.name>this.appVersion&&(new Noty({type:"info",text:`Update available!!<br>${this.latestAppVersion}`,timeout:6e4,callbacks:{onClick:()=>VRCX.OpenLink("https://github.com/pypy-vrc/VRCX/releases")}}).show(),this.notifyMenu("more"))):this.latestAppVersion="Error occured"})},f.methods.update=function(){!1!==n.isLoggedIn&&(--this.nextRefresh<=0&&(this.nextRefresh=60,n.getCurrentUser().catch(e=>{throw 401===e.status_code&&n.getConfig().then(e=>(n.login({username:this.loginForm.username,password:this.loginForm.password}).catch(e=>{throw 401===e.status_code&&n.logout(),e}),e)),e})),this.checkActiveFriends(),this.refreshGameLog(),VRCX.IsGameRunning().then(e=>{e!==this.isGameRunning&&(this.isGameRunning=e,Discord.SetTimestamps(Date.now(),0)),this.updateDiscord(),this.updateOpenVR()}))},f.methods.updateSharedFeed=function(){for(var e=[],{data:t}=this.gameLogTable,r=t.length,i=0;i<25&&!(r<=0);){if((d=t[--r]).type){var a=!1,s=!1;for(var o of n.cachedUsers.values())if(o.displayName===d.data){a=this.friends.has(o.id),s=n.cachedFavoritesByObjectId.has(o.id);break}e.push({...d,isFriend:a,isFavorite:s})}else e.push(d);++i}var{data:t}=this.feedTable;for(r=t.length,i=0;i<25&&!(r<=0);){var d;"Avatar"!==(d=t[--r]).type&&(e.push({...d,isFriend:this.friends.has(d.userId),isFavorite:n.cachedFavoritesByObjectId.has(d.userId)}),++i)}e.sort((function(e,t){return e.created_at<t.created_at?1:e.created_at>t.created_at?-1:0})),e.length>25&&(e.length=25),VRCXStorage.SetArray("sharedFeeds",e)},f.methods.notifyMenu=function(e){var{menu:t}=this.$refs;if(t.activeIndex!==e){var r=t.items[e];r&&r.$el.classList.add("notify")}},f.methods.selectMenu=function(e){document.querySelectorAll('[role="tooltip"]').forEach(e=>{e.remove()});var t=this.$refs.menu.items[e];t&&t.$el.classList.remove("notify")},f.methods.promptTOTP=function(){this.$prompt("Enter a numeric code from your authenticator app","Two-factor Authentication",{distinguishCancelAndClose:!0,cancelButtonText:"Use OTP",confirmButtonText:"Verify",inputPlaceholder:"Code",inputPattern:/^[0-9]{6}$/,inputErrorMessage:"Invalid Code",callback:(e,t)=>{"confirm"===e?n.verifyTOTP({code:t.inputValue}).catch(e=>{throw this.promptTOTP(),e}).then(e=>(n.getCurrentUser(),e)):"cancel"===e&&this.promptOTP()}})},f.methods.promptOTP=function(){this.$prompt("Enter one of your saved recovery codes","Two-factor Authentication",{distinguishCancelAndClose:!0,cancelButtonText:"Use TOTP",confirmButtonText:"Verify",inputPlaceholder:"Code",inputPattern:/^[a-z0-9]{4}-[a-z0-9]{4}$/,inputErrorMessage:"Invalid Code",callback:(e,t)=>{"confirm"===e?n.verifyOTP({code:t.inputValue}).catch(e=>{throw this.promptOTP(),e}).then(e=>(n.getCurrentUser(),e)):"cancel"===e&&this.promptTOTP()}})},n.$on("USER:2FA",(function(){f.promptTOTP()})),n.$on("LOGOUT",(function(){new Noty({type:"success",text:`See you again, <strong>${t(this.currentUser.displayName)}</strong>!`}).show()})),n.$on("LOGIN",(function(e){new Noty({type:"success",text:`Hello there, <strong>${t(e.ref.displayName)}</strong>!`}).show(),f.$refs.menu.activeIndex="feed"})),f.data.loginForm={loading:!0,username:"",password:"",rules:{username:[{required:!0,trigger:"blur"}],password:[{required:!0,trigger:"blur"}]}},f.methods.login=function(){this.$refs.loginForm.validate(e=>{e&&!this.loginForm.loading&&(this.loginForm.loading=!0,n.getConfig().catch(e=>{throw this.loginForm.loading=!1,e}).then(e=>(n.login({username:this.loginForm.username,password:this.loginForm.password}).finally(()=>{this.loginForm.loading=!1}),e)))})},f.methods.loginWithSteam=function(){this.loginForm.loading||(this.loginForm.loading=!0,VRCX.LoginWithSteam().catch(e=>{throw this.loginForm.loading=!1,e}).then(e=>{e?n.getConfig().catch(e=>{throw this.loginForm.loading=!1,e}).then(t=>(n.loginWithSteam({steamTicket:e}).finally(()=>{this.loginForm.loading=!1}),t)):(this.loginForm.loading=!1,this.$message({message:"It only works when VRChat is running.",type:"error"}))}))},f.methods.loadMemo=function(e){var t=`memo_${e}`;return VRCXStorage.Get(t)},f.methods.saveMemo=function(e,t){var r=`memo_${e}`;t?VRCXStorage.Set(r,String(t)):VRCXStorage.Remove(r);var i=this.friends.get(e);i&&(i.memo=String(t||""))},f.data.friends=new Map,f.data.pendingActiveFriends=new Set,f.data.friendsNo=0,f.data.isFriendsGroup0=!0,f.data.isFriendsGroup1=!0,f.data.isFriendsGroup2=!0,f.data.isFriendsGroup3=!1,f.data.friendsGroup0_=[],f.data.friendsGroup1_=[],f.data.friendsGroup2_=[],f.data.friendsGroup3_=[],f.data.friendsGroupA_=[],f.data.friendsGroupB_=[],f.data.friendsGroupC_=[],f.data.friendsGroupD_=[],f.data.sortFriendsGroup0=!1,f.data.sortFriendsGroup1=!1,f.data.sortFriendsGroup2=!1,f.data.sortFriendsGroup3=!1,f.data.orderFriendsGroup0=VRCXStorage.GetBool("orderFriendGroup0"),f.data.orderFriendsGroup1=VRCXStorage.GetBool("orderFriendGroup1"),f.data.orderFriendsGroup2=VRCXStorage.GetBool("orderFriendGroup2"),f.data.orderFriendsGroup3=VRCXStorage.GetBool("orderFriendGroup3");var p=function(){VRCXStorage.SetBool("orderFriendGroup0",this.orderFriendsGroup0),VRCXStorage.SetBool("orderFriendGroup1",this.orderFriendsGroup1),VRCXStorage.SetBool("orderFriendGroup2",this.orderFriendsGroup2),VRCXStorage.SetBool("orderFriendGroup3",this.orderFriendsGroup3)};f.watch.orderFriendsGroup0=p,f.watch.orderFriendsGroup1=p,f.watch.orderFriendsGroup2=p,f.watch.orderFriendsGroup3=p,f.methods.fetchActiveFriend=function(e){return this.pendingActiveFriends.add(e),n.getUser({userId:e}).then(t=>(this.pendingActiveFriends.delete(e),t))},f.methods.checkActiveFriends=function(){if(!1!==Array.isArray(n.currentUser.activeFriends))for(var e of n.currentUser.activeFriends)if(!this.pendingActiveFriends.has(e)){var t=n.cachedUsers.get(e);if(void 0===t||"offline"===t.status){if(this.pendingActiveFriends.size>=5)break;this.fetchActiveFriend(e)}}},n.$on("LOGIN",(function(){f.friends.clear(),f.pendingActiveFriends.clear(),f.friendsNo=0,f.isFriendsGroup0=!0,f.isFriendsGroup1=!0,f.isFriendsGroup2=!0,f.isFriendsGroup3=!1,f.friendsGroup0_=[],f.friendsGroup1_=[],f.friendsGroup2_=[],f.friendsGroup3_=[],f.friendsGroupA_=[],f.friendsGroupB_=[],f.friendsGroupC_=[],f.friendsGroupD_=[],f.sortFriendsGroup0=!1,f.sortFriendsGroup1=!1,f.sortFriendsGroup2=!1,f.sortFriendsGroup3=!1})),n.$on("USER:CURRENT",(function(e){f.refreshFriends(e.ref,e.origin)})),n.$on("USER",(function(e){f.updateFriend(e.ref.id)})),n.$on("FRIEND:ADD",(function(e){f.addFriend(e.params.userId)})),n.$on("FRIEND:DELETE",(function(e){f.deleteFriend(e.params.userId)})),n.$on("FRIEND:STATE",(function(e){f.updateFriend(e.params.userId,e.json.state)})),n.$on("FAVORITE",(function(e){f.updateFriend(e.ref.favoriteId)})),n.$on("FAVORITE:@DELETE",(function(e){f.updateFriend(e.ref.favoriteId)})),f.methods.refreshFriends=function(e,t){var r=new Map;for(var i of e.friends)r.set(i,"offline");for(var i of e.offlineFriends)r.set(i,"offline");for(var i of e.activeFriends)r.set(i,"active");for(var i of e.onlineFriends)r.set(i,"online");for(var[i,a]of r)this.friends.has(i)?this.updateFriend(i,a,t):this.addFriend(i,a);for(var i of this.friends.keys())!1===r.has(i)&&this.deleteFriend(i);t&&n.refreshFriends()},f.methods.addFriend=function(e,t){if(!this.friends.has(e)){var r=n.cachedUsers.get(e),i={id:e,state:t||"offline",isVIP:n.cachedFavoritesByObjectId.has(e),ref:r,name:"",no:++this.friendsNo,memo:this.loadMemo(e)};void 0===r?void 0!==(r=this.friendLog[e])&&r.displayName&&(i.name=r.displayName):i.name=r.name,this.friends.set(e,i),"online"===i.state?i.isVIP?(this.sortFriendsGroup0=!0,this.friendsGroup0_.push(i),this.friendsGroupA_.unshift(i)):(this.sortFriendsGroup1=!0,this.friendsGroup1_.push(i),this.friendsGroupB_.unshift(i)):"active"===i.state?(this.sortFriendsGroup2=!0,this.friendsGroup2_.push(i),this.friendsGroupC_.unshift(i)):(this.sortFriendsGroup3=!0,this.friendsGroup3_.push(i),this.friendsGroupD_.unshift(i))}},f.methods.deleteFriend=function(t){var r=this.friends.get(t);void 0!==r&&(this.friends.delete(t),"online"===r.state?r.isVIP?(e(this.friendsGroup0_,r),e(this.friendsGroupA_,r)):(e(this.friendsGroup1_,r),e(this.friendsGroupB_,r)):"active"===r.state?(e(this.friendsGroup2_,r),e(this.friendsGroupC_,r)):(e(this.friendsGroup3_,r),e(this.friendsGroupD_,r)))},f.methods.updateFriend=function(t,r,i){var a=this.friends.get(t);if(void 0!==a){var s=n.cachedUsers.get(t),o=n.cachedFavoritesByObjectId.has(t);void 0===r||a.state===r?(a.ref!==s&&(a.ref=s,"online"===a.state?a.isVIP?(e(this.friendsGroupA_,a),this.friendsGroupA_.push(a)):(e(this.friendsGroupB_,a),this.friendsGroupB_.push(a)):"active"===a.state?(e(this.friendsGroupC_,a),this.friendsGroupC_.push(a)):(e(this.friendsGroupD_,a),this.friendsGroupD_.push(a))),a.isVIP!==o&&(a.isVIP=o,"online"===a.state&&(a.isVIP?(e(this.friendsGroup1_,a),e(this.friendsGroupB_,a),this.sortFriendsGroup0=!0,this.friendsGroup0_.push(a),this.friendsGroupA_.unshift(a)):(e(this.friendsGroup0_,a),e(this.friendsGroupA_,a),this.sortFriendsGroup1=!0,this.friendsGroup1_.push(a),this.friendsGroupB_.unshift(a)))),void 0!==s&&a.name!==s.displayName&&(a.name=s.displayName,"online"===a.state?a.isVIP?this.sortFriendsGroup0=!0:this.sortFriendsGroup1=!0:"active"===a.state?this.sortFriendsGroup2=!0:this.sortFriendsGroup3=!0),i&&"online"!==a.state&&void 0!==s&&""!==s.location&&"offline"!==s.location&&n.getUser({userId:t})):("online"===a.state?a.isVIP?(e(this.friendsGroup0_,a),e(this.friendsGroupA_,a)):(e(this.friendsGroup1_,a),e(this.friendsGroupB_,a)):"active"===a.state?(e(this.friendsGroup2_,a),e(this.friendsGroupC_,a)):(e(this.friendsGroup3_,a),e(this.friendsGroupD_,a)),a.state!==r&&(a.state=r),a.isVIP!==o&&(a.isVIP=o),void 0!==s&&(a.ref!==s&&(a.ref=s),a.name!==s.displayName&&(a.name=s.displayName)),"online"===a.state?a.isVIP?(this.sortFriendsGroup0=!0,this.friendsGroup0_.push(a),this.friendsGroupA_.unshift(a)):(this.sortFriendsGroup1=!0,this.friendsGroup1_.push(a),this.friendsGroupB_.unshift(a)):"active"===a.state?(this.sortFriendsGroup2=!0,this.friendsGroup2_.push(a),this.friendsGroupC_.unshift(a)):(this.sortFriendsGroup3=!0,this.friendsGroup3_.push(a),this.friendsGroupD_.unshift(a)))}};var v=function(e,t){var r=String(e.name).toUpperCase(),i=String(t.name).toUpperCase();return r<i?-1:r>i?1:0},m=function(e,t){var r=String(e.updated_at).toUpperCase(),i=String(t.updated_at).toUpperCase();return r<i?1:r>i?-1:0},g=function(e,t){var r=String(e.displayName).toUpperCase(),i=String(t.displayName).toUpperCase();return r<i?-1:r>i?1:0};f.computed.friendsGroup0=function(){return this.orderFriendsGroup0?this.friendsGroupA_:(this.sortFriendsGroup0&&(this.sortFriendsGroup0=!1,this.friendsGroup0_.sort(v)),this.friendsGroup0_)},f.computed.friendsGroup1=function(){return this.orderFriendsGroup1?this.friendsGroupB_:(this.sortFriendsGroup1&&(this.sortFriendsGroup1=!1,this.friendsGroup1_.sort(v)),this.friendsGroup1_)},f.computed.friendsGroup2=function(){return this.orderFriendsGroup2?this.friendsGroupC_:(this.sortFriendsGroup2&&(this.sortFriendsGroup2=!1,this.friendsGroup2_.sort(v)),this.friendsGroup2_)},f.computed.friendsGroup3=function(){return this.orderFriendsGroup3?this.friendsGroupD_:(this.sortFriendsGroup3&&(this.sortFriendsGroup3=!1,this.friendsGroup3_.sort(v)),this.friendsGroup3_)},f.methods.userStatusClass=function(e){var t={};return void 0!==e&&("offline"===e.location?t.offline=!0:"active"===e.status?t.active=!0:"join me"===e.status?t.joinme=!0:"ask me"===e.status?t.askme=!0:"busy"===e.status&&(t.busy=!0)),t},f.methods.confirmDeleteFriend=function(e){this.$confirm("Continue? Unfriend","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.deleteFriend({userId:e})}})},f.data.quickSearch="",f.data.quickSearchItems=[],f.methods.quickSearchRemoteMethod=function(e){var t=[];if(e){var r=e.toUpperCase();for(var i of this.friends.values())if(void 0!==i.ref){var a=i.name.toUpperCase(),s=a.includes(r);if(!s){var o=String(i.ref.username);s=o.toUpperCase().includes(r)&&!o.startsWith("steam_")}!s&&i.memo&&(s=String(i.memo).toUpperCase().includes(r)),s&&t.push({value:i.id,label:i.name,ref:i.ref,NAME:a})}t.sort((function(e,t){var i=e.NAME.startsWith(r),a=t.NAME.startsWith(r);if(i!==a){if(i)return-1;if(a)return 1}return e.NAME<t.NAME?-1:e.NAME>t.NAME?1:0})),t.length>4&&(t.length=4),t.push({value:`search:${e}`,label:e})}this.quickSearchItems=t},f.methods.quickSearchChange=function(e){e&&(e.startsWith("search:")?(this.searchText=e.substr(7),this.search(),this.$refs.menu.activeIndex="search"):this.showUserDialog(e))},f.methods.quickSearchVisibleChange=function(e){e&&(this.quickSearch="")},f.data.feedTable={data:[],filters:[{prop:"type",value:[],filterFn:(e,t)=>t.value.some(t=>t===e.type)},{prop:"displayName",value:""},{prop:"userId",value:!1,filterFn:(e,t)=>!t.value||n.cachedFavoritesByObjectId.has(e.userId)}],tableProps:{stripe:!0,size:"mini",defaultSort:{prop:"created_at",order:"descending"}},pageSize:10,paginationProps:{small:!0,layout:"sizes,prev,pager,next,total",pageSizes:[10,25,50,100]}},n.$on("LOGIN",(function(e){f.feedTable.data=VRCXStorage.GetArray(`${e.ref.id}_feedTable`),f.sweepFeed()})),n.$on("USER:UPDATE",(function(e){var{ref:t,props:r}=e;!1!==f.friends.has(t.id)&&(r.location&&("offline"===r.location[0]?f.addFeed("Offline",t,{location:r.location[1],time:r.location[2]}):"offline"===r.location[1]?f.addFeed("Online",t,{location:r.location[0]}):f.addFeed("GPS",t,{location:[r.location[0],r.location[1]],time:r.location[2]})),r.currentAvatarThumbnailImageUrl&&f.addFeed("Avatar",t,{avatar:r.currentAvatarThumbnailImageUrl}),(r.status||r.statusDescription)&&f.addFeed("Status",t,{status:[{status:r.status?r.status[0]:t.status,statusDescription:r.statusDescription?r.statusDescription[0]:t.statusDescription},{status:r.status?r.status[1]:t.status,statusDescription:r.statusDescription?r.statusDescription[1]:t.statusDescription}]}))}));var I=null;f.methods.saveFeed=function(){null===I&&(I=setTimeout(()=>{I=null,VRCXStorage.SetArray(`${n.currentUser.id}_feedTable`,this.feedTable.data)},1))},f.methods.addFeed=function(e,t,r){this.feedTable.data.push({created_at:(new Date).toJSON(),type:e,userId:t.id,displayName:t.displayName,...r}),this.sweepFeed(),this.saveFeed(),this.notifyMenu("feed")},f.methods.clearFeed=function(){this.$confirm("Continue? Clear Feed","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:e=>{if("confirm"===e){var t=this.feedTable;t.data=t.data.filter(e=>!t.filters.every(t=>{if(t.value){if(!Array.isArray(t.value))return t.filterFn?t.filterFn(e,t):String(e[t.prop]).toUpperCase().includes(String(t.value).toUpperCase());if(t.value.length){if(t.filterFn)return t.filterFn(e,t);var r=String(e[t.prop]).toUpperCase();return t.value.some(e=>r.includes(String(e).toUpperCase()))}}return!0}))}}})},f.methods.sweepFeed=function(){for(var{data:e}=this.feedTable,t=new Date(Date.now()-2592e5).toJSON(),r=0,i=e.length;r<i&&e[r].created_at<t;)++r;r===i?this.feedTable.data=[]:r&&e.splice(0,r)},f.data.lastLocation="",f.data.lastLocation$={},f.data.discordActive=VRCXStorage.GetBool("discordActive"),f.data.discordInstance=VRCXStorage.GetBool("discordInstance");var $=function(){VRCXStorage.SetBool("discordActive",this.discordActive),VRCXStorage.SetBool("discordInstance",this.discordInstance)};f.watch.discordActive=$,f.watch.discordInstance=$,f.data.gameLogTable={data:[],filters:[{prop:"type",value:[],filterFn:(e,t)=>t.value.some(t=>t===e.type)},{prop:"data",value:""}],tableProps:{stripe:!0,size:"mini",defaultSort:{prop:"created_at",order:"descending"}},pageSize:10,paginationProps:{small:!0,layout:"sizes,prev,pager,next,total",pageSizes:[10,25,50,100]}},f.methods.resetGameLog=function(){LogWatcher.Reset().then(()=>{this.gameLogTable.data=[]})},f.methods.refreshGameLog=function(){LogWatcher.Get().then(e=>{if(e.length){var{data:t}=this.gameLogTable;for(var r of e){var i={created_at:String(r[0]),type:String(r[1]),data:String(r[2])};if("Location"===i.type){var a=i.data;a.endsWith(":")&&(a=a.substr(0,a.length-1),i.data=a),this.lastLocation=a}t.push(i)}this.sweepGameLog(),t.length&&this.notifyMenu("gameLog")}this.updateSharedFeed()})},f.methods.sweepGameLog=function(){for(var{data:e}=this.gameLogTable,t=new Date(Date.now()-2592e5).toJSON(),r=0,i=e.length;r<i&&e[r].created_at<t;)++r;r===i?this.gameLogTable.data=[]:r&&e.splice(0,r)},f.methods.updateDiscord=function(){if(!1!==this.isGameRunning&&""!==this.lastLocation){if(this.lastLocation!==this.lastLocation$.tag){var e=n.parseLocation(this.lastLocation);if(e.worldName=e.worldId,this.lastLocation$=e,e.worldId){var t=n.cachedWorlds.get(e.worldId);t?e.worldName=t.name:n.getWorld({worldId:e.worldId}).then(t=>(e.worldName=t.ref.name,t))}}var r=this.lastLocation$;r.worldName.length<2&&(r.worldName+="".repeat(2-r.worldName.length)),this.discordInstance?Discord.SetText(r.worldName,`#${r.instanceName} ${r.accessType}`):Discord.SetText(r.worldName,""),Discord.SetActive(this.discordActive)}else Discord.SetActive(!1)},f.methods.lookupUser=function(e){for(var t of n.cachedUsers.values())if(t.displayName===e)return void this.showUserDialog(t.id);this.searchText=e,this.search(),this.$refs.menu.activeIndex="search",this.$refs.searchTab.currentName="0"},f.data.searchText="",f.data.searchUserResults=[],f.data.searchUserParams={},f.data.searchWorldResults=[],f.data.searchWorldOption="",f.data.searchWorldParams={},f.data.searchAvatarResults=[],f.data.searchAvatarParams={},f.data.isSearchUserLoading=!1,f.data.isSearchWorldLoading=!1,f.data.isSearchAvatarLoading=!1,n.$on("LOGIN",(function(){f.searchText="",f.searchUserResults=[],f.searchUserParams={},f.searchWorldResults=[],f.searchWorldOption="",f.searchWorldParams={},f.searchAvatarResults=[],f.searchAvatarParams={},f.isSearchUserLoading=!1,f.isSearchWorldLoading=!1,f.isSearchAvatarLoading=!1})),f.methods.clearSearch=function(){this.searchUserResults=[],this.searchWorldResults=[],this.searchAvatarResults=[]},f.methods.search=function(){this.searchUser(),this.searchWorld({})},f.methods.searchUser=function(){this.searchUserParams={n:10,offset:0,search:this.searchText},this.moreSearchUser()},f.methods.moreSearchUser=function(e){var t=this.searchUserParams;e&&(t.offset+=t.n*e,t.offset<0&&(t.offset=0)),this.isSearchUserLoading=!0,n.getUsers(t).finally(()=>{this.isSearchUserLoading=!1}).then(e=>{var t=new Map;for(var r of e.json){var i=n.cachedUsers.get(r.id);void 0!==i&&t.set(i.id,i)}return this.searchUserResults=Array.from(t.values()),e})},f.methods.searchWorld=function(e){this.searchWorldOption="";var t={n:10,offset:0};switch(e.sortHeading){case"featured":t.sort="order",t.featured="true";break;case"trending":t.sort="popularity",t.featured="false";break;case"updated":t.sort="updated";break;case"created":t.sort="created";break;case"publication":t.sort="publicationDate";break;case"shuffle":t.sort="shuffle";break;case"active":this.searchWorldOption="active";break;case"recent":this.searchWorldOption="recent";break;case"favorite":this.searchWorldOption="favorites";break;case"labs":t.sort="labsPublicationDate";break;case"heat":t.sort="heat",t.featured="false";break;default:t.sort="popularity",t.search=this.searchText}t.order=e.sortOrder||"descending","mine"===e.sortOwnership&&(t.user="me",t.releaseStatus="all"),e.tag&&(t.tag=e.tag),this.searchWorldParams=t,this.moreSearchWorld()},f.methods.moreSearchWorld=function(e){var t=this.searchWorldParams;e&&(t.offset+=t.n*e,t.offset<0&&(t.offset=0)),this.isSearchWorldLoading=!0,n.getWorlds(t,this.searchWorldOption).finally(()=>{this.isSearchWorldLoading=!1}).then(e=>{var t=new Map;for(var r of e.json){var i=n.cachedWorlds.get(r.id);void 0!==i&&t.set(i.id,i)}return this.searchWorldResults=Array.from(t.values()),e})},f.methods.searchAvatar=function(e){var t={n:10,offset:0};switch(e){case"updated":t.sort="updated";break;case"created":t.sort="created";break;case"mine":t.user="me",t.releaseStatus="all";break;default:t.sort="popularity",t.search=this.searchText}t.order="descending",this.searchAvatarParams=t,this.moreSearchAvatar()},f.methods.moreSearchAvatar=function(e){var t=this.searchAvatarParams;e&&(t.offset+=t.n*e,t.offset<0&&(t.offset=0)),this.isSearchAvatarLoading=!0,n.getAvatars(t).finally(()=>{this.isSearchAvatarLoading=!1}).then(e=>{var t=new Map;for(var r of e.json){var i=n.cachedAvatars.get(r.id);void 0!==i&&t.set(i.id,i)}return this.searchAvatarResults=Array.from(t.values()),e})},f.data.favoriteObjects=new Map,f.data.favoriteFriends_=[],f.data.favoriteWorlds_=[],f.data.favoriteAvatars_=[],f.data.sortFavoriteFriends=!1,f.data.sortFavoriteWorlds=!1,f.data.sortFavoriteAvatars=!1,n.$on("LOGIN",(function(){f.favoriteObjects.clear(),f.favoriteFriends_=[],f.favoriteWorlds_=[],f.favoriteAvatars_=[],f.sortFavoriteFriends=!1,f.sortFavoriteWorlds=!1,f.sortFavoriteAvatars=!1})),n.$on("FAVORITE",(function(e){f.applyFavorite(e.ref.type,e.ref.favoriteId)})),n.$on("FAVORITE:@DELETE",(function(e){f.applyFavorite(e.ref.type,e.ref.favoriteId)})),n.$on("USER",(function(e){f.applyFavorite("friend",e.ref.id)})),n.$on("WORLD",(function(e){f.applyFavorite("world",e.ref.id)})),n.$on("AVATAR",(function(e){f.applyFavorite("avatar",e.ref.id)})),f.methods.applyFavorite=function(t,r){var i=n.cachedFavoritesByObjectId.get(r),a=this.favoriteObjects.get(r);if(void 0!==i){var s=!1;if(void 0===a){if(a={id:r,type:t,groupKey:i.$groupKey,ref:null,name:""},this.favoriteObjects.set(r,a),"friend"===t)void 0===(o=n.cachedUsers.get(r))?void 0!==(o=this.friendLog[r])&&o.displayName&&(a.name=o.displayName):(a.ref=o,a.name=o.displayName);else if("world"===t){void 0!==(o=n.cachedWorlds.get(r))&&(a.ref=o,a.name=o.name)}else if("avatar"===t){void 0!==(o=n.cachedAvatars.get(r))&&(a.ref=o,a.name=o.name)}s=!0}else{if(a.type!==t&&(s=!0,"friend"===t?e(this.favoriteFriends_,a):"world"===t?e(this.favoriteWorlds_,a):"avatar"===t&&e(this.favoriteAvatars_,a)),"friend"===t)void 0!==(o=n.cachedUsers.get(r))&&(a.ref!==o&&(a.ref=o),a.name!==o.displayName&&(a.name=o.displayName,this.sortFavoriteFriends=!0));else if("world"===t){void 0!==(o=n.cachedWorlds.get(r))&&(a.ref!==o&&(a.ref=o),a.name!==o.name&&(a.name=o.name,this.sortFavoriteWorlds=!0))}else if("avatar"===t){var o;void 0!==(o=n.cachedAvatars.get(r))&&(a.ref!==o&&(a.ref=o),a.name!==o.name&&(a.name=o.name,this.sortFavoriteAvatars=!0))}}s&&("friend"===t?(this.favoriteFriends_.push(a),this.sortFavoriteFriends=!0):"world"===t?(this.favoriteWorlds_.push(a),this.sortFavoriteWorlds=!0):"avatar"===t&&(this.favoriteAvatars_.push(a),this.sortFavoriteAvatars=!0))}else void 0!==a&&(this.favoriteObjects.delete(r),"friend"===t?e(this.favoriteFriends_,a):"world"===t?e(this.favoriteWorlds_,a):"avatar"===t&&e(this.favoriteAvatars_,a))},f.methods.deleteFavorite=function(e){this.$confirm("Continue? Delete Favorite","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.deleteFavorite({objectId:e})}})},f.methods.changeFavoriteGroupName=function(e){this.$prompt("Enter a new name","Change Group Name",{distinguishCancelAndClose:!0,cancelButtonText:"Cancel",confirmButtonText:"Change",inputPlaceholder:"Name",inputValue:e.displayName,inputPattern:/\S+/,inputErrorMessage:"Name is required",callback:(t,r)=>{"confirm"===t&&n.saveFavoriteGroup({type:e.type,group:e.name,displayName:r.inputValue}).then(e=>(this.$message("Group updated!"),e))}})},f.methods.clearFavoriteGroup=function(e){this.$confirm("Continue? Clear Group","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.clearFavoriteGroup({type:e.type,group:e.name})}})},f.computed.favoriteFriends=function(){return this.sortFavoriteFriends&&(this.sortFavoriteFriends=!1,this.favoriteFriends_.sort(v)),this.favoriteFriends_},f.computed.favoriteWorlds=function(){return this.sortFavoriteWorlds&&(this.sortFavoriteWorlds=!1,this.favoriteWorlds_.sort(v)),this.favoriteWorlds_},f.computed.favoriteAvatars=function(){return this.sortFavoriteAvatars&&(this.sortFavoriteAvatars=!1,this.favoriteAvatars_.sort(v)),this.favoriteAvatars_},f.data.friendLog={},f.data.friendLogTable={data:[],filters:[{prop:"type",value:[],filterFn:(e,t)=>t.value.some(t=>t===e.type)},{prop:"displayName",value:""}],tableProps:{stripe:!0,size:"mini",defaultSort:{prop:"created_at",order:"descending"}},pageSize:10,paginationProps:{small:!0,layout:"sizes,prev,pager,next,total",pageSizes:[10,25,50,100]}},n.$on("LOGIN",(function(e){f.initFriendship(e.ref)})),n.$on("USER:CURRENT",(function(e){f.updateFriendships(e.ref)})),n.$on("USER",(function(e){f.updateFriendship(e.ref)})),n.$on("FRIEND:ADD",(function(e){f.addFriendship(e.params.userId)})),n.$on("FRIEND:DELETE",(function(e){f.deleteFriendship(e.params.userId)})),n.$on("FRIEND:REQUEST",(function(e){var t=this.cachedUsers.get(e.params.userId);void 0!==t&&(f.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"FriendRequest",userId:t.id,displayName:t.displayName}),f.saveFriendLog())})),n.$on("FRIEND:REQUEST:CANCEL",(function(e){var t=this.cachedUsers.get(e.params.userId);void 0!==t&&(f.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"CancelFriendRequst",userId:t.id,displayName:t.displayName}),f.saveFriendLog())}));var y=null;f.methods.saveFriendLog=function(){null===y&&(y=setTimeout(()=>{y=null,VRCXStorage.SetObject(`${n.currentUser.id}_friendLog`,this.friendLog),VRCXStorage.SetArray(`${n.currentUser.id}_friendLogTable`,this.friendLogTable.data),VRCXStorage.Set(`${n.currentUser.id}_friendLogUpdatedAt`,(new Date).toJSON())},1))},f.methods.initFriendship=function(e){if(VRCXStorage.Get(`${e.id}_friendLogUpdatedAt`))this.friendLog=VRCXStorage.GetObject(`${e.id}_friendLog`),this.friendLogTable.data=VRCXStorage.GetArray(`${e.id}_friendLogTable`);else{var t={};for(var r of e.friends){var i={id:r},a=n.cachedUsers.get(r);void 0!==a&&(i.displayName=a.displayName,i.trustLevel=a.$trustLevel),t[r]=i}this.friendLog=t,this.friendLogTable.data=[],this.saveFriendLog()}},f.methods.addFriendship=function(e){if(void 0===this.friendLog[e]){var t={id:e,displayName:null,trustLevel:null};Vue.set(this.friendLog,e,t);var r=n.cachedUsers.get(e);void 0!==r&&(t.displayName=r.displayName,t.trustLevel=r.$trustLevel,this.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"Friend",userId:r.id,displayName:t.displayName})),this.saveFriendLog(),this.notifyMenu("friendLog")}},f.methods.deleteFriendship=function(e){var t=this.friendLog[e];void 0!==t&&(Vue.delete(this.friendLog,e),this.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"Unfriend",userId:e,displayName:t.displayName}),this.saveFriendLog(),this.notifyMenu("friendLog"))},f.methods.updateFriendships=function(e){var t=new Set;for(var r of e.friends)t.add(r),this.addFriendship(r);for(var r in this.friendLog)!1===t.has(r)&&this.deleteFriendship(r)},f.methods.updateFriendship=function(e){var t=this.friendLog[e.id];void 0!==t&&(t.displayName!==e.displayName&&(t.displayName?this.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"DisplayName",userId:e.id,displayName:e.displayName,previousDisplayName:t.displayName}):null===t.displayName&&this.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"Friend",userId:e.id,displayName:e.displayName}),t.displayName=e.displayName,this.saveFriendLog(),this.notifyMenu("friendLog")),e.$trustLevel&&t.trustLevel!==e.$trustLevel&&(t.trustLevel&&this.friendLogTable.data.push({created_at:(new Date).toJSON(),type:"TrustLevel",userId:e.id,displayName:e.displayName,trustLevel:e.$trustLevel,previousTrustLevel:t.trustLevel}),t.trustLevel=e.$trustLevel,this.saveFriendLog(),this.notifyMenu("friendLog")))},f.methods.deleteFriendLog=function(t){this.$confirm("Continue? Delete Log","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:r=>{"confirm"===r&&e(this.friendLogTable.data,t)&&this.saveFriendLog()}})},f.data.playerModerationTable={data:[],filters:[{prop:"type",value:[],filterFn:(e,t)=>t.value.some(t=>t===e.type)},{prop:["sourceDisplayName","targetDisplayName"],value:""}],tableProps:{stripe:!0,size:"mini",defaultSort:{prop:"created",order:"descending"}},pageSize:10,paginationProps:{small:!0,layout:"sizes,prev,pager,next,total",pageSizes:[10,25,50,100]}},n.$on("LOGIN",(function(){f.playerModerationTable.data=[]})),n.$on("PLAYER-MODERATION",(function(e){for(var{ref:t}=e,r=f.playerModerationTable.data,{length:i}=r,a=0;a<i;++a)if(r[a].id===t.id)return void(t.$isDeleted?r.splice(a,1):Vue.set(r,a,t));!1===t.$isDeleted&&(f.playerModerationTable.data.push(t),f.notifyMenu("moderation"))})),n.$on("PLAYER-MODERATION:@DELETE",(function(e){for(var{ref:t}=e,r=f.playerModerationTable.data,{length:i}=r,a=0;a<i;++a)if(r[a].id===t.id)return void r.splice(a,1)})),f.methods.deletePlayerModeration=function(e){this.$confirm("Continue? Delete Moderation","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.deletePlayerModeration({moderated:e.targetUserId,type:e.type})}})},f.data.notificationTable={data:[],filters:[{prop:"type",value:[],filterFn:(e,t)=>t.value.some(t=>t===e.type)},{prop:"senderUsername",value:""}],tableProps:{stripe:!0,size:"mini",defaultSort:{prop:"created_at",order:"descending"}},pageSize:10,paginationProps:{small:!0,layout:"sizes,prev,pager,next,total",pageSizes:[10,25,50,100]}},n.$on("LOGIN",(function(){f.notificationTable.data=[]})),n.$on("NOTIFICATION",(function(e){for(var{ref:t}=e,r=f.notificationTable.data,{length:i}=r,a=0;a<i;++a)if(r[a].id===t.id)return void(t.$isDeleted?r.splice(a,1):Vue.set(r,a,t));!1===t.$isDeleted&&(f.notificationTable.data.push(t),f.notifyMenu("notification"))})),n.$on("NOTIFICATION:@DELETE",(function(e){for(var{ref:t}=e,r=f.notificationTable.data,{length:i}=r,a=0;a<i;++a)if(r[a].id===t.id)return void r.splice(a,1)})),f.methods.acceptNotification=function(e){this.$confirm("Continue? Accept Friend Request","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.acceptNotification({notificationId:e.id})}})},f.methods.hideNotification=function(e){this.$confirm("Continue? Delete Notification","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.hideNotification({notificationId:e.id})}})},f.data.userLanguageVisible=0,f.data.userLanguageSelected="",f.data.userLanguages=function(){var e=[];for(var t in s){var r=s[t];e.push({key:t,value:r})}return e}(),f.data.currentUserTreeData=[],f.data.pastDisplayNameTable={data:[],tableProps:{stripe:!0,size:"mini",defaultSort:{prop:"updated_at",order:"descending"}},pageSize:10,paginationProps:{small:!0,layout:"sizes,prev,pager,next,total",pageSizes:[10,25,50,100]}},f.data.visits=0,f.data.openVR=VRCXStorage.GetBool("openVR"),f.data.openVRAlways=VRCXStorage.GetBool("openVRAlways");var T=function(){VRCXStorage.SetBool("openVR",this.openVR),VRCXStorage.SetBool("openVRAlways",this.openVRAlways)};f.watch.openVR=T,f.watch.openVRAlways=T,f.data.isDarkMode=VRCXStorage.GetBool("isDarkMode"),a.disabled=!1===f.data.isDarkMode,f.watch.isDarkMode=function(){VRCXStorage.SetBool("isDarkMode",this.isDarkMode),a.disabled=!1===this.isDarkMode},f.data.isStartAtWindowsStartup=VRCXStorage.GetBool("VRCX_StartAtWindowsStartup"),f.data.isStartAsMinimizedState=VRCXStorage.GetBool("VRCX_StartAsMinimizedState"),f.data.isCloseToTray=VRCXStorage.GetBool("VRCX_CloseToTray");var F=function(){VRCXStorage.SetBool("VRCX_StartAtWindowsStartup",this.isStartAtWindowsStartup),VRCXStorage.SetBool("VRCX_StartAsMinimizedState",this.isStartAsMinimizedState),VRCXStorage.SetBool("VRCX_CloseToTray",this.isCloseToTray),VRCX.SetStartup(this.isStartAtWindowsStartup)};f.watch.isStartAtWindowsStartup=F,f.watch.isStartAsMinimizedState=F,f.watch.isCloseToTray=F,n.$on("LOGIN",(function(){f.currentUserTreeData=[],f.pastDisplayNameTable.data=[]})),n.$on("USER:CURRENT",(function(e){e.ref.pastDisplayNames&&(f.pastDisplayNameTable.data=e.ref.pastDisplayNames)})),n.$on("VISITS",(function(e){f.visits=e.json})),f.methods.addUserLanguage=function(e){e===String(e)&&n.addUserTags({tags:[`language_${e}`]})},f.methods.removeUserLanguage=function(e){e===String(e)&&n.removeUserTags({tags:[`language_${e}`]})},f.methods.logout=function(){this.$confirm("Continue? Logout","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:e=>{"confirm"===e&&n.logout()}})},f.methods.resetHome=function(){this.$confirm("Continue? Reset Home","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:e=>{"confirm"===e&&n.saveCurrentUser({homeLocation:""}).then(e=>(this.$message({message:"Home world has been reset",type:"success"}),e))}})},f.methods.updateOpenVR=function(){this.openVR&&(this.isGameRunning||this.openVRAlways)?VRCX.StartVR():VRCX.StopVR()},f.methods.refreshCurrentUserTreeData=function(){this.currentUserTreeData=u(n.currentUser)},f.methods.promptUserDialog=function(){this.$prompt("Enter a User ID (UUID)","Direct Access",{distinguishCancelAndClose:!0,confirmButtonText:"OK",cancelButtonText:"Cancel",inputPattern:/\S+/,inputErrorMessage:"User ID is required",callback:(e,t)=>{"confirm"===e&&t.inputValue&&this.showUserDialog(t.inputValue)}})},f.methods.promptWorldDialog=function(){this.$prompt("Enter a World ID (UUID)","Direct Access",{distinguishCancelAndClose:!0,confirmButtonText:"OK",cancelButtonText:"Cancel",inputPattern:/\S+/,inputErrorMessage:"World ID is required",callback:(e,t)=>{"confirm"===e&&t.inputValue&&this.showWorldDialog(t.inputValue)}})},f.methods.promptAvatarDialog=function(){this.$prompt("Enter a Avatar ID (UUID)","Direct Access",{distinguishCancelAndClose:!0,confirmButtonText:"OK",cancelButtonText:"Cancel",inputPattern:/\S+/,inputErrorMessage:"Avatar ID is required",callback:(e,t)=>{"confirm"===e&&t.inputValue&&this.showAvatarDialog(t.inputValue)}})};var S=e=>{var t=0;document.querySelectorAll(".v-modal,.el-dialog__wrapper").forEach(r=>{var i=Number(r.style.zIndex)||0;i&&i>t&&r!==e&&(t=i)}),t&&(e.style.zIndex=t+1)};f.data.userDialog={visible:!1,loading:!1,id:"",ref:{},friend:{},isFriend:!1,incomingRequest:!1,outgoingRequest:!1,isBlock:!1,isMute:!1,isHideAvatar:!1,isFavorite:!1,$location:{},users:[],instance:{},worlds:[],avatars:[],isWorldsLoading:!1,isAvatarsLoading:!1,worldSorting:"update",avatarSorting:"update",treeData:[],memo:""},f.watch["userDialog.memo"]=function(){var e=this.userDialog;this.saveMemo(e.id,e.memo)},f.methods.getFaviconUrl=function(e){try{return`https://www.google.com/s2/favicons?domain=${new URL(e).origin}`}catch(e){return""}},n.$on("LOGOUT",(function(){f.userDialog.visible=!1})),n.$on("USER",(function(e){var{ref:t}=e,r=f.userDialog;!1!==r.visible&&r.id===t.id&&(r.ref=t,f.applyUserDialogLocation())})),n.$on("WORLD",(function(e){var t=f.userDialog;!1!==t.visible&&t.$location.worldId===e.ref.id&&f.applyUserDialogLocation()})),n.$on("FRIEND:STATUS",(function(e){var t=f.userDialog;if(!1!==t.visible&&t.id===e.params.userId){var{json:r}=e;t.isFriend=r.isFriend,t.incomingRequest=r.incomingRequest,t.outgoingRequest=r.outgoingRequest}})),n.$on("FRIEND:REQUEST",(function(e){var t=f.userDialog;!1!==t.visible&&t.id===e.params.userId&&(e.json.success?t.isFriend=!0:t.outgoingRequest=!0)})),n.$on("FRIEND:REQUEST:CANCEL",(function(e){var t=f.userDialog;!1!==t.visible&&t.id===e.params.userId&&(t.outgoingRequest=!1)})),n.$on("NOTIFICATION",(function(e){var{ref:t}=e,r=f.userDialog;!1===r.visible||t.$isDeleted||"friendRequest"!==t.type||t.senderUserId!==r.id||(r.incomingRequest=!0)})),n.$on("NOTIFICATION:ACCEPT",(function(e){var{ref:t}=e,r=f.userDialog;!1!==r.visible&&void 0!==t&&"friendRequest"===t.type&&t.senderUserId===r.id&&(r.isFriend=!0)})),n.$on("NOTIFICATION:@DELETE",(function(e){var{ref:t}=e,r=f.userDialog;!1!==r.visible&&"friendRequest"===t.type&&t.senderUserId===r.id&&(r.incomingRequest=!1)})),n.$on("FRIEND:DELETE",(function(e){var t=f.userDialog;!1!==t.visible&&t.id===e.params.userId&&(t.isFriend=!1)})),n.$on("PLAYER-MODERATION",(function(e){var{ref:t}=e,r=f.userDialog;!1===r.visible||t.$isDeleted||t.targetUserId!==r.id&&t.sourceUserId!==this.currentUser.id||("block"===t.type?r.isBlock=!0:"mute"===t.type?r.isMute=!0:"hideAvatar"===t.type&&(r.isHideAvatar=!0))})),n.$on("PLAYER-MODERATION:@DELETE",(function(e){var{ref:t}=e,r=f.userDialog;!1!==r.visible&&t.targetUserId===r.id&&t.sourceUserId===this.currentUser.id&&("block"===t.type?r.isBlock=!1:"mute"===t.type?r.isMute=!1:"hideAvatar"===t.type&&(r.isHideAvatar=!1))})),n.$on("FAVORITE",(function(e){var{ref:t}=e,r=f.userDialog;!1===r.visible||t.$isDeleted||t.favoriteId!==r.id||(r.isFavorite=!0)})),n.$on("FAVORITE:@DELETE",(function(e){var t=f.userDialog;!1!==t.visible&&t.id===e.ref.favoriteId&&(t.isFavorite=!1)})),f.methods.showUserDialog=function(e){this.$nextTick(()=>S(this.$refs.userDialog.$el));var t=this.userDialog;t.id=e,t.treeData=[],t.memo=this.loadMemo(e),t.visible=!0,t.loading=!0,n.getCachedUser({userId:e}).catch(e=>{throw t.loading=!1,t.visible=!1,e}).then(e=>{if(e.ref.id===t.id){for(var r of(t.loading=!1,t.ref=e.ref,t.friend=this.friends.get(t.id),t.isFriend=Boolean(t.friend),t.incomingRequest=!1,t.outgoingRequest=!1,t.isBlock=!1,t.isMute=!1,t.isHideAvatar=!1,n.cachedPlayerModerations.values()))!1===r.$isDeleted&&r.targetUserId===t.id&&r.sourceUserId===n.currentUser.id&&("block"===r.type?t.isBlock=!0:"mute"===r.type?t.isMute=!0:"hideAvatar"===r.type&&(t.isHideAvatar=!0));t.isFavorite=n.cachedFavoritesByObjectId.has(t.id),this.applyUserDialogLocation();var i=[];for(var r of n.cachedWorlds.values())r.authorId===t.id&&i.push(r);this.setUserDialogWorlds(i);var a=[];for(var r of n.cachedAvatars.values())r.authorId===t.id&&a.push(r);this.setUserDialogAvatars(a),t.avatars=a,t.isWorldsLoading=!1,t.isAvatarsLoading=!1,n.getFriendStatus({userId:t.id}),e.cache&&n.getUser(e.params)}return e})},f.methods.applyUserDialogLocation=function(){var e=this.userDialog,t=n.parseLocation(e.ref.location);(e.$location=t,t.userId)&&(void 0===(i=n.cachedUsers.get(t.userId))?n.getUser({userId:t.userId}).then(e=>(Vue.set(t,"user",e.ref),e)):t.user=i);var r=[];if(!1===t.isOffline)for(var{ref:i}of this.friends.values())void 0!==i&&i.location===t.tag&&r.push(i);if(this.isGameRunning&&this.lastLocation===t.tag&&r.push(n.currentUser),r.sort(g),e.users=r,e.instance={},t.worldId){var i,a=function(r){for(var[i,a]of r)if(i===t.instanceId){e.instance={id:i,occupants:a};break}};void 0===(i=n.cachedWorlds.get(t.worldId))?n.getWorld({worldId:t.worldId}).then(e=>(e.ref.id===t.worldId&&a(e.ref.instances),!0)):a(i.instances)}},f.methods.setUserDialogWorlds=function(e){var t=this.userDialog;"update"===t.worldSorting?e.sort(m):e.sort(v),t.worlds=e},f.methods.setUserDialogAvatars=function(e){var t=this.userDialog;"update"===t.avatarSorting?e.sort(m):e.sort(v),t.avatars=e},f.methods.refreshUserDialogWorlds=function(){var e=this.userDialog;if(!e.isWorldsLoading){e.isWorldsLoading=!0;var t={n:100,offset:0,sort:"updated",order:"descending",userId:e.id,releaseStatus:"public"};t.userId===n.currentUser.id&&(t.user="me",t.releaseStatus="all");var r=new Map;for(var i of n.cachedWorlds.values())i.authorId===e.id&&r.set(i.id,i);n.bulk({fn:"getWorlds",N:-1,params:t,handle:e=>{for(var t of e.json){var i=n.cachedWorlds.get(t.id);void 0!==i&&r.set(i.id,i)}},done:()=>{if(e.id===t.userId){var i=Array.from(r.values());this.setUserDialogWorlds(i)}e.isWorldsLoading=!1}})}},f.methods.refreshUserDialogAvatars=function(){var e=this.userDialog;if(!e.isAvatarsLoading){e.isAvatarsLoading=!0;var t={n:100,offset:0,sort:"updated",order:"descending",userId:e.id,releaseStatus:"public"};t.userId===n.currentUser.id&&(t.user="me",t.releaseStatus="all");var r=new Map;for(var i of n.cachedAvatars.values())i.authorId===e.id&&r.set(i.id,i);n.bulk({fn:"getAvatars",N:-1,params:t,handle:e=>{for(var t of e.json){var i=n.cachedAvatars.get(t.id);void 0!==i&&r.set(i.id,i)}},done:()=>{if(e.id===t.userId){var i=Array.from(r.values());this.setUserDialogAvatars(i)}e.isAvatarsLoading=!1}})}};f.methods.userDialogCommand=function(e){var t=this.userDialog;if(!1!==t.visible)if("Add Favorite"===e)this.showFavoriteDialog("friend",t.id);else if("Message"===e)this.$prompt("Enter a message","Send Message",{distinguishCancelAndClose:!0,confirmButtonText:"Send",cancelButtonText:"Cancel",inputPattern:/\S+/,inputErrorMessage:"Message is required",callback:(e,r)=>{"confirm"===e&&r.inputValue&&n.sendNotification({receiverUserId:t.id,type:"message",message:r.inputValue,seen:!1,details:"{}"}).then(e=>(this.$message("Message sent"),e))}});else if("Show Avatar Author"===e){var{currentAvatarImageUrl:r}=t.ref,i=c(r);i?n.call(`file/${i}`).then(({ownerId:e})=>{for(var i of n.cachedAvatars.values())if(i.imageUrl===r)return void this.showAvatarDialog(i.id);t.loading=!0;var a={n:100,offset:0,sort:"updated",order:"descending",userId:e,releaseStatus:"public"};a.userId===n.currentUser.id&&(a.user="me",a.releaseStatus="all"),n.bulk({fn:"getAvatars",N:-1,params:a,done:()=>{for(var i of(t.loading=!1,n.cachedAvatars.values()))if(i.imageUrl===r)return void this.showAvatarDialog(i.id);e!==t.id?this.showUserDialog(e):this.$message({message:"It's personal (own) avatar",type:"warning"})}})}):this.$message({message:"Sorry, the author is unknown",type:"error"})}else this.$confirm(`Continue? ${e}`,"Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:r=>{"confirm"===r&&((e,t)=>{switch(e){case"Delete Favorite":n.deleteFavorite({objectId:t});break;case"Accept Friend Request":""===(r=n.getFriendRequest(t))?n.sendFriendRequest({userId:t}):n.acceptNotification({notificationId:r});break;case"Decline Friend Request":var r;""===(r=n.getFriendRequest(t))?n.cancelFriendRequest({userId:t}):n.hideNotification({notificationId:r});break;case"Cancel Friend Request":n.cancelFriendRequest({userId:t});break;case"Send Friend Request":n.sendFriendRequest({userId:t});break;case"Unblock":n.deletePlayerModeration({moderated:t,type:"block"});break;case"Block":n.sendPlayerModeration({moderated:t,type:"block"});break;case"Unmute":n.deletePlayerModeration({moderated:t,type:"mute"});break;case"Mute":n.sendPlayerModeration({moderated:t,type:"mute"});break;case"Show Avatar":n.deletePlayerModeration({moderated:t,type:"hideAvatar"});break;case"Hide Avatar":n.sendPlayerModeration({moderated:t,type:"hideAvatar"});break;case"Unfriend":n.deleteFriend({userId:t})}})(e,t.id)}})},f.methods.refreshUserDialogTreeData=function(){var e=this.userDialog;e.treeData=u(e.ref)},f.methods.changeUserDialogWorldSorting=function(){var e=this.userDialog;this.setUserDialogWorlds(e.worlds)},f.methods.changeUserDialogAvatarSorting=function(){var e=this.userDialog;this.setUserDialogAvatars(e.avatars)},f.data.worldDialog={visible:!1,loading:!1,id:"",$location:{},ref:{},isFavorite:!1,rooms:[],treeData:[],fileCreatedAt:"",fileSize:""},n.$on("LOGOUT",(function(){f.worldDialog.visible=!1})),n.$on("WORLD",(function(e){var{ref:t}=e,r=f.worldDialog;if(!1!==r.visible&&r.id===t.id){if(r.ref=t,"Loading"===r.fileSize){var i=c(t.assetUrl);i&&this.call(`file/${i}`).then((function(e){var t=e.versions[e.versions.length-1];r.fileCreatedAt=t.created_at,r.fileSize=`${(t.file.sizeInBytes/1048576).toFixed(2)} MiB`}))}f.applyWorldDialogInstances()}})),n.$on("FAVORITE",(function(e){var{ref:t}=e,r=f.worldDialog;!1===r.visible||t.$isDeleted||t.favoriteId!==r.id||(r.isFavorite=!0)})),n.$on("FAVORITE:@DELETE",(function(e){var t=f.worldDialog;!1!==t.visible&&t.id===e.ref.favoriteId&&(t.isFavorite=!1)})),f.methods.showWorldDialog=function(e){this.$nextTick(()=>S(this.$refs.worldDialog.$el));var t=this.worldDialog,r=n.parseLocation(e);""!==r.worldId&&(t.id=r.worldId,t.$location=r,t.treeData=[],t.fileCreatedAt="",t.fileSize="Loading",t.visible=!0,t.loading=!0,n.getCachedWorld({worldId:r.worldId}).catch(e=>{throw t.loading=!1,t.visible=!1,e}).then(e=>(t.id===e.ref.id&&(t.loading=!1,t.ref=e.ref,t.isFavorite=n.cachedFavoritesByObjectId.has(t.id),t.rooms=[],this.applyWorldDialogInstances(),e.cache&&n.getWorld(e.params)),e)))},f.methods.applyWorldDialogInstances=function(){var e=this.worldDialog,t={};for(var[r,i]of e.ref.instances)t[r]={id:r,occupants:i,users:[]};var{instanceId:a}=e.$location;for(var{ref:s}of(a&&void 0===t[a]&&(t[a]={id:a,occupants:0,users:[]}),this.friends.values()))if(void 0!==s&&void 0!==s.$location&&s.$location.worldId===e.id){var{instanceId:a}=s.$location;void 0===(l=t[a])&&(l={id:a,occupants:0,users:[]},t[a]=l),l.users.push(s)}if(this.isGameRunning){var o=n.parseLocation(this.lastLocation);if(o.worldId===e.id)void 0===(l=t[o.instanceId])&&(t[(l={id:o.instanceId,occupants:1,users:[]}).id]=l),l.users.push(n.currentUser)}var d=[];for(var l of Object.values(t)){const t=n.parseLocation(`${e.id}:${l.id}`);var s;if(l.location=t.tag,l.$location=t,t.userId)void 0===(s=n.cachedUsers.get(t.userId))?n.getUser({userId:t.userId}).then(e=>(Vue.set(t,"user",e.ref),e)):t.user=s;l.users.sort(g),d.push(l)}d.sort((function(e,t){return t.users.length-e.users.length||t.occupants-e.occupants})),e.rooms=d},f.methods.worldDialogCommand=function(e){var t=this.worldDialog;!1!==t.visible&&("New Instance"===e?this.showNewInstanceDialog(t.$location.tag):"Add Favorite"===e?this.showFavoriteDialog("world",t.id):this.$confirm(`Continue? ${e}`,"Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:r=>{if("confirm"===r)switch(e){case"Delete Favorite":n.deleteFavorite({objectId:t.id});break;case"Make Home":n.saveCurrentUser({homeLocation:t.id}).then(e=>(this.$message({message:"Home world updated",type:"success"}),e));break;case"Reset Home":n.saveCurrentUser({homeLocation:""}).then(e=>(this.$message({message:"Home world has been reset",type:"success"}),e))}}}))},f.methods.refreshWorldDialogTreeData=function(){var e=this.worldDialog;e.treeData=u(e.ref)},f.computed.worldDialogPlatform=function(){var{ref:e}=this.worldDialog,t=[];if(e.unityPackages)for(var r of e.unityPackages){var i="PC";"standalonewindows"===r.platform?i="PC":"android"===r.platform?i="Quest":r.platform&&({platform:i}=r),t.push(`${i}/${r.unityVersion}`)}return t.join(", ")},f.data.avatarDialog={visible:!1,loading:!1,id:"",ref:{},isFavorite:!1,treeData:[],fileCreatedAt:"",fileSize:""},n.$on("LOGOUT",(function(){f.avatarDialog.visible=!1})),n.$on("AVATAR",(function(e){var t=f.avatarDialog;if(!1!==t.visible&&t.id===e.ref.id&&(t.ref=e.ref,"Loading"===t.fileSize)){var r=c(e.ref.assetUrl);r&&this.call(`file/${r}`).then(e=>{var r=e.versions[e.versions.length-1];t.fileCreatedAt=r.created_at,t.fileSize=`${(r.file.sizeInBytes/1048576).toFixed(2)} MiB`})}})),n.$on("FAVORITE",(function(e){var{ref:t}=e,r=f.avatarDialog;!1===r.visible||t.$isDeleted||t.favoriteId!==r.id||(r.isFavorite=!0)})),n.$on("FAVORITE:@DELETE",(function(e){var t=f.avatarDialog;!1!==t.visible&&t.id===e.ref.favoriteId&&(t.isFavorite=!1)})),f.methods.showAvatarDialog=function(e){this.$nextTick(()=>S(this.$refs.avatarDialog.$el));var t=this.avatarDialog;t.id=e,t.treeData=[],t.fileCreatedAt="",t.fileSize="Loading",t.visible=!0,t.loading=!0,n.getCachedAvatar({avatarId:e}).catch(e=>{throw t.loading=!1,t.visible=!1,e}).then(e=>(t.id===e.ref.id&&(t.loading=!1,t.ref=e.ref,t.isFavorite=n.cachedFavoritesByObjectId.has(t.ref.id),e.cache&&n.getAvatar(e.params)),e))},f.methods.avatarDialogCommand=function(e){var t=this.avatarDialog;!1!==t.visible&&("Add Favorite"===e?this.showFavoriteDialog("avatar",t.id):this.$confirm(`Continue? ${e}`,"Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:r=>{if("confirm"===r)switch(e){case"Delete Favorite":n.deleteFavorite({objectId:t.id});break;case"Select Avatar":n.selectAvatar({avatarId:t.id})}}}))},f.methods.refreshAvatarDialogTreeData=function(){var e=this.avatarDialog;e.treeData=u(e.ref)},f.computed.avatarDialogPlatform=function(){var{ref:e}=this.avatarDialog,t=[];if(e.unityPackages)for(var r of e.unityPackages){var i="PC";"standalonewindows"===r.platform?i="PC":"android"===r.platform?i="Quest":r.platform&&({platform:i}=r),t.push(`${i}/${r.unityVersion}`)}return t.join(", ")},f.data.favoriteDialog={visible:!1,loading:!1,type:"",objectId:"",groups:[]},n.$on("LOGOUT",(function(){f.favoriteDialog.visible=!1})),f.methods.addFavorite=function(e){var t=this.favoriteDialog;t.loading=!0,n.addFavorite({type:t.type,favoriteId:t.objectId,tags:e.name}).finally(()=>{t.loading=!1}).then(e=>(t.visible=!1,e))},f.methods.showFavoriteDialog=function(e,t){this.$nextTick(()=>S(this.$refs.favoriteDialog.$el));var r=this.favoriteDialog;r.type=e,r.objectId=t,"friend"===e?(r.groups=n.favoriteFriendGroups,r.visible=!0):"world"===e?(r.groups=n.favoriteWorldGroups,r.visible=!0):"avatar"===e&&(r.groups=n.favoriteAvatarGroups,r.visible=!0)},f.data.inviteDialog={visible:!1,loading:!1,worldId:"",worldName:"",userIds:[]},n.$on("LOGOUT",(function(){f.inviteDialog.visible=!1})),f.methods.sendInvite=function(){this.$confirm("Continue? Invite","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:e=>{var t=this.inviteDialog;if("confirm"===e&&!0!==t.loading){t.loading=!0;var r={receiverUserId:"",type:"invite",message:"This is a generated invite",seen:!1,details:{worldId:t.worldId,worldName:t.worldName}},i=()=>{t.userIds.length>0?(r.receiverUserId=t.userIds.shift(),n.sendNotification(r).finally(i)):(t.loading=!1,t.visible=!1,this.$message({message:"Invite sent",type:"success"}))};i()}}})},f.methods.showInviteDialog=function(e){this.$nextTick(()=>S(this.$refs.inviteDialog.$el));var t=n.parseLocation(e);t.isOffline||t.isPrivate||""===t.worldId||n.getCachedWorld({worldId:t.worldId}).then(e=>{var r=this.inviteDialog;r.userIds=[],r.worldId=t.tag,r.worldName=e.ref.name,r.visible=!0})},f.data.socialStatusDialog={visible:!1,loading:!1,status:"",statusDescription:""},n.$on("LOGOUT",(function(){f.socialStatusDialog.visible=!1})),f.methods.saveSocialStatus=function(){var e=this.socialStatusDialog;e.loading||(e.loading=!0,n.saveCurrentUser({status:e.status,statusDescription:e.statusDescription}).finally(()=>{e.loading=!1}).then(t=>(e.visible=!1,this.$message({message:"Status updated",type:"success"}),t)))},f.methods.showSocialStatusDialog=function(){this.$nextTick(()=>S(this.$refs.socialStatusDialog.$el));var e=this.socialStatusDialog;e.status=n.currentUser.status,e.statusDescription=n.currentUser.statusDescription,e.visible=!0},f.data.bioDialog={visible:!1,loading:!1,bio:"",bioLinks:[]},n.$on("LOGOUT",(function(){f.bioDialog.visible=!1})),f.methods.saveBio=function(){var e=this.bioDialog;e.loading||(e.loading=!0,n.saveCurrentUser({bio:e.bio,bioLinks:e.bioLinks}).finally(()=>{e.loading=!1}).then(t=>(e.visible=!1,this.$message({message:"Bio updated",type:"success"}),t)))},f.methods.showBioDialog=function(){this.$nextTick(()=>S(this.$refs.bioDialog.$el));var e=this.bioDialog;e.bio=n.currentUser.bio,e.bioLinks=n.currentUser.bioLinks.slice(),e.visible=!0},f.data.newInstanceDialog={visible:!1,loading:!1,worldId:"",instanceId:"",accessType:"",location:"",url:""},n.$on("LOGOUT",(function(){f.newInstanceDialog.visible=!1})),f.methods.buildInstance=function(){var e=this.newInstanceDialog,t=[];t.push((99999*Math.random()+1).toFixed(0)),"public"!==e.accessType&&("friends+"===e.accessType?t.push(`~hidden(${n.currentUser.id})`):"friends"===e.accessType?t.push(`~friends(${n.currentUser.id})`):t.push(`~private(${n.currentUser.id})`),t.push(`~nonce(${"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=16*Math.random()|0;return"x"!==e&&(t|=8),t.toString(16)})})`),"invite+"===e.accessType&&t.push("~canRequestInvite")),e.instanceId=t.join("")};var D=function(e,t){return t?`https://vrchat.net/launch?worldId=${encodeURIComponent(e)}&instanceId=${encodeURIComponent(t)}`:`https://vrchat.net/launch?worldId=${encodeURIComponent(e)}`},A=function(){var e=this.newInstanceDialog;e.instanceId?e.location=`${e.worldId}:${e.instanceId}`:e.location=e.worldId,e.url=D(e.worldId,e.instanceId)};f.watch["newInstanceDialog.worldId"]=A,f.watch["newInstanceDialog.instanceId"]=A,f.methods.showNewInstanceDialog=function(e){this.$nextTick(()=>S(this.$refs.newInstanceDialog.$el));var t=n.parseLocation(e);if(!t.isOffline&&!t.isPrivate&&""!==t.worldId){var r=this.newInstanceDialog;r.worldId=t.worldId,r.accessType="public",this.buildInstance(),r.visible=!0}},f.methods.makeHome=function(e){this.$confirm("Continue? Make Home","Confirm",{confirmButtonText:"Confirm",cancelButtonText:"Cancel",type:"info",callback:t=>{"confirm"===t&&n.saveCurrentUser({homeLocation:e}).then(e=>(this.$message({message:"Home world updated",type:"success"}),e))}})},f.data.launchDialog={visible:!1,loading:!1,desktop:VRCXStorage.GetBool("launchAsDesktop"),location:"",url:""},f.watch["launchDialog.desktop"]=function(){VRCXStorage.SetBool("launchAsDesktop",this.launchDialog.desktop)},n.$on("LOGOUT",(function(){f.launchDialog.visible=!1})),f.methods.showLaunchDialog=function(e){this.$nextTick(()=>S(this.$refs.launchDialog.$el));var t=n.parseLocation(e);if(!t.isOffline&&!t.isPrivate&&""!==t.worldId){var r=this.launchDialog;t.instanceId?r.location=`${t.worldId}:${t.instanceId}`:r.location=t.worldId,r.url=D(t.worldId,t.instanceId),r.visible=!0}},f.methods.launchGame=function(){var e=this.launchDialog;VRCX.StartGame(e.location,e.desktop),e.visible=!1},f=new Vue(f),window.$app=f}))},function(e,t,r){}]);