import{al as L,r as c,am as l,an as i}from"./index-CipWZKo_.js";const b=L("services",()=>{const S=c({}),o=c({}),d=c([]),f=c(null),O=c(null),R=c(null);async function E(){if(!(Object.keys(S.value).length>0))try{const e=await l.post(i.services);e?.data?S.value=e.data:S.value={}}catch(e){console.error("Ошибка при загрузке сервисов:",e),S.value={}}}async function h(){const e=await l.post(i.DNSmanagerOrders);f.value=e.data}async function P(){await l.post(i.ExtraIPOrders).then(e=>{O.value=e.data})}async function y(){await l.post(i.ISPswOrders).then(e=>{R.value=e.data})}async function k(e){let t="ERROR",a=null,r=null,s=null,{Code:n="Default"}=e;return n==="Default"?s=i.ServiceOrder:s="/API/"+n+"Order",await l.post(s,e).then(u=>{u?.data?.Status==="Ok"?(t="SUCCESS",r=u?.data):a=u?.data?.Exception}),{result:t,info:r,error:a}}async function v(e){let t="ERROR",a=null,r=null,s=null,{Code:n="Default"}=e;return n==="Default"?s="/API/DNSmanagerOrder":s="/API/"+n+"Order",await l.post(s,e).then(u=>{u?.data?.Status==="Ok"?(t="SUCCESS",r=u?.data):a=u?.data?.Exception}),{result:t,info:r,error:a}}async function w(e){let t="ERROR",a=null,r=null,s=null,{Code:n="Default"}=e;return n==="Default"?s=i.ExtraIPOrder:s="/API/"+n+"Order",await l.post(s,e).then(u=>{u?.data?.Status==="Ok"?(t="SUCCESS",r=u?.data):a=u?.data?.Exception}),{result:t,info:r,error:a}}async function C(e){let t="ERROR",a=null,r=null,s=null,{Code:n="Default"}=e;return n==="Default"?s=i.ISPswOrder:s="/API/"+n+"Order",await l.post(s,e).then(u=>{u?.data?.Status==="Ok"?(t="SUCCESS",r=u?.data):a=u?.data?.Exception}),{result:t,info:r,error:a}}async function U(e){let t="ERROR";return await l.post(i.ExtraIPOrderPay,e).then(a=>{a?.data?.Status==="UseBasket"&&(t="UseBasket"),a?.data?.Status==="NoBasket"&&(t="NoBasket"),a?.data?.Status==="Ok"&&(t="NoBasket")}),t}async function D(e){let t="ERROR";return await l.post(i.ISPswOrderPay,e).then(a=>{a?.data?.Status==="UseBasket"&&(t="UseBasket"),a?.data?.Status==="NoBasket"&&(t="NoBasket"),a?.data?.Status==="Ok"&&(t="NoBasket")}),t}async function I(e){let t="ERROR";return await l.post(i.DNSOrderPay,e).then(a=>{a?.data?.Status==="UseBasket"&&(t="UseBasket"),a?.data?.Status==="NoBasket"&&(t="NoBasket"),a?.data?.Status==="Ok"&&(t="NoBasket")}),t}async function N(e="Default",t){let a="ERROR",r=null,s=null;return e==="Default"?s=i.ServiceOrderPay:s="/"+e+"OrderPay",await l.post(s,t).then(n=>{n?.data?.Status==="Ok"?a="SUCCESS":n?.data?.Status==="UseBasket"?a="BASKET":r=n?.data?.Exception}),{result:a,error:r}}async function m(e){let t="ERROR",a=null;return await l.post("/API/v2/"+e+"Schemes",{}).then(r=>{r?.data?(t="SUCCESS",o.value[e]=r?.data):a=r?.data?.Exception}),{result:t,error:a}}async function p(e){let t="ERROR",a=null;return await l.post(i.DNSmanagerOrderSchemeChange,e).then(r=>{r?.data?.Status==="Ok"&&(t="SUCCESS")}),{result:t,error:a}}async function B(e){let t="ERROR",a=null;return await l.post(i.ISPswOrderSchemeChange,e).then(r=>{r?.data?.Status==="Ok"&&(t="SUCCESS")}),{result:t,error:a}}async function x(e){try{const t=await l.post(i.DependServices,e);return t?.data?(d.value=t.data,{result:"SUCCESS",error:null}):(d.value=[],{result:"ERROR",error:t?.data?.Exception})}catch(t){return console.error("Ошибка при загрузке зависимых сервисов:",t),d.value=[],{result:"ERROR",error:t.message}}}async function g(e){await l.post(i.updateResourcesUsed,{Orders:e})}return{ServicesList:S,additionalServicesScheme:o,DependServicesList:d,fetchAdditionalServiceScheme:m,fetchDependServices:x,ServiceOrderPay:N,fetchServices:E,ServiceOrder:k,DNSmanagerOrder:v,ISPswOrder:C,ExtraIPOrder:w,fetchDNSmanagerOrders:h,DNSmanagerOrdersList:f,DNSmanagerOrderSchemeChange:p,ISPswOrdersList:R,fetchISPswOrders:y,ISPswOrderSchemeChange:B,ISPswOrderPay:D,DNSOrderPay:I,fetchExtraIPOrders:P,ExtraIPOrdersList:O,ExtraIPOrderPay:U,updateResourcesUsed:g}});export{b as u};
