diff --git a/app/__init__.py b/app/__init__.py
index 2e7c2995e..2144b4975 100755
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -11,7 +11,7 @@
from config import DOCS, XRAY_SUBSCRIPTION_PATH
-__version__ = "0.5.2"
+__version__ = "0.6.0"
app = FastAPI(
diff --git a/app/dashboard/build/404.html b/app/dashboard/build/404.html
index c075c0c83..128e9aed0 100644
--- a/app/dashboard/build/404.html
+++ b/app/dashboard/build/404.html
@@ -33,7 +33,7 @@
-
+
diff --git a/app/dashboard/build/assets/index.ec887564.js b/app/dashboard/build/assets/index.a97b5769.js
similarity index 65%
rename from app/dashboard/build/assets/index.ec887564.js
rename to app/dashboard/build/assets/index.a97b5769.js
index 55758c578..4f7ab6a1d 100644
--- a/app/dashboard/build/assets/index.ec887564.js
+++ b/app/dashboard/build/assets/index.a97b5769.js
@@ -1,4 +1,4 @@
-import{i as Mt,B as sn,a as an,b as ln,j as vr,d as B,U as jt,z as cn,r as dn,f as hn,Q as un,e as pn,$ as mn,c as zt,g as x,h as gn,C as fn,k as Dt,u as Ht,l as j,m as r,H as _,n as e,T as h,o as bn,p as D,s as xn,q as f,t as ht,J as yn,v as Ir,A as Et,w as Sn,x as Cn,M as oe,y as se,D as ae,E as ie,F as le,G as fe,I as Ve,K as zr,L as wn,N as lt,O as ce,P as R,R as H,S as Dr,V as ne,W as U,X as pe,Y as Z,Z as Re,_ as F,a0 as Ut,a1 as rt,a2 as _n,a3 as Ee,a4 as Ne,a5 as kn,a6 as Er,a7 as Ur,a8 as st,a9 as St,aa as vn,ab as je,ac as Ct,ad as Xt,ae as In,af as Rr,ag as Lr,ah as Tr,ai as me,aj as zn,ak as Dn,al as En,am as Un,an as Rn,ao as Bt,ap as Ar,aq as Mr,ar as ge,as as Jt,at as Ln,au as Tn,av as An,aw as Nt,ax as Mn,ay as Nn,az as Fn,aA as Pn,aB as Wn,aC as On,aD as wt,aE as jn,aF as Me,aG as Hn,aH as S,aI as ut,aJ as Nr,aK as pt,aL as N,aM as $t,aN as Bn,aO as He,aP as Be,aQ as Ft,aR as $e,aS as Ce,aT as we,aU as _e,aV as ke,aW as ve,aX as Ie,aY as Kt,aZ as $n,a_ as _t,a$ as at,b0 as Vt,b1 as Vn,b2 as Gn,b3 as Yn,b4 as Fr,b5 as Zn,b6 as ct,b7 as kt,b8 as Pr,b9 as Qn,ba as qn,bb as Wr,bc as Ae,bd as Xn,be as Jn,bf as Kn,bg as Gt,bh as Rt,bi as er,bj as Or,bk as eo,bl as to,bm as tr,bn as ro,bo as rr,bp as jr,bq as no,br as Hr,bs as oo,bt as so,bu as Br,bv as ao,bw as io,bx as $r,by as Vr,bz as Gr,bA as X,bB as lo,bC as Yr,bD as nr,bE as co,bF as ho,bG as uo,bH as po,bI as mo,bJ as go,bK as Zr,bL as fo,bM as or,bN as sr,bO as Oe,bP as ze,bQ as ar,bR as ue,bS as ir,bT as bo,bU as xo,bV as yo,bW as So,bX as Co,bY as wo,bZ as _o,b_ as ko,b$ as vo,c0 as Io,c1 as zo,c2 as Do,c3 as Eo,c4 as Uo,c5 as Ro,c6 as Lo,c7 as To}from"./vendor.8aa8dc93.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.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 o(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=o(i);fetch(i.href,a)}})();Mt.use(sn).use(an).use(ln).init({debug:{}.NODE_ENV==="development",returnNull:!1,fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1},load:"languageOnly",detection:{caches:["localStorage","sessionStorage","cookie"]},backend:{loadPath:vr(["/dashboard/","locales/{{lng}}.json"])}},function(t,n){B.locale(Mt.language)});Mt.on("languageChanged",t=>{B.locale(t)});jt("zh-cn",cn);jt("ru",dn);jt("fa",hn);const Pt=new un,Qr=t=>{const n=document.querySelector('meta[name="theme-color"]');n==null||n.setAttribute("content",t=="dark"?"#1A202C":"#3B81F6")},Ao=pn({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 vt=()=>localStorage.getItem("token"),Mo=t=>{localStorage.setItem("token",t)},No=()=>{localStorage.removeItem("token")},Fo=mn.create({baseURL:"/api/"}),Po=(t,n={})=>(vt()&&(n.headers={...(n==null?void 0:n.headers)||{},Authorization:`Bearer ${vt()}`}),Fo(t,n)),O=Po,Wo=zt(t=>({isLoading:!0,isPostLoading:!1,version:null,started:!1,logs_websocket:null,config:"",fetchCoreSettings:()=>{t({isLoading:!0}),Promise.all([O("/core").then(({version:n,started:o,logs_websocket:s})=>t({version:n,started:o,logs_websocket:s})),O("/core/config").then(n=>t({config:n}))]).finally(()=>t({isLoading:!1}))},updateConfig:n=>(t({isPostLoading:!0}),O("/core/config",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})})),restartCore:()=>O("/core/restart",{method:"POST"})}));function re(t,n=2,o=!1){if(!+t)return"0 B";const s=1024,i=n<0?0:n,a=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(t)/Math.log(s));return o?[parseFloat((t/Math.pow(s,l)).toFixed(i)),a[l]]:`${parseFloat((t/Math.pow(s,l)).toFixed(i))} ${a[l]}`}const lr=t=>{if(t!==null)return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Oo=x(gn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),jo=x(fn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Ho=x(Dt,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Lt=({title:t,content:n,icon:o})=>r(bn,{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(_,{alignItems:"center",columnGap:"4",children:[e(D,{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:o}),e(h,{color:"gray.600",_dark:{color:"gray.300"},fontWeight:"medium",textTransform:"capitalize",fontSize:"sm",children:t})]}),e(D,{fontSize:"3xl",fontWeight:"semibold",mt:"2",children:n})]}),Wt="statistics-query-key",Bo=t=>{const{version:n}=E(),{data:o}=Ht({queryKey:Wt,queryFn:()=>O("/system"),refetchInterval:5e3,onSuccess:({version:i})=>{n!==i&&E.setState({version:i})}}),{t:s}=j();return r(_,{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(Lt,{title:s("activeUsers"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:lr(o.users_active)}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:["/ ",lr(o.total_user)]})]}),icon:e(Oo,{})}),e(Lt,{title:s("dataUsage"),content:o&&re(o.incoming_bandwidth+o.outgoing_bandwidth),icon:e(jo,{})}),e(Lt,{title:s("memoryUsage"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:re(o.mem_used,1,!0)[0]}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:[re(o.mem_used,1,!0)[1]," /"," ",re(o.mem_total,1)]})]}),icon:e(Ho,{})})]})},qr="marzban-num-users-per-page",cr=10,$o=()=>{const t=localStorage.getItem(qr)||cr.toString();return parseInt(t)||cr},Vo=t=>localStorage.setItem(qr,t),Go=t=>{for(const n in t)t[n]||delete t[n];return E.setState({loading:!0}),O("/users",{query:t}).then(n=>(E.setState({users:n}),n)).finally(()=>{E.setState({loading:!1})})},Yo=()=>O("/inbounds").then(t=>{E.setState({inbounds:new Map(Object.entries(t))})}).finally(()=>{E.setState({loading:!1})}),E=zt(xn((t,n)=>({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:$o(),sort:"-created_at"},inbounds:new Map,isEditingCore:!1,refetchUsers:()=>{Go(n().filters)},resetAllUsage:()=>O("/users/reset",{method:"POST"}).then(()=>{n().onResetAllUsage(!1),n().refetchUsers()}),onResetAllUsage:o=>t({isResetingAllUsage:o}),onCreateUser:o=>t({isCreatingNewUser:o}),onEditingUser:o=>{t({editingUser:o})},onDeletingUser:o=>{t({deletingUser:o})},onFilterChange:o=>{t({filters:{...n().filters,...o}}),n().refetchUsers()},setQRCode:o=>{t({QRcodeLinks:o})},deleteUser:o=>(t({editingUser:null}),O(`/user/${o.username}`,{method:"DELETE"}).then(()=>{t({deletingUser:null}),n().refetchUsers(),Pt.invalidateQueries(Wt)})),createUser:o=>O("/user",{method:"POST",body:o}).then(()=>{t({editingUser:null}),n().refetchUsers(),Pt.invalidateQueries(Wt)}),editUser:o=>O(`/user/${o.username}`,{method:"PUT",body:o}).then(()=>{n().onEditingUser(null),n().refetchUsers()}),fetchUserUsage:(o,s)=>{for(const i in s)s[i]||delete s[i];return O(`/user/${o.username}/usage`,{method:"GET",query:s})},onEditingHosts:o=>{t({isEditingHosts:o})},onEditingNodes:o=>{t({isEditingNodes:o})},onShowingNodesUsage:o=>{t({isShowingNodesUsage:o})},setSubLink:o=>{t({subscribeUrl:o})},resetDataUsage:o=>O(`/user/${o.username}/reset`,{method:"POST"}).then(()=>{t({resetUsageUser:null}),n().refetchUsers()}),revokeSubscription:o=>O(`/user/${o.username}/revoke_sub`,{method:"POST"}).then(s=>{t({revokeSubscriptionUser:null,editingUser:s}),n().refetchUsers()})}))),de=({children:t,color:n})=>e(D,{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:`${n}.400`,opacity:".5",borderRadius:"5px",zIndex:"1",_dark:{bg:`${n}.400`}},_after:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100% + 10px)",height:"calc(100% + 10px)",transform:"translate(-5px, -5px)",bg:`${n}.400`,opacity:".4",borderRadius:"8px",zIndex:"1",_dark:{bg:`${n}.400`}},children:e(h,{color:`${n}.500`,_dark:{color:`${n}.900`},position:"relative",zIndex:"2",children:t})});window.ace.define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!0,n.cssClass="ace-nord-dark",t("../lib/dom").importCssString(n.cssText,n.cssClass)});window.ace.define("ace/theme/dawn",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!1,n.cssClass="ace-dawn",t("../lib/dom").importCssString(n.cssText,n.cssClass)});const Zo=f.exports.forwardRef(({json:t,onChange:n,mode:o="code"},s)=>{const{colorMode:i}=ht(),a={mode:o,onChangeText:n,statusBar:!1,mainMenuBar:!1,theme:i==="dark"?"ace/theme/nord_dark":"ace/theme/dawn"},l=f.exports.useRef(null),u=f.exports.useRef(null);return f.exports.useEffect(()=>(u.current=new yn(l.current,a),()=>{u.current&&u.current.destroy()}),[]),f.exports.useEffect(()=>{u.current&&u.current.update(t)},[t]),e(D,{ref:s,border:"1px solid",borderColor:"gray.300",_dark:{borderColor:"gray.500"},borderRadius:5,h:"full",children:e(D,{height:"full",ref:l})})}),dr=500,Qo=x(Ir,{baseStyle:{w:5,h:5}}),qo=x(Et,{baseStyle:{w:4,h:4}}),Xo=x(Sn,{baseStyle:{w:4,h:4}}),Jo=x(Cn,{baseStyle:{w:3,h:3}}),Ko=t=>({[rt.ReadyState.CONNECTING]:"connecting",[rt.ReadyState.OPEN]:"connected",[rt.ReadyState.CLOSING]:"closed",[rt.ReadyState.CLOSED]:"closed",[rt.ReadyState.UNINSTANTIATED]:"closed"})[t],es=()=>{try{let t=new URL("/api/".startsWith("/")?window.location.origin+"/api/":"/api/");return(t.protocol==="https:"?"wss://":"ws://")+vr([t.host+t.pathname,"/core/logs"])+"?interval=1&token="+vt()}catch(t){return console.error("Unable to generate websocket url"),console.error(t),null}};let Le=[];const ts=()=>{const{isEditingCore:t}=E(),{fetchCoreSettings:n,updateConfig:o,isLoading:s,config:i,isPostLoading:a,version:l,restartCore:u}=Wo(),p=f.exports.useRef(null),[C,d]=f.exports.useState([]),{t:c}=j(),w=fe(),v=Ve({defaultValues:{config:i||{}}});f.exports.useEffect(()=>{i&&v.setValue("config",i)},[i]),f.exports.useEffect(()=>{t&&n()},[t]);const m=f.exports.useRef(!0),y=f.exports.useCallback(zr(L=>{var J,z,P;const V=Math.abs((((J=p.current)==null?void 0:J.scrollTop)||0)-(((z=p.current)==null?void 0:z.scrollHeight)||0)+(((P=p.current)==null?void 0:P.offsetHeight)||0))<10;p.current&&V?m.current=!0:m.current=!1,L.length<40&&d(L)},300),[]),{readyState:T}=wn(es(),{onMessage:L=>{Le.push(L.data),Le.length>dr&&(Le=Le.splice(0,Le.length-dr)),y([...Le])},shouldReconnect:()=>!0,reconnectAttempts:10,reconnectInterval:1e3});f.exports.useEffect(()=>{var L;p.current&&m.current&&(p.current.scrollTop=(L=p.current)==null?void 0:L.scrollHeight)},[C]),f.exports.useEffect(()=>()=>{Le=[]},[]);const g=Ko(T.toString()),{mutate:b,isLoading:W}=lt(u),$=({config:L})=>{o(L).then(()=>{w({title:c("core.successMessage"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(V=>{let J=c("core.generalErrorMessage");typeof V.response._data.detail=="object"&&(J=V.response._data.detail[Object.keys(V.response._data.detail)[0]]),typeof V.response._data.detail=="string"&&(J=V.response._data.detail),w({title:J,status:"error",isClosable:!0,position:"top",duration:3e3})})},I=f.exports.useRef(null),[A,Y]=f.exports.useState(!1),q=()=>{var L;document.fullscreenElement?(document.exitFullscreen(),Y(!1)):((L=I.current)==null||L.requestFullscreen(),Y(!0))};return r("form",{onSubmit:v.handleSubmit($),children:[r(ce,{children:[r(R,{children:[r(_,{justifyContent:"space-between",alignItems:"flex-start",children:[r(H,{children:[c("core.configuration")," ",s&&e(Dr,{isIndeterminate:!0,size:"15px"})]}),e(_,{gap:0,children:e(ne,{label:"Xray Version",placement:"top",children:e(U,{height:"100%",textTransform:"lowercase",children:l&&`v${l}`})})})]}),r(D,{position:"relative",ref:I,minHeight:"300px",children:[e(pe,{control:v.control,name:"config",render:({field:L})=>e(Zo,{json:i,onChange:L.onChange})}),e(Z,{size:"xs","aria-label":"full screen",variant:"ghost",position:"absolute",top:"2",right:"4",onClick:q,children:A?e(Jo,{}):e(Xo,{})})]})]}),r(R,{mt:"4",children:[r(_,{justifyContent:"space-between",children:[e(H,{children:c("core.logs")}),e(h,{as:H,children:c(`core.socket.${g}`)})]}),e(D,{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:C.map((L,V)=>e(h,{fontSize:"xs",opacity:.8,whiteSpace:"pre-line",children:L},V))})]})]}),e(Re,{children:r(_,{w:"full",justifyContent:"space-between",children:[e(D,{children:e(F,{size:"sm",leftIcon:e(qo,{className:Ut({"animate-spin":W})}),onClick:()=>b(),children:c(W?"core.restarting":"core.restartCore")})}),e(_,{children:e(F,{size:"sm",variant:"solid",colorScheme:"primary",px:"5",type:"submit",isDisabled:s||a,isLoading:a,children:c("core.save")})})]})})]})},rs=()=>{const{isEditingCore:t}=E(),n=E.setState.bind(null,{isEditingCore:!1}),{t:o}=j();return r(oe,{isOpen:t,onClose:n,size:"3xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"full",children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:e(Qo,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:o("core.title")})]})}),e(le,{mt:3}),e(ts,{})]})]})},mt=x(_n,{baseStyle:{w:5,h:5}}),ns=()=>{const[t,n]=f.exports.useState(!1),{deletingUser:o,onDeletingUser:s,deleteUser:i}=E(),{t:a}=j(),l=fe(),u=()=>{s(null)},p=()=>{o&&(n(!0),i(o).then(()=>{l({title:a("deleteUser.deleteSuccess",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).then(u).finally(n.bind(null,!1)))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:a("deleteUser.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:a("deleteUser.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:a("delete")})]})]})]})},Yt={baseStyle:{w:4,h:4}},os=x(kn,Yt),ss=x(Er,Yt),Xr=x(Et,Yt),as=zr(t=>{E.getState().onFilterChange({...E.getState().filters,offset:0,search:t})},300),is=({...t})=>{const{loading:n,filters:o,onFilterChange:s,refetchUsers:i,onCreateUser:a}=E(),{t:l}=j(),[u,p]=f.exports.useState(""),C=c=>{p(c.target.value),as(c.target.value)},d=()=>{p(""),s({...o,offset:0,search:""})};return r(Ur,{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(st,{colSpan:{base:1,md:2,lg:1},order:{base:2,md:1},children:r(St,{children:[e(vn,{pointerEvents:"none",children:e(os,{})}),e(je,{placeholder:l("search"),value:u,borderColor:"light-border",onChange:C}),r(Ct,{children:[n&&e(Ne,{size:"xs"}),o.search&&o.search.length>0&&e(Z,{onClick:d,"aria-label":"clear",size:"xs",variant:"ghost",children:e(ss,{})})]})]})}),e(st,{colSpan:2,order:{base:1,md:2},children:r(_,{justifyContent:"flex-end",alignItems:"center",h:"full",children:[e(Z,{"aria-label":"refresh users",disabled:n,onClick:i,size:"sm",variant:"outline",children:e(Xr,{className:Ut({"animate-spin":n})})}),e(F,{colorScheme:"primary",size:"sm",onClick:()=>a(!0),px:5,children:l("createUser")})]})})]})},Jr="https://github.com/Gozargah/Marzban",ls="https://github.com/Gozargah",cs="https://github.com/Gozargah/Marzban#donation",Kr=t=>{const{version:n}=E();return e(_,{w:"full",py:"0",position:"relative",...t,children:r(h,{display:"inline-block",flexGrow:1,textAlign:"center",color:"gray.500",fontSize:"xs",children:[e(Xt,{color:"blue.400",href:Jr,children:"Marzban"}),n?` (v${n}), `:", ","Made with \u2764\uFE0F in"," ",e(Xt,{color:"blue.400",href:ls,children:"Gozargah"})]})})},ds=x(In,{baseStyle:{w:4,h:4}}),en=({actions:t})=>{const{i18n:n}=j();var o=s=>{n.changeLanguage(s)};return r(Rr,{placement:"bottom-end",children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ds,{}),position:"relative"}),r(Tr,{minW:"100px",zIndex:9999,children:[e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("en"),children:"English"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("fa"),children:"\u0641\u0627\u0631\u0633\u06CC"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("zh-cn"),children:"\u7B80\u4F53\u4E2D\u6587"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("ru"),children:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"})]})]})},be={baseStyle:{w:4,h:4}},hs=x(zn,be),us=x(Dn,be),ps=x(Ir,be),ms=x(En,be),gs=x(Un,be),fs=x(Rn,be),bs=x(Bt,be),xs=x(Ar,be),ys=x(Dt,be),Ss=x(Mr,be),hr=x(D,{baseStyle:{bg:"yellow.500",w:"2",h:"2",rounded:"full",position:"absolute"}}),tn="marzban-menu-notification",Cs=()=>{const t=localStorage.getItem(tn);if(!t)return!0;try{return t&&Tn(parseInt(t))?An(new Date,new Date(parseInt(t)))>=7:!0}catch{return!0}},ws=({actions:t})=>{const{onEditingHosts:n,onResetAllUsage:o,onEditingNodes:s,onShowingNodesUsage:i}=E(),{t:a}=j(),{colorMode:l,toggleColorMode:u}=ht(),[p,C]=f.exports.useState(Cs()),d=l==="dark"?"dark_dimmed":l,c=()=>{localStorage.setItem(tn,new Date().getTime().toString()),C(!1)};return r(_,{gap:2,justifyContent:"space-between",__css:{"& .menuList":{direction:"ltr"}},position:"relative",children:[e(h,{as:"h1",fontWeight:"semibold",fontSize:"2xl",children:a("users")}),p&&e(hr,{top:"0",right:"0",zIndex:9999}),e(D,{overflow:"auto",css:{direction:"rtl"},children:r(_,{alignItems:"center",children:[r(Rr,{children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ge,{children:e(ms,{})}),position:"relative"}),r(Tr,{minW:"170px",zIndex:99999,className:"menuList",children:[e(me,{maxW:"170px",fontSize:"sm",icon:e(bs,{}),onClick:n.bind(null,!0),children:a("header.hostSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(xs,{}),onClick:s.bind(null,!0),children:a("header.nodeSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(ys,{}),onClick:i.bind(null,!0),children:a("header.nodesUsage")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(Ss,{}),onClick:o.bind(null,!0),children:a("resetAllUsage")}),e(Jt,{to:cs,target:"_blank",children:r(me,{maxW:"170px",fontSize:"sm",icon:e(fs,{}),position:"relative",onClick:c,children:[a("header.donation")," ",p&&e(hr,{top:"3",right:"2"})]})}),e(Jt,{to:"/login",children:e(me,{maxW:"170px",fontSize:"sm",icon:e(gs,{}),children:a("header.logout")})})]})]}),e(Z,{size:"sm",variant:"outline","aria-label":"core settings",onClick:()=>{E.setState({isEditingCore:!0})},children:e(ps,{})}),e(en,{}),e(Z,{size:"sm",variant:"outline","aria-label":"switch theme",onClick:()=>{Qr(l=="dark"?"light":"dark"),u()},children:l==="light"?e(hs,{}):e(us,{})}),e(D,{css:{direction:"ltr"},display:"flex",alignItems:"center",pr:"2",__css:{"& span":{display:"inline-flex"}},children:e(Ln,{href:Jr,"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"})})]})})]})},_s=[{title:"Inbound's default",value:"inbound_default"},{title:"TLS",value:"tls"},{title:"None",value:"none"}],ks=[{title:"",value:""},{title:"h3",value:"h3"},{title:"h2",value:"h2"},{title:"http/1.1",value:"http/1.1"},{title:"h3,h2,http/1.1",value:"h3,h2,http/1.1"},{title:"h3,h2",value:"h3,h2"},{title:"h2,http/1.1",value:"h2,http/1.1"}],vs=[{title:"",value:""},...["chrome","firefox","safari","ios","android","edge","360","qq","random","randomized"].map(t=>({title:t,value:t}))],Is=[{title:"none",value:""},{title:"xtls-rprx-vision",value:"xtls-rprx-vision"}],zs=["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"],Ds=zt(t=>({isLoading:!1,isPostLoading:!1,hosts:{},fetchHosts:()=>{t({isLoading:!0}),O("/hosts").then(n=>t({hosts:n})).finally(()=>t({isLoading:!1}))},setHosts:n=>(t({isPostLoading:!0}),O("/hosts",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})}))}));const Es=x(Er,{baseStyle:{w:4,h:4}}),Ue=Nt.forwardRef(({disabled:t,step:n,label:o,className:s,startAdornment:i,endAdornment:a,type:l="text",placeholder:u,onChange:p,onBlur:C,name:d,value:c,onClick:w,error:v,clearable:m=!1,...y},T)=>{const g=()=>{p&&p({target:{value:"",name:d}})},{size:b="md"}=y,W=l=="number"?jn:je,$=l=="number"?Mn:Nt.Fragment,I=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:n,name:d,type:l,placeholder:u,onChange:A=>{p&&p(A)},onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,size:b}:{};return r(R,{isInvalid:!!v,children:[o&&e(H,{children:o}),r(St,{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(Nn,{children:i}),r($,{...I,children:[e(W,{name:d,ref:T,step:n,className:Ut(s),type:l,placeholder:u,onChange:p,onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,_focusVisible:{outline:"none",borderTopColor:"transparent",borderRightColor:"transparent",borderBottomColor:"transparent"},_disabled:{cursor:"not-allowed"},...y,roundedLeft:i?"0":"md",roundedRight:a?"0":"md"}),l=="number"&&e(ge,{children:r(Fn,{children:[e(Pn,{}),e(Wn,{})]})})]}),a&&e(On,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",children:a}),m&&c&&c.length&&e(Ct,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",onClick:g,cursor:"pointer",children:e(Es,{})})]}),!!v&&e(wt,{children:v})]})}),Tt=x(Me,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Te=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Us=x(Bt,{baseStyle:{w:5,h:5}}),De=x(Hn,{baseStyle:{w:4,h:4,color:"gray.400",cursor:"pointer"}}),Rs=S.record(S.string().min(1),S.array(S.object({remark:S.string().min(1,"Remark is required"),address:S.string().min(1,"Address is required"),port:S.string().or(S.number()).nullable().transform(t=>typeof t=="number"?t:t!==null&&!isNaN(parseInt(t))?Number(parseInt(t)):null),path:S.string().nullable(),sni:S.string().nullable(),host:S.string().nullable(),mux_enable:S.boolean().default(!1),allowinsecure:S.boolean().nullable().default(!1),is_disabled:S.boolean().default(!0),fragment_setting:S.string().nullable(),random_user_agent:S.boolean().default(!1),security:S.string(),alpn:S.string(),fingerprint:S.string()}))),Se=x(wt,{baseStyle:{color:"red.400",display:"block",textAlign:"left",w:"100%"}}),Ls=({hostKey:t,isOpen:n,toggleAccordion:o})=>{const{inbounds:s}=E(),i=[...s.values()].flat().filter(v=>v.tag===t)[0],a=$t(),{fields:l,append:u,remove:p}=Bn({control:a.control,name:t}),{errors:C}=a.formState,{t:d}=j(),c=C[t],w=()=>{u({host:"",sni:"",port:null,path:null,address:"",remark:"",mux_enable:!1,allowinsecure:!1,is_disabled:!1,fragment_setting:"",random_user_agent:!1,security:"inbound_default",alpn:"",fingerprint:""})};return f.exports.useEffect(()=>{c&&!n&&o()},[c]),r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:o,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:t}),e(Ft,{})]}),e($e,{px:2,pb:2,children:r(N,{gap:3,children:[l.map((v,m)=>{var y,T,g,b,W,$,I,A,Y,q,L,V,J,z,P,K,Fe,bt,xt,ee,Pe,Ye,Ze,Qe,qe,Xe,k,M,te,xe,he,ye,G,Je,Ke,et,tt;return r(N,{border:"1px solid",_dark:{borderColor:"gray.600",bg:"#273142"},_light:{borderColor:"gray.200",bg:"#fcfbfb"},p:2,w:"full",borderRadius:"4px",children:[e(_,{w:"100%",alignItems:"flex-start",children:r(R,{position:"relative",zIndex:10,isInvalid:!!(c&&((y=c[m])==null?void 0:y.remark)),children:[r(St,{children:[e(Te,{...a.register(t+"."+m+".remark"),size:"sm",borderRadius:"4px",placeholder:"Remark"}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(Kt,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((T=c[m])==null?void 0:T.remark)&&e(Se,{children:(b=(g=c[m])==null?void 0:g.remark)==null?void 0:b.message})]})}),r(R,{isInvalid:!!(c&&((W=c[m])==null?void 0:W.address)),children:[r(St,{children:[e(Te,{size:"sm",borderRadius:"4px",placeholder:"Address (e.g. example.com)",...a.register(t+"."+m+".address")}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(Kt,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&(($=c[m])==null?void 0:$.address)&&e(Se,{children:(A=(I=c[m])==null?void 0:I.address)==null?void 0:A.message})]}),e(pt,{w:"full",allowToggle:!0,children:r(He,{border:"0",children:[r(Be,{display:"flex",px:0,py:1,borderRadius:3,_hover:{bg:"transparent"},children:[r(h,{flex:"3",align:"start",fontSize:"xs",color:"gray.600",_dark:{color:"gray.500"},pl:1,children:[d("hostsDialog.advancedOptions"),e(Ft,{fontSize:"sm",ml:1})]}),r($n,{flex:"1",px:"0",children:[e(pe,{control:a.control,name:`${t}.${m}.is_disabled`,render:({field:Q})=>e(_t,{mx:"1.5",colorScheme:"primary",...Q,value:void 0,isChecked:!Q.value,onChange:We=>{console.log(We.target.checked),Q.onChange(!We.target.checked)}})}),e(ne,{label:"Delete",placement:"top",children:e(Z,{"aria-label":"Delete",size:"sm",colorScheme:"red",variant:"ghost",onClick:p.bind(null,m),children:e(mt,{})})})]})]}),e($e,{w:"full",p:1,children:r(N,{w:"full",borderRadius:"4px",children:[r(R,{isInvalid:!!(c&&((Y=c[m])==null?void 0:Y.port)),children:[r(H,{display:"flex",pb:1,alignItems:"center",justifyContent:"space-between",gap:1,m:"0",children:[e("span",{children:d("hostsDialog.port")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.port.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:String(i.port||"8080"),type:"number",...a.register(t+"."+m+".port")})]}),r(R,{isInvalid:!!(c&&((q=c[m])==null?void 0:q.sni)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.sni")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.sni.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"SNI (e.g. example.com)",...a.register(t+"."+m+".sni")}),c&&((L=c[m])==null?void 0:L.sni)&&e(Se,{children:(J=(V=c[m])==null?void 0:V.sni)==null?void 0:J.message})]}),r(R,{isInvalid:!!(c&&((z=c[m])==null?void 0:z.host)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.host")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.host.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Host (e.g. example.com)",...a.register(t+"."+m+".host")}),c&&((P=c[m])==null?void 0:P.host)&&e(Se,{children:(Fe=(K=c[m])==null?void 0:K.host)==null?void 0:Fe.message})]}),r(R,{isInvalid:!!(c&&((bt=c[m])==null?void 0:bt.path)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.path")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.path.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"path (e.g. /vless)",...a.register(t+"."+m+".path")}),c&&((xt=c[m])==null?void 0:xt.path)&&e(Se,{children:(Pe=(ee=c[m])==null?void 0:ee.path)==null?void 0:Pe.message})]}),r(R,{height:"66px",children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.security")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.security.info")})]})})]})]}),e(Tt,{size:"sm",...a.register(t+"."+m+".security"),children:_s.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.alpn")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".alpn"),children:ks.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.fingerprint")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".fingerprint"),children:vs.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{isInvalid:!!(c&&((Ye=c[m])==null?void 0:Ye.fragment_setting)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.fragment")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.fragment.info")}),e(h,{fontSize:"xs",pr:5,pt:2,pb:1,children:d("hostsDialog.fragment.info.examples")}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,tlshello"}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,1-3"}),e(h,{fontSize:"xs",pr:5,pt:"3",children:d("hostsDialog.fragment.info.attention")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Fragment settings by pattern",...a.register(t+"."+m+".fragment_setting")}),c&&((Ze=c[m])==null?void 0:Ze.fragment_setting)&&e(Se,{children:(qe=(Qe=c[m])==null?void 0:Qe.fragment_setting)==null?void 0:qe.message})]}),e(R,{isInvalid:!!(c&&((Xe=c[m])==null?void 0:Xe.allowinsecure)),children:r(at,{...a.register(t+"."+m+".allowinsecure"),name:t+"."+m+".allowinsecure",children:[e(H,{children:d("hostsDialog.allowinsecure")}),c&&((k=c[m])==null?void 0:k.allowinsecure)&&e(Se,{children:(te=(M=c[m])==null?void 0:M.allowinsecure)==null?void 0:te.message})]})}),r(R,{isInvalid:!!(c&&((xe=c[m])==null?void 0:xe.mux_enable)),children:[e(at,{...a.register(t+"."+m+".mux_enable"),children:e(H,{children:d("hostsDialog.muxEnable")})}),c&&((he=c[m])==null?void 0:he.mux_enable)&&e(Se,{children:(G=(ye=c[m])==null?void 0:ye.mux_enable)==null?void 0:G.message})]}),r(R,{isInvalid:!!(c&&((Je=c[m])==null?void 0:Je.random_user_agent)),children:[e(at,{...a.register(t+"."+m+".random_user_agent"),children:e(H,{children:d("hostsDialog.randomUserAgent")})}),c&&((Ke=c[m])==null?void 0:Ke.random_user_agent)&&e(Se,{children:(tt=(et=c[m])==null?void 0:et.random_user_agent)==null?void 0:tt.message})]})]},m)})]})})]},m)}),e(F,{variant:"outline",w:"full",size:"sm",color:"",fontWeight:"normal",onClick:w,children:d("hostsDialog.addHost")})]})})]})},Ts=()=>{const{isEditingHosts:t,onEditingHosts:n,refetchUsers:o,inbounds:s}=E(),{isLoading:i,hosts:a,fetchHosts:l,isPostLoading:u,setHosts:p}=Ds(),C=fe(),{t:d}=j(),[c,w]=f.exports.useState({});f.exports.useEffect(()=>{t&&l()},[t]);const v=Ve({resolver:ut(Rs)});f.exports.useEffect(()=>{a&&t&&v.reset(a)},[a]);const m=()=>{w({}),n(!1)},y=g=>{p(g).then(()=>{C({title:d("hostsDialog.savedSuccess"),status:"success",isClosable:!0,position:"top",duration:3e3}),o()}).catch(b=>{var W,$,I,A,Y;(((W=b==null?void 0:b.response)==null?void 0:W.status)===409||(($=b==null?void 0:b.response)==null?void 0:$.status)===400)&&C({title:(A=(I=b.response)==null?void 0:I._data)==null?void 0:A.detail,status:"error",isClosable:!0,position:"top",duration:3e3}),((Y=b==null?void 0:b.response)==null?void 0:Y.status)===422&&Object.keys(b.response._data.detail).forEach(q=>{C({title:b.response._data.detail[q]+" ("+q+")",status:"error",isClosable:!0,position:"top",duration:3e3})})})},T=g=>{c[String(g)]?delete c[String(g)]:c[String(g)]={},w({...c})};return r(oe,{isOpen:t,onClose:m,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Us,{color:"white"})})}),e(le,{mt:3}),e(ce,{w:"440px",pb:3,pt:3,children:e(Nr,{...v,children:r("form",{onSubmit:v.handleSubmit(y),children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:d("hostsDialog.title")}),i&&d("hostsDialog.loading"),!i&&a&&(Object.keys(a).length>0?e(pt,{w:"full",allowToggle:!0,allowMultiple:!0,index:Object.keys(c).map(g=>parseInt(g)),children:e(N,{w:"full",children:Object.keys(a).map((g,b)=>e(Ls,{toggleAccordion:()=>T(b),isOpen:c[String(b)],hostKey:g},g))})}):"No inbound found. Please check your Xray config file."),e(_,{justifyContent:"flex-end",py:2,children:e(F,{variant:"solid",mt:"2",type:"submit",colorScheme:"primary",size:"sm",px:5,isLoading:u,disabled:u,children:d("hostsDialog.apply")})})]})})})]})]})},rn=S.object({name:S.string().min(1),address:S.string().min(1),port:S.number().min(1).or(S.string().transform(t=>parseFloat(t))),api_port:S.number().min(1).or(S.string().transform(t=>parseFloat(t))),xray_version:S.string().nullable().optional(),id:S.number().nullable().optional(),status:S.enum(["connected","connecting","error","disabled"]).nullable().optional(),message:S.string().nullable().optional(),add_as_new_host:S.boolean().optional(),usage_coefficient:S.number().or(S.string().transform(t=>parseFloat(t)))}),As=()=>({name:"",address:"",port:62050,api_port:62051,xray_version:"",usage_coefficient:1}),dt="fetch-nodes-query-key",Ms=()=>{const{isEditingNodes:t}=E();return Ht({queryKey:dt,queryFn:gt.getState().fetchNodes,refetchInterval:t?3e3:void 0,refetchOnWindowFocus:!1})},gt=zt((t,n)=>({nodes:[],addNode(o){return O("/node",{method:"POST",body:o})},fetchNodes(){return O("/nodes")},fetchNodesUsage(o){return O("/nodes/usage",{query:o})},updateNode(o){return O(`/node/${o.id}`,{method:"PUT",body:o})},setDeletingNode(o){t({deletingNode:o})},reconnectNode(o){return O(`/node/${o.id}/reconnect`,{method:"POST"})},deleteNode:()=>{var o;return O(`/node/${(o=n().deletingNode)==null?void 0:o.id}`,{method:"DELETE"})}})),Zt=(t,n,o)=>{if(t.response&&t.response._data){if(typeof t.response._data.detail=="string")return n({title:t.response._data.detail,status:"error",isClosable:!0,position:"top",duration:3e3});if(typeof t.response._data.detail=="object"&&o){Object.keys(t.response._data.detail).forEach(s=>o.setError(s,{message:t.response._data.detail[s]}));return}}return n({title:"Something went wrong!",status:"error",isClosable:!0,position:"top",duration:3e3})},Qt=(t,n)=>n({title:t,status:"success",isClosable:!0,position:"top",duration:3e3}),Ns=({deleteCallback:t})=>{const{deleteNode:n,deletingNode:o,setDeletingNode:s}=gt(),{t:i}=j(),a=fe(),l=Vt(),u=()=>{s(null)},{isLoading:p,mutate:C}=lt(n,{onSuccess:()=>{Qt(i("deleteNode.deleteSuccess",{name:o&&o.name}),a),s(null),l.invalidateQueries(dt),t&&t()},onError:d=>{Zt(d,a)}});return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("deleteNode.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("deleteNode.prompt",{name:o.name})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:()=>C(),leftIcon:p?e(Ne,{size:"xs"}):void 0,children:i("delete")})]})]})]})},ft={baseStyle:{strokeWidth:"2px",w:4,h:4}},ur=x(Vn,ft),Fs=x(Gn,ft),pr=x(Yn,ft),mr=x(Fr,ft),Ps=x(Fr,ft),Ot=[{title:"No",value:"no_reset"},{title:"Daily",value:"day"},{title:"Weekly",value:"week"},{title:"Monthly",value:"month"},{title:"Annually",value:"year"}],it={active:{statusColor:"green",bandWidthColor:"primary",icon:ur},connected:{statusColor:"green",bandWidthColor:"primary",icon:ur},disabled:{statusColor:"gray",bandWidthColor:"gray",icon:Fs},expired:{statusColor:"orange",bandWidthColor:"orange",icon:mr},on_hold:{statusColor:"purple",bandWidthColor:"purple",icon:Ps},connecting:{statusColor:"orange",bandWidthColor:"orange",icon:mr},limited:{statusColor:"red",bandWidthColor:"red",icon:pr},error:{statusColor:"red",bandWidthColor:"red",icon:pr}},qt=t=>{let n={status:"",time:""};if(t){B(t*1e3).utc().isAfter(B().utc())?n.status="expires":n.status="expired";const o=[],s=B.duration(B(t*1e3).utc().diff(B()));s.years()!=0&&o.push(Math.abs(s.years())+" year"+(Math.abs(s.years())!=1?"s":"")),s.months()!=0&&o.push(Math.abs(s.months())+" month"+(Math.abs(s.months())!=1?"s":"")),s.days()!=0&&o.push(Math.abs(s.days())+" day"+(Math.abs(s.days())!=1?"s":"")),o.length===0&&(s.hours()!=0&&o.push(Math.abs(s.hours())+" hour"+(Math.abs(s.hours())!=1?"s":"")),s.minutes()!=0&&o.push(Math.abs(s.minutes())+" min"+(Math.abs(s.minutes())!=1?"s":""))),n.time=o.join(", ")}return n},yt=({expiryDate:t,status:n,compact:o=!1,showDetail:s=!0,extraText:i})=>{const{t:a}=j(),l=qt(t),u=it[n].icon;return r(ge,{children:[r(U,{colorScheme:it[n].statusColor,rounded:"full",display:"inline-flex",px:3,py:1,columnGap:o?1:2,alignItems:"center",children:[e(u,{w:o?3:4}),s&&r(h,{textTransform:"capitalize",fontSize:o?".7rem":".875rem",lineHeight:o?"1rem":"1.25rem",fontWeight:"medium",letterSpacing:"tighter",children:[n==="on_hold"?a(n):n,i&&`: ${i}`]})]}),s&&t&&e(h,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:a(l.status,{time:l.time})})]})},nt=x(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ws=x(Ar,{baseStyle:{w:5,h:5}}),Os=x(Zn,{baseStyle:{w:5,h:5,strokeWidth:2}}),js=({toggleAccordion:t,node:n})=>{const{updateNode:o,reconnectNode:s,setDeletingNode:i}=gt(),{t:a}=j(),l=Vt(),u=fe(),p=Ve({defaultValues:n,resolver:ut(rn)}),C=i.bind(null,n),{isLoading:d,mutate:c}=lt(o,{onSuccess:()=>{Qt("Node updated successfully",u),l.invalidateQueries(dt)},onError:y=>{Zt(y,u,p)}}),{isLoading:w,mutate:v}=lt(s.bind(null,n),{onSuccess:()=>{l.invalidateQueries(dt)}}),m=w?"connecting":n.status?n.status:"error";return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:t,children:[r(_,{w:"full",justifyContent:"space-between",pr:2,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:n.name}),r(_,{children:[n.xray_version&&e(U,{colorScheme:"blue",rounded:"full",display:"inline-flex",px:3,py:1,children:r(h,{textTransform:"capitalize",fontSize:"0.7rem",fontWeight:"medium",letterSpacing:"tighter",children:["Xray ",n.xray_version]})}),n.status&&e(yt,{status:m,compact:!0})]})]}),e(Ft,{})]}),r($e,{px:2,pb:2,children:[e(N,{pb:3,alignItems:"flex-start",children:m==="error"&&e(ct,{status:"error",size:"xs",children:r(D,{children:[r(_,{w:"full",children:[e(kt,{w:4}),e(h,{marginInlineEnd:0,children:n.message})]}),e(_,{justifyContent:"flex-end",w:"full",children:e(F,{size:"sm","aria-label":"reconnect node",leftIcon:e(Xr,{}),onClick:()=>v(),disabled:w,children:a(w?"nodes.reconnecting":"nodes.reconnect")})})]})})}),e(nn,{form:p,mutate:c,isLoading:d,submitBtnText:a("nodes.editNode"),btnLeftAdornment:e(ne,{label:a("delete"),placement:"top",children:e(Z,{colorScheme:"red",variant:"ghost",size:"sm","aria-label":"delete node",onClick:C,children:e(mt,{})})})})]})]})},Hs=({toggleAccordion:t,resetAccordions:n})=>{const o=fe(),{t:s}=j(),i=Vt(),{addNode:a}=gt(),l=Ve({resolver:ut(rn),defaultValues:{...As(),add_as_new_host:!0}}),{isLoading:u,mutate:p}=lt(a,{onSuccess:()=>{Qt(s("nodes.addNodeSuccess",{name:l.getValues("name")}),o),i.invalidateQueries(dt),l.reset(),n()},onError:C=>{Zt(C,o,l)}});return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[e(Be,{px:2,borderRadius:"3px",onClick:t,children:r(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},display:"flex",gap:1,children:[e(Os,{display:"inline-block"})," ",e("span",{children:s("nodes.addNewMarzbanNode")})]})}),e($e,{px:2,py:4,children:e(nn,{form:l,mutate:p,isLoading:u,submitBtnText:s("nodes.addNode"),btnProps:{variant:"solid"},addAsHost:!0})})]})},nn=({form:t,mutate:n,isLoading:o,submitBtnText:s,btnProps:i={},btnLeftAdornment:a,addAsHost:l=!1})=>{var v,m,y,T,g,b,W,$,I,A,Y,q,L,V,J;const{t:u}=j(),[p,C]=f.exports.useState(!1),{data:d,isLoading:c}=Ht({queryKey:"node-settings",queryFn:()=>O("/node/settings")});function w(z){if(document.body.createTextRange){const P=document.body.createTextRange();P.moveToElementText(z),P.select()}else if(window.getSelection){const P=window.getSelection(),K=document.createRange();K.selectNodeContents(z),P.removeAllRanges(),P.addRange(K)}else console.warn("Could not select text in node: Unsupported browser.")}return e("form",{onSubmit:t.handleSubmit(z=>n(z)),children:r(N,{children:[d&&d.certificate&&e(ct,{status:"info",alignItems:"start",children:r(Pr,{display:"flex",flexDirection:"column",overflow:"hidden",children:[e("span",{children:u("nodes.connection-hint")}),r(_,{justify:"end",py:2,children:[e(F,{as:"a",colorScheme:"primary",size:"xs",download:"ssl_client_cert.pem",href:URL.createObjectURL(new Blob([d.certificate],{type:"text/plain"})),children:u("nodes.download-certificate")}),e(ne,{placement:"top",label:u("nodes.show-certificate"),children:e(Z,{"aria-label":u("nodes.show-certificate"),onClick:C.bind(null,!p),colorScheme:"whiteAlpha",color:"primary",size:"xs",children:p?e(qn,{width:"15px"}):e(Qn,{width:"15px"})})})]}),e(Wr,{in:p,animateOpacity:!0,children:e(h,{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=>{w(z.target)},children:d.certificate})})]})}),r(_,{w:"full",children:[e(R,{children:e(nt,{label:u("nodes.nodeName"),size:"sm",placeholder:"Marzban-S2",...t.register("name"),error:(y=(m=(v=t.formState)==null?void 0:v.errors)==null?void 0:m.name)==null?void 0:y.message})}),e(_,{px:1,children:e(pe,{name:"status",control:t.control,render:({field:z})=>e(ne,{placement:"top",label:`${u("usersTable.status")}: `+(z.value!=="disabled"?u("active"):u("disabled")),textTransform:"capitalize",children:e(D,{mt:"6",children:e(_t,{colorScheme:"primary",isChecked:z.value!=="disabled",onChange:P=>{P.target.checked?z.onChange("connecting"):z.onChange("disabled")}})})},z.value)})})]}),e(_,{alignItems:"flex-start",w:"100%",children:e(D,{w:"100%",children:e(nt,{label:u("nodes.nodeAddress"),size:"sm",placeholder:"51.20.12.13",...t.register("address"),error:(b=(g=(T=t.formState)==null?void 0:T.errors)==null?void 0:g.address)==null?void 0:b.message})})}),r(_,{alignItems:"flex-start",w:"100%",children:[e(D,{children:e(nt,{label:u("nodes.nodePort"),size:"sm",placeholder:"62050",...t.register("port"),error:(I=($=(W=t.formState)==null?void 0:W.errors)==null?void 0:$.port)==null?void 0:I.message})}),e(D,{children:e(nt,{label:u("nodes.nodeAPIPort"),size:"sm",placeholder:"62051",...t.register("api_port"),error:(q=(Y=(A=t.formState)==null?void 0:A.errors)==null?void 0:Y.api_port)==null?void 0:q.message})}),e(D,{children:e(nt,{label:u("nodes.usageCoefficient"),size:"sm",placeholder:"1",...t.register("usage_coefficient"),error:(J=(V=(L=t.formState)==null?void 0:L.errors)==null?void 0:V.usage_coefficient)==null?void 0:J.message})})]}),l&&e(R,{py:1,children:e(at,{...t.register("add_as_new_host"),children:e(H,{m:0,children:u("nodes.addHostForEveryInbound")})})}),r(_,{w:"full",children:[a,e(F,{flexGrow:1,type:"submit",colorScheme:"primary",size:"sm",px:5,w:"full",isLoading:o,...i,children:s})]})]})})},Bs=()=>{const{isEditingNodes:t,onEditingNodes:n}=E(),{t:o}=j(),[s,i]=f.exports.useState({}),{data:a,isLoading:l}=Ms(),u=()=>{i({}),n(!1)},p=C=>{s[String(C)]?delete s[String(C)]:s[String(C)]={},i({...s})};return r(ge,{children:[r(oe,{isOpen:t,onClose:u,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Ws,{color:"white"})})}),e(le,{mt:3}),r(ce,{w:"440px",pb:6,pt:3,children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:o("nodes.title")}),l&&"loading...",e(pt,{w:"full",allowToggle:!0,index:Object.keys(s).map(C=>parseInt(C)),children:r(N,{w:"full",children:[!l&&a&&a.map((C,d)=>e(js,{toggleAccordion:()=>p(d),node:C},C.name)),e(Hs,{toggleAccordion:()=>p((a||[]).length),resetAccordions:()=>i({})})]})})]})]})]}),e(Ns,{deleteCallback:()=>i({})})]})};function $s(t){const n=360/t,o=90,s=47,i=[];for(let a=0;a(w<0&&(w+=1),w>1&&(w-=1),w<.16666666666666666?d+(c-d)*6*w:w<.5?c:w<.6666666666666666?d+(c-d)*(.6666666666666666-w)*6:d),p=o<.5?o*(1+n):o+n-o*n,C=2*o-p;s=Math.round(u(C,p,t+1/3)*255),i=Math.round(u(C,p,t)*255),a=Math.round(u(C,p,t-1/3)*255)}const l=u=>{const p=u.toString(16);return p.length===1?"0"+p:p};return`#${l(s)}${l(i)}${l(a)}`}const gr=({border:t,...n})=>{const{getInputProps:o,getRadioProps:s}=no(n),i=Ae({base:"xs",md:"sm"});return r(D,{as:"label",children:[e("input",{...o()}),e(D,{...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:n.children})]})},on=({onChange:t,defaultValue:n,...o})=>{const{t:s,i18n:i}=j();ht();const a=Ae({base:["7h","1d","3d","1w"],md:["7h","1d","3d","1w","1m","3m"]}),l={h:"hour",d:"day",w:"week",m:"month",y:"year"},u=Ae({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:C,setValue:d}=Xn({name:"filter",defaultValue:n,onChange:z=>{if(z==="custom")return;v(),a.indexOf(z)>=0?(T(s("userDialog.custom")),b(!1)):(T(s("userDialog.custom")+` (${z})`),b(!0));const P=Number(z.substring(0,z.length-1)),K=l[z[z.length-1]];t(z,{start:B().utc().subtract(P,K).format("YYYY-MM-DDTHH:00:00")})}}),{isOpen:c,onOpen:w,onClose:v}=Jn(),m=f.exports.useRef(null);Kn({ref:m,handler:v});const[y,T]=f.exports.useState(s("userDialog.custom")),[g,b]=f.exports.useState(!1),[W,$]=f.exports.useState(0),I=Ae({base:1,md:2}),A=Ae({base:"xs",md:"sm"}),[Y,q]=f.exports.useState(null),[L,V]=f.exports.useState(null),J=z=>{const[P,K]=z;L&&!K?(q(null),V(null)):(q(P),V(K),P&&K&&(v(),t("custom",{start:B(P).format("YYYY-MM-DDT00:00:00"),end:B(K).format("YYYY-MM-DDT23:59:59")})))};return r(N,{...o,children:[W==0&&r(Gt,{...p(),gap:0,display:"flex",borderWidth:"1px",borderRadius:"md",minW:{base:"320px",md:"400px"},children:[a.map(z=>e(gr,{...C({value:z}),children:z},z)),e(D,{onClick:()=>{q(null),V(null),w()},cursor:"pointer",borderRadius:"md",w:"full",fontSize:A,px:3,py:1,bg:g?"primary.500":"unset",color:g?"white":"unset",borderColor:g?"primary.500":"unset",children:r(_,{children:[e(h,{children:y}),e(Rt,{as:er,boxSize:"18px"})]})})]}),W==1&&r(_,{onClick:w,cursor:"pointer",fontSize:A,borderRadius:"md",px:3,py:1,minW:{base:"320px",md:"400px"},borderWidth:"1px",children:[e(h,{w:"full",color:Y?"unset":"gray.500",children:Y?B(Y).format("YYYY-MM-DD (00:00)"):s("userDialog.startDate")}),e(Rt,{as:Or,boxSize:"18px"}),e(h,{w:"full",color:L?"unset":"gray.500",children:L?B(L).format("YYYY-MM-DD (23:59)"):s("userDialog.endDate")}),e(Rt,{as:er,boxSize:"18px"})]}),e(N,{ref:m,marginTop:"40px !important",borderRadius:"md",borderWidth:"1px",position:"absolute",zIndex:"1",backgroundColor:"white",_dark:{backgroundColor:"gray.700"},display:c?"unset":"none",children:r(eo,{onChange:z=>$(z),children:[r(to,{children:[e(tr,{fontSize:A,children:s("userDialog.relative")}),e(tr,{fontSize:A,children:s("userDialog.absolute")})]}),r(ro,{children:[e(rr,{children:u.map(z=>e(N,{alignItems:"start",pl:2,pr:2,children:r(_,{justifyItems:"flex-start",mb:4,children:[e(h,{fontSize:A,minW:"60px",children:s("userDialog."+z.title)}),z.options.map(P=>e(gr,{border:!0,...C({value:P}),children:P},P+".custom"))]})},z.title))}),e(rr,{className:"datepicker-panel",children:e(N,{children:e(jr,{locale:i.language.toLocaleLowerCase(),selected:Y,onChange:J,startDate:Y,endDate:L,selectsRange:!0,maxDate:new Date,monthsShown:I,peekNextMonth:!1,inline:!0})})})]})]})})]})};function It(t,n,o=[],s=[]){const i=re(o.reduce((a,l)=>a+=l,0));return{series:o,options:{labels:s,chart:{width:"100%",height:"100%",type:"donut",animations:{enabled:!1}},title:{text:`${n}${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:u})=>re(u.config.series[l],1)},tooltip:{custom:({series:a,seriesIndex:l,dataPointIndex:u,w:p})=>{const C=re(a[l],1),d=Math.max(a.reduce((w,v)=>w+=v),1),c=Math.round(a[l]/d*1e3)/10+"%";return`
+import{i as Nt,B as sn,a as an,b as ln,j as vr,d as B,U as Ht,z as cn,r as dn,f as hn,Q as un,e as pn,$ as mn,c as zt,g as y,h as gn,C as fn,k as Dt,u as Bt,l as j,m as r,H as _,n as e,T as h,o as bn,p as D,s as xn,q as f,t as ht,J as yn,v as Ir,A as Et,w as Sn,x as Cn,M as oe,y as se,D as ae,E as ie,F as le,G as fe,I as Ve,K as zr,L as wn,N as lt,O as ce,P as R,R as H,S as Dr,V as ne,W as U,X as pe,Y as Z,Z as Re,_ as F,a0 as Ut,a1 as rt,a2 as _n,a3 as Ee,a4 as Ne,a5 as kn,a6 as Er,a7 as Ur,a8 as st,a9 as St,aa as vn,ab as je,ac as Ct,ad as Jt,ae as In,af as Rr,ag as Lr,ah as Tr,ai as me,aj as zn,ak as Dn,al as En,am as Un,an as Rn,ao as $t,ap as Ar,aq as Mr,ar as ge,as as Kt,at as Ln,au as Tn,av as An,aw as Ft,ax as Mn,ay as Nn,az as Fn,aA as Pn,aB as Wn,aC as On,aD as wt,aE as jn,aF as Me,aG as Hn,aH as x,aI as ut,aJ as Nr,aK as pt,aL as N,aM as Vt,aN as Bn,aO as He,aP as Be,aQ as Pt,aR as $e,aS as Ce,aT as we,aU as _e,aV as ke,aW as ve,aX as Ie,aY as er,aZ as $n,a_ as _t,a$ as at,b0 as Gt,b1 as Vn,b2 as Gn,b3 as Yn,b4 as Fr,b5 as Zn,b6 as ct,b7 as kt,b8 as Pr,b9 as Qn,ba as qn,bb as Wr,bc as Ae,bd as Xn,be as Jn,bf as Kn,bg as Yt,bh as Rt,bi as tr,bj as Or,bk as eo,bl as to,bm as rr,bn as ro,bo as nr,bp as jr,bq as no,br as Hr,bs as oo,bt as so,bu as Br,bv as ao,bw as io,bx as $r,by as Vr,bz as Gr,bA as X,bB as lo,bC as Yr,bD as or,bE as co,bF as ho,bG as uo,bH as po,bI as mo,bJ as go,bK as Zr,bL as fo,bM as sr,bN as ar,bO as Oe,bP as ze,bQ as ir,bR as ue,bS as lr,bT as bo,bU as xo,bV as yo,bW as So,bX as Co,bY as wo,bZ as _o,b_ as ko,b$ as vo,c0 as Io,c1 as zo,c2 as Do,c3 as Eo,c4 as Uo,c5 as Ro,c6 as Lo,c7 as To}from"./vendor.8aa8dc93.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.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 o(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=o(i);fetch(i.href,a)}})();Nt.use(sn).use(an).use(ln).init({debug:{}.NODE_ENV==="development",returnNull:!1,fallbackLng:"en",interpolation:{escapeValue:!1},react:{useSuspense:!1},load:"languageOnly",detection:{caches:["localStorage","sessionStorage","cookie"]},backend:{loadPath:vr(["/dashboard/","locales/{{lng}}.json"])}},function(t,n){B.locale(Nt.language)});Nt.on("languageChanged",t=>{B.locale(t)});Ht("zh-cn",cn);Ht("ru",dn);Ht("fa",hn);const Wt=new un,Qr=t=>{const n=document.querySelector('meta[name="theme-color"]');n==null||n.setAttribute("content",t=="dark"?"#1A202C":"#3B81F6")},Ao=pn({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 vt=()=>localStorage.getItem("token"),Mo=t=>{localStorage.setItem("token",t)},No=()=>{localStorage.removeItem("token")},Fo=mn.create({baseURL:"/api/"}),Po=(t,n={})=>(vt()&&(n.headers={...(n==null?void 0:n.headers)||{},Authorization:`Bearer ${vt()}`}),Fo(t,n)),O=Po,Wo=zt(t=>({isLoading:!0,isPostLoading:!1,version:null,started:!1,logs_websocket:null,config:"",fetchCoreSettings:()=>{t({isLoading:!0}),Promise.all([O("/core").then(({version:n,started:o,logs_websocket:s})=>t({version:n,started:o,logs_websocket:s})),O("/core/config").then(n=>t({config:n}))]).finally(()=>t({isLoading:!1}))},updateConfig:n=>(t({isPostLoading:!0}),O("/core/config",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})})),restartCore:()=>O("/core/restart",{method:"POST"})}));function re(t,n=2,o=!1){if(!+t)return"0 B";const s=1024,i=n<0?0:n,a=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],l=Math.floor(Math.log(t)/Math.log(s));return o?[parseFloat((t/Math.pow(s,l)).toFixed(i)),a[l]]:`${parseFloat((t/Math.pow(s,l)).toFixed(i))} ${a[l]}`}const cr=t=>{if(t!==null)return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},Oo=y(gn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),jo=y(fn,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Ho=y(Dt,{baseStyle:{w:5,h:5,position:"relative",zIndex:"2"}}),Lt=({title:t,content:n,icon:o})=>r(bn,{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(_,{alignItems:"center",columnGap:"4",children:[e(D,{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:o}),e(h,{color:"gray.600",_dark:{color:"gray.300"},fontWeight:"medium",textTransform:"capitalize",fontSize:"sm",children:t})]}),e(D,{fontSize:"3xl",fontWeight:"semibold",mt:"2",children:n})]}),Ot="statistics-query-key",Bo=t=>{const{version:n}=E(),{data:o}=Bt({queryKey:Ot,queryFn:()=>O("/system"),refetchInterval:5e3,onSuccess:({version:i})=>{n!==i&&E.setState({version:i})}}),{t:s}=j();return r(_,{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(Lt,{title:s("activeUsers"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:cr(o.users_active)}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:["/ ",cr(o.total_user)]})]}),icon:e(Oo,{})}),e(Lt,{title:s("dataUsage"),content:o&&re(o.incoming_bandwidth+o.outgoing_bandwidth),icon:e(jo,{})}),e(Lt,{title:s("memoryUsage"),content:o&&r(_,{alignItems:"flex-end",children:[e(h,{children:re(o.mem_used,1,!0)[0]}),r(h,{fontWeight:"normal",fontSize:"lg",as:"span",display:"inline-block",pb:"5px",children:[re(o.mem_used,1,!0)[1]," /"," ",re(o.mem_total,1)]})]}),icon:e(Ho,{})})]})},qr="marzban-num-users-per-page",dr=10,$o=()=>{const t=localStorage.getItem(qr)||dr.toString();return parseInt(t)||dr},Vo=t=>localStorage.setItem(qr,t),Go=t=>{for(const n in t)t[n]||delete t[n];return E.setState({loading:!0}),O("/users",{query:t}).then(n=>(E.setState({users:n}),n)).finally(()=>{E.setState({loading:!1})})},Yo=()=>O("/inbounds").then(t=>{E.setState({inbounds:new Map(Object.entries(t))})}).finally(()=>{E.setState({loading:!1})}),E=zt(xn((t,n)=>({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:$o(),sort:"-created_at"},inbounds:new Map,isEditingCore:!1,refetchUsers:()=>{Go(n().filters)},resetAllUsage:()=>O("/users/reset",{method:"POST"}).then(()=>{n().onResetAllUsage(!1),n().refetchUsers()}),onResetAllUsage:o=>t({isResetingAllUsage:o}),onCreateUser:o=>t({isCreatingNewUser:o}),onEditingUser:o=>{t({editingUser:o})},onDeletingUser:o=>{t({deletingUser:o})},onFilterChange:o=>{t({filters:{...n().filters,...o}}),n().refetchUsers()},setQRCode:o=>{t({QRcodeLinks:o})},deleteUser:o=>(t({editingUser:null}),O(`/user/${o.username}`,{method:"DELETE"}).then(()=>{t({deletingUser:null}),n().refetchUsers(),Wt.invalidateQueries(Ot)})),createUser:o=>O("/user",{method:"POST",body:o}).then(()=>{t({editingUser:null}),n().refetchUsers(),Wt.invalidateQueries(Ot)}),editUser:o=>O(`/user/${o.username}`,{method:"PUT",body:o}).then(()=>{n().onEditingUser(null),n().refetchUsers()}),fetchUserUsage:(o,s)=>{for(const i in s)s[i]||delete s[i];return O(`/user/${o.username}/usage`,{method:"GET",query:s})},onEditingHosts:o=>{t({isEditingHosts:o})},onEditingNodes:o=>{t({isEditingNodes:o})},onShowingNodesUsage:o=>{t({isShowingNodesUsage:o})},setSubLink:o=>{t({subscribeUrl:o})},resetDataUsage:o=>O(`/user/${o.username}/reset`,{method:"POST"}).then(()=>{t({resetUsageUser:null}),n().refetchUsers()}),revokeSubscription:o=>O(`/user/${o.username}/revoke_sub`,{method:"POST"}).then(s=>{t({revokeSubscriptionUser:null,editingUser:s}),n().refetchUsers()})}))),de=({children:t,color:n})=>e(D,{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:`${n}.400`,opacity:".5",borderRadius:"5px",zIndex:"1",_dark:{bg:`${n}.400`}},_after:{content:'""',display:"block",position:"absolute",top:"0",left:"0",width:"calc(100% + 10px)",height:"calc(100% + 10px)",transform:"translate(-5px, -5px)",bg:`${n}.400`,opacity:".4",borderRadius:"8px",zIndex:"1",_dark:{bg:`${n}.400`}},children:e(h,{color:`${n}.500`,_dark:{color:`${n}.900`},position:"relative",zIndex:"2",children:t})});window.ace.define("ace/theme/nord_dark",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!0,n.cssClass="ace-nord-dark",t("../lib/dom").importCssString(n.cssText,n.cssClass)});window.ace.define("ace/theme/dawn",["require","exports","module","ace/lib/dom"],(t,n,o)=>{n.isDark=!1,n.cssClass="ace-dawn",t("../lib/dom").importCssString(n.cssText,n.cssClass)});const Zo=f.exports.forwardRef(({json:t,onChange:n,mode:o="code"},s)=>{const{colorMode:i}=ht(),a={mode:o,onChangeText:n,statusBar:!1,mainMenuBar:!1,theme:i==="dark"?"ace/theme/nord_dark":"ace/theme/dawn"},l=f.exports.useRef(null),u=f.exports.useRef(null);return f.exports.useEffect(()=>(u.current=new yn(l.current,a),()=>{u.current&&u.current.destroy()}),[]),f.exports.useEffect(()=>{u.current&&u.current.update(t)},[t]),e(D,{ref:s,border:"1px solid",borderColor:"gray.300",_dark:{borderColor:"gray.500"},borderRadius:5,h:"full",children:e(D,{height:"full",ref:l})})}),hr=500,Qo=y(Ir,{baseStyle:{w:5,h:5}}),qo=y(Et,{baseStyle:{w:4,h:4}}),Xo=y(Sn,{baseStyle:{w:4,h:4}}),Jo=y(Cn,{baseStyle:{w:3,h:3}}),Ko=t=>({[rt.ReadyState.CONNECTING]:"connecting",[rt.ReadyState.OPEN]:"connected",[rt.ReadyState.CLOSING]:"closed",[rt.ReadyState.CLOSED]:"closed",[rt.ReadyState.UNINSTANTIATED]:"closed"})[t],es=()=>{try{let t=new URL("/api/".startsWith("/")?window.location.origin+"/api/":"/api/");return(t.protocol==="https:"?"wss://":"ws://")+vr([t.host+t.pathname,"/core/logs"])+"?interval=1&token="+vt()}catch(t){return console.error("Unable to generate websocket url"),console.error(t),null}};let Le=[];const ts=()=>{const{isEditingCore:t}=E(),{fetchCoreSettings:n,updateConfig:o,isLoading:s,config:i,isPostLoading:a,version:l,restartCore:u}=Wo(),p=f.exports.useRef(null),[C,d]=f.exports.useState([]),{t:c}=j(),w=fe(),v=Ve({defaultValues:{config:i||{}}});f.exports.useEffect(()=>{i&&v.setValue("config",i)},[i]),f.exports.useEffect(()=>{t&&n()},[t]);const m=f.exports.useRef(!0),S=f.exports.useCallback(zr(L=>{var J,z,P;const V=Math.abs((((J=p.current)==null?void 0:J.scrollTop)||0)-(((z=p.current)==null?void 0:z.scrollHeight)||0)+(((P=p.current)==null?void 0:P.offsetHeight)||0))<10;p.current&&V?m.current=!0:m.current=!1,L.length<40&&d(L)},300),[]),{readyState:T}=wn(es(),{onMessage:L=>{Le.push(L.data),Le.length>hr&&(Le=Le.splice(0,Le.length-hr)),S([...Le])},shouldReconnect:()=>!0,reconnectAttempts:10,reconnectInterval:1e3});f.exports.useEffect(()=>{var L;p.current&&m.current&&(p.current.scrollTop=(L=p.current)==null?void 0:L.scrollHeight)},[C]),f.exports.useEffect(()=>()=>{Le=[]},[]);const g=Ko(T.toString()),{mutate:b,isLoading:W}=lt(u),$=({config:L})=>{o(L).then(()=>{w({title:c("core.successMessage"),status:"success",isClosable:!0,position:"top",duration:3e3})}).catch(V=>{let J=c("core.generalErrorMessage");typeof V.response._data.detail=="object"&&(J=V.response._data.detail[Object.keys(V.response._data.detail)[0]]),typeof V.response._data.detail=="string"&&(J=V.response._data.detail),w({title:J,status:"error",isClosable:!0,position:"top",duration:3e3})})},I=f.exports.useRef(null),[A,Y]=f.exports.useState(!1),q=()=>{var L;document.fullscreenElement?(document.exitFullscreen(),Y(!1)):((L=I.current)==null||L.requestFullscreen(),Y(!0))};return r("form",{onSubmit:v.handleSubmit($),children:[r(ce,{children:[r(R,{children:[r(_,{justifyContent:"space-between",alignItems:"flex-start",children:[r(H,{children:[c("core.configuration")," ",s&&e(Dr,{isIndeterminate:!0,size:"15px"})]}),e(_,{gap:0,children:e(ne,{label:"Xray Version",placement:"top",children:e(U,{height:"100%",textTransform:"lowercase",children:l&&`v${l}`})})})]}),r(D,{position:"relative",ref:I,minHeight:"300px",children:[e(pe,{control:v.control,name:"config",render:({field:L})=>e(Zo,{json:i,onChange:L.onChange})}),e(Z,{size:"xs","aria-label":"full screen",variant:"ghost",position:"absolute",top:"2",right:"4",onClick:q,children:A?e(Jo,{}):e(Xo,{})})]})]}),r(R,{mt:"4",children:[r(_,{justifyContent:"space-between",children:[e(H,{children:c("core.logs")}),e(h,{as:H,children:c(`core.socket.${g}`)})]}),e(D,{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:C.map((L,V)=>e(h,{fontSize:"xs",opacity:.8,whiteSpace:"pre-line",children:L},V))})]})]}),e(Re,{children:r(_,{w:"full",justifyContent:"space-between",children:[e(D,{children:e(F,{size:"sm",leftIcon:e(qo,{className:Ut({"animate-spin":W})}),onClick:()=>b(),children:c(W?"core.restarting":"core.restartCore")})}),e(_,{children:e(F,{size:"sm",variant:"solid",colorScheme:"primary",px:"5",type:"submit",isDisabled:s||a,isLoading:a,children:c("core.save")})})]})})]})},rs=()=>{const{isEditingCore:t}=E(),n=E.setState.bind(null,{isEditingCore:!1}),{t:o}=j();return r(oe,{isOpen:t,onClose:n,size:"3xl",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"full",children:[e(ie,{pt:6,children:r(_,{gap:2,children:[e(de,{color:"primary",children:e(Qo,{color:"white"})}),e(h,{fontWeight:"semibold",fontSize:"lg",children:o("core.title")})]})}),e(le,{mt:3}),e(ts,{})]})]})},mt=y(_n,{baseStyle:{w:5,h:5}}),ns=()=>{const[t,n]=f.exports.useState(!1),{deletingUser:o,onDeletingUser:s,deleteUser:i}=E(),{t:a}=j(),l=fe(),u=()=>{s(null)},p=()=>{o&&(n(!0),i(o).then(()=>{l({title:a("deleteUser.deleteSuccess",{username:o.username}),status:"success",isClosable:!0,position:"top",duration:3e3})}).then(u).finally(n.bind(null,!1)))};return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:a("deleteUser.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:a("deleteUser.prompt",{username:o.username})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:a("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:p,leftIcon:t?e(Ne,{size:"xs"}):void 0,children:a("delete")})]})]})]})},Zt={baseStyle:{w:4,h:4}},os=y(kn,Zt),ss=y(Er,Zt),Xr=y(Et,Zt),as=zr(t=>{E.getState().onFilterChange({...E.getState().filters,offset:0,search:t})},300),is=({...t})=>{const{loading:n,filters:o,onFilterChange:s,refetchUsers:i,onCreateUser:a}=E(),{t:l}=j(),[u,p]=f.exports.useState(""),C=c=>{p(c.target.value),as(c.target.value)},d=()=>{p(""),s({...o,offset:0,search:""})};return r(Ur,{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(st,{colSpan:{base:1,md:2,lg:1},order:{base:2,md:1},children:r(St,{children:[e(vn,{pointerEvents:"none",children:e(os,{})}),e(je,{placeholder:l("search"),value:u,borderColor:"light-border",onChange:C}),r(Ct,{children:[n&&e(Ne,{size:"xs"}),o.search&&o.search.length>0&&e(Z,{onClick:d,"aria-label":"clear",size:"xs",variant:"ghost",children:e(ss,{})})]})]})}),e(st,{colSpan:2,order:{base:1,md:2},children:r(_,{justifyContent:"flex-end",alignItems:"center",h:"full",children:[e(Z,{"aria-label":"refresh users",disabled:n,onClick:i,size:"sm",variant:"outline",children:e(Xr,{className:Ut({"animate-spin":n})})}),e(F,{colorScheme:"primary",size:"sm",onClick:()=>a(!0),px:5,children:l("createUser")})]})})]})},Jr="https://github.com/Gozargah/Marzban",ls="https://github.com/Gozargah",cs="https://github.com/Gozargah/Marzban#donation",Kr=t=>{const{version:n}=E();return e(_,{w:"full",py:"0",position:"relative",...t,children:r(h,{display:"inline-block",flexGrow:1,textAlign:"center",color:"gray.500",fontSize:"xs",children:[e(Jt,{color:"blue.400",href:Jr,children:"Marzban"}),n?` (v${n}), `:", ","Made with \u2764\uFE0F in"," ",e(Jt,{color:"blue.400",href:ls,children:"Gozargah"})]})})},ds=y(In,{baseStyle:{w:4,h:4}}),en=({actions:t})=>{const{i18n:n}=j();var o=s=>{n.changeLanguage(s)};return r(Rr,{placement:"bottom-end",children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ds,{}),position:"relative"}),r(Tr,{minW:"100px",zIndex:9999,children:[e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("en"),children:"English"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("fa"),children:"\u0641\u0627\u0631\u0633\u06CC"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("zh-cn"),children:"\u7B80\u4F53\u4E2D\u6587"}),e(me,{maxW:"100px",fontSize:"sm",onClick:()=>o("ru"),children:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"})]})]})},be={baseStyle:{w:4,h:4}},hs=y(zn,be),us=y(Dn,be),ps=y(Ir,be),ms=y(En,be),gs=y(Un,be),fs=y(Rn,be),bs=y($t,be),xs=y(Ar,be),ys=y(Dt,be),Ss=y(Mr,be),ur=y(D,{baseStyle:{bg:"yellow.500",w:"2",h:"2",rounded:"full",position:"absolute"}}),tn="marzban-menu-notification",Cs=()=>{const t=localStorage.getItem(tn);if(!t)return!0;try{return t&&Tn(parseInt(t))?An(new Date,new Date(parseInt(t)))>=7:!0}catch{return!0}},ws=({actions:t})=>{const{onEditingHosts:n,onResetAllUsage:o,onEditingNodes:s,onShowingNodesUsage:i}=E(),{t:a}=j(),{colorMode:l,toggleColorMode:u}=ht(),[p,C]=f.exports.useState(Cs()),d=l==="dark"?"dark_dimmed":l,c=()=>{localStorage.setItem(tn,new Date().getTime().toString()),C(!1)};return r(_,{gap:2,justifyContent:"space-between",__css:{"& .menuList":{direction:"ltr"}},position:"relative",children:[e(h,{as:"h1",fontWeight:"semibold",fontSize:"2xl",children:a("users")}),p&&e(ur,{top:"0",right:"0",zIndex:9999}),e(D,{overflow:"auto",css:{direction:"rtl"},children:r(_,{alignItems:"center",children:[r(Rr,{children:[e(Lr,{as:Z,size:"sm",variant:"outline",icon:e(ge,{children:e(ms,{})}),position:"relative"}),r(Tr,{minW:"170px",zIndex:99999,className:"menuList",children:[e(me,{maxW:"170px",fontSize:"sm",icon:e(bs,{}),onClick:n.bind(null,!0),children:a("header.hostSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(xs,{}),onClick:s.bind(null,!0),children:a("header.nodeSettings")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(ys,{}),onClick:i.bind(null,!0),children:a("header.nodesUsage")}),e(me,{maxW:"170px",fontSize:"sm",icon:e(Ss,{}),onClick:o.bind(null,!0),children:a("resetAllUsage")}),e(Kt,{to:cs,target:"_blank",children:r(me,{maxW:"170px",fontSize:"sm",icon:e(fs,{}),position:"relative",onClick:c,children:[a("header.donation")," ",p&&e(ur,{top:"3",right:"2"})]})}),e(Kt,{to:"/login",children:e(me,{maxW:"170px",fontSize:"sm",icon:e(gs,{}),children:a("header.logout")})})]})]}),e(Z,{size:"sm",variant:"outline","aria-label":"core settings",onClick:()=>{E.setState({isEditingCore:!0})},children:e(ps,{})}),e(en,{}),e(Z,{size:"sm",variant:"outline","aria-label":"switch theme",onClick:()=>{Qr(l=="dark"?"light":"dark"),u()},children:l==="light"?e(hs,{}):e(us,{})}),e(D,{css:{direction:"ltr"},display:"flex",alignItems:"center",pr:"2",__css:{"& span":{display:"inline-flex"}},children:e(Ln,{href:Jr,"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"})})]})})]})},_s=[{title:"Inbound's default",value:"inbound_default"},{title:"TLS",value:"tls"},{title:"None",value:"none"}],ks=[{title:"",value:""},{title:"h3",value:"h3"},{title:"h2",value:"h2"},{title:"http/1.1",value:"http/1.1"},{title:"h3,h2,http/1.1",value:"h3,h2,http/1.1"},{title:"h3,h2",value:"h3,h2"},{title:"h2,http/1.1",value:"h2,http/1.1"}],vs=[{title:"",value:""},...["chrome","firefox","safari","ios","android","edge","360","qq","random","randomized"].map(t=>({title:t,value:t}))],Is=[{title:"none",value:""},{title:"xtls-rprx-vision",value:"xtls-rprx-vision"}],zs=["aes-128-gcm","aes-256-gcm","chacha20-ietf-poly1305"],Ds=zt(t=>({isLoading:!1,isPostLoading:!1,hosts:{},fetchHosts:()=>{t({isLoading:!0}),O("/hosts").then(n=>t({hosts:n})).finally(()=>t({isLoading:!1}))},setHosts:n=>(t({isPostLoading:!0}),O("/hosts",{method:"PUT",body:n}).finally(()=>{t({isPostLoading:!1})}))}));const Es=y(Er,{baseStyle:{w:4,h:4}}),Ue=Ft.forwardRef(({disabled:t,step:n,label:o,className:s,startAdornment:i,endAdornment:a,type:l="text",placeholder:u,onChange:p,onBlur:C,name:d,value:c,onClick:w,error:v,clearable:m=!1,...S},T)=>{const g=()=>{p&&p({target:{value:"",name:d}})},{size:b="md"}=S,W=l=="number"?jn:je,$=l=="number"?Mn:Ft.Fragment,I=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:n,name:d,type:l,placeholder:u,onChange:A=>{p&&p(A)},onBlur:C,value:c,onClick:w,disabled:t,flexGrow:1,size:b}:{};return r(R,{isInvalid:!!v,children:[o&&e(H,{children:o}),r(St,{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(Nn,{children:i}),r($,{...I,children:[e(W,{name:d,ref:T,step:n,className:Ut(s),type:l,placeholder:u,onChange:p,onBlur:C,value:c,onClick:w,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(ge,{children:r(Fn,{children:[e(Pn,{}),e(Wn,{})]})})]}),a&&e(On,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",children:a}),m&&c&&c.length&&e(Ct,{borderLeftRadius:0,borderRightRadius:"6px",bg:"transparent",onClick:g,cursor:"pointer",children:e(Es,{})})]}),!!v&&e(wt,{children:v})]})}),Tt=y(Me,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Te=y(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Us=y($t,{baseStyle:{w:5,h:5}}),De=y(Hn,{baseStyle:{w:4,h:4,color:"gray.400",cursor:"pointer"}}),Rs=x.record(x.string().min(1),x.array(x.object({remark:x.string().min(1,"Remark is required"),address:x.string().min(1,"Address is required"),port:x.string().or(x.number()).nullable().transform(t=>typeof t=="number"?t:t!==null&&!isNaN(parseInt(t))?Number(parseInt(t)):null),path:x.string().nullable(),sni:x.string().nullable(),host:x.string().nullable(),mux_enable:x.boolean().default(!1),allowinsecure:x.boolean().nullable().default(!1),is_disabled:x.boolean().default(!0),fragment_setting:x.string().nullable(),random_user_agent:x.boolean().default(!1),security:x.string(),alpn:x.string(),fingerprint:x.string()}))),Se=y(wt,{baseStyle:{color:"red.400",display:"block",textAlign:"left",w:"100%"}}),Ls=({hostKey:t,isOpen:n,toggleAccordion:o})=>{const{inbounds:s}=E(),i=[...s.values()].flat().filter(v=>v.tag===t)[0],a=Vt(),{fields:l,append:u,remove:p}=Bn({control:a.control,name:t}),{errors:C}=a.formState,{t:d}=j(),c=C[t],w=()=>{u({host:"",sni:"",port:null,path:null,address:"",remark:"",mux_enable:!1,allowinsecure:!1,is_disabled:!1,fragment_setting:"",random_user_agent:!1,security:"inbound_default",alpn:"",fingerprint:""})};return f.exports.useEffect(()=>{c&&!n&&o()},[c]),r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:o,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:t}),e(Pt,{})]}),e($e,{px:2,pb:2,children:r(N,{gap:3,children:[l.map((v,m)=>{var S,T,g,b,W,$,I,A,Y,q,L,V,J,z,P,K,Fe,bt,xt,ee,Pe,Ye,Ze,Qe,qe,Xe,k,M,te,xe,he,ye,G,Je,Ke,et,tt;return r(N,{border:"1px solid",_dark:{borderColor:"gray.600",bg:"#273142"},_light:{borderColor:"gray.200",bg:"#fcfbfb"},p:2,w:"full",borderRadius:"4px",children:[e(_,{w:"100%",alignItems:"flex-start",children:r(R,{position:"relative",zIndex:10,isInvalid:!!(c&&((S=c[m])==null?void 0:S.remark)),children:[r(St,{children:[e(Te,{...a.register(t+"."+m+".remark"),size:"sm",borderRadius:"4px",placeholder:"Remark"}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(er,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&((T=c[m])==null?void 0:T.remark)&&e(Se,{children:(b=(g=c[m])==null?void 0:g.remark)==null?void 0:b.message})]})}),r(R,{isInvalid:!!(c&&((W=c[m])==null?void 0:W.address)),children:[r(St,{children:[e(Te,{size:"sm",borderRadius:"4px",placeholder:"Address (e.g. example.com)",...a.register(t+"."+m+".address")}),e(Ct,{children:r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(D,{mt:"-8px",children:e(De,{})})}),e(_e,{children:r(ke,{children:[e(ve,{}),e(Ie,{}),e(er,{children:r(D,{fontSize:"xs",children:[e(h,{pr:"20px",children:d("hostsDialog.desc")}),r(h,{children:[r(U,{children:["{","SERVER_IP","}"]})," ",d("hostsDialog.currentServer")]}),r(h,{mt:1,children:[r(U,{children:["{","SERVER_IPV6","}"]})," ",d("hostsDialog.currentServerv6")]}),r(h,{mt:1,children:[r(U,{children:["{","USERNAME","}"]})," ",d("hostsDialog.username")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_USAGE","}"]})," ",d("hostsDialog.dataUsage")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LEFT","}"]})," ",d("hostsDialog.remainingData")]}),r(h,{mt:1,children:[r(U,{children:["{","DATA_LIMIT","}"]})," ",d("hostsDialog.dataLimit")]}),r(h,{mt:1,children:[r(U,{children:["{","DAYS_LEFT","}"]})," ",d("hostsDialog.remainingDays")]}),r(h,{mt:1,children:[r(U,{children:["{","EXPIRE_DATE","}"]})," ",d("hostsDialog.expireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","JALALI_EXPIRE_DATE","}"]})," ",d("hostsDialog.jalaliExpireDate")]}),r(h,{mt:1,children:[r(U,{children:["{","TIME_LEFT","}"]})," ",d("hostsDialog.remainingTime")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_TEXT","}"]})," ",d("hostsDialog.statusText")]}),r(h,{mt:1,children:[r(U,{children:["{","STATUS_EMOJI","}"]})," ",d("hostsDialog.statusEmoji")]}),r(h,{mt:1,children:[r(U,{children:["{","PROTOCOL","}"]})," ",d("hostsDialog.proxyProtocol")]}),r(h,{mt:1,children:[r(U,{children:["{","TRANSPORT","}"]})," ",d("hostsDialog.proxyMethod")]})]})})]})})]})})]}),c&&(($=c[m])==null?void 0:$.address)&&e(Se,{children:(A=(I=c[m])==null?void 0:I.address)==null?void 0:A.message})]}),e(pt,{w:"full",allowToggle:!0,children:r(He,{border:"0",children:[r(Be,{display:"flex",px:0,py:1,borderRadius:3,_hover:{bg:"transparent"},children:[r(h,{flex:"3",align:"start",fontSize:"xs",color:"gray.600",_dark:{color:"gray.500"},pl:1,children:[d("hostsDialog.advancedOptions"),e(Pt,{fontSize:"sm",ml:1})]}),r($n,{flex:"1",px:"0",children:[e(pe,{control:a.control,name:`${t}.${m}.is_disabled`,render:({field:Q})=>e(_t,{mx:"1.5",colorScheme:"primary",...Q,value:void 0,isChecked:!Q.value,onChange:We=>{console.log(We.target.checked),Q.onChange(!We.target.checked)}})}),e(ne,{label:"Delete",placement:"top",children:e(Z,{"aria-label":"Delete",size:"sm",colorScheme:"red",variant:"ghost",onClick:p.bind(null,m),children:e(mt,{})})})]})]}),e($e,{w:"full",p:1,children:r(N,{w:"full",borderRadius:"4px",children:[r(R,{isInvalid:!!(c&&((Y=c[m])==null?void 0:Y.port)),children:[r(H,{display:"flex",pb:1,alignItems:"center",justifyContent:"space-between",gap:1,m:"0",children:[e("span",{children:d("hostsDialog.port")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.port.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:String(i.port||"8080"),type:"number",...a.register(t+"."+m+".port")})]}),r(R,{isInvalid:!!(c&&((q=c[m])==null?void 0:q.sni)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.sni")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.sni.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"SNI (e.g. example.com)",...a.register(t+"."+m+".sni")}),c&&((L=c[m])==null?void 0:L.sni)&&e(Se,{children:(J=(V=c[m])==null?void 0:V.sni)==null?void 0:J.message})]}),r(R,{isInvalid:!!(c&&((z=c[m])==null?void 0:z.host)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.host")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.host.info")}),e(h,{fontSize:"xs",mt:"2",children:e(Ee,{i18nKey:"hostsDialog.host.wildcard",components:{badge:e(U,{})}})}),e(h,{fontSize:"xs",children:e(Ee,{i18nKey:"hostsDialog.host.multiHost",components:{badge:e(U,{})}})})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Host (e.g. example.com)",...a.register(t+"."+m+".host")}),c&&((P=c[m])==null?void 0:P.host)&&e(Se,{children:(Fe=(K=c[m])==null?void 0:K.host)==null?void 0:Fe.message})]}),r(R,{isInvalid:!!(c&&((bt=c[m])==null?void 0:bt.path)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.path")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.path.info")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"path (e.g. /vless)",...a.register(t+"."+m+".path")}),c&&((xt=c[m])==null?void 0:xt.path)&&e(Se,{children:(Pe=(ee=c[m])==null?void 0:ee.path)==null?void 0:Pe.message})]}),r(R,{height:"66px",children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.security")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.security.info")})]})})]})]}),e(Tt,{size:"sm",...a.register(t+"."+m+".security"),children:_s.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.alpn")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".alpn"),children:ks.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{height:"66px",children:[e(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:e("span",{children:d("hostsDialog.fingerprint")})}),e(Tt,{size:"sm",...a.register(t+"."+m+".fingerprint"),children:vs.map(Q=>e("option",{value:Q.value,children:Q.title},Q.value))})]}),r(R,{isInvalid:!!(c&&((Ye=c[m])==null?void 0:Ye.fragment_setting)),children:[r(H,{display:"flex",pb:1,alignItems:"center",gap:1,justifyContent:"space-between",m:"0",children:[e("span",{children:d("hostsDialog.fragment")}),r(Ce,{isLazy:!0,placement:"right",children:[e(we,{children:e(De,{})}),e(_e,{children:r(ke,{p:2,children:[e(ve,{}),e(Ie,{}),e(h,{fontSize:"xs",pr:5,children:d("hostsDialog.fragment.info")}),e(h,{fontSize:"xs",pr:5,pt:2,pb:1,children:d("hostsDialog.fragment.info.examples")}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,tlshello"}),e(h,{fontSize:"xs",pr:5,children:"100-200,10-20,1-3"}),e(h,{fontSize:"xs",pr:5,pt:"3",children:d("hostsDialog.fragment.info.attention")})]})})]})]}),e(Te,{size:"sm",borderRadius:"4px",placeholder:"Fragment settings by pattern",...a.register(t+"."+m+".fragment_setting")}),c&&((Ze=c[m])==null?void 0:Ze.fragment_setting)&&e(Se,{children:(qe=(Qe=c[m])==null?void 0:Qe.fragment_setting)==null?void 0:qe.message})]}),e(R,{isInvalid:!!(c&&((Xe=c[m])==null?void 0:Xe.allowinsecure)),children:r(at,{...a.register(t+"."+m+".allowinsecure"),name:t+"."+m+".allowinsecure",children:[e(H,{children:d("hostsDialog.allowinsecure")}),c&&((k=c[m])==null?void 0:k.allowinsecure)&&e(Se,{children:(te=(M=c[m])==null?void 0:M.allowinsecure)==null?void 0:te.message})]})}),r(R,{isInvalid:!!(c&&((xe=c[m])==null?void 0:xe.mux_enable)),children:[e(at,{...a.register(t+"."+m+".mux_enable"),children:e(H,{children:d("hostsDialog.muxEnable")})}),c&&((he=c[m])==null?void 0:he.mux_enable)&&e(Se,{children:(G=(ye=c[m])==null?void 0:ye.mux_enable)==null?void 0:G.message})]}),r(R,{isInvalid:!!(c&&((Je=c[m])==null?void 0:Je.random_user_agent)),children:[e(at,{...a.register(t+"."+m+".random_user_agent"),children:e(H,{children:d("hostsDialog.randomUserAgent")})}),c&&((Ke=c[m])==null?void 0:Ke.random_user_agent)&&e(Se,{children:(tt=(et=c[m])==null?void 0:et.random_user_agent)==null?void 0:tt.message})]})]},m)})]})})]},m)}),e(F,{variant:"outline",w:"full",size:"sm",color:"",fontWeight:"normal",onClick:w,children:d("hostsDialog.addHost")})]})})]})},Ts=()=>{const{isEditingHosts:t,onEditingHosts:n,refetchUsers:o,inbounds:s}=E(),{isLoading:i,hosts:a,fetchHosts:l,isPostLoading:u,setHosts:p}=Ds(),C=fe(),{t:d}=j(),[c,w]=f.exports.useState({});f.exports.useEffect(()=>{t&&l()},[t]);const v=Ve({resolver:ut(Rs)});f.exports.useEffect(()=>{a&&t&&v.reset(a)},[a]);const m=()=>{w({}),n(!1)},S=g=>{p(g).then(()=>{C({title:d("hostsDialog.savedSuccess"),status:"success",isClosable:!0,position:"top",duration:3e3}),o()}).catch(b=>{var W,$,I,A,Y;(((W=b==null?void 0:b.response)==null?void 0:W.status)===409||(($=b==null?void 0:b.response)==null?void 0:$.status)===400)&&C({title:(A=(I=b.response)==null?void 0:I._data)==null?void 0:A.detail,status:"error",isClosable:!0,position:"top",duration:3e3}),((Y=b==null?void 0:b.response)==null?void 0:Y.status)===422&&Object.keys(b.response._data.detail).forEach(q=>{C({title:b.response._data.detail[q]+" ("+q+")",status:"error",isClosable:!0,position:"top",duration:3e3})})})},T=g=>{c[String(g)]?delete c[String(g)]:c[String(g)]={},w({...c})};return r(oe,{isOpen:t,onClose:m,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Us,{color:"white"})})}),e(le,{mt:3}),e(ce,{w:"440px",pb:3,pt:3,children:e(Nr,{...v,children:r("form",{onSubmit:v.handleSubmit(S),children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:d("hostsDialog.title")}),i&&d("hostsDialog.loading"),!i&&a&&(Object.keys(a).length>0?e(pt,{w:"full",allowToggle:!0,allowMultiple:!0,index:Object.keys(c).map(g=>parseInt(g)),children:e(N,{w:"full",children:Object.keys(a).map((g,b)=>e(Ls,{toggleAccordion:()=>T(b),isOpen:c[String(b)],hostKey:g},g))})}):"No inbound found. Please check your Xray config file."),e(_,{justifyContent:"flex-end",py:2,children:e(F,{variant:"solid",mt:"2",type:"submit",colorScheme:"primary",size:"sm",px:5,isLoading:u,disabled:u,children:d("hostsDialog.apply")})})]})})})]})]})},rn=x.object({name:x.string().min(1),address:x.string().min(1),port:x.number().min(1).or(x.string().transform(t=>parseFloat(t))),api_port:x.number().min(1).or(x.string().transform(t=>parseFloat(t))),xray_version:x.string().nullable().optional(),id:x.number().nullable().optional(),status:x.enum(["connected","connecting","error","disabled"]).nullable().optional(),message:x.string().nullable().optional(),add_as_new_host:x.boolean().optional(),usage_coefficient:x.number().or(x.string().transform(t=>parseFloat(t)))}),As=()=>({name:"",address:"",port:62050,api_port:62051,xray_version:"",usage_coefficient:1}),dt="fetch-nodes-query-key",Ms=()=>{const{isEditingNodes:t}=E();return Bt({queryKey:dt,queryFn:gt.getState().fetchNodes,refetchInterval:t?3e3:void 0,refetchOnWindowFocus:!1})},gt=zt((t,n)=>({nodes:[],addNode(o){return O("/node",{method:"POST",body:o})},fetchNodes(){return O("/nodes")},fetchNodesUsage(o){return O("/nodes/usage",{query:o})},updateNode(o){return O(`/node/${o.id}`,{method:"PUT",body:o})},setDeletingNode(o){t({deletingNode:o})},reconnectNode(o){return O(`/node/${o.id}/reconnect`,{method:"POST"})},deleteNode:()=>{var o;return O(`/node/${(o=n().deletingNode)==null?void 0:o.id}`,{method:"DELETE"})}})),Qt=(t,n,o)=>{if(t.response&&t.response._data){if(typeof t.response._data.detail=="string")return n({title:t.response._data.detail,status:"error",isClosable:!0,position:"top",duration:3e3});if(typeof t.response._data.detail=="object"&&o){Object.keys(t.response._data.detail).forEach(s=>o.setError(s,{message:t.response._data.detail[s]}));return}}return n({title:"Something went wrong!",status:"error",isClosable:!0,position:"top",duration:3e3})},qt=(t,n)=>n({title:t,status:"success",isClosable:!0,position:"top",duration:3e3}),Ns=({deleteCallback:t})=>{const{deleteNode:n,deletingNode:o,setDeletingNode:s}=gt(),{t:i}=j(),a=fe(),l=Gt(),u=()=>{s(null)},{isLoading:p,mutate:C}=lt(n,{onSuccess:()=>{qt(i("deleteNode.deleteSuccess",{name:o&&o.name}),a),s(null),l.invalidateQueries(dt),t&&t()},onError:d=>{Qt(d,a)}});return r(oe,{isCentered:!0,isOpen:!!o,onClose:u,size:"sm",children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",children:[e(ie,{pt:6,children:e(de,{color:"red",children:e(mt,{})})}),e(le,{mt:3}),r(ce,{children:[e(h,{fontWeight:"semibold",fontSize:"lg",children:i("deleteNode.title")}),o&&e(h,{mt:1,fontSize:"sm",_dark:{color:"gray.400"},color:"gray.600",children:e(Ee,{components:{b:e("b",{})},children:i("deleteNode.prompt",{name:o.name})})})]}),r(Re,{display:"flex",children:[e(F,{size:"sm",onClick:u,mr:3,w:"full",variant:"outline",children:i("cancel")}),e(F,{size:"sm",w:"full",colorScheme:"red",onClick:()=>C(),leftIcon:p?e(Ne,{size:"xs"}):void 0,children:i("delete")})]})]})]})},ft={baseStyle:{strokeWidth:"2px",w:4,h:4}},pr=y(Vn,ft),Fs=y(Gn,ft),mr=y(Yn,ft),gr=y(Fr,ft),Ps=y(Fr,ft),jt=[{title:"No",value:"no_reset"},{title:"Daily",value:"day"},{title:"Weekly",value:"week"},{title:"Monthly",value:"month"},{title:"Annually",value:"year"}],it={active:{statusColor:"green",bandWidthColor:"primary",icon:pr},connected:{statusColor:"green",bandWidthColor:"primary",icon:pr},disabled:{statusColor:"gray",bandWidthColor:"gray",icon:Fs},expired:{statusColor:"orange",bandWidthColor:"orange",icon:gr},on_hold:{statusColor:"purple",bandWidthColor:"purple",icon:Ps},connecting:{statusColor:"orange",bandWidthColor:"orange",icon:gr},limited:{statusColor:"red",bandWidthColor:"red",icon:mr},error:{statusColor:"red",bandWidthColor:"red",icon:mr}},Xt=t=>{let n={status:"",time:""};if(t){B(t*1e3).utc().isAfter(B().utc())?n.status="expires":n.status="expired";const o=[],s=B.duration(B(t*1e3).utc().diff(B()));s.years()!=0&&o.push(Math.abs(s.years())+" year"+(Math.abs(s.years())!=1?"s":"")),s.months()!=0&&o.push(Math.abs(s.months())+" month"+(Math.abs(s.months())!=1?"s":"")),s.days()!=0&&o.push(Math.abs(s.days())+" day"+(Math.abs(s.days())!=1?"s":"")),o.length===0&&(s.hours()!=0&&o.push(Math.abs(s.hours())+" hour"+(Math.abs(s.hours())!=1?"s":"")),s.minutes()!=0&&o.push(Math.abs(s.minutes())+" min"+(Math.abs(s.minutes())!=1?"s":""))),n.time=o.join(", ")}return n},yt=({expiryDate:t,status:n,compact:o=!1,showDetail:s=!0,extraText:i})=>{const{t:a}=j(),l=Xt(t),u=it[n].icon;return r(ge,{children:[r(U,{colorScheme:it[n].statusColor,rounded:"full",display:"inline-flex",px:3,py:1,columnGap:o?1:2,alignItems:"center",children:[e(u,{w:o?3:4}),s&&r(h,{textTransform:"capitalize",fontSize:o?".7rem":".875rem",lineHeight:o?"1rem":"1.25rem",fontWeight:"medium",letterSpacing:"tighter",children:[n==="on_hold"?a(n):n,i&&`: ${i}`]})]}),s&&t&&e(h,{display:"inline-block",fontSize:"xs",fontWeight:"medium",ml:"2",color:"gray.600",_dark:{color:"gray.400"},children:a(l.status,{time:l.time})})]})},nt=y(Ue,{baseStyle:{bg:"white",_dark:{bg:"gray.700"}}}),Ws=y(Ar,{baseStyle:{w:5,h:5}}),Os=y(Zn,{baseStyle:{w:5,h:5,strokeWidth:2}}),js=({toggleAccordion:t,node:n})=>{const{updateNode:o,reconnectNode:s,setDeletingNode:i}=gt(),{t:a}=j(),l=Gt(),u=fe(),p=Ve({defaultValues:n,resolver:ut(rn)}),C=i.bind(null,n),{isLoading:d,mutate:c}=lt(o,{onSuccess:()=>{qt("Node updated successfully",u),l.invalidateQueries(dt)},onError:S=>{Qt(S,u,p)}}),{isLoading:w,mutate:v}=lt(s.bind(null,n),{onSuccess:()=>{l.invalidateQueries(dt)}}),m=w?"connecting":n.status?n.status:"error";return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[r(Be,{px:2,borderRadius:"3px",onClick:t,children:[r(_,{w:"full",justifyContent:"space-between",pr:2,children:[e(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},children:n.name}),r(_,{children:[n.xray_version&&e(U,{colorScheme:"blue",rounded:"full",display:"inline-flex",px:3,py:1,children:r(h,{textTransform:"capitalize",fontSize:"0.7rem",fontWeight:"medium",letterSpacing:"tighter",children:["Xray ",n.xray_version]})}),n.status&&e(yt,{status:m,compact:!0})]})]}),e(Pt,{})]}),r($e,{px:2,pb:2,children:[e(N,{pb:3,alignItems:"flex-start",children:m==="error"&&e(ct,{status:"error",size:"xs",children:r(D,{children:[r(_,{w:"full",children:[e(kt,{w:4}),e(h,{marginInlineEnd:0,children:n.message})]}),e(_,{justifyContent:"flex-end",w:"full",children:e(F,{size:"sm","aria-label":"reconnect node",leftIcon:e(Xr,{}),onClick:()=>v(),disabled:w,children:a(w?"nodes.reconnecting":"nodes.reconnect")})})]})})}),e(nn,{form:p,mutate:c,isLoading:d,submitBtnText:a("nodes.editNode"),btnLeftAdornment:e(ne,{label:a("delete"),placement:"top",children:e(Z,{colorScheme:"red",variant:"ghost",size:"sm","aria-label":"delete node",onClick:C,children:e(mt,{})})})})]})]})},Hs=({toggleAccordion:t,resetAccordions:n})=>{const o=fe(),{t:s}=j(),i=Gt(),{addNode:a}=gt(),l=Ve({resolver:ut(rn),defaultValues:{...As(),add_as_new_host:!0}}),{isLoading:u,mutate:p}=lt(a,{onSuccess:()=>{qt(s("nodes.addNodeSuccess",{name:l.getValues("name")}),o),i.invalidateQueries(dt),l.reset(),n()},onError:C=>{Qt(C,o,l)}});return r(He,{border:"1px solid",_dark:{borderColor:"gray.600"},_light:{borderColor:"gray.200"},borderRadius:"4px",p:1,w:"full",children:[e(Be,{px:2,borderRadius:"3px",onClick:t,children:r(h,{as:"span",fontWeight:"medium",fontSize:"sm",flex:"1",textAlign:"left",color:"gray.700",_dark:{color:"gray.300"},display:"flex",gap:1,children:[e(Os,{display:"inline-block"})," ",e("span",{children:s("nodes.addNewMarzbanNode")})]})}),e($e,{px:2,py:4,children:e(nn,{form:l,mutate:p,isLoading:u,submitBtnText:s("nodes.addNode"),btnProps:{variant:"solid"},addAsHost:!0})})]})},nn=({form:t,mutate:n,isLoading:o,submitBtnText:s,btnProps:i={},btnLeftAdornment:a,addAsHost:l=!1})=>{var v,m,S,T,g,b,W,$,I,A,Y,q,L,V,J;const{t:u}=j(),[p,C]=f.exports.useState(!1),{data:d,isLoading:c}=Bt({queryKey:"node-settings",queryFn:()=>O("/node/settings")});function w(z){if(document.body.createTextRange){const P=document.body.createTextRange();P.moveToElementText(z),P.select()}else if(window.getSelection){const P=window.getSelection(),K=document.createRange();K.selectNodeContents(z),P.removeAllRanges(),P.addRange(K)}else console.warn("Could not select text in node: Unsupported browser.")}return e("form",{onSubmit:t.handleSubmit(z=>n(z)),children:r(N,{children:[d&&d.certificate&&e(ct,{status:"info",alignItems:"start",children:r(Pr,{display:"flex",flexDirection:"column",overflow:"hidden",children:[e("span",{children:u("nodes.connection-hint")}),r(_,{justify:"end",py:2,children:[e(F,{as:"a",colorScheme:"primary",size:"xs",download:"ssl_client_cert.pem",href:URL.createObjectURL(new Blob([d.certificate],{type:"text/plain"})),children:u("nodes.download-certificate")}),e(ne,{placement:"top",label:u("nodes.show-certificate"),children:e(Z,{"aria-label":u("nodes.show-certificate"),onClick:C.bind(null,!p),colorScheme:"whiteAlpha",color:"primary",size:"xs",children:p?e(qn,{width:"15px"}):e(Qn,{width:"15px"})})})]}),e(Wr,{in:p,animateOpacity:!0,children:e(h,{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=>{w(z.target)},children:d.certificate})})]})}),r(_,{w:"full",children:[e(R,{children:e(nt,{label:u("nodes.nodeName"),size:"sm",placeholder:"Marzban-S2",...t.register("name"),error:(S=(m=(v=t.formState)==null?void 0:v.errors)==null?void 0:m.name)==null?void 0:S.message})}),e(_,{px:1,children:e(pe,{name:"status",control:t.control,render:({field:z})=>e(ne,{placement:"top",label:`${u("usersTable.status")}: `+(z.value!=="disabled"?u("active"):u("disabled")),textTransform:"capitalize",children:e(D,{mt:"6",children:e(_t,{colorScheme:"primary",isChecked:z.value!=="disabled",onChange:P=>{P.target.checked?z.onChange("connecting"):z.onChange("disabled")}})})},z.value)})})]}),e(_,{alignItems:"flex-start",w:"100%",children:e(D,{w:"100%",children:e(nt,{label:u("nodes.nodeAddress"),size:"sm",placeholder:"51.20.12.13",...t.register("address"),error:(b=(g=(T=t.formState)==null?void 0:T.errors)==null?void 0:g.address)==null?void 0:b.message})})}),r(_,{alignItems:"flex-start",w:"100%",children:[e(D,{children:e(nt,{label:u("nodes.nodePort"),size:"sm",placeholder:"62050",...t.register("port"),error:(I=($=(W=t.formState)==null?void 0:W.errors)==null?void 0:$.port)==null?void 0:I.message})}),e(D,{children:e(nt,{label:u("nodes.nodeAPIPort"),size:"sm",placeholder:"62051",...t.register("api_port"),error:(q=(Y=(A=t.formState)==null?void 0:A.errors)==null?void 0:Y.api_port)==null?void 0:q.message})}),e(D,{children:e(nt,{label:u("nodes.usageCoefficient"),size:"sm",placeholder:"1",...t.register("usage_coefficient"),error:(J=(V=(L=t.formState)==null?void 0:L.errors)==null?void 0:V.usage_coefficient)==null?void 0:J.message})})]}),l&&e(R,{py:1,children:e(at,{...t.register("add_as_new_host"),children:e(H,{m:0,children:u("nodes.addHostForEveryInbound")})})}),r(_,{w:"full",children:[a,e(F,{flexGrow:1,type:"submit",colorScheme:"primary",size:"sm",px:5,w:"full",isLoading:o,...i,children:s})]})]})})},Bs=()=>{const{isEditingNodes:t,onEditingNodes:n}=E(),{t:o}=j(),[s,i]=f.exports.useState({}),{data:a,isLoading:l}=Ms(),u=()=>{i({}),n(!1)},p=C=>{s[String(C)]?delete s[String(C)]:s[String(C)]={},i({...s})};return r(ge,{children:[r(oe,{isOpen:t,onClose:u,children:[e(se,{bg:"blackAlpha.300",backdropFilter:"blur(10px)"}),r(ae,{mx:"3",w:"fit-content",maxW:"3xl",children:[e(ie,{pt:6,children:e(de,{color:"primary",children:e(Ws,{color:"white"})})}),e(le,{mt:3}),r(ce,{w:"440px",pb:6,pt:3,children:[e(h,{mb:3,opacity:.8,fontSize:"sm",children:o("nodes.title")}),l&&"loading...",e(pt,{w:"full",allowToggle:!0,index:Object.keys(s).map(C=>parseInt(C)),children:r(N,{w:"full",children:[!l&&a&&a.map((C,d)=>e(js,{toggleAccordion:()=>p(d),node:C},C.name)),e(Hs,{toggleAccordion:()=>p((a||[]).length),resetAccordions:()=>i({})})]})})]})]})]}),e(Ns,{deleteCallback:()=>i({})})]})};function $s(t){const n=360/t,o=90,s=47,i=[];for(let a=0;a(w<0&&(w+=1),w>1&&(w-=1),w<.16666666666666666?d+(c-d)*6*w:w<.5?c:w<.6666666666666666?d+(c-d)*(.6666666666666666-w)*6:d),p=o<.5?o*(1+n):o+n-o*n,C=2*o-p;s=Math.round(u(C,p,t+1/3)*255),i=Math.round(u(C,p,t)*255),a=Math.round(u(C,p,t-1/3)*255)}const l=u=>{const p=u.toString(16);return p.length===1?"0"+p:p};return`#${l(s)}${l(i)}${l(a)}`}const fr=({border:t,...n})=>{const{getInputProps:o,getRadioProps:s}=no(n),i=Ae({base:"xs",md:"sm"});return r(D,{as:"label",children:[e("input",{...o()}),e(D,{...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:n.children})]})},on=({onChange:t,defaultValue:n,...o})=>{const{t:s,i18n:i}=j();ht();const a=Ae({base:["7h","1d","3d","1w"],md:["7h","1d","3d","1w","1m","3m"]}),l={h:"hour",d:"day",w:"week",m:"month",y:"year"},u=Ae({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:C,setValue:d}=Xn({name:"filter",defaultValue:n,onChange:z=>{if(z==="custom")return;v(),a.indexOf(z)>=0?(T(s("userDialog.custom")),b(!1)):(T(s("userDialog.custom")+` (${z})`),b(!0));const P=Number(z.substring(0,z.length-1)),K=l[z[z.length-1]];t(z,{start:B().utc().subtract(P,K).format("YYYY-MM-DDTHH:00:00")})}}),{isOpen:c,onOpen:w,onClose:v}=Jn(),m=f.exports.useRef(null);Kn({ref:m,handler:v});const[S,T]=f.exports.useState(s("userDialog.custom")),[g,b]=f.exports.useState(!1),[W,$]=f.exports.useState(0),I=Ae({base:1,md:2}),A=Ae({base:"xs",md:"sm"}),[Y,q]=f.exports.useState(null),[L,V]=f.exports.useState(null),J=z=>{const[P,K]=z;L&&!K?(q(null),V(null)):(q(P),V(K),P&&K&&(v(),t("custom",{start:B(P).format("YYYY-MM-DDT00:00:00"),end:B(K).format("YYYY-MM-DDT23:59:59")})))};return r(N,{...o,children:[W==0&&r(Yt,{...p(),gap:0,display:"flex",borderWidth:"1px",borderRadius:"md",minW:{base:"320px",md:"400px"},children:[a.map(z=>e(fr,{...C({value:z}),children:z},z)),e(D,{onClick:()=>{q(null),V(null),w()},cursor:"pointer",borderRadius:"md",w:"full",fontSize:A,px:3,py:1,bg:g?"primary.500":"unset",color:g?"white":"unset",borderColor:g?"primary.500":"unset",children:r(_,{children:[e(h,{children:S}),e(Rt,{as:tr,boxSize:"18px"})]})})]}),W==1&&r(_,{onClick:w,cursor:"pointer",fontSize:A,borderRadius:"md",px:3,py:1,minW:{base:"320px",md:"400px"},borderWidth:"1px",children:[e(h,{w:"full",color:Y?"unset":"gray.500",children:Y?B(Y).format("YYYY-MM-DD (00:00)"):s("userDialog.startDate")}),e(Rt,{as:Or,boxSize:"18px"}),e(h,{w:"full",color:L?"unset":"gray.500",children:L?B(L).format("YYYY-MM-DD (23:59)"):s("userDialog.endDate")}),e(Rt,{as:tr,boxSize:"18px"})]}),e(N,{ref:m,marginTop:"40px !important",borderRadius:"md",borderWidth:"1px",position:"absolute",zIndex:"1",backgroundColor:"white",_dark:{backgroundColor:"gray.700"},display:c?"unset":"none",children:r(eo,{onChange:z=>$(z),children:[r(to,{children:[e(rr,{fontSize:A,children:s("userDialog.relative")}),e(rr,{fontSize:A,children:s("userDialog.absolute")})]}),r(ro,{children:[e(nr,{children:u.map(z=>e(N,{alignItems:"start",pl:2,pr:2,children:r(_,{justifyItems:"flex-start",mb:4,children:[e(h,{fontSize:A,minW:"60px",children:s("userDialog."+z.title)}),z.options.map(P=>e(fr,{border:!0,...C({value:P}),children:P},P+".custom"))]})},z.title))}),e(nr,{className:"datepicker-panel",children:e(N,{children:e(jr,{locale:i.language.toLocaleLowerCase(),selected:Y,onChange:J,startDate:Y,endDate:L,selectsRange:!0,maxDate:new Date,monthsShown:I,peekNextMonth:!1,inline:!0})})})]})]})})]})};function It(t,n,o=[],s=[]){const i=re(o.reduce((a,l)=>a+=l,0));return{series:o,options:{labels:s,chart:{width:"100%",height:"100%",type:"donut",animations:{enabled:!1}},title:{text:`${n}${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:u})=>re(u.config.series[l],1)},tooltip:{custom:({series:a,seriesIndex:l,dataPointIndex:u,w:p})=>{const C=re(a[l],1),d=Math.max(a.reduce((w,v)=>w+=v),1),c=Math.round(a[l]/d*1e3)/10+"%";return`