import{_ as D}from"./ButtonDefault-CzWpVlv6.js";import{_ as k}from"./BasicInput-BG-lQkv5.js";import{u as g,g as r,r as B,l as E,D as V,o as M,c as S,a as d,t as m,b as p,W as U}from"./index-Bb2UEb_P.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./component-C-Q4t0gB.js";import"./common-U_VzDrmL.js";const A={class:"modal__body"},R={class:"list-item__subtitle"},q={class:"modal__accept-form"},x={__name:"ModalWindowAcceptContact",props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(_,{emit:f}){const o=_,v=f,c=g(),s=r(()=>c.userInfo),C=r(()=>Object.keys(s.value?.Contacts)?.map(t=>{if(!s.value?.Contacts?.[t]?.IsHidden)return s.value?.Contacts?.[t]})),n=B(""),I=o.data.sendConfirmRequest,y=t=>C.value.find(e=>e.ID===t),a=r(()=>{const t=y(o.data.contactId);return t?{...o.data,methodId:t.MethodID,address:t.Address}:(console.error("Контакт не найден по ID",o.data.contactId),o.data)}),l=async()=>{const t={Method:a.value.methodId,Value:a.value.address,ContactID:o.data.contactId,Confirm:n.value};try{(await I(`${U}/API/Confirm`,t)).Status==="Ok"?(v("modalClose"),await c.fetchUserData()):console.error("Ошибка подтверждения кода")}catch(e){console.error("Ошибка запроса подтверждения кода",e)}},u=t=>{t.key==="Enter"&&l()};return E(()=>{document.addEventListener("keyup",u)}),V(()=>{document.removeEventListener("keyup",u)}),(t,e)=>{const b=k,h=D;return M(),S("div",A,[e[2]||(e[2]=d("div",{class:"list-item__title"},"Введите код подтверждения",-1)),d("div",R," Отправили "+m(a.value.methodId)+" на «"+m(a.value.address)+"» ",1),d("div",q,[p(b,{label:"Код подтверждения",name:"mailCode",placeholder:"Введите код",modelValue:n.value,"onUpdate:modelValue":e[0]||(e[0]=i=>n.value=i)},null,8,["modelValue"]),p(h,{class:"modal__button",label:"Подтвердить",onClick:e[1]||(e[1]=i=>l())})])])}}};export{x as default};
