From b2ad111eaf7d802e9c747ff34710a407ba3d3319 Mon Sep 17 00:00:00 2001 From: Gozarman <120019621+gozarman@users.noreply.github.com> Date: Fri, 1 Mar 2024 17:36:44 +0000 Subject: [PATCH] bump version to 0.4.9 --- app/__init__.py | 2 +- app/dashboard/build/404.html | 4 ++-- .../build/assets/{index.6107a319.js => index.2e9c394e.js} | 6 +++--- .../build/assets/{vendor.d3666332.js => vendor.764109dc.js} | 0 app/dashboard/build/index.html | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename app/dashboard/build/assets/{index.6107a319.js => index.2e9c394e.js} (73%) rename app/dashboard/build/assets/{vendor.d3666332.js => vendor.764109dc.js} (100%) diff --git a/app/__init__.py b/app/__init__.py index d14189d1e..a941edf11 100755 --- a/app/__init__.py +++ b/app/__init__.py @@ -11,7 +11,7 @@ from config import DOCS, XRAY_SUBSCRIPTION_PATH -__version__ = "0.4.8" +__version__ = "0.4.9" app = FastAPI( diff --git a/app/dashboard/build/404.html b/app/dashboard/build/404.html index cd865e25b..4ccace450 100644 --- a/app/dashboard/build/404.html +++ b/app/dashboard/build/404.html @@ -33,8 +33,8 @@ - - + + diff --git a/app/dashboard/build/assets/index.6107a319.js b/app/dashboard/build/assets/index.2e9c394e.js similarity index 73% rename from app/dashboard/build/assets/index.6107a319.js rename to app/dashboard/build/assets/index.2e9c394e.js index f9a4d7030..ae832d85f 100644 --- a/app/dashboard/build/assets/index.6107a319.js +++ b/app/dashboard/build/assets/index.2e9c394e.js @@ -1,4 +1,4 @@ -import{i as _t,B as to,a as ro,b as oo,j as yr,d as j,U as Et,z as no,r as so,f as io,Q as ao,e as lo,$ as co,c as gt,g as x,h as uo,C as ho,k as ft,u as Rt,l as O,m as r,H as w,n as e,T as u,o as po,p as v,s as mo,q as g,t as Je,J as go,v as Sr,A as bt,w as fo,x as bo,M as re,y as oe,D as ne,E as se,F as ie,G as ue,I as je,K as Cr,L as xo,N as Qe,O as ae,P as T,R as G,S as wr,V as te,W as E,X as ze,Y as $,Z as be,_ as N,a0 as xt,a1 as Ve,a2 as yo,a3 as fe,a4 as Re,a5 as So,a6 as kr,a7 as _r,a8 as Ye,a9 as ct,aa as Co,ab as Fe,ac as dt,ad as Yt,ae as wo,af as Ir,ag as vr,ah as zr,ai as de,aj as ko,ak as _o,al as Io,am as vo,an as zo,ao as Lt,ap as Dr,aq as Ur,ar as me,as as Zt,at as Do,au as Uo,av as Eo,aw as It,ax as Ro,ay as Lo,az as To,aA as Ao,aB as Mo,aC as No,aD as ut,aE as Fo,aF as Ee,aG as Po,aH as k,aI as Ke,aJ as Er,aK as et,aL as M,aM as Tt,aN as Wo,aO as Pe,aP as We,aQ as vt,aR as Oe,aS as ye,aT as Se,aU as Ce,aV as we,aW as ke,aX as _e,aY as Qt,aZ as At,a_ as Oo,a$ as jo,b0 as Ho,b1 as Rr,b2 as Bo,b3 as qe,b4 as ht,b5 as Lr,b6 as $o,b7 as Vo,b8 as Tr,b9 as Ar,ba as Mr,bb as De,bc as Go,bd as Yo,be as Zo,bf as Mt,bg as St,bh as qt,bi as Nr,bj as Qo,bk as qo,bl as Xt,bm as Xo,bn as Jt,bo as Fr,bp as Jo,bq as Pr,br as Ko,bs as en,bt as Wr,bu as tn,bv as rn,bw as Or,bx as jr,by as Hr,bz as X,bA as on,bB as Br,bC as nn,bD as sn,bE as an,bF as ln,bG as cn,bH as dn,bI as un,bJ as $r,bK as hn,bL as Kt,bM as er,bN as Me,bO as ge,bP as tr,bQ as ce,bR as rr,bS as pn,bT as mn,bU as gn,bV as fn,bW as bn,bX as xn,bY as yn,bZ as Sn,b_ as Cn,b$ as wn,c0 as kn,c1 as _n,c2 as In,c3 as vn,c4 as zn,c5 as Dn,c6 as Un}from"./vendor.d3666332.js";(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerpolicy&&(a.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?a.credentials="include":i.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();_t.use(to).use(ro).use(oo).init({debug:{}.NODE_ENV==="development",returnNull:!1,fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1},load:"languageOnly",detection:{caches:["localStorage","sessionStorage","cookie"]},backend:{loadPath:yr(["/dashboard/","locales/{{lng}}.json"])}},function(t,o){j.locale(_t.language)});_t.on("languageChanged",t=>{j.locale(t)});Et("zh-cn",no);Et("ru",so);Et("fa",io);const zt=new ao,Vr=t=>{const o=document.querySelector('meta[name="theme-color"]');o==null||o.setAttribute("content",t=="dark"?"#1A202C":"#3B81F6")},En=lo({shadows:{outline:"0 0 0 2px var(--chakra-colors-primary-200)"},fonts:{body:"Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif"},colors:{"light-border":"#d2d2d4",primary:{50:"#9cb7f2",100:"#88a9ef",200:"#749aec",300:"#618ce9",400:"#4d7de7",500:"#396fe4",600:"#3364cd",700:"#2e59b6",800:"#284ea0",900:"#224389"},gray:{750:"#222C3B"}},components:{Alert:{baseStyle:{container:{borderRadius:"6px",fontSize:"sm"}}},Select:{baseStyle:{field:{_dark:{borderColor:"gray.600",borderRadius:"6px"},_light:{borderRadius:"6px"}}}},FormHelperText:{baseStyle:{fontSize:"xs"}},FormLabel:{baseStyle:{fontSize:"sm",fontWeight:"medium",mb:"1",_dark:{color:"gray.300"}}},Input:{baseStyle:{addon:{_dark:{borderColor:"gray.600",_placeholder:{color:"gray.500"}}},field:{_focusVisible:{boxShadow:"none",borderColor:"primary.200",outlineColor:"primary.200"},_dark:{borderColor:"gray.600",_disabled:{color:"gray.400",borderColor:"gray.500"},_placeholder:{color:"gray.500"}}}}},Table:{baseStyle:{table:{borderCollapse:"separate",borderSpacing:0},thead:{borderBottomColor:"light-border"},th:{background:"#F9FAFB",borderColor:"light-border !important",borderBottomColor:"light-border !important",borderTop:"1px solid ",borderTopColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border !important"},_last:{borderRight:"1px solid",borderColor:"light-border !important"},_dark:{borderColor:"gray.600 !important",background:"gray.750"}},td:{transition:"all .1s ease-out",borderColor:"light-border",borderBottomColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_last:{borderRight:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_dark:{borderColor:"gray.600",borderBottomColor:"gray.600 !important"}},tr:{"&.interactive":{cursor:"pointer",_hover:{"& > td":{bg:"gray.200"},_dark:{"& > td":{bg:"gray.750"}}}},_last:{"& > td":{_first:{borderBottomLeftRadius:"8px"},_last:{borderBottomRightRadius:"8px"}}}}}}}});const pt=()=>localStorage.getItem("token"),Rn=t=>{localStorage.setItem("token",t)},Ln=()=>{localStorage.removeItem("token")},Tn=co.create({baseURL:"/api/"}),An=(t,o={})=>(pt()&&(o.headers={...(o==null?void 0:o.headers)||{},Authorization:`Bearer ${pt()}`}),Tn(t,o)),W=An,Mn=gt(t=>({isLoading:!0,isPostLoading:!1,version:null,started:!1,logs_websocket:null,config:"",fetchCoreSettings:()=>{t({isLoading:!0}),Promise.all([W("/core").then(({version:o,started:n,logs_websocket:s})=>t({version:o,started:n,logs_websocket:s})),W("/core/config").then(o=>t({config:o}))]).finally(()=>t({isLoading:!1}))},updateConfig:o=>(t({isPostLoading:!0}),W("/core/config",{method:"PUT",body:o}).finally(()=>{t({isPostLoading:!1})})),restartCore:()=>W("/core/restart",{method:"POST"})}));function ee(t,o=2,n=!1){if(!+t)return"0 B";const s=1024,i=o<0?0:o,a=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(t)/Math.log(s));return n?[parseFloat((t/Math.pow(s,l)).toFixed(i)),a[l]]:`${parseFloat((t/Math.pow(s,l)).toFixed(i))} ${a[l]}`}const or=t=>{if(t!==null)return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Nn=x(uo,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Fn=x(ho,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Pn=x(ft,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Ct=({title:t,content:o,icon:n})=>r(po,{p:6,borderWidth:"1px",borderColor:"light-border",bg:"#F9FAFB",_dark:{borderColor:"gray.600",bg:"gray.750"},borderStyle:"solid",boxShadow:"none",borderRadius:"12px",width:"full",display:"flex",justifyContent:"space-between",flexDirection:"row",children:[r(w,{alignItems:"center",columnGap:"4",children:[e(v,{p:"2",position:"relative",color:"white",_before:{content:'""',position:"absolute",top:0,left:0,bg:"primary.400",display:"block",w:"full",h:"full",borderRadius:"5px",opacity:".5",z:"1"},_after:{content:'""',position:"absolute",top:"-5px",left:"-5px",bg:"primary.400",display:"block",w:"calc(100% + 10px)",h:"calc(100% + 10px)",borderRadius:"8px",opacity:".4",z:"1"},children:n}),e(u,{color:"gray.600",_dark:{color:"gray.300"},fontWeight:"medium",textTransform:"capitalize",fontSize:"sm",children:t})]}),e(v,{fontSize:"3xl",fontWeight:"semibold",mt:"2",children:o})]}),Dt="statistics-query-key",Wn=t=>{const{version:o}=I(),{data:n}=Rt({queryKey:Dt,queryFn:()=>W("/system"),refetchInterval:5e3,onSuccess:({version:i})=>{o!==i&&I.setState({version:i})}}),{t:s}=O();return r(w,{justifyContent:"space-between",gap:0,columnGap:{lg:4,md:0},rowGap:{lg:0,base:4},display:"flex",flexDirection:{lg:"row",base:"column"},...t,children:[e(Ct,{title:s("activeUsers"),content:n&&r(w,{alignItems:"flex-end",children:[e(u,{children:or(n.users_active)}),r(u,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:["/ ",or(n.total_user)]})]}),icon:e(Nn,{})}),e(Ct,{title:s("dataUsage"),content:n&&ee(n.incoming_bandwidth+n.outgoing_bandwidth),icon:e(Fn,{})}),e(Ct,{title:s("memoryUsage"),content:n&&r(w,{alignItems:"flex-end",children:[e(u,{children:ee(n.mem_used,1,!0)[0]}),r(u,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:[ee(n.mem_used,1,!0)[1]," /"," ",ee(n.mem_total,1)]})]}),icon:e(Pn,{})})]})},Gr="marzban-num-users-per-page",nr=10,On=()=>{const t=localStorage.getItem(Gr)||nr.toString();return parseInt(t)||nr},jn=t=>localStorage.setItem(Gr,t),Hn=t=>{for(const o in t)t[o]||delete t[o];return I.setState({loading:!0}),W("/users",{query:t}).then(o=>(I.setState({users:o}),o)).finally(()=>{I.setState({loading:!1})})},Bn=()=>W("/inbounds").then(t=>{I.setState({inbounds:new Map(Object.entries(t))})}).finally(()=>{I.setState({loading:!1})}),I=gt(mo((t,o)=>({version:null,editingUser:null,deletingUser:null,isCreatingNewUser:!1,QRcodeLinks:null,subscribeUrl:null,users:{users:[],total:0},loading:!0,isResetingAllUsage:!1,isEditingHosts:!1,isEditingNodes:!1,isShowingNodesUsage:!1,resetUsageUser:null,revokeSubscriptionUser:null,filters:{username:"",limit:On(),sort:"-created_at"},inbounds:new Map,isEditingCore:!1,refetchUsers:()=>{Hn(o().filters)},resetAllUsage:()=>W("/users/reset",{method:"POST"}).then(()=>{o().onResetAllUsage(!1),o().refetchUsers()}),onResetAllUsage:n=>t({isResetingAllUsage:n}),onCreateUser:n=>t({isCreatingNewUser:n}),onEditingUser:n=>{t({editingUser:n})},onDeletingUser:n=>{t({deletingUser:n})},onFilterChange:n=>{t({filters:{...o().filters,...n}}),o().refetchUsers()},setQRCode:n=>{t({QRcodeLinks:n})},deleteUser:n=>(t({editingUser:null}),W(`/user/${n.username}`,{method:"DELETE"}).then(()=>{t({deletingUser:null}),o().refetchUsers(),zt.invalidateQueries(Dt)})),createUser:n=>W("/user",{method:"POST",body:n}).then(()=>{t({editingUser:null}),o().refetchUsers(),zt.invalidateQueries(Dt)}),editUser:n=>W(`/user/${n.username}`,{method:"PUT",body:n}).then(()=>{o().onEditingUser(null),o().refetchUsers()}),fetchUserUsage:(n,s)=>{for(const i in s)s[i]||delete s[i];return W(`/user/${n.username}/usage`,{method:"GET",query:s})},onEditingHosts:n=>{t({isEditingHosts:n})},onEditingNodes:n=>{t({isEditingNodes:n})},onShowingNodesUsage:n=>{t({isShowingNodesUsage:n})},setSubLink:n=>{t({subscribeUrl:n})},resetDataUsage:n=>W(`/user/${n.username}/reset`,{method:"POST"}).then(()=>{t({resetUsageUser:null}),o().refetchUsers()}),revokeSubscription:n=>W(`/user/${n.username}/revoke_sub`,{method:"POST"}).then(s=>{t({revokeSubscriptionUser:null,editingUser:s}),o().refetchUsers()})}))),le=({children:t,color:o})=>e(v,{position:"relative",width:"36px",height:"36px",display:"flex",justifyContent:"center",alignItems:"center",_before:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100%)",height:"calc(100%)",bg:`${o}.400`,opacity:".5",borderRadius:"5px",zIndex:"1",_dark:{bg:`${o}.400`}},_after:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100% + 10px)",height:"calc(100% + 10px)",transform:"translate(-5px, -5px)",bg:`${o}.400`,opacity:".4",borderRadius:"8px",zIndex:"1",_dark:{bg:`${o}.400`}},children:e(u,{color:`${o}.500`,_dark:{color:`${o}.900`},position:"relative",zIndex:"2",children:t})});window.ace.define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"],(t,o,n)=>{o.isDark=!0,o.cssClass="ace-nord-dark",t("../lib/dom").importCssString(o.cssText,o.cssClass)});window.ace.define("ace/theme/dawn",["require","exports","module","ace/lib/dom"],(t,o,n)=>{o.isDark=!1,o.cssClass="ace-dawn",t("../lib/dom").importCssString(o.cssText,o.cssClass)});const $n=g.exports.forwardRef(({json:t,onChange:o,mode:n="code"},s)=>{const{colorMode:i}=Je(),a={mode:n,onChangeText:o,statusBar:!1,mainMenuBar:!1,theme:i==="dark"?"ace/theme/nord_dark":"ace/theme/dawn"},l=g.exports.useRef(null),h=g.exports.useRef(null);return g.exports.useEffect(()=>(h.current=new go(l.current,a),()=>{h.current&&h.current.destroy()}),[]),g.exports.useEffect(()=>{h.current&&h.current.update(t)},[t]),e(v,{ref:s,border:"1px solid",borderColor:"gray.300",_dark:{borderColor:"gray.500"},borderRadius:5,h:"full",children:e(v,{height:"full",ref:l})})}),sr=500,Vn=x(Sr,{baseStyle:{w:5,h:5}}),Gn=x(bt,{baseStyle:{w:4,h:4}}),Yn=x(fo,{baseStyle:{w:4,h:4}}),Zn=x(bo,{baseStyle:{w:3,h:3}}),Qn=t=>({[Ve.ReadyState.CONNECTING]:"connecting",[Ve.ReadyState.OPEN]:"connected",[Ve.ReadyState.CLOSING]:"closed",[Ve.ReadyState.CLOSED]:"closed",[Ve.ReadyState.UNINSTANTIATED]:"closed"})[t],qn=()=>{try{let t=new URL("/api/".startsWith("/")?window.location.origin+"/api/":"/api/");return(t.protocol==="https:"?"wss://":"ws://")+yr([t.host+t.pathname,"/core/logs"])+"?interval=1&token="+pt()}catch(t){return console.error("Unable to generate websocket url"),console.error(t),null}};let Ie=[];const Xn=()=>{const{isEditingCore:t}=I(),{fetchCoreSettings:o,updateConfig:n,isLoading:s,config:i,isPostLoading:a,version:l,restartCore:h}=Mn(),p=g.exports.useRef(null),[y,d]=g.exports.useState([]),{t:c}=O(),C=ue(),_=je({defaultValues:{config:i||{}}});g.exports.useEffect(()=>{i&&_.setValue("config",i)},[i]),g.exports.useEffect(()=>{t&&o()},[t]);const f=g.exports.useRef(!0),S=g.exports.useCallback(Cr(z=>{var Z,R,Q;const F=Math.abs((((Z=p.current)==null?void 0:Z.scrollTop)||0)-(((R=p.current)==null?void 0:R.scrollHeight)||0)+(((Q=p.current)==null?void 0:Q.offsetHeight)||0))<10;p.current&&F?f.current=!0:f.current=!1,z.length<40&&d(z)},300),[]),{readyState:L}=xo(qn(),{onMessage:z=>{Ie.push(z.data),Ie.length>sr&&(Ie=Ie.splice(0,Ie.length-sr)),S([...Ie])},shouldReconnect:()=>!0,reconnectAttempts:10,reconnectInterval:1e3});g.exports.useEffect(()=>{var z;p.current&&f.current&&(p.current.scrollTop=(z=p.current)==null?void 0:z.scrollHeight)},[y]),g.exports.useEffect(()=>()=>{Ie=[]},[]);const m=Qn(L.toString()),{mutate:b,isLoading:P}=Qe(h),H=({config:z})=>{n(z).then(()=>{C({title:c("core.successMessage"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(F=>{let Z=c("core.generalErrorMessage");typeof F.response._data.detail=="object"&&(Z=F.response._data.detail[Object.keys(F.response._data.detail)[0]]),typeof F.response._data.detail=="string"&&(Z=F.response._data.detail),C({title:Z,status:"error",isClosable:!0,position:"top",duration:3e3})})},U=g.exports.useRef(null),[A,B]=g.exports.useState(!1),Y=()=>{var z;document.fullscreenElement?(document.exitFullscreen(),B(!1)):((z=U.current)==null||z.requestFullscreen(),B(!0))};return r("form",{onSubmit:_.handleSubmit(H),children:[r(ae,{children:[r(T,{children:[r(w,{justifyContent:"space-between",alignItems:"flex-start",children:[r(G,{children:[c("core.configuration")," ",s&&e(wr,{isIndeterminate:!0,size:"15px"})]}),e(w,{gap:0,children:e(te,{label:"Xray Version",placement:"top",children:e(E,{height:"100%",textTransform:"lowercase",children:l&&`v${l}`})})})]}),r(v,{position:"relative",ref:U,minHeight:"300px",children:[e(ze,{control:_.control,name:"config",render:({field:z})=>e($n,{json:i,onChange:z.onChange})}),e($,{size:"xs","aria-label":"full screen",variant:"ghost",position:"absolute",top:"2",right:"4",onClick:Y,children:A?e(Zn,{}):e(Yn,{})})]})]}),r(T,{mt:"4",children:[r(w,{justifyContent:"space-between",children:[e(G,{children:c("core.logs")}),e(u,{as:G,children:c(`core.socket.${m}`)})]}),e(v,{border:"1px solid",borderColor:"gray.300",bg:"#F9F9F9",_dark:{borderColor:"gray.500",bg:"#2e3440"},borderRadius:5,minHeight:"200px",maxHeight:"250px",p:2,overflowY:"auto",ref:p,children:y.map((z,F)=>e(u,{fontSize:"xs",opacity:.8,whiteSpace:"pre-line",children:z},F))})]})]}),e(be,{children:r(w,{w:"full",justifyContent:"space-between",children:[e(v,{children:e(N,{size:"sm",leftIcon:e(Gn,{className:xt({"animate-spin":P})}),onClick:()=>b(),children:c(P?"core.restarting":"core.restartCore")})}),e(w,{children:e(N,{size:"sm",variant:"solid",colorScheme:"primary",px:"5",type:"submit",isDisabled:s||a,isLoading:a,children:c("core.save")})})]})})]})},Jn=()=>{const{isEditingCore:t}=I(),o=I.setState.bind(null,{isEditingCore:!1}),{t:n}=O();return r(re,{isOpen:t,onClose:o,size:"3xl",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"full",children:[e(se,{pt:6,children:r(w,{gap:2,children:[e(le,{color:"primary",children:e(Vn,{color:"white"})}),e(u,{fontWeight:"semibold",fontSize:"lg",children:n("core.title")})]})}),e(ie,{mt:3}),e(Xn,{})]})]})},tt=x(yo,{baseStyle:{w:5,h:5}}),Kn=()=>{const[t,o]=g.exports.useState(!1),{deletingUser:n,onDeletingUser:s,deleteUser:i}=I(),{t:a}=O(),l=ue(),h=()=>{s(null)},p=()=>{n&&(o(!0),i(n).then(()=>{l({title:a("deleteUser.deleteSuccess",{username:n.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).then(h).finally(o.bind(null,!1)))};return r(re,{isCentered:!0,isOpen:!!n,onClose:h,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"red",children:e(tt,{})})}),e(ie,{mt:3}),r(ae,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:a("deleteUser.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:a("deleteUser.prompt",{username:n.username})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:h,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Re,{size:"xs"}):void 0,children:a("delete")})]})]})]})},Nt={baseStyle:{w:4,h:4}},es=x(So,Nt),ts=x(kr,Nt),Yr=x(bt,Nt),rs=Cr(t=>{I.getState().onFilterChange({...I.getState().filters,offset:0,username:t})},300),os=({...t})=>{const{loading:o,filters:n,onFilterChange:s,refetchUsers:i,onCreateUser:a}=I(),{t:l}=O(),[h,p]=g.exports.useState(""),y=c=>{p(c.target.value),rs(c.target.value)},d=()=>{p(""),s({...n,offset:0,username:""})};return r(_r,{id:"filters",templateColumns:{lg:"repeat(3, 1fr)",md:"repeat(4, 1fr)",base:"repeat(1, 1fr)"},position:"sticky",top:0,mx:"-6",px:"6",rowGap:4,gap:{lg:4,base:0},bg:"var(--chakra-colors-chakra-body-bg)",py:4,zIndex:"docked",...t,children:[e(Ye,{colSpan:{base:1,md:2,lg:1},order:{base:2,md:1},children:r(ct,{children:[e(Co,{pointerEvents:"none",children:e(es,{})}),e(Fe,{placeholder:l("search"),value:h,borderColor:"light-border",onChange:y}),r(dt,{children:[o&&e(Re,{size:"xs"}),n.username&&n.username.length>0&&e($,{onClick:d,"aria-label":"clear",size:"xs",variant:"ghost",children:e(ts,{})})]})]})}),e(Ye,{colSpan:2,order:{base:1,md:2},children:r(w,{justifyContent:"flex-end",alignItems:"center",h:"full",children:[e($,{"aria-label":"refresh users",disabled:o,onClick:i,size:"sm",variant:"outline",children:e(Yr,{className:xt({"animate-spin":o})})}),e(N,{colorScheme:"primary",size:"sm",onClick:()=>a(!0),px:5,children:l("createUser")})]})})]})},Zr="https://github.com/Gozargah/Marzban",ns="https://github.com/Gozargah",ss="https://github.com/Gozargah/Marzban#donation",Qr=t=>{const{version:o}=I();return e(w,{w:"full",py:"0",position:"relative",...t,children:r(u,{display:"inline-block",flexGrow:1,textAlign:"center",color:"gray.500",fontSize:"xs",children:[e(Yt,{color:"blue.400",href:Zr,children:"Marzban"}),o?` (v${o}), `:", ","Made with \u2764\uFE0F in"," ",e(Yt,{color:"blue.400",href:ns,children:"Gozargah"})]})})},is=x(wo,{baseStyle:{w:4,h:4}}),qr=({actions:t})=>{const{i18n:o}=O();var n=s=>{o.changeLanguage(s)};return r(Ir,{placement:"bottom-end",children:[e(vr,{as:$,size:"sm",variant:"outline",icon:e(is,{}),position:"relative"}),r(zr,{minW:"100px",zIndex:9999,children:[e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("en"),children:"English"}),e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("fa"),children:"\u0641\u0627\u0631\u0633\u06CC"}),e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("zh-cn"),children:"\u7B80\u4F53\u4E2D\u6587"}),e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("ru"),children:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"})]})]})},he={baseStyle:{w:4,h:4}},as=x(ko,he),ls=x(_o,he),cs=x(Sr,he),ds=x(Io,he),us=x(vo,he),hs=x(zo,he),ps=x(Lt,he),ms=x(Dr,he),gs=x(ft,he),fs=x(Ur,he),ir=x(v,{baseStyle:{bg:"yellow.500",w:"2",h:"2",rounded:"full",position:"absolute"}}),Xr="marzban-menu-notification",bs=()=>{const t=localStorage.getItem(Xr);if(!t)return!0;try{return t&&Uo(parseInt(t))?Eo(new Date,new Date(parseInt(t)))>=7:!0}catch{return!0}},xs=({actions:t})=>{const{onEditingHosts:o,onResetAllUsage:n,onEditingNodes:s,onShowingNodesUsage:i}=I(),{t:a}=O(),{colorMode:l,toggleColorMode:h}=Je(),[p,y]=g.exports.useState(bs()),d=l==="dark"?"dark_dimmed":l,c=()=>{localStorage.setItem(Xr,new Date().getTime().toString()),y(!1)};return r(w,{gap:2,justifyContent:"space-between",__css:{"& .menuList":{direction:"ltr"}},position:"relative",children:[e(u,{as:"h1",fontWeight:"semibold",fontSize:"2xl",children:a("users")}),p&&e(ir,{top:"0",right:"0",zIndex:9999}),e(v,{overflow:"auto",css:{direction:"rtl"},children:r(w,{alignItems:"center",children:[r(Ir,{children:[e(vr,{as:$,size:"sm",variant:"outline",icon:e(me,{children:e(ds,{})}),position:"relative"}),r(zr,{minW:"170px",zIndex:99999,className:"menuList",children:[e(de,{maxW:"170px",fontSize:"sm",icon:e(ps,{}),onClick:o.bind(null,!0),children:a("header.hostSettings")}),e(de,{maxW:"170px",fontSize:"sm",icon:e(ms,{}),onClick:s.bind(null,!0),children:a("header.nodeSettings")}),e(de,{maxW:"170px",fontSize:"sm",icon:e(gs,{}),onClick:i.bind(null,!0),children:a("header.nodesUsage")}),e(de,{maxW:"170px",fontSize:"sm",icon:e(fs,{}),onClick:n.bind(null,!0),children:a("resetAllUsage")}),e(Zt,{to:ss,target:"_blank",children:r(de,{maxW:"170px",fontSize:"sm",icon:e(hs,{}),position:"relative",onClick:c,children:[a("header.donation")," ",p&&e(ir,{top:"3",right:"2"})]})}),e(Zt,{to:"/login",children:e(de,{maxW:"170px",fontSize:"sm",icon:e(us,{}),children:a("header.logout")})})]})]}),e($,{size:"sm",variant:"outline","aria-label":"core settings",onClick:()=>{I.setState({isEditingCore:!0})},children:e(cs,{})}),e(qr,{}),e($,{size:"sm",variant:"outline","aria-label":"switch theme",onClick:()=>{Vr(l=="dark"?"light":"dark"),h()},children:l==="light"?e(as,{}):e(ls,{})}),e(v,{css:{direction:"ltr"},display:"flex",alignItems:"center",pr:"2",__css:{"& span":{display:"inline-flex"}},children:e(Do,{href:Zr,"data-color-scheme":`no-preference: ${d}; light: ${d}; dark: ${d};`,"data-size":"large","data-show-count":"true","aria-label":"Star Marzban on GitHub",children:"Star"})})]})})]})},ys=[{title:"Inbound's default",value:"inbound_default"},{title:"TLS",value:"tls"},{title:"None",value:"none"}],Ss=[{title:"",value:""},{title:"h2",value:"h2"},{title:"http/1.1",value:"http/1.1"},{title:"h2, http/1.1",value:"h2,http/1.1"}],Cs=[{title:"",value:""},...["chrome","firefox","safari","ios","android","edge","360","qq","random","randomized"].map(t=>({title:t,value:t}))],ws=[{title:"none",value:""},{title:"xtls-rprx-vision",value:"xtls-rprx-vision"}],ks=["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"],_s=gt(t=>({isLoading:!1,isPostLoading:!1,hosts:{},fetchHosts:()=>{t({isLoading:!0}),W("/hosts").then(o=>t({hosts:o})).finally(()=>t({isLoading:!1}))},setHosts:o=>(t({isPostLoading:!0}),W("/hosts",{method:"PUT",body:o}).finally(()=>{t({isPostLoading:!1})}))}));const Is=x(kr,{baseStyle:{w:4,h:4}}),Ue=It.forwardRef(({disabled:t,step:o,label:n,className:s,startAdornment:i,endAdornment:a,type:l="text",placeholder:h,onChange:p,onBlur:y,name:d,value:c,onClick:C,error:_,clearable:f=!1,...S},L)=>{const m=()=>{p&&p({target:{value:"",name:d}})},{size:b="md"}=S,P=l=="number"?Fo:Fe,H=l=="number"?Ro:It.Fragment,U=l=="number"?{keepWithinRange:!0,precision:5,format:A=>isNaN(parseFloat(String(A)))||Number(parseFloat(String(A)).toFixed(5))===0?A:Number(parseFloat(String(A)).toFixed(5)),min:0,step:o,name:d,type:l,placeholder:h,onChange:A=>{p&&p(A)},onBlur:y,value:c,onClick:C,disabled:t,flexGrow:1,size:b}:{};return r(T,{isInvalid:!!_,children:[n&&e(G,{children:n}),r(ct,{size:b,w:"full",rounded:"md",_focusWithin:{outline:"2px solid",outlineColor:"primary.200"},bg:t?"gray.100":"transparent",_dark:{bg:t?"gray.600":"transparent"},children:[i&&e(Lo,{children:i}),r(H,{...U,children:[e(P,{name:d,ref:L,step:o,className:xt(s),type:l,placeholder:h,onChange:p,onBlur:y,value:c,onClick:C,disabled:t,flexGrow:1,_focusVisible:{outline:"none",borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent"},_disabled:{cursor:"not-allowed"},...S,roundedLeft:i?"0":"md",roundedRight:a?"0":"md"}),l=="number"&&e(me,{children:r(To,{children:[e(Ao,{}),e(Mo,{})]})})]}),a&&e(No,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",children:a}),f&&c&&c.length&&e(dt,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",onClick:m,cursor:"pointer",children:e(Is,{})})]}),!!_&&e(ut,{children:_})]})}),wt=x(Ee,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ne=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),vs=x(Lt,{baseStyle:{w:5,h:5}}),ve=x(Po,{baseStyle:{w:4,h:4,color:"gray.400",cursor:"pointer"}}),zs=k.record(k.string().min(1),k.array(k.object({remark:k.string().min(1,"Remark is required"),address:k.string().min(1,"Address is required"),port:k.string().or(k.number()).nullable().transform(t=>typeof t=="number"?t:t!==null&&!isNaN(parseInt(t))?Number(parseInt(t)):null),path:k.string().nullable(),sni:k.string().nullable(),host:k.string().nullable(),security:k.string(),alpn:k.string(),fingerprint:k.string()}))),Ge=x(ut,{baseStyle:{color:"red.400",display:"block",textAlign:"left",w:"100%"}}),Ds=({hostKey:t,isOpen:o,toggleAccordion:n})=>{const{inbounds:s}=I(),i=[...s.values()].flat().filter(_=>_.tag===t)[0],a=Tt(),{fields:l,append:h,remove:p}=Wo({control:a.control,name:t}),{errors:y}=a.formState,{t:d}=O(),c=y[t],C=()=>{h({host:"",sni:"",port:null,path:null,address:"",remark:"",security:"inbound_default",alpn:"",fingerprint:""})};return g.exports.useEffect(()=>{c&&!o&&n()},[c]),r(Pe,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(We,{px:2,borderRadius:"3px",onClick:n,children:[e(u,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:t}),e(vt,{})]}),e(Oe,{px:2,pb:2,children:r(M,{gap:3,children:[l.map((_,f)=>{var S,L,m,b,P,H,U,A,B,Y,z,F,Z,R,Q,K,nt,st,pe,Be,$e;return r(M,{border:"1px solid",_dark:{borderColor:"gray.600",bg:"#273142"},_light:{borderColor:"gray.200",bg:"#fcfbfb"},p:2,w:"full",borderRadius:"4px",children:[e(w,{w:"100%",alignItems:"flex-start",children:r(T,{position:"relative",zIndex:10,isInvalid:!!(c&&((S=c[f])==null?void 0:S.remark)),children:[r(ct,{children:[e(Ne,{...a.register(t+"."+f+".remark"),size:"sm",borderRadius:"4px",placeholder:"Remark"}),e(dt,{children:r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(v,{mt:"-8px",children:e(ve,{})})}),e(Ce,{children:r(we,{children:[e(ke,{}),e(_e,{}),e(Qt,{children:r(v,{fontSize:"xs",children:[e(u,{pr:"20px",children:d("hostsDialog.desc")}),r(u,{children:[r(E,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(u,{mt:1,children:[r(E,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(u,{mt:1,children:[r(E,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(u,{mt:1,children:[r(E,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(u,{mt:1,children:[r(E,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(u,{mt:1,children:[r(E,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(u,{mt:1,children:[r(E,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((L=c[f])==null?void 0:L.remark)&&e(Ge,{children:(b=(m=c[f])==null?void 0:m.remark)==null?void 0:b.message})]})}),r(T,{isInvalid:!!(c&&((P=c[f])==null?void 0:P.address)),children:[r(ct,{children:[e(Ne,{size:"sm",borderRadius:"4px",placeholder:"Address (e.g. example.com)",...a.register(t+"."+f+".address")}),e(dt,{children:r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(v,{mt:"-8px",children:e(ve,{})})}),e(Ce,{children:r(we,{children:[e(ke,{}),e(_e,{}),e(Qt,{children:r(v,{fontSize:"xs",children:[e(u,{pr:"20px",children:d("hostsDialog.desc")}),r(u,{children:[r(E,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(u,{mt:1,children:[r(E,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(u,{mt:1,children:[r(E,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(u,{mt:1,children:[r(E,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(u,{mt:1,children:[r(E,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(u,{mt:1,children:[r(E,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(u,{mt:1,children:[r(E,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((H=c[f])==null?void 0:H.address)&&e(Ge,{children:(A=(U=c[f])==null?void 0:U.address)==null?void 0:A.message})]}),e(et,{w:"full",allowToggle:!0,children:r(Pe,{border:"0",children:[r(We,{display:"flex",justifyContent:"space-between",px:0,py:1,borderRadius:3,_hover:{bg:"transparent"},children:[r(u,{fontSize:"xs",color:"gray.600",_dark:{color:"gray.500"},pl:1,children:[d("hostsDialog.advancedOptions"),e(vt,{fontSize:"sm",ml:1})]}),e(te,{label:"Delete",placement:"top",children:e($,{"aria-label":"Delete",size:"sm",colorScheme:"red",variant:"ghost",onClick:p.bind(null,f),children:e(tt,{})})})]}),e(Oe,{w:"full",p:1,children:r(M,{w:"full",borderRadius:"4px",children:[r(T,{isInvalid:!!(c&&((B=c[f])==null?void 0:B.port)),children:[r(G,{display:"flex",pb:1,alignItems:"center",justifyContent:"space-between",gap:1,m:"0",children:[e("span",{children:d("hostsDialog.port")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.port.info")})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:String(i.port||"8080"),type:"number",...a.register(t+"."+f+".port")})]}),r(T,{isInvalid:!!(c&&((Y=c[f])==null?void 0:Y.sni)),children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.sni")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.sni.info")}),e(u,{fontSize:"xs",mt:"2",children:e(fe,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(E,{})}})}),e(u,{fontSize:"xs",children:e(fe,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(E,{})}})})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:"SNI (e.g. example.com)",...a.register(t+"."+f+".sni")}),c&&((z=c[f])==null?void 0:z.sni)&&e(Ge,{children:(Z=(F=c[f])==null?void 0:F.sni)==null?void 0:Z.message})]}),r(T,{isInvalid:!!(c&&((R=c[f])==null?void 0:R.host)),children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.host")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.host.info")}),e(u,{fontSize:"xs",mt:"2",children:e(fe,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(E,{})}})}),e(u,{fontSize:"xs",children:e(fe,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(E,{})}})})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:"Host (e.g. example.com)",...a.register(t+"."+f+".host")}),c&&((Q=c[f])==null?void 0:Q.host)&&e(Ge,{children:(nt=(K=c[f])==null?void 0:K.host)==null?void 0:nt.message})]}),r(T,{isInvalid:!!(c&&((st=c[f])==null?void 0:st.path)),children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.path")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.path.info")})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:"path (e.g. /vless)",...a.register(t+"."+f+".path")}),c&&((pe=c[f])==null?void 0:pe.path)&&e(Ge,{children:($e=(Be=c[f])==null?void 0:Be.path)==null?void 0:$e.message})]}),r(T,{height:"66px",children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.security")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.security.info")})]})})]})]}),e(wt,{size:"sm",...a.register(t+"."+f+".security"),children:ys.map(J=>e("option",{value:J.value,children:J.title},J.value))})]}),r(T,{height:"66px",children:[e(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.alpn")})}),e(wt,{size:"sm",...a.register(t+"."+f+".alpn"),children:Ss.map(J=>e("option",{value:J.value,children:J.title},J.value))})]}),r(T,{height:"66px",children:[e(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.fingerprint")})}),e(wt,{size:"sm",...a.register(t+"."+f+".fingerprint"),children:Cs.map(J=>e("option",{value:J.value,children:J.title},J.value))})]})]},f)})]})})]},f)}),e(N,{variant:"outline",w:"full",size:"sm",color:"",fontWeight:"normal",onClick:C,children:d("hostsDialog.addHost")})]})})]})},Us=()=>{const{isEditingHosts:t,onEditingHosts:o,refetchUsers:n,inbounds:s}=I(),{isLoading:i,hosts:a,fetchHosts:l,isPostLoading:h,setHosts:p}=_s(),y=ue(),{t:d}=O(),[c,C]=g.exports.useState({});g.exports.useEffect(()=>{t&&l()},[t]);const _=je({resolver:Ke(zs)});g.exports.useEffect(()=>{a&&t&&_.reset(a)},[a]);const f=()=>{C({}),o(!1)},S=m=>{p(m).then(()=>{y({title:d("hostsDialog.savedSuccess"),status:"success",isClosable:!0,position:"top",duration:3e3}),n()}).catch(b=>{var P,H,U,A,B;(((P=b==null?void 0:b.response)==null?void 0:P.status)===409||((H=b==null?void 0:b.response)==null?void 0:H.status)===400)&&y({title:(A=(U=b.response)==null?void 0:U._data)==null?void 0:A.detail,status:"error",isClosable:!0,position:"top",duration:3e3}),((B=b==null?void 0:b.response)==null?void 0:B.status)===422&&Object.keys(b.response._data.detail).forEach(Y=>{y({title:b.response._data.detail[Y]+" ("+Y+")",status:"error",isClosable:!0,position:"top",duration:3e3})})})},L=m=>{c[String(m)]?delete c[String(m)]:c[String(m)]={},C({...c})};return r(re,{isOpen:t,onClose:f,children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(se,{pt:6,children:e(le,{color:"primary",children:e(vs,{color:"white"})})}),e(ie,{mt:3}),e(ae,{w:"440px",pb:3,pt:3,children:e(Er,{..._,children:r("form",{onSubmit:_.handleSubmit(S),children:[e(u,{mb:3,opacity:.8,fontSize:"sm",children:d("hostsDialog.title")}),i&&d("hostsDialog.loading"),!i&&a&&(Object.keys(a).length>0?e(et,{w:"full",allowToggle:!0,allowMultiple:!0,index:Object.keys(c).map(m=>parseInt(m)),children:e(M,{w:"full",children:Object.keys(a).map((m,b)=>e(Ds,{toggleAccordion:()=>L(b),isOpen:c[String(b)],hostKey:m},m))})}):"No inbound found. Please check your Xray config file."),e(w,{justifyContent:"flex-end",py:2,children:e(N,{variant:"solid",mt:"2",type:"submit",colorScheme:"primary",size:"sm",px:5,isLoading:h,disabled:h,children:d("hostsDialog.apply")})})]})})})]})]})},Jr=k.object({name:k.string().min(1),address:k.string().min(1),port:k.number().min(1).or(k.string().transform(t=>parseFloat(t))),api_port:k.number().min(1).or(k.string().transform(t=>parseFloat(t))),xray_version:k.string().nullable().optional(),id:k.number().nullable().optional(),status:k.enum(["connected","connecting","error","disabled"]).nullable().optional(),message:k.string().nullable().optional(),add_as_new_host:k.boolean().optional()}),Es=()=>({name:"",address:"",port:62050,api_port:62051,xray_version:""}),Xe="fetch-nodes-query-key",Rs=()=>{const{isEditingNodes:t}=I();return Rt({queryKey:Xe,queryFn:rt.getState().fetchNodes,refetchInterval:t?3e3:void 0,refetchOnWindowFocus:!1})},rt=gt((t,o)=>({nodes:[],addNode(n){return W("/node",{method:"POST",body:n})},fetchNodes(){return W("/nodes")},fetchNodesUsage(n){return W("/nodes/usage",{query:n})},updateNode(n){return W(`/node/${n.id}`,{method:"PUT",body:n})},setDeletingNode(n){t({deletingNode:n})},reconnectNode(n){return W(`/node/${n.id}/reconnect`,{method:"POST"})},deleteNode:()=>{var n;return W(`/node/${(n=o().deletingNode)==null?void 0:n.id}`,{method:"DELETE"})}})),Ft=(t,o,n)=>{if(t.response&&t.response._data){if(typeof t.response._data.detail=="string")return o({title:t.response._data.detail,status:"error",isClosable:!0,position:"top",duration:3e3});if(typeof t.response._data.detail=="object"&&n){Object.keys(t.response._data.detail).forEach(s=>n.setError(s,{message:t.response._data.detail[s]}));return}}return o({title:"Something went wrong!",status:"error",isClosable:!0,position:"top",duration:3e3})},Pt=(t,o)=>o({title:t,status:"success",isClosable:!0,position:"top",duration:3e3}),Ls=({deleteCallback:t})=>{const{deleteNode:o,deletingNode:n,setDeletingNode:s}=rt(),{t:i}=O(),a=ue(),l=At(),h=()=>{s(null)},{isLoading:p,mutate:y}=Qe(o,{onSuccess:()=>{Pt(i("deleteNode.deleteSuccess",{name:n&&n.name}),a),s(null),l.invalidateQueries(Xe),t&&t()},onError:d=>{Ft(d,a)}});return r(re,{isCentered:!0,isOpen:!!n,onClose:h,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"red",children:e(tt,{})})}),e(ie,{mt:3}),r(ae,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:i("deleteNode.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:i("deleteNode.prompt",{name:n.name})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:h,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"red",onClick:()=>y(),leftIcon:p?e(Re,{size:"xs"}):void 0,children:i("delete")})]})]})]})},ot={baseStyle:{strokeWidth:"2px",w:4,h:4}},ar=x(Oo,ot),Ts=x(jo,ot),lr=x(Ho,ot),cr=x(Rr,ot),As=x(Rr,ot),Ut=[{title:"No",value:"no_reset"},{title:"Daily",value:"day"},{title:"Weekly",value:"week"},{title:"Monthly",value:"month"},{title:"Annually",value:"year"}],Ze={active:{statusColor:"green",bandWidthColor:"primary",icon:ar},connected:{statusColor:"green",bandWidthColor:"primary",icon:ar},disabled:{statusColor:"gray",bandWidthColor:"gray",icon:Ts},expired:{statusColor:"orange",bandWidthColor:"orange",icon:cr},on_hold:{statusColor:"purple",bandWidthColor:"purple",icon:As},connecting:{statusColor:"orange",bandWidthColor:"orange",icon:cr},limited:{statusColor:"red",bandWidthColor:"red",icon:lr},error:{statusColor:"red",bandWidthColor:"red",icon:lr}},Wt=t=>{let o={status:"",time:""};if(t){j(t*1e3).utc().isAfter(j().utc())?o.status="expires":o.status="expired";const n=[],s=j.duration(j(t*1e3).utc().diff(j()));s.years()!=0&&n.push(Math.abs(s.years())+" year"+(Math.abs(s.years())!=1?"s":"")),s.months()!=0&&n.push(Math.abs(s.months())+" month"+(Math.abs(s.months())!=1?"s":"")),s.days()!=0&&n.push(Math.abs(s.days())+" day"+(Math.abs(s.days())!=1?"s":"")),n.length===0&&(s.hours()!=0&&n.push(Math.abs(s.hours())+" hour"+(Math.abs(s.hours())!=1?"s":"")),s.minutes()!=0&&n.push(Math.abs(s.minutes())+" min"+(Math.abs(s.minutes())!=1?"s":""))),o.time=n.join(", ")}return o},lt=({expiryDate:t,status:o,compact:n=!1,showDetail:s=!0,extraText:i})=>{const{t:a}=O(),l=Wt(t),h=Ze[o].icon;return r(me,{children:[r(E,{colorScheme:Ze[o].statusColor,rounded:"full",display:"inline-flex",px:3,py:1,columnGap:n?1:2,alignItems:"center",children:[e(h,{w:n?3:4}),s&&r(u,{textTransform:"capitalize",fontSize:n?".7rem":".875rem",lineHeight:n?"1rem":"1.25rem",fontWeight:"medium",letterSpacing:"tighter",children:[o,i&&`: ${i}`]})]}),s&&t&&e(u,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:a(l.status,{time:l.time})})]})},it=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ms=x(Dr,{baseStyle:{w:5,h:5}}),Ns=x(Bo,{baseStyle:{w:5,h:5,strokeWidth:2}}),Fs=({toggleAccordion:t,node:o})=>{const{updateNode:n,reconnectNode:s,setDeletingNode:i}=rt(),{t:a}=O(),l=At(),h=ue(),p=je({defaultValues:o,resolver:Ke(Jr)}),y=i.bind(null,o),{isLoading:d,mutate:c}=Qe(n,{onSuccess:()=>{Pt("Node updated successfully",h),l.invalidateQueries(Xe)},onError:S=>{Ft(S,h,p)}}),{isLoading:C,mutate:_}=Qe(s.bind(null,o),{onSuccess:()=>{l.invalidateQueries(Xe)}}),f=C?"connecting":o.status?o.status:"error";return r(Pe,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(We,{px:2,borderRadius:"3px",onClick:t,children:[r(w,{w:"full",justifyContent:"space-between",pr:2,children:[e(u,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:o.name}),r(w,{children:[o.xray_version&&e(E,{colorScheme:"blue",rounded:"full",display:"inline-flex",px:3,py:1,children:r(u,{textTransform:"capitalize",fontSize:"0.7rem",fontWeight:"medium",letterSpacing:"tighter",children:["Xray ",o.xray_version]})}),o.status&&e(lt,{status:f,compact:!0})]})]}),e(vt,{})]}),r(Oe,{px:2,pb:2,children:[e(M,{pb:3,alignItems:"flex-start",children:f==="error"&&e(qe,{status:"error",size:"xs",children:r(v,{children:[r(w,{w:"full",children:[e(ht,{w:4}),e(u,{marginInlineEnd:0,children:o.message})]}),e(w,{justifyContent:"flex-end",w:"full",children:e(N,{size:"sm","aria-label":"reconnect node",leftIcon:e(Yr,{}),onClick:()=>_(),disabled:C,children:a(C?"nodes.reconnecting":"nodes.reconnect")})})]})})}),e(Kr,{form:p,mutate:c,isLoading:d,submitBtnText:a("nodes.editNode"),btnLeftAdornment:e(te,{label:a("delete"),placement:"top",children:e($,{colorScheme:"red",variant:"ghost",size:"sm","aria-label":"delete node",onClick:y,children:e(tt,{})})})})]})]})},Ps=({toggleAccordion:t,resetAccordions:o})=>{const n=ue(),{t:s}=O(),i=At(),{addNode:a}=rt(),l=je({resolver:Ke(Jr),defaultValues:{...Es(),add_as_new_host:!0}}),{isLoading:h,mutate:p}=Qe(a,{onSuccess:()=>{Pt(s("nodes.addNodeSuccess",{name:l.getValues("name")}),n),i.invalidateQueries(Xe),l.reset(),o()},onError:y=>{Ft(y,n,l)}});return r(Pe,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[e(We,{px:2,borderRadius:"3px",onClick:t,children:r(u,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},display:"flex",gap:1,children:[e(Ns,{display:"inline-block"})," ",e("span",{children:s("nodes.addNewMarzbanNode")})]})}),e(Oe,{px:2,py:4,children:e(Kr,{form:l,mutate:p,isLoading:h,submitBtnText:s("nodes.addNode"),btnProps:{variant:"solid"},addAsHost:!0})})]})},Kr=({form:t,mutate:o,isLoading:n,submitBtnText:s,btnProps:i={},btnLeftAdornment:a,addAsHost:l=!1})=>{var _,f,S,L,m,b,P,H,U,A,B,Y;const{t:h}=O(),[p,y]=g.exports.useState(!1),{data:d,isLoading:c}=Rt({queryKey:"node-settings",queryFn:()=>W("/node/settings")});function C(z){if(document.body.createTextRange){const F=document.body.createTextRange();F.moveToElementText(z),F.select()}else if(window.getSelection){const F=window.getSelection(),Z=document.createRange();Z.selectNodeContents(z),F.removeAllRanges(),F.addRange(Z)}else console.warn("Could not select text in node: Unsupported browser.")}return e("form",{onSubmit:t.handleSubmit(z=>o(z)),children:r(M,{children:[d&&d.certificate&&e(qe,{status:"info",alignItems:"start",children:r(Lr,{display:"flex",flexDirection:"column",overflow:"hidden",children:[e("span",{children:h("nodes.connection-hint")}),r(w,{justify:"end",py:2,children:[e(N,{as:"a",colorScheme:"primary",size:"xs",download:"ssl_client_cert.pem",href:URL.createObjectURL(new Blob([d.certificate],{type:"text/plain"})),children:h("nodes.download-certificate")}),e(te,{placement:"top",label:h("nodes.show-certificate"),children:e($,{"aria-label":h("nodes.show-certificate"),onClick:y.bind(null,!p),colorScheme:"whiteAlpha",color:"primary",size:"xs",children:p?e(Vo,{width:"15px"}):e($o,{width:"15px"})})})]}),e(Tr,{in:p,animateOpacity:!0,children:e(u,{bg:"rgba(255,255,255,.5)",_dark:{bg:"rgba(255,255,255,.2)"},rounded:"md",p:"2",lineHeight:"1.2",fontSize:"10px",fontFamily:"Courier",whiteSpace:"pre",overflow:"auto",onClick:z=>{C(z.target)},children:d.certificate})})]})}),r(w,{w:"full",children:[e(T,{children:e(it,{label:h("nodes.nodeName"),size:"sm",placeholder:"Marzban-S2",...t.register("name"),error:(S=(f=(_=t.formState)==null?void 0:_.errors)==null?void 0:f.name)==null?void 0:S.message})}),e(w,{px:1,children:e(ze,{name:"status",control:t.control,render:({field:z})=>e(te,{placement:"top",label:`${h("usersTable.status")}: `+(z.value!=="disabled"?h("active"):h("disabled")),textTransform:"capitalize",children:e(v,{mt:"6",children:e(Ar,{colorScheme:"primary",isChecked:z.value!=="disabled",onChange:F=>{F.target.checked?z.onChange("connecting"):z.onChange("disabled")}})})},z.value)})})]}),r(w,{alignItems:"flex-start",children:[e(v,{w:"50%",children:e(it,{label:h("nodes.nodeAddress"),size:"sm",placeholder:"51.20.12.13",...t.register("address"),error:(b=(m=(L=t.formState)==null?void 0:L.errors)==null?void 0:m.address)==null?void 0:b.message})}),e(v,{w:"25%",children:e(it,{label:h("nodes.nodePort"),size:"sm",placeholder:"62050",...t.register("port"),error:(U=(H=(P=t.formState)==null?void 0:P.errors)==null?void 0:H.port)==null?void 0:U.message})}),e(v,{w:"25%",children:e(it,{label:h("nodes.nodeAPIPort"),size:"sm",placeholder:"62051",...t.register("api_port"),error:(Y=(B=(A=t.formState)==null?void 0:A.errors)==null?void 0:B.api_port)==null?void 0:Y.message})})]}),l&&e(T,{py:1,children:e(Mr,{...t.register("add_as_new_host"),children:e(G,{m:0,children:h("nodes.addHostForEveryInbound")})})}),r(w,{w:"full",children:[a,e(N,{flexGrow:1,type:"submit",colorScheme:"primary",size:"sm",px:5,w:"full",isLoading:n,...i,children:s})]})]})})},Ws=()=>{const{isEditingNodes:t,onEditingNodes:o}=I(),{t:n}=O(),[s,i]=g.exports.useState({}),{data:a,isLoading:l}=Rs(),h=()=>{i({}),o(!1)},p=y=>{s[String(y)]?delete s[String(y)]:s[String(y)]={},i({...s})};return r(me,{children:[r(re,{isOpen:t,onClose:h,children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(se,{pt:6,children:e(le,{color:"primary",children:e(Ms,{color:"white"})})}),e(ie,{mt:3}),r(ae,{w:"440px",pb:6,pt:3,children:[e(u,{mb:3,opacity:.8,fontSize:"sm",children:n("nodes.title")}),l&&"loading...",e(et,{w:"full",allowToggle:!0,index:Object.keys(s).map(y=>parseInt(y)),children:r(M,{w:"full",children:[!l&&a&&a.map((y,d)=>e(Fs,{toggleAccordion:()=>p(d),node:y},y.name)),e(Ps,{toggleAccordion:()=>p((a||[]).length),resetAccordions:()=>i({})})]})})]})]})]}),e(Ls,{deleteCallback:()=>i({})})]})};function Os(t){const o=360/t,n=90,s=47,i=[];for(let a=0;a(C<0&&(C+=1),C>1&&(C-=1),C<.16666666666666666?d+(c-d)*6*C:C<.5?c:C<.6666666666666666?d+(c-d)*(.6666666666666666-C)*6:d),p=n<.5?n*(1+o):n+o-n*o,y=2*n-p;s=Math.round(h(y,p,t+1/3)*255),i=Math.round(h(y,p,t)*255),a=Math.round(h(y,p,t-1/3)*255)}const l=h=>{const p=h.toString(16);return p.length===1?"0"+p:p};return`#${l(s)}${l(i)}${l(a)}`}const dr=({border:t,...o})=>{const{getInputProps:n,getRadioProps:s}=Jo(o),i=De({base:"xs",md:"sm"});return r(v,{as:"label",children:[e("input",{...n()}),e(v,{...s(),minW:"48px",w:"full",h:"full",textAlign:"center",cursor:"pointer",fontSize:i,borderWidth:t?"1px":"0px",borderRadius:"md",_checked:{bg:"primary.500",color:"white",borderColor:"primary.500"},_focus:{boxShadow:"outline"},px:3,py:1,children:o.children})]})},eo=({onChange:t,defaultValue:o,...n})=>{const{t:s,i18n:i}=O();Je();const a=De({base:["7h","1d","3d","1w"],md:["7h","1d","3d","1w","1m","3m"]}),l={h:"hour",d:"day",w:"week",m:"month",y:"year"},h=De({base:[{title:"hours",options:["1h","3h","6h","12h"]},{title:"days",options:["1d","2d","3d","4d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m"]}],md:[{title:"hours",options:["1h","2h","3h","6h","8h","12h"]},{title:"days",options:["1d","2d","3d","4d","5d","6d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m","8m"]}]}),{getRootProps:p,getRadioProps:y,setValue:d}=Go({name:"filter",defaultValue:o,onChange:R=>{if(R==="custom")return;_(),a.indexOf(R)>=0?(L(s("userDialog.custom")),b(!1)):(L(s("userDialog.custom")+` (${R})`),b(!0));const Q=Number(R.substring(0,R.length-1)),K=l[R[R.length-1]];t(R,{start:j().utc().subtract(Q,K).format("YYYY-MM-DDTHH:00:00")})}}),{isOpen:c,onOpen:C,onClose:_}=Yo(),f=g.exports.useRef(null);Zo({ref:f,handler:_});const[S,L]=g.exports.useState(s("userDialog.custom")),[m,b]=g.exports.useState(!1),[P,H]=g.exports.useState(0),U=De({base:1,md:2}),A=De({base:"xs",md:"sm"}),[B,Y]=g.exports.useState(null),[z,F]=g.exports.useState(null),Z=R=>{const[Q,K]=R;z&&!K?(Y(null),F(null)):(Y(Q),F(K),Q&&K&&(_(),t("custom",{start:j(Q).format("YYYY-MM-DDT00:00:00"),end:j(K).format("YYYY-MM-DDT23:59:59")})))};return r(M,{...n,children:[P==0&&r(Mt,{...p(),gap:0,display:"flex",borderWidth:"1px",borderRadius:"md",minW:{base:"320px",md:"400px"},children:[a.map(R=>e(dr,{...y({value:R}),children:R},R)),e(v,{onClick:()=>{Y(null),F(null),C()},cursor:"pointer",borderRadius:"md",w:"full",fontSize:A,px:3,py:1,bg:m?"primary.500":"unset",color:m?"white":"unset",borderColor:m?"primary.500":"unset",children:r(w,{children:[e(u,{children:S}),e(St,{as:qt,boxSize:"18px"})]})})]}),P==1&&r(w,{onClick:C,cursor:"pointer",fontSize:A,borderRadius:"md",px:3,py:1,minW:{base:"320px",md:"400px"},borderWidth:"1px",children:[e(u,{w:"full",color:B?"unset":"gray.500",children:B?j(B).format("YYYY-MM-DD (00:00)"):s("userDialog.startDate")}),e(St,{as:Nr,boxSize:"18px"}),e(u,{w:"full",color:z?"unset":"gray.500",children:z?j(z).format("YYYY-MM-DD (23:59)"):s("userDialog.endDate")}),e(St,{as:qt,boxSize:"18px"})]}),e(M,{ref:f,marginTop:"40px !important",borderRadius:"md",borderWidth:"1px",position:"absolute",zIndex:"1",backgroundColor:"white",_dark:{backgroundColor:"gray.700"},display:c?"unset":"none",children:r(Qo,{onChange:R=>H(R),children:[r(qo,{children:[e(Xt,{fontSize:A,children:s("userDialog.relative")}),e(Xt,{fontSize:A,children:s("userDialog.absolute")})]}),r(Xo,{children:[e(Jt,{children:h.map(R=>e(M,{alignItems:"start",pl:2,pr:2,children:r(w,{justifyItems:"flex-start",mb:4,children:[e(u,{fontSize:A,minW:"60px",children:s("userDialog."+R.title)}),R.options.map(Q=>e(dr,{border:!0,...y({value:Q}),children:Q},Q+".custom"))]})},R.title))}),e(Jt,{className:"datepicker-panel",children:e(M,{children:e(Fr,{locale:i.language.toLocaleLowerCase(),selected:B,onChange:Z,startDate:B,endDate:z,selectsRange:!0,maxDate:new Date,monthsShown:U,peekNextMonth:!1,inline:!0})})})]})]})})]})};function mt(t,o,n=[],s=[]){const i=ee(n.reduce((a,l)=>a+=l,0));return{series:n,options:{labels:s,chart:{width:"100%",height:"100%",type:"donut",animations:{enabled:!1}},title:{text:`${o}${i}`,align:"center",style:{fontWeight:"var(--chakra-fontWeights-medium)",color:t==="dark"?"var(--chakra-colors-gray-300)":void 0}},legend:{position:"bottom",labels:{colors:t==="dark"?"#CBD5E0":void 0,useSeriesColors:!1}},stroke:{width:1,colors:void 0},dataLabels:{formatter:(a,{seriesIndex:l,w:h})=>ee(h.config.series[l],1)},tooltip:{custom:({series:a,seriesIndex:l,dataPointIndex:h,w:p})=>{const y=ee(a[l],1),d=Math.max(a.reduce((C,_)=>C+=_),1),c=Math.round(a[l]/d*1e3)/10+"%";return` +import{i as _t,B as to,a as ro,b as oo,j as yr,d as j,U as Et,z as no,r as so,f as ao,Q as io,e as lo,$ as co,c as gt,g as x,h as uo,C as ho,k as ft,u as Rt,l as O,m as r,H as w,n as e,T as u,o as po,p as v,s as mo,q as g,t as Je,J as go,v as Sr,A as bt,w as fo,x as bo,M as re,y as oe,D as ne,E as se,F as ae,G as ue,I as je,K as Cr,L as xo,N as Qe,O as ie,P as T,R as G,S as wr,V as te,W as E,X as ze,Y as $,Z as be,_ as N,a0 as xt,a1 as Ve,a2 as yo,a3 as fe,a4 as Re,a5 as So,a6 as kr,a7 as _r,a8 as Ye,a9 as ct,aa as Co,ab as Fe,ac as dt,ad as Yt,ae as wo,af as Ir,ag as vr,ah as zr,ai as de,aj as ko,ak as _o,al as Io,am as vo,an as zo,ao as Lt,ap as Dr,aq as Ur,ar as me,as as Zt,at as Do,au as Uo,av as Eo,aw as It,ax as Ro,ay as Lo,az as To,aA as Ao,aB as Mo,aC as No,aD as ut,aE as Fo,aF as Ee,aG as Wo,aH as k,aI as Ke,aJ as Er,aK as et,aL as M,aM as Tt,aN as Po,aO as We,aP as Pe,aQ as vt,aR as Oe,aS as ye,aT as Se,aU as Ce,aV as we,aW as ke,aX as _e,aY as Qt,aZ as At,a_ as Oo,a$ as jo,b0 as Ho,b1 as Rr,b2 as Bo,b3 as qe,b4 as ht,b5 as Lr,b6 as $o,b7 as Vo,b8 as Tr,b9 as Ar,ba as Mr,bb as De,bc as Go,bd as Yo,be as Zo,bf as Mt,bg as St,bh as qt,bi as Nr,bj as Qo,bk as qo,bl as Xt,bm as Xo,bn as Jt,bo as Fr,bp as Jo,bq as Wr,br as Ko,bs as en,bt as Pr,bu as tn,bv as rn,bw as Or,bx as jr,by as Hr,bz as X,bA as on,bB as Br,bC as nn,bD as sn,bE as an,bF as ln,bG as cn,bH as dn,bI as un,bJ as $r,bK as hn,bL as Kt,bM as er,bN as Me,bO as ge,bP as tr,bQ as ce,bR as rr,bS as pn,bT as mn,bU as gn,bV as fn,bW as bn,bX as xn,bY as yn,bZ as Sn,b_ as Cn,b$ as wn,c0 as kn,c1 as _n,c2 as In,c3 as vn,c4 as zn,c5 as Dn,c6 as Un}from"./vendor.764109dc.js";(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerpolicy&&(i.referrerPolicy=a.referrerpolicy),a.crossorigin==="use-credentials"?i.credentials="include":a.crossorigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();_t.use(to).use(ro).use(oo).init({debug:{}.NODE_ENV==="development",returnNull:!1,fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1},load:"languageOnly",detection:{caches:["localStorage","sessionStorage","cookie"]},backend:{loadPath:yr(["/dashboard/","locales/{{lng}}.json"])}},function(t,o){j.locale(_t.language)});_t.on("languageChanged",t=>{j.locale(t)});Et("zh-cn",no);Et("ru",so);Et("fa",ao);const zt=new io,Vr=t=>{const o=document.querySelector('meta[name="theme-color"]');o==null||o.setAttribute("content",t=="dark"?"#1A202C":"#3B81F6")},En=lo({shadows:{outline:"0 0 0 2px var(--chakra-colors-primary-200)"},fonts:{body:"Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif"},colors:{"light-border":"#d2d2d4",primary:{50:"#9cb7f2",100:"#88a9ef",200:"#749aec",300:"#618ce9",400:"#4d7de7",500:"#396fe4",600:"#3364cd",700:"#2e59b6",800:"#284ea0",900:"#224389"},gray:{750:"#222C3B"}},components:{Alert:{baseStyle:{container:{borderRadius:"6px",fontSize:"sm"}}},Select:{baseStyle:{field:{_dark:{borderColor:"gray.600",borderRadius:"6px"},_light:{borderRadius:"6px"}}}},FormHelperText:{baseStyle:{fontSize:"xs"}},FormLabel:{baseStyle:{fontSize:"sm",fontWeight:"medium",mb:"1",_dark:{color:"gray.300"}}},Input:{baseStyle:{addon:{_dark:{borderColor:"gray.600",_placeholder:{color:"gray.500"}}},field:{_focusVisible:{boxShadow:"none",borderColor:"primary.200",outlineColor:"primary.200"},_dark:{borderColor:"gray.600",_disabled:{color:"gray.400",borderColor:"gray.500"},_placeholder:{color:"gray.500"}}}}},Table:{baseStyle:{table:{borderCollapse:"separate",borderSpacing:0},thead:{borderBottomColor:"light-border"},th:{background:"#F9FAFB",borderColor:"light-border !important",borderBottomColor:"light-border !important",borderTop:"1px solid ",borderTopColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border !important"},_last:{borderRight:"1px solid",borderColor:"light-border !important"},_dark:{borderColor:"gray.600 !important",background:"gray.750"}},td:{transition:"all .1s ease-out",borderColor:"light-border",borderBottomColor:"light-border !important",_first:{borderLeft:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_last:{borderRight:"1px solid",borderColor:"light-border",_dark:{borderColor:"gray.600"}},_dark:{borderColor:"gray.600",borderBottomColor:"gray.600 !important"}},tr:{"&.interactive":{cursor:"pointer",_hover:{"& > td":{bg:"gray.200"},_dark:{"& > td":{bg:"gray.750"}}}},_last:{"& > td":{_first:{borderBottomLeftRadius:"8px"},_last:{borderBottomRightRadius:"8px"}}}}}}}});const pt=()=>localStorage.getItem("token"),Rn=t=>{localStorage.setItem("token",t)},Ln=()=>{localStorage.removeItem("token")},Tn=co.create({baseURL:"/api/"}),An=(t,o={})=>(pt()&&(o.headers={...(o==null?void 0:o.headers)||{},Authorization:`Bearer ${pt()}`}),Tn(t,o)),P=An,Mn=gt(t=>({isLoading:!0,isPostLoading:!1,version:null,started:!1,logs_websocket:null,config:"",fetchCoreSettings:()=>{t({isLoading:!0}),Promise.all([P("/core").then(({version:o,started:n,logs_websocket:s})=>t({version:o,started:n,logs_websocket:s})),P("/core/config").then(o=>t({config:o}))]).finally(()=>t({isLoading:!1}))},updateConfig:o=>(t({isPostLoading:!0}),P("/core/config",{method:"PUT",body:o}).finally(()=>{t({isPostLoading:!1})})),restartCore:()=>P("/core/restart",{method:"POST"})}));function ee(t,o=2,n=!1){if(!+t)return"0 B";const s=1024,a=o<0?0:o,i=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(t)/Math.log(s));return n?[parseFloat((t/Math.pow(s,l)).toFixed(a)),i[l]]:`${parseFloat((t/Math.pow(s,l)).toFixed(a))} ${i[l]}`}const or=t=>{if(t!==null)return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Nn=x(uo,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Fn=x(ho,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Wn=x(ft,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Ct=({title:t,content:o,icon:n})=>r(po,{p:6,borderWidth:"1px",borderColor:"light-border",bg:"#F9FAFB",_dark:{borderColor:"gray.600",bg:"gray.750"},borderStyle:"solid",boxShadow:"none",borderRadius:"12px",width:"full",display:"flex",justifyContent:"space-between",flexDirection:"row",children:[r(w,{alignItems:"center",columnGap:"4",children:[e(v,{p:"2",position:"relative",color:"white",_before:{content:'""',position:"absolute",top:0,left:0,bg:"primary.400",display:"block",w:"full",h:"full",borderRadius:"5px",opacity:".5",z:"1"},_after:{content:'""',position:"absolute",top:"-5px",left:"-5px",bg:"primary.400",display:"block",w:"calc(100% + 10px)",h:"calc(100% + 10px)",borderRadius:"8px",opacity:".4",z:"1"},children:n}),e(u,{color:"gray.600",_dark:{color:"gray.300"},fontWeight:"medium",textTransform:"capitalize",fontSize:"sm",children:t})]}),e(v,{fontSize:"3xl",fontWeight:"semibold",mt:"2",children:o})]}),Dt="statistics-query-key",Pn=t=>{const{version:o}=I(),{data:n}=Rt({queryKey:Dt,queryFn:()=>P("/system"),refetchInterval:5e3,onSuccess:({version:a})=>{o!==a&&I.setState({version:a})}}),{t:s}=O();return r(w,{justifyContent:"space-between",gap:0,columnGap:{lg:4,md:0},rowGap:{lg:0,base:4},display:"flex",flexDirection:{lg:"row",base:"column"},...t,children:[e(Ct,{title:s("activeUsers"),content:n&&r(w,{alignItems:"flex-end",children:[e(u,{children:or(n.users_active)}),r(u,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:["/ ",or(n.total_user)]})]}),icon:e(Nn,{})}),e(Ct,{title:s("dataUsage"),content:n&&ee(n.incoming_bandwidth+n.outgoing_bandwidth),icon:e(Fn,{})}),e(Ct,{title:s("memoryUsage"),content:n&&r(w,{alignItems:"flex-end",children:[e(u,{children:ee(n.mem_used,1,!0)[0]}),r(u,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:[ee(n.mem_used,1,!0)[1]," /"," ",ee(n.mem_total,1)]})]}),icon:e(Wn,{})})]})},Gr="marzban-num-users-per-page",nr=10,On=()=>{const t=localStorage.getItem(Gr)||nr.toString();return parseInt(t)||nr},jn=t=>localStorage.setItem(Gr,t),Hn=t=>{for(const o in t)t[o]||delete t[o];return I.setState({loading:!0}),P("/users",{query:t}).then(o=>(I.setState({users:o}),o)).finally(()=>{I.setState({loading:!1})})},Bn=()=>P("/inbounds").then(t=>{I.setState({inbounds:new Map(Object.entries(t))})}).finally(()=>{I.setState({loading:!1})}),I=gt(mo((t,o)=>({version:null,editingUser:null,deletingUser:null,isCreatingNewUser:!1,QRcodeLinks:null,subscribeUrl:null,users:{users:[],total:0},loading:!0,isResetingAllUsage:!1,isEditingHosts:!1,isEditingNodes:!1,isShowingNodesUsage:!1,resetUsageUser:null,revokeSubscriptionUser:null,filters:{username:"",limit:On(),sort:"-created_at"},inbounds:new Map,isEditingCore:!1,refetchUsers:()=>{Hn(o().filters)},resetAllUsage:()=>P("/users/reset",{method:"POST"}).then(()=>{o().onResetAllUsage(!1),o().refetchUsers()}),onResetAllUsage:n=>t({isResetingAllUsage:n}),onCreateUser:n=>t({isCreatingNewUser:n}),onEditingUser:n=>{t({editingUser:n})},onDeletingUser:n=>{t({deletingUser:n})},onFilterChange:n=>{t({filters:{...o().filters,...n}}),o().refetchUsers()},setQRCode:n=>{t({QRcodeLinks:n})},deleteUser:n=>(t({editingUser:null}),P(`/user/${n.username}`,{method:"DELETE"}).then(()=>{t({deletingUser:null}),o().refetchUsers(),zt.invalidateQueries(Dt)})),createUser:n=>P("/user",{method:"POST",body:n}).then(()=>{t({editingUser:null}),o().refetchUsers(),zt.invalidateQueries(Dt)}),editUser:n=>P(`/user/${n.username}`,{method:"PUT",body:n}).then(()=>{o().onEditingUser(null),o().refetchUsers()}),fetchUserUsage:(n,s)=>{for(const a in s)s[a]||delete s[a];return P(`/user/${n.username}/usage`,{method:"GET",query:s})},onEditingHosts:n=>{t({isEditingHosts:n})},onEditingNodes:n=>{t({isEditingNodes:n})},onShowingNodesUsage:n=>{t({isShowingNodesUsage:n})},setSubLink:n=>{t({subscribeUrl:n})},resetDataUsage:n=>P(`/user/${n.username}/reset`,{method:"POST"}).then(()=>{t({resetUsageUser:null}),o().refetchUsers()}),revokeSubscription:n=>P(`/user/${n.username}/revoke_sub`,{method:"POST"}).then(s=>{t({revokeSubscriptionUser:null,editingUser:s}),o().refetchUsers()})}))),le=({children:t,color:o})=>e(v,{position:"relative",width:"36px",height:"36px",display:"flex",justifyContent:"center",alignItems:"center",_before:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100%)",height:"calc(100%)",bg:`${o}.400`,opacity:".5",borderRadius:"5px",zIndex:"1",_dark:{bg:`${o}.400`}},_after:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100% + 10px)",height:"calc(100% + 10px)",transform:"translate(-5px, -5px)",bg:`${o}.400`,opacity:".4",borderRadius:"8px",zIndex:"1",_dark:{bg:`${o}.400`}},children:e(u,{color:`${o}.500`,_dark:{color:`${o}.900`},position:"relative",zIndex:"2",children:t})});window.ace.define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"],(t,o,n)=>{o.isDark=!0,o.cssClass="ace-nord-dark",t("../lib/dom").importCssString(o.cssText,o.cssClass)});window.ace.define("ace/theme/dawn",["require","exports","module","ace/lib/dom"],(t,o,n)=>{o.isDark=!1,o.cssClass="ace-dawn",t("../lib/dom").importCssString(o.cssText,o.cssClass)});const $n=g.exports.forwardRef(({json:t,onChange:o,mode:n="code"},s)=>{const{colorMode:a}=Je(),i={mode:n,onChangeText:o,statusBar:!1,mainMenuBar:!1,theme:a==="dark"?"ace/theme/nord_dark":"ace/theme/dawn"},l=g.exports.useRef(null),h=g.exports.useRef(null);return g.exports.useEffect(()=>(h.current=new go(l.current,i),()=>{h.current&&h.current.destroy()}),[]),g.exports.useEffect(()=>{h.current&&h.current.update(t)},[t]),e(v,{ref:s,border:"1px solid",borderColor:"gray.300",_dark:{borderColor:"gray.500"},borderRadius:5,h:"full",children:e(v,{height:"full",ref:l})})}),sr=500,Vn=x(Sr,{baseStyle:{w:5,h:5}}),Gn=x(bt,{baseStyle:{w:4,h:4}}),Yn=x(fo,{baseStyle:{w:4,h:4}}),Zn=x(bo,{baseStyle:{w:3,h:3}}),Qn=t=>({[Ve.ReadyState.CONNECTING]:"connecting",[Ve.ReadyState.OPEN]:"connected",[Ve.ReadyState.CLOSING]:"closed",[Ve.ReadyState.CLOSED]:"closed",[Ve.ReadyState.UNINSTANTIATED]:"closed"})[t],qn=()=>{try{let t=new URL("/api/".startsWith("/")?window.location.origin+"/api/":"/api/");return(t.protocol==="https:"?"wss://":"ws://")+yr([t.host+t.pathname,"/core/logs"])+"?interval=1&token="+pt()}catch(t){return console.error("Unable to generate websocket url"),console.error(t),null}};let Ie=[];const Xn=()=>{const{isEditingCore:t}=I(),{fetchCoreSettings:o,updateConfig:n,isLoading:s,config:a,isPostLoading:i,version:l,restartCore:h}=Mn(),p=g.exports.useRef(null),[y,d]=g.exports.useState([]),{t:c}=O(),C=ue(),_=je({defaultValues:{config:a||{}}});g.exports.useEffect(()=>{a&&_.setValue("config",a)},[a]),g.exports.useEffect(()=>{t&&o()},[t]);const f=g.exports.useRef(!0),S=g.exports.useCallback(Cr(z=>{var Z,R,Q;const F=Math.abs((((Z=p.current)==null?void 0:Z.scrollTop)||0)-(((R=p.current)==null?void 0:R.scrollHeight)||0)+(((Q=p.current)==null?void 0:Q.offsetHeight)||0))<10;p.current&&F?f.current=!0:f.current=!1,z.length<40&&d(z)},300),[]),{readyState:L}=xo(qn(),{onMessage:z=>{Ie.push(z.data),Ie.length>sr&&(Ie=Ie.splice(0,Ie.length-sr)),S([...Ie])},shouldReconnect:()=>!0,reconnectAttempts:10,reconnectInterval:1e3});g.exports.useEffect(()=>{var z;p.current&&f.current&&(p.current.scrollTop=(z=p.current)==null?void 0:z.scrollHeight)},[y]),g.exports.useEffect(()=>()=>{Ie=[]},[]);const m=Qn(L.toString()),{mutate:b,isLoading:W}=Qe(h),H=({config:z})=>{n(z).then(()=>{C({title:c("core.successMessage"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(F=>{let Z=c("core.generalErrorMessage");typeof F.response._data.detail=="object"&&(Z=F.response._data.detail[Object.keys(F.response._data.detail)[0]]),typeof F.response._data.detail=="string"&&(Z=F.response._data.detail),C({title:Z,status:"error",isClosable:!0,position:"top",duration:3e3})})},U=g.exports.useRef(null),[A,B]=g.exports.useState(!1),Y=()=>{var z;document.fullscreenElement?(document.exitFullscreen(),B(!1)):((z=U.current)==null||z.requestFullscreen(),B(!0))};return r("form",{onSubmit:_.handleSubmit(H),children:[r(ie,{children:[r(T,{children:[r(w,{justifyContent:"space-between",alignItems:"flex-start",children:[r(G,{children:[c("core.configuration")," ",s&&e(wr,{isIndeterminate:!0,size:"15px"})]}),e(w,{gap:0,children:e(te,{label:"Xray Version",placement:"top",children:e(E,{height:"100%",textTransform:"lowercase",children:l&&`v${l}`})})})]}),r(v,{position:"relative",ref:U,minHeight:"300px",children:[e(ze,{control:_.control,name:"config",render:({field:z})=>e($n,{json:a,onChange:z.onChange})}),e($,{size:"xs","aria-label":"full screen",variant:"ghost",position:"absolute",top:"2",right:"4",onClick:Y,children:A?e(Zn,{}):e(Yn,{})})]})]}),r(T,{mt:"4",children:[r(w,{justifyContent:"space-between",children:[e(G,{children:c("core.logs")}),e(u,{as:G,children:c(`core.socket.${m}`)})]}),e(v,{border:"1px solid",borderColor:"gray.300",bg:"#F9F9F9",_dark:{borderColor:"gray.500",bg:"#2e3440"},borderRadius:5,minHeight:"200px",maxHeight:"250px",p:2,overflowY:"auto",ref:p,children:y.map((z,F)=>e(u,{fontSize:"xs",opacity:.8,whiteSpace:"pre-line",children:z},F))})]})]}),e(be,{children:r(w,{w:"full",justifyContent:"space-between",children:[e(v,{children:e(N,{size:"sm",leftIcon:e(Gn,{className:xt({"animate-spin":W})}),onClick:()=>b(),children:c(W?"core.restarting":"core.restartCore")})}),e(w,{children:e(N,{size:"sm",variant:"solid",colorScheme:"primary",px:"5",type:"submit",isDisabled:s||i,isLoading:i,children:c("core.save")})})]})})]})},Jn=()=>{const{isEditingCore:t}=I(),o=I.setState.bind(null,{isEditingCore:!1}),{t:n}=O();return r(re,{isOpen:t,onClose:o,size:"3xl",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"full",children:[e(se,{pt:6,children:r(w,{gap:2,children:[e(le,{color:"primary",children:e(Vn,{color:"white"})}),e(u,{fontWeight:"semibold",fontSize:"lg",children:n("core.title")})]})}),e(ae,{mt:3}),e(Xn,{})]})]})},tt=x(yo,{baseStyle:{w:5,h:5}}),Kn=()=>{const[t,o]=g.exports.useState(!1),{deletingUser:n,onDeletingUser:s,deleteUser:a}=I(),{t:i}=O(),l=ue(),h=()=>{s(null)},p=()=>{n&&(o(!0),a(n).then(()=>{l({title:i("deleteUser.deleteSuccess",{username:n.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).then(h).finally(o.bind(null,!1)))};return r(re,{isCentered:!0,isOpen:!!n,onClose:h,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"red",children:e(tt,{})})}),e(ae,{mt:3}),r(ie,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:i("deleteUser.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:i("deleteUser.prompt",{username:n.username})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:h,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Re,{size:"xs"}):void 0,children:i("delete")})]})]})]})},Nt={baseStyle:{w:4,h:4}},es=x(So,Nt),ts=x(kr,Nt),Yr=x(bt,Nt),rs=Cr(t=>{I.getState().onFilterChange({...I.getState().filters,offset:0,username:t})},300),os=({...t})=>{const{loading:o,filters:n,onFilterChange:s,refetchUsers:a,onCreateUser:i}=I(),{t:l}=O(),[h,p]=g.exports.useState(""),y=c=>{p(c.target.value),rs(c.target.value)},d=()=>{p(""),s({...n,offset:0,username:""})};return r(_r,{id:"filters",templateColumns:{lg:"repeat(3, 1fr)",md:"repeat(4, 1fr)",base:"repeat(1, 1fr)"},position:"sticky",top:0,mx:"-6",px:"6",rowGap:4,gap:{lg:4,base:0},bg:"var(--chakra-colors-chakra-body-bg)",py:4,zIndex:"docked",...t,children:[e(Ye,{colSpan:{base:1,md:2,lg:1},order:{base:2,md:1},children:r(ct,{children:[e(Co,{pointerEvents:"none",children:e(es,{})}),e(Fe,{placeholder:l("search"),value:h,borderColor:"light-border",onChange:y}),r(dt,{children:[o&&e(Re,{size:"xs"}),n.username&&n.username.length>0&&e($,{onClick:d,"aria-label":"clear",size:"xs",variant:"ghost",children:e(ts,{})})]})]})}),e(Ye,{colSpan:2,order:{base:1,md:2},children:r(w,{justifyContent:"flex-end",alignItems:"center",h:"full",children:[e($,{"aria-label":"refresh users",disabled:o,onClick:a,size:"sm",variant:"outline",children:e(Yr,{className:xt({"animate-spin":o})})}),e(N,{colorScheme:"primary",size:"sm",onClick:()=>i(!0),px:5,children:l("createUser")})]})})]})},Zr="https://github.com/Gozargah/Marzban",ns="https://github.com/Gozargah",ss="https://github.com/Gozargah/Marzban#donation",Qr=t=>{const{version:o}=I();return e(w,{w:"full",py:"0",position:"relative",...t,children:r(u,{display:"inline-block",flexGrow:1,textAlign:"center",color:"gray.500",fontSize:"xs",children:[e(Yt,{color:"blue.400",href:Zr,children:"Marzban"}),o?` (v${o}), `:", ","Made with \u2764\uFE0F in"," ",e(Yt,{color:"blue.400",href:ns,children:"Gozargah"})]})})},as=x(wo,{baseStyle:{w:4,h:4}}),qr=({actions:t})=>{const{i18n:o}=O();var n=s=>{o.changeLanguage(s)};return r(Ir,{placement:"bottom-end",children:[e(vr,{as:$,size:"sm",variant:"outline",icon:e(as,{}),position:"relative"}),r(zr,{minW:"100px",zIndex:9999,children:[e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("en"),children:"English"}),e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("fa"),children:"\u0641\u0627\u0631\u0633\u06CC"}),e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("zh-cn"),children:"\u7B80\u4F53\u4E2D\u6587"}),e(de,{maxW:"100px",fontSize:"sm",onClick:()=>n("ru"),children:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"})]})]})},he={baseStyle:{w:4,h:4}},is=x(ko,he),ls=x(_o,he),cs=x(Sr,he),ds=x(Io,he),us=x(vo,he),hs=x(zo,he),ps=x(Lt,he),ms=x(Dr,he),gs=x(ft,he),fs=x(Ur,he),ar=x(v,{baseStyle:{bg:"yellow.500",w:"2",h:"2",rounded:"full",position:"absolute"}}),Xr="marzban-menu-notification",bs=()=>{const t=localStorage.getItem(Xr);if(!t)return!0;try{return t&&Uo(parseInt(t))?Eo(new Date,new Date(parseInt(t)))>=7:!0}catch{return!0}},xs=({actions:t})=>{const{onEditingHosts:o,onResetAllUsage:n,onEditingNodes:s,onShowingNodesUsage:a}=I(),{t:i}=O(),{colorMode:l,toggleColorMode:h}=Je(),[p,y]=g.exports.useState(bs()),d=l==="dark"?"dark_dimmed":l,c=()=>{localStorage.setItem(Xr,new Date().getTime().toString()),y(!1)};return r(w,{gap:2,justifyContent:"space-between",__css:{"& .menuList":{direction:"ltr"}},position:"relative",children:[e(u,{as:"h1",fontWeight:"semibold",fontSize:"2xl",children:i("users")}),p&&e(ar,{top:"0",right:"0",zIndex:9999}),e(v,{overflow:"auto",css:{direction:"rtl"},children:r(w,{alignItems:"center",children:[r(Ir,{children:[e(vr,{as:$,size:"sm",variant:"outline",icon:e(me,{children:e(ds,{})}),position:"relative"}),r(zr,{minW:"170px",zIndex:99999,className:"menuList",children:[e(de,{maxW:"170px",fontSize:"sm",icon:e(ps,{}),onClick:o.bind(null,!0),children:i("header.hostSettings")}),e(de,{maxW:"170px",fontSize:"sm",icon:e(ms,{}),onClick:s.bind(null,!0),children:i("header.nodeSettings")}),e(de,{maxW:"170px",fontSize:"sm",icon:e(gs,{}),onClick:a.bind(null,!0),children:i("header.nodesUsage")}),e(de,{maxW:"170px",fontSize:"sm",icon:e(fs,{}),onClick:n.bind(null,!0),children:i("resetAllUsage")}),e(Zt,{to:ss,target:"_blank",children:r(de,{maxW:"170px",fontSize:"sm",icon:e(hs,{}),position:"relative",onClick:c,children:[i("header.donation")," ",p&&e(ar,{top:"3",right:"2"})]})}),e(Zt,{to:"/login",children:e(de,{maxW:"170px",fontSize:"sm",icon:e(us,{}),children:i("header.logout")})})]})]}),e($,{size:"sm",variant:"outline","aria-label":"core settings",onClick:()=>{I.setState({isEditingCore:!0})},children:e(cs,{})}),e(qr,{}),e($,{size:"sm",variant:"outline","aria-label":"switch theme",onClick:()=>{Vr(l=="dark"?"light":"dark"),h()},children:l==="light"?e(is,{}):e(ls,{})}),e(v,{css:{direction:"ltr"},display:"flex",alignItems:"center",pr:"2",__css:{"& span":{display:"inline-flex"}},children:e(Do,{href:Zr,"data-color-scheme":`no-preference: ${d}; light: ${d}; dark: ${d};`,"data-size":"large","data-show-count":"true","aria-label":"Star Marzban on GitHub",children:"Star"})})]})})]})},ys=[{title:"Inbound's default",value:"inbound_default"},{title:"TLS",value:"tls"},{title:"None",value:"none"}],Ss=[{title:"",value:""},{title:"h2",value:"h2"},{title:"http/1.1",value:"http/1.1"},{title:"h2, http/1.1",value:"h2,http/1.1"}],Cs=[{title:"",value:""},...["chrome","firefox","safari","ios","android","edge","360","qq","random","randomized"].map(t=>({title:t,value:t}))],ws=[{title:"none",value:""},{title:"xtls-rprx-vision",value:"xtls-rprx-vision"}],ks=["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"],_s=gt(t=>({isLoading:!1,isPostLoading:!1,hosts:{},fetchHosts:()=>{t({isLoading:!0}),P("/hosts").then(o=>t({hosts:o})).finally(()=>t({isLoading:!1}))},setHosts:o=>(t({isPostLoading:!0}),P("/hosts",{method:"PUT",body:o}).finally(()=>{t({isPostLoading:!1})}))}));const Is=x(kr,{baseStyle:{w:4,h:4}}),Ue=It.forwardRef(({disabled:t,step:o,label:n,className:s,startAdornment:a,endAdornment:i,type:l="text",placeholder:h,onChange:p,onBlur:y,name:d,value:c,onClick:C,error:_,clearable:f=!1,...S},L)=>{const m=()=>{p&&p({target:{value:"",name:d}})},{size:b="md"}=S,W=l=="number"?Fo:Fe,H=l=="number"?Ro:It.Fragment,U=l=="number"?{keepWithinRange:!0,precision:5,format:A=>isNaN(parseFloat(String(A)))||Number(parseFloat(String(A)).toFixed(5))===0?A:Number(parseFloat(String(A)).toFixed(5)),min:0,step:o,name:d,type:l,placeholder:h,onChange:A=>{p&&p(A)},onBlur:y,value:c,onClick:C,disabled:t,flexGrow:1,size:b}:{};return r(T,{isInvalid:!!_,children:[n&&e(G,{children:n}),r(ct,{size:b,w:"full",rounded:"md",_focusWithin:{outline:"2px solid",outlineColor:"primary.200"},bg:t?"gray.100":"transparent",_dark:{bg:t?"gray.600":"transparent"},children:[a&&e(Lo,{children:a}),r(H,{...U,children:[e(W,{name:d,ref:L,step:o,className:xt(s),type:l,placeholder:h,onChange:p,onBlur:y,value:c,onClick:C,disabled:t,flexGrow:1,_focusVisible:{outline:"none",borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent"},_disabled:{cursor:"not-allowed"},...S,roundedLeft:a?"0":"md",roundedRight:i?"0":"md"}),l=="number"&&e(me,{children:r(To,{children:[e(Ao,{}),e(Mo,{})]})})]}),i&&e(No,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",children:i}),f&&c&&c.length&&e(dt,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",onClick:m,cursor:"pointer",children:e(Is,{})})]}),!!_&&e(ut,{children:_})]})}),wt=x(Ee,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ne=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),vs=x(Lt,{baseStyle:{w:5,h:5}}),ve=x(Wo,{baseStyle:{w:4,h:4,color:"gray.400",cursor:"pointer"}}),zs=k.record(k.string().min(1),k.array(k.object({remark:k.string().min(1,"Remark is required"),address:k.string().min(1,"Address is required"),port:k.string().or(k.number()).nullable().transform(t=>typeof t=="number"?t:t!==null&&!isNaN(parseInt(t))?Number(parseInt(t)):null),path:k.string().nullable(),sni:k.string().nullable(),host:k.string().nullable(),security:k.string(),alpn:k.string(),fingerprint:k.string()}))),Ge=x(ut,{baseStyle:{color:"red.400",display:"block",textAlign:"left",w:"100%"}}),Ds=({hostKey:t,isOpen:o,toggleAccordion:n})=>{const{inbounds:s}=I(),a=[...s.values()].flat().filter(_=>_.tag===t)[0],i=Tt(),{fields:l,append:h,remove:p}=Po({control:i.control,name:t}),{errors:y}=i.formState,{t:d}=O(),c=y[t],C=()=>{h({host:"",sni:"",port:null,path:null,address:"",remark:"",security:"inbound_default",alpn:"",fingerprint:""})};return g.exports.useEffect(()=>{c&&!o&&n()},[c]),r(We,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Pe,{px:2,borderRadius:"3px",onClick:n,children:[e(u,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:t}),e(vt,{})]}),e(Oe,{px:2,pb:2,children:r(M,{gap:3,children:[l.map((_,f)=>{var S,L,m,b,W,H,U,A,B,Y,z,F,Z,R,Q,K,nt,st,pe,Be,$e;return r(M,{border:"1px solid",_dark:{borderColor:"gray.600",bg:"#273142"},_light:{borderColor:"gray.200",bg:"#fcfbfb"},p:2,w:"full",borderRadius:"4px",children:[e(w,{w:"100%",alignItems:"flex-start",children:r(T,{position:"relative",zIndex:10,isInvalid:!!(c&&((S=c[f])==null?void 0:S.remark)),children:[r(ct,{children:[e(Ne,{...i.register(t+"."+f+".remark"),size:"sm",borderRadius:"4px",placeholder:"Remark"}),e(dt,{children:r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(v,{mt:"-8px",children:e(ve,{})})}),e(Ce,{children:r(we,{children:[e(ke,{}),e(_e,{}),e(Qt,{children:r(v,{fontSize:"xs",children:[e(u,{pr:"20px",children:d("hostsDialog.desc")}),r(u,{children:[r(E,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(u,{mt:1,children:[r(E,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(u,{mt:1,children:[r(E,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(u,{mt:1,children:[r(E,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(u,{mt:1,children:[r(E,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(u,{mt:1,children:[r(E,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(u,{mt:1,children:[r(E,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((L=c[f])==null?void 0:L.remark)&&e(Ge,{children:(b=(m=c[f])==null?void 0:m.remark)==null?void 0:b.message})]})}),r(T,{isInvalid:!!(c&&((W=c[f])==null?void 0:W.address)),children:[r(ct,{children:[e(Ne,{size:"sm",borderRadius:"4px",placeholder:"Address (e.g. example.com)",...i.register(t+"."+f+".address")}),e(dt,{children:r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(v,{mt:"-8px",children:e(ve,{})})}),e(Ce,{children:r(we,{children:[e(ke,{}),e(_e,{}),e(Qt,{children:r(v,{fontSize:"xs",children:[e(u,{pr:"20px",children:d("hostsDialog.desc")}),r(u,{children:[r(E,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(u,{mt:1,children:[r(E,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(u,{mt:1,children:[r(E,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(u,{mt:1,children:[r(E,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(u,{mt:1,children:[r(E,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(u,{mt:1,children:[r(E,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(u,{mt:1,children:[r(E,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(u,{mt:1,children:[r(E,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(u,{mt:1,children:[r(E,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((H=c[f])==null?void 0:H.address)&&e(Ge,{children:(A=(U=c[f])==null?void 0:U.address)==null?void 0:A.message})]}),e(et,{w:"full",allowToggle:!0,children:r(We,{border:"0",children:[r(Pe,{display:"flex",justifyContent:"space-between",px:0,py:1,borderRadius:3,_hover:{bg:"transparent"},children:[r(u,{fontSize:"xs",color:"gray.600",_dark:{color:"gray.500"},pl:1,children:[d("hostsDialog.advancedOptions"),e(vt,{fontSize:"sm",ml:1})]}),e(te,{label:"Delete",placement:"top",children:e($,{"aria-label":"Delete",size:"sm",colorScheme:"red",variant:"ghost",onClick:p.bind(null,f),children:e(tt,{})})})]}),e(Oe,{w:"full",p:1,children:r(M,{w:"full",borderRadius:"4px",children:[r(T,{isInvalid:!!(c&&((B=c[f])==null?void 0:B.port)),children:[r(G,{display:"flex",pb:1,alignItems:"center",justifyContent:"space-between",gap:1,m:"0",children:[e("span",{children:d("hostsDialog.port")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.port.info")})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:String(a.port||"8080"),type:"number",...i.register(t+"."+f+".port")})]}),r(T,{isInvalid:!!(c&&((Y=c[f])==null?void 0:Y.sni)),children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.sni")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.sni.info")}),e(u,{fontSize:"xs",mt:"2",children:e(fe,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(E,{})}})}),e(u,{fontSize:"xs",children:e(fe,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(E,{})}})})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:"SNI (e.g. example.com)",...i.register(t+"."+f+".sni")}),c&&((z=c[f])==null?void 0:z.sni)&&e(Ge,{children:(Z=(F=c[f])==null?void 0:F.sni)==null?void 0:Z.message})]}),r(T,{isInvalid:!!(c&&((R=c[f])==null?void 0:R.host)),children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.host")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.host.info")}),e(u,{fontSize:"xs",mt:"2",children:e(fe,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(E,{})}})}),e(u,{fontSize:"xs",children:e(fe,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(E,{})}})})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:"Host (e.g. example.com)",...i.register(t+"."+f+".host")}),c&&((Q=c[f])==null?void 0:Q.host)&&e(Ge,{children:(nt=(K=c[f])==null?void 0:K.host)==null?void 0:nt.message})]}),r(T,{isInvalid:!!(c&&((st=c[f])==null?void 0:st.path)),children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.path")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.path.info")})]})})]})]}),e(Ne,{size:"sm",borderRadius:"4px",placeholder:"path (e.g. /vless)",...i.register(t+"."+f+".path")}),c&&((pe=c[f])==null?void 0:pe.path)&&e(Ge,{children:($e=(Be=c[f])==null?void 0:Be.path)==null?void 0:$e.message})]}),r(T,{height:"66px",children:[r(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.security")}),r(ye,{isLazy:!0,placement:"right",children:[e(Se,{children:e(ve,{})}),e(Ce,{children:r(we,{p:2,children:[e(ke,{}),e(_e,{}),e(u,{fontSize:"xs",pr:5,children:d("hostsDialog.security.info")})]})})]})]}),e(wt,{size:"sm",...i.register(t+"."+f+".security"),children:ys.map(J=>e("option",{value:J.value,children:J.title},J.value))})]}),r(T,{height:"66px",children:[e(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.alpn")})}),e(wt,{size:"sm",...i.register(t+"."+f+".alpn"),children:Ss.map(J=>e("option",{value:J.value,children:J.title},J.value))})]}),r(T,{height:"66px",children:[e(G,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.fingerprint")})}),e(wt,{size:"sm",...i.register(t+"."+f+".fingerprint"),children:Cs.map(J=>e("option",{value:J.value,children:J.title},J.value))})]})]},f)})]})})]},f)}),e(N,{variant:"outline",w:"full",size:"sm",color:"",fontWeight:"normal",onClick:C,children:d("hostsDialog.addHost")})]})})]})},Us=()=>{const{isEditingHosts:t,onEditingHosts:o,refetchUsers:n,inbounds:s}=I(),{isLoading:a,hosts:i,fetchHosts:l,isPostLoading:h,setHosts:p}=_s(),y=ue(),{t:d}=O(),[c,C]=g.exports.useState({});g.exports.useEffect(()=>{t&&l()},[t]);const _=je({resolver:Ke(zs)});g.exports.useEffect(()=>{i&&t&&_.reset(i)},[i]);const f=()=>{C({}),o(!1)},S=m=>{p(m).then(()=>{y({title:d("hostsDialog.savedSuccess"),status:"success",isClosable:!0,position:"top",duration:3e3}),n()}).catch(b=>{var W,H,U,A,B;(((W=b==null?void 0:b.response)==null?void 0:W.status)===409||((H=b==null?void 0:b.response)==null?void 0:H.status)===400)&&y({title:(A=(U=b.response)==null?void 0:U._data)==null?void 0:A.detail,status:"error",isClosable:!0,position:"top",duration:3e3}),((B=b==null?void 0:b.response)==null?void 0:B.status)===422&&Object.keys(b.response._data.detail).forEach(Y=>{y({title:b.response._data.detail[Y]+" ("+Y+")",status:"error",isClosable:!0,position:"top",duration:3e3})})})},L=m=>{c[String(m)]?delete c[String(m)]:c[String(m)]={},C({...c})};return r(re,{isOpen:t,onClose:f,children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(se,{pt:6,children:e(le,{color:"primary",children:e(vs,{color:"white"})})}),e(ae,{mt:3}),e(ie,{w:"440px",pb:3,pt:3,children:e(Er,{..._,children:r("form",{onSubmit:_.handleSubmit(S),children:[e(u,{mb:3,opacity:.8,fontSize:"sm",children:d("hostsDialog.title")}),a&&d("hostsDialog.loading"),!a&&i&&(Object.keys(i).length>0?e(et,{w:"full",allowToggle:!0,allowMultiple:!0,index:Object.keys(c).map(m=>parseInt(m)),children:e(M,{w:"full",children:Object.keys(i).map((m,b)=>e(Ds,{toggleAccordion:()=>L(b),isOpen:c[String(b)],hostKey:m},m))})}):"No inbound found. Please check your Xray config file."),e(w,{justifyContent:"flex-end",py:2,children:e(N,{variant:"solid",mt:"2",type:"submit",colorScheme:"primary",size:"sm",px:5,isLoading:h,disabled:h,children:d("hostsDialog.apply")})})]})})})]})]})},Jr=k.object({name:k.string().min(1),address:k.string().min(1),port:k.number().min(1).or(k.string().transform(t=>parseFloat(t))),api_port:k.number().min(1).or(k.string().transform(t=>parseFloat(t))),xray_version:k.string().nullable().optional(),id:k.number().nullable().optional(),status:k.enum(["connected","connecting","error","disabled"]).nullable().optional(),message:k.string().nullable().optional(),add_as_new_host:k.boolean().optional()}),Es=()=>({name:"",address:"",port:62050,api_port:62051,xray_version:""}),Xe="fetch-nodes-query-key",Rs=()=>{const{isEditingNodes:t}=I();return Rt({queryKey:Xe,queryFn:rt.getState().fetchNodes,refetchInterval:t?3e3:void 0,refetchOnWindowFocus:!1})},rt=gt((t,o)=>({nodes:[],addNode(n){return P("/node",{method:"POST",body:n})},fetchNodes(){return P("/nodes")},fetchNodesUsage(n){return P("/nodes/usage",{query:n})},updateNode(n){return P(`/node/${n.id}`,{method:"PUT",body:n})},setDeletingNode(n){t({deletingNode:n})},reconnectNode(n){return P(`/node/${n.id}/reconnect`,{method:"POST"})},deleteNode:()=>{var n;return P(`/node/${(n=o().deletingNode)==null?void 0:n.id}`,{method:"DELETE"})}})),Ft=(t,o,n)=>{if(t.response&&t.response._data){if(typeof t.response._data.detail=="string")return o({title:t.response._data.detail,status:"error",isClosable:!0,position:"top",duration:3e3});if(typeof t.response._data.detail=="object"&&n){Object.keys(t.response._data.detail).forEach(s=>n.setError(s,{message:t.response._data.detail[s]}));return}}return o({title:"Something went wrong!",status:"error",isClosable:!0,position:"top",duration:3e3})},Wt=(t,o)=>o({title:t,status:"success",isClosable:!0,position:"top",duration:3e3}),Ls=({deleteCallback:t})=>{const{deleteNode:o,deletingNode:n,setDeletingNode:s}=rt(),{t:a}=O(),i=ue(),l=At(),h=()=>{s(null)},{isLoading:p,mutate:y}=Qe(o,{onSuccess:()=>{Wt(a("deleteNode.deleteSuccess",{name:n&&n.name}),i),s(null),l.invalidateQueries(Xe),t&&t()},onError:d=>{Ft(d,i)}});return r(re,{isCentered:!0,isOpen:!!n,onClose:h,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"red",children:e(tt,{})})}),e(ae,{mt:3}),r(ie,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:a("deleteNode.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:a("deleteNode.prompt",{name:n.name})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:h,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"red",onClick:()=>y(),leftIcon:p?e(Re,{size:"xs"}):void 0,children:a("delete")})]})]})]})},ot={baseStyle:{strokeWidth:"2px",w:4,h:4}},ir=x(Oo,ot),Ts=x(jo,ot),lr=x(Ho,ot),cr=x(Rr,ot),As=x(Rr,ot),Ut=[{title:"No",value:"no_reset"},{title:"Daily",value:"day"},{title:"Weekly",value:"week"},{title:"Monthly",value:"month"},{title:"Annually",value:"year"}],Ze={active:{statusColor:"green",bandWidthColor:"primary",icon:ir},connected:{statusColor:"green",bandWidthColor:"primary",icon:ir},disabled:{statusColor:"gray",bandWidthColor:"gray",icon:Ts},expired:{statusColor:"orange",bandWidthColor:"orange",icon:cr},on_hold:{statusColor:"purple",bandWidthColor:"purple",icon:As},connecting:{statusColor:"orange",bandWidthColor:"orange",icon:cr},limited:{statusColor:"red",bandWidthColor:"red",icon:lr},error:{statusColor:"red",bandWidthColor:"red",icon:lr}},Pt=t=>{let o={status:"",time:""};if(t){j(t*1e3).utc().isAfter(j().utc())?o.status="expires":o.status="expired";const n=[],s=j.duration(j(t*1e3).utc().diff(j()));s.years()!=0&&n.push(Math.abs(s.years())+" year"+(Math.abs(s.years())!=1?"s":"")),s.months()!=0&&n.push(Math.abs(s.months())+" month"+(Math.abs(s.months())!=1?"s":"")),s.days()!=0&&n.push(Math.abs(s.days())+" day"+(Math.abs(s.days())!=1?"s":"")),n.length===0&&(s.hours()!=0&&n.push(Math.abs(s.hours())+" hour"+(Math.abs(s.hours())!=1?"s":"")),s.minutes()!=0&&n.push(Math.abs(s.minutes())+" min"+(Math.abs(s.minutes())!=1?"s":""))),o.time=n.join(", ")}return o},lt=({expiryDate:t,status:o,compact:n=!1,showDetail:s=!0,extraText:a})=>{const{t:i}=O(),l=Pt(t),h=Ze[o].icon;return r(me,{children:[r(E,{colorScheme:Ze[o].statusColor,rounded:"full",display:"inline-flex",px:3,py:1,columnGap:n?1:2,alignItems:"center",children:[e(h,{w:n?3:4}),s&&r(u,{textTransform:"capitalize",fontSize:n?".7rem":".875rem",lineHeight:n?"1rem":"1.25rem",fontWeight:"medium",letterSpacing:"tighter",children:[o,a&&`: ${a}`]})]}),s&&t&&e(u,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:i(l.status,{time:l.time})})]})},at=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ms=x(Dr,{baseStyle:{w:5,h:5}}),Ns=x(Bo,{baseStyle:{w:5,h:5,strokeWidth:2}}),Fs=({toggleAccordion:t,node:o})=>{const{updateNode:n,reconnectNode:s,setDeletingNode:a}=rt(),{t:i}=O(),l=At(),h=ue(),p=je({defaultValues:o,resolver:Ke(Jr)}),y=a.bind(null,o),{isLoading:d,mutate:c}=Qe(n,{onSuccess:()=>{Wt("Node updated successfully",h),l.invalidateQueries(Xe)},onError:S=>{Ft(S,h,p)}}),{isLoading:C,mutate:_}=Qe(s.bind(null,o),{onSuccess:()=>{l.invalidateQueries(Xe)}}),f=C?"connecting":o.status?o.status:"error";return r(We,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Pe,{px:2,borderRadius:"3px",onClick:t,children:[r(w,{w:"full",justifyContent:"space-between",pr:2,children:[e(u,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:o.name}),r(w,{children:[o.xray_version&&e(E,{colorScheme:"blue",rounded:"full",display:"inline-flex",px:3,py:1,children:r(u,{textTransform:"capitalize",fontSize:"0.7rem",fontWeight:"medium",letterSpacing:"tighter",children:["Xray ",o.xray_version]})}),o.status&&e(lt,{status:f,compact:!0})]})]}),e(vt,{})]}),r(Oe,{px:2,pb:2,children:[e(M,{pb:3,alignItems:"flex-start",children:f==="error"&&e(qe,{status:"error",size:"xs",children:r(v,{children:[r(w,{w:"full",children:[e(ht,{w:4}),e(u,{marginInlineEnd:0,children:o.message})]}),e(w,{justifyContent:"flex-end",w:"full",children:e(N,{size:"sm","aria-label":"reconnect node",leftIcon:e(Yr,{}),onClick:()=>_(),disabled:C,children:i(C?"nodes.reconnecting":"nodes.reconnect")})})]})})}),e(Kr,{form:p,mutate:c,isLoading:d,submitBtnText:i("nodes.editNode"),btnLeftAdornment:e(te,{label:i("delete"),placement:"top",children:e($,{colorScheme:"red",variant:"ghost",size:"sm","aria-label":"delete node",onClick:y,children:e(tt,{})})})})]})]})},Ws=({toggleAccordion:t,resetAccordions:o})=>{const n=ue(),{t:s}=O(),a=At(),{addNode:i}=rt(),l=je({resolver:Ke(Jr),defaultValues:{...Es(),add_as_new_host:!0}}),{isLoading:h,mutate:p}=Qe(i,{onSuccess:()=>{Wt(s("nodes.addNodeSuccess",{name:l.getValues("name")}),n),a.invalidateQueries(Xe),l.reset(),o()},onError:y=>{Ft(y,n,l)}});return r(We,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[e(Pe,{px:2,borderRadius:"3px",onClick:t,children:r(u,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},display:"flex",gap:1,children:[e(Ns,{display:"inline-block"})," ",e("span",{children:s("nodes.addNewMarzbanNode")})]})}),e(Oe,{px:2,py:4,children:e(Kr,{form:l,mutate:p,isLoading:h,submitBtnText:s("nodes.addNode"),btnProps:{variant:"solid"},addAsHost:!0})})]})},Kr=({form:t,mutate:o,isLoading:n,submitBtnText:s,btnProps:a={},btnLeftAdornment:i,addAsHost:l=!1})=>{var _,f,S,L,m,b,W,H,U,A,B,Y;const{t:h}=O(),[p,y]=g.exports.useState(!1),{data:d,isLoading:c}=Rt({queryKey:"node-settings",queryFn:()=>P("/node/settings")});function C(z){if(document.body.createTextRange){const F=document.body.createTextRange();F.moveToElementText(z),F.select()}else if(window.getSelection){const F=window.getSelection(),Z=document.createRange();Z.selectNodeContents(z),F.removeAllRanges(),F.addRange(Z)}else console.warn("Could not select text in node: Unsupported browser.")}return e("form",{onSubmit:t.handleSubmit(z=>o(z)),children:r(M,{children:[d&&d.certificate&&e(qe,{status:"info",alignItems:"start",children:r(Lr,{display:"flex",flexDirection:"column",overflow:"hidden",children:[e("span",{children:h("nodes.connection-hint")}),r(w,{justify:"end",py:2,children:[e(N,{as:"a",colorScheme:"primary",size:"xs",download:"ssl_client_cert.pem",href:URL.createObjectURL(new Blob([d.certificate],{type:"text/plain"})),children:h("nodes.download-certificate")}),e(te,{placement:"top",label:h("nodes.show-certificate"),children:e($,{"aria-label":h("nodes.show-certificate"),onClick:y.bind(null,!p),colorScheme:"whiteAlpha",color:"primary",size:"xs",children:p?e(Vo,{width:"15px"}):e($o,{width:"15px"})})})]}),e(Tr,{in:p,animateOpacity:!0,children:e(u,{bg:"rgba(255,255,255,.5)",_dark:{bg:"rgba(255,255,255,.2)"},rounded:"md",p:"2",lineHeight:"1.2",fontSize:"10px",fontFamily:"Courier",whiteSpace:"pre",overflow:"auto",onClick:z=>{C(z.target)},children:d.certificate})})]})}),r(w,{w:"full",children:[e(T,{children:e(at,{label:h("nodes.nodeName"),size:"sm",placeholder:"Marzban-S2",...t.register("name"),error:(S=(f=(_=t.formState)==null?void 0:_.errors)==null?void 0:f.name)==null?void 0:S.message})}),e(w,{px:1,children:e(ze,{name:"status",control:t.control,render:({field:z})=>e(te,{placement:"top",label:`${h("usersTable.status")}: `+(z.value!=="disabled"?h("active"):h("disabled")),textTransform:"capitalize",children:e(v,{mt:"6",children:e(Ar,{colorScheme:"primary",isChecked:z.value!=="disabled",onChange:F=>{F.target.checked?z.onChange("connecting"):z.onChange("disabled")}})})},z.value)})})]}),r(w,{alignItems:"flex-start",children:[e(v,{w:"50%",children:e(at,{label:h("nodes.nodeAddress"),size:"sm",placeholder:"51.20.12.13",...t.register("address"),error:(b=(m=(L=t.formState)==null?void 0:L.errors)==null?void 0:m.address)==null?void 0:b.message})}),e(v,{w:"25%",children:e(at,{label:h("nodes.nodePort"),size:"sm",placeholder:"62050",...t.register("port"),error:(U=(H=(W=t.formState)==null?void 0:W.errors)==null?void 0:H.port)==null?void 0:U.message})}),e(v,{w:"25%",children:e(at,{label:h("nodes.nodeAPIPort"),size:"sm",placeholder:"62051",...t.register("api_port"),error:(Y=(B=(A=t.formState)==null?void 0:A.errors)==null?void 0:B.api_port)==null?void 0:Y.message})})]}),l&&e(T,{py:1,children:e(Mr,{...t.register("add_as_new_host"),children:e(G,{m:0,children:h("nodes.addHostForEveryInbound")})})}),r(w,{w:"full",children:[i,e(N,{flexGrow:1,type:"submit",colorScheme:"primary",size:"sm",px:5,w:"full",isLoading:n,...a,children:s})]})]})})},Ps=()=>{const{isEditingNodes:t,onEditingNodes:o}=I(),{t:n}=O(),[s,a]=g.exports.useState({}),{data:i,isLoading:l}=Rs(),h=()=>{a({}),o(!1)},p=y=>{s[String(y)]?delete s[String(y)]:s[String(y)]={},a({...s})};return r(me,{children:[r(re,{isOpen:t,onClose:h,children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(se,{pt:6,children:e(le,{color:"primary",children:e(Ms,{color:"white"})})}),e(ae,{mt:3}),r(ie,{w:"440px",pb:6,pt:3,children:[e(u,{mb:3,opacity:.8,fontSize:"sm",children:n("nodes.title")}),l&&"loading...",e(et,{w:"full",allowToggle:!0,index:Object.keys(s).map(y=>parseInt(y)),children:r(M,{w:"full",children:[!l&&i&&i.map((y,d)=>e(Fs,{toggleAccordion:()=>p(d),node:y},y.name)),e(Ws,{toggleAccordion:()=>p((i||[]).length),resetAccordions:()=>a({})})]})})]})]})]}),e(Ls,{deleteCallback:()=>a({})})]})};function Os(t){const o=360/t,n=90,s=47,a=[];for(let i=0;i(C<0&&(C+=1),C>1&&(C-=1),C<.16666666666666666?d+(c-d)*6*C:C<.5?c:C<.6666666666666666?d+(c-d)*(.6666666666666666-C)*6:d),p=n<.5?n*(1+o):n+o-n*o,y=2*n-p;s=Math.round(h(y,p,t+1/3)*255),a=Math.round(h(y,p,t)*255),i=Math.round(h(y,p,t-1/3)*255)}const l=h=>{const p=h.toString(16);return p.length===1?"0"+p:p};return`#${l(s)}${l(a)}${l(i)}`}const dr=({border:t,...o})=>{const{getInputProps:n,getRadioProps:s}=Jo(o),a=De({base:"xs",md:"sm"});return r(v,{as:"label",children:[e("input",{...n()}),e(v,{...s(),minW:"48px",w:"full",h:"full",textAlign:"center",cursor:"pointer",fontSize:a,borderWidth:t?"1px":"0px",borderRadius:"md",_checked:{bg:"primary.500",color:"white",borderColor:"primary.500"},_focus:{boxShadow:"outline"},px:3,py:1,children:o.children})]})},eo=({onChange:t,defaultValue:o,...n})=>{const{t:s,i18n:a}=O();Je();const i=De({base:["7h","1d","3d","1w"],md:["7h","1d","3d","1w","1m","3m"]}),l={h:"hour",d:"day",w:"week",m:"month",y:"year"},h=De({base:[{title:"hours",options:["1h","3h","6h","12h"]},{title:"days",options:["1d","2d","3d","4d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m"]}],md:[{title:"hours",options:["1h","2h","3h","6h","8h","12h"]},{title:"days",options:["1d","2d","3d","4d","5d","6d"]},{title:"weeks",options:["1w","2w","3w","4w"]},{title:"months",options:["1m","2m","3m","6m","8m"]}]}),{getRootProps:p,getRadioProps:y,setValue:d}=Go({name:"filter",defaultValue:o,onChange:R=>{if(R==="custom")return;_(),i.indexOf(R)>=0?(L(s("userDialog.custom")),b(!1)):(L(s("userDialog.custom")+` (${R})`),b(!0));const Q=Number(R.substring(0,R.length-1)),K=l[R[R.length-1]];t(R,{start:j().utc().subtract(Q,K).format("YYYY-MM-DDTHH:00:00")})}}),{isOpen:c,onOpen:C,onClose:_}=Yo(),f=g.exports.useRef(null);Zo({ref:f,handler:_});const[S,L]=g.exports.useState(s("userDialog.custom")),[m,b]=g.exports.useState(!1),[W,H]=g.exports.useState(0),U=De({base:1,md:2}),A=De({base:"xs",md:"sm"}),[B,Y]=g.exports.useState(null),[z,F]=g.exports.useState(null),Z=R=>{const[Q,K]=R;z&&!K?(Y(null),F(null)):(Y(Q),F(K),Q&&K&&(_(),t("custom",{start:j(Q).format("YYYY-MM-DDT00:00:00"),end:j(K).format("YYYY-MM-DDT23:59:59")})))};return r(M,{...n,children:[W==0&&r(Mt,{...p(),gap:0,display:"flex",borderWidth:"1px",borderRadius:"md",minW:{base:"320px",md:"400px"},children:[i.map(R=>e(dr,{...y({value:R}),children:R},R)),e(v,{onClick:()=>{Y(null),F(null),C()},cursor:"pointer",borderRadius:"md",w:"full",fontSize:A,px:3,py:1,bg:m?"primary.500":"unset",color:m?"white":"unset",borderColor:m?"primary.500":"unset",children:r(w,{children:[e(u,{children:S}),e(St,{as:qt,boxSize:"18px"})]})})]}),W==1&&r(w,{onClick:C,cursor:"pointer",fontSize:A,borderRadius:"md",px:3,py:1,minW:{base:"320px",md:"400px"},borderWidth:"1px",children:[e(u,{w:"full",color:B?"unset":"gray.500",children:B?j(B).format("YYYY-MM-DD (00:00)"):s("userDialog.startDate")}),e(St,{as:Nr,boxSize:"18px"}),e(u,{w:"full",color:z?"unset":"gray.500",children:z?j(z).format("YYYY-MM-DD (23:59)"):s("userDialog.endDate")}),e(St,{as:qt,boxSize:"18px"})]}),e(M,{ref:f,marginTop:"40px !important",borderRadius:"md",borderWidth:"1px",position:"absolute",zIndex:"1",backgroundColor:"white",_dark:{backgroundColor:"gray.700"},display:c?"unset":"none",children:r(Qo,{onChange:R=>H(R),children:[r(qo,{children:[e(Xt,{fontSize:A,children:s("userDialog.relative")}),e(Xt,{fontSize:A,children:s("userDialog.absolute")})]}),r(Xo,{children:[e(Jt,{children:h.map(R=>e(M,{alignItems:"start",pl:2,pr:2,children:r(w,{justifyItems:"flex-start",mb:4,children:[e(u,{fontSize:A,minW:"60px",children:s("userDialog."+R.title)}),R.options.map(Q=>e(dr,{border:!0,...y({value:Q}),children:Q},Q+".custom"))]})},R.title))}),e(Jt,{className:"datepicker-panel",children:e(M,{children:e(Fr,{locale:a.language.toLocaleLowerCase(),selected:B,onChange:Z,startDate:B,endDate:z,selectsRange:!0,maxDate:new Date,monthsShown:U,peekNextMonth:!1,inline:!0})})})]})]})})]})};function mt(t,o,n=[],s=[]){const a=ee(n.reduce((i,l)=>i+=l,0));return{series:n,options:{labels:s,chart:{width:"100%",height:"100%",type:"donut",animations:{enabled:!1}},title:{text:`${o}${a}`,align:"center",style:{fontWeight:"var(--chakra-fontWeights-medium)",color:t==="dark"?"var(--chakra-colors-gray-300)":void 0}},legend:{position:"bottom",labels:{colors:t==="dark"?"#CBD5E0":void 0,useSeriesColors:!1}},stroke:{width:1,colors:void 0},dataLabels:{formatter:(i,{seriesIndex:l,w:h})=>ee(h.config.series[l],1)},tooltip:{custom:({series:i,seriesIndex:l,dataPointIndex:h,w:p})=>{const y=ee(i[l],1),d=Math.max(i.reduce((C,_)=>C+=_),1),c=Math.round(i[l]/d*1e3)/10+"%";return`
{n(S).then(L=>{const m=[],b=[];for(const P in L.usages){const H=L.usages[P];b.push(H.uplink+H.downlink),m.push(H.node_name)}y(mt(l,h,b,m))})};g.exports.useEffect(()=>{t&&C({start:j().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")})},[t]);const _=()=>{o(!1),c("1m")},f=i;return r(re,{isOpen:t,onClose:_,size:"2xl",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"full",children:[e(se,{pt:6,children:r(w,{gap:2,children:[e(le,{color:"primary",children:e(Hs,{color:"white"})}),e(u,{fontWeight:"semibold",fontSize:"lg",children:s("header.nodesUsage")})]})}),e(ie,{mt:3,disabled:f}),e(ae,{children:r(M,{gap:4,children:[e(eo,{defaultValue:d,onChange:(S,L)=>{c(S),C(L)}}),e(v,{justifySelf:"center",w:"full",maxW:"300px",mt:"4",children:e(g.exports.Suspense,{fallback:e(wr,{isIndeterminate:!0}),children:e(Pr,{options:p.options,series:p.series,type:"donut",height:"500px"})})})]})}),e(be,{mt:"3"})]})]})},ur=x(Ko),$s=x(Nr,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),Vs=x(en,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),Gs=x(Wr,{baseStyle:{w:5,h:5}}),Ys=()=>{const{QRcodeLinks:t,setQRCode:o,setSubLink:n,subscribeUrl:s}=I(),i=t!==null,[a,l]=g.exports.useState(0),{t:h}=O(),p=()=>{o(null),n(null)},y=String(s).startsWith("/")?window.location.origin+s:String(s);return r(re,{isOpen:i,onClose:p,children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(se,{pt:6,children:e(le,{color:"primary",children:e(Gs,{color:"white"})})}),e(ie,{mt:3}),t&&r(ae,{gap:{base:"20px",lg:"50px"},pr:{lg:"60px"},px:{base:"50px"},display:"flex",justifyContent:"center",flexDirection:{base:"column",lg:"row"},children:[s&&r(M,{children:[e(ur,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:y,bg:"white"}),e(u,{display:"block",textAlign:"center",pb:3,mt:1,children:h("qrcodeDialog.sublink")})]}),r(v,{w:"300px",children:[e(tn,{centerPadding:"0px",centerMode:!0,slidesToShow:1,slidesToScroll:1,dots:!1,afterChange:l,onInit:()=>l(0),nextArrow:e($,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"next",mr:"-4",children:e($s,{})}),prevArrow:e($,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"prev",ml:"-4",children:e(Vs,{})}),children:t.map((d,c)=>e(w,{children:e(ur,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:d,bg:"white"})},c))}),r(u,{display:"block",textAlign:"center",pb:3,mt:1,children:[a+1," / ",t.length]})]})]})]})]})},Zs=x(Ur,{baseStyle:{w:5,h:5}}),Qs=()=>{const[t,o]=g.exports.useState(!1),{isResetingAllUsage:n,onResetAllUsage:s,resetAllUsage:i}=I(),{t:a}=O(),l=ue(),h=()=>{s(!1)},p=()=>{o(!0),i().then(()=>{l({title:a("resetAllUsage.success"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{l({title:a("resetAllUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{o(!1)})};return r(re,{isCentered:!0,isOpen:n,onClose:h,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"red",children:e(Zs,{})})}),e(ie,{mt:3}),r(ae,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:a("resetAllUsage.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:a("resetAllUsage.prompt")})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:h,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Re,{size:"xs"}):void 0,children:a("reset")})]})]})]})},qs=x(bt,{baseStyle:{w:5,h:5}}),Xs=()=>{const[t,o]=g.exports.useState(!1),{resetUsageUser:n,resetDataUsage:s}=I(),{t:i}=O(),a=ue(),l=()=>{I.setState({resetUsageUser:null})},h=()=>{n&&(o(!0),s(n).then(()=>{a({title:i("resetUserUsage.success",{username:n.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{a({title:i("resetUserUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{o(!1)}))};return r(re,{isCentered:!0,isOpen:!!n,onClose:l,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"blue",children:e(qs,{})})}),e(ie,{mt:3}),r(ae,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:i("resetUserUsage.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:i("resetUserUsage.prompt",{username:n.username})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"blue",onClick:h,leftIcon:t?e(Re,{size:"xs"}):void 0,children:i("reset")})]})]})]})},Js=x(bt,{baseStyle:{w:5,h:5}}),Ks=()=>{const[t,o]=g.exports.useState(!1),{revokeSubscriptionUser:n,revokeSubscription:s}=I(),{t:i}=O(),a=ue(),l=()=>{I.setState({revokeSubscriptionUser:null})},h=()=>{n&&(o(!0),s(n).then(()=>{a({title:i("revokeUserSub.success",{username:n.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{a({title:i("revokeUserSub.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{o(!1)}))};return r(re,{isCentered:!0,isOpen:!!n,onClose:l,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"blue",children:e(Js,{})})}),e(ie,{mt:3}),r(ae,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:i("revokeUserSub.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:i("revokeUserSub.prompt",{username:n.username})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"blue",onClick:h,leftIcon:t?e(Re,{size:"xs"}):void 0,children:i("revoke")})]})]})]})},ei=x(rn,{baseStyle:{strokeWidth:"2px",w:5,h:5}}),ti=({inbound:t,...o})=>{const{getCheckboxProps:n,getInputProps:s,getLabelProps:i,htmlProps:a}=jr(o),l=s();return r(v,{as:"label",children:[e("input",{...l}),r(v,{w:"fll",position:"relative",...a,cursor:"pointer",borderRadius:"sm",border:"1px solid",borderColor:"gray.200",_dark:{borderColor:"gray.600"},display:"flex",alignItems:"center",justifyContent:"space-between",overflow:"hidden",_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent",fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& p":{opacity:1}},__css:{"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...n(),children:[e(Mr,{size:"sm",w:"full",maxW:"full",color:"gray.700",_dark:{color:"gray.300"},textTransform:"uppercase",colorScheme:"primary",className:"inbound-item",isChecked:l.checked,pointerEvents:"none",flexGrow:1,children:e(w,{justify:"space-between",w:"full",maxW:"calc(100% - 20px)",spacing:0,gap:2,overflow:"hidden",children:r(u,{isTruncated:!0,...i(),fontSize:"xs",children:[t.tag," ",r(u,{as:"span",children:["(",t.network,")"]})]})})}),t.tls&&t.tls!="none"&&e(E,{fontSize:"xs",opacity:".8",size:"xs",children:t.tls})]})]})},ri=({disabled:t,title:o,description:n,toggleAccordion:s,isSelected:i,...a})=>{const l=Tt(),{inbounds:h}=I(),{getCheckboxProps:p,getInputProps:y,getLabelProps:d,htmlProps:c}=jr(a),C=y(),[_]=Hr({name:[`inbounds.${o}`],control:l.control}),{getCheckboxProps:f}=Or({value:_,onChange:b=>{if(l.setValue(`inbounds.${o}`,b),b.length===0){const P=l.getValues("selected_proxies");l.setValue("selected_proxies",P.filter(H=>H!==o)),s()}}}),S=_&&i&&(I.getState().inbounds.get(o)||[]).length!==_.length,L=(I.getState().inbounds.get(o)||[]).length>0,m=!i&&!L;return r(Pe,{isDisabled:!L,borderRadius:"md",borderStyle:"solid",border:"1px",borderColor:"gray.200",bg:m?"gray.100":"transparent",_dark:{borderColor:"gray.600",bg:m?"#364154":"transparent"},_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent"},...p(),children:[r(v,{as:m?"span":"label",position:"relative",children:[S&&e(v,{position:"absolute",w:"2",h:"2",bg:"yellow.500",top:"-1",right:"-1",rounded:"full",zIndex:999}),e("input",{...C}),r(v,{w:"fll",position:"relative",...c,borderRadius:"md",cursor:m?"not-allowed":"pointer",_checked:{fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& > svg":{opacity:1,"&.checked":{display:"block"},"&.unchecked":{display:"none"}},"& p":{opacity:1}},__css:{"& > svg":{opacity:.3,"&.checked":{display:"none"},"&.unchecked":{display:"block"}},"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...p(),children:[e(We,{display:C.checked&&L?"block":"none",as:"span",className:"checked",color:"primary.200",position:"absolute",right:"3",top:"3",w:"auto",p:0,onClick:s,children:e($,{size:"sm","aria-label":"inbound settings",children:e(ei,{})})}),e(u,{fontSize:"sm",color:m?"gray.400":"gray.700",_dark:{color:m?"gray.500":"gray.300"},...d(),children:o}),e(u,{fontWeight:"medium",color:m?"gray.400":"gray.600",_dark:{color:m?"gray.500":"gray.400"},fontSize:"xs",children:n})]})]}),e(Oe,{px:2,pb:3,roundedBottom:"5px",pt:3,_dark:{bg:C.checked&&"gray.750"},children:r(M,{w:"full",rowGap:2,borderStyle:"solid",borderWidth:"1px",borderRadius:"md",pl:3,pr:3,pt:1.5,_dark:{bg:"gray.700"},children:[r(M,{alignItems:"flex-start",w:"full",children:[e(u,{fontSize:"sm",children:X("inbound")}),e(Mt,{gap:2,alignItems:"flex-start",w:"full",columns:1,spacing:1,children:(h.get(o)||[]).map(b=>e(ti,{...f({value:b.tag}),inbound:b},b.tag))})]}),o==="vmess"&&i&&e(M,{alignItems:"flex-start",w:"full",children:r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:"ID"}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vmess.id")})]})}),o==="vless"&&i&&r(M,{alignItems:"flex-start",w:"full",children:[r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:"ID"}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vless.id")})]}),r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:"Flow"}),e(Ee,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.vless.flow"),children:ws.map(b=>e("option",{value:b.value,children:b.title},b.title))})]})]}),o==="trojan"&&i&&e(M,{alignItems:"flex-start",w:"full",children:r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:X("password")}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.trojan.password")})]})}),o==="shadowsocks"&&i&&r(M,{alignItems:"flex-start",w:"full",children:[r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:X("password")}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.shadowsocks.password")})]}),r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:X("userDialog.method")}),e(Ee,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.shadowsocks.method"),children:ks.map(b=>e("option",{value:b,children:b},b))})]})]})]})})]})},oi=g.exports.forwardRef(({name:t,list:o,onChange:n,disabled:s,...i},a)=>{const l=Tt(),[h,p]=g.exports.useState([]),y=c=>{h.includes(c)?h.splice(h.indexOf(c),1):h.push(c),p([...h])},{getCheckboxProps:d}=Or({value:i.value,onChange:c=>{var _;const C=c.filter(f=>!i.value.includes(f));C[0]&&l.setValue(`inbounds.${C[0]}`,(_=I.getState().inbounds.get(C[0]))==null?void 0:_.map(f=>f.tag)),p(h.filter(f=>c.find(S=>S===o[f].title))),n({target:{value:c,name:t}})}});return e(et,{allowToggle:!0,index:h,children:e(Mt,{ref:a,gap:2,alignItems:"flex-start",columns:1,spacing:1,children:o.map((c,C)=>e(ri,{toggleAccordion:y.bind(null,C),disabled:s,title:c.title,description:c.description,isSelected:!!i.value.find(_=>_===c.title),...d({value:c.title})},c.title))})})}),ni=x(on,{baseStyle:{w:5,h:5}}),si=x(Br,{baseStyle:{w:5,h:5}}),ii=x(ft,{baseStyle:{w:5,h:5}}),ai=k.object({username:k.string().min(1,{message:"Required"}),selected_proxies:k.array(k.string()).refine(t=>t.length>0,{message:"userDialog.selectOneProtocol"}),note:k.string().nullable(),proxies:k.record(k.string(),k.record(k.string(),k.any())).transform(t=>{const o=(n,s)=>{n&&n[s]===""&&delete n[s]};return o(t.vmess,"id"),o(t.vless,"id"),o(t.trojan,"password"),o(t.shadowsocks,"password"),o(t.shadowsocks,"method"),t}),data_limit:k.string().min(0,"The minimum number is 0").or(k.number()).nullable().transform(t=>t?Number((parseFloat(String(t))*1073741824).toFixed(5)):0),expire:k.number().nullable(),data_limit_reset_strategy:k.string(),status:k.string(),inbounds:k.record(k.string(),k.array(k.string())).transform(t=>(Object.keys(t).forEach(o=>{var n;Array.isArray(t[o])&&!((n=t[o])!=null&&n.length)&&delete t[o]}),t))}),li=t=>({...t,data_limit:t.data_limit?Number((t.data_limit/1073741824).toFixed(5)):t.data_limit,selected_proxies:Object.keys(t.proxies)}),kt=()=>{const t=Object.fromEntries(I.getState().inbounds),o={};for(const n in t)o[n]=t[n].map(s=>s.tag);return{selected_proxies:Object.keys(t),data_limit:null,expire:null,username:"",data_limit_reset_strategy:"no_reset",status:"active",note:"",inbounds:o,proxies:{vless:{id:"",flow:""},vmess:{id:""},trojan:{password:""},shadowsocks:{password:"",method:"chacha20-ietf-poly1305"}}}},ci=(t,o)=>{const n=t.reduce((s,i)=>({...s,[i]:{}}),{});return o&&t.forEach(s=>{o[s]&&(n[s]=o[s])}),n},di=()=>{var Be,$e,J,Ot,jt;const{editingUser:t,isCreatingNewUser:o,onCreateUser:n,editUser:s,fetchUserUsage:i,onEditingUser:a,createUser:l,onDeletingUser:h}=I(),p=!!t,y=o||p,[d,c]=g.exports.useState(!1),[C,_]=g.exports.useState(""),f=ue(),{t:S,i18n:L}=O(),{colorMode:m}=Je(),[b,P]=g.exports.useState(!1),H=()=>{P(D=>!D)},U=je({defaultValues:kt(),resolver:Ke(ai)});g.exports.useEffect(()=>I.subscribe(D=>D.inbounds,()=>{U.reset(kt())}),[]);const[A]=Hr({control:U.control,name:["data_limit"]}),B=S("userDialog.total"),[Y,z]=g.exports.useState(mt(m,B)),[F,Z]=g.exports.useState("1m"),R=D=>{i(t,D).then(V=>{const Le=[],Te=[];for(const xe in V.usages)Te.push(V.usages[xe].used_traffic),Le.push(V.usages[xe].node_name);z(mt(m,B,Te,Le))})};g.exports.useEffect(()=>{t&&(U.reset(li(t)),R({start:j().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")}))},[t]);const Q=D=>{c(!0);const V={edited:s,created:l},Le=p?"edited":"created";_(null);const{selected_proxies:Te,...xe}=D;let Ae={...xe,data_limit:D.data_limit,proxies:ci(Te,D.proxies),data_limit_reset_strategy:D.data_limit&&D.data_limit>0?D.data_limit_reset_strategy:"no_reset",status:D.status==="active"||D.status==="disabled"?D.status:"active"};V[Le](Ae).then(()=>{f({title:S(p?"userDialog.userEdited":"userDialog.userCreated",{username:D.username}),status:"success",isClosable:!0,position:"top",duration:3e3}),K()}).catch(q=>{var Ht,Bt,$t,Vt,Gt;(((Ht=q==null?void 0:q.response)==null?void 0:Ht.status)===409||((Bt=q==null?void 0:q.response)==null?void 0:Bt.status)===400)&&_((Vt=($t=q==null?void 0:q.response)==null?void 0:$t._data)==null?void 0:Vt.detail),((Gt=q==null?void 0:q.response)==null?void 0:Gt.status)===422&&Object.keys(q.response._data.detail).forEach(yt=>{_(q==null?void 0:q.response._data.detail[yt]),U.setError(yt,{type:"custom",message:q.response._data.detail[yt]})})}).finally(()=>{c(!1)})},K=()=>{U.reset(kt()),n(!1),a(null),_(null),P(!1),Z("1m")},nt=()=>{I.setState({resetUsageUser:t})},st=()=>{I.setState({revokeSubscriptionUser:t})},pe=d;return r(re,{isOpen:y,onClose:K,size:"2xl",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),e(Er,{...U,children:e(ne,{mx:"3",children:r("form",{onSubmit:U.handleSubmit(Q),children:[e(se,{pt:6,children:r(w,{gap:2,children:[e(le,{color:"primary",children:p?e(si,{color:"white"}):e(ni,{color:"white"})}),e(u,{fontWeight:"semibold",fontSize:"lg",children:S(p?"userDialog.editUserTitle":"createNewUser")})]})}),e(ie,{mt:3,disabled:pe}),r(ae,{children:[r(_r,{templateColumns:{base:"repeat(1, 1fr)",md:"repeat(2, 1fr)"},gap:3,children:[e(Ye,{children:r(M,{justifyContent:"space-between",children:[r(nn,{flexDirection:"column",gridAutoRows:"min-content",w:"full",children:[r(T,{mb:"10px",children:[e(G,{children:S("username")}),r(w,{children:[e(Ue,{size:"sm",type:"text",borderRadius:"6px",error:(Be=U.formState.errors.username)==null?void 0:Be.message,disabled:pe||p,...U.register("username")}),p&&e(w,{px:1,children:e(ze,{name:"status",control:U.control,render:({field:D})=>e(te,{placement:"top",label:"status: "+D.value,textTransform:"capitalize",children:e(v,{children:e(Ar,{colorScheme:"primary",disabled:D.value!=="active"&&D.value!=="disabled",isChecked:D.value==="active",onChange:V=>{V.target.checked?D.onChange("active"):D.onChange("disabled")}})})})})})]})]}),r(T,{mb:"10px",children:[e(G,{children:S("userDialog.dataLimit")}),e(ze,{control:U.control,name:"data_limit",render:({field:D})=>{var V;return e(Ue,{endAdornment:"GB",type:"number",size:"sm",borderRadius:"6px",onChange:D.onChange,disabled:pe,error:(V=U.formState.errors.data_limit)==null?void 0:V.message,value:D.value?String(D.value):""})}})]}),e(Tr,{in:!!(A&&A>0),animateOpacity:!0,style:{width:"100%"},children:r(T,{height:"66px",children:[e(G,{children:S("userDialog.periodicUsageReset")}),e(ze,{control:U.control,name:"data_limit_reset_strategy",render:({field:D})=>e(Ee,{size:"sm",...D,children:Ut.map(V=>e("option",{value:V.value,children:S("userDialog.resetStrategy"+V.title)},V.value))})})]})}),r(T,{mb:"10px",children:[e(G,{children:S("userDialog.expiryDate")}),e(ze,{name:"expire",control:U.control,render:({field:D})=>{var xe;function V(Ae){return j(j(Ae*1e3).utc()).toDate()}const{status:Le,time:Te}=Wt(D.value);return r(me,{children:[e(Fr,{locale:L.language.toLocaleLowerCase(),dateFormat:S("dateFormat"),minDate:new Date,selected:D.value?V(D.value):void 0,onChange:Ae=>{D.onChange({target:{value:Ae?j(j(Ae).set("hour",23).set("minute",59).set("second",59)).utc().valueOf()/1e3:0,name:"expire"}})},customInput:e(Ue,{size:"sm",type:"text",borderRadius:"6px",clearable:!0,disabled:pe,error:(xe=U.formState.errors.expire)==null?void 0:xe.message})}),D.value?e(sn,{children:S(Le,{time:Te})}):""]})}})]}),r(T,{mb:"10px",isInvalid:!!U.formState.errors.note,children:[e(G,{children:S("userDialog.note")}),e(an,{...U.register("note")}),e(ut,{children:(J=($e=U.formState.errors)==null?void 0:$e.note)==null?void 0:J.message})]})]}),C&&r(qe,{status:"error",display:{base:"none",md:"flex"},children:[e(ht,{}),C]})]})}),e(Ye,{children:r(T,{isInvalid:!!((Ot=U.formState.errors.selected_proxies)!=null&&Ot.message),children:[e(G,{children:S("userDialog.protocols")}),e(ze,{control:U.control,name:"selected_proxies",render:({field:D})=>e(oi,{list:[{title:"vmess",description:S("userDialog.vmessDesc")},{title:"vless",description:S("userDialog.vlessDesc")},{title:"trojan",description:S("userDialog.trojanDesc")},{title:"shadowsocks",description:S("userDialog.shadowsocksDesc")}],disabled:pe,...D})}),e(ut,{children:S((jt=U.formState.errors.selected_proxies)==null?void 0:jt.message)})]})}),p&&b&&e(Ye,{pt:6,colSpan:{base:1,md:2},children:r(M,{gap:4,children:[e(eo,{defaultValue:F,onChange:(D,V)=>{Z(D),R(V)}}),e(v,{width:{base:"100%",md:"70%"},justifySelf:"center",children:e(Pr,{options:Y.options,series:Y.series,type:"donut"})})]})})]}),C&&r(qe,{mt:"3",status:"error",display:{base:"flex",md:"none"},children:[e(ht,{}),C]})]}),e(be,{mt:"3",children:r(w,{justifyContent:"space-between",w:"full",gap:3,flexDirection:{base:"column",sm:"row"},children:[e(w,{justifyContent:"flex-start",w:{base:"full",sm:"unset"},children:p&&r(me,{children:[e(te,{label:S("delete"),placement:"top",children:e($,{"aria-label":"Delete",size:"sm",onClick:()=>{h(t),K()},children:e(tt,{})})}),e(te,{label:S("userDialog.usage"),placement:"top",children:e($,{"aria-label":"usage",size:"sm",onClick:H,children:e(ii,{})})}),e(N,{onClick:nt,size:"sm",children:S("userDialog.resetUsage")}),e(N,{onClick:st,size:"sm",children:S("userDialog.revokeSubscription")})]})}),e(w,{w:"full",maxW:{md:"50%",base:"full"},justify:"end",children:e(N,{type:"submit",size:"sm",px:"8",colorScheme:"primary",leftIcon:d?e(Re,{size:"xs"}):void 0,disabled:pe,children:S(p?"userDialog.editUser":"createUser")})})]})})]})})})]})},ui=t=>g.exports.createElement("svg",{xmlns:"http://www.w3.org/2000/svg","data-name":"Layer 1",width:782.04441,height:701.88002,viewBox:"0 0 782.04441 701.88002",xmlnsXlink:"http://www.w3.org/1999/xlink",...t},g.exports.createElement("path",{d:"M609.48783,100.59015l-25.44631,6.56209L270.53735,187.9987,245.091,194.56079A48.17927,48.17927,0,0,0,210.508,253.17865L320.849,681.05606a48.17924,48.17924,0,0,0,58.61776,34.58317l.06572-.01695,364.26536-93.93675.06572-.01695a48.17923,48.17923,0,0,0,34.58309-58.6178l-110.341-427.87741A48.17928,48.17928,0,0,0,609.48783,100.59015Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M612.94784,114.00532l-30.13945,7.77236L278.68955,200.20385l-30.139,7.77223a34.30949,34.30949,0,0,0-24.6275,41.74308l110.341,427.87741a34.30946,34.30946,0,0,0,41.7431,24.62736l.06572-.01695,364.26536-93.93674.06619-.01707a34.30935,34.30935,0,0,0,24.627-41.7429l-110.341-427.87741A34.30938,34.30938,0,0,0,612.94784,114.00532Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),g.exports.createElement("path",{d:"M590.19,252.56327,405.917,300.08359a8.01411,8.01411,0,0,1-4.00241-15.52046l184.273-47.52033A8.01412,8.01412,0,0,1,590.19,252.56327Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M628.955,270.49906,412.671,326.27437a8.01411,8.01411,0,1,1-4.00241-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M620.45825,369.93676l-184.273,47.52032a8.01411,8.01411,0,1,1-4.00242-15.52046l184.273-47.52032a8.01411,8.01411,0,1,1,4.00241,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M659.22329,387.87255l-216.284,55.77531a8.01411,8.01411,0,1,1-4.00242-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M650.72653,487.31025l-184.273,47.52033a8.01412,8.01412,0,0,1-4.00242-15.52047l184.273-47.52032a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M689.49156,505.246l-216.284,55.77532a8.01412,8.01412,0,1,1-4.00241-15.52047l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M374.45884,348.80871l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76146L289.5963,304.81607a3.847,3.847,0,0,1,2.76145-4.68061l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76145l14.96947,58.04817A3.847,3.847,0,0,1,374.45884,348.80871Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M404.72712,466.1822l-65.21247,16.817a3.847,3.847,0,0,1-4.68062-2.76146l-14.96946-58.04816A3.847,3.847,0,0,1,322.626,417.509l65.21246-16.817a3.847,3.847,0,0,1,4.68062,2.76145l14.96946,58.04817A3.847,3.847,0,0,1,404.72712,466.1822Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M434.99539,583.55569l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76145l-14.96946-58.04817a3.847,3.847,0,0,1,2.76145-4.68062l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76146l14.96947,58.04816A3.847,3.847,0,0,1,434.99539,583.55569Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M863.63647,209.0517H487.31811a48.17928,48.17928,0,0,0-48.125,48.12512V699.05261a48.17924,48.17924,0,0,0,48.125,48.12507H863.63647a48.17924,48.17924,0,0,0,48.125-48.12507V257.17682A48.17928,48.17928,0,0,0,863.63647,209.0517Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M863.637,222.90589H487.31811a34.30948,34.30948,0,0,0-34.271,34.27093V699.05261a34.30947,34.30947,0,0,0,34.271,34.27088H863.637a34.30936,34.30936,0,0,0,34.27051-34.27088V257.17682A34.30937,34.30937,0,0,0,863.637,222.90589Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),g.exports.createElement("circle",{cx:694.19401,cy:614.02963,r:87.85039,fill:"#3182CE"}),g.exports.createElement("path",{d:"M945.18722,701.63087H914.63056V671.07421a11.45875,11.45875,0,0,0-22.9175,0v30.55666H861.1564a11.45875,11.45875,0,0,0,0,22.9175h30.55666V755.105a11.45875,11.45875,0,1,0,22.9175,0V724.54837h30.55666a11.45875,11.45875,0,0,0,0-22.9175Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),g.exports.createElement("path",{d:"M807.00068,465.71551H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01412,8.01412,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M840.05889,492.76314H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01411,8.01411,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M807.00068,586.929H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M840.05889,613.97661H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01412,8.01412,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M574.07028,505.04162H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V441.25158a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,505.04162Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M574.07028,626.25509H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V562.46505a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,626.25509Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M807.21185,330.781H666.91017a8.01411,8.01411,0,0,1,0-16.02823H807.21185a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),g.exports.createElement("path",{d:"M840.27007,357.82862H666.91017a8.01411,8.01411,0,1,1,0-16.02822h173.3599a8.01411,8.01411,0,0,1,0,16.02822Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),g.exports.createElement("path",{d:"M635.85911,390.6071H506.51316a3.847,3.847,0,0,1-3.84277-3.84277V285.81706a3.847,3.847,0,0,1,3.84277-3.84277H635.85911a3.847,3.847,0,0,1,3.84277,3.84277V386.76433A3.847,3.847,0,0,1,635.85911,390.6071Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"})),hi=t=>{if(!t)return null;const o=new Date(t+"Z");return Math.floor(o.getTime()/1e3)},hr=({lastOnline:t})=>{const o=Math.floor(Date.now()/1e3),n=hi(t);if(typeof t>"u"||t===null)return e("div",{className:"circle pulse orange"});const s=n?o-n:1/0;return s>0&&s<=60?e("div",{className:"circle pulse green"}):e("div",{className:"circle pulse red"})},pi=t=>{if(!t)return null;const o=new Date(t+"Z");return Math.floor(o.getTime()/1e3)},pr=({lastOnline:t})=>{const o=Math.floor(Date.now()/1e3),n=pi(t),s=n?o-n:null,i=n?Wt(n):{status:"",time:"Not Connected Yet"};return e(u,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:s&&s<=60?"Online":s?`${i.time} ago`:i.time})},mi=x(ln,{baseStyle:{w:4,h:4}}),gi=x(cn,{baseStyle:{w:4,h:4}}),mr=5;function fi(t,o,n){if(n0&&(i[0]=0,i[1]="prev-more"),i[i.length-1]{const{filters:t,onFilterChange:o,users:{total:n}}=I(),{limit:s,offset:i}=t,a=(i||0)/(s||1),l=Math.ceil(n/(s||1)),h=fi(l,a,7),p=c=>{o({...t,offset:c*s})},y=c=>{o({...t,limit:parseInt(c.target.value)}),jn(c.target.value)},{t:d}=O();return r(w,{justifyContent:"space-between",mt:4,w:"full",display:"flex",columnGap:{lg:4,md:0},rowGap:{md:0,base:4},flexDirection:{md:"row",base:"column"},children:[e(v,{order:{base:2,md:1},children:r(w,{children:[r(Ee,{minW:"60px",value:s,onChange:y,size:"sm",rounded:"md",children:[e("option",{children:"10"}),e("option",{children:"20"}),e("option",{children:"30"})]}),e(u,{whiteSpace:"nowrap",fontSize:"sm",children:d("itemsPerPage")})]})}),r(dn,{size:"sm",isAttached:!0,variant:"outline",order:{base:1,md:2},children:[e(N,{leftIcon:e(mi,{}),onClick:p.bind(null,a-1),isDisabled:a===0||l===0,children:d("previous")}),h.map(c=>typeof c=="string"?e(N,{children:"..."},c):e(N,{variant:c===a?"solid":"outline",onClick:p.bind(null,c),children:c+1},c)),e(N,{rightIcon:e(gi,{}),onClick:p.bind(null,a+1),isDisabled:a+1===l||l===0,children:d("next")})]})]})},xi=x(ui),He={baseStyle:{w:{base:4,md:5},h:{base:4,md:5}}},yi=x(un,He),Si=x($r,He),gr=x(hn,He),Ci=x(Lt,He),wi=x(Wr,He),ki=x(Br,He),_i=x($r,{baseStyle:{width:"15px",height:"15px"}}),Ii=t=>{for(var o=0;o{const{used:o,total:n,dataLimitResetStrategy:s,totalUsedTraffic:i}=t,a=n===0||n===null;return e(w,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:r(u,{children:[ee(o)," /"," ",a?e(u,{as:"span",fontFamily:"system-ui",children:"\u221E"}):ee(n)]})})},fr=t=>{const{used:o,total:n,dataLimitResetStrategy:s,totalUsedTraffic:i,...a}=t,l=n===0||n===null,h=!l&&o/n*100>=100;return r(me,{children:[e(pn,{orientation:"horizontal",value:l?100:Math.min(o/n*100,100),colorScheme:h?"red":"primary",...a,children:e(mn,{h:"6px",borderRadius:"full",children:e(gn,{borderRadius:"full"})})}),r(w,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:[r(u,{children:[ee(o)," /"," ",l?e(u,{as:"span",fontFamily:"system-ui",children:"\u221E"}):ee(n)+(s&&s!=="no_reset"?" "+X("userDialog.resetStrategy"+Ii(s)):"")]}),r(u,{children:[X("usersTable.total"),": ",ee(i)]})]})]})},at=({sort:t,column:o})=>t.includes(o)?e(_i,{transform:t.startsWith("-")?void 0:"rotate(180deg)"}):null,zi=t=>{const{filters:o,users:{users:n},users:s,onEditingUser:i,onFilterChange:a}=I(),{t:l}=O(),[h,p]=g.exports.useState(void 0),y=De({base:120,lg:72})||72,[d,c]=g.exports.useState(`${y}px`),C=De({base:!1,md:!0});g.exports.useEffect(()=>{const m=()=>{const b=document.querySelectorAll("#filters")[0];c(`${b.offsetHeight}px`)};window.addEventListener("scroll",m)},[]);const _=n.length!==s.total,f=m=>{let b=o.sort;b.includes(m)?b.startsWith("-")?b="-created_at":b="-"+m:b=m,a({sort:b})},S=m=>{a({status:m.target.value.length>0?m.target.value:void 0})},L=m=>{p(m===h?void 0:m)};return r(v,{id:"users-table",overflowX:{base:"unset",md:"unset"},children:[e(et,{allowMultiple:!0,display:{base:"block",md:"none"},index:h,children:r(Kt,{orientation:"vertical",zIndex:"docked",...t,children:[e(er,{zIndex:"docked",position:"relative",children:r(Me,{children:[e(ge,{position:"sticky",top:d,minW:"120px",pl:4,pr:4,cursor:"pointer",onClick:f.bind(null,"username"),children:r(w,{children:[e("span",{children:l("users")}),e(at,{sort:o.sort,column:"username"})]})}),e(ge,{position:"sticky",top:d,minW:"50px",pl:0,pr:0,w:"140px",cursor:"pointer",children:r(w,{spacing:0,position:"relative",children:[r(u,{position:"absolute",_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,w:"100%",children:[l("usersTable.status"),o.status?": "+o.status:""]}),r(Ee,{value:o.sort,fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",p:0,border:0,h:"auto",w:"auto",icon:e(me,{}),_focusVisible:{border:"0 !important"},onChange:S,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ge,{position:"sticky",top:d,minW:"100px",cursor:"pointer",pr:0,onClick:f.bind(null,"used_traffic"),children:r(w,{children:[e("span",{children:l("usersTable.dataUsage")}),e(at,{sort:o.sort,column:"used_traffic"})]})}),e(ge,{position:"sticky",top:d,minW:"32px",w:"32px",p:0,cursor:"pointer"})]})}),e(tr,{children:!C&&(n==null?void 0:n.map((m,b)=>r(g.exports.Fragment,{children:[r(Me,{onClick:L.bind(null,b),cursor:"pointer",children:[e(ce,{borderBottom:0,minW:"100px",pl:4,pr:4,children:r("div",{className:"flex-status",children:[e(hr,{lastOnline:m.online_at}),m.username]})}),e(ce,{borderBottom:0,minW:"50px",pl:0,pr:0,children:e(lt,{compact:!0,showDetail:!1,expiryDate:m.expire,status:m.status})}),e(ce,{borderBottom:0,minW:"100px",pr:0,children:e(vi,{totalUsedTraffic:m.lifetime_used_traffic,dataLimitResetStrategy:m.data_limit_reset_strategy,used:m.used_traffic,total:m.data_limit,colorScheme:Ze[m.status].bandWidthColor})}),e(ce,{p:0,borderBottom:0,w:"32px",minW:"32px",children:e(Si,{color:"gray.600",_dark:{color:"gray.400"},transition:"transform .2s ease-out",transform:h===b?"rotate(180deg)":"0deg"})})]}),e(Me,{className:"collapsible",onClick:L.bind(null,b),children:e(ce,{p:0,colSpan:4,children:r(Pe,{border:0,children:[e(We,{display:"none"}),e(Oe,{border:0,cursor:"pointer",px:6,py:3,children:r(M,{justifyContent:"space-between",spacing:"4",children:[r(M,{alignItems:"flex-start",w:"full",spacing:-1,children:[e(u,{textTransform:"capitalize",fontSize:"xs",fontWeight:"bold",color:"gray.600",_dark:{color:"gray.400"},children:l("usersTable.dataUsage")}),e(v,{width:"full",minW:"230px",children:e(fr,{totalUsedTraffic:m.lifetime_used_traffic,dataLimitResetStrategy:m.data_limit_reset_strategy,used:m.used_traffic,total:m.data_limit,colorScheme:Ze[m.status].bandWidthColor})})]}),r(w,{w:"full",justifyContent:"space-between",children:[r(v,{width:"full",children:[e(lt,{compact:!0,expiryDate:m.expire,status:m.status}),e(pr,{lastOnline:m.online_at})]}),r(w,{children:[e(br,{user:m}),e(te,{label:l("userDialog.editUser"),placement:"top",children:e($,{p:"0 !important","aria-label":"Edit user",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:P=>{P.stopPropagation(),i(m)},children:e(ki,{})})})]})]})]})})]})})})]},m.username)))})]})}),r(Kt,{orientation:"vertical",display:{base:"none",md:"table"},...t,children:[e(er,{zIndex:"docked",position:"relative",children:r(Me,{children:[e(ge,{position:"sticky",top:{base:"unset",md:d},minW:"140px",cursor:"pointer",onClick:f.bind(null,"username"),children:r(w,{children:[e("span",{children:l("username")}),e(at,{sort:o.sort,column:"username"})]})}),e(ge,{position:"sticky",top:{base:"unset",md:d},width:"400px",minW:"150px",cursor:"pointer",children:r(w,{spacing:0,position:"relative",children:[r(u,{position:"absolute",_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,w:"100%",children:[l("usersTable.status"),o.status?": "+o.status:""]}),r(Ee,{fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",p:0,border:0,h:"auto",w:"auto",icon:e(me,{}),_focusVisible:{border:"0 !important"},value:o.sort,onChange:S,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ge,{position:"sticky",top:{base:"unset",md:d},width:"350px",minW:"230px",cursor:"pointer",onClick:f.bind(null,"used_traffic"),children:r(w,{children:[e("span",{children:l("usersTable.dataUsage")}),e(at,{sort:o.sort,column:"used_traffic"})]})}),e(ge,{position:"sticky",top:{base:"unset",md:d},width:"200px",minW:"180px"})]})}),r(tr,{children:[C&&(n==null?void 0:n.map((m,b)=>r(Me,{className:xt("interactive",{"last-row":b===n.length-1}),onClick:()=>i(m),children:[e(ce,{minW:"140px",children:r("div",{className:"flex-status",children:[e(hr,{lastOnline:m.online_at}),m.username,e(pr,{lastOnline:m.online_at})]})}),e(ce,{width:"400px",minW:"150px",children:e(lt,{expiryDate:m.expire,status:m.status})}),e(ce,{width:"350px",minW:"230px",children:e(fr,{totalUsedTraffic:m.lifetime_used_traffic,dataLimitResetStrategy:m.data_limit_reset_strategy,used:m.used_traffic,total:m.data_limit,colorScheme:Ze[m.status].bandWidthColor})}),e(ce,{width:"200px",minW:"180px",children:e(br,{user:m})})]},m.username))),n.length==0&&e(Me,{children:e(ce,{colSpan:4,children:e(Di,{isFiltered:_})})})]})]}),e(bi,{})]})},br=({user:t})=>{const{setQRCode:o,setSubLink:n}=I(),s=t.links.join(`\r -`),[i,a]=g.exports.useState([-1,!1]);return g.exports.useEffect(()=>{i[1]&&setTimeout(()=>{a([-1,!1])},1e3)},[i]),r(w,{justifyContent:"flex-end",onClick:l=>{l.preventDefault(),l.stopPropagation()},children:[e(rr,{text:t.subscription_url.startsWith("/")?window.location.origin+t.subscription_url:t.subscription_url,onCopy:()=>{a([0,!0])},children:e("div",{children:e(te,{label:i[0]==0&&i[1]?X("usersTable.copied"):X("usersTable.copyLink"),placement:"top",children:e($,{p:"0 !important","aria-label":"copy subscription link",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:i[0]==0&&i[1]?e(gr,{}):e(Ci,{})})})})}),e(rr,{text:s,onCopy:()=>{a([1,!0])},children:e("div",{children:e(te,{label:i[0]==1&&i[1]?X("usersTable.copied"):X("usersTable.copyConfigs"),placement:"top",children:e($,{p:"0 !important","aria-label":"copy configs",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:i[0]==1&&i[1]?e(gr,{}):e(yi,{})})})})}),e(te,{label:"QR Code",placement:"top",children:e($,{p:"0 !important","aria-label":"qr code",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:()=>{o(t.links),n(t.subscription_url)},children:e(wi,{})})})]})},Di=({isFiltered:t})=>{const{onCreateUser:o}=I();return r(v,{padding:"5",py:"8",display:"flex",alignItems:"center",flexDirection:"column",gap:4,w:"full",children:[e(xi,{maxHeight:"200px",maxWidth:"200px",_dark:{'path[fill="#fff"]':{fill:"gray.800"},'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.700"},'circle[fill="#3182CE"]':{fill:"primary.300"}},_light:{'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.300"},'circle[fill="#3182CE"]':{fill:"primary.500"}}}),e(u,{fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:t?X("usersTable.noUserMatched"):X("usersTable.noUser")}),!t&&e(N,{size:"sm",colorScheme:"primary",onClick:()=>o(!0),children:X("createUser")})]})},Ui=()=>(g.exports.useEffect(()=>{I.getState().refetchUsers(),Bn()},[]),r(M,{justifyContent:"space-between",minH:"100vh",p:"6",rowGap:4,children:[r(v,{w:"full",children:[e(xs,{}),e(Wn,{mt:"4"}),e(os,{}),e(zi,{}),e(di,{}),e(Kn,{}),e(Ys,{}),e(Us,{}),e(Xs,{}),e(Ks,{}),e(Ws,{}),e(Bs,{}),e(Qs,{}),e(Jn,{})]}),e(Qr,{})]})),Ei=t=>g.exports.createElement("svg",{viewBox:"0 0 747 747",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},g.exports.createElement("path",{d:"M746.671 209.652V77.6572C746.671 72.9384 743.827 68.6832 739.468 66.8811C735.108 65.0738 730.093 66.0739 726.754 69.4072L579.354 216.807C577.453 202.386 570.203 189.203 559.037 179.87C547.875 170.542 533.615 165.744 519.083 166.432C504.551 167.12 490.807 173.24 480.573 183.583L414.375 249.776C412.417 235.391 405.141 222.25 393.985 212.959C382.823 203.662 368.594 198.88 354.083 199.552C339.578 200.224 325.849 206.302 315.594 216.588L274.343 257.828L19.9167 3.41515C16.5781 0.0818157 11.5625 -0.918184 7.20306 0.889149C2.84373 2.69648 0 6.94648 0 11.6651V143.649C0 146.743 1.22917 149.712 3.41667 151.899L191.843 340.339L3.41667 528.753C1.2292 530.94 0 533.909 0 537.003V668.997C0 673.716 2.84373 677.971 7.20306 679.773C11.5624 681.581 16.578 680.58 19.9167 677.247L167.317 529.847C169.285 544.233 176.561 557.358 187.718 566.65C198.869 575.947 213.098 580.728 227.603 580.066C242.103 579.404 255.838 573.342 266.098 563.071L332.295 496.874V496.879C334.259 511.264 341.535 524.395 352.691 533.686C363.853 542.977 378.082 547.759 392.587 547.092C407.093 546.421 420.822 540.348 431.077 530.066L472.327 488.826L726.754 743.239C728.941 745.427 731.91 746.656 735.004 746.656C736.535 746.661 738.056 746.359 739.473 745.77C743.832 743.963 746.671 739.708 746.671 734.989V602.994C746.671 599.901 745.442 596.932 743.254 594.744L554.827 406.318L743.254 217.904H743.259C745.447 215.717 746.676 212.748 746.676 209.654L746.671 209.652ZM23.3373 39.8118L257.844 274.318L208.328 323.818L23.3413 138.818L23.3373 39.8118ZM723.337 706.825L488.831 472.318L538.347 422.818L723.333 607.818L723.337 706.825ZM23.3373 541.825L332.097 233.078C338.764 226.719 347.624 223.172 356.843 223.172C366.056 223.172 374.916 226.719 381.588 233.078C388.151 239.641 391.838 248.548 391.838 257.828C391.838 267.114 388.151 276.016 381.588 282.577L23.3347 640.831L23.3373 541.825ZM249.604 546.575C240.755 555.419 227.864 558.872 215.781 555.638C203.703 552.398 194.265 542.961 191.027 530.883C187.792 518.8 191.245 505.91 200.089 497.06L497.076 200.074C505.92 191.23 518.811 187.772 530.893 191.011C542.971 194.246 552.409 203.678 555.648 215.76C558.888 227.839 555.434 240.73 546.591 249.572L249.604 546.575ZM723.337 204.815L414.577 513.562C407.911 519.926 399.051 523.473 389.832 523.473C380.618 523.473 371.753 519.926 365.087 513.562C358.529 506.999 354.842 498.098 354.842 488.816C354.842 479.535 358.529 470.634 365.087 464.071L723.34 105.818L723.337 204.815Z",fill:"currentColor"})),Ri=k.object({username:k.string().min(1,"login.fieldRequired"),password:k.string().min(1,"login.fieldRequired")}),Li=x(Ei,{baseStyle:{strokeWidth:"10px",w:12,h:12}}),Ti=x(fn,{baseStyle:{w:5,h:5,strokeWidth:"2px"}}),xr=()=>{var c,C;const[t,o]=g.exports.useState(""),[n,s]=g.exports.useState(!1),i=bn(),{t:a}=O();let l=xn();const{register:h,formState:{errors:p},handleSubmit:y}=je({resolver:Ke(Ri)});g.exports.useEffect(()=>{Ln(),l.pathname!=="/login"&&i("/login",{replace:!0})},[]);const d=_=>{o("");const f=new FormData;f.append("username",_.username),f.append("password",_.password),f.append("grant_type","password"),s(!0),W("/admin/token",{method:"post",body:f}).then(({access_token:S})=>{Rn(S),i("/")}).catch(S=>{o(S.response._data.detail)}).finally(s.bind(null,!1))};return r(M,{justifyContent:"space-between",minH:"100vh",p:"6",w:"full",children:[r(v,{w:"full",children:[e(w,{justifyContent:"end",w:"full",children:e(qr,{})}),e(w,{w:"full",justifyContent:"center",alignItems:"center",children:r(v,{w:"full",maxW:"340px",mt:"6",children:[r(M,{alignItems:"center",w:"full",children:[e(Li,{}),e(u,{fontSize:"2xl",fontWeight:"semibold",children:a("login.loginYourAccount")}),e(u,{color:"gray.600",_dark:{color:"gray.400"},children:a("login.welcomeBack")})]}),e(v,{w:"full",maxW:"300px",m:"auto",pt:"4",children:e("form",{onSubmit:y(d),children:r(M,{mt:4,rowGap:2,children:[e(T,{children:e(Ue,{w:"full",placeholder:a("username"),...h("username"),error:a((c=p==null?void 0:p.username)==null?void 0:c.message)})}),e(T,{children:e(Ue,{w:"full",type:"password",placeholder:a("password"),...h("password"),error:a((C=p==null?void 0:p.password)==null?void 0:C.message)})}),t&&r(qe,{status:"error",rounded:"md",children:[e(ht,{}),e(Lr,{children:t})]}),r(N,{isLoading:n,type:"submit",w:"full",colorScheme:"primary",children:[e(Ti,{marginRight:1}),a("login")]})]})})})]})})]}),e(Qr,{})]})},Ai=()=>W("/admin",{headers:{Authorization:`Bearer ${pt()}`}}),Mi=yn([{path:"/",element:e(Ui,{}),errorElement:e(xr,{}),loader:Ai},{path:"/login/",element:e(xr,{})}],{basename:"/dashboard/"});function Ni(){return e("main",{className:"p-8",children:e(Sn,{router:Mi})})}j.extend(Cn);j.extend(wn);j.extend(kn);j.extend(_n);j.extend(In);Vr(vn.get()||"light");zn.createRoot(document.getElementById("root")).render(e(It.StrictMode,{children:e(Dn,{theme:En,children:e(Un,{client:zt,children:e(Ni,{})})})})); + `}},colors:Os(n.length)}}}const Hs=x(ft,{baseStyle:{w:5,h:5}}),Bs=()=>{const{isShowingNodesUsage:t,onShowingNodesUsage:o}=I(),{fetchNodesUsage:n}=rt(),{t:s}=O(),[a,i]=g.exports.useState(!1),{colorMode:l}=Je(),h=s("userDialog.total"),[p,y]=g.exports.useState(mt(l,h)),[d,c]=g.exports.useState("1m"),C=S=>{n(S).then(L=>{const m=[],b=[];for(const W in L.usages){const H=L.usages[W];b.push(H.uplink+H.downlink),m.push(H.node_name)}y(mt(l,h,b,m))})};g.exports.useEffect(()=>{t&&C({start:j().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")})},[t]);const _=()=>{o(!1),c("1m")},f=a;return r(re,{isOpen:t,onClose:_,size:"2xl",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"full",children:[e(se,{pt:6,children:r(w,{gap:2,children:[e(le,{color:"primary",children:e(Hs,{color:"white"})}),e(u,{fontWeight:"semibold",fontSize:"lg",children:s("header.nodesUsage")})]})}),e(ae,{mt:3,disabled:f}),e(ie,{children:r(M,{gap:4,children:[e(eo,{defaultValue:d,onChange:(S,L)=>{c(S),C(L)}}),e(v,{justifySelf:"center",w:"full",maxW:"300px",mt:"4",children:e(g.exports.Suspense,{fallback:e(wr,{isIndeterminate:!0}),children:e(Wr,{options:p.options,series:p.series,type:"donut",height:"500px"})})})]})}),e(be,{mt:"3"})]})]})},ur=x(Ko),$s=x(Nr,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),Vs=x(en,{baseStyle:{w:6,h:6,color:"gray.600",_dark:{color:"white"}}}),Gs=x(Pr,{baseStyle:{w:5,h:5}}),Ys=()=>{const{QRcodeLinks:t,setQRCode:o,setSubLink:n,subscribeUrl:s}=I(),a=t!==null,[i,l]=g.exports.useState(0),{t:h}=O(),p=()=>{o(null),n(null)},y=String(s).startsWith("/")?window.location.origin+s:String(s);return r(re,{isOpen:a,onClose:p,children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(se,{pt:6,children:e(le,{color:"primary",children:e(Gs,{color:"white"})})}),e(ae,{mt:3}),t&&r(ie,{gap:{base:"20px",lg:"50px"},pr:{lg:"60px"},px:{base:"50px"},display:"flex",justifyContent:"center",flexDirection:{base:"column",lg:"row"},children:[s&&r(M,{children:[e(ur,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:y,bg:"white"}),e(u,{display:"block",textAlign:"center",pb:3,mt:1,children:h("qrcodeDialog.sublink")})]}),r(v,{w:"300px",children:[e(tn,{centerPadding:"0px",centerMode:!0,slidesToShow:1,slidesToScroll:1,dots:!1,afterChange:l,onInit:()=>l(0),nextArrow:e($,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"next",mr:"-4",children:e($s,{})}),prevArrow:e($,{size:"sm",position:"absolute",display:"flex !important",_before:{content:'""'},"aria-label":"prev",ml:"-4",children:e(Vs,{})}),children:t.map((d,c)=>e(w,{children:e(ur,{mx:"auto",size:300,p:"2",level:"L",includeMargin:!1,value:d,bg:"white"})},c))}),r(u,{display:"block",textAlign:"center",pb:3,mt:1,children:[i+1," / ",t.length]})]})]})]})]})},Zs=x(Ur,{baseStyle:{w:5,h:5}}),Qs=()=>{const[t,o]=g.exports.useState(!1),{isResetingAllUsage:n,onResetAllUsage:s,resetAllUsage:a}=I(),{t:i}=O(),l=ue(),h=()=>{s(!1)},p=()=>{o(!0),a().then(()=>{l({title:i("resetAllUsage.success"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{l({title:i("resetAllUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{o(!1)})};return r(re,{isCentered:!0,isOpen:n,onClose:h,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"red",children:e(Zs,{})})}),e(ae,{mt:3}),r(ie,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:i("resetAllUsage.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:i("resetAllUsage.prompt")})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:h,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Re,{size:"xs"}):void 0,children:i("reset")})]})]})]})},qs=x(bt,{baseStyle:{w:5,h:5}}),Xs=()=>{const[t,o]=g.exports.useState(!1),{resetUsageUser:n,resetDataUsage:s}=I(),{t:a}=O(),i=ue(),l=()=>{I.setState({resetUsageUser:null})},h=()=>{n&&(o(!0),s(n).then(()=>{i({title:a("resetUserUsage.success",{username:n.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{i({title:a("resetUserUsage.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{o(!1)}))};return r(re,{isCentered:!0,isOpen:!!n,onClose:l,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"blue",children:e(qs,{})})}),e(ae,{mt:3}),r(ie,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:a("resetUserUsage.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:a("resetUserUsage.prompt",{username:n.username})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"blue",onClick:h,leftIcon:t?e(Re,{size:"xs"}):void 0,children:a("reset")})]})]})]})},Js=x(bt,{baseStyle:{w:5,h:5}}),Ks=()=>{const[t,o]=g.exports.useState(!1),{revokeSubscriptionUser:n,revokeSubscription:s}=I(),{t:a}=O(),i=ue(),l=()=>{I.setState({revokeSubscriptionUser:null})},h=()=>{n&&(o(!0),s(n).then(()=>{i({title:a("revokeUserSub.success",{username:n.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(()=>{i({title:a("revokeUserSub.error"),status:"error",isClosable:!0,position:"top",duration:3e3})}).finally(()=>{o(!1)}))};return r(re,{isCentered:!0,isOpen:!!n,onClose:l,size:"sm",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ne,{mx:"3",children:[e(se,{pt:6,children:e(le,{color:"blue",children:e(Js,{})})}),e(ae,{mt:3}),r(ie,{children:[e(u,{fontWeight:"semibold",fontSize:"lg",children:a("revokeUserSub.title")}),n&&e(u,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(fe,{components:{b:e("b",{})},children:a("revokeUserSub.prompt",{username:n.username})})})]}),r(be,{display:"flex",children:[e(N,{size:"sm",onClick:l,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(N,{size:"sm",w:"full",colorScheme:"blue",onClick:h,leftIcon:t?e(Re,{size:"xs"}):void 0,children:a("revoke")})]})]})]})},ea=x(rn,{baseStyle:{strokeWidth:"2px",w:5,h:5}}),ta=({inbound:t,...o})=>{const{getCheckboxProps:n,getInputProps:s,getLabelProps:a,htmlProps:i}=jr(o),l=s();return r(v,{as:"label",children:[e("input",{...l}),r(v,{w:"fll",position:"relative",...i,cursor:"pointer",borderRadius:"sm",border:"1px solid",borderColor:"gray.200",_dark:{borderColor:"gray.600"},display:"flex",alignItems:"center",justifyContent:"space-between",overflow:"hidden",_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent",fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& p":{opacity:1}},__css:{"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...n(),children:[e(Mr,{size:"sm",w:"full",maxW:"full",color:"gray.700",_dark:{color:"gray.300"},textTransform:"uppercase",colorScheme:"primary",className:"inbound-item",isChecked:l.checked,pointerEvents:"none",flexGrow:1,children:e(w,{justify:"space-between",w:"full",maxW:"calc(100% - 20px)",spacing:0,gap:2,overflow:"hidden",children:r(u,{isTruncated:!0,...a(),fontSize:"xs",children:[t.tag," ",r(u,{as:"span",children:["(",t.network,")"]})]})})}),t.tls&&t.tls!="none"&&e(E,{fontSize:"xs",opacity:".8",size:"xs",children:t.tls})]})]})},ra=({disabled:t,title:o,description:n,toggleAccordion:s,isSelected:a,...i})=>{const l=Tt(),{inbounds:h}=I(),{getCheckboxProps:p,getInputProps:y,getLabelProps:d,htmlProps:c}=jr(i),C=y(),[_]=Hr({name:[`inbounds.${o}`],control:l.control}),{getCheckboxProps:f}=Or({value:_,onChange:b=>{if(l.setValue(`inbounds.${o}`,b),b.length===0){const W=l.getValues("selected_proxies");l.setValue("selected_proxies",W.filter(H=>H!==o)),s()}}}),S=_&&a&&(I.getState().inbounds.get(o)||[]).length!==_.length,L=(I.getState().inbounds.get(o)||[]).length>0,m=!a&&!L;return r(We,{isDisabled:!L,borderRadius:"md",borderStyle:"solid",border:"1px",borderColor:"gray.200",bg:m?"gray.100":"transparent",_dark:{borderColor:"gray.600",bg:m?"#364154":"transparent"},_checked:{bg:"gray.50",outline:"2px",boxShadow:"outline",outlineColor:"primary.500",borderColor:"transparent"},...p(),children:[r(v,{as:m?"span":"label",position:"relative",children:[S&&e(v,{position:"absolute",w:"2",h:"2",bg:"yellow.500",top:"-1",right:"-1",rounded:"full",zIndex:999}),e("input",{...C}),r(v,{w:"fll",position:"relative",...c,borderRadius:"md",cursor:m?"not-allowed":"pointer",_checked:{fontWeight:"medium",_dark:{bg:"gray.750",borderColor:"transparent"},"& > svg":{opacity:1,"&.checked":{display:"block"},"&.unchecked":{display:"none"}},"& p":{opacity:1}},__css:{"& > svg":{opacity:.3,"&.checked":{display:"none"},"&.unchecked":{display:"block"}},"& p":{opacity:.8}},textTransform:"capitalize",px:3,py:2,fontWeight:"medium",...p(),children:[e(Pe,{display:C.checked&&L?"block":"none",as:"span",className:"checked",color:"primary.200",position:"absolute",right:"3",top:"3",w:"auto",p:0,onClick:s,children:e($,{size:"sm","aria-label":"inbound settings",children:e(ea,{})})}),e(u,{fontSize:"sm",color:m?"gray.400":"gray.700",_dark:{color:m?"gray.500":"gray.300"},...d(),children:o}),e(u,{fontWeight:"medium",color:m?"gray.400":"gray.600",_dark:{color:m?"gray.500":"gray.400"},fontSize:"xs",children:n})]})]}),e(Oe,{px:2,pb:3,roundedBottom:"5px",pt:3,_dark:{bg:C.checked&&"gray.750"},children:r(M,{w:"full",rowGap:2,borderStyle:"solid",borderWidth:"1px",borderRadius:"md",pl:3,pr:3,pt:1.5,_dark:{bg:"gray.700"},children:[r(M,{alignItems:"flex-start",w:"full",children:[e(u,{fontSize:"sm",children:X("inbound")}),e(Mt,{gap:2,alignItems:"flex-start",w:"full",columns:1,spacing:1,children:(h.get(o)||[]).map(b=>e(ta,{...f({value:b.tag}),inbound:b},b.tag))})]}),o==="vmess"&&a&&e(M,{alignItems:"flex-start",w:"full",children:r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:"ID"}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vmess.id")})]})}),o==="vless"&&a&&r(M,{alignItems:"flex-start",w:"full",children:[r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:"ID"}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.vless.id")})]}),r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:"Flow"}),e(Ee,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.vless.flow"),children:ws.map(b=>e("option",{value:b.value,children:b.title},b.title))})]})]}),o==="trojan"&&a&&e(M,{alignItems:"flex-start",w:"full",children:r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:X("password")}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.trojan.password")})]})}),o==="shadowsocks"&&a&&r(M,{alignItems:"flex-start",w:"full",children:[r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:X("password")}),e(Fe,{fontSize:"xs",size:"sm",borderRadius:"6px",pl:2,pr:2,placeholder:X("userDialog.generatedByDefault"),...l.register("proxies.shadowsocks.password")})]}),r(T,{height:"66px",children:[e(u,{fontSize:"sm",pb:1,children:X("userDialog.method")}),e(Ee,{fontSize:"xs",size:"sm",borderRadius:"6px",...l.register("proxies.shadowsocks.method"),children:ks.map(b=>e("option",{value:b,children:b},b))})]})]})]})})]})},oa=g.exports.forwardRef(({name:t,list:o,onChange:n,disabled:s,...a},i)=>{const l=Tt(),[h,p]=g.exports.useState([]),y=c=>{h.includes(c)?h.splice(h.indexOf(c),1):h.push(c),p([...h])},{getCheckboxProps:d}=Or({value:a.value,onChange:c=>{var _;const C=c.filter(f=>!a.value.includes(f));C[0]&&l.setValue(`inbounds.${C[0]}`,(_=I.getState().inbounds.get(C[0]))==null?void 0:_.map(f=>f.tag)),p(h.filter(f=>c.find(S=>S===o[f].title))),n({target:{value:c,name:t}})}});return e(et,{allowToggle:!0,index:h,children:e(Mt,{ref:i,gap:2,alignItems:"flex-start",columns:1,spacing:1,children:o.map((c,C)=>e(ra,{toggleAccordion:y.bind(null,C),disabled:s,title:c.title,description:c.description,isSelected:!!a.value.find(_=>_===c.title),...d({value:c.title})},c.title))})})}),na=x(on,{baseStyle:{w:5,h:5}}),sa=x(Br,{baseStyle:{w:5,h:5}}),aa=x(ft,{baseStyle:{w:5,h:5}}),ia=k.object({username:k.string().min(1,{message:"Required"}),selected_proxies:k.array(k.string()).refine(t=>t.length>0,{message:"userDialog.selectOneProtocol"}),note:k.string().nullable(),proxies:k.record(k.string(),k.record(k.string(),k.any())).transform(t=>{const o=(n,s)=>{n&&n[s]===""&&delete n[s]};return o(t.vmess,"id"),o(t.vless,"id"),o(t.trojan,"password"),o(t.shadowsocks,"password"),o(t.shadowsocks,"method"),t}),data_limit:k.string().min(0,"The minimum number is 0").or(k.number()).nullable().transform(t=>t?Number((parseFloat(String(t))*1073741824).toFixed(5)):0),expire:k.number().nullable(),data_limit_reset_strategy:k.string(),status:k.string(),inbounds:k.record(k.string(),k.array(k.string())).transform(t=>(Object.keys(t).forEach(o=>{var n;Array.isArray(t[o])&&!((n=t[o])!=null&&n.length)&&delete t[o]}),t))}),la=t=>({...t,data_limit:t.data_limit?Number((t.data_limit/1073741824).toFixed(5)):t.data_limit,selected_proxies:Object.keys(t.proxies)}),kt=()=>{const t=Object.fromEntries(I.getState().inbounds),o={};for(const n in t)o[n]=t[n].map(s=>s.tag);return{selected_proxies:Object.keys(t),data_limit:null,expire:null,username:"",data_limit_reset_strategy:"no_reset",status:"active",note:"",inbounds:o,proxies:{vless:{id:"",flow:""},vmess:{id:""},trojan:{password:""},shadowsocks:{password:"",method:"chacha20-ietf-poly1305"}}}},ca=(t,o)=>{const n=t.reduce((s,a)=>({...s,[a]:{}}),{});return o&&t.forEach(s=>{o[s]&&(n[s]=o[s])}),n},da=()=>{var Be,$e,J,Ot,jt;const{editingUser:t,isCreatingNewUser:o,onCreateUser:n,editUser:s,fetchUserUsage:a,onEditingUser:i,createUser:l,onDeletingUser:h}=I(),p=!!t,y=o||p,[d,c]=g.exports.useState(!1),[C,_]=g.exports.useState(""),f=ue(),{t:S,i18n:L}=O(),{colorMode:m}=Je(),[b,W]=g.exports.useState(!1),H=()=>{W(D=>!D)},U=je({defaultValues:kt(),resolver:Ke(ia)});g.exports.useEffect(()=>I.subscribe(D=>D.inbounds,()=>{U.reset(kt())}),[]);const[A]=Hr({control:U.control,name:["data_limit"]}),B=S("userDialog.total"),[Y,z]=g.exports.useState(mt(m,B)),[F,Z]=g.exports.useState("1m"),R=D=>{a(t,D).then(V=>{const Le=[],Te=[];for(const xe in V.usages)Te.push(V.usages[xe].used_traffic),Le.push(V.usages[xe].node_name);z(mt(m,B,Te,Le))})};g.exports.useEffect(()=>{t&&(U.reset(la(t)),R({start:j().utc().subtract(30,"day").format("YYYY-MM-DDTHH:00:00")}))},[t]);const Q=D=>{c(!0);const V={edited:s,created:l},Le=p?"edited":"created";_(null);const{selected_proxies:Te,...xe}=D;let Ae={...xe,data_limit:D.data_limit,proxies:ca(Te,D.proxies),data_limit_reset_strategy:D.data_limit&&D.data_limit>0?D.data_limit_reset_strategy:"no_reset",status:D.status==="active"||D.status==="disabled"?D.status:"active"};V[Le](Ae).then(()=>{f({title:S(p?"userDialog.userEdited":"userDialog.userCreated",{username:D.username}),status:"success",isClosable:!0,position:"top",duration:3e3}),K()}).catch(q=>{var Ht,Bt,$t,Vt,Gt;(((Ht=q==null?void 0:q.response)==null?void 0:Ht.status)===409||((Bt=q==null?void 0:q.response)==null?void 0:Bt.status)===400)&&_((Vt=($t=q==null?void 0:q.response)==null?void 0:$t._data)==null?void 0:Vt.detail),((Gt=q==null?void 0:q.response)==null?void 0:Gt.status)===422&&Object.keys(q.response._data.detail).forEach(yt=>{_(q==null?void 0:q.response._data.detail[yt]),U.setError(yt,{type:"custom",message:q.response._data.detail[yt]})})}).finally(()=>{c(!1)})},K=()=>{U.reset(kt()),n(!1),i(null),_(null),W(!1),Z("1m")},nt=()=>{I.setState({resetUsageUser:t})},st=()=>{I.setState({revokeSubscriptionUser:t})},pe=d;return r(re,{isOpen:y,onClose:K,size:"2xl",children:[e(oe,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),e(Er,{...U,children:e(ne,{mx:"3",children:r("form",{onSubmit:U.handleSubmit(Q),children:[e(se,{pt:6,children:r(w,{gap:2,children:[e(le,{color:"primary",children:p?e(sa,{color:"white"}):e(na,{color:"white"})}),e(u,{fontWeight:"semibold",fontSize:"lg",children:S(p?"userDialog.editUserTitle":"createNewUser")})]})}),e(ae,{mt:3,disabled:pe}),r(ie,{children:[r(_r,{templateColumns:{base:"repeat(1, 1fr)",md:"repeat(2, 1fr)"},gap:3,children:[e(Ye,{children:r(M,{justifyContent:"space-between",children:[r(nn,{flexDirection:"column",gridAutoRows:"min-content",w:"full",children:[r(T,{mb:"10px",children:[e(G,{children:S("username")}),r(w,{children:[e(Ue,{size:"sm",type:"text",borderRadius:"6px",error:(Be=U.formState.errors.username)==null?void 0:Be.message,disabled:pe||p,...U.register("username")}),p&&e(w,{px:1,children:e(ze,{name:"status",control:U.control,render:({field:D})=>e(te,{placement:"top",label:"status: "+D.value,textTransform:"capitalize",children:e(v,{children:e(Ar,{colorScheme:"primary",disabled:D.value!=="active"&&D.value!=="disabled",isChecked:D.value==="active",onChange:V=>{V.target.checked?D.onChange("active"):D.onChange("disabled")}})})})})})]})]}),r(T,{mb:"10px",children:[e(G,{children:S("userDialog.dataLimit")}),e(ze,{control:U.control,name:"data_limit",render:({field:D})=>{var V;return e(Ue,{endAdornment:"GB",type:"number",size:"sm",borderRadius:"6px",onChange:D.onChange,disabled:pe,error:(V=U.formState.errors.data_limit)==null?void 0:V.message,value:D.value?String(D.value):""})}})]}),e(Tr,{in:!!(A&&A>0),animateOpacity:!0,style:{width:"100%"},children:r(T,{height:"66px",children:[e(G,{children:S("userDialog.periodicUsageReset")}),e(ze,{control:U.control,name:"data_limit_reset_strategy",render:({field:D})=>e(Ee,{size:"sm",...D,children:Ut.map(V=>e("option",{value:V.value,children:S("userDialog.resetStrategy"+V.title)},V.value))})})]})}),r(T,{mb:"10px",children:[e(G,{children:S("userDialog.expiryDate")}),e(ze,{name:"expire",control:U.control,render:({field:D})=>{var xe;function V(Ae){return j(j(Ae*1e3).utc()).toDate()}const{status:Le,time:Te}=Pt(D.value);return r(me,{children:[e(Fr,{locale:L.language.toLocaleLowerCase(),dateFormat:S("dateFormat"),minDate:new Date,selected:D.value?V(D.value):void 0,onChange:Ae=>{D.onChange({target:{value:Ae?j(j(Ae).set("hour",23).set("minute",59).set("second",59)).utc().valueOf()/1e3:0,name:"expire"}})},customInput:e(Ue,{size:"sm",type:"text",borderRadius:"6px",clearable:!0,disabled:pe,error:(xe=U.formState.errors.expire)==null?void 0:xe.message})}),D.value?e(sn,{children:S(Le,{time:Te})}):""]})}})]}),r(T,{mb:"10px",isInvalid:!!U.formState.errors.note,children:[e(G,{children:S("userDialog.note")}),e(an,{...U.register("note")}),e(ut,{children:(J=($e=U.formState.errors)==null?void 0:$e.note)==null?void 0:J.message})]})]}),C&&r(qe,{status:"error",display:{base:"none",md:"flex"},children:[e(ht,{}),C]})]})}),e(Ye,{children:r(T,{isInvalid:!!((Ot=U.formState.errors.selected_proxies)!=null&&Ot.message),children:[e(G,{children:S("userDialog.protocols")}),e(ze,{control:U.control,name:"selected_proxies",render:({field:D})=>e(oa,{list:[{title:"vmess",description:S("userDialog.vmessDesc")},{title:"vless",description:S("userDialog.vlessDesc")},{title:"trojan",description:S("userDialog.trojanDesc")},{title:"shadowsocks",description:S("userDialog.shadowsocksDesc")}],disabled:pe,...D})}),e(ut,{children:S((jt=U.formState.errors.selected_proxies)==null?void 0:jt.message)})]})}),p&&b&&e(Ye,{pt:6,colSpan:{base:1,md:2},children:r(M,{gap:4,children:[e(eo,{defaultValue:F,onChange:(D,V)=>{Z(D),R(V)}}),e(v,{width:{base:"100%",md:"70%"},justifySelf:"center",children:e(Wr,{options:Y.options,series:Y.series,type:"donut"})})]})})]}),C&&r(qe,{mt:"3",status:"error",display:{base:"flex",md:"none"},children:[e(ht,{}),C]})]}),e(be,{mt:"3",children:r(w,{justifyContent:"space-between",w:"full",gap:3,flexDirection:{base:"column",sm:"row"},children:[e(w,{justifyContent:"flex-start",w:{base:"full",sm:"unset"},children:p&&r(me,{children:[e(te,{label:S("delete"),placement:"top",children:e($,{"aria-label":"Delete",size:"sm",onClick:()=>{h(t),K()},children:e(tt,{})})}),e(te,{label:S("userDialog.usage"),placement:"top",children:e($,{"aria-label":"usage",size:"sm",onClick:H,children:e(aa,{})})}),e(N,{onClick:nt,size:"sm",children:S("userDialog.resetUsage")}),e(N,{onClick:st,size:"sm",children:S("userDialog.revokeSubscription")})]})}),e(w,{w:"full",maxW:{md:"50%",base:"full"},justify:"end",children:e(N,{type:"submit",size:"sm",px:"8",colorScheme:"primary",leftIcon:d?e(Re,{size:"xs"}):void 0,disabled:pe,children:S(p?"userDialog.editUser":"createUser")})})]})})]})})})]})},ua=t=>g.exports.createElement("svg",{xmlns:"http://www.w3.org/2000/svg","data-name":"Layer 1",width:782.04441,height:701.88002,viewBox:"0 0 782.04441 701.88002",xmlnsXlink:"http://www.w3.org/1999/xlink",...t},g.exports.createElement("path",{d:"M609.48783,100.59015l-25.44631,6.56209L270.53735,187.9987,245.091,194.56079A48.17927,48.17927,0,0,0,210.508,253.17865L320.849,681.05606a48.17924,48.17924,0,0,0,58.61776,34.58317l.06572-.01695,364.26536-93.93675.06572-.01695a48.17923,48.17923,0,0,0,34.58309-58.6178l-110.341-427.87741A48.17928,48.17928,0,0,0,609.48783,100.59015Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M612.94784,114.00532l-30.13945,7.77236L278.68955,200.20385l-30.139,7.77223a34.30949,34.30949,0,0,0-24.6275,41.74308l110.341,427.87741a34.30946,34.30946,0,0,0,41.7431,24.62736l.06572-.01695,364.26536-93.93674.06619-.01707a34.30935,34.30935,0,0,0,24.627-41.7429l-110.341-427.87741A34.30938,34.30938,0,0,0,612.94784,114.00532Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),g.exports.createElement("path",{d:"M590.19,252.56327,405.917,300.08359a8.01411,8.01411,0,0,1-4.00241-15.52046l184.273-47.52033A8.01412,8.01412,0,0,1,590.19,252.56327Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M628.955,270.49906,412.671,326.27437a8.01411,8.01411,0,1,1-4.00241-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M620.45825,369.93676l-184.273,47.52032a8.01411,8.01411,0,1,1-4.00242-15.52046l184.273-47.52032a8.01411,8.01411,0,1,1,4.00241,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M659.22329,387.87255l-216.284,55.77531a8.01411,8.01411,0,1,1-4.00242-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M650.72653,487.31025l-184.273,47.52033a8.01412,8.01412,0,0,1-4.00242-15.52047l184.273-47.52032a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M689.49156,505.246l-216.284,55.77532a8.01412,8.01412,0,1,1-4.00241-15.52047l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z",transform:"translate(-208.9778 -99.05999)",fill:"#f2f2f2"}),g.exports.createElement("path",{d:"M374.45884,348.80871l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76146L289.5963,304.81607a3.847,3.847,0,0,1,2.76145-4.68061l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76145l14.96947,58.04817A3.847,3.847,0,0,1,374.45884,348.80871Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M404.72712,466.1822l-65.21247,16.817a3.847,3.847,0,0,1-4.68062-2.76146l-14.96946-58.04816A3.847,3.847,0,0,1,322.626,417.509l65.21246-16.817a3.847,3.847,0,0,1,4.68062,2.76145l14.96946,58.04817A3.847,3.847,0,0,1,404.72712,466.1822Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M434.99539,583.55569l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76145l-14.96946-58.04817a3.847,3.847,0,0,1,2.76145-4.68062l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76146l14.96947,58.04816A3.847,3.847,0,0,1,434.99539,583.55569Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M863.63647,209.0517H487.31811a48.17928,48.17928,0,0,0-48.125,48.12512V699.05261a48.17924,48.17924,0,0,0,48.125,48.12507H863.63647a48.17924,48.17924,0,0,0,48.125-48.12507V257.17682A48.17928,48.17928,0,0,0,863.63647,209.0517Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M863.637,222.90589H487.31811a34.30948,34.30948,0,0,0-34.271,34.27093V699.05261a34.30947,34.30947,0,0,0,34.271,34.27088H863.637a34.30936,34.30936,0,0,0,34.27051-34.27088V257.17682A34.30937,34.30937,0,0,0,863.637,222.90589Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),g.exports.createElement("circle",{cx:694.19401,cy:614.02963,r:87.85039,fill:"#3182CE"}),g.exports.createElement("path",{d:"M945.18722,701.63087H914.63056V671.07421a11.45875,11.45875,0,0,0-22.9175,0v30.55666H861.1564a11.45875,11.45875,0,0,0,0,22.9175h30.55666V755.105a11.45875,11.45875,0,1,0,22.9175,0V724.54837h30.55666a11.45875,11.45875,0,0,0,0-22.9175Z",transform:"translate(-208.9778 -99.05999)",fill:"#fff"}),g.exports.createElement("path",{d:"M807.00068,465.71551H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01412,8.01412,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M840.05889,492.76314H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01411,8.01411,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M807.00068,586.929H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M840.05889,613.97661H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01412,8.01412,0,1,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M574.07028,505.04162H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V441.25158a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,505.04162Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M574.07028,626.25509H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V562.46505a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,626.25509Z",transform:"translate(-208.9778 -99.05999)",fill:"#e6e6e6"}),g.exports.createElement("path",{d:"M807.21185,330.781H666.91017a8.01411,8.01411,0,0,1,0-16.02823H807.21185a8.01411,8.01411,0,0,1,0,16.02823Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),g.exports.createElement("path",{d:"M840.27007,357.82862H666.91017a8.01411,8.01411,0,1,1,0-16.02822h173.3599a8.01411,8.01411,0,0,1,0,16.02822Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"}),g.exports.createElement("path",{d:"M635.85911,390.6071H506.51316a3.847,3.847,0,0,1-3.84277-3.84277V285.81706a3.847,3.847,0,0,1,3.84277-3.84277H635.85911a3.847,3.847,0,0,1,3.84277,3.84277V386.76433A3.847,3.847,0,0,1,635.85911,390.6071Z",transform:"translate(-208.9778 -99.05999)",fill:"#ccc"})),ha=t=>{if(!t)return null;const o=new Date(t+"Z");return Math.floor(o.getTime()/1e3)},hr=({lastOnline:t})=>{const o=Math.floor(Date.now()/1e3),n=ha(t);if(typeof t>"u"||t===null)return e("div",{className:"circle pulse orange"});const s=n?o-n:1/0;return s>0&&s<=60?e("div",{className:"circle pulse green"}):e("div",{className:"circle pulse red"})},pa=t=>{if(!t)return null;const o=new Date(t+"Z");return Math.floor(o.getTime()/1e3)},pr=({lastOnline:t})=>{const o=Math.floor(Date.now()/1e3),n=pa(t),s=n?o-n:null,a=n?Pt(n):{status:"",time:"Not Connected Yet"};return e(u,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:s&&s<=60?"Online":s?`${a.time} ago`:a.time})},ma=x(ln,{baseStyle:{w:4,h:4}}),ga=x(cn,{baseStyle:{w:4,h:4}}),mr=5;function fa(t,o,n){if(n0&&(a[0]=0,a[1]="prev-more"),a[a.length-1]{const{filters:t,onFilterChange:o,users:{total:n}}=I(),{limit:s,offset:a}=t,i=(a||0)/(s||1),l=Math.ceil(n/(s||1)),h=fa(l,i,7),p=c=>{o({...t,offset:c*s})},y=c=>{o({...t,limit:parseInt(c.target.value)}),jn(c.target.value)},{t:d}=O();return r(w,{justifyContent:"space-between",mt:4,w:"full",display:"flex",columnGap:{lg:4,md:0},rowGap:{md:0,base:4},flexDirection:{md:"row",base:"column"},children:[e(v,{order:{base:2,md:1},children:r(w,{children:[r(Ee,{minW:"60px",value:s,onChange:y,size:"sm",rounded:"md",children:[e("option",{children:"10"}),e("option",{children:"20"}),e("option",{children:"30"})]}),e(u,{whiteSpace:"nowrap",fontSize:"sm",children:d("itemsPerPage")})]})}),r(dn,{size:"sm",isAttached:!0,variant:"outline",order:{base:1,md:2},children:[e(N,{leftIcon:e(ma,{}),onClick:p.bind(null,i-1),isDisabled:i===0||l===0,children:d("previous")}),h.map(c=>typeof c=="string"?e(N,{children:"..."},c):e(N,{variant:c===i?"solid":"outline",onClick:p.bind(null,c),children:c+1},c)),e(N,{rightIcon:e(ga,{}),onClick:p.bind(null,i+1),isDisabled:i+1===l||l===0,children:d("next")})]})]})},xa=x(ua),He={baseStyle:{w:{base:4,md:5},h:{base:4,md:5}}},ya=x(un,He),Sa=x($r,He),gr=x(hn,He),Ca=x(Lt,He),wa=x(Pr,He),ka=x(Br,He),_a=x($r,{baseStyle:{width:"15px",height:"15px"}}),Ia=t=>{for(var o=0;o{const{used:o,total:n,dataLimitResetStrategy:s,totalUsedTraffic:a}=t,i=n===0||n===null;return e(w,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:r(u,{children:[ee(o)," /"," ",i?e(u,{as:"span",fontFamily:"system-ui",children:"\u221E"}):ee(n)]})})},fr=t=>{const{used:o,total:n,dataLimitResetStrategy:s,totalUsedTraffic:a,...i}=t,l=n===0||n===null,h=!l&&o/n*100>=100;return r(me,{children:[e(pn,{orientation:"horizontal",value:l?100:Math.min(o/n*100,100),colorScheme:h?"red":"primary",...i,children:e(mn,{h:"6px",borderRadius:"full",children:e(gn,{borderRadius:"full"})})}),r(w,{justifyContent:"space-between",fontSize:"xs",fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:[r(u,{children:[ee(o)," /"," ",l?e(u,{as:"span",fontFamily:"system-ui",children:"\u221E"}):ee(n)+(s&&s!=="no_reset"?" "+X("userDialog.resetStrategy"+Ia(s)):"")]}),r(u,{children:[X("usersTable.total"),": ",ee(a)]})]})]})},it=({sort:t,column:o})=>t.includes(o)?e(_a,{transform:t.startsWith("-")?void 0:"rotate(180deg)"}):null,za=t=>{const{filters:o,users:{users:n},users:s,onEditingUser:a,onFilterChange:i}=I(),{t:l}=O(),[h,p]=g.exports.useState(void 0),y=De({base:120,lg:72})||72,[d,c]=g.exports.useState(`${y}px`),C=De({base:!1,md:!0});g.exports.useEffect(()=>{const m=()=>{const b=document.querySelectorAll("#filters")[0];c(`${b.offsetHeight}px`)};window.addEventListener("scroll",m)},[]);const _=n.length!==s.total,f=m=>{let b=o.sort;b.includes(m)?b.startsWith("-")?b="-created_at":b="-"+m:b=m,i({sort:b})},S=m=>{i({status:m.target.value.length>0?m.target.value:void 0})},L=m=>{p(m===h?void 0:m)};return r(v,{id:"users-table",overflowX:{base:"unset",md:"unset"},children:[e(et,{allowMultiple:!0,display:{base:"block",md:"none"},index:h,children:r(Kt,{orientation:"vertical",zIndex:"docked",...t,children:[e(er,{zIndex:"docked",position:"relative",children:r(Me,{children:[e(ge,{position:"sticky",top:d,minW:"120px",pl:4,pr:4,cursor:"pointer",onClick:f.bind(null,"username"),children:r(w,{children:[e("span",{children:l("users")}),e(it,{sort:o.sort,column:"username"})]})}),e(ge,{position:"sticky",top:d,minW:"50px",pl:0,pr:0,w:"140px",cursor:"pointer",children:r(w,{spacing:0,position:"relative",children:[r(u,{position:"absolute",_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,w:"100%",children:[l("usersTable.status"),o.status?": "+o.status:""]}),r(Ee,{value:o.sort,fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",p:0,border:0,h:"auto",w:"auto",icon:e(me,{}),_focusVisible:{border:"0 !important"},onChange:S,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ge,{position:"sticky",top:d,minW:"100px",cursor:"pointer",pr:0,onClick:f.bind(null,"used_traffic"),children:r(w,{children:[e("span",{children:l("usersTable.dataUsage")}),e(it,{sort:o.sort,column:"used_traffic"})]})}),e(ge,{position:"sticky",top:d,minW:"32px",w:"32px",p:0,cursor:"pointer"})]})}),e(tr,{children:!C&&(n==null?void 0:n.map((m,b)=>r(g.exports.Fragment,{children:[r(Me,{onClick:L.bind(null,b),cursor:"pointer",children:[e(ce,{borderBottom:0,minW:"100px",pl:4,pr:4,maxW:"calc(100vw - 50px - 32px - 100px - 48px)",children:r("div",{className:"flex-status",children:[e(hr,{lastOnline:m.online_at}),e(u,{isTruncated:!0,children:m.username})]})}),e(ce,{borderBottom:0,minW:"50px",pl:0,pr:0,children:e(lt,{compact:!0,showDetail:!1,expiryDate:m.expire,status:m.status})}),e(ce,{borderBottom:0,minW:"100px",pr:0,children:e(va,{totalUsedTraffic:m.lifetime_used_traffic,dataLimitResetStrategy:m.data_limit_reset_strategy,used:m.used_traffic,total:m.data_limit,colorScheme:Ze[m.status].bandWidthColor})}),e(ce,{p:0,borderBottom:0,w:"32px",minW:"32px",children:e(Sa,{color:"gray.600",_dark:{color:"gray.400"},transition:"transform .2s ease-out",transform:h===b?"rotate(180deg)":"0deg"})})]}),e(Me,{className:"collapsible",onClick:L.bind(null,b),children:e(ce,{p:0,colSpan:4,children:r(We,{border:0,children:[e(Pe,{display:"none"}),e(Oe,{border:0,cursor:"pointer",px:6,py:3,children:r(M,{justifyContent:"space-between",spacing:"4",children:[r(M,{alignItems:"flex-start",w:"full",spacing:-1,children:[e(u,{textTransform:"capitalize",fontSize:"xs",fontWeight:"bold",color:"gray.600",_dark:{color:"gray.400"},children:l("usersTable.dataUsage")}),e(v,{width:"full",minW:"230px",children:e(fr,{totalUsedTraffic:m.lifetime_used_traffic,dataLimitResetStrategy:m.data_limit_reset_strategy,used:m.used_traffic,total:m.data_limit,colorScheme:Ze[m.status].bandWidthColor})})]}),r(w,{w:"full",justifyContent:"space-between",children:[r(v,{width:"full",children:[e(lt,{compact:!0,expiryDate:m.expire,status:m.status}),e(pr,{lastOnline:m.online_at})]}),r(w,{children:[e(br,{user:m}),e(te,{label:l("userDialog.editUser"),placement:"top",children:e($,{p:"0 !important","aria-label":"Edit user",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:W=>{W.stopPropagation(),a(m)},children:e(ka,{})})})]})]})]})})]})})})]},m.username)))})]})}),r(Kt,{orientation:"vertical",display:{base:"none",md:"table"},...t,children:[e(er,{zIndex:"docked",position:"relative",children:r(Me,{children:[e(ge,{position:"sticky",top:{base:"unset",md:d},minW:"140px",cursor:"pointer",onClick:f.bind(null,"username"),children:r(w,{children:[e("span",{children:l("username")}),e(it,{sort:o.sort,column:"username"})]})}),e(ge,{position:"sticky",top:{base:"unset",md:d},width:"400px",minW:"150px",cursor:"pointer",children:r(w,{spacing:0,position:"relative",children:[r(u,{position:"absolute",_dark:{bg:"gray.750"},_light:{bg:"#F9FAFB"},userSelect:"none",pointerEvents:"none",zIndex:1,w:"100%",children:[l("usersTable.status"),o.status?": "+o.status:""]}),r(Ee,{fontSize:"xs",fontWeight:"extrabold",textTransform:"uppercase",cursor:"pointer",p:0,border:0,h:"auto",w:"auto",icon:e(me,{}),_focusVisible:{border:"0 !important"},value:o.sort,onChange:S,children:[e("option",{}),e("option",{children:"active"}),e("option",{children:"disabled"}),e("option",{children:"limited"}),e("option",{children:"expired"})]})]})}),e(ge,{position:"sticky",top:{base:"unset",md:d},width:"350px",minW:"230px",cursor:"pointer",onClick:f.bind(null,"used_traffic"),children:r(w,{children:[e("span",{children:l("usersTable.dataUsage")}),e(it,{sort:o.sort,column:"used_traffic"})]})}),e(ge,{position:"sticky",top:{base:"unset",md:d},width:"200px",minW:"180px"})]})}),r(tr,{children:[C&&(n==null?void 0:n.map((m,b)=>r(Me,{className:xt("interactive",{"last-row":b===n.length-1}),onClick:()=>a(m),children:[e(ce,{minW:"140px",children:r("div",{className:"flex-status",children:[e(hr,{lastOnline:m.online_at}),m.username,e(pr,{lastOnline:m.online_at})]})}),e(ce,{width:"400px",minW:"150px",children:e(lt,{expiryDate:m.expire,status:m.status})}),e(ce,{width:"350px",minW:"230px",children:e(fr,{totalUsedTraffic:m.lifetime_used_traffic,dataLimitResetStrategy:m.data_limit_reset_strategy,used:m.used_traffic,total:m.data_limit,colorScheme:Ze[m.status].bandWidthColor})}),e(ce,{width:"200px",minW:"180px",children:e(br,{user:m})})]},m.username))),n.length==0&&e(Me,{children:e(ce,{colSpan:4,children:e(Da,{isFiltered:_})})})]})]}),e(ba,{})]})},br=({user:t})=>{const{setQRCode:o,setSubLink:n}=I(),s=t.links.join(`\r +`),[a,i]=g.exports.useState([-1,!1]);return g.exports.useEffect(()=>{a[1]&&setTimeout(()=>{i([-1,!1])},1e3)},[a]),r(w,{justifyContent:"flex-end",onClick:l=>{l.preventDefault(),l.stopPropagation()},children:[e(rr,{text:t.subscription_url.startsWith("/")?window.location.origin+t.subscription_url:t.subscription_url,onCopy:()=>{i([0,!0])},children:e("div",{children:e(te,{label:a[0]==0&&a[1]?X("usersTable.copied"):X("usersTable.copyLink"),placement:"top",children:e($,{p:"0 !important","aria-label":"copy subscription link",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:a[0]==0&&a[1]?e(gr,{}):e(Ca,{})})})})}),e(rr,{text:s,onCopy:()=>{i([1,!0])},children:e("div",{children:e(te,{label:a[0]==1&&a[1]?X("usersTable.copied"):X("usersTable.copyConfigs"),placement:"top",children:e($,{p:"0 !important","aria-label":"copy configs",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},children:a[0]==1&&a[1]?e(gr,{}):e(ya,{})})})})}),e(te,{label:"QR Code",placement:"top",children:e($,{p:"0 !important","aria-label":"qr code",bg:"transparent",_dark:{_hover:{bg:"gray.700"}},size:{base:"sm",md:"md"},onClick:()=>{o(t.links),n(t.subscription_url)},children:e(wa,{})})})]})},Da=({isFiltered:t})=>{const{onCreateUser:o}=I();return r(v,{padding:"5",py:"8",display:"flex",alignItems:"center",flexDirection:"column",gap:4,w:"full",children:[e(xa,{maxHeight:"200px",maxWidth:"200px",_dark:{'path[fill="#fff"]':{fill:"gray.800"},'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.700"},'circle[fill="#3182CE"]':{fill:"primary.300"}},_light:{'path[fill="#f2f2f2"], path[fill="#e6e6e6"], path[fill="#ccc"]':{fill:"gray.300"},'circle[fill="#3182CE"]':{fill:"primary.500"}}}),e(u,{fontWeight:"medium",color:"gray.600",_dark:{color:"gray.400"},children:t?X("usersTable.noUserMatched"):X("usersTable.noUser")}),!t&&e(N,{size:"sm",colorScheme:"primary",onClick:()=>o(!0),children:X("createUser")})]})},Ua=()=>(g.exports.useEffect(()=>{I.getState().refetchUsers(),Bn()},[]),r(M,{justifyContent:"space-between",minH:"100vh",p:"6",rowGap:4,children:[r(v,{w:"full",children:[e(xs,{}),e(Pn,{mt:"4"}),e(os,{}),e(za,{}),e(da,{}),e(Kn,{}),e(Ys,{}),e(Us,{}),e(Xs,{}),e(Ks,{}),e(Ps,{}),e(Bs,{}),e(Qs,{}),e(Jn,{})]}),e(Qr,{})]})),Ea=t=>g.exports.createElement("svg",{viewBox:"0 0 747 747",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},g.exports.createElement("path",{d:"M746.671 209.652V77.6572C746.671 72.9384 743.827 68.6832 739.468 66.8811C735.108 65.0738 730.093 66.0739 726.754 69.4072L579.354 216.807C577.453 202.386 570.203 189.203 559.037 179.87C547.875 170.542 533.615 165.744 519.083 166.432C504.551 167.12 490.807 173.24 480.573 183.583L414.375 249.776C412.417 235.391 405.141 222.25 393.985 212.959C382.823 203.662 368.594 198.88 354.083 199.552C339.578 200.224 325.849 206.302 315.594 216.588L274.343 257.828L19.9167 3.41515C16.5781 0.0818157 11.5625 -0.918184 7.20306 0.889149C2.84373 2.69648 0 6.94648 0 11.6651V143.649C0 146.743 1.22917 149.712 3.41667 151.899L191.843 340.339L3.41667 528.753C1.2292 530.94 0 533.909 0 537.003V668.997C0 673.716 2.84373 677.971 7.20306 679.773C11.5624 681.581 16.578 680.58 19.9167 677.247L167.317 529.847C169.285 544.233 176.561 557.358 187.718 566.65C198.869 575.947 213.098 580.728 227.603 580.066C242.103 579.404 255.838 573.342 266.098 563.071L332.295 496.874V496.879C334.259 511.264 341.535 524.395 352.691 533.686C363.853 542.977 378.082 547.759 392.587 547.092C407.093 546.421 420.822 540.348 431.077 530.066L472.327 488.826L726.754 743.239C728.941 745.427 731.91 746.656 735.004 746.656C736.535 746.661 738.056 746.359 739.473 745.77C743.832 743.963 746.671 739.708 746.671 734.989V602.994C746.671 599.901 745.442 596.932 743.254 594.744L554.827 406.318L743.254 217.904H743.259C745.447 215.717 746.676 212.748 746.676 209.654L746.671 209.652ZM23.3373 39.8118L257.844 274.318L208.328 323.818L23.3413 138.818L23.3373 39.8118ZM723.337 706.825L488.831 472.318L538.347 422.818L723.333 607.818L723.337 706.825ZM23.3373 541.825L332.097 233.078C338.764 226.719 347.624 223.172 356.843 223.172C366.056 223.172 374.916 226.719 381.588 233.078C388.151 239.641 391.838 248.548 391.838 257.828C391.838 267.114 388.151 276.016 381.588 282.577L23.3347 640.831L23.3373 541.825ZM249.604 546.575C240.755 555.419 227.864 558.872 215.781 555.638C203.703 552.398 194.265 542.961 191.027 530.883C187.792 518.8 191.245 505.91 200.089 497.06L497.076 200.074C505.92 191.23 518.811 187.772 530.893 191.011C542.971 194.246 552.409 203.678 555.648 215.76C558.888 227.839 555.434 240.73 546.591 249.572L249.604 546.575ZM723.337 204.815L414.577 513.562C407.911 519.926 399.051 523.473 389.832 523.473C380.618 523.473 371.753 519.926 365.087 513.562C358.529 506.999 354.842 498.098 354.842 488.816C354.842 479.535 358.529 470.634 365.087 464.071L723.34 105.818L723.337 204.815Z",fill:"currentColor"})),Ra=k.object({username:k.string().min(1,"login.fieldRequired"),password:k.string().min(1,"login.fieldRequired")}),La=x(Ea,{baseStyle:{strokeWidth:"10px",w:12,h:12}}),Ta=x(fn,{baseStyle:{w:5,h:5,strokeWidth:"2px"}}),xr=()=>{var c,C;const[t,o]=g.exports.useState(""),[n,s]=g.exports.useState(!1),a=bn(),{t:i}=O();let l=xn();const{register:h,formState:{errors:p},handleSubmit:y}=je({resolver:Ke(Ra)});g.exports.useEffect(()=>{Ln(),l.pathname!=="/login"&&a("/login",{replace:!0})},[]);const d=_=>{o("");const f=new FormData;f.append("username",_.username),f.append("password",_.password),f.append("grant_type","password"),s(!0),P("/admin/token",{method:"post",body:f}).then(({access_token:S})=>{Rn(S),a("/")}).catch(S=>{o(S.response._data.detail)}).finally(s.bind(null,!1))};return r(M,{justifyContent:"space-between",minH:"100vh",p:"6",w:"full",children:[r(v,{w:"full",children:[e(w,{justifyContent:"end",w:"full",children:e(qr,{})}),e(w,{w:"full",justifyContent:"center",alignItems:"center",children:r(v,{w:"full",maxW:"340px",mt:"6",children:[r(M,{alignItems:"center",w:"full",children:[e(La,{}),e(u,{fontSize:"2xl",fontWeight:"semibold",children:i("login.loginYourAccount")}),e(u,{color:"gray.600",_dark:{color:"gray.400"},children:i("login.welcomeBack")})]}),e(v,{w:"full",maxW:"300px",m:"auto",pt:"4",children:e("form",{onSubmit:y(d),children:r(M,{mt:4,rowGap:2,children:[e(T,{children:e(Ue,{w:"full",placeholder:i("username"),...h("username"),error:i((c=p==null?void 0:p.username)==null?void 0:c.message)})}),e(T,{children:e(Ue,{w:"full",type:"password",placeholder:i("password"),...h("password"),error:i((C=p==null?void 0:p.password)==null?void 0:C.message)})}),t&&r(qe,{status:"error",rounded:"md",children:[e(ht,{}),e(Lr,{children:t})]}),r(N,{isLoading:n,type:"submit",w:"full",colorScheme:"primary",children:[e(Ta,{marginRight:1}),i("login")]})]})})})]})})]}),e(Qr,{})]})},Aa=()=>P("/admin",{headers:{Authorization:`Bearer ${pt()}`}}),Ma=yn([{path:"/",element:e(Ua,{}),errorElement:e(xr,{}),loader:Aa},{path:"/login/",element:e(xr,{})}],{basename:"/dashboard/"});function Na(){return e("main",{className:"p-8",children:e(Sn,{router:Ma})})}j.extend(Cn);j.extend(wn);j.extend(kn);j.extend(_n);j.extend(In);Vr(vn.get()||"light");zn.createRoot(document.getElementById("root")).render(e(It.StrictMode,{children:e(Dn,{theme:En,children:e(Un,{client:zt,children:e(Na,{})})})})); diff --git a/app/dashboard/build/assets/vendor.d3666332.js b/app/dashboard/build/assets/vendor.764109dc.js similarity index 100% rename from app/dashboard/build/assets/vendor.d3666332.js rename to app/dashboard/build/assets/vendor.764109dc.js diff --git a/app/dashboard/build/index.html b/app/dashboard/build/index.html index cd865e25b..4ccace450 100644 --- a/app/dashboard/build/index.html +++ b/app/dashboard/build/index.html @@ -33,8 +33,8 @@ - - + +