marzban-sdk
Version:
The Marzban SDK is a fully typed client library for interacting with the Marzban API. It works in both browser and Node.js environments
2 lines • 39.1 kB
JavaScript
import x from'axios';import ge from'axios-retry';var te=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(s,e)=>(typeof require<"u"?require:s)[e]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var d="http://localhost".replace(/\/+$/,"");var U=class{constructor(s,e=d,r=x){this.basePath=e;this.axios=r;s&&(this.configuration=s,this.basePath=s.basePath??e);}},_=class extends Error{constructor(e,r){super(r);this.field=e;this.name="RequiredError";}},p={};var m="https://example.com",y=function(n,s,e){if(e==null)throw new _(s,`Required parameter ${s} was null or undefined when calling ${n}.`)};var R=async function(n,s,e,r){if(r&&r.accessToken){let a=typeof r.accessToken=="function"?await r.accessToken(s,e):await r.accessToken;n.Authorization="Bearer "+a;}};function J(n,s,e=""){s!=null&&(typeof s=="object"?Array.isArray(s)?s.forEach(r=>J(n,r,e)):Object.keys(s).forEach(r=>J(n,s[r],`${e}${e!==""?".":""}${r}`)):n.has(e)?n.append(e,s):n.set(e,s));}var h=function(n,...s){let e=new URLSearchParams(n.search);J(e,s),n.search=e.toString();},V=function(n,s,e){let r=typeof n!="string";return (r&&e&&e.isJsonMime?e.isJsonMime(s.headers["Content-Type"]):r)?JSON.stringify(n!==void 0?n:{}):n||""},g=function(n){return n.pathname+n.search+n.hash},A=function(n,s,e,r){return (a=s,t=e)=>{let o={...n.options,url:(a.defaults.baseURL?"":r?.basePath??t)+n.url};return a.request(o)}};var ne=function(n){return {activateAllDisabledUsers:async(s,e={})=>{y("activateAllDisabledUsers","username",s);let r="/api/admin/{username}/users/activate".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},adminToken:async(s,e,r,a,t,o,i={})=>{y("adminToken","username",s),y("adminToken","password",e);let l="/api/admin/token",c=new URL(l,m),u;n&&(u=n.baseOptions);let P={method:"POST",...u,...i},S={},q={},b=new URLSearchParams;r!==void 0&&b.set("grant_type",r),s!==void 0&&b.set("username",s),e!==void 0&&b.set("password",e),a!==void 0&&b.set("scope",a),t!==void 0&&b.set("client_id",t),o!==void 0&&b.set("client_secret",o),S["Content-Type"]="application/x-www-form-urlencoded",h(c,q);let z=u&&u.headers?u.headers:{};return P.headers={...S,...z,...i.headers},P.data=b.toString(),{url:g(c),options:P}},createAdmin:async(s,e={})=>{y("createAdmin","adminCreate",s);let r="/api/admin",a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),i["Content-Type"]="application/json",h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},o.data=V(s,o,n),{url:g(a),options:o}},disableAllActiveUsers:async(s,e={})=>{y("disableAllActiveUsers","username",s);let r="/api/admin/{username}/users/disable".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},getAdminUsage:async(s,e={})=>{y("getAdminUsage","username",s);let r="/api/admin/usage/{username}".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"GET",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},getAdmins:async(s,e,r,a={})=>{let t="/api/admins",o=new URL(t,m),i;n&&(i=n.baseOptions);let l={method:"GET",...i,...a},c={},u={};await R(c,"OAuth2PasswordBearer",[],n),s!==void 0&&(u.offset=s),e!==void 0&&(u.limit=e),r!==void 0&&(u.username=r),h(o,u);let P=i&&i.headers?i.headers:{};return l.headers={...c,...P,...a.headers},{url:g(o),options:l}},getCurrentAdmin:async(s={})=>{let e="/api/admin",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},modifyAdmin:async(s,e,r={})=>{y("modifyAdmin","username",s),y("modifyAdmin","adminModify",e);let a="/api/admin/{username}".replace("{username}",encodeURIComponent(String(s))),t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"PUT",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),l["Content-Type"]="application/json",h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},i.data=V(e,i,n),{url:g(t),options:i}},removeAdmin:async(s,e={})=>{y("removeAdmin","username",s);let r="/api/admin/{username}".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"DELETE",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},resetAdminUsage:async(s,e={})=>{y("resetAdminUsage","username",s);let r="/api/admin/usage/reset/{username}".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}}}},C=function(n){let s=ne(n);return {async activateAllDisabledUsers(e,r){let a=await s.activateAllDisabledUsers(e,r),t=n?.serverIndex??0,o=p["AdminApi.activateAllDisabledUsers"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async adminToken(e,r,a,t,o,i,l){let c=await s.adminToken(e,r,a,t,o,i,l),u=n?.serverIndex??0,P=p["AdminApi.adminToken"]?.[u]?.url;return (S,q)=>A(c,x,d,n)(S,P||q)},async createAdmin(e,r){let a=await s.createAdmin(e,r),t=n?.serverIndex??0,o=p["AdminApi.createAdmin"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async disableAllActiveUsers(e,r){let a=await s.disableAllActiveUsers(e,r),t=n?.serverIndex??0,o=p["AdminApi.disableAllActiveUsers"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getAdminUsage(e,r){let a=await s.getAdminUsage(e,r),t=n?.serverIndex??0,o=p["AdminApi.getAdminUsage"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getAdmins(e,r,a,t){let o=await s.getAdmins(e,r,a,t),i=n?.serverIndex??0,l=p["AdminApi.getAdmins"]?.[i]?.url;return (c,u)=>A(o,x,d,n)(c,l||u)},async getCurrentAdmin(e){let r=await s.getCurrentAdmin(e),a=n?.serverIndex??0,t=p["AdminApi.getCurrentAdmin"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async modifyAdmin(e,r,a){let t=await s.modifyAdmin(e,r,a),o=n?.serverIndex??0,i=p["AdminApi.modifyAdmin"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async removeAdmin(e,r){let a=await s.removeAdmin(e,r),t=n?.serverIndex??0,o=p["AdminApi.removeAdmin"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async resetAdminUsage(e,r){let a=await s.resetAdminUsage(e,r),t=n?.serverIndex??0,o=p["AdminApi.resetAdminUsage"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)}}};var I=class extends U{activateAllDisabledUsers(s,e){return C(this.configuration).activateAllDisabledUsers(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}adminToken(s,e,r,a,t,o,i){return C(this.configuration).adminToken(s,e,r,a,t,o,i).then(l=>l(this.axios,this.basePath)).then(({data:l})=>l)}createAdmin(s,e){return C(this.configuration).createAdmin(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}disableAllActiveUsers(s,e){return C(this.configuration).disableAllActiveUsers(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getAdminUsage(s,e){return C(this.configuration).getAdminUsage(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getAdmins(s,e,r,a){return C(this.configuration).getAdmins(s,e,r,a).then(t=>t(this.axios,this.basePath)).then(({data:t})=>t)}getCurrentAdmin(s){return C(this.configuration).getCurrentAdmin(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}modifyAdmin(s,e,r){return C(this.configuration).modifyAdmin(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}removeAdmin(s,e){return C(this.configuration).removeAdmin(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}resetAdminUsage(s,e){return C(this.configuration).resetAdminUsage(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}},oe=function(n){return {getCoreConfig:async(s={})=>{let e="/api/core/config",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},getCoreStats:async(s={})=>{let e="/api/core",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},modifyCoreConfig:async(s,e={})=>{y("modifyCoreConfig","body",s);let r="/api/core/config",a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"PUT",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),i["Content-Type"]="application/json",h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},o.data=V(s,o,n),{url:g(a),options:o}},restartCore:async(s={})=>{let e="/api/core/restart",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"POST",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}}}},B=function(n){let s=oe(n);return {async getCoreConfig(e){let r=await s.getCoreConfig(e),a=n?.serverIndex??0,t=p["CoreApi.getCoreConfig"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async getCoreStats(e){let r=await s.getCoreStats(e),a=n?.serverIndex??0,t=p["CoreApi.getCoreStats"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async modifyCoreConfig(e,r){let a=await s.modifyCoreConfig(e,r),t=n?.serverIndex??0,o=p["CoreApi.modifyCoreConfig"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async restartCore(e){let r=await s.restartCore(e),a=n?.serverIndex??0,t=p["CoreApi.restartCore"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)}}};var E=class extends U{getCoreConfig(s){return B(this.configuration).getCoreConfig(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}getCoreStats(s){return B(this.configuration).getCoreStats(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}modifyCoreConfig(s,e){return B(this.configuration).modifyCoreConfig(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}restartCore(s){return B(this.configuration).restartCore(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}},ie=function(n){return {base:async(s={})=>{let e="/",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={};h(r,{});let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}}}},le=function(n){let s=ie(n);return {async base(e){let r=await s.base(e),a=n?.serverIndex??0,t=p["DefaultApi.base"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)}}};var H=class extends U{base(s){return le(this.configuration).base(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}},ce=function(n){return {addNode:async(s,e={})=>{y("addNode","nodeCreate",s);let r="/api/node",a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),i["Content-Type"]="application/json",h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},o.data=V(s,o,n),{url:g(a),options:o}},getNode:async(s,e={})=>{y("getNode","nodeId",s);let r="/api/node/{node_id}".replace("{node_id}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"GET",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},getNodeSettings:async(s={})=>{let e="/api/node/settings",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},getNodes:async(s={})=>{let e="/api/nodes",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},getUsage:async(s,e,r={})=>{let a="/api/nodes/usage",t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"GET",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),s!==void 0&&(c.start=s),e!==void 0&&(c.end=e),h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},{url:g(t),options:i}},modifyNode:async(s,e,r={})=>{y("modifyNode","nodeId",s),y("modifyNode","nodeModify",e);let a="/api/node/{node_id}".replace("{node_id}",encodeURIComponent(String(s))),t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"PUT",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),l["Content-Type"]="application/json",h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},i.data=V(e,i,n),{url:g(t),options:i}},reconnectNode:async(s,e={})=>{y("reconnectNode","nodeId",s);let r="/api/node/{node_id}/reconnect".replace("{node_id}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},removeNode:async(s,e={})=>{y("removeNode","nodeId",s);let r="/api/node/{node_id}".replace("{node_id}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"DELETE",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}}}},v=function(n){let s=ce(n);return {async addNode(e,r){let a=await s.addNode(e,r),t=n?.serverIndex??0,o=p["NodeApi.addNode"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getNode(e,r){let a=await s.getNode(e,r),t=n?.serverIndex??0,o=p["NodeApi.getNode"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getNodeSettings(e){let r=await s.getNodeSettings(e),a=n?.serverIndex??0,t=p["NodeApi.getNodeSettings"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async getNodes(e){let r=await s.getNodes(e),a=n?.serverIndex??0,t=p["NodeApi.getNodes"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async getUsage(e,r,a){let t=await s.getUsage(e,r,a),o=n?.serverIndex??0,i=p["NodeApi.getUsage"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async modifyNode(e,r,a){let t=await s.modifyNode(e,r,a),o=n?.serverIndex??0,i=p["NodeApi.modifyNode"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async reconnectNode(e,r){let a=await s.reconnectNode(e,r),t=n?.serverIndex??0,o=p["NodeApi.reconnectNode"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async removeNode(e,r){let a=await s.removeNode(e,r),t=n?.serverIndex??0,o=p["NodeApi.removeNode"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)}}};var L=class extends U{addNode(s,e){return v(this.configuration).addNode(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getNode(s,e){return v(this.configuration).getNode(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getNodeSettings(s){return v(this.configuration).getNodeSettings(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}getNodes(s){return v(this.configuration).getNodes(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}getUsage(s,e,r){return v(this.configuration).getUsage(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}modifyNode(s,e,r){return v(this.configuration).modifyNode(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}reconnectNode(s,e){return v(this.configuration).reconnectNode(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}removeNode(s,e){return v(this.configuration).removeNode(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}},ue=function(n){return {userGetUsage:async(s,e,r,a={})=>{y("userGetUsage","token",s);let t="/sub/{token}/usage".replace("{token}",encodeURIComponent(String(s))),o=new URL(t,m),i;n&&(i=n.baseOptions);let l={method:"GET",...i,...a},c={},u={};e!==void 0&&(u.start=e),r!==void 0&&(u.end=r),h(o,u);let P=i&&i.headers?i.headers:{};return l.headers={...c,...P,...a.headers},{url:g(o),options:l}},userSubscription:async(s,e,r={})=>{y("userSubscription","token",s);let a="/sub/{token}/".replace("{token}",encodeURIComponent(String(s))),t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"GET",...o,...r},l={},c={};e!=null&&(l["user-agent"]=String(e)),h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},{url:g(t),options:i}},userSubscriptionInfo:async(s,e={})=>{y("userSubscriptionInfo","token",s);let r="/sub/{token}/info".replace("{token}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"GET",...t,...e},i={};h(a,{});let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},userSubscriptionWithClientType:async(s,e,r,a={})=>{y("userSubscriptionWithClientType","clientType",s),y("userSubscriptionWithClientType","token",e);let t="/sub/{token}/{client_type}".replace("{client_type}",encodeURIComponent(String(s))).replace("{token}",encodeURIComponent(String(e))),o=new URL(t,m),i;n&&(i=n.baseOptions);let l={method:"GET",...i,...a},c={},u={};r!=null&&(c["user-agent"]=String(r)),h(o,u);let P=i&&i.headers?i.headers:{};return l.headers={...c,...P,...a.headers},{url:g(o),options:l}}}},N=function(n){let s=ue(n);return {async userGetUsage(e,r,a,t){let o=await s.userGetUsage(e,r,a,t),i=n?.serverIndex??0,l=p["SubscriptionApi.userGetUsage"]?.[i]?.url;return (c,u)=>A(o,x,d,n)(c,l||u)},async userSubscription(e,r,a){let t=await s.userSubscription(e,r,a),o=n?.serverIndex??0,i=p["SubscriptionApi.userSubscription"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async userSubscriptionInfo(e,r){let a=await s.userSubscriptionInfo(e,r),t=n?.serverIndex??0,o=p["SubscriptionApi.userSubscriptionInfo"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async userSubscriptionWithClientType(e,r,a,t){let o=await s.userSubscriptionWithClientType(e,r,a,t),i=n?.serverIndex??0,l=p["SubscriptionApi.userSubscriptionWithClientType"]?.[i]?.url;return (c,u)=>A(o,x,d,n)(c,l||u)}}};var F=class extends U{userGetUsage(s,e,r,a){return N(this.configuration).userGetUsage(s,e,r,a).then(t=>t(this.axios,this.basePath)).then(({data:t})=>t)}userSubscription(s,e,r){return N(this.configuration).userSubscription(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}userSubscriptionInfo(s,e){return N(this.configuration).userSubscriptionInfo(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}userSubscriptionWithClientType(s,e,r,a){return N(this.configuration).userSubscriptionWithClientType(s,e,r,a).then(t=>t(this.axios,this.basePath)).then(({data:t})=>t)}},de=function(n){return {getHosts:async(s={})=>{let e="/api/hosts",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},getInbounds:async(s={})=>{let e="/api/inbounds",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},getSystemStats:async(s={})=>{let e="/api/system",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"GET",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},modifyHosts:async(s,e={})=>{y("modifyHosts","requestBody",s);let r="/api/hosts",a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"PUT",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),i["Content-Type"]="application/json",h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},o.data=V(s,o,n),{url:g(a),options:o}}}},k=function(n){let s=de(n);return {async getHosts(e){let r=await s.getHosts(e),a=n?.serverIndex??0,t=p["SystemApi.getHosts"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async getInbounds(e){let r=await s.getInbounds(e),a=n?.serverIndex??0,t=p["SystemApi.getInbounds"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async getSystemStats(e){let r=await s.getSystemStats(e),a=n?.serverIndex??0,t=p["SystemApi.getSystemStats"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async modifyHosts(e,r){let a=await s.modifyHosts(e,r),t=n?.serverIndex??0,o=p["SystemApi.modifyHosts"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)}}};var j=class extends U{getHosts(s){return k(this.configuration).getHosts(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}getInbounds(s){return k(this.configuration).getInbounds(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}getSystemStats(s){return k(this.configuration).getSystemStats(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}modifyHosts(s,e){return k(this.configuration).modifyHosts(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}},pe=function(n){return {activeNextPlan:async(s,e={})=>{y("activeNextPlan","username",s);let r="/api/user/{username}/active-next".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},addUser:async(s,e={})=>{y("addUser","userCreate",s);let r="/api/user",a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),i["Content-Type"]="application/json",h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},o.data=V(s,o,n),{url:g(a),options:o}},deleteExpiredUsers:async(s,e,r={})=>{let a="/api/users/expired",t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"DELETE",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),s!==void 0&&(c.expired_after=s instanceof Date?s.toISOString():s),e!==void 0&&(c.expired_before=e instanceof Date?e.toISOString():e),h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},{url:g(t),options:i}},getExpiredUsers:async(s,e,r={})=>{let a="/api/users/expired",t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"GET",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),s!==void 0&&(c.expired_after=s instanceof Date?s.toISOString():s),e!==void 0&&(c.expired_before=e instanceof Date?e.toISOString():e),h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},{url:g(t),options:i}},getUser:async(s,e={})=>{y("getUser","username",s);let r="/api/user/{username}".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"GET",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},getUserUsage:async(s,e,r,a={})=>{y("getUserUsage","username",s);let t="/api/user/{username}/usage".replace("{username}",encodeURIComponent(String(s))),o=new URL(t,m),i;n&&(i=n.baseOptions);let l={method:"GET",...i,...a},c={},u={};await R(c,"OAuth2PasswordBearer",[],n),e!==void 0&&(u.start=e),r!==void 0&&(u.end=r),h(o,u);let P=i&&i.headers?i.headers:{};return l.headers={...c,...P,...a.headers},{url:g(o),options:l}},getUsers:async(s,e,r,a,t,o,i,l={})=>{let c="/api/users",u=new URL(c,m),P;n&&(P=n.baseOptions);let S={method:"GET",...P,...l},q={},b={};await R(q,"OAuth2PasswordBearer",[],n),s!==void 0&&(b.offset=s),e!==void 0&&(b.limit=e),r&&(b.username=r),a!==void 0&&(b.search=a),t&&(b.admin=t),o!==void 0&&(b.status=o),i!==void 0&&(b.sort=i),h(u,b);let z=P&&P.headers?P.headers:{};return S.headers={...q,...z,...l.headers},{url:g(u),options:S}},getUsersUsage:async(s,e,r,a={})=>{let t="/api/users/usage",o=new URL(t,m),i;n&&(i=n.baseOptions);let l={method:"GET",...i,...a},c={},u={};await R(c,"OAuth2PasswordBearer",[],n),s!==void 0&&(u.start=s),e!==void 0&&(u.end=e),r&&(u.admin=r),h(o,u);let P=i&&i.headers?i.headers:{};return l.headers={...c,...P,...a.headers},{url:g(o),options:l}},modifyUser:async(s,e,r={})=>{y("modifyUser","username",s),y("modifyUser","userModify",e);let a="/api/user/{username}".replace("{username}",encodeURIComponent(String(s))),t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"PUT",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),l["Content-Type"]="application/json",h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},i.data=V(e,i,n),{url:g(t),options:i}},removeUser:async(s,e={})=>{y("removeUser","username",s);let r="/api/user/{username}".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"DELETE",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},resetUserDataUsage:async(s,e={})=>{y("resetUserDataUsage","username",s);let r="/api/user/{username}/reset".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},resetUsersDataUsage:async(s={})=>{let e="/api/users/reset",r=new URL(e,m),a;n&&(a=n.baseOptions);let t={method:"POST",...a,...s},o={},i={};await R(o,"OAuth2PasswordBearer",[],n),h(r,i);let l=a&&a.headers?a.headers:{};return t.headers={...o,...l,...s.headers},{url:g(r),options:t}},revokeUserSubscription:async(s,e={})=>{y("revokeUserSubscription","username",s);let r="/api/user/{username}/revoke_sub".replace("{username}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},setOwner:async(s,e,r={})=>{y("setOwner","username",s),y("setOwner","adminUsername",e);let a="/api/user/{username}/set-owner".replace("{username}",encodeURIComponent(String(s))),t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"PUT",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),e!==void 0&&(c.admin_username=e),h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},{url:g(t),options:i}}}},f=function(n){let s=pe(n);return {async activeNextPlan(e,r){let a=await s.activeNextPlan(e,r),t=n?.serverIndex??0,o=p["UserApi.activeNextPlan"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async addUser(e,r){let a=await s.addUser(e,r),t=n?.serverIndex??0,o=p["UserApi.addUser"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async deleteExpiredUsers(e,r,a){let t=await s.deleteExpiredUsers(e,r,a),o=n?.serverIndex??0,i=p["UserApi.deleteExpiredUsers"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async getExpiredUsers(e,r,a){let t=await s.getExpiredUsers(e,r,a),o=n?.serverIndex??0,i=p["UserApi.getExpiredUsers"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async getUser(e,r){let a=await s.getUser(e,r),t=n?.serverIndex??0,o=p["UserApi.getUser"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getUserUsage(e,r,a,t){let o=await s.getUserUsage(e,r,a,t),i=n?.serverIndex??0,l=p["UserApi.getUserUsage"]?.[i]?.url;return (c,u)=>A(o,x,d,n)(c,l||u)},async getUsers(e,r,a,t,o,i,l,c){let u=await s.getUsers(e,r,a,t,o,i,l,c),P=n?.serverIndex??0,S=p["UserApi.getUsers"]?.[P]?.url;return (q,b)=>A(u,x,d,n)(q,S||b)},async getUsersUsage(e,r,a,t){let o=await s.getUsersUsage(e,r,a,t),i=n?.serverIndex??0,l=p["UserApi.getUsersUsage"]?.[i]?.url;return (c,u)=>A(o,x,d,n)(c,l||u)},async modifyUser(e,r,a){let t=await s.modifyUser(e,r,a),o=n?.serverIndex??0,i=p["UserApi.modifyUser"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async removeUser(e,r){let a=await s.removeUser(e,r),t=n?.serverIndex??0,o=p["UserApi.removeUser"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async resetUserDataUsage(e,r){let a=await s.resetUserDataUsage(e,r),t=n?.serverIndex??0,o=p["UserApi.resetUserDataUsage"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async resetUsersDataUsage(e){let r=await s.resetUsersDataUsage(e),a=n?.serverIndex??0,t=p["UserApi.resetUsersDataUsage"]?.[a]?.url;return (o,i)=>A(r,x,d,n)(o,t||i)},async revokeUserSubscription(e,r){let a=await s.revokeUserSubscription(e,r),t=n?.serverIndex??0,o=p["UserApi.revokeUserSubscription"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async setOwner(e,r,a){let t=await s.setOwner(e,r,a),o=n?.serverIndex??0,i=p["UserApi.setOwner"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)}}};var D=class extends U{activeNextPlan(s,e){return f(this.configuration).activeNextPlan(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}addUser(s,e){return f(this.configuration).addUser(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}deleteExpiredUsers(s,e,r){return f(this.configuration).deleteExpiredUsers(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}getExpiredUsers(s,e,r){return f(this.configuration).getExpiredUsers(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}getUser(s,e){return f(this.configuration).getUser(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getUserUsage(s,e,r,a){return f(this.configuration).getUserUsage(s,e,r,a).then(t=>t(this.axios,this.basePath)).then(({data:t})=>t)}getUsers(s,e,r,a,t,o,i,l){return f(this.configuration).getUsers(s,e,r,a,t,o,i,l).then(c=>c(this.axios,this.basePath)).then(({data:c})=>c)}getUsersUsage(s,e,r,a){return f(this.configuration).getUsersUsage(s,e,r,a).then(t=>t(this.axios,this.basePath)).then(({data:t})=>t)}modifyUser(s,e,r){return f(this.configuration).modifyUser(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}removeUser(s,e){return f(this.configuration).removeUser(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}resetUserDataUsage(s,e){return f(this.configuration).resetUserDataUsage(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}resetUsersDataUsage(s){return f(this.configuration).resetUsersDataUsage(s).then(e=>e(this.axios,this.basePath)).then(({data:e})=>e)}revokeUserSubscription(s,e){return f(this.configuration).revokeUserSubscription(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}setOwner(s,e,r){return f(this.configuration).setOwner(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}},me=function(n){return {addUserTemplate:async(s,e={})=>{y("addUserTemplate","userTemplateCreate",s);let r="/api/user_template",a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"POST",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),i["Content-Type"]="application/json",h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},o.data=V(s,o,n),{url:g(a),options:o}},getUserTemplateEndpoint:async(s,e={})=>{y("getUserTemplateEndpoint","templateId",s);let r="/api/user_template/{template_id}".replace("{template_id}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"GET",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}},getUserTemplates:async(s,e,r={})=>{let a="/api/user_template",t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"GET",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),s!==void 0&&(c.offset=s),e!==void 0&&(c.limit=e),h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},{url:g(t),options:i}},modifyUserTemplate:async(s,e,r={})=>{y("modifyUserTemplate","templateId",s),y("modifyUserTemplate","userTemplateModify",e);let a="/api/user_template/{template_id}".replace("{template_id}",encodeURIComponent(String(s))),t=new URL(a,m),o;n&&(o=n.baseOptions);let i={method:"PUT",...o,...r},l={},c={};await R(l,"OAuth2PasswordBearer",[],n),l["Content-Type"]="application/json",h(t,c);let u=o&&o.headers?o.headers:{};return i.headers={...l,...u,...r.headers},i.data=V(e,i,n),{url:g(t),options:i}},removeUserTemplate:async(s,e={})=>{y("removeUserTemplate","templateId",s);let r="/api/user_template/{template_id}".replace("{template_id}",encodeURIComponent(String(s))),a=new URL(r,m),t;n&&(t=n.baseOptions);let o={method:"DELETE",...t,...e},i={},l={};await R(i,"OAuth2PasswordBearer",[],n),h(a,l);let c=t&&t.headers?t.headers:{};return o.headers={...i,...c,...e.headers},{url:g(a),options:o}}}},T=function(n){let s=me(n);return {async addUserTemplate(e,r){let a=await s.addUserTemplate(e,r),t=n?.serverIndex??0,o=p["UserTemplateApi.addUserTemplate"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getUserTemplateEndpoint(e,r){let a=await s.getUserTemplateEndpoint(e,r),t=n?.serverIndex??0,o=p["UserTemplateApi.getUserTemplateEndpoint"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)},async getUserTemplates(e,r,a){let t=await s.getUserTemplates(e,r,a),o=n?.serverIndex??0,i=p["UserTemplateApi.getUserTemplates"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async modifyUserTemplate(e,r,a){let t=await s.modifyUserTemplate(e,r,a),o=n?.serverIndex??0,i=p["UserTemplateApi.modifyUserTemplate"]?.[o]?.url;return (l,c)=>A(t,x,d,n)(l,i||c)},async removeUserTemplate(e,r){let a=await s.removeUserTemplate(e,r),t=n?.serverIndex??0,o=p["UserTemplateApi.removeUserTemplate"]?.[t]?.url;return (i,l)=>A(a,x,d,n)(i,o||l)}}};var M=class extends U{addUserTemplate(s,e){return T(this.configuration).addUserTemplate(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getUserTemplateEndpoint(s,e){return T(this.configuration).getUserTemplateEndpoint(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}getUserTemplates(s,e,r){return T(this.configuration).getUserTemplates(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}modifyUserTemplate(s,e,r){return T(this.configuration).modifyUserTemplate(s,e,r).then(a=>a(this.axios,this.basePath)).then(({data:a})=>a)}removeUserTemplate(s,e){return T(this.configuration).removeUserTemplate(s,e).then(r=>r(this.axios,this.basePath)).then(({data:r})=>r)}};var Q=class{constructor(s={}){this.apiKey=s.apiKey,this.username=s.username,this.password=s.password,this.accessToken=s.accessToken,this.basePath=s.basePath,this.serverIndex=s.serverIndex,this.baseOptions=s.baseOptions,this.formDataCtor=s.formDataCtor;}isJsonMime(s){let e=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return s!==null&&(e.test(s)||s.toLowerCase()==="application/json-patch+json")}};var Z=(n,s)=>{let e=x.create({baseURL:n});return ge(e,{retries:s?.retries??3,retryDelay:r=>r*1e3}),e};var $=class{constructor(s){this.authPromise=null;this.configuration=s;}async authenticate(s,e){return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(r,a)=>{try{let o=await new I(this.configuration).adminToken(s,e);o?.access_token?(this.configuration.accessToken=o.access_token,r()):a(new Error("Failed to retrieve access token"));}catch(t){console.error("Authentication failed",t),a(t);}finally{this.authPromise=null;}}),this.authPromise)}async waitForAuth(){let s=true;for(;s;)this.authPromise?(s=true,await this.authPromise):s=false;}retryAuth(){return this.authenticate(this.configuration.username,this.configuration.password)}get accessToken(){return this.configuration.accessToken?.toString()||""}set accessToken(s){this.configuration.accessToken=s;}};var ee=(n,s,e)=>{n.interceptors.request.use(async r=>{await s.waitForAuth();let a=s.accessToken;return r.headers.authorization=a?`Bearer ${a}`:void 0,r},r=>Promise.reject(r)),n.interceptors.response.use(r=>r,async r=>{let a=r?.config;if(r?.response?.status===401&&!a?.sent){a.sent=true;try{await s.authenticate(e.username,e.password);let t=s.accessToken;if(t)return a.headers.authorization=`Bearer ${t}`,n(a)}catch(t){return Promise.reject(t)}}return Promise.reject(r)});};var se=({basePath:n,endpoint:s,interval:e,token:r})=>{let a=new URL(n),t=a.protocol==="https:"?"wss":"ws";return a.protocol=t,a.pathname=s,a.searchParams.set("interval",e.toString()),a.searchParams.set("token",r),a.toString()};var W=class{constructor(s,e){this.url=s,this.protocols=e,this.socket=this.createWebSocket();}on(s,e){this.socket.addEventListener(s,e);}send(s){this.socket.send(s);}close(s,e){this.socket.close(s,e);}get readyState(){return this.socket.readyState}},Y=class extends W{createWebSocket(){return new WebSocket(this.url,this.protocols)}},X=class extends W{createWebSocket(){let s=te("ws");return new s(this.url,this.protocols)}},G=class{static create(s,e){return typeof window<"u"&&typeof window.WebSocket<"u"?new Y(s,e):new X(s,e)}};var K=class{constructor(s,e){this.activeConnections=new Set;this.maxRetries=3;this.basePath=s,this.authService=e;}async ensureAuthenticated(){this.authService.accessToken||(await this.authService.waitForAuth(),await this.authService.retryAuth());}async connect(s,e,r=0){await this.ensureAuthenticated();let a=se({basePath:this.basePath,endpoint:s,token:this.authService.accessToken,interval:e?.interval??1}),t=G.create(a);return this.activeConnections.add(t),t.on("open",()=>console.log(`Connected to ${s}`)),t.on("message",({data:o})=>e.onMessage(o)),t.on("error",async o=>{let i=o.message||"";if(console.error(`WebSocket error (${s}):`,i),i.includes("403")){if(console.warn(`Received 403 (retry ${r+1}/${this.maxRetries})`),r>=this.maxRetries){console.error("Max retries reached. Connection failed."),e.onError?.(o);return}return await this.authService.retryAuth(),this.connect(s,e,r+1)}e.onError?.(o);}),t.on("close",()=>{this.activeConnections.delete(t),console.log(`Disconnected from ${s}`);}),()=>{t.close(),this.activeConnections.delete(t);}}async connectByCore(s){return this.connect("/api/core/logs",s)}async connectByNode(s,e){return this.connect(`/api/node/${s}/logs`,e)}closeAllConnections(){this.activeConnections.forEach(s=>s.close()),this.activeConnections.clear(),console.log("All WebSocket connections closed.");}};var re=class{constructor(s){this.configuration=new Q({basePath:s.baseUrl,username:s.username,password:s.password}),this.client=Z(s.baseUrl,{retries:s.retries}),this.authService=new $(this.configuration),this.admin=new I(this.configuration,void 0,this.client),this.core=new E(this.configuration,void 0,this.client),this.node=new L(this.configuration,void 0,this.client),this.user=new D(this.configuration,void 0,this.client),this.system=new j(this.configuration,void 0,this.client),this.default=new H(this.configuration,void 0,this.client),this.subscription=new F(this.configuration,void 0,this.client),this.userTemplate=new M(this.configuration,void 0,this.client),this.logs=new K(s.baseUrl,this.authService),ee(this.client,this.authService,s),this.authService.authenticate(s.username,s.password);}};
export{re as MarzbanSDK};