import{_ as T}from"./EmptyStateBlock-BaR9js3E.js";import{_ as $}from"./TotalAmount.vue_vue_type_script_setup_true_lang-CXrtmBc-.js";import{_ as L}from"./BlockOrderPayBalance-3MeD3TJ2.js";import{_ as V}from"./ClausesKeeper-CTja-fCz.js";import{_ as R}from"./ButtonDefault-BIBStZbJ.js";import{_ as M}from"./BlockBalanceAgreement-qtspRQ_B.js";import{r as g,f as I,g as j,H as F,s as K,D as k,c as N,b as w,a as r,C as _,F as O,h as B,t as x,v as q,d as z,o as u}from"./index-CmCGXBst.js";import{u as H}from"./contracts-P7YPBhEI.js";import{u as G}from"./services-C54cnl9l.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 tw-mb-6"},W={class:"section"},X={class:"section-header"},Y={class:"section-header__wrapper"},Z={class:"section-title"},ee={class:"section-label"},te={__name:"AdditionalServicesProlongCode",async setup(ae){let l,c;const f=H(),s=G(),A=j(),C=z(),a=g(null),d=g(!1),o=I(()=>Object.values(s?.ISPswOrdersList).find(e=>e.OrderID==A.params.id)),m=I(()=>f.contractsList[o.value.ContractID]),n=I(()=>s?.additionalServicesScheme?.ISPsw?Object.keys(s.additionalServicesScheme.ISPsw).map(e=>{const t=s.additionalServicesScheme.ISPsw[e];return{...t,value:t?.ID,name:t?.Name,cost:t?.CostDay,month:t?.CostMonth}}).filter(e=>e?.ID==o.value?.SchemeID):[]),D=e=>{e.key==="Enter"&&e.ctrlKey&&S()};F(()=>{document.addEventListener("keyup",D)}),K(()=>{document.removeEventListener("keyup",D)});function S(){d.value=!0;const e=parseFloat(m.value?.Balance)>=parseFloat(P(a.value?.price-b())??0),t=n.value[0]?.cost==="0.00"&&n.value[0]?.month==="0.00",p=e||t,v=!p,y={ISPswOrderID:o.value.ID,DaysPay:a.value?.actualDays,IsNoBasket:p,IsUseBasket:v,PayMessage:""};s.ISPswOrderPay(y).then(i=>{i==="UseBasket"?C.push("/Basket"):i==="NoBasket"&&C.push("/AdditionalServices?ServiceID=51000"),d.value=!1}).catch(i=>{console.error("ISPswOrderPay error:",i),d.value=!1})}function P(e){return Number(e).toFixed(2)||0}function b(){let e=0;return a.value?.discounts?.Bonuses.map(t=>{e+=+t.Economy}),e}return F(()=>{s.fetchAdditionalServiceScheme("ISPsw")}),[l,c]=k(()=>s.fetchISPswOrders()),await l,c(),[l,c]=k(()=>s.fetchAdditionalServiceScheme("ISPsw")),await l,c(),[l,c]=k(()=>f.fetchContracts()),await l,c(),(e,t)=>{const p=M,v=R,y=V,i=L,E=$,U=T;return u(),N(O,null,[w(p),r("div",Q,[o.value?(u(),N(O,{key:0},[r("section",W,[r("div",X,[r("div",Y,[r("h1",Z,"Оплата заказа ПО ISPsystem, "+x(o.value.IP||""),1),n.value[0]?.ConsiderTypeID!=="Upon"?(u(),_(v,{key:0,class:"btn--wide",label:parseFloat(m.value.Balance)>=parseFloat(a.value?.price)?"Оплатить c баланса договора":"Добавить в корзину",disabled:a.value===null||a.value?.price===null,"is-loading":d.value,onClick:t[0]||(t[0]=h=>S())},null,8,["label","disabled","is-loading"])):B("",!0)]),r("div",ee,x(n.value[0]?.Name),1)]),w(y)]),m.value&&n.value[0]?.ConsiderTypeID!=="Upon"?(u(),_(i,{key:0,modelValue:a.value,"onUpdate:modelValue":t[1]||(t[1]=h=>a.value=h),contract:m.value,daysRemainded:o.value.DaysRemainded,serviceID:51e3,scheme:n.value[0],order:o.value},null,8,["modelValue","contract","daysRemainded","scheme","order"])):B("",!0),r("div",null,[a.value?(u(),_(E,{key:0,tariff:a.value},null,8,["tariff"])):B("",!0),w(v,{class:"btn--wide",label:parseFloat(q(f).contractsList[o.value.ContractID]?.Balance)>=(P(a.value?.price-b())??0)?"Оплатить c баланса договора":"Добавить в корзину",disabled:(a.value===null||a.value?.price===null)&&n.value[0]?.ConsiderTypeID!=="Upon","is-loading":d.value,onClick:t[2]||(t[2]=h=>S())},null,8,["label","disabled","is-loading"])])],64)):(u(),_(U,{key:1,label:"Заказ нельзя продлить"}))])],64)}}},ye=J(te,[["__scopeId","data-v-2d4063d6"]]);export{ye as default};
