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