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