import{_ as C}from"./ButtonDefault-BIBStZbJ.js";import{G as y,r as v,x as k,f as S,H as _,s as w,c as x,o as P,a as o,b as h,e as E,t as n,w as f,v as N}from"./index-CmCGXBst.js";import{s as O}from"./multiselect-DhoC9bwZ.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";const j={class:"modal__body"},B={class:"list-item__subtitle"},G={class:"modal__input-row tw-items-center"},L={class:"list-form_col list-form_col--xl"},U={class:"search-field form-field"},W={class:"multiselect-multiple-label"},H={class:"multiselect-option"},K={__name:"ModalWindowVPSOrderSchemeChange",props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(V,{emit:I}){const l=V,D=I,a=y(),c=v(!1),r=v(null),b=k("emitter"),i=S(()=>Object.keys(a?.vpsSchemes).map(t=>({...a?.vpsSchemes[t],value:a?.vpsSchemes[t]?.ID,name:a?.vpsSchemes[t]?.Name,cost:a?.vpsSchemes[t]?.CostMonth})).filter(t=>t?.ID==l.data?.VpsSchemeID)),d=S(()=>{const t=i.value[0],s=Object.keys(a?.vpsSchemes).map(e=>({...a?.vpsSchemes[e],value:a?.vpsSchemes[e]?.ID}))?.filter(e=>e?.IsSchemeChangeable&&e?.ID!==l.data?.VpsSchemeID&&e?.ServersGroupID==l.data?.ServerGroup);return[t,...s].sort((e,g)=>e.SortID-g.SortID).map(e=>({...e,disabled:e.ID==t.ID}))});function u(){c.value=!0,a.VPSOrderSchemeChange({NewSchemeID:r.value,VPSOrderID:l.data?.VpsID}).then(t=>{let{result:s,error:m}=t;s==="SUCCESS"&&(l.data?.emitEvent&&b.emit(l.data?.emitEvent),D("modalClose")),c.value=!1})}_(()=>{r.value=d.value?.[1]?.value});const p=t=>{t.key==="Enter"&&u()};return _(()=>{document.addEventListener("keyup",p)}),w(()=>{document.removeEventListener("keyup",p)}),(t,s)=>{const m=C;return P(),x("div",j,[s[4]||(s[4]=o("div",{class:"list-item__title"},"Смена тарифного плана",-1)),o("div",B,[s[2]||(s[2]=E(" Текущий тарифный план ",-1)),o("span",null,n(i.value[0]?.name)+"/"+n(i.value[0]?.cost),1)]),o("div",G,[s[3]||(s[3]=o("div",{class:"modal__input-label"},"Новый тарифный план",-1)),o("div",L,[o("div",U,[h(N(O),{class:"multiselect--white",options:d.value,type:"text",modelValue:r.value,"onUpdate:modelValue":s[0]||(s[0]=e=>r.value=e),placeholder:"Поиск"},{singlelabel:f(({value:e})=>[o("div",W,[o("span",null,n(e?.Name)+"/"+n(e?.CostMonth),1)])]),option:f(({option:e})=>[o("div",H,n(e?.Name)+"/"+n(e?.CostMonth),1)]),_:1},8,["options","modelValue"])])])]),h(m,{class:"modal__button",label:"Сменить","is-loading":c.value,onClick:s[1]||(s[1]=e=>u())},null,8,["is-loading"])])}}},A=M(K,[["__scopeId","data-v-c5045754"]]);export{A as default};
