import{al as y,am as n,an as i}from"./index-CmCGXBst.js";const p=y("global",()=>{async function d(r){let t="ERROR",a=null;return await n.post(i.delete,{...r}).then(e=>{e?.data?.Status==="Exception"?a=e?.data?.Exception:t="SUCCESS"}),{result:t,error:a}}async function u(r){let t="ERROR",a=null;return await n.post(i.OrdersTransfer,{...r}).then(e=>{e?.data?.Status==="Exception"?a=e?.data?.Exception:t="SUCCESS"}),{result:t,error:a}}async function s(r){let t="ERROR",a=null;return await n.post(i.OrderManage,{...r}).then(e=>{e?.data?.Status==="Exception"?a=e?.data?.Exception:(t="SUCCESS",window.open(e?.data?.Url,"_blank"))}),{result:t,error:a}}async function c(r){let t="ERROR",a=null;return await n.post(i.OrderManage,{...r}).then(e=>{if(e?.data?.Status==="Ok"){const l=window.open("","_blank");let o=`<html>
                            <head><title>Управление заказом</title></head>
                            <body>
                              <form id="OrderManageForm" action="${e.data.Url}" method="post">`;Object.entries(e.data.Args||{}).forEach(([w,m])=>{o+=`<input type="hidden" name="${w}" value="${m}">`}),o+=`</form>
                          <script>
                            document.getElementById('OrderManageForm').submit();
                          <\/script>
                        </body>
                        </html>`,l.document.write(o),l.document.close(),t="SUCCESS"}else e?.data?.Status==="Exception"?a=e?.data?.Exception:a="Неизвестный статус ответа"}).catch(e=>{a=e}),{result:t,error:a}}async function S(r){let t="ERROR",a=null;return await n.post(i.OrderChangePassword,{...r}).then(e=>{e?.data?.Status==="Ok"&&(t="SUCCESS")}),{result:t,error:a}}async function f(r){let t="ERROR",a=null;return await n.post(i.OrderRestore,{...r}).then(e=>{e?.data?.Status==="Ok"&&(t="SUCCESS")}),{result:t,error:a}}async function O(r){const{data:t}=await n.get(i.Discount+r);return t}async function R(){let r="ERROR";return await n.get(i.Generator).then(t=>{t?.data&&(r=t?.data)}),r}async function E(r){let t="ERROR";return await n.post(i.NoticeEdit,r).then(a=>{a?.data?.Status==="Ok"&&(t="SUCCESS")}),t}async function h(r){let t="ERROR";return await n.post("/API/OrdersPay",r).then(a=>{a?.data?.Status==="Url"&&a?.data?.Location==="/Basket"&&(t="Basket"),a?.data?.Status==="Ok"&&(t=a?.data)}),t}return{deleteItem:d,OrdersTransfer:u,OrderChangePassword:S,OrderRestore:f,OrderManage:s,fetchDiscount:O,NoticeEdit:E,OrderManageHosting:c,fetchPassword:R,OrdersPay:h}});export{p as u};
