import{b as p}from"./pageBase-BMRrrbJy.js";import{H as v}from"./HeaderPrimary-4m6cqeCO.js";import b from"./LoadingState-DcJhqFpf.js";import{A as _}from"./AppFooter-DqN81Zi1.js";import{_ as P,c as A,P as S,a0 as $,aZ as k,U as f,f as r,l as d,M as I,C as x,i as l,h as C,w as c,r as n,o as s,T as F,n as O}from"./index-B-ozwYGV.js";import"./Dropdown-Bq32NRED.js";const U={name:"Profile",components:{HeaderPrimary:v,LoadingState:b,AppFooter:_,pageBase:p},extends:p,setup(){return{userStore:A()}},data(){return{loadingData:!0,dataLoading:!0,loadedSlug:null,isClaiming:!1,profile:{followers:[]},oppSortKey:"default"}},computed:{loggedInAccount(){return this.userStore.loggedInAccount},period:function(){return this.$route.params.calendarSubsection!==null&&this.$route.params.calendarSubsection==="past-events"?"past":"upcoming"}},watch:{$route:{handler:function(e,t){e.name.startsWith("PublicProfile")&&(typeof e.params.slug<"u"&&(typeof t>"u"||typeof t.params.slug<"u"&&e.params.slug!==t.params.slug)&&(this.loadingData=!0,this.$scrollTo("#appUI"),this.loadProfile(this.$route.params.slug)),this.period!==null&&typeof this.profile<"u"&&typeof this.profile[`${this.period}Events`]<"u"&&this.profile[`${this.period}Events`].length===0&&(this.dataLoading=!0,this.profile.loadPagedEvents(this.period).then(()=>{this.dataLoading=!1})))}}},beforeMount(){this.$route.path.endsWith("/claim")&&(this.isClaiming=!0)},beforeUpdate(){this.loadProfile(this.$route.params.slug)},methods:{accountLoggedIn:function(){this.loadProfile(this.$route.params.slug)},profileUpdated:function(e){this.profile=e},filterMembers:function(e){for(let t=e.length-1;t>=0;--t)(e[t].visibility===0||e[t].visibility===2&&typeof this.loggedInAccount>"u")&&e.splice(t,1);return e},filterEnsembles:function(e){for(let t=e.length-1;t>=0;--t)(e[t].visibility===0||e[t].visibility===2&&typeof this.loggedInAccount>"u")&&e.splice(t,1)},loadProfile:async function(e){let t=null;e!==this.loadedSlug&&(this.loadedSlug=e,S.load(e,{public:!0,load:"[managers.[account],members.[person.[expertises,country,managers]],projectsAsParticipant.[participants.[person]],profileContacts.[expertises,country],validMemberOf.[profile.[expertises,country]],collections.[admins.[person]],collectionsAsCollaborator.[admins.[person]],calls.[admins.[person]],callsAsCollaborator.[admins.[person]],groups.[admins.[person]],groupsAsCollaborator.[admins.[person]]]"}).then(async i=>{if(this.$headTags.set(i.metaTags),await $.list(i,!0),await k.list(i,!0),await f.listForProfile(i),this.loggedInAccount!=null&&(this.loggedInAccount.hasManagedProfile(i.id)||this.loggedInAccount.isAdmin))t="admin";else switch(i.visibility){case 0:this.$router.replace("/404");break;case 1:t=i.isShadow?"is-shadow":"visible";break;case 2:this.loggedInAccount!=null?t="visible":this.$router.replace("/404");break}if(t!==null)switch((typeof i.followers>"u"||i.followers===null)&&(i.followers=[]),await i.loadPagedEvents(this.period),typeof i.memberOf<"u"&&i.memberOf.length>0&&this.filterEnsembles(i.memberOf),this.profile=i,this.loadingData=!1,this.dataLoading=!1,t){case"admin":this.profile.visibility===0?this.$notify({type:"warn",title:this.$t("messages.profile-hidden.title",{$capitalize:!0}),text:this.$t("messages.profile-hidden.message",{$capitalize:!0}),duration:1e4}):this.profile.visibility===2&&this.$notify({type:"warn",title:this.$t("messages.profile-visible-users.title",{$capitalize:!0}),text:this.$t("messages.profile-visible-users.message",{$capitalize:!0}),duration:1e4});break}}).catch(i=>{console.log(i),(i.status===404||typeof i.data.data<"u"&&Object.keys(i.data.data).length===0)&&this.$router.replace("/404")}))},followerAdded:function(e){this.profile.followers.push(e)},followerRemoved:function(e){this.profile.followers.splice(this.profile.followers.findIndex(t=>t===e),1)},reloadOpps:function(e){this.oppSortKey=e,f.listForProfile(this.profile,this.oppSortKey)}}},B={key:1},D={key:1},E={style:{"min-height":"400px"}};function L(e,t,i,K,o,a){const u=n("pageBase"),h=n("LoadingState"),g=n("HeaderPrimary"),m=n("router-view"),y=n("AppFooter");return s(),r("div",null,[e.loading?(s(),d(u,I(x({key:0},e.$props)),null,16)):(s(),r("div",B,[o.loadingData?(s(),d(h,{key:0,style:{"margin-top":"150px"}})):(s(),r("div",D,[l(g,{"is-claiming":o.isClaiming,profile:o.profile,"loading-data":o.loadingData,onFollowerRemoved:a.followerRemoved,onFollowerAdded:a.followerAdded},null,8,["is-claiming","profile","loading-data","onFollowerRemoved","onFollowerAdded"]),C("div",E,[l(m,{profile:o.profile,period:a.period,"data-loading":o.dataLoading,"opp-sort-key":o.oppSortKey,onProfileUpdated:a.profileUpdated,onOppSortKey:a.reloadOpps},{default:c(({Component:w})=>[l(F,{name:"contentFade",appear:"",mode:"out-in"},{default:c(()=>[(s(),d(O(w)))]),_:2},1024)]),_:1},8,["profile","period","data-loading","opp-sort-key","onProfileUpdated","onOppSortKey"])]),l(y)]))]))])}const V=P(U,[["render",L]]);export{V as default};