import{_ as j}from"./ButtonDefault-BIBStZbJ.js";import{_ as A}from"./BasicInput-KlObNzdO.js";import{s as P}from"./multiselect-DhoC9bwZ.js";import{ao as U,u as J,x as O,r as m,f as u,H as $,c as F,o as R,a as c,b,v as y,F as H}from"./index-CmCGXBst.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./component-0WedTVCo.js";const K={class:"tw-flex tw-flex-wrap tw-gap-2 tw-mt-4"},Y={__name:"ModalWindowCreateContact",emits:["modalClose","buttonClicked"],setup(W,{emit:S}){const _=U(),i=J();O("emitter");const M=S,d=m(""),s=m(""),V=m({}),B=m({Name:"",Sign:""}),o=u(()=>i.userInfo),p=u(()=>_.data.Notifies?.Methods),E=u(()=>Object.keys(o.value?.Contacts).map(e=>{if(!o.value?.Contacts?.[e]?.IsHidden)return o.value?.Contacts?.[e]}).filter(Boolean)),g=u(()=>Object.keys(p.value).filter(e=>p.value[e].IsActive==="1").map(e=>({name:p.value[e].Name,value:e}))),a=u(()=>_.data.Messages?.Prompts),w=e=>{switch(e){case"Email":const t=a.value.Email,l=/<B>Например:<\/B>\s*([^<]+)/,r=t.match(l);return r&&r[1]?`${r[1]}`:t;case"SMS":const n=a.value.SMS,N=/<B>Например:<\/B>\s*([^<]+)/,v=n.match(N);return v&&v[1]?`${v[1]}`:n;case"Jabber":const h=a.value.Jabber,T=/<B>Например:<\/B>\s*([^<]+)/,f=h.match(T);return f&&f[1]?`${f[1]}`:h;default:return"Ссылка или id"}},x=e=>{switch(e){case"Email":return a.value.Email;case"SMS":return a.value.SMS;case"Jabber":return a.value.Jabber;case"Telegram":return a.value.Telegram;case"Viber":return a.value.Viber;case"VKontakte":return a.value.VKontakte;default:return"Ссылка или id"}};function k(){M("modalClose")}function C(){let e={};E.value.forEach((t,l)=>{e[l]={...t,oldValue:t.Address}}),V.value=e,D()}function D(){B.value={Name:o.value?.Name,Email:o.value?.Email,Sign:o.value?.Sign}}C();function I(){const e={MethodID:s.value,Address:d.value,TimeBegin:"00",TimeEnd:"00",IsActive:"yes",ContactID:"0"};i.userEditContact(e).then(t=>{t.response==="SUCCESS"&&(i.fetchUserData().then(()=>{C()}),k())})}return $(()=>{i.OAuth()}),(e,t)=>{const l=A,r=j;return R(),F(H,null,[t[2]||(t[2]=c("div",{class:"list-item__title"},"Новый контакт",-1)),c("div",K,[c("div",null,[b(y(P),{modelValue:s.value,"onUpdate:modelValue":t[0]||(t[0]=n=>s.value=n),options:g.value,disabled:g.value.length<=1,label:"name",placeholder:"Тип адреса"},null,8,["modelValue","options","disabled"])]),c("div",null,[b(l,{name:"name",placeholder:w(s.value),vertical:"",modelValue:d.value,"onUpdate:modelValue":t[1]||(t[1]=n=>d.value=n),title:x(s.value)},null,8,["placeholder","modelValue","title"])]),c("div",null,[b(r,{class:"profile-info__add-button tw-h-10",label:"Добавить контакт",onClick:I})])])],64)}}};export{Y as default};
