1import{d as w}from"./v7.12-CApw0dbM.js";import{aM as I,aU as a,aP as l,aX as i,aW as b,b1 as S,aV as c,bB as k,a_ as E,b0 as C,c4 as _,c5 as V,c6 as A,c7 as P,c8 as U,c9 as $,bs as m,ca as N,cb as B,cc as R,cd as F,ce as T,cf as L,bx as M,bi as W,bh as O,bz as p,b4 as g,b5 as y,aQ as f,aT as D}from"./v7.12-VpakeqIi.js";import{T as j}from"./v7.12-Bpmpg4Z1.js";import"./v7.12-BzjUzmp5.js";import"./v7.12-BtlHOY4Y.js";const q=I({__name:"TheSwitch",props:{enabled:{type:Boolean,required:!0}},setup(e){return(t,s)=>(l(),a("div",{class:b(["the-switch",{"the-switch--enabled":e.enabled}])},[...s[0]||(s[0]=[i("div",{class:"the-switch__handle"},null,-1)])],2))}}),G=""+new URL("google-C0p3N1mO.svg",import.meta.url).href,K=""+new URL("vkontakte-Dd53WDun.svg",import.meta.url).href,Q=""+new URL("yandex-D1wffQaQ.svg",import.meta.url).href,z=S({name:"AccountButton",props:{account:{type:Object,required:!0}},computed:{buttonIconSrc(){switch(this.account.name){case"google":return G;case"vkid":return K;case"yandex":return Q}},buttonClass(){return{[`account-button--${this.account.id}`]:!0,"account-button--connected":this.account.isConnected}}},methods:{onClickRemove(){this.$emit("remove",this.account)},onClickButton(){this.account.isConnected||this.$emit("add",this.account)}}},"$nIVV7cMNrd"),H={class:"account-button__content"},X=["src"],Y={class:"account-button__title"};function J(e,t,s,d,o,u){return l(),a("div",{class:b(["account-button",e.buttonClass]),onClick:t[1]||(t[1]=E(r=>e.onClickButton(),["stop"]))},[i("div",H,[e.account.isIcon?(l(),a("img",{key:0,class:"account-button__icon",src:e.buttonIconSrc},null,8,X)):c("",!0),i("div",Y,k(e.account.title),1)]),e.account.isConnected?(l(),a("div",{key:0,class:"account-button__remove",onClick:t[0]||(t[0]=E(r=>e.onClickRemove(),["stop"]))},[...t[2]||(t[2]=[i("div",{class:"account-button__remove-icon"},null,-1)])])):c("",!0)],2)}const Z=C(z,[["render",J],["__scopeId","data-v-9d141332"]]);function x(e){var s,d,o,u;if(((s=e==null?void 0:e.response)==null?void 0:s.status)===429)return"СлиÑком много попÑÑок. ÐопÑобÑйÑе позже.";let t=null;try{t=(u=(o=(d=e==null?void 0:e.response)==null?void 0:d._data)==null?void 0:o.msg)!=null&&u.email?e.response._data.msg.email.join():e.response._data.msg??e.response._data.message}catch(r){console.error(r)}return t==="The email has already been taken."?"Email Ñже занÑÑ":t}const ee={cancelled:"ÐÑивÑзка оÑменена",auth_failed:"Ðе ÑдалоÑÑ Ð¿ÑивÑзаÑÑ Ð°ÐºÐºÐ°ÑнÑ. ÐопÑобÑйÑе Ñнова."},te="Ðе ÑдалоÑÑ Ð¿ÑивÑзаÑÑ Ð°ÐºÐºÐ°ÑнÑ. ÐопÑобÑйÑе Ñнова.",ie=S({name:"ProfileSettings",components:{TheSwitch:q,AccountButton:Z,TextInputCustom:j},setup(){const{data:e}=M("social-settings",()=>$fetch("/bff/social-settings"));return{indexStore:O(),uiStore:W(),socialSettings:e}},data:()=>({pushNotificationsManager:null,isResendUsed:!1,isLinkResultConsumed:!1,fieldEmail
1:{id:"email",isLoader:!1,isVerify:!1,isVerifySend:!1,placeholder:"ÐведиÑе поÑÑÑ",value:"",valueEdit:"",valueTemp:"",isFocus:!1,propertyAPIName:"email",state:"pending",timeoutAfterSuccessValid:null,validFunc:_,error:{text:""}},notificationEmail:{propertyAPIName:"subscribe_email",label:"ÐоÑÑовÑе ÑведомлениÑ",value:0,isUsed:!1,error:{text:"ÐÑибка пÑи ÑоÑ
Ñанении. ÐопÑобÑйÑе позже"}},notificationWeb:{propertyAPIName:"subscribe_web_push",label:"ÐповеÑÐµÐ½Ð¸Ñ Ð² бÑаÑзеÑе",value:0,isUsed:!1,error:{text:"ÐÑибка пÑи ÑоÑ
Ñанении. ÐопÑобÑйÑе позже"}},notificationInstant:{propertyAPIName:"subscribe_web",label:"ÐгновеннÑе ÑведомлениÑ",value:0,isUsed:!1,error:{text:"ÐÑибка пÑи ÑоÑ
Ñанении. ÐопÑобÑйÑе позже"}},accounts:{google:{id:"google",name:"google",title:"Google",isConnected:!1,isRegistered:!0,isIcon:!0,isUsed:!1,propertyAPIName:"google",value:null},vkid:{id:"vkid",name:"vkid",title:"VK ID",isConnected:!1,isRegistered:!0,isIcon:!0,isUsed:!1,propertyAPIName:"vkid",value:null},yandex:{id:"yandex",name:"yandex",title:"ЯндекÑ",isConnected:!1,isRegistered:!0,isUsed:!1,isIcon:!0,propertyAPIName:"yandex",value:null}}}
1),computed:{isVerifyState(){const{fieldEmail:e}=this;return!!(e.isVerify||e.isVerifySend)},userState(){return this.indexStore.user},webPushNotifications(){return this.indexStore.isSubscribedToWebPushNotifications},notificationEmailValue(){return!!(this.notificationEmail.value&&this.fieldEmail.value)},notificationInstantValue(){return!!this.notificationInstant.value},notificationWebValue(){return!!this.notificationWeb.value&&L()},accountsConnected(){return Object.values(this.accounts).filter(e=>e.isConnected&&this.isProviderEnabled(e.id))},accountsNotConnected(){return Object.values(this.accounts).filter(e=>!e.isConnected&&e.isRegistered&&this.isProviderEnabled(e.id))},verifyClass(){return{"verify--send":this.fieldEmail.isVerifySend,"verify--complete":this.fieldEmail.isVerify}},pendingEmail(){var e;return((e=this.userState)==null?void 0:e.email_temp)||this.fieldEmail.valueTemp||""},verifyTooltipContent(){return this.fieldEmail.isVerifySend?this.pendingEmail?`ÐиÑÑмо Ñ Ð¿Ð¾Ð´ÑвеÑждением оÑпÑавлено на ${this.pendingEmail}. ÐожалÑйÑÑа, пÑовеÑÑÑе поÑÑÑ Ð² ÑеÑение ÑÑÑок.`:"Ðа ÑказаннÑй адÑÐµÑ Ð¾ÑпÑавлено пиÑÑмо Ñ Ð¿Ð¾Ð´ÑвеÑждением. ÐожалÑйÑÑа, пÑовеÑÑÑе поÑÑÑ Ð² ÑеÑение ÑÑÑок.":this.fieldEmail.isVerify?"ÐоÑÑовÑй ÑÑик ÑÑпеÑно пÑивÑзан":""},isSafari(){return w.isSafari}},watch:{userState(){this.init()},webPushNotifications(e){this.notificationWeb.value=e?1:0}},created(){this.init()},mounted(){this.pushNotificationsManager=T(this.$pushApi,()=>{this.notificationWeb.value=1},()=>{this.notificationWeb.value=0})},methods:{init(){const{userState:e}=this;e!==null&&(this.notificationWeb.value=this.webPushNotifications?1:0,this.fieldEmail.value=e.email??"",this.fieldEmail.valueEdit=e.email??"",this.fieldEmail.valueTemp=e.email_temp??"",this.fieldEmail.state="saved",this.fieldEmail.isVerify=!!(e.email&&this.fieldEmail.valueEdit===e.email),this.fieldEmail.isVerifySend=!!e.email_temp,this.initAccounts(),this.loadPreferences(),this.consumeLinkResult())},loadPreferences(){var e;(e=this.indexStore.fetchPreferences())==null||e.then(t=>{this.notificationEmail.value=t!=null&&t.subscribe_email?1:0,this.notificationInstant.value=t!=null&&t.subscribe_web?1:0})},async saveEmail(e){var t;if(e.state==="edit"){if(typeof e.validFunc=="function"&&!e.validFunc(e.valueEdit)){e.state="error";return}_(e.valueEdit)&&(e.state="pending",(t=this.indexStore.requestEmailChange(e.valueEdit))==null||t.then(()=>{m({content:"Ðа ÑказаннÑй адÑÐµÑ Ð¾ÑпÑавлено пиÑÑмо Ñ Ð¿Ð¾Ð´ÑвеÑждением. ÐожалÑйÑÑа, пÑовеÑÑÑе поÑÑÑ Ð² ÑеÑение ÑÑÑок."}),e.isVerifySend=!0,e.valueTemp=e.valueEdit,e.state="saved"}).catch(s=>{e.state="edit",this.handleError(s)}).finally(()=>{setTimeout(()=>{e.isLoader=!1},500)}))}},resendEmail(){var e;this.isResendUsed||(this.isResendUsed=!0,(e=this.indexStore.resendEmailConfirmation())==null||e.then(()=>{m({content:this.pendingEmail?`ÐиÑÑмо Ñ Ð¿Ð¾Ð´ÑвеÑждением повÑоÑно оÑпÑавлено на ${this.pendingEmail}.`:"ÐиÑÑмо Ñ Ð¿Ð¾Ð´ÑвеÑждением оÑпÑавлено повÑоÑно."})}).catch(this.handleError).finally(()=>{this.isResendUsed=!1}))},setField(e,t){var s;e.valueEdit=t,this.fieldEmail.isVerify=this.userState?this.fieldEmail.valueEdit===this.userState.email:!1,this.fieldEmail.isVerifySend=!!((s=this.userState)!=null&&s.email_temp&&this.fieldEmail.valueEdit===this.userState.email_temp),e.state=e.valueEdit===e.value||e.valueEdit===e.valueTemp?"saved":"edit"},isButtonField(e){return e.isFocus===!0&&e.state==="edit"},getFieldButtonClass(e){return{[`field__button--${e.state}`]:!0}},onFocusField(e){e.isFocus=!0},onBlurField(e){e.isFocus=!1},async logout(){R(),F(),this.indexStore.logout()},initAccounts(){const{userState:e,accounts:t}=this;Object.keys(t).forEach(s=>{var u;const d=s,o=((u=e==null?void 0:e.socials)==null?void 0:u[d])??null;t[d].isConnected=!!o,t[d].value=(o==null?void 0:o.id)!=null?String(o.id):null})},isProviderEnabled(e){var t;return!!((t=this.socialSettings)!=null&&t[`social_${e}_enabled`])},switchedValueWeb(e){var s;if(!this.pushNotificationsManager)return;const t=!e.value;e.value?this.pushNotificationsManager.unsubscribe():this.pushNotificationsManager.subscribe(),(s=this.indexStore.patchPreference({key:e.propertyAPIName,value:t}))==null||s.catch(this.handleError)},switchedValueMail(e){var s;if(e.isUsed||!this.fieldEmail.value)return;e.isUsed=!0;const t=!e.value;(s=this.indexStore.patchPreference({key:e.propertyAPIName,value:t}))==null||s.then(()=>{e.value=t?1:0}).catch(this.handleError).finally(()=>{e.isUsed=!1}
1)},switchedValue(e){var s;if(e.isUsed)return;e.isUsed=!0;const t=!e.value;(s=this.indexStore.patchPreference({key:e.propertyAPIName,value:t}))==null||s.then(()=>{e.value=t?1:0}).catch(this.handleError).finally(()=>{e.isUsed=!1})},handleError(e){m({content:x(e),isError:!0})},disableSocialAccount(e){var t;e.isUsed||(e.isUsed=!0,(t=this.indexStore.disableSocialAccount(e.name))==null||t.then(s=>{var o,u;const d=((o=s==null?void 0:s.data)==null?void 0:o.data)??(s==null?void 0:s.data);if(d)this.indexStore.updateUser(d);else{if((u=this.indexStore.user)!=null&&u.socials){const r={...this.indexStore.user.socials};delete r[e.name],this.indexStore.patchUser({socials:r})}e.isConnected=!1,e.value=null}}).catch(this.handleError).finally(()=>{e.isUsed=!1}))},addSocialAccount(e){e.isUsed||(e.isUsed=!0,B(e.name,window.location.href).then(t=>{window.location.href=t}).catch(t=>{console.error("[ProfileSettings] social link failed",t),this.handleError(t)}).finally(()=>{e.isUsed=!1}))},consumeLinkResult(){if(this.isLinkResultConsumed)return;const e=N();if(e!==null){if(this.isLinkResultConsumed=!0,"linkError"in e){m({content:ee[e.linkError]??te,isError:!0});return}this.confirmLink(e.linkToken)}},confirmLink(e){var d;const t=V(A());if(!t)return;const s=Object.keys(((d=this.userState)==null?void 0:d.socials)??{});P(t,e).then(()=>U(t)).then(o=>{var h;const u=$(o.social_users);this.indexStore.patchUser({socials:u}),this.initAccounts();const r=Object.keys(u).find(n=>!s.includes(n)),v=r?(h=this.accounts[r])==null?void 0:h.title:null;m({content:v?`ÐккаÑÐ½Ñ ${v} пÑивÑзан`:"ÐккаÑÐ½Ñ Ð¿ÑивÑзан"})}).catch(o=>{console.error("[ProfileSettings] social link failed",o),this.handleError(o)})},deleteAccount(){this.uiStore.showModalDeleteAccount()}}},"$04q3YW2c-9"),se={class:"profile-settings"},ne={class:"profile-settings__content profile-content"},oe={class:"profile-settings__settings"},ae={class:"setting setting--accounts"},le={class:"setting__accounts"},de={class:"accounts"},ue={class:"setting__accounts"},re={class:"accounts"},ce={class:"setting"},he={class:"field__state"},fe={key:0,class:"field__loader"},me={key:1,class:"field__verify"},ve={class:"field__verify-tooltip"},be={key:0,class:"setting__resend"},pe=["disabled"],ge={class:"setting setting--with-switch"},Ee={class:"setting__switch"},_e={key:0,class:"setting setting--with-switch"},ye={class:"setting__switch"},Se={class:"setting setting--with-switch"},ke={class:"setting__switch"},Ce={class:"setting"},we={class:"setting setting--delete"};function Ie(e,t,s,d,o,u){const r=p("AccountButton"),v=p("TextInputCustom"),h=p("TheSwitch");return l(),a("div",se,[i("div",ne,[t[18]||(t[18]=i("div",{class:"profile-settings__title"},"ÐаÑÑÑойки",-1)),i("div",oe,[i("div",ae,[t[12]||(t[12]=i("div",{class:"setting__title"},"ÐодклÑÑÑннÑе аккаÑнÑÑ",-1)),i("div",le,[i("div",de,[(l(!0),a(g,null,y(e.accountsConnected,n=>(l(),a("div",{class:"accounts__item",key:n.id},[f(r,{account:n,onRemove:e.disableSocialAccount},null,8,["account","onRemove"])]))),128))])]),e.accountsNotConnected.length?(l(),a(g,{key:0},[t[11]||(t[11]=i("div",{class:"setting__subtitle"},"ÐÑполÑзÑйÑе аккаÑнÑÑ Ð´ÑÑгиÑ
ÑеÑвиÑов Ð´Ð»Ñ Ð²Ñ
ода на ÐайÑÑ
акеÑ",-1)),i("div",ue,[i("div",re,[(l(!0),a(g,null,y(e.accountsNotConnected,n=>(l(),a("div",{class:"accounts__item",key:n.id},[f(r,{account:n,onAdd:e.addSocialAccount},null,8,["account","onAdd"])]))),128))])])],64)):c("",!0)]),i("div",ce,[t[14]||(t[14]=i("div",{class:"setting__title"},"ÐдÑÐµÑ ÑлекÑÑонной поÑÑÑ",-1)),f(v,{id:e.fieldEmail.id,placeholder:e.fieldEmail.placeholder,modelValue:e.fieldEmail.valueEdit,"onUpdate:modelValue":[t[1]||(t[1]=n=>e.fieldEmail.valueEdit=n),t[2]||(t[2]=n=>e.setField(e.fieldEmail,n))],value:e.fieldEmail.value,state:e.fieldEmail.state,onOnFocus:t[3]||(t[3]=n=>e.onFocusField(e.fieldEmail)),onOnBlur:t[4]||(t[4]=n=>e.onBlurField(e.fieldEmail))},{default:D(()=>[i("div",he,[e.fieldEmail.state==="pending"?(l(),a("div",fe,[...t[13]||(t[13]=[i("div",{class:"loader"},null,-1)])])):c("",!0),e.isVerifyState?(l(),a("div",me,[i("div",{class:b(["verify",e.verifyClass])},null,2),i("div",ve,k(e.verifyTooltipContent),1)])):c("",!0),e.isButtonField(e.fieldEmail)?(l(),a("div",{key:2,class:b(["field__button",e.getFieldButtonClass(e.fieldEmail)]),onClick:t[0]||(t[0]=n=>e.saveEmail(e.fieldEmail))},null,2)):c("",!0)])]),_:1},8,["id","placeholder","modelValue","value","state"]),e.fieldEmail.isVerifySen
1d?(l(),a("div",be,[i("button",{class:"setting__button setting__button--resend",disabled:e.isResendUsed,onClick:t[5]||(t[5]=(...n)=>e.resendEmail&&e.resendEmail(...n))},"ÐÑпÑавиÑÑ Ð¿Ð¸ÑÑмо еÑÑ Ñаз",8,pe)])):c("",!0)]),i("div",ge,[t[15]||(t[15]=i("div",{class:"setting__title"},"ÐоÑÑовÑе ÑведомлениÑ",-1)),i("div",Ee,[f(h,{enabled:e.notificationEmailValue,onClick:t[6]||(t[6]=n=>e.switchedValueMail(e.notificationEmail))},null,8,["enabled"])])]),e.isSafari?c("",!0):(l(),a("div",_e,[t[16]||(t[16]=i("div",{class:"setting__title"},"Ð£Ð²ÐµÐ´Ð¾Ð¼Ð»ÐµÐ½Ð¸Ñ Ð² бÑаÑзеÑе",-1)),i("div",ye,[f(h,{enabled:e.notificationWebValue,onClick:t[7]||(t[7]=n=>e.switchedValueWeb(e.notificationWeb))},null,8,["enabled"])])])),i("div",Se,[t[17]||(t[17]=i("div",{class:"setting__title"},"ÐгновеннÑе ÑведомлениÑ",-1)),i("div",ke,[f(h,{enabled:e.notificationInstantValue,onClick:t[8]||(t[8]=n=>e.switchedValue(e.notificationInstant))},null,8,["enabled"])])]),i("div",Ce,[i("button",{class:"setting__button setting__button--logout",onClick:t[9]||(t[9]=(...n)=>e.logout&&e.logout(...n))},"ÐÑйÑи")])])]),i("div",we,[i("button",{class:"setting__button setting__button--secondary setting__button--remove",onClick:t[10]||(t[10]=(...n)=>e.deleteAccount&&e.deleteAccount(...n))},"УдалиÑÑ Ð°ÐºÐºÐ°ÑнÑ")])])}const Ne=C(ie,[["render",Ie],["__scopeId","data-v-d9bcb888"]]);export{Ne as default}; 2//# sourceMappingURL=v7.12-D8E53NAd.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.