import{_ as R}from"./EmptyStateBlock-BaR9js3E.js";import{_ as A}from"./ButtonDefault-BIBStZbJ.js";import{_ as T}from"./TotalAmount.vue_vue_type_script_setup_true_lang-CXrtmBc-.js";import{_ as K}from"./BlockOrderPayBalance-3MeD3TJ2.js";import{_ as N}from"./ClausesKeeper-CTja-fCz.js";import{_ as U}from"./BlockBalanceAgreement-qtspRQ_B.js";import{G as j,r as f,f as c,g as F,H,s as G,D as y,c as d,b as m,a as _,C as S,h as D,F as M,d as q,o as s}from"./index-CmCGXBst.js";import{u as z}from"./contracts-P7YPBhEI.js";import{_ as J}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./bootstrap-vue-next-DwS3lKQb.js";import"./component-0WedTVCo.js";import"./global-5eUCDNCu.js";import"./IconCross-BH1MaI1J.js";import"./IconClose-B_k4TzXM.js";const Q={class:"tw-px-4 md:tw-px-8"},W={key:0},X={class:"tw-mb-8"},Y={key:1,class:"section"},Z={key:2,class:"section"},ee={class:"container"},te={__name:"VPSOrderPayId",async setup(ae){let o,n;const r=j(),h=z(),k=q(),B=F(),a=f(null),u=f(null),p=f(!1),w=c(()=>Object.keys(r.vpsSchemes).map(e=>r.vpsSchemes[e])),l=c(()=>Object.values(r.vpsList).find(e=>e.OrderID==B.params.id)),v=c(()=>h.contractsList[u.value]),i=c(()=>w.value.find(e=>e?.ID==l.value?.SchemeID)),C=c(()=>v.value?.Balance>a.value?.price?"Оплатить c баланса договора":"Добавить в корзину");function V(){p.value=!0,r.VPSOrderPay({VPSOrderID:l.value?.ID,DaysPay:a.value?.actualDays,IsChange:!0}).then(e=>{let{result:t,error:b}=e;t==="SUCCESS"?k.push("/VPSOrders"):t==="BASKET"&&k.push("/Basket"),p.value=!0})}const P=e=>{e.key==="Enter"&&e.ctrlKey&&!O.value&&V()},O=c(()=>a.value===null||u.value===null);return H(()=>{document.addEventListener("keyup",P)}),G(()=>{document.removeEventListener("keyup",P)}),[o,n]=y(()=>r.fetchVPSSchemes()),await o,n(),[o,n]=y(()=>h.fetchContracts()),await o,n(),[o,n]=y(()=>r.fetchVPS()),await o,n(),u.value=l.value?.ContractID,(e,t)=>{const b=U,E=N,x=K,L=T,$=A,I=R;return s(),d(M,null,[m(b),_("div",Q,[l.value?(s(),d("div",W,[_("div",X,[t[2]||(t[2]=_("h1",{class:"tw-w-full tw-mb-6"},"Оплата заказа VPS/VDS сервера",-1)),m(E,{partition:"Header:/VPSSchemes"})]),v.value?(s(),S(x,{key:0,modelValue:a.value,"onUpdate:modelValue":t[0]||(t[0]=g=>a.value=g),contract:v.value,scheme:i.value,serviceID:3e4,daysRemainded:l.value?.DaysRemainded,order:l.value},null,8,["modelValue","contract","scheme","daysRemainded","order"])):D("",!0),i.value?.IsPayed&&i.value?.IsProlong||!i.value?.IsPayed?(s(),d("div",Y,[a.value?(s(),S(L,{key:0,tariff:a.value},null,8,["tariff"])):D("",!0),m($,{class:"btn--wide",label:C.value,disabled:a.value===null||u.value===null,"is-loading":p.value,onClick:t[1]||(t[1]=g=>V())},null,8,["label","disabled","is-loading"])])):(s(),d("div",Z,[_("div",ee,[m(I,{class:"no-margin",label:"Заказ нельзя продлить"})])]))])):(s(),S(I,{key:1,label:"Заказ VPS/VDS сервера не найден",class:"tw-my-8"}))])],64)}}},ye=J(te,[["__scopeId","data-v-55449043"]]);export{ye as default};
