import{_ as A}from"./EmptyStateBlock-D6U_EDq6.js";import{_ as E}from"./ButtonDefault-CghIUDY0.js";import{_ as R}from"./TotalAmount.vue_vue_type_script_setup_true_lang-GfTe3s0M.js";import{_ as L}from"./BlockOrderPayBalance-C1k6h3Ad.js";import{_ as U}from"./ClausesKeeper-DVJgfLR3.js";import{_ as T}from"./BlockBalanceAgreement-2iQbaweR.js";import{r as C,f as u,g as j,D as h,c as g,b as p,a as c,C as b,F as w,h as N,t as F,v as M,d as q,o as d}from"./index-CipWZKo_.js";import{u as z}from"./contracts-CILh9uSu.js";import{u as G}from"./services-Dmz4Qt8q.js";import{_ as H}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./bootstrap-vue-next-3DpAa4tb.js";import"./component-DWBAga-C.js";import"./global-Fil99La8.js";import"./IconCross-C6IvNpdZ.js";import"./IconClose-ChC2G6HM.js";const J={class:"tw-px-4 md:tw-px-8"},K={class:"section-header"},Q={class:"section-header__wrapper"},W={class:"section-label"},X={class:"tw-my-6"},Y={__name:"ExtraIPOrderPayId",async setup(Z){let o,r;const k=z(),s=G(),B=j(),P=q(),t=C(null),i=C(!1),n=u(()=>Object.values(s.ExtraIPOrdersList).find(a=>a.OrderID==B.params.id)),m=u(()=>k.contractsList[n.value.ContractID]),S=u(()=>Number(m.value?.Balance)>=t.value?.price-D.value?"Оплатить c баланса договора":"Добавить в корзину"),_=u(()=>s?.additionalServicesScheme?.ExtraIP?Object.keys(s.additionalServicesScheme.ExtraIP).map(a=>{const e=s.additionalServicesScheme.ExtraIP[a];return{...e,value:e?.ID,name:e?.Name,cost:e?.CostDay,month:e?.CostMonth}}).filter(a=>a?.ID==n.value?.SchemeID):[]);function x(){i.value=!0;const a=Number(m.value?.Balance)>=t.value?.price-D.value,e=_.value[0]?.cost==="0.00"&&_.value[0]?.month==="0.00",v=a||e,f=!v,I={ExtraIPOrderID:n.value.ID,DaysPay:t.value?.actualDays,IsNoBasket:v,IsUseBasket:f,PayMessage:""};s.ExtraIPOrderPay(I).then(l=>{l==="UseBasket"?P.push("/Basket"):l==="NoBasket"?P.push("/AdditionalServices"):console.error("Ошибка оплаты заказа"),i.value=!1}).catch(l=>{console.error("ExtraIPOrderPay error:",l),i.value=!1})}const D=u(()=>{let a=0;return t.value?.discounts?.Bonuses.map(e=>{a+=Number(e.Economy)}),a});return[o,r]=h(()=>s.fetchExtraIPOrders()),await o,r(),[o,r]=h(()=>s.fetchAdditionalServiceScheme("ExtraIP")),await o,r(),[o,r]=h(()=>k.fetchContracts()),await o,r(),(a,e)=>{const v=T,f=E,I=U,l=L,O=R,$=E,V=A;return d(),g(w,null,[p(v),c("div",J,[n.value?(d(),g(w,{key:0},[c("div",K,[c("div",Q,[e[3]||(e[3]=c("h1",{class:"section-title"},"Оплата заказа IP адреса",-1)),p(f,{class:"btn--wide",label:S.value,disabled:t.value===null||t.value?.price===null,"is-loading":i.value,onClick:e[0]||(e[0]=y=>x())},null,8,["label","disabled","is-loading"])]),c("div",W,F(_.value[0]?.Name),1)]),p(I),m.value?(d(),b(l,{key:0,modelValue:t.value,"onUpdate:modelValue":e[1]||(e[1]=y=>t.value=y),contract:m.value,daysRemainded:n.value?.DaysRemainded,serviceID:5e4,scheme:_.value[0],order:n.value},null,8,["modelValue","contract","daysRemainded","scheme","order"])):N("",!0),c("div",X,[t.value?(d(),b(O,{key:0,tariff:t.value},null,8,["tariff"])):N("",!0),p($,{class:"btn--wide",label:S.value,disabled:t.value===null||t.value?.price===null,"is-loading":i.value,onClick:e[2]||(e[2]=y=>x())},null,8,["label","disabled","is-loading"])])],64)):(d(),b(V,{key:1,label:`Заказ #${M(B).params.id} не найден`},null,8,["label"]))])],64)}}},pe=H(Y,[["__scopeId","data-v-3570d21e"]]);export{pe as default};
