import{r as e,h as t,H as s}from"./p-1ea36ff3.js";import{D as i}from"./p-d50d0ec8.js";import{S as o}from"./p-16bf9265.js";import"./p-7e860896.js";import"./p-944da115.js";import"./p-d343a062.js";import{c as r,b as p}from"./p-d49099be.js";import{M as a}from"./p-214632d0.js";import{m}from"./p-d4bb09bf.js";import{g as n}from"./p-8dfe8365.js";import{g as d}from"./p-7a8af4a6.js";import{s as c}from"./p-3a8caaf9.js";import"./p-eebad85b.js";import"./p-28c66a78.js";import"./p-6eb29778.js";import"./p-681f800a.js";import"./p-3b35e507.js";import"./p-240d1ae7.js";import"./p-35267d98.js";import"./p-cd1b0e39.js";import"./p-234c1f97.js";import"./p-70e54631.js";import"./p-fac8edcc.js";import"./p-48f43f2a.js";import"./p-d27cb594.js";import"./p-56d4255d.js";import"./p-814c9d06.js";import"./p-73aa5f56.js";import"./p-7957afd8.js";import"./p-814af281.js";import"./p-e929429b.js";import"./p-5b0214f9.js";import"./p-32f47ea6.js";import"./p-c393f218.js";import"./p-165a9088.js";import"./p-bc737eae.js";import"./p-63545896.js";import"./p-7fd840fa.js";let j=class{constructor(t){e(this,t),this.isPending=!0}componentWillLoad(){this.loadData()}onAction(e){const t=e.detail;switch(t.name){case"go-to-mentees-page":window.dispatchEvent(new CustomEvent("dvn.mentornity-member-home-widgets-wrapper.open-mentees-page"));break;case"go-to-mentors-page":window.dispatchEvent(new CustomEvent("dvn.mentornity-member-home-widgets-wrapper.open-mentors-page"));break;case"go-to-pair-detail-page":window.dispatchEvent(new CustomEvent("dvn.mentornity-member-home-widgets-wrapper.open-user-pair-page",{detail:{userId:t.params.uid,subId:t.params.subId}}));break;case"go-to-mentor-selection":window.dispatchEvent(new CustomEvent("dvn.mentornity-member-home-widgets-wrapper.open-mentor-selection-page"))}}async loadData(){const{context:e,headers:t}=n(this.groupId),{organisationDomain:s,organisationId:j,role:f,userId:g}=e;this.apiSozluk=(new o).setLanguage(this.language).setContents(c);const b=r(m,t);this.meetingGoalConfig=await b.getOrganisationMeetingGoalConfig(s).catch((e=>this.error=e));const w="mentor"===f?"mentors":"mentees",u=await b.getMeetings(j,w,g,{status:"active"}).catch((e=>this.error=e));this.mentornityBridgeApi=new a(m,e,t),await r(m,t).getOrganisationConfig(e.organisationId).then((e=>{this.organisationConfig=p.decode(e),this.mentornityBridgeApi.organisationConfig=p.decode(e)}));const h=await b.getViewConfigs(e.organisationId).catch((e=>this.error=e));if(!h)return;const l=d(e,this.language,this.organisationConfig,h.results),v=i.decode({}),y="mentor"===e.role?"subscribed":"subscriber",C=await this.mentornityBridgeApi.getPairsOfUser(l.table.base,l.table.name,y,v._id).catch((e=>this.error=e)),k=[],P=[],E="mentor"===e.role?"subscriber":"subscribed";C.results.forEach((e=>{"active"===(null==e?void 0:e.status)?k.push({user:e[E][0],meetings:u.results.filter((t=>t.guests.some((t=>t._id===e[E][0]._id))))}):"requested"===(null==e?void 0:e.status)&&P.push({user:e[E][0],meetings:u.results.filter((t=>t.guests.some((t=>t._id===e[E][0]._id))))})})),this.activePairs=k,this.requestedPairs=P,this.organisationConfig=await b.getOrganisationConfig(j),this.isPending=!1}render(){const{activePairs:e,apiSozluk:i,isPending:o,menteeType:r,meetingGoalConfig:p,organisationConfig:a,requestedPairs:m,userType:n}=this,d=p&&p.meetingGoals.length>0;return d?t(s,null,t("mentornity-root-wrapper",{class:"d-block pt-4",theme:{cornerRadius:"5px"}},d&&t("mentornity-pair-meeting-summary-widget",{apiSozluk:i,isPending:o,activePairs:e,organisationConfig:a,meetingGoalConfig:p,requestedPairs:m,userType:n,menteeType:r}))):null}};export{j as mentornity_member_home_widgets_wrapper}