import{g as i}from"./p-62d6b6a7.js";import{N as t}from"./p-9f31253b.js";import{T as e}from"./p-968ee2ec.js";import{M as s}from"./p-0b1ac773.js";import{V as r}from"./p-ad6da9fe.js";import{F as a}from"./p-38a21ba5.js";import{T as o}from"./p-0ff0ee91.js";import{A as n}from"./p-6af4d5e0.js";import{c as m,f as l}from"./p-a3d5ad34.js";import{b as f,s as p,d as c}from"./p-2c9430cc.js";import{c as d}from"./p-26046226.js";import{a as b}from"./p-65434c2b.js";import{N as u}from"./p-6cf8ecf7.js";import"./p-e78d5616.js";import"./p-3968aca6.js";import"./p-d343a062.js";import{g as h,a as j}from"./p-f88474bf.js";const N={formView:{fetchError:"Fetching data failed.",retry:"Retry",submit:"Update Info",myInfo:"My Info",infoUpdated:"Info Updated"},formFields:{bio:"Bio",firstName:"First name",lastName:"Last name",pairLimit:"Pair limit",skills:"Professional Expertise",title:"Title"}},w={formView:{fetchError:"Veri alırken hata oluştu.",retry:"Tekrar Dene",submit:"Bilgileri Güncelle",myInfo:"Bilgilerim",infoUpdated:"Bilgiler Güncellendi"},formFields:{bio:"Kısaca kendinizi tanıtın",firstName:"İsim",lastName:"Soyisim",pairLimit:"Eşleşme sınırı",skills:"Uzmanlık Alanlarınız",title:"Ünvan"}},y={formView:{fetchError:"Falha na busca de dados.",retry:"Repetir",submit:"Informação de atualização",myInfo:"Minha informação",infoUpdated:"Informações atualizadas"},formFields:{bio:"Biografia",firstName:"Primeiro nome",lastName:"Último nome",pairLimit:"Limite de pares",skills:"Experiência profissional",title:"Título"}};class v{constructor(i,t,e,s){this.user=i,this.language=s,this.userMetadata=t,this.userMentorship=e;const{headers:r}=h();this.api=m(j,r)}onSubmit(i){const{values:t}=i.detail,{firstName:e,lastName:s,bio:r,skills:a,title:o,subscriptionLimit:n}=t,m=function(i,t){var e={};for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&t.indexOf(s)<0&&(e[s]=i[s]);if(null!=i&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(i);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(i,s[r])&&(e[s[r]]=i[s[r]])}return e}(t,["firstName","lastName","bio","skills","title","subscriptionLimit"]),l={firstName:e,lastName:s,bio:r,skills:a,title:o},f={subscriptionLimit:parseInt(n)},p=m;return new Promise(((i,t)=>{let e=[this.api.update("users",this.user._id,l)];this.userMetadata&&e.push(this.api.update("metadatas",this.userMetadata._id,{data:Object.assign(Object.assign({},this.userMetadata.data),p)})),this.userMentorship&&void 0!==n&&e.push(this.api.update("mentorships",this.userMentorship._id,f));const s="tr"===this.language?w:"pt-br"===this.language?y:N;Promise.all(e).then((()=>i({events:[new u(b.congratulate(s.formView.infoUpdated))]}))).catch((()=>{t(["Unexpected error"])}))}))}}function k(i,t,e,s,r){const a={firstName:e.firstName,lastName:e.lastName,bio:e.bio,title:e.title,skills:e.skills},{role:o}=i;return("mentor"===o?t.metadatas.mentorsCanEditMetadata:t.metadatas.menteesCanEditMetadata)&&(("mentor"===o?t.metadatas.mentor:t.metadatas.mentee)||[]).map(f).forEach((i=>{a[i.id]=s.data[i.id]})),r&&(a.subscriptionLimit=r.subscriptionLimit),a}function g(i,t,e,s,r,m,l){var f;if(!e)return null;const p="tr"===t?w:"pt-br"===t?y:N,{role:c}=i,b=I(p,c,e),u=(null===(f=null==s?void 0:s.dvnAppViewConfig)||void 0===f?void 0:f.ui.fields)||d(b),h="mentor"===c?e.metadatas.mentorsCanEditMetadata:e.metadatas.menteesCanEditMetadata;return a.decode({_id:"update-membership-info-page",base:"mentornity",title:p.formView.myInfo,table:o.decode({name:"mentees",fields:b}),type:n.FormView,handler:new v(r,h?m:void 0,l,t),ui:{fields:u,i18n:p.formView}})}function I(a,o,n){const m="mentor"===o?n.profileFieldVisibilities.mentor:n.profileFieldVisibilities.mentee,d=[new e("firstName",a.formFields.firstName).addInterceptor("onSubmit",new r(2,32)).addInterceptor("onSubmit",new s).require(),new e("lastName",a.formFields.lastName).addInterceptor("onSubmit",new r(2,32)).addInterceptor("onSubmit",new s).require()];n.webAppConfiguration.membershipForm||d.push(...[new e("title",a.formFields.title).addInterceptor("onSubmit",new s),new e("bio",a.formFields.bio).setLines(3).setLinesMax(10),i({id:"skills",title:a.formFields.skills,type:"multiple-choice",inputType:"select",options:p.map((i=>({label:c[i],value:i})))})].filter((i=>m[i.id])));let b=[];return("mentor"===o?n.metadatas.mentorsCanEditMetadata:n.metadatas.menteesCanEditMetadata)&&(b=(("mentor"===o?n.metadatas.mentor:n.metadatas.mentee)||[]).map(f)),"mentor"===o&&n.mentorMenteeSubscription===l.Restricted?[...d,new t("subscriptionLimit",a.formFields.pairLimit),...b]:[...d,...b]}export{g as a,k as b,I as g}