"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[254],{10777:(e,r,n)=>{n.r(r),n.d(r,{firstLoginDataUrl:()=>o,accumulateErrors:()=>s,fetchPost:()=>i,firstLoginData:()=>a,resendLink:()=>c,signinUrl:()=>d,signin:()=>h,signupUrl:()=>p,signup:()=>f,ApiError:()=>l,AggregateError:()=>w,recoverPasswordUrl:()=>m,recoverPassword:()=>j,resetPassword:()=>g});var t=n(85198);const o="/accounts/first_login_data/";function s(e,r){return Object.entries(e).map(e=>new l(e[1].join("\n"),r,e[0]))}function i(e,r){return(0,t.fetch)(e,{method:"POST",credentials:"include",mode:"same-origin",body:r})}function a(e){return i(o,e).then(e=>e.ok?e.json():e.json().then(r=>{throw new w(s(r.errors,e.status))}))}function c(){return i("/api/v1/users/anon/change-email/resend/").then(e=>e.ok?e.json():e.json().then(e=>{throw Error(e.error)}))}const d="/accounts/signin/";function u(e){return e.json().then(r=>{if("error"in r&&""!==r.error||"code"in r||!e.ok)throw new l(r.error||r.detail,e.status,r.code,r.two_factor_types);return r})}function h(e){return i(d,e).then(u)}const p="/accounts/signup/";function f(e){return i(p,e).then(e=>e.json().then(r=>{if("errors"in r&&""!==r.errors)throw new w(s(r.errors,e.status))}))}class l extends Error{constructor(e,r,n,t){super(e),this.type=n,this.status=r}}class w extends Error{constructor(e){super(e.map(e=>e.message).join("\n")),this.errors=[],this.errors=e}}const m="/api/v1/recover_password/search/";function j(e){return i(m,e).then(u)}function g(e){return i("/accounts/reset_password/",e).then(e=>400===e.status?e.json().then(r=>{if("errors"in r)throw new w(s(r.errors,e.status));throw new l(r.detail,e.status,r.code)}):u(e))}},60347:(e,r,n)=>{n.r(r),n.d(r,{Code:()=>t,checkUserAnonymizationAbility:()=>d,anonimyzeAccount:()=>u,cancelAccountDeletion:()=>h,contacts:()=>p,SendCodeStatus:()=>f,isCodeSendedResponse:()=>l,contactsSendCode:()=>w,contactsConfirmAccess:()=>m,changeEmail:()=>j,togglePrivacyChattingMode:()=>g,getProfile:()=>v,getMe:()=>E});var t,o=n(28353),s=n(85198),i=n(10777),a=n(88537);!function(e){e.PaidServicesExist="paid_services_exist",e.UnusablePassword="unusable_password",e.InvalidPassword="invalid_password",e.TooManyAttempts="too_many_attempts"}(t||(t={}));const c=o.t("Unknown error happened");function d(){return(0,s.fetch)("/api/v1/users/anonymize/",{credentials:"include",method:"GET",headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error(c);return e.json()})}function u(e){return(0,s.fetch)("/api/v1/users/anonymize/",{credentials:"include",method:"POST",headers:{accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({current_password:e})}).then(e=>{if(!e.ok)throw new Error(c);return e.json()})}function h(){return(0,s.fetch)("/api/v1/users/anonymize/",{credentials:"include",method:"DELETE",headers:{accept:"application/json"}}).then(e=>{if(!e.ok)throw new Error(c);return e.json()})}function p(){return(0,s.fetch)("/api/v1/user/profile/contacts/",{credentials:"include",method:"GET"}).then(e=>e.json())}var f;function l(e){ return e.status===f.Sended}!function(e){e[e.AlreadyConfirmed=0]="AlreadyConfirmed",e[e.Sended=1]="Sended"}(f||(f={}));function w(e){const r=new FormData;return r.append("option",e.option),(0,s.fetch)("/api/v1/user/profile/contacts/send_code/",{credentials:"include",method:"POST",body:r}).then(e=>e.ok?e.json().then(e=>({status:f.Sended,response:{sid:e.sid,exp:Date.now()+1e3*e.exp}})):e.json().then(e=>{if("confirmed"===e.code)return{status:f.AlreadyConfirmed};if(e.errors)throw Error(Object.values(e.errors).join());throw Error(e.error)}))}function m(e){const r=new FormData;return r.append("option",e.option),r.append("code",e.code),r.append("sid",e.sid),(0,s.fetch)("/api/v1/user/profile/contacts/confirm_access/",{credentials:"include",method:"POST",body:r}).then(e=>e.ok?e.json().then(e=>({exp:Date.now()+1e3*e.exp})):e.json().then(e=>{if(e.errors)throw Error(Object.values(e.errors).join());throw Error(e.error)}))}function j(e){return(0,s.fetch)("/api/v1/users/change-email/",{method:"POST",credentials:"include",headers:{accept:"application/json"},body:e}).then(e=>e.ok?e.json():e.json().then(r=>{if(400===e.status)throw new i.AggregateError((0,i.accumulateErrors)(r.errors,e.status));if(403===e.status)throw new i.ApiError(r.error,e.status,r.code);if(429===e.status)throw new i.ApiError(r.error,e.status,r.code);throw Error("Unhandled exception")}))}function g(e){const r=new FormData;return r.append("disallow_adding_to_private_chats",e.toString()),(0,s.fetch)("/api/v1/user/profile/settings/",{method:"POST",body:r}).then(e=>{if(!e.ok)throw new Error(c);return e.json()}).then(e=>(0,a.ensureDefined)(e.disallow_adding_to_private_chats))}async function v(e){const r=await(0,s.fetch)(`/api/v1/user/profile/${e}/?by=username`);return r.ok?r.json():r.json().then(e=>{throw new Error(e.detail)})}async function E(){const e=await(0,s.fetch)("/api/v1/user/profile/me/");if(!e.ok){const r=await e.json();throw 403===e.status?new i.ApiError(r.detail,e.status,r.code):Error(String(r))}return e.json()}}}]);