import{g as t}from"./p-0e4ae084.js";import{N as i}from"./p-97c18602.js";import{T as e}from"./p-0db2169b.js";import{F as s,M as r}from"./p-61301881.js";import{V as o}from"./p-ad6da9fe.js";import{T as a}from"./p-4f99fb23.js";import{A as n}from"./p-27da9105.js";import{c as m,d as l}from"./p-c4bbdd1e.js";import{c as p,s as f,a as c}from"./p-9043df2a.js";import{c as u}from"./p-84720732.js";import{a as b}from"./p-65434c2b.js";import{N as d}from"./p-6cf8ecf7.js";import"./p-06588791.js";import"./p-944da115.js";import"./p-d343a062.js";import{g as h,m as j}from"./p-3a5f9c0f.js";const N={formView:{fetchError:"Fetching data failed.",retry:"Retry",submit:"Update Info"},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"},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"}};class v{constructor(t,i,e){this.user=t,this.userMetadata=i,this.userMentorship=e;const{headers:s}=h();this.api=m(j,s)}onSubmit(t){const{values:i}=t.detail,{firstName:e,lastName:s,bio:r,skills:o,title:a,subscriptionLimit:n}=i,m=function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(t);r<s.length;r++)i.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(e[s[r]]=t[s[r]])}return e}(i,["firstName","lastName","bio","skills","title","subscriptionLimit"]),l={firstName:e,lastName:s,bio:r,skills:o,title:a},p={subscriptionLimit:parseInt(n)},f=m;return new Promise(((t,i)=>{let e=[this.api.update("users",this.user._id,l)];this.userMetadata&&e.push(this.api.update("metadatas",this.userMetadata._id,{data:f})),this.userMentorship&&void 0!==n&&e.push(this.api.update("mentorships",this.userMentorship._id,p)),Promise.all(e).then((()=>t({events:[new d(b.congratulate("Info updated"))]}))).catch((()=>{i(["Unexpected error"])}))}))}}function k(t,i,e,s,r){const o={firstName:e.firstName,lastName:e.lastName,bio:e.bio,title:e.title,skills:e.skills},{role:a}=t;return("mentor"===a?i.metadatas.mentorsCanEditMetadata:i.metadatas.menteesCanEditMetadata)&&(("mentor"===a?i.metadatas.mentor:i.metadatas.mentee)||[]).map(p).forEach((t=>{o[t.id]=s.data[t.id]})),r&&(o.subscriptionLimit=r.subscriptionLimit),o}function y(t,i,e,r,o,m,l){var p;if(!e)return null;const f="tr"===i?w:N,{role:c}=t,b=L(f,c,e),d=(null===(p=null==r?void 0:r.dvnAppViewConfig)||void 0===p?void 0:p.ui.fields)||u(b),h="mentor"===c?e.metadatas.mentorsCanEditMetadata:e.metadatas.menteesCanEditMetadata;return s.decode({_id:"update-membership-info-page",base:"mentornity",title:"My info",table:a.decode({name:"mentees",fields:b}),type:n.FormView,handler:new v(o,h?m:void 0,l),ui:{fields:d,i18n:f.formView}})}function L(s,a,n){const m="mentor"===a?n.profileFieldVisibilities.mentor:n.profileFieldVisibilities.mentee,u=[new e("firstName",s.formFields.firstName).addInterceptor("onSubmit",new o(2,32)).addInterceptor("onSubmit",new r).require(),new e("lastName",s.formFields.lastName).addInterceptor("onSubmit",new o(2,32)).addInterceptor("onSubmit",new r).require(),...[new e("title",s.formFields.title).addInterceptor("onSubmit",new r),new e("bio",s.formFields.bio).setLines(3).setLinesMax(10),t({id:"skills",title:s.formFields.skills,type:"multiple-choice",inputType:"select",options:f.map((t=>({label:c[t],value:t})))})].filter((t=>m[t.id]))];let b=[];return("mentor"===a?n.metadatas.mentorsCanEditMetadata:n.metadatas.menteesCanEditMetadata)&&(b=(("mentor"===a?n.metadatas.mentor:n.metadatas.mentee)||[]).map(p)),"mentor"===a&&n.mentorMenteeSubscription===l.Restricted?[...u,new i("subscriptionLimit",s.formFields.pairLimit),...b]:[...u,...b]}export{y as a,k as b,L as g}