diff --git a/app/Http/Controllers/V2/Admin/ConfigController.php b/app/Http/Controllers/V2/Admin/ConfigController.php index 86a5375..e36e843 100644 --- a/app/Http/Controllers/V2/Admin/ConfigController.php +++ b/app/Http/Controllers/V2/Admin/ConfigController.php @@ -218,7 +218,7 @@ class ConfigController extends Controller ) ), 'subscribe_template_surge' => (string) $this->getTemplateContent( - $this->getRuleFile(Stash::CUSTOM_TEMPLATE_FILE, Stash::DEFAULT_TEMPLATE_FILE) + $this->getRuleFile(Surge::CUSTOM_TEMPLATE_FILE, Surge::DEFAULT_TEMPLATE_FILE) ), 'subscribe_template_surfboard' => (string) $this->getTemplateContent( $this->getRuleFile(Surfboard::CUSTOM_TEMPLATE_FILE, Surfboard::DEFAULT_TEMPLATE_FILE) diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 1374837..8824fb6 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,4 +1,4 @@ -import{r as u,j as e,t as Sl,c as kl,I as Ka,a as zs,S as Na,u as Ts,b as Tl,d as _a,R as fn,e as gn,f as Dl,F as Pl,C as El,L as jn,T as vn,g as bn,h as Rl,i as Il,k as Vl,l as $,z as x,m as V,n as fe,o as be,p as ie,q as os,s as Ce,v as Ws,w as Ml,O as wa,x as Fl,y as Ol,A as Ll,B as zl,D as Al,E as $l,Q as Hl,G as Ul,H as ql,J as Kl,P as Bl,K as Gl,M as Wl,N as Yl,U as Ql,V as yn,W as Nn,X as zt,Y as At,Z as Ca,_ as Ze,$ as $t,a0 as Ht,a1 as _n,a2 as wn,a3 as Cn,a4 as Sa,a5 as Sn,a6 as Jl,a7 as kn,a8 as Tn,a9 as Dn,aa as Pn,ab as As,ac as En,ad as Xl,ae as Rn,af as In,ag as Zl,ah as ei,ai as si,aj as ti,ak as ai,al as ni,am as ri,an as li,ao as ii,ap as oi,aq as ci,ar as Vn,as as di,at as ui,au as $s,av as Mn,aw as mi,ax as xi,ay as Fn,az as ka,aA as hi,aB as pi,aC as Ba,aD as fi,aE as On,aF as gi,aG as Ln,aH as ji,aI as vi,aJ as bi,aK as yi,aL as Ni,aM as _i,aN as zn,aO as wi,aP as Ci,aQ as Si,aR as Le,aS as ki,aT as An,aU as Ti,aV as Di,aW as $n,aX as Hn,aY as Un,aZ as Pi,a_ as Ei,a$ as Ri,b0 as qn,b1 as Ii,b2 as Ta,b3 as Kn,b4 as Vi,b5 as Bn,b6 as Mi,b7 as Gn,b8 as Fi,b9 as Wn,ba as Yn,bb as Oi,bc as Li,bd as Qn,be as zi,bf as Ai,bg as Jn,bh as $i,bi as Xn,bj as Hi,bk as Ui,bl as ls,bm as rs,bn as jt,bo as qi,bp as Ki,bq as Bi,br as Gi,bs as Wi,bt as Yi,bu as Ga,bv as Wa,bw as Qi,bx as Ji,by as Xi,bz as Zi,bA as eo,bB as ha,bC as pt,bD as so,bE as to,bF as Zn,bG as ao,bH as no,bI as er,bJ as ro,bK as lo,bL as Ya,bM as pa,bN as fa,bO as io,bP as oo,bQ as sr,bR as co,bS as Da,bT as uo,bU as mo,bV as xo,bW as tr,bX as ar,bY as ho,bZ as po,b_ as fo,b$ as go,c0 as jo,c1 as nr,c2 as vo,c3 as bo,c4 as yo,c5 as No,c6 as Rt,c7 as Ve,c8 as Qa,c9 as _o,ca as rr,cb as lr,cc as ir,cd as or,ce as cr,cf as dr,cg as wo,ch as Co,ci as So,cj as Ut,ck as Hs,cl as cs,cm as ts,cn as as,co as ds,cp as us,cq as ms,cr as ko,cs as To,ct as Do,cu as Po,cv as Eo,cw as Ro,cx as Io,cy as Vo,cz as Mo,cA as ga,cB as Pa,cC as Ea,cD as Fo,cE as Ds,cF as Ps,cG as qt,cH as Oo,cI as It,cJ as Lo,cK as Ja,cL as ur,cM as Xa,cN as Vt,cO as zo,cP as Ao,cQ as $o,cR as Ho,cS as mr,cT as Uo,cU as qo,cV as xr,cW as ja,cX as hr,cY as Ko,cZ as pr,c_ as fr,c$ as Bo,d0 as Go,d1 as Wo,d2 as Yo,d3 as Qo}from"./vendor.js";import"./index.js";var cp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Jo(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var t=function r(){return this instanceof r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return s[r]}})}),t}const Xo={theme:"system",setTheme:()=>null},gr=u.createContext(Xo);function Zo({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=u.useState(()=>localStorage.getItem(t)||n);u.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const m=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(m);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(gr.Provider,{...r,value:l,children:s})}const ec=()=>{const s=u.useContext(gr);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},sc=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),tc=function(s,n){return new URL(s,n).href},Za={},me=function(n,t,r){let a=Promise.resolve();if(t&&t.length>0){const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(o=>{if(o=tc(o,r),o in Za)return;Za[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(!!r)for(let C=l.length-1;C>=0;C--){const S=l[C];if(S.href===o&&(!c||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const E=document.createElement("link");if(E.rel=c?"stylesheet":sc,c||(E.as="script"),E.crossOrigin="",E.href=o,m&&E.setAttribute("nonce",m),document.head.appendChild(E),c)return new Promise((C,S)=>{E.addEventListener("load",C),E.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function N(...s){return Sl(kl(s))}const rt=zs("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),P=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:m,...o},c)=>{const h=r?Na:"button";return e.jsxs(h,{className:N(rt({variant:n,size:t,className:s})),disabled:l||i,ref:c,...o,children:[(d&&l||!d&&!m&&l)&&e.jsx(Ka,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&m&&e.jsx("div",{className:"ml-2",children:m}),m&&l&&e.jsx(Ka,{className:"ml-2 h-4 w-4 animate-spin"})]})});P.displayName="Button";function Ys({className:s,minimal:n=!1}){const t=Ts(),r=Tl(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:N("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{}),a]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function en(){const s=Ts();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function ac(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(P,{variant:"outline",children:"Learn more"})})]})})}function nc(s){return typeof s>"u"}function rc(s){return s===null}function lc(s){return rc(s)||nc(s)}class ic{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,t,r=null){const a=JSON.stringify({value:t,time:Date.now(),expire:r!==null?new Date().getTime()+r*1e3:null});this.storage.setItem(this.getKey(n),a)}get(n,t=null){const r=this.storage.getItem(this.getKey(n));if(!r)return{value:t,time:0};try{const a=JSON.parse(r),{value:i,time:l,expire:d}=a;return lc(d)||d>new Date().getTime()?{value:i,time:l}:(this.remove(n),{value:t,time:0})}catch{return this.remove(n),{value:t,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function jr({prefixKey:s="",storage:n=sessionStorage}){return new ic({prefixKey:s,storage:n})}const vr="Xboard_",oc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:localStorage})},cc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:sessionStorage})},Kt=oc({prefixKey:vr});cc({prefixKey:vr});const br="access_token";function ft(){return Kt.get(br)}function yr(){Kt.remove(br)}const sn=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function dc({children:s}){const n=Ts(),t=_a(),r=ft();return u.useEffect(()=>{if(!r.value&&!sn.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),sn.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const ke=u.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(fn,{ref:a,decorative:t,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));ke.displayName=fn.displayName;const uc=zs("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mt=u.forwardRef(({className:s,...n},t)=>e.jsx(gn,{ref:t,className:N(uc(),s),...n}));Mt.displayName=gn.displayName;const ye=Pl,Nr=u.createContext({}),g=({...s})=>e.jsx(Nr.Provider,{value:{name:s.name},children:e.jsx(El,{...s})}),Bt=()=>{const s=u.useContext(Nr),n=u.useContext(_r),{getFieldState:t,formState:r}=Dl(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:i}=n;return{id:i,name:s.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},_r=u.createContext({}),f=u.forwardRef(({className:s,...n},t)=>{const r=u.useId();return e.jsx(_r.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:N("space-y-2",s),...n})})});f.displayName="FormItem";const j=u.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Bt();return e.jsx(Mt,{ref:t,className:N(r&&"text-destructive",s),htmlFor:a,...n})});j.displayName="FormLabel";const y=u.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Bt();return e.jsx(Na,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});y.displayName="FormControl";const F=u.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Bt();return e.jsx("p",{ref:t,id:r,className:N("text-[0.8rem] text-muted-foreground",s),...n})});F.displayName="FormDescription";const T=u.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Bt(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:N("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});T.displayName="FormMessage";const Gt=Rl,vt=u.forwardRef(({className:s,...n},t)=>e.jsx(jn,{ref:t,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));vt.displayName=jn.displayName;const qe=u.forwardRef(({className:s,...n},t)=>e.jsx(vn,{ref:t,className:N("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));qe.displayName=vn.displayName;const ps=u.forwardRef(({className:s,...n},t)=>e.jsx(bn,{ref:t,className:N("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ps.displayName=bn.displayName;function Ne(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Il(s).format(n))}function mc(s=void 0,n="YYYY-MM-DD"){return Ne(s,n)}function Xs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ls(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,i=>i.includes(".")?".00":i);return n?`¥${a}`:a}function Ft(s){return new Promise(n=>{(async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(s);else{const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),!a)throw new Error("execCommand failed")}n(!0)}catch(r){console.error(r),n(!1)}})()})}function fs(s){const n=s/1024,t=n/1024,r=t/1024,a=r/1024;return a>=1?Xs(a)+" TB":r>=1?Xs(r)+" GB":t>=1?Xs(t)+" MB":Xs(n)+" KB"}const xc="locale";function hc(){return Kt.get(xc)}function wr(){yr();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),t=new URL(window.location.href),a=`${t.pathname.split("/")[1]?`/${t.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=a+(n?`?redirect=${s}`:"")}const pc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function fc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const I=Vl.create({baseURL:fc(),timeout:12e3,headers:{"Content-Type":"application/json"}});I.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=ft();if(!pc.includes(s.url?.split("?")[0]||"")){if(!n.value)return wr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=hc().value||"zh-CN",s},s=>Promise.reject(s));I.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,t=s.response?.data?.message;return(n===401||n===403)&&wr(),$.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const gc="access_token";function jc(s){Kt.set(gc,s)}const H=window?.settings?.secure_path,vc=s=>I.get(H+"/stat/getOrder",{params:s}),bc=()=>I.get(H+"/stat/getStats"),tn=s=>I.get(H+"/stat/getTrafficRank",{params:s}),yc=()=>I.get(H+"/theme/getThemes"),Nc=s=>I.post(H+"/theme/getThemeConfig",{name:s}),_c=(s,n)=>I.post(H+"/theme/saveThemeConfig",{name:s,config:n}),wc=s=>{const n=new FormData;return n.append("file",s),I.post(H+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Cc=s=>I.post(H+"/theme/delete",{name:s}),Sc=s=>I.post(H+"/config/save",s),Cr=()=>I.get(H+"/server/manage/getNodes"),kc=s=>I.post(H+"/server/manage/save",s),Tc=s=>I.post(H+"/server/manage/drop",s),Dc=s=>I.post(H+"/server/manage/copy",s),Pc=s=>I.post(H+"/server/manage/update",s),Ec=s=>I.post(H+"/server/manage/sort",s),bt=()=>I.get(H+"/server/group/fetch"),Rc=s=>I.post(H+"/server/group/save",s),Ic=s=>I.post(H+"/server/group/drop",s),Sr=()=>I.get(H+"/server/route/fetch"),Vc=s=>I.post(H+"/server/route/save",s),Mc=s=>I.post(H+"/server/route/drop",s),Fc=()=>I.get(H+"/payment/fetch"),Oc=()=>I.get(H+"/payment/getPaymentMethods"),Lc=s=>I.post(H+"/payment/getPaymentForm",s),zc=s=>I.post(H+"/payment/save",s),Ac=s=>I.post(H+"/payment/drop",s),$c=s=>I.post(H+"/payment/show",s),Hc=s=>I.post(H+"/payment/sort",s),Uc=s=>I.post(H+"/notice/save",s),qc=s=>I.post(H+"/notice/drop",s),Kc=s=>I.post(H+"/notice/show",s),Bc=()=>I.get(H+"/knowledge/fetch"),Gc=s=>I.get(H+"/knowledge/fetch?id="+s),Wc=s=>I.post(H+"/knowledge/save",s),Yc=s=>I.post(H+"/knowledge/drop",s),Qc=s=>I.post(H+"/knowledge/show",s),Jc=s=>I.post(H+"/knowledge/sort",s),Us=()=>I.get(H+"/plan/fetch"),Xc=s=>I.post(H+"/plan/save",s),aa=s=>I.post(H+"/plan/update",s),Zc=s=>I.post(H+"/plan/drop",s),ed=s=>I.post(H+"/plan/sort",{ids:s}),sd=async s=>I.post(H+"/order/fetch",s),td=s=>I.post(H+"/order/detail",s),ad=s=>I.post(H+"/order/paid",s),nd=s=>I.post(H+"/order/cancel",s),an=s=>I.post(H+"/order/update",s),rd=s=>I.post(H+"/order/assign",s),ld=s=>I.post(H+"/coupon/fetch",s),id=s=>I.post(H+"/coupon/generate",s),od=s=>I.post(H+"/coupon/drop",s),cd=s=>I.post(H+"/coupon/update",s),dd=s=>I.post(H+"/user/fetch",s),ud=s=>I.post(H+"/user/update",s),md=s=>I.post(H+"/user/resetSecret",s),xd=s=>I.post(H+"/user/generate",s),hd=s=>I.post(H+"/stat/getStatUser",s),pd=s=>I.post(H+"/ticket/fetch",s),fd=s=>I.get(H+"/ticket/fetch?id= "+s),gd=s=>I.post(H+"/ticket/close",{id:s}),js=(s="")=>I.get(H+"/config/fetch?key="+s),vs=s=>I.post(H+"/config/save",s),jd=()=>I.get(H+"/config/getEmailTemplate"),vd=()=>I.post(H+"/config/testSendMail"),bd=()=>I.post(H+"/config/setTelegramWebhook"),yd=x.object({subscribe_template_singbox:x.string().nullable(),subscribe_template_clash:x.string().nullable(),subscribe_template_clashmeta:x.string().nullable(),subscribe_template_stash:x.string().nullable(),subscribe_template_surge:x.string().nullable(),subscribe_template_surfboard:x.string().nullable()}),Nd={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function _d(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),[a,i]=u.useState("singbox"),l=fe({resolver:be(yd),defaultValues:Nd,mode:"onBlur"}),{data:d}=ie({queryKey:["settings","client"],queryFn:()=>js("subscribe_template")}),{mutateAsync:m}=os({mutationFn:vs,onSuccess:h=>{h.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(d?.data.subscribe_template){const h=d.data.subscribe_template;Object.entries(h).forEach(([_,E])=>{l.setValue(_,E)}),r.current=h}},[d]),console.log(l.getValues());const o=u.useCallback(Ce.debounce(async h=>{if(!Ce.isEqual(h,r.current)){t(!0);try{await m(h),r.current=h}finally{t(!1)}}},1e3),[m]),c=u.useCallback(h=>{o(h)},[o]);return e.jsx(ye,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Gt,{value:a,onValueChange:i,children:[e.jsxs(vt,{children:[e.jsx(qe,{value:"singbox",children:"Sing-box"}),e.jsx(qe,{value:"clash",children:"Clash"}),e.jsx(qe,{value:"clashmeta",children:"Clash Meta"}),e.jsx(qe,{value:"stash",children:"Stash"}),e.jsx(qe,{value:"surge",children:"Surge"}),e.jsx(qe,{value:"surfboard",children:"Surfboard"})]}),e.jsx(ps,{value:"singbox",children:e.jsx(g,{control:l.control,name:"subscribe_template_singbox",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.singbox.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"json",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.singbox.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"clash",children:e.jsx(g,{control:l.control,name:"subscribe_template_clash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clash.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clash.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"clashmeta",children:e.jsx(g,{control:l.control,name:"subscribe_template_clashmeta",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clashmeta.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clashmeta.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"stash",children:e.jsx(g,{control:l.control,name:"subscribe_template_stash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.stash.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.stash.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"surge",children:e.jsx(g,{control:l.control,name:"subscribe_template_surge",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.surge.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"ini",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.surge.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"surfboard",children:e.jsx(g,{control:l.control,name:"subscribe_template_surfboard",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.sufboard.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"ini",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.sufboard.description")}),e.jsx(T,{})]})})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function wd(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(ke,{}),e.jsx(_d,{})]})}const Cd=()=>e.jsx(dc,{children:e.jsx(wa,{})}),Sd=Ml([{path:"/sign-in",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ud);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Cd,{}),children:[{path:"/",lazy:async()=>({Component:(await me(()=>Promise.resolve().then(()=>Xd),void 0,import.meta.url)).default}),errorElement:e.jsx(Ys,{}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>vu);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ys,{}),children:[{path:"system",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>_u);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>ku);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ru);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ou);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Hu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Gu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>am);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>om);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>xm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(wd,{})}]},{path:"payment",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>_m);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Sm);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Om);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Km);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>yx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Sx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Rx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ys,{}),children:[{path:"plan",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>$x);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>sh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>dh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ah);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>lp);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ys},{path:"/404",Component:en},{path:"/503",Component:ac},{path:"*",Component:en}]);function kd(){return I.get("/user/info")}const na={token:ft()?.value||"",userInfo:null,isLoggedIn:!!ft()?.value,loading:!1,error:null},mt=Fl("user/fetchUserInfo",async()=>(await kd()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),kr=Ol({name:"user",initialState:na,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>na},extraReducers:s=>{s.addCase(mt.pending,n=>{n.loading=!0,n.error=null}).addCase(mt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(mt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return na})}}),{setToken:Td,resetUserState:Dd}=kr.actions,Pd=s=>s.user.userInfo,Ed=kr.reducer,Tr=Ll({reducer:{user:Ed}});ft()?.value&&Tr.dispatch(mt());zl.use(Al).use($l).init({resources:{"en-US":window.XBOARD_TRANSLATIONS?.["en-US"]||{},"zh-CN":window.XBOARD_TRANSLATIONS?.["zh-CN"]||{},"ko-KR":window.XBOARD_TRANSLATIONS?.["ko-KR"]||{}},fallbackLng:"zh-CN",supportedLngs:["en-US","zh-CN","ko-KR"],detection:{order:["querystring","localStorage","navigator"],lookupQuerystring:"lang",lookupLocalStorage:"i18nextLng",caches:["localStorage"]},interpolation:{escapeValue:!1}});const Rd=new Hl;Ul.createRoot(document.getElementById("root")).render(e.jsx(ql.StrictMode,{children:e.jsx(Kl,{client:Rd,children:e.jsx(Bl,{store:Tr,children:e.jsxs(Zo,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Gl,{router:Sd}),e.jsx(Wl,{richColors:!0,position:"top-right"})]})})})}));const We=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));We.displayName="Card";const es=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex flex-col space-y-1.5 p-6",s),...n}));es.displayName="CardHeader";const Cs=u.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:N("font-semibold leading-none tracking-tight",s),...n}));Cs.displayName="CardTitle";const et=u.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:N("text-sm text-muted-foreground",s),...n}));et.displayName="CardDescription";const ss=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("p-6 pt-0",s),...n}));ss.displayName="CardContent";const Id=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex items-center p-6 pt-0",s),...n}));Id.displayName="CardFooter";const D=u.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));D.displayName="Input";const Dr=u.forwardRef(({className:s,...n},t)=>{const[r,a]=u.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}),e.jsx(P,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>a(i=>!i),children:r?e.jsx(Yl,{size:18}):e.jsx(Ql,{size:18})})]})});Dr.displayName="PasswordInput";const Vd=s=>I({url:"/passport/auth/login",method:"post",data:s});function Md({className:s,onForgotPassword:n,...t}){const r=Ts(),a=yn(),{t:i}=V("auth"),l=x.object({email:x.string().min(1,{message:i("signIn.validation.emailRequired")}),password:x.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=fe({resolver:be(l),defaultValues:{email:"",password:""}});async function m(o){try{const{data:c}=await Vd(o);jc(c.auth_data),a(Td(c.auth_data)),await a(mt()).unwrap(),r("/")}catch(c){console.error("Login failed:",c),c.response?.data?.message&&d.setError("root",{message:c.response.data.message})}}return e.jsx("div",{className:N("grid gap-6",s),...t,children:e.jsx(ye,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(m),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[d.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:d.formState.errors.root.message}),e.jsx(g,{control:d.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.email")}),e.jsx(y,{children:e.jsx(D,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"password",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.password")}),e.jsx(y,{children:e.jsx(Dr,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(T,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(P,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const _e=Nn,Je=_n,Fd=wn,yt=Ca,Pr=u.forwardRef(({className:s,...n},t)=>e.jsx(zt,{ref:t,className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));Pr.displayName=zt.displayName;const ve=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Fd,{children:[e.jsx(Pr,{}),e.jsxs(At,{ref:r,className:N("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...t,children:[n,e.jsxs(Ca,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ve.displayName=At.displayName;const Se=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});Se.displayName="DialogHeader";const Ke=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ke.displayName="DialogFooter";const we=u.forwardRef(({className:s,...n},t)=>e.jsx($t,{ref:t,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));we.displayName=$t.displayName;const Pe=u.forwardRef(({className:s,...n},t)=>e.jsx(Ht,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Pe.displayName=Ht.displayName;const st=zs("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?Na:"button";return e.jsx(l,{className:N(st({variant:n,size:t,className:s})),ref:i,...a})});J.displayName="Button";const Ss=Zl,ks=ei,Od=si,Ld=u.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Cn,{ref:a,className:N("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...r,children:[t,e.jsx(Sa,{className:"ml-auto h-4 w-4"})]}));Ld.displayName=Cn.displayName;const zd=u.forwardRef(({className:s,...n},t)=>e.jsx(Sn,{ref:t,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));zd.displayName=Sn.displayName;const gs=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Jl,{children:e.jsx(kn,{ref:r,sideOffset:n,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));gs.displayName=kn.displayName;const ge=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Tn,{ref:r,className:N("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...t}));ge.displayName=Tn.displayName;const Ad=u.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Dn,{ref:a,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx(As,{className:"h-4 w-4"})})}),n]}));Ad.displayName=Dn.displayName;const $d=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(En,{ref:r,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx(Xl,{className:"h-4 w-4 fill-current"})})}),n]}));$d.displayName=En.displayName;const Ra=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Rn,{ref:r,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ra.displayName=Rn.displayName;const tt=u.forwardRef(({className:s,...n},t)=>e.jsx(In,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));tt.displayName=In.displayName;const va=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});va.displayName="DropdownMenuShortcut";const ra=[{code:"en-US",name:"English",flag:ti,shortName:"EN"},{code:"zh-CN",name:"中文",flag:ai,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:ni,shortName:"KR"}];function Er(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=ra.find(a=>a.code===s.language)||ra[1],r=t.flag;return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(r,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:t.shortName})]})}),e.jsx(gs,{align:"end",className:"w-[120px]",children:ra.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(ge,{onClick:()=>n(a.code),className:N("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(i,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:N("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function Hd(){const[s,n]=u.useState(!1),{t}=V("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:[e.jsx("div",{className:"absolute right-4 top-4 md:right-8 md:top-8",children:e.jsx(Er,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[480px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(We,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(Md,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(_e,{open:s,onOpenChange:n,children:e.jsx(ve,{children:e.jsxs(Se,{children:[e.jsx(we,{children:t("signIn.resetPassword.title")}),e.jsx(Pe,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Ft(r).then(()=>{$.success(t("common:copy.success"))}),children:e.jsx(ri,{className:"h-4 w-4"})})]})})]})})})]})}const Ud=Object.freeze(Object.defineProperty({__proto__:null,default:Hd},Symbol.toStringTag,{value:"Module"})),Ee=u.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:N("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",t&&"md:h-svh",s),...r}));Ee.displayName="Layout";const Re=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Re.displayName="LayoutHeader";const Fe=u.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Fe.displayName="LayoutBody";const Rr=li,Ir=ii,Vr=oi,je=ci,he=di,pe=ui,ce=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Vn,{ref:r,sideOffset:n,className:N("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t}));ce.displayName=Vn.displayName;function Wt(){const{pathname:s}=_a();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function Mr({key:s,defaultValue:n}){const[t,r]=u.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return u.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function qd(){const[s,n]=Mr({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(i=>i!==a))}}}function Kd({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const m=`${a(d.title)}-${d.href}`;return n&&l?u.createElement(Wd,{...d,sub:l,key:m,closeNav:r}):n?u.createElement(Gd,{...d,key:m,closeNav:r}):l?u.createElement(Bd,{...d,sub:l,key:m,closeNav:r}):u.createElement(Fr,{...d,key:m,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:N("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",t),children:e.jsx(je,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(i)})})})}function Fr({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Wt(),{t:d}=V();return e.jsxs($s,{to:r,onClick:a,className:N(rt({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",i&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":l(r)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),d(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:d(t)})]})}function Bd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{isExpanded:l,toggleItem:d}=qd(),{t:m}=V(),o=!!r?.find(_=>i(_.href)),c=m(s),h=l(c)||o;return e.jsxs(Rr,{open:h,onOpenChange:()=>d(c),children:[e.jsxs(Ir,{className:N(rt({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),m(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:m(t)}),e.jsx("span",{className:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Mn,{stroke:1})})]}),e.jsx(Vr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(_=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Fr,{..._,subLink:!0,closeNav:a})},m(_.title)))})})]})}function Gd({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V();return e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsxs($s,{to:r,onClick:a,className:N(rt({variant:i(r)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:l(s)})]})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s),t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)})]})]})}function Wd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V(),d=!!r?.find(m=>i(m.href));return e.jsxs(Ss,{children:[e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Mn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(gs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ra,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(tt,{}),r.map(({title:m,icon:o,label:c,href:h})=>e.jsx(ge,{asChild:!0,children:e.jsxs($s,{to:h,onClick:a,className:`${i(h)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(m)}),c&&e.jsx("span",{className:"ml-auto text-xs",children:l(c)})]})},`${l(m)}-${h}`))]})]})}const Or=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(mi,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(xi,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(Fn,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(ka,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(hi,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(pi,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Ba,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(fi,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(On,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(gi,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Ln,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(ji,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(vi,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(bi,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Ba,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(yi,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Ni,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(_i,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(zn,{size:18})}]}];function Yd({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=u.useState(!1),{t:i}=V();return u.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:N(`fixed left-0 right-0 top-0 z-50 flex h-auto flex-col border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>a(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${r?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(Ee,{className:"flex h-full flex-col",children:[e.jsxs(Re,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(wi,{}):e.jsx(Ci,{})})]}),e.jsx(Kd,{id:"sidebar-menu",className:N("flex-1 overflow-auto",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:Or}),e.jsx("div",{className:N("border-t border-border/50 bg-background","px-4 py-2.5 text-xs text-muted-foreground",r?"block":"hidden md:block",n?"text-center":"text-left"),children:e.jsxs("div",{className:N("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:N("tracking-wide whitespace-nowrap","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(P,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(Si,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Qd(){const[s,n]=Mr({key:"collapsed-sidebar",defaultValue:!1});return u.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function Jd(){const[s,n]=Qd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Yd,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(wa,{})})]})}const Xd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"})),Ms=u.forwardRef(({className:s,...n},t)=>e.jsx(Le,{ref:t,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ms.displayName=Le.displayName;const Zd=({children:s,...n})=>e.jsx(_e,{...n,children:e.jsx(ve,{className:"overflow-hidden p-0",children:e.jsx(Ms,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),qs=u.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ki,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Le.Input,{ref:t,className:N("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));qs.displayName=Le.Input.displayName;const Fs=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.List,{ref:t,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Fs.displayName=Le.List.displayName;const Ks=u.forwardRef((s,n)=>e.jsx(Le.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ks.displayName=Le.Empty.displayName;const Ye=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Group,{ref:t,className:N("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Ye.displayName=Le.Group.displayName;const lt=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Separator,{ref:t,className:N("-mx-1 h-px bg-border",s),...n}));lt.displayName=Le.Separator.displayName;const Me=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Item,{ref:t,className:N("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Me.displayName=Le.Item.displayName;function eu(){const s=[];for(const n of Or)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function Be(){const[s,n]=u.useState(!1),t=Ts(),r=eu(),{t:a}=V("search"),{t:i}=V("nav");u.useEffect(()=>{const d=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=u.useCallback(d=>{n(!1),t(d)},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(An,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:a("placeholder")}),e.jsx("span",{className:"sr-only",children:a("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:a("shortcut.key")})]}),e.jsxs(Zd,{open:s,onOpenChange:n,children:[e.jsx(qs,{placeholder:a("placeholder")}),e.jsxs(Fs,{children:[e.jsx(Ks,{children:a("noResults")}),e.jsx(Ye,{heading:a("title"),children:r.map(d=>e.jsxs(Me,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}function ze(){const{theme:s,setTheme:n}=ec();return u.useEffect(()=>{const t=s==="dark"?"#020817":"#fff",r=document.querySelector("meta[name='theme-color']");r&&r.setAttribute("content",t)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(P,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(Ti,{size:20}):e.jsx(Di,{size:20})}),e.jsx(Er,{})]})}const Lr=u.forwardRef(({className:s,...n},t)=>e.jsx($n,{ref:t,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));Lr.displayName=$n.displayName;const zr=u.forwardRef(({className:s,...n},t)=>e.jsx(Hn,{ref:t,className:N("aspect-square h-full w-full",s),...n}));zr.displayName=Hn.displayName;const Ar=u.forwardRef(({className:s,...n},t)=>e.jsx(Un,{ref:t,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));Ar.displayName=Un.displayName;function Ae(){const s=Ts(),n=yn(),t=Pi(Pd),{t:r}=V(["common"]),a=()=>{yr(),n(Dd()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(Lr,{className:"h-8 w-8",children:[e.jsx(zr,{src:t?.avatar_url,alt:i}),e.jsx(Ar,{children:l})]})})}),e.jsxs(gs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ra,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:i}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(tt,{}),e.jsx(ge,{asChild:!0,children:e.jsxs($s,{to:"/config/system",children:[r("common:settings"),e.jsx(va,{children:"⌘S"})]})}),e.jsx(tt,{}),e.jsxs(ge,{onClick:a,children:[r("common:logout"),e.jsx(va,{children:"⇧⌘Q"})]})]})]})}const G=Ei,He=zi,W=Ri,K=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(qn,{ref:r,className:N("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[n,e.jsx(Ii,{asChild:!0,children:e.jsx(Ta,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=qn.displayName;const $r=u.forwardRef(({className:s,...n},t)=>e.jsx(Kn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Vi,{className:"h-4 w-4"})}));$r.displayName=Kn.displayName;const Hr=u.forwardRef(({className:s,...n},t)=>e.jsx(Bn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Ta,{className:"h-4 w-4"})}));Hr.displayName=Bn.displayName;const B=u.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(Mi,{children:e.jsxs(Gn,{ref:a,className:N("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:t,...r,children:[e.jsx($r,{}),e.jsx(Fi,{className:N("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Hr,{})]})}));B.displayName=Gn.displayName;const su=u.forwardRef(({className:s,...n},t)=>e.jsx(Wn,{ref:t,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));su.displayName=Wn.displayName;const z=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Yn,{ref:r,className:N("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Oi,{children:e.jsx(As,{className:"h-4 w-4"})})}),e.jsx(Li,{children:n})]}));z.displayName=Yn.displayName;const tu=u.forwardRef(({className:s,...n},t)=>e.jsx(Qn,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));tu.displayName=Qn.displayName;function Bs({className:s,classNames:n,showOutsideDays:t=!0,...r}){return e.jsx(Ai,{showOutsideDays:t,className:N("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:N(st({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:N("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:N(st({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:a,...i})=>e.jsx(Jn,{className:N("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(Sa,{className:N("h-4 w-4",a),...i})},...r})}Bs.displayName="Calendar";const bs=Hi,ys=Ui,xs=u.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx($i,{children:e.jsx(Xn,{ref:a,align:n,sideOffset:t,className:N("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})}));xs.displayName=Xn.displayName;const Es={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},dt=s=>(s/100).toFixed(2),au=({active:s,payload:n,label:t})=>{const{t:r}=V();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:t}),n.map((a,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[r(a.name),":"]}),e.jsx("span",{className:"font-medium",children:a.name.includes(r("dashboard:overview.amount"))?`¥${dt(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},nu=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],ru=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=ls(t,7);break;case"30d":r=ls(t,30);break;case"90d":r=ls(t,90);break;case"180d":r=ls(t,180);break;case"365d":r=ls(t,365);break;default:r=ls(t,30)}return{startDate:r,endDate:t}};function lu(){const[s,n]=u.useState("amount"),[t,r]=u.useState("30d"),[a,i]=u.useState({from:ls(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:m}=ru(t,a),{data:o}=ie({queryKey:["orderStat",{start_date:rs(d,"yyyy-MM-dd"),end_date:rs(m,"yyyy-MM-dd")}],queryFn:async()=>{const{data:c}=await vc({start_date:rs(d,"yyyy-MM-dd"),end_date:rs(m,"yyyy-MM-dd")});return c},refetchInterval:3e4});return e.jsxs(We,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Cs,{children:l("dashboard:overview.title")}),e.jsxs(et,{children:[o?.summary.start_date," ",l("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(G,{value:t,onValueChange:c=>r(c),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:nu.map(c=>e.jsx(z,{value:c.value,children:l(c.label)},c.value))})]}),t==="custom"&&e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a?.from?a.to?e.jsxs(e.Fragment,{children:[rs(a.from,"yyyy-MM-dd")," -"," ",rs(a.to,"yyyy-MM-dd")]}):rs(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Bs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:c=>{c?.from&&c?.to&&i({from:c.from,to:c.to})},numberOfMonths:2})})]})]}),e.jsx(Gt,{value:s,onValueChange:c=>n(c),children:e.jsxs(vt,{children:[e.jsx(qe,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(qe,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(ss,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",dt(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(qi,{width:"100%",height:"100%",children:e.jsxs(Ki,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Bi,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>rs(new Date(c),"MM-dd",{locale:Qi})}),e.jsx(Gi,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>s==="amount"?`¥${dt(c)}`:l("dashboard:overview.transactions",{count:c})}),e.jsx(Wi,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Yi,{content:e.jsx(au,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ga,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Es.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ga,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Es.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Es.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Wa,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Es.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function oe({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function iu(){return e.jsxs(We,{children:[e.jsxs(es,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(oe,{className:"h-4 w-[120px]"}),e.jsx(oe,{className:"h-4 w-4"})]}),e.jsxs(ss,{children:[e.jsx(oe,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(oe,{className:"h-4 w-[100px]"})]})]})]})}function ou(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:8}).map((s,n)=>e.jsx(iu,{},n))})}var ae=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(ae||{});const ot={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},ct={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var is=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(is||{}),xe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(xe||{});const Nt={0:"待确认",1:"发放中",2:"有效",3:"无效"},_t={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var De=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(De||{});const cu={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var re=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s.Tuic="tuic",s.Socks="socks",s.Naive="naive",s.Http="http",s.Mieru="mieru",s))(re||{});const Xe=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"},{type:"tuic",label:"TUIC"},{type:"socks",label:"SOCKS"},{type:"naive",label:"Naive"},{type:"http",label:"HTTP"},{type:"mieru",label:"Mieru"}],Ue={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50"};var Ge=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Ge||{});const du={1:"按金额优惠",2:"按比例优惠"};var Vs=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Vs||{}),Oe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Oe||{}),xt=(s=>(s.MONTH="monthly",s.QUARTER="quarterly",s.HALF_YEAR="half_yearly",s.YEAR="yearly",s.TWO_YEAR="two_yearly",s.THREE_YEAR="three_yearly",s.ONETIME="onetime",s.RESET="reset_traffic",s))(xt||{});function Rs({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(We,{className:N("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(es,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Cs,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(ss,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(to,{className:N("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("ml-1 text-xs",r.isPositive?"text-emerald-500":"text-red-500"),children:[r.isPositive?"+":"-",Math.abs(r.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function uu({className:s}){const n=Ts(),{t}=V(),{data:r,isLoading:a}=ie({queryKey:["dashboardStats"],queryFn:async()=>(await bc()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(ou,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",xe.PENDING.toString()),l.set("status",ae.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Rs,{title:t("dashboard:stats.todayIncome"),value:Ls(r.todayIncome),icon:e.jsx(Ji,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.monthlyIncome"),value:Ls(r.currentMonthIncome),icon:e.jsx(Xi,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(Zi,{className:N("h-4 w-4",r.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:r.ticketPendingTotal>0?t("dashboard:stats.hasPendingTickets"):t("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:r.ticketPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(eo,{className:N("h-4 w-4",r.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:r.commissionPendingTotal>0?t("dashboard:stats.hasPendingCommission"):t("dashboard:stats.noPendingCommission"),onClick:i,highlight:r.commissionPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyUpload"),value:fs(r.monthTraffic.upload),icon:e.jsx(pt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:fs(r.todayTraffic.upload)})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyDownload"),value:fs(r.monthTraffic.download),icon:e.jsx(so,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:fs(r.todayTraffic.download)})})]})}const at=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Zn,{ref:r,className:N("relative overflow-hidden",s),...t,children:[e.jsx(ao,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ot,{}),e.jsx(no,{})]}));at.displayName=Zn.displayName;const Ot=u.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(er,{ref:r,orientation:n,className:N("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:e.jsx(ro,{className:"relative flex-1 rounded-full bg-border"})}));Ot.displayName=er.displayName;const ba={today:{getValue:()=>{const s=io();return{start:s,end:oo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:ls(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:ls(s,30),end:s}}},custom:{getValue:()=>null}};function nn({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=V(),i={today:a("dashboard:trafficRank.today"),last7days:a("dashboard:trafficRank.last7days"),last30days:a("dashboard:trafficRank.last30days"),custom:a("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(G,{value:s,onValueChange:t,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(ba).map(([l])=>e.jsx(z,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[rs(n.from,"yyyy-MM-dd")," -"," ",rs(n.to,"yyyy-MM-dd")]}):rs(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Bs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:l=>{l?.from&&l?.to&&r({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const Qs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function mu({className:s}){const{t:n}=V(),[t,r]=u.useState("today"),[a,i]=u.useState({from:ls(new Date,7),to:new Date}),[l,d]=u.useState("today"),[m,o]=u.useState({from:ls(new Date,7),to:new Date}),c=u.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:ba[t].getValue(),[t,a]),h=u.useMemo(()=>l==="custom"?{start:m.from,end:m.to}:ba[l].getValue(),[l,m]),{data:_}=ie({queryKey:["nodeTrafficRank",c.start,c.end],queryFn:()=>tn({type:"node",start_time:Ce.round(c.start.getTime()/1e3),end_time:Ce.round(c.end.getTime()/1e3)}),refetchInterval:3e4}),{data:E}=ie({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>tn({type:"user",start_time:Ce.round(h.start.getTime()/1e3),end_time:Ce.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(We,{children:[e.jsx(es,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(lo,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(nn,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ss,{className:"flex-1",children:_?.data?e.jsxs(at,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:_.data.map(C=>e.jsx(je,{delayDuration:200,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/_.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Ot,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(We,{children:[e.jsx(es,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(ha,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(nn,{selectedRange:l,customDateRange:m,onRangeChange:d,onCustomRangeChange:o}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ss,{className:"flex-1",children:E?.data?e.jsxs(at,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:E.data.map(C=>e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/E.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Ot,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const xu=zs("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function q({className:s,variant:n,...t}){return e.jsx("div",{className:N(xu({variant:n}),s),...t})}const le=window?.settings?.secure_path,Ur=5*60*1e3,ya=new Map,hu=s=>{const n=ya.get(s);return n?Date.now()-n.timestamp>Ur?(ya.delete(s),null):n.data:null},pu=(s,n)=>{ya.set(s,{data:n,timestamp:Date.now()})},fu=async(s,n=Ur)=>{const t=hu(s);if(t)return t;const r=await I.get(s);return pu(s,r),r},Lt={getList:s=>I.post(`${le}/user/fetch`,s),update:s=>I.post(`${le}/user/update`,s),resetSecret:s=>I.post(`${le}/user/resetSecret`,{id:s}),generate:s=>I.post(`${le}/user/generate`,s),getStats:s=>I.post(`${le}/stat/getStatUser`,s),destroy:s=>I.post(`${le}/user/destroy`,{id:s}),sendMail:s=>I.post(`${le}/user/sendMail`,s),dumpCSV:s=>I.post(`${le}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>I.post(`${le}/user/ban`,s)},rn={getList:()=>fu(`${le}/notice/fetch`),save:s=>I.post(`${le}/notice/save`,s),drop:s=>I.post(`${le}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${le}/notice/show`,{id:s}),sort:s=>I.post(`${le}/notice/sort`,{ids:s})},la={getList:s=>I.post(`${le}/ticket/fetch`,s),getInfo:s=>I.get(`${le}/ticket/fetch?id=${s}`),reply:s=>I.post(`${le}/ticket/reply`,s),close:s=>I.post(`${le}/ticket/close`,{id:s})},ln={getSystemStatus:()=>I.get(`${le}/system/getSystemStatus`),getQueueStats:()=>I.get(`${le}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${le}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${le}/system/getQueueMasters`),getSystemLog:s=>I.get(`${le}/system/getSystemLog`,{params:s})},ws={getPluginList:()=>I.get(`${le}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),I.post(`${le}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>I.post(`${le}/plugin/delete`,{code:s}),installPlugin:s=>I.post(`${le}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${le}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${le}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${le}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${le}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${le}/plugin/config`,{code:s,config:n})},Dt=u.forwardRef(({className:s,value:n,...t},r)=>e.jsx(sr,{ref:r,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(co,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Dt.displayName=sr.displayName;function gu(){const{t:s}=V(),[n,t]=u.useState(null),[r,a]=u.useState(null),[i,l]=u.useState(!0),[d,m]=u.useState(!1),o=async()=>{try{m(!0);const[_,E]=await Promise.all([ln.getSystemStatus(),ln.getQueueStats()]);t(_.data),a(E.data)}catch(_){console.error("Error fetching system data:",_)}finally{l(!1),m(!1)}};u.useEffect(()=>{o();const _=setInterval(o,3e4);return()=>clearInterval(_)},[]);const c=()=>{o()};if(i)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})});const h=_=>_?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(We,{children:[e.jsxs(es,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(et,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:c,disabled:d,children:e.jsx(mo,{className:N("h-4 w-4",d&&"animate-spin")})})]}),e.jsx(ss,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h(r?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(q,{variant:r?.status?"secondary":"destructive",children:r?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:r?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.recentJobs||0}),e.jsx(Dt,{value:(r?.recentJobs||0)/(r?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:r?.periods?.recentJobs||0})})})]})}),e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.jobsPerMinute||0}),e.jsx(Dt,{value:(r?.jobsPerMinute||0)/(r?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:r?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(We,{children:[e.jsxs(es,{children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(et,{children:s("dashboard:queue.details.description")})]}),e.jsx(ss,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:r?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:r?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[r?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:r?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[r?.processes||0," /"," ",(r?.processes||0)+(r?.pausedMasters||0)]})]}),e.jsx(Dt,{value:(r?.processes||0)/((r?.processes||0)+(r?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function ju(){const{t:s}=V();return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Be,{}),e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(uu,{}),e.jsx(lu,{}),e.jsx(mu,{}),e.jsx(gu,{})]})})})]})}const vu=Object.freeze(Object.defineProperty({__proto__:null,default:ju},Symbol.toStringTag,{value:"Module"}));function bu({className:s,items:n,...t}){const{pathname:r}=_a(),a=Ts(),[i,l]=u.useState(r??"/settings"),d=o=>{l(o),a(o)},{t:m}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(G,{value:i,onValueChange:d,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(W,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(z,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:m(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:N("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(o=>e.jsxs($s,{to:o.href,className:N(rt({variant:"ghost"}),r===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),m(o.title)]},o.href))})})]})}const yu=[{title:"site.title",key:"site",icon:e.jsx(ho,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Ln,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(zn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(po,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(On,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(fo,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(go,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Fn,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(jo,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Nu(){const{t:s}=V("settings");return e.jsxs(Ee,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Re,{children:[e.jsx(Be,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(ke,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(bu,{items:yu})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(wa,{})})})]})]})]})}const _u=Object.freeze(Object.defineProperty({__proto__:null,default:Nu},Symbol.toStringTag,{value:"Module"})),Y=u.forwardRef(({className:s,...n},t)=>e.jsx(nr,{className:N("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:t,children:e.jsx(vo,{className:N("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Y.displayName=nr.displayName;const Ns=u.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:N("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}));Ns.displayName="Textarea";const wu=x.object({logo:x.string().nullable().default(""),force_https:x.number().nullable().default(0),stop_register:x.number().nullable().default(0),app_name:x.string().nullable().default(""),app_description:x.string().nullable().default(""),app_url:x.string().nullable().default(""),subscribe_url:x.string().nullable().default(""),try_out_plan_id:x.number().nullable().default(0),try_out_hour:x.coerce.number().nullable().default(0),tos_url:x.string().nullable().default(""),currency:x.string().nullable().default(""),currency_symbol:x.string().nullable().default("")});function Cu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),{data:a}=ie({queryKey:["settings","site"],queryFn:()=>js("site")}),{data:i}=ie({queryKey:["plans"],queryFn:()=>Us()}),l=fe({resolver:be(wu),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=os({mutationFn:vs,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(a?.data?.site){const c=a?.data?.site;Object.entries(c).forEach(([h,_])=>{l.setValue(h,_)}),r.current=c}},[a]);const m=u.useCallback(Ce.debounce(async c=>{if(!Ce.isEqual(c,r.current)){t(!0);try{const h=Object.entries(c).reduce((_,[E,C])=>(_[E]=C===null?"":C,_),{});await d(h),r.current=c}finally{t(!1)}}},1e3),[d]),o=u.useCallback(c=>{m(c)},[m]);return u.useEffect(()=>{const c=l.watch(h=>{o(h)});return()=>c.unsubscribe()},[l.watch,o]),e.jsx(ye,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:l.control,name:"app_name",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"app_description",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"app_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"force_https",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"logo",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"subscribe_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(y,{children:e.jsx(Ns,{placeholder:s("site.form.subscribeUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"tos_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"stop_register",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"try_out_plan_id",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(y,{children:e.jsxs(G,{value:c.value?.toString(),onValueChange:h=>{c.onChange(Number(h)),o(l.getValues())},children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(h=>e.jsx(z,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(T,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(g,{control:l.control,name:"try_out_hour",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"currency",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"currency_symbol",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(T,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Su(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(ke,{}),e.jsx(Cu,{})]})}const ku=Object.freeze(Object.defineProperty({__proto__:null,default:Su},Symbol.toStringTag,{value:"Module"})),Tu=x.object({email_verify:x.boolean().nullable(),safe_mode_enable:x.boolean().nullable(),secure_path:x.string().nullable(),email_whitelist_enable:x.boolean().nullable(),email_whitelist_suffix:x.array(x.string().nullable()).nullable(),email_gmail_limit_enable:x.boolean().nullable(),recaptcha_enable:x.boolean().nullable(),recaptcha_key:x.string().nullable(),recaptcha_site_key:x.string().nullable(),register_limit_by_ip_enable:x.boolean().nullable(),register_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:x.boolean().nullable(),password_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable()}),Du={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,recaptcha_enable:!1,recaptcha_key:"",recaptcha_site_key:"",register_limit_by_ip_enable:!1,register_limit_count:"",register_limit_expire:"",password_limit_enable:!1,password_limit_count:"",password_limit_expire:""};function Pu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(Tu),defaultValues:Du,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","safe"],queryFn:()=>js("safe")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data.safe){const o=i.data.safe;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Ce.debounce(async o=>{if(!Ce.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(ye,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"email_verify",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"secure_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("email_whitelist_enable")&&e.jsx(g,{control:a.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(y,{children:e.jsx(Ns,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` +import{r as u,j as e,t as Sl,c as kl,I as Ka,a as zs,S as Na,u as Ts,b as Tl,d as _a,R as fn,e as gn,f as Dl,F as Pl,C as El,L as jn,T as vn,g as bn,h as Rl,i as Il,k as Vl,l as $,z as x,m as V,n as fe,o as be,p as ie,q as os,s as Ce,v as Ws,w as Ml,O as wa,x as Fl,y as Ol,A as Ll,B as zl,D as Al,E as $l,Q as Hl,G as Ul,H as ql,J as Kl,P as Bl,K as Gl,M as Wl,N as Yl,U as Ql,V as yn,W as Nn,X as zt,Y as At,Z as Ca,_ as Ze,$ as $t,a0 as Ht,a1 as _n,a2 as wn,a3 as Cn,a4 as Sa,a5 as Sn,a6 as Jl,a7 as kn,a8 as Tn,a9 as Dn,aa as Pn,ab as As,ac as En,ad as Xl,ae as Rn,af as In,ag as Zl,ah as ei,ai as si,aj as ti,ak as ai,al as ni,am as ri,an as li,ao as ii,ap as oi,aq as ci,ar as Vn,as as di,at as ui,au as $s,av as Mn,aw as mi,ax as xi,ay as Fn,az as ka,aA as hi,aB as pi,aC as Ba,aD as fi,aE as On,aF as gi,aG as Ln,aH as ji,aI as vi,aJ as bi,aK as yi,aL as Ni,aM as _i,aN as zn,aO as wi,aP as Ci,aQ as Si,aR as Le,aS as ki,aT as An,aU as Ti,aV as Di,aW as $n,aX as Hn,aY as Un,aZ as Pi,a_ as Ei,a$ as Ri,b0 as qn,b1 as Ii,b2 as Ta,b3 as Kn,b4 as Vi,b5 as Bn,b6 as Mi,b7 as Gn,b8 as Fi,b9 as Wn,ba as Yn,bb as Oi,bc as Li,bd as Qn,be as zi,bf as Ai,bg as Jn,bh as $i,bi as Xn,bj as Hi,bk as Ui,bl as ls,bm as rs,bn as jt,bo as qi,bp as Ki,bq as Bi,br as Gi,bs as Wi,bt as Yi,bu as Ga,bv as Wa,bw as Qi,bx as Ji,by as Xi,bz as Zi,bA as eo,bB as ha,bC as pt,bD as so,bE as to,bF as Zn,bG as ao,bH as no,bI as er,bJ as ro,bK as lo,bL as Ya,bM as pa,bN as fa,bO as io,bP as oo,bQ as sr,bR as co,bS as Da,bT as uo,bU as mo,bV as xo,bW as tr,bX as ar,bY as ho,bZ as po,b_ as fo,b$ as go,c0 as jo,c1 as nr,c2 as vo,c3 as bo,c4 as yo,c5 as No,c6 as Rt,c7 as Ve,c8 as Qa,c9 as _o,ca as rr,cb as lr,cc as ir,cd as or,ce as cr,cf as dr,cg as wo,ch as Co,ci as So,cj as Ut,ck as Hs,cl as cs,cm as ts,cn as as,co as ds,cp as us,cq as ms,cr as ko,cs as To,ct as Do,cu as Po,cv as Eo,cw as Ro,cx as Io,cy as Vo,cz as Mo,cA as ga,cB as Pa,cC as Ea,cD as Fo,cE as Ds,cF as Ps,cG as qt,cH as Oo,cI as It,cJ as Lo,cK as Ja,cL as ur,cM as Xa,cN as Vt,cO as zo,cP as Ao,cQ as $o,cR as Ho,cS as mr,cT as Uo,cU as qo,cV as xr,cW as ja,cX as hr,cY as Ko,cZ as pr,c_ as fr,c$ as Bo,d0 as Go,d1 as Wo,d2 as Yo,d3 as Qo}from"./vendor.js";import"./index.js";var cp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Jo(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var t=function r(){return this instanceof r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return s[r]}})}),t}const Xo={theme:"system",setTheme:()=>null},gr=u.createContext(Xo);function Zo({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=u.useState(()=>localStorage.getItem(t)||n);u.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const m=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(m);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(gr.Provider,{...r,value:l,children:s})}const ec=()=>{const s=u.useContext(gr);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},sc=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),tc=function(s,n){return new URL(s,n).href},Za={},me=function(n,t,r){let a=Promise.resolve();if(t&&t.length>0){const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(o=>{if(o=tc(o,r),o in Za)return;Za[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(!!r)for(let C=l.length-1;C>=0;C--){const S=l[C];if(S.href===o&&(!c||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const E=document.createElement("link");if(E.rel=c?"stylesheet":sc,c||(E.as="script"),E.crossOrigin="",E.href=o,m&&E.setAttribute("nonce",m),document.head.appendChild(E),c)return new Promise((C,S)=>{E.addEventListener("load",C),E.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function N(...s){return Sl(kl(s))}const rt=zs("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),P=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:m,...o},c)=>{const h=r?Na:"button";return e.jsxs(h,{className:N(rt({variant:n,size:t,className:s})),disabled:l||i,ref:c,...o,children:[(d&&l||!d&&!m&&l)&&e.jsx(Ka,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&m&&e.jsx("div",{className:"ml-2",children:m}),m&&l&&e.jsx(Ka,{className:"ml-2 h-4 w-4 animate-spin"})]})});P.displayName="Button";function Ys({className:s,minimal:n=!1}){const t=Ts(),r=Tl(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:N("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{}),a]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function en(){const s=Ts();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function ac(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(P,{variant:"outline",children:"Learn more"})})]})})}function nc(s){return typeof s>"u"}function rc(s){return s===null}function lc(s){return rc(s)||nc(s)}class ic{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,t,r=null){const a=JSON.stringify({value:t,time:Date.now(),expire:r!==null?new Date().getTime()+r*1e3:null});this.storage.setItem(this.getKey(n),a)}get(n,t=null){const r=this.storage.getItem(this.getKey(n));if(!r)return{value:t,time:0};try{const a=JSON.parse(r),{value:i,time:l,expire:d}=a;return lc(d)||d>new Date().getTime()?{value:i,time:l}:(this.remove(n),{value:t,time:0})}catch{return this.remove(n),{value:t,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function jr({prefixKey:s="",storage:n=sessionStorage}){return new ic({prefixKey:s,storage:n})}const vr="Xboard_",oc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:localStorage})},cc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:sessionStorage})},Kt=oc({prefixKey:vr});cc({prefixKey:vr});const br="access_token";function ft(){return Kt.get(br)}function yr(){Kt.remove(br)}const sn=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function dc({children:s}){const n=Ts(),t=_a(),r=ft();return u.useEffect(()=>{if(!r.value&&!sn.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),sn.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const ke=u.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(fn,{ref:a,decorative:t,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));ke.displayName=fn.displayName;const uc=zs("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mt=u.forwardRef(({className:s,...n},t)=>e.jsx(gn,{ref:t,className:N(uc(),s),...n}));Mt.displayName=gn.displayName;const ye=Pl,Nr=u.createContext({}),g=({...s})=>e.jsx(Nr.Provider,{value:{name:s.name},children:e.jsx(El,{...s})}),Bt=()=>{const s=u.useContext(Nr),n=u.useContext(_r),{getFieldState:t,formState:r}=Dl(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:i}=n;return{id:i,name:s.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},_r=u.createContext({}),f=u.forwardRef(({className:s,...n},t)=>{const r=u.useId();return e.jsx(_r.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:N("space-y-2",s),...n})})});f.displayName="FormItem";const j=u.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Bt();return e.jsx(Mt,{ref:t,className:N(r&&"text-destructive",s),htmlFor:a,...n})});j.displayName="FormLabel";const y=u.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Bt();return e.jsx(Na,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});y.displayName="FormControl";const F=u.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Bt();return e.jsx("p",{ref:t,id:r,className:N("text-[0.8rem] text-muted-foreground",s),...n})});F.displayName="FormDescription";const T=u.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Bt(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:N("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});T.displayName="FormMessage";const Gt=Rl,vt=u.forwardRef(({className:s,...n},t)=>e.jsx(jn,{ref:t,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));vt.displayName=jn.displayName;const qe=u.forwardRef(({className:s,...n},t)=>e.jsx(vn,{ref:t,className:N("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));qe.displayName=vn.displayName;const ps=u.forwardRef(({className:s,...n},t)=>e.jsx(bn,{ref:t,className:N("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ps.displayName=bn.displayName;function Ne(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Il(s).format(n))}function mc(s=void 0,n="YYYY-MM-DD"){return Ne(s,n)}function Xs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ls(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,i=>i.includes(".")?".00":i);return n?`¥${a}`:a}function Ft(s){return new Promise(n=>{(async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(s);else{const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),!a)throw new Error("execCommand failed")}n(!0)}catch(r){console.error(r),n(!1)}})()})}function fs(s){const n=s/1024,t=n/1024,r=t/1024,a=r/1024;return a>=1?Xs(a)+" TB":r>=1?Xs(r)+" GB":t>=1?Xs(t)+" MB":Xs(n)+" KB"}const xc="locale";function hc(){return Kt.get(xc)}function wr(){yr();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),t=new URL(window.location.href),a=`${t.pathname.split("/")[1]?`/${t.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=a+(n?`?redirect=${s}`:"")}const pc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function fc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const I=Vl.create({baseURL:fc(),timeout:12e3,headers:{"Content-Type":"application/json"}});I.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=ft();if(!pc.includes(s.url?.split("?")[0]||"")){if(!n.value)return wr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=hc().value||"zh-CN",s},s=>Promise.reject(s));I.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,t=s.response?.data?.message;return(n===401||n===403)&&wr(),$.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const gc="access_token";function jc(s){Kt.set(gc,s)}const H=window?.settings?.secure_path,vc=s=>I.get(H+"/stat/getOrder",{params:s}),bc=()=>I.get(H+"/stat/getStats"),tn=s=>I.get(H+"/stat/getTrafficRank",{params:s}),yc=()=>I.get(H+"/theme/getThemes"),Nc=s=>I.post(H+"/theme/getThemeConfig",{name:s}),_c=(s,n)=>I.post(H+"/theme/saveThemeConfig",{name:s,config:n}),wc=s=>{const n=new FormData;return n.append("file",s),I.post(H+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Cc=s=>I.post(H+"/theme/delete",{name:s}),Sc=s=>I.post(H+"/config/save",s),Cr=()=>I.get(H+"/server/manage/getNodes"),kc=s=>I.post(H+"/server/manage/save",s),Tc=s=>I.post(H+"/server/manage/drop",s),Dc=s=>I.post(H+"/server/manage/copy",s),Pc=s=>I.post(H+"/server/manage/update",s),Ec=s=>I.post(H+"/server/manage/sort",s),bt=()=>I.get(H+"/server/group/fetch"),Rc=s=>I.post(H+"/server/group/save",s),Ic=s=>I.post(H+"/server/group/drop",s),Sr=()=>I.get(H+"/server/route/fetch"),Vc=s=>I.post(H+"/server/route/save",s),Mc=s=>I.post(H+"/server/route/drop",s),Fc=()=>I.get(H+"/payment/fetch"),Oc=()=>I.get(H+"/payment/getPaymentMethods"),Lc=s=>I.post(H+"/payment/getPaymentForm",s),zc=s=>I.post(H+"/payment/save",s),Ac=s=>I.post(H+"/payment/drop",s),$c=s=>I.post(H+"/payment/show",s),Hc=s=>I.post(H+"/payment/sort",s),Uc=s=>I.post(H+"/notice/save",s),qc=s=>I.post(H+"/notice/drop",s),Kc=s=>I.post(H+"/notice/show",s),Bc=()=>I.get(H+"/knowledge/fetch"),Gc=s=>I.get(H+"/knowledge/fetch?id="+s),Wc=s=>I.post(H+"/knowledge/save",s),Yc=s=>I.post(H+"/knowledge/drop",s),Qc=s=>I.post(H+"/knowledge/show",s),Jc=s=>I.post(H+"/knowledge/sort",s),Us=()=>I.get(H+"/plan/fetch"),Xc=s=>I.post(H+"/plan/save",s),aa=s=>I.post(H+"/plan/update",s),Zc=s=>I.post(H+"/plan/drop",s),ed=s=>I.post(H+"/plan/sort",{ids:s}),sd=async s=>I.post(H+"/order/fetch",s),td=s=>I.post(H+"/order/detail",s),ad=s=>I.post(H+"/order/paid",s),nd=s=>I.post(H+"/order/cancel",s),an=s=>I.post(H+"/order/update",s),rd=s=>I.post(H+"/order/assign",s),ld=s=>I.post(H+"/coupon/fetch",s),id=s=>I.post(H+"/coupon/generate",s),od=s=>I.post(H+"/coupon/drop",s),cd=s=>I.post(H+"/coupon/update",s),dd=s=>I.post(H+"/user/fetch",s),ud=s=>I.post(H+"/user/update",s),md=s=>I.post(H+"/user/resetSecret",s),xd=s=>I.post(H+"/user/generate",s),hd=s=>I.post(H+"/stat/getStatUser",s),pd=s=>I.post(H+"/ticket/fetch",s),fd=s=>I.get(H+"/ticket/fetch?id= "+s),gd=s=>I.post(H+"/ticket/close",{id:s}),js=(s="")=>I.get(H+"/config/fetch?key="+s),vs=s=>I.post(H+"/config/save",s),jd=()=>I.get(H+"/config/getEmailTemplate"),vd=()=>I.post(H+"/config/testSendMail"),bd=()=>I.post(H+"/config/setTelegramWebhook"),yd=x.object({subscribe_template_singbox:x.string().nullable(),subscribe_template_clash:x.string().nullable(),subscribe_template_clashmeta:x.string().nullable(),subscribe_template_stash:x.string().nullable(),subscribe_template_surge:x.string().nullable(),subscribe_template_surfboard:x.string().nullable()}),Nd={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function _d(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),[a,i]=u.useState("singbox"),l=fe({resolver:be(yd),defaultValues:Nd,mode:"onBlur"}),{data:d}=ie({queryKey:["settings","client"],queryFn:()=>js("subscribe_template")}),{mutateAsync:m}=os({mutationFn:vs,onSuccess:h=>{h.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(d?.data.subscribe_template){const h=d.data.subscribe_template;Object.entries(h).forEach(([_,E])=>{l.setValue(_,E)}),r.current=h}},[d]),console.log(l.getValues());const o=u.useCallback(Ce.debounce(async h=>{if(!Ce.isEqual(h,r.current)){t(!0);try{await m(h),r.current=h}finally{t(!1)}}},1e3),[m]),c=u.useCallback(h=>{o(h)},[o]);return e.jsx(ye,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Gt,{value:a,onValueChange:i,children:[e.jsxs(vt,{children:[e.jsx(qe,{value:"singbox",children:"Sing-box"}),e.jsx(qe,{value:"clash",children:"Clash"}),e.jsx(qe,{value:"clashmeta",children:"Clash Meta"}),e.jsx(qe,{value:"stash",children:"Stash"}),e.jsx(qe,{value:"surge",children:"Surge"}),e.jsx(qe,{value:"surfboard",children:"Surfboard"})]}),e.jsx(ps,{value:"singbox",children:e.jsx(g,{control:l.control,name:"subscribe_template_singbox",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.singbox.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"json",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.singbox.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"clash",children:e.jsx(g,{control:l.control,name:"subscribe_template_clash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clash.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clash.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"clashmeta",children:e.jsx(g,{control:l.control,name:"subscribe_template_clashmeta",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clashmeta.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clashmeta.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"stash",children:e.jsx(g,{control:l.control,name:"subscribe_template_stash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.stash.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.stash.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"surge",children:e.jsx(g,{control:l.control,name:"subscribe_template_surge",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.surge.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"ini",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.surge.description")}),e.jsx(T,{})]})})}),e.jsx(ps,{value:"surfboard",children:e.jsx(g,{control:l.control,name:"subscribe_template_surfboard",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.surfboard.title")}),e.jsx(y,{children:e.jsx(Ws,{height:"500px",defaultLanguage:"ini",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.surfboard.description")}),e.jsx(T,{})]})})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function wd(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(ke,{}),e.jsx(_d,{})]})}const Cd=()=>e.jsx(dc,{children:e.jsx(wa,{})}),Sd=Ml([{path:"/sign-in",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ud);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Cd,{}),children:[{path:"/",lazy:async()=>({Component:(await me(()=>Promise.resolve().then(()=>Xd),void 0,import.meta.url)).default}),errorElement:e.jsx(Ys,{}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>vu);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ys,{}),children:[{path:"system",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>_u);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>ku);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ru);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ou);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Hu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Gu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>am);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>om);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>xm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(wd,{})}]},{path:"payment",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>_m);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Sm);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Om);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Km);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>yx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Sx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Rx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ys,{}),children:[{path:"plan",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>$x);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>sh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>dh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ah);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>lp);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ys},{path:"/404",Component:en},{path:"/503",Component:ac},{path:"*",Component:en}]);function kd(){return I.get("/user/info")}const na={token:ft()?.value||"",userInfo:null,isLoggedIn:!!ft()?.value,loading:!1,error:null},mt=Fl("user/fetchUserInfo",async()=>(await kd()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),kr=Ol({name:"user",initialState:na,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>na},extraReducers:s=>{s.addCase(mt.pending,n=>{n.loading=!0,n.error=null}).addCase(mt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(mt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return na})}}),{setToken:Td,resetUserState:Dd}=kr.actions,Pd=s=>s.user.userInfo,Ed=kr.reducer,Tr=Ll({reducer:{user:Ed}});ft()?.value&&Tr.dispatch(mt());zl.use(Al).use($l).init({resources:{"en-US":window.XBOARD_TRANSLATIONS?.["en-US"]||{},"zh-CN":window.XBOARD_TRANSLATIONS?.["zh-CN"]||{},"ko-KR":window.XBOARD_TRANSLATIONS?.["ko-KR"]||{}},fallbackLng:"zh-CN",supportedLngs:["en-US","zh-CN","ko-KR"],detection:{order:["querystring","localStorage","navigator"],lookupQuerystring:"lang",lookupLocalStorage:"i18nextLng",caches:["localStorage"]},interpolation:{escapeValue:!1}});const Rd=new Hl;Ul.createRoot(document.getElementById("root")).render(e.jsx(ql.StrictMode,{children:e.jsx(Kl,{client:Rd,children:e.jsx(Bl,{store:Tr,children:e.jsxs(Zo,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Gl,{router:Sd}),e.jsx(Wl,{richColors:!0,position:"top-right"})]})})})}));const We=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));We.displayName="Card";const es=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex flex-col space-y-1.5 p-6",s),...n}));es.displayName="CardHeader";const Cs=u.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:N("font-semibold leading-none tracking-tight",s),...n}));Cs.displayName="CardTitle";const et=u.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:N("text-sm text-muted-foreground",s),...n}));et.displayName="CardDescription";const ss=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("p-6 pt-0",s),...n}));ss.displayName="CardContent";const Id=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex items-center p-6 pt-0",s),...n}));Id.displayName="CardFooter";const D=u.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));D.displayName="Input";const Dr=u.forwardRef(({className:s,...n},t)=>{const[r,a]=u.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}),e.jsx(P,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>a(i=>!i),children:r?e.jsx(Yl,{size:18}):e.jsx(Ql,{size:18})})]})});Dr.displayName="PasswordInput";const Vd=s=>I({url:"/passport/auth/login",method:"post",data:s});function Md({className:s,onForgotPassword:n,...t}){const r=Ts(),a=yn(),{t:i}=V("auth"),l=x.object({email:x.string().min(1,{message:i("signIn.validation.emailRequired")}),password:x.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=fe({resolver:be(l),defaultValues:{email:"",password:""}});async function m(o){try{const{data:c}=await Vd(o);jc(c.auth_data),a(Td(c.auth_data)),await a(mt()).unwrap(),r("/")}catch(c){console.error("Login failed:",c),c.response?.data?.message&&d.setError("root",{message:c.response.data.message})}}return e.jsx("div",{className:N("grid gap-6",s),...t,children:e.jsx(ye,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(m),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[d.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:d.formState.errors.root.message}),e.jsx(g,{control:d.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.email")}),e.jsx(y,{children:e.jsx(D,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"password",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.password")}),e.jsx(y,{children:e.jsx(Dr,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(T,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(P,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const _e=Nn,Je=_n,Fd=wn,yt=Ca,Pr=u.forwardRef(({className:s,...n},t)=>e.jsx(zt,{ref:t,className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));Pr.displayName=zt.displayName;const ve=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Fd,{children:[e.jsx(Pr,{}),e.jsxs(At,{ref:r,className:N("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...t,children:[n,e.jsxs(Ca,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ve.displayName=At.displayName;const Se=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});Se.displayName="DialogHeader";const Ke=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ke.displayName="DialogFooter";const we=u.forwardRef(({className:s,...n},t)=>e.jsx($t,{ref:t,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));we.displayName=$t.displayName;const Pe=u.forwardRef(({className:s,...n},t)=>e.jsx(Ht,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Pe.displayName=Ht.displayName;const st=zs("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?Na:"button";return e.jsx(l,{className:N(st({variant:n,size:t,className:s})),ref:i,...a})});J.displayName="Button";const Ss=Zl,ks=ei,Od=si,Ld=u.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Cn,{ref:a,className:N("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...r,children:[t,e.jsx(Sa,{className:"ml-auto h-4 w-4"})]}));Ld.displayName=Cn.displayName;const zd=u.forwardRef(({className:s,...n},t)=>e.jsx(Sn,{ref:t,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));zd.displayName=Sn.displayName;const gs=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Jl,{children:e.jsx(kn,{ref:r,sideOffset:n,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));gs.displayName=kn.displayName;const ge=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Tn,{ref:r,className:N("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...t}));ge.displayName=Tn.displayName;const Ad=u.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Dn,{ref:a,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx(As,{className:"h-4 w-4"})})}),n]}));Ad.displayName=Dn.displayName;const $d=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(En,{ref:r,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx(Xl,{className:"h-4 w-4 fill-current"})})}),n]}));$d.displayName=En.displayName;const Ra=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Rn,{ref:r,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ra.displayName=Rn.displayName;const tt=u.forwardRef(({className:s,...n},t)=>e.jsx(In,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));tt.displayName=In.displayName;const va=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});va.displayName="DropdownMenuShortcut";const ra=[{code:"en-US",name:"English",flag:ti,shortName:"EN"},{code:"zh-CN",name:"中文",flag:ai,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:ni,shortName:"KR"}];function Er(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=ra.find(a=>a.code===s.language)||ra[1],r=t.flag;return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(r,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:t.shortName})]})}),e.jsx(gs,{align:"end",className:"w-[120px]",children:ra.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(ge,{onClick:()=>n(a.code),className:N("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(i,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:N("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function Hd(){const[s,n]=u.useState(!1),{t}=V("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:[e.jsx("div",{className:"absolute right-4 top-4 md:right-8 md:top-8",children:e.jsx(Er,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[480px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(We,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(Md,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(_e,{open:s,onOpenChange:n,children:e.jsx(ve,{children:e.jsxs(Se,{children:[e.jsx(we,{children:t("signIn.resetPassword.title")}),e.jsx(Pe,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Ft(r).then(()=>{$.success(t("common:copy.success"))}),children:e.jsx(ri,{className:"h-4 w-4"})})]})})]})})})]})}const Ud=Object.freeze(Object.defineProperty({__proto__:null,default:Hd},Symbol.toStringTag,{value:"Module"})),Ee=u.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:N("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",t&&"md:h-svh",s),...r}));Ee.displayName="Layout";const Re=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Re.displayName="LayoutHeader";const Fe=u.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Fe.displayName="LayoutBody";const Rr=li,Ir=ii,Vr=oi,je=ci,he=di,pe=ui,ce=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Vn,{ref:r,sideOffset:n,className:N("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t}));ce.displayName=Vn.displayName;function Wt(){const{pathname:s}=_a();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function Mr({key:s,defaultValue:n}){const[t,r]=u.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return u.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function qd(){const[s,n]=Mr({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(i=>i!==a))}}}function Kd({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const m=`${a(d.title)}-${d.href}`;return n&&l?u.createElement(Wd,{...d,sub:l,key:m,closeNav:r}):n?u.createElement(Gd,{...d,key:m,closeNav:r}):l?u.createElement(Bd,{...d,sub:l,key:m,closeNav:r}):u.createElement(Fr,{...d,key:m,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:N("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",t),children:e.jsx(je,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(i)})})})}function Fr({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Wt(),{t:d}=V();return e.jsxs($s,{to:r,onClick:a,className:N(rt({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",i&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":l(r)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),d(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:d(t)})]})}function Bd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{isExpanded:l,toggleItem:d}=qd(),{t:m}=V(),o=!!r?.find(_=>i(_.href)),c=m(s),h=l(c)||o;return e.jsxs(Rr,{open:h,onOpenChange:()=>d(c),children:[e.jsxs(Ir,{className:N(rt({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),m(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:m(t)}),e.jsx("span",{className:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Mn,{stroke:1})})]}),e.jsx(Vr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(_=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Fr,{..._,subLink:!0,closeNav:a})},m(_.title)))})})]})}function Gd({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V();return e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsxs($s,{to:r,onClick:a,className:N(rt({variant:i(r)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:l(s)})]})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s),t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)})]})]})}function Wd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V(),d=!!r?.find(m=>i(m.href));return e.jsxs(Ss,{children:[e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Mn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(gs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ra,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(tt,{}),r.map(({title:m,icon:o,label:c,href:h})=>e.jsx(ge,{asChild:!0,children:e.jsxs($s,{to:h,onClick:a,className:`${i(h)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(m)}),c&&e.jsx("span",{className:"ml-auto text-xs",children:l(c)})]})},`${l(m)}-${h}`))]})]})}const Or=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(mi,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(xi,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(Fn,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(ka,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(hi,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(pi,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Ba,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(fi,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(On,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(gi,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Ln,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(ji,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(vi,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(bi,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Ba,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(yi,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Ni,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(_i,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(zn,{size:18})}]}];function Yd({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=u.useState(!1),{t:i}=V();return u.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:N(`fixed left-0 right-0 top-0 z-50 flex h-auto flex-col border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>a(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${r?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(Ee,{className:"flex h-full flex-col",children:[e.jsxs(Re,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(wi,{}):e.jsx(Ci,{})})]}),e.jsx(Kd,{id:"sidebar-menu",className:N("flex-1 overflow-auto",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:Or}),e.jsx("div",{className:N("border-t border-border/50 bg-background","px-4 py-2.5 text-xs text-muted-foreground",r?"block":"hidden md:block",n?"text-center":"text-left"),children:e.jsxs("div",{className:N("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:N("tracking-wide whitespace-nowrap","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(P,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(Si,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Qd(){const[s,n]=Mr({key:"collapsed-sidebar",defaultValue:!1});return u.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function Jd(){const[s,n]=Qd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Yd,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(wa,{})})]})}const Xd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"})),Ms=u.forwardRef(({className:s,...n},t)=>e.jsx(Le,{ref:t,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ms.displayName=Le.displayName;const Zd=({children:s,...n})=>e.jsx(_e,{...n,children:e.jsx(ve,{className:"overflow-hidden p-0",children:e.jsx(Ms,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),qs=u.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ki,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Le.Input,{ref:t,className:N("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));qs.displayName=Le.Input.displayName;const Fs=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.List,{ref:t,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Fs.displayName=Le.List.displayName;const Ks=u.forwardRef((s,n)=>e.jsx(Le.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ks.displayName=Le.Empty.displayName;const Ye=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Group,{ref:t,className:N("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Ye.displayName=Le.Group.displayName;const lt=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Separator,{ref:t,className:N("-mx-1 h-px bg-border",s),...n}));lt.displayName=Le.Separator.displayName;const Me=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Item,{ref:t,className:N("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Me.displayName=Le.Item.displayName;function eu(){const s=[];for(const n of Or)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function Be(){const[s,n]=u.useState(!1),t=Ts(),r=eu(),{t:a}=V("search"),{t:i}=V("nav");u.useEffect(()=>{const d=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=u.useCallback(d=>{n(!1),t(d)},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(An,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:a("placeholder")}),e.jsx("span",{className:"sr-only",children:a("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:a("shortcut.key")})]}),e.jsxs(Zd,{open:s,onOpenChange:n,children:[e.jsx(qs,{placeholder:a("placeholder")}),e.jsxs(Fs,{children:[e.jsx(Ks,{children:a("noResults")}),e.jsx(Ye,{heading:a("title"),children:r.map(d=>e.jsxs(Me,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}function ze(){const{theme:s,setTheme:n}=ec();return u.useEffect(()=>{const t=s==="dark"?"#020817":"#fff",r=document.querySelector("meta[name='theme-color']");r&&r.setAttribute("content",t)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(P,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(Ti,{size:20}):e.jsx(Di,{size:20})}),e.jsx(Er,{})]})}const Lr=u.forwardRef(({className:s,...n},t)=>e.jsx($n,{ref:t,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));Lr.displayName=$n.displayName;const zr=u.forwardRef(({className:s,...n},t)=>e.jsx(Hn,{ref:t,className:N("aspect-square h-full w-full",s),...n}));zr.displayName=Hn.displayName;const Ar=u.forwardRef(({className:s,...n},t)=>e.jsx(Un,{ref:t,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));Ar.displayName=Un.displayName;function Ae(){const s=Ts(),n=yn(),t=Pi(Pd),{t:r}=V(["common"]),a=()=>{yr(),n(Dd()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(Lr,{className:"h-8 w-8",children:[e.jsx(zr,{src:t?.avatar_url,alt:i}),e.jsx(Ar,{children:l})]})})}),e.jsxs(gs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ra,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:i}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(tt,{}),e.jsx(ge,{asChild:!0,children:e.jsxs($s,{to:"/config/system",children:[r("common:settings"),e.jsx(va,{children:"⌘S"})]})}),e.jsx(tt,{}),e.jsxs(ge,{onClick:a,children:[r("common:logout"),e.jsx(va,{children:"⇧⌘Q"})]})]})]})}const G=Ei,He=zi,W=Ri,K=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(qn,{ref:r,className:N("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[n,e.jsx(Ii,{asChild:!0,children:e.jsx(Ta,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=qn.displayName;const $r=u.forwardRef(({className:s,...n},t)=>e.jsx(Kn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Vi,{className:"h-4 w-4"})}));$r.displayName=Kn.displayName;const Hr=u.forwardRef(({className:s,...n},t)=>e.jsx(Bn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Ta,{className:"h-4 w-4"})}));Hr.displayName=Bn.displayName;const B=u.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(Mi,{children:e.jsxs(Gn,{ref:a,className:N("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:t,...r,children:[e.jsx($r,{}),e.jsx(Fi,{className:N("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Hr,{})]})}));B.displayName=Gn.displayName;const su=u.forwardRef(({className:s,...n},t)=>e.jsx(Wn,{ref:t,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));su.displayName=Wn.displayName;const z=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Yn,{ref:r,className:N("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Oi,{children:e.jsx(As,{className:"h-4 w-4"})})}),e.jsx(Li,{children:n})]}));z.displayName=Yn.displayName;const tu=u.forwardRef(({className:s,...n},t)=>e.jsx(Qn,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));tu.displayName=Qn.displayName;function Bs({className:s,classNames:n,showOutsideDays:t=!0,...r}){return e.jsx(Ai,{showOutsideDays:t,className:N("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:N(st({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:N("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:N(st({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:a,...i})=>e.jsx(Jn,{className:N("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(Sa,{className:N("h-4 w-4",a),...i})},...r})}Bs.displayName="Calendar";const bs=Hi,ys=Ui,xs=u.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx($i,{children:e.jsx(Xn,{ref:a,align:n,sideOffset:t,className:N("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})}));xs.displayName=Xn.displayName;const Es={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},dt=s=>(s/100).toFixed(2),au=({active:s,payload:n,label:t})=>{const{t:r}=V();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:t}),n.map((a,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[r(a.name),":"]}),e.jsx("span",{className:"font-medium",children:a.name.includes(r("dashboard:overview.amount"))?`¥${dt(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},nu=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],ru=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=ls(t,7);break;case"30d":r=ls(t,30);break;case"90d":r=ls(t,90);break;case"180d":r=ls(t,180);break;case"365d":r=ls(t,365);break;default:r=ls(t,30)}return{startDate:r,endDate:t}};function lu(){const[s,n]=u.useState("amount"),[t,r]=u.useState("30d"),[a,i]=u.useState({from:ls(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:m}=ru(t,a),{data:o}=ie({queryKey:["orderStat",{start_date:rs(d,"yyyy-MM-dd"),end_date:rs(m,"yyyy-MM-dd")}],queryFn:async()=>{const{data:c}=await vc({start_date:rs(d,"yyyy-MM-dd"),end_date:rs(m,"yyyy-MM-dd")});return c},refetchInterval:3e4});return e.jsxs(We,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Cs,{children:l("dashboard:overview.title")}),e.jsxs(et,{children:[o?.summary.start_date," ",l("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(G,{value:t,onValueChange:c=>r(c),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:nu.map(c=>e.jsx(z,{value:c.value,children:l(c.label)},c.value))})]}),t==="custom"&&e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a?.from?a.to?e.jsxs(e.Fragment,{children:[rs(a.from,"yyyy-MM-dd")," -"," ",rs(a.to,"yyyy-MM-dd")]}):rs(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Bs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:c=>{c?.from&&c?.to&&i({from:c.from,to:c.to})},numberOfMonths:2})})]})]}),e.jsx(Gt,{value:s,onValueChange:c=>n(c),children:e.jsxs(vt,{children:[e.jsx(qe,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(qe,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(ss,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",dt(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(qi,{width:"100%",height:"100%",children:e.jsxs(Ki,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Bi,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>rs(new Date(c),"MM-dd",{locale:Qi})}),e.jsx(Gi,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>s==="amount"?`¥${dt(c)}`:l("dashboard:overview.transactions",{count:c})}),e.jsx(Wi,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Yi,{content:e.jsx(au,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ga,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Es.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ga,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Es.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Es.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Wa,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Es.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function oe({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function iu(){return e.jsxs(We,{children:[e.jsxs(es,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(oe,{className:"h-4 w-[120px]"}),e.jsx(oe,{className:"h-4 w-4"})]}),e.jsxs(ss,{children:[e.jsx(oe,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(oe,{className:"h-4 w-[100px]"})]})]})]})}function ou(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:8}).map((s,n)=>e.jsx(iu,{},n))})}var ae=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(ae||{});const ot={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},ct={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var is=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(is||{}),xe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(xe||{});const Nt={0:"待确认",1:"发放中",2:"有效",3:"无效"},_t={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var De=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(De||{});const cu={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var re=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s.Tuic="tuic",s.Socks="socks",s.Naive="naive",s.Http="http",s.Mieru="mieru",s))(re||{});const Xe=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"},{type:"tuic",label:"TUIC"},{type:"socks",label:"SOCKS"},{type:"naive",label:"Naive"},{type:"http",label:"HTTP"},{type:"mieru",label:"Mieru"}],Ue={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50"};var Ge=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Ge||{});const du={1:"按金额优惠",2:"按比例优惠"};var Vs=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Vs||{}),Oe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Oe||{}),xt=(s=>(s.MONTH="monthly",s.QUARTER="quarterly",s.HALF_YEAR="half_yearly",s.YEAR="yearly",s.TWO_YEAR="two_yearly",s.THREE_YEAR="three_yearly",s.ONETIME="onetime",s.RESET="reset_traffic",s))(xt||{});function Rs({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(We,{className:N("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(es,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Cs,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(ss,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(to,{className:N("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("ml-1 text-xs",r.isPositive?"text-emerald-500":"text-red-500"),children:[r.isPositive?"+":"-",Math.abs(r.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function uu({className:s}){const n=Ts(),{t}=V(),{data:r,isLoading:a}=ie({queryKey:["dashboardStats"],queryFn:async()=>(await bc()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(ou,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",xe.PENDING.toString()),l.set("status",ae.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Rs,{title:t("dashboard:stats.todayIncome"),value:Ls(r.todayIncome),icon:e.jsx(Ji,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.monthlyIncome"),value:Ls(r.currentMonthIncome),icon:e.jsx(Xi,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(Zi,{className:N("h-4 w-4",r.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:r.ticketPendingTotal>0?t("dashboard:stats.hasPendingTickets"):t("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:r.ticketPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(eo,{className:N("h-4 w-4",r.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:r.commissionPendingTotal>0?t("dashboard:stats.hasPendingCommission"):t("dashboard:stats.noPendingCommission"),onClick:i,highlight:r.commissionPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyUpload"),value:fs(r.monthTraffic.upload),icon:e.jsx(pt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:fs(r.todayTraffic.upload)})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyDownload"),value:fs(r.monthTraffic.download),icon:e.jsx(so,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:fs(r.todayTraffic.download)})})]})}const at=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Zn,{ref:r,className:N("relative overflow-hidden",s),...t,children:[e.jsx(ao,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ot,{}),e.jsx(no,{})]}));at.displayName=Zn.displayName;const Ot=u.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(er,{ref:r,orientation:n,className:N("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:e.jsx(ro,{className:"relative flex-1 rounded-full bg-border"})}));Ot.displayName=er.displayName;const ba={today:{getValue:()=>{const s=io();return{start:s,end:oo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:ls(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:ls(s,30),end:s}}},custom:{getValue:()=>null}};function nn({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=V(),i={today:a("dashboard:trafficRank.today"),last7days:a("dashboard:trafficRank.last7days"),last30days:a("dashboard:trafficRank.last30days"),custom:a("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(G,{value:s,onValueChange:t,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(ba).map(([l])=>e.jsx(z,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[rs(n.from,"yyyy-MM-dd")," -"," ",rs(n.to,"yyyy-MM-dd")]}):rs(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Bs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:l=>{l?.from&&l?.to&&r({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const Qs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function mu({className:s}){const{t:n}=V(),[t,r]=u.useState("today"),[a,i]=u.useState({from:ls(new Date,7),to:new Date}),[l,d]=u.useState("today"),[m,o]=u.useState({from:ls(new Date,7),to:new Date}),c=u.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:ba[t].getValue(),[t,a]),h=u.useMemo(()=>l==="custom"?{start:m.from,end:m.to}:ba[l].getValue(),[l,m]),{data:_}=ie({queryKey:["nodeTrafficRank",c.start,c.end],queryFn:()=>tn({type:"node",start_time:Ce.round(c.start.getTime()/1e3),end_time:Ce.round(c.end.getTime()/1e3)}),refetchInterval:3e4}),{data:E}=ie({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>tn({type:"user",start_time:Ce.round(h.start.getTime()/1e3),end_time:Ce.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(We,{children:[e.jsx(es,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(lo,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(nn,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ss,{className:"flex-1",children:_?.data?e.jsxs(at,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:_.data.map(C=>e.jsx(je,{delayDuration:200,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/_.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Ot,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(We,{children:[e.jsx(es,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(ha,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(nn,{selectedRange:l,customDateRange:m,onRangeChange:d,onCustomRangeChange:o}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ss,{className:"flex-1",children:E?.data?e.jsxs(at,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:E.data.map(C=>e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/E.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Ot,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const xu=zs("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function q({className:s,variant:n,...t}){return e.jsx("div",{className:N(xu({variant:n}),s),...t})}const le=window?.settings?.secure_path,Ur=5*60*1e3,ya=new Map,hu=s=>{const n=ya.get(s);return n?Date.now()-n.timestamp>Ur?(ya.delete(s),null):n.data:null},pu=(s,n)=>{ya.set(s,{data:n,timestamp:Date.now()})},fu=async(s,n=Ur)=>{const t=hu(s);if(t)return t;const r=await I.get(s);return pu(s,r),r},Lt={getList:s=>I.post(`${le}/user/fetch`,s),update:s=>I.post(`${le}/user/update`,s),resetSecret:s=>I.post(`${le}/user/resetSecret`,{id:s}),generate:s=>I.post(`${le}/user/generate`,s),getStats:s=>I.post(`${le}/stat/getStatUser`,s),destroy:s=>I.post(`${le}/user/destroy`,{id:s}),sendMail:s=>I.post(`${le}/user/sendMail`,s),dumpCSV:s=>I.post(`${le}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>I.post(`${le}/user/ban`,s)},rn={getList:()=>fu(`${le}/notice/fetch`),save:s=>I.post(`${le}/notice/save`,s),drop:s=>I.post(`${le}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${le}/notice/show`,{id:s}),sort:s=>I.post(`${le}/notice/sort`,{ids:s})},la={getList:s=>I.post(`${le}/ticket/fetch`,s),getInfo:s=>I.get(`${le}/ticket/fetch?id=${s}`),reply:s=>I.post(`${le}/ticket/reply`,s),close:s=>I.post(`${le}/ticket/close`,{id:s})},ln={getSystemStatus:()=>I.get(`${le}/system/getSystemStatus`),getQueueStats:()=>I.get(`${le}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${le}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${le}/system/getQueueMasters`),getSystemLog:s=>I.get(`${le}/system/getSystemLog`,{params:s})},ws={getPluginList:()=>I.get(`${le}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),I.post(`${le}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>I.post(`${le}/plugin/delete`,{code:s}),installPlugin:s=>I.post(`${le}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${le}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${le}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${le}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${le}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${le}/plugin/config`,{code:s,config:n})},Dt=u.forwardRef(({className:s,value:n,...t},r)=>e.jsx(sr,{ref:r,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(co,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Dt.displayName=sr.displayName;function gu(){const{t:s}=V(),[n,t]=u.useState(null),[r,a]=u.useState(null),[i,l]=u.useState(!0),[d,m]=u.useState(!1),o=async()=>{try{m(!0);const[_,E]=await Promise.all([ln.getSystemStatus(),ln.getQueueStats()]);t(_.data),a(E.data)}catch(_){console.error("Error fetching system data:",_)}finally{l(!1),m(!1)}};u.useEffect(()=>{o();const _=setInterval(o,3e4);return()=>clearInterval(_)},[]);const c=()=>{o()};if(i)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})});const h=_=>_?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(We,{children:[e.jsxs(es,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(et,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:c,disabled:d,children:e.jsx(mo,{className:N("h-4 w-4",d&&"animate-spin")})})]}),e.jsx(ss,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h(r?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(q,{variant:r?.status?"secondary":"destructive",children:r?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:r?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.recentJobs||0}),e.jsx(Dt,{value:(r?.recentJobs||0)/(r?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:r?.periods?.recentJobs||0})})})]})}),e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.jobsPerMinute||0}),e.jsx(Dt,{value:(r?.jobsPerMinute||0)/(r?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:r?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(We,{children:[e.jsxs(es,{children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(et,{children:s("dashboard:queue.details.description")})]}),e.jsx(ss,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:r?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:r?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[r?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:r?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[r?.processes||0," /"," ",(r?.processes||0)+(r?.pausedMasters||0)]})]}),e.jsx(Dt,{value:(r?.processes||0)/((r?.processes||0)+(r?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function ju(){const{t:s}=V();return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Be,{}),e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(uu,{}),e.jsx(lu,{}),e.jsx(mu,{}),e.jsx(gu,{})]})})})]})}const vu=Object.freeze(Object.defineProperty({__proto__:null,default:ju},Symbol.toStringTag,{value:"Module"}));function bu({className:s,items:n,...t}){const{pathname:r}=_a(),a=Ts(),[i,l]=u.useState(r??"/settings"),d=o=>{l(o),a(o)},{t:m}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(G,{value:i,onValueChange:d,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(W,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(z,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:m(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:N("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(o=>e.jsxs($s,{to:o.href,className:N(rt({variant:"ghost"}),r===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),m(o.title)]},o.href))})})]})}const yu=[{title:"site.title",key:"site",icon:e.jsx(ho,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Ln,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(zn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(po,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(On,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(fo,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(go,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Fn,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(jo,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Nu(){const{t:s}=V("settings");return e.jsxs(Ee,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Re,{children:[e.jsx(Be,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(ke,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(bu,{items:yu})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(wa,{})})})]})]})]})}const _u=Object.freeze(Object.defineProperty({__proto__:null,default:Nu},Symbol.toStringTag,{value:"Module"})),Y=u.forwardRef(({className:s,...n},t)=>e.jsx(nr,{className:N("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:t,children:e.jsx(vo,{className:N("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Y.displayName=nr.displayName;const Ns=u.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:N("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}));Ns.displayName="Textarea";const wu=x.object({logo:x.string().nullable().default(""),force_https:x.number().nullable().default(0),stop_register:x.number().nullable().default(0),app_name:x.string().nullable().default(""),app_description:x.string().nullable().default(""),app_url:x.string().nullable().default(""),subscribe_url:x.string().nullable().default(""),try_out_plan_id:x.number().nullable().default(0),try_out_hour:x.coerce.number().nullable().default(0),tos_url:x.string().nullable().default(""),currency:x.string().nullable().default(""),currency_symbol:x.string().nullable().default("")});function Cu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),{data:a}=ie({queryKey:["settings","site"],queryFn:()=>js("site")}),{data:i}=ie({queryKey:["plans"],queryFn:()=>Us()}),l=fe({resolver:be(wu),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=os({mutationFn:vs,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(a?.data?.site){const c=a?.data?.site;Object.entries(c).forEach(([h,_])=>{l.setValue(h,_)}),r.current=c}},[a]);const m=u.useCallback(Ce.debounce(async c=>{if(!Ce.isEqual(c,r.current)){t(!0);try{const h=Object.entries(c).reduce((_,[E,C])=>(_[E]=C===null?"":C,_),{});await d(h),r.current=c}finally{t(!1)}}},1e3),[d]),o=u.useCallback(c=>{m(c)},[m]);return u.useEffect(()=>{const c=l.watch(h=>{o(h)});return()=>c.unsubscribe()},[l.watch,o]),e.jsx(ye,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:l.control,name:"app_name",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"app_description",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"app_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"force_https",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"logo",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"subscribe_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(y,{children:e.jsx(Ns,{placeholder:s("site.form.subscribeUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"tos_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"stop_register",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"try_out_plan_id",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(y,{children:e.jsxs(G,{value:c.value?.toString(),onValueChange:h=>{c.onChange(Number(h)),o(l.getValues())},children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(h=>e.jsx(z,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(T,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(g,{control:l.control,name:"try_out_hour",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"currency",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:l.control,name:"currency_symbol",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(T,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Su(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(ke,{}),e.jsx(Cu,{})]})}const ku=Object.freeze(Object.defineProperty({__proto__:null,default:Su},Symbol.toStringTag,{value:"Module"})),Tu=x.object({email_verify:x.boolean().nullable(),safe_mode_enable:x.boolean().nullable(),secure_path:x.string().nullable(),email_whitelist_enable:x.boolean().nullable(),email_whitelist_suffix:x.array(x.string().nullable()).nullable(),email_gmail_limit_enable:x.boolean().nullable(),recaptcha_enable:x.boolean().nullable(),recaptcha_key:x.string().nullable(),recaptcha_site_key:x.string().nullable(),register_limit_by_ip_enable:x.boolean().nullable(),register_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:x.boolean().nullable(),password_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable()}),Du={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,recaptcha_enable:!1,recaptcha_key:"",recaptcha_site_key:"",register_limit_by_ip_enable:!1,register_limit_count:"",register_limit_expire:"",password_limit_enable:!1,password_limit_count:"",password_limit_expire:""};function Pu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(Tu),defaultValues:Du,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","safe"],queryFn:()=>js("safe")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data.safe){const o=i.data.safe;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Ce.debounce(async o=>{if(!Ce.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(ye,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"email_verify",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"secure_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("email_whitelist_enable")&&e.jsx(g,{control:a.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(y,{children:e.jsx(Ns,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` `),onChange:c=>{const h=c.target.value.split(` `).filter(Boolean);o.onChange(h),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(F,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.key.description")}),e.jsx(T,{})]})})]}),e.jsx(g,{control:a.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(F,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"register_limit_count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.count.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(T,{})]})})]}),e.jsx(g,{control:a.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(F,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"password_limit_count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(T,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function Eu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ke,{}),e.jsx(Pu,{})]})}const Ru=Object.freeze(Object.defineProperty({__proto__:null,default:Eu},Symbol.toStringTag,{value:"Module"})),Iu=x.object({plan_change_enable:x.boolean().nullable().default(!1),reset_traffic_method:x.coerce.number().nullable().default(0),surplus_enable:x.boolean().nullable().default(!1),new_order_event_id:x.coerce.number().nullable().default(0),renew_order_event_id:x.coerce.number().nullable().default(0),change_order_event_id:x.coerce.number().nullable().default(0),show_info_to_server_enable:x.boolean().nullable().default(!1),show_protocol_to_server_enable:x.boolean().nullable().default(!1),default_remind_expire:x.boolean().nullable().default(!1),default_remind_traffic:x.boolean().nullable().default(!1),subscribe_path:x.string().nullable().default("s")}),Vu={plan_change_enable:!1,reset_traffic_method:0,surplus_enable:!1,new_order_event_id:0,renew_order_event_id:0,change_order_event_id:0,show_info_to_server_enable:!1,show_protocol_to_server_enable:!1,default_remind_expire:!1,default_remind_traffic:!1,subscribe_path:"s"};function Mu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(Iu),defaultValues:Vu,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","subscribe"],queryFn:()=>js("subscribe")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data?.subscribe){const o=i?.data?.subscribe;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Ce.debounce(async o=>{if(!Ce.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(ye,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(F,{children:s("subscribe.plan_change_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(z,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(z,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(z,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(z,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(F,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"surplus_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(F,{children:s("subscribe.surplus_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.new_order_event.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.renew_order_event.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.change_order_event.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"subscribe_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:"subscribe",...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:o.value||"s"})]}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(F,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(F,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Fu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ke,{}),e.jsx(Mu,{})]})}const Ou=Object.freeze(Object.defineProperty({__proto__:null,default:Fu},Symbol.toStringTag,{value:"Module"})),Lu=x.object({invite_force:x.boolean().default(!1),invite_commission:x.coerce.string().default("0"),invite_gen_limit:x.coerce.string().default("0"),invite_never_expire:x.boolean().default(!1),commission_first_time_enable:x.boolean().default(!1),commission_auto_check_enable:x.boolean().default(!1),commission_withdraw_limit:x.coerce.string().default("0"),commission_withdraw_method:x.array(x.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:x.boolean().default(!1),commission_distribution_enable:x.boolean().default(!1),commission_distribution_l1:x.coerce.number().default(0),commission_distribution_l2:x.coerce.number().default(0),commission_distribution_l3:x.coerce.number().default(0)}),zu={invite_force:!1,invite_commission:"0",invite_gen_limit:"0",invite_never_expire:!1,commission_first_time_enable:!1,commission_auto_check_enable:!1,commission_withdraw_limit:"0",commission_withdraw_method:["支付宝","USDT","Paypal"],withdraw_close_enable:!1,commission_distribution_enable:!1,commission_distribution_l1:0,commission_distribution_l2:0,commission_distribution_l3:0};function Au(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(Lu),defaultValues:zu,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","invite"],queryFn:()=>js("invite")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data?.invite){const o=i?.data?.invite;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Ce.debounce(async o=>{if(!Ce.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(ye,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"invite_force",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(F,{children:s("invite.invite_force.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"invite_commission",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_commission.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_gen_limit.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(F,{children:s("invite.invite_never_expire.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(F,{children:s("invite.commission_first_time.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(F,{children:s("invite.commission_auto_check.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_method.placeholder"),...o,value:Array.isArray(o.value)?o.value.join(","):"",onChange:c=>{const h=c.target.value.split(",").filter(Boolean);o.onChange(h),m(a.getValues())}})}),e.jsx(F,{children:s("invite.commission_withdraw_method.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(F,{children:s("invite.withdraw_close.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(F,{children:s("invite.commission_distribution.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l1")}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l2")}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l3")}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(T,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function $u(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ke,{}),e.jsx(Au,{})]})}const Hu=Object.freeze(Object.defineProperty({__proto__:null,default:$u},Symbol.toStringTag,{value:"Module"})),Uu=x.object({frontend_theme:x.string().nullable(),frontend_theme_sidebar:x.string().nullable(),frontend_theme_header:x.string().nullable(),frontend_theme_color:x.string().nullable(),frontend_background_url:x.string().url().nullable()}),qu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Ku(){const{data:s}=ie({queryKey:["settings","frontend"],queryFn:()=>js("frontend")}),n=fe({resolver:be(Uu),defaultValues:qu,mode:"onChange"});u.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,i])=>{n.setValue(a,i)})}},[s]);function t(r){vs(r).then(({data:a})=>{a&&$.success("更新成功")})}return e.jsx(ye,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(g,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Y,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(g,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Y,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(g,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(f,{children:[e.jsx(j,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(y,{children:e.jsxs("select",{className:N(rt({variant:"outline"}),"w-[200px] appearance-none font-normal"),...r,children:[e.jsx("option",{value:"default",children:"默认"}),e.jsx("option",{value:"black",children:"黑色"}),e.jsx("option",{value:"blackblue",children:"暗蓝色"}),e.jsx("option",{value:"green",children:"奶绿色"})]})}),e.jsx(Ta,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(T,{})]})}),e.jsx(g,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(f,{children:[e.jsx(j,{children:"背景"}),e.jsx(y,{children:e.jsx(D,{placeholder:"请输入图片地址",...r})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(T,{})]})}),e.jsx(P,{type:"submit",children:"保存设置"})]})})}function Bu(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"个性化设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自定义系统界面外观,包括主题风格、布局、颜色方案、背景图等个性化选项。"})]}),e.jsx(ke,{}),e.jsx(Ku,{})]})}const Gu=Object.freeze(Object.defineProperty({__proto__:null,default:Bu},Symbol.toStringTag,{value:"Module"})),Wu=x.object({server_pull_interval:x.coerce.number().nullable(),server_push_interval:x.coerce.number().nullable(),server_token:x.string().nullable(),device_limit_mode:x.coerce.number().nullable()}),Yu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Qu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(Wu),defaultValues:Yu,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","server"],queryFn:()=>js("server")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:c=>{c.data&&$.success(s("common.AutoSaved"))}});u.useEffect(()=>{if(i?.data.server){const c=i.data.server;Object.entries(c).forEach(([h,_])=>{a.setValue(h,_)}),r.current=c}},[i]);const d=u.useCallback(Ce.debounce(async c=>{if(!Ce.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),m=u.useCallback(c=>{d(c)},[d]);u.useEffect(()=>{const c=a.watch(h=>{m(h)});return()=>c.unsubscribe()},[a.watch,m]);const o=()=>{const c=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let _="";for(let E=0;Ee.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_token.title")}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...c,value:c.value||"",className:"pr-10"}),e.jsx(je,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:h=>{h.preventDefault(),o()},children:e.jsx(bo,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ce,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(F,{children:s("server.server_token.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"server_pull_interval",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;c.onChange(_)}})}),e.jsx(F,{children:s("server.server_pull_interval.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"server_push_interval",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;c.onChange(_)}})}),e.jsx(F,{children:s("server.server_push_interval.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"device_limit_mode",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(G,{onValueChange:c.onChange,value:c.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(z,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(F,{children:s("server.device_limit_mode.description")}),e.jsx(T,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Ju(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ke,{}),e.jsx(Qu,{})]})}const Xu=Object.freeze(Object.defineProperty({__proto__:null,default:Ju},Symbol.toStringTag,{value:"Module"}));function Zu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(_e,{open:s,onOpenChange:n,children:e.jsxs(ve,{className:"sm:max-w-[425px]",children:[e.jsxs(Se,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-destructive"}),e.jsx(we,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Pe,{children:r?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(at,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const em=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function sm(){const{t:s}=V("settings"),[n,t]=u.useState(null),[r,a]=u.useState(!1),i=u.useRef(null),[l,d]=u.useState(!1),m=fe({resolver:be(em),defaultValues:{},mode:"onBlur"}),{data:o}=ie({queryKey:["settings","email"],queryFn:()=>js("email")}),{data:c}=ie({queryKey:["emailTemplate"],queryFn:()=>jd()}),{mutateAsync:h}=os({mutationFn:vs,onSuccess:w=>{w.data&&$.success(s("common.autoSaved"))}}),{mutate:_,isPending:E}=os({mutationFn:vd,onMutate:()=>{t(null),a(!1)},onSuccess:w=>{t(w.data),a(!0),w.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});u.useEffect(()=>{if(o?.data.email){const w=o.data.email;Object.entries(w).forEach(([b,k])=>{m.setValue(b,k)}),i.current=w}},[o]);const C=u.useCallback(Ce.debounce(async w=>{if(!Ce.isEqual(w,i.current)){d(!0);try{await h(w),i.current=w}finally{d(!1)}}},1e3),[h]),S=u.useCallback(w=>{C(w)},[C]);return u.useEffect(()=>{const w=m.watch(b=>{S(b)});return()=>w.unsubscribe()},[m.watch,S]),e.jsxs(e.Fragment,{children:[e.jsx(ye,{...m,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:m.control,name:"email_host",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_host.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_host.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"email_port",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_port.title")}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...w,value:w.value||"",onChange:b=>{const k=b.target.value?Number(b.target.value):null;w.onChange(k)}})}),e.jsx(F,{children:s("email.email_port.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"email_encryption",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(G,{onValueChange:w.onChange,value:w.value||"none",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(z,{value:"none",children:s("email.email_encryption.none")}),e.jsx(z,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(z,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(F,{children:s("email.email_encryption.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"email_username",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_username.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_username.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"email_password",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_password.title")}),e.jsx(y,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_password.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"email_from_address",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_from.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_from.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"email_template",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(G,{onValueChange:b=>{w.onChange(b),S(m.getValues())},value:w.value||void 0,children:[e.jsx(y,{children:e.jsx(K,{className:"w-[200px]",children:e.jsx(W,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(B,{children:c?.data?.map(b=>e.jsx(z,{value:b,children:b},b))})]}),e.jsx(F,{children:s("email.email_template.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:m.control,name:"remind_mail_enable",render:({field:w})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(F,{children:s("email.remind_mail.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:w.value||!1,onCheckedChange:b=>{w.onChange(b),S(m.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{onClick:()=>_(),loading:E,disabled:E,children:s(E?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Zu,{open:r,onOpenChange:a,result:n})]})}function tm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ke,{}),e.jsx(sm,{})]})}const am=Object.freeze(Object.defineProperty({__proto__:null,default:tm},Symbol.toStringTag,{value:"Module"})),nm=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),rm={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function lm(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(nm),defaultValues:rm,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","telegram"],queryFn:()=>js("telegram")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:h=>{h.data&&$.success(s("common.autoSaved"))}}),{mutate:d,isPending:m}=os({mutationFn:bd,onSuccess:h=>{h.data&&$.success(s("telegram.webhook.success"))}});u.useEffect(()=>{if(i?.data.telegram){const h=i.data.telegram;Object.entries(h).forEach(([_,E])=>{a.setValue(_,E)}),r.current=h}},[i]);const o=u.useCallback(Ce.debounce(async h=>{if(!Ce.isEqual(h,r.current)){t(!0);try{await l(h),r.current=h}finally{t(!1)}}},1e3),[l]),c=u.useCallback(h=>{o(h)},[o]);return u.useEffect(()=>{const h=a.watch(_=>{c(_)});return()=>h.unsubscribe()},[a.watch,c]),e.jsx(ye,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.bot_token.description")}),e.jsx(T,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(P,{loading:m,disabled:m,onClick:()=>d(),children:s(m?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(F,{children:s("telegram.webhook.description")}),e.jsx(T,{})]}),e.jsx(g,{control:a.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(F,{children:s("telegram.bot_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:h.value||!1,onCheckedChange:_=>{h.onChange(_),c(a.getValues())}})}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.discuss_link.description")}),e.jsx(T,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function im(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ke,{}),e.jsx(lm,{})]})}const om=Object.freeze(Object.defineProperty({__proto__:null,default:im},Symbol.toStringTag,{value:"Module"})),cm=x.object({windows_version:x.string().nullable(),windows_download_url:x.string().nullable(),macos_version:x.string().nullable(),macos_download_url:x.string().nullable(),android_version:x.string().nullable(),android_download_url:x.string().nullable()}),dm={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function um(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=fe({resolver:be(cm),defaultValues:dm,mode:"onBlur"}),{data:i}=ie({queryKey:["settings","app"],queryFn:()=>js("app")}),{mutateAsync:l}=os({mutationFn:vs,onSuccess:o=>{o.data&&$.success(s("app.save_success"))}});u.useEffect(()=>{if(i?.data.app){const o=i.data.app;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Ce.debounce(async o=>{if(!Ce.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(ye,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"windows_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.version.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"windows_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.download.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"macos_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.version.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"macos_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.download.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"android_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.version.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.version.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:a.control,name:"android_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.download.title")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.download.description")}),e.jsx(T,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function mm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ke,{}),e.jsx(um,{})]})}const xm=Object.freeze(Object.defineProperty({__proto__:null,default:mm},Symbol.toStringTag,{value:"Module"})),Ia=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:N("w-full caption-bottom text-sm",s),...n})}));Ia.displayName="Table";const Va=u.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:N("[&_tr]:border-b",s),...n}));Va.displayName="TableHeader";const Ma=u.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:N("[&_tr:last-child]:border-0",s),...n}));Ma.displayName="TableBody";const hm=u.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:N("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));hm.displayName="TableFooter";const Is=u.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:N("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Is.displayName="TableRow";const Fa=u.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:N("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Fa.displayName="TableHead";const Zs=u.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:N("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Zs.displayName="TableCell";const pm=u.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:N("mt-4 text-sm text-muted-foreground",s),...n}));pm.displayName="TableCaption";function fm({table:s}){const[n,t]=u.useState(""),{t:r}=V("common");u.useEffect(()=>{t((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const a=i=>{const l=parseInt(i);!isNaN(l)&&l>=1&&l<=s.getPageCount()?s.setPageIndex(l-1):t((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:r("table.pagination.selected",{selected:s.getFilteredSelectedRowModel().rows.length,total:s.getFilteredRowModel().rows.length})}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("table.pagination.itemsPerPage")}),e.jsxs(G,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx(z,{value:`${i}`,children:i},i))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(D,{type:"text",value:n,onChange:i=>t(i.target.value),onBlur:i=>a(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a(i.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:r("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.firstPage")}),e.jsx(yo,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.previousPage")}),e.jsx(Jn,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.nextPage")}),e.jsx(Sa,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.lastPage")}),e.jsx(No,{className:"h-4 w-4"})]})]})]})]})}function hs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:m=!0,isLoading:o=!1}){const{t:c}=V("common"),h=u.useRef(null),_=s.getAllColumns().filter(w=>w.getIsPinned()==="left"),E=s.getAllColumns().filter(w=>w.getIsPinned()==="right"),C=w=>_.slice(0,w).reduce((b,k)=>b+(k.getSize()??0),0),S=w=>E.slice(w+1).reduce((b,k)=>b+(k.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:h,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(Ia,{children:[e.jsx(Va,{children:s.getHeaderGroups().map(w=>e.jsx(Is,{className:"hover:bg-transparent",children:w.headers.map((b,k)=>{const p=b.column.getIsPinned()==="left",v=b.column.getIsPinned()==="right",M=p?C(_.indexOf(b.column)):void 0,U=v?S(E.indexOf(b.column)):void 0;return e.jsx(Fa,{colSpan:b.colSpan,style:{width:b.getSize(),...p&&{left:M},...v&&{right:U}},className:N("h-11 bg-card px-4 text-muted-foreground",(p||v)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",p&&"before:right-0",v&&"before:left-0"]),children:b.isPlaceholder?null:Rt(b.column.columnDef.header,b.getContext())},b.id)})},w.id))}),e.jsx(Ma,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((w,b)=>e.jsx(Is,{"data-state":w.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:k=>r?.(k,b),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:k=>d?.(k,b),children:w.getVisibleCells().map((k,p)=>{const v=k.column.getIsPinned()==="left",M=k.column.getIsPinned()==="right",U=v?C(_.indexOf(k.column)):void 0,se=M?S(E.indexOf(k.column)):void 0;return e.jsx(Zs,{style:{width:k.column.getSize(),...v&&{left:U},...M&&{right:se}},className:N("bg-card",(v||M)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",v&&"before:right-0",M&&"before:left-0"]),children:Rt(k.column.columnDef.cell,k.getContext())},k.id)})},w.id)):e.jsx(Is,{children:e.jsx(Zs,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:c("table.noData")})})})]})})}),m&&e.jsx(fm,{table:s})]})}const gm=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),on={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function qr({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=on}){const{t:a}=V("payment"),[i,l]=u.useState(!1),[d,m]=u.useState(!1),[o,c]=u.useState([]),[h,_]=u.useState([]),E=gm(a),C=fe({resolver:be(E),defaultValues:r,mode:"onChange"}),S=C.watch("payment");u.useEffect(()=>{i&&(async()=>{const{data:k}=await Oc();c(k)})()},[i]),u.useEffect(()=>{if(!S||!i)return;(async()=>{const k={payment:S,...t==="edit"&&{id:Number(C.getValues("id"))}};Lc(k).then(({data:p})=>{_(p);const v=p.reduce((M,U)=>(U.field_name&&(M[U.field_name]=U.value??""),M),{});C.setValue("config",v)})})()},[S,i,C,t]);const w=async b=>{m(!0);try{(await zc(b)).data&&($.success(a("form.messages.success")),C.reset(on),s(),l(!1))}finally{m(!1)}};return e.jsxs(_e,{open:i,onOpenChange:l,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(ve,{className:"sm:max-w-[425px]",children:[e.jsx(Se,{children:e.jsx(we,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(ye,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(w),className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"name",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:a("form.fields.name.placeholder"),...b})}),e.jsx(F,{children:a("form.fields.name.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"icon",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.icon.label")}),e.jsx(y,{children:e.jsx(D,{...b,value:b.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(F,{children:a("form.fields.icon.description")}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"notify_domain",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.notify_domain.label")}),e.jsx(y,{children:e.jsx(D,{...b,value:b.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(F,{children:a("form.fields.notify_domain.description")}),e.jsx(T,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{control:C.control,name:"handling_fee_percent",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(y,{children:e.jsx(D,{type:"number",...b,value:b.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"handling_fee_fixed",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(y,{children:e.jsx(D,{type:"number",...b,value:b.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(T,{})]})})]}),e.jsx(g,{control:C.control,name:"payment",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.payment.label")}),e.jsxs(G,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(B,{children:o.map(k=>e.jsx(z,{value:k,children:k},k))})]}),e.jsx(F,{children:a("form.fields.payment.description")}),e.jsx(T,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(b=>e.jsx(g,{control:C.control,name:`config.${b.field_name}`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(j,{children:b.label}),e.jsx(y,{children:e.jsx(D,{...k,value:k.value||""})}),e.jsx(T,{})]})},b.field_name))}),e.jsxs(Ke,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:t,className:r}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(P,{variant:"ghost",size:"default",className:N("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",r),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),t&&e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Qa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(pa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(fa,{className:"h-4 w-4 text-foreground/70"}):e.jsx(_o,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:N("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",r),children:[e.jsx("span",{children:n}),t&&e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const Oa=wo,Kr=Co,jm=So,Br=u.forwardRef(({className:s,...n},t)=>e.jsx(rr,{className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));Br.displayName=rr.displayName;const Yt=u.forwardRef(({className:s,...n},t)=>e.jsxs(jm,{children:[e.jsx(Br,{}),e.jsx(lr,{ref:t,className:N("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));Yt.displayName=lr.displayName;const Qt=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Qt.displayName="AlertDialogHeader";const Jt=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Jt.displayName="AlertDialogFooter";const Xt=u.forwardRef(({className:s,...n},t)=>e.jsx(ir,{ref:t,className:N("text-lg font-semibold",s),...n}));Xt.displayName=ir.displayName;const Zt=u.forwardRef(({className:s,...n},t)=>e.jsx(or,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Zt.displayName=or.displayName;const ea=u.forwardRef(({className:s,...n},t)=>e.jsx(cr,{ref:t,className:N(st(),s),...n}));ea.displayName=cr.displayName;const sa=u.forwardRef(({className:s,...n},t)=>e.jsx(dr,{ref:t,className:N(st({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));sa.displayName=dr.displayName;function Qe({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Oa,{children:[e.jsx(Kr,{asChild:!0,children:n}),e.jsxs(Yt,{className:N("sm:max-w-[425px]",d),children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:t}),e.jsx(Zt,{children:r})]}),e.jsxs(Jt,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a})}),e.jsx(ea,{asChild:!0,children:e.jsx(P,{variant:l,onClick:s,children:i})})]})]})]})}const Gr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),vm=({refetch:s,isSortMode:n=!1})=>{const{t}=V("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ut,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(q,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(Y,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await $c({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.name")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.payment")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:r})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:r,title:t("table.columns.notify_url")}),e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{className:"ml-1",children:e.jsx(Gr,{className:"h-4 w-4"})}),e.jsx(ce,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:r.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("table.columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(qr,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(Qe,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await Ac({id:r.original.id});a&&s()},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function bm({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("payment"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{refetch:n}),e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),i&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(Ze,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function ym(){const[s,n]=u.useState([]),[t,r]=u.useState([]),[a,i]=u.useState(!1),[l,d]=u.useState([]),[m,o]=u.useState({"drag-handle":!1}),[c,h]=u.useState({pageSize:20,pageIndex:0}),{refetch:_}=ie({queryKey:["paymentList"],queryFn:async()=>{const{data:b}=await Fc();return d(b?.map(k=>({...k,enable:!!k.enable}))||[]),b}});u.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const E=(b,k)=>{a&&(b.dataTransfer.setData("text/plain",k.toString()),b.currentTarget.classList.add("opacity-50"))},C=(b,k)=>{if(!a)return;b.preventDefault(),b.currentTarget.classList.remove("bg-muted");const p=parseInt(b.dataTransfer.getData("text/plain"));if(p===k)return;const v=[...l],[M]=v.splice(p,1);v.splice(k,0,M),d(v)},S=async()=>{a?Hc({ids:l.map(b=>b.id)}).then(()=>{_(),i(!1),$.success("排序保存成功")}):i(!0)},w=ts({data:l,columns:vm({refetch:_,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:m,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:as(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(hs,{table:w,toolbar:b=>e.jsx(bm,{table:b,refetch:_,saveOrder:S,isSortMode:a}),draggable:a,onDragStart:E,onDragEnd:b=>b.currentTarget.classList.remove("opacity-50"),onDragOver:b=>{b.preventDefault(),b.currentTarget.classList.add("bg-muted")},onDragLeave:b=>b.currentTarget.classList.remove("bg-muted"),onDrop:C,showPagination:!a})}function Nm(){const{t:s}=V("payment");return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Be,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(ym,{})})]})]})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:Nm},Symbol.toStringTag,{value:"Module"}));function wm({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,i]=u.useState(!0),[l,d]=u.useState(!1),[m,o]=u.useState(null),c=ko({config:To(Do())}),h=fe({resolver:be(c),defaultValues:{config:{}}});u.useEffect(()=>{(async()=>{try{const{data:S}=await ws.getPluginConfig(s);o(S),h.reset({config:Object.fromEntries(Object.entries(S).map(([w,b])=>[w,b.value]))})}catch{$.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const _=async C=>{d(!0);try{await ws.updatePluginConfig(s,C.config),$.success(r("messages.configSaveSuccess")),t()}catch{$.error(r("messages.configSaveError"))}finally{d(!1)}},E=(C,S)=>{switch(S.type){case"string":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsx(D,{placeholder:S.placeholder,...w})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(T,{})]})},C);case"number":case"percentage":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:S.placeholder,...w,onChange:b=>{const k=Number(b.target.value);S.type==="percentage"?w.onChange(Math.min(100,Math.max(0,k))):w.onChange(k)},className:S.type==="percentage"?"pr-8":"",min:S.type==="percentage"?0:void 0,max:S.type==="percentage"?100:void 0,step:S.type==="percentage"?1:void 0}),S.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(Po,{className:"h-4 w-4 text-muted-foreground"})})]})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(T,{})]})},C);case"select":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsxs(G,{onValueChange:w.onChange,defaultValue:w.value,children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:S.placeholder})})}),e.jsx(B,{children:S.options?.map(b=>e.jsx(z,{value:b.value,children:b.label},b.value))})]}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(T,{})]})},C);case"boolean":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:S.label||S.description}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description})]}),e.jsx(y,{children:e.jsx(Y,{checked:w.value,onCheckedChange:w.onChange})})]})},C);case"text":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsx(Ns,{placeholder:S.placeholder,...w})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(T,{})]})},C);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{className:"h-4 w-[200px]"}),e.jsx(oe,{className:"h-10 w-full"}),e.jsx(oe,{className:"h-4 w-[200px]"}),e.jsx(oe,{className:"h-10 w-full"})]}):e.jsx(ye,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(_),className:"space-y-4",children:[m&&Object.entries(m).map(([C,S])=>E(C,S)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(P,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function Cm(){const{t:s}=V("plugin"),[n,t]=u.useState(null),[r,a]=u.useState(!1),[i,l]=u.useState(null),[d,m]=u.useState(""),[o,c]=u.useState("all"),[h,_]=u.useState(!1),[E,C]=u.useState(!1),[S,w]=u.useState(!1),b=u.useRef(null),{data:k,isLoading:p,refetch:v}=ie({queryKey:["pluginList"],queryFn:async()=>{const{data:R}=await ws.getPluginList();return R}});k&&[...new Set(k.map(R=>R.category||"other"))];const M=k?.filter(R=>{const X=R.name.toLowerCase().includes(d.toLowerCase())||R.description.toLowerCase().includes(d.toLowerCase())||R.code.toLowerCase().includes(d.toLowerCase()),_s=o==="all"||R.category===o;return X&&_s}),U=async R=>{t(R),ws.installPlugin(R).then(()=>{$.success(s("messages.installSuccess")),v()}).catch(X=>{$.error(X.message||s("messages.installError"))}).finally(()=>{t(null)})},se=async R=>{t(R),ws.uninstallPlugin(R).then(()=>{$.success(s("messages.uninstallSuccess")),v()}).catch(X=>{$.error(X.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},L=async(R,X)=>{t(R),(X?ws.disablePlugin:ws.enablePlugin)(R).then(()=>{$.success(s(X?"messages.disableSuccess":"messages.enableSuccess")),v()}).catch(Te=>{$.error(Te.message||s(X?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},Z=R=>{k?.find(X=>X.code===R),l(R),a(!0)},de=async R=>{if(!R.name.endsWith(".zip")){$.error(s("upload.error.format"));return}_(!0),ws.uploadPlugin(R).then(()=>{$.success(s("messages.uploadSuccess")),C(!1),v()}).catch(X=>{$.error(X.message||s("messages.uploadError"))}).finally(()=>{_(!1),b.current&&(b.current.value="")})},Q=R=>{R.preventDefault(),R.stopPropagation(),R.type==="dragenter"||R.type==="dragover"?w(!0):R.type==="dragleave"&&w(!1)},te=R=>{R.preventDefault(),R.stopPropagation(),w(!1),R.dataTransfer.files&&R.dataTransfer.files[0]&&de(R.dataTransfer.files[0])},A=async R=>{t(R),ws.deletePlugin(R).then(()=>{$.success(s("messages.deleteSuccess")),v()}).catch(X=>{$.error(X.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ka,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(An,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:d,onChange:R=>m(R.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(P,{onClick:()=>C(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Gt,{defaultValue:"all",className:"w-full",children:[e.jsxs(vt,{children:[e.jsx(qe,{value:"all",children:s("tabs.all")}),e.jsx(qe,{value:"installed",children:s("tabs.installed")}),e.jsx(qe,{value:"available",children:s("tabs.available")})]}),e.jsx(ps,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:p?e.jsxs(e.Fragment,{children:[e.jsx(oa,{}),e.jsx(oa,{}),e.jsx(oa,{})]}):M?.map(R=>e.jsx(ia,{plugin:R,onInstall:U,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:A,isLoading:n===R.name},R.name))})}),e.jsx(ps,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M?.filter(R=>R.is_installed).map(R=>e.jsx(ia,{plugin:R,onInstall:U,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:A,isLoading:n===R.name},R.name))})}),e.jsx(ps,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M?.filter(R=>!R.is_installed).map(R=>e.jsx(ia,{plugin:R,onInstall:U,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:A,isLoading:n===R.name},R.code))})})]})]}),e.jsx(_e,{open:r,onOpenChange:a,children:e.jsxs(ve,{className:"sm:max-w-lg",children:[e.jsxs(Se,{children:[e.jsxs(we,{children:[k?.find(R=>R.code===i)?.name," ",s("config.title")]}),e.jsx(Pe,{children:s("config.description")})]}),i&&e.jsx(wm,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),v()}})]})}),e.jsx(_e,{open:E,onOpenChange:C,children:e.jsxs(ve,{className:"sm:max-w-md",children:[e.jsxs(Se,{children:[e.jsx(we,{children:s("upload.title")}),e.jsx(Pe,{children:s("upload.description")})]}),e.jsxs("div",{className:N("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",S&&"border-primary/50 bg-muted/50"),onDragEnter:Q,onDragLeave:Q,onDragOver:Q,onDrop:te,children:[e.jsx("input",{type:"file",ref:b,className:"hidden",accept:".zip",onChange:R=>{const X=R.target.files?.[0];X&&de(X)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(pt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>b.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function ia({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l}){const{t:d}=V("plugin");return e.jsxs(We,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(es,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{children:s.name}),s.is_installed&&e.jsx(q,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?d("status.enabled"):d("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ka,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[d("author"),": ",s.author]})})]})})]}),e.jsx(ss,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(Eo,{className:"mr-2 h-4 w-4"}),d("button.config")]}),e.jsxs(P,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(Ro,{className:"mr-2 h-4 w-4"}),s.is_enabled?d("button.disable"):d("button.enable")]}),e.jsx(Qe,{title:d("uninstall.title"),description:d("uninstall.description"),cancelText:d("common:cancel"),confirmText:d("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(P,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(cs,{className:"mr-2 h-4 w-4"}),d("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{onClick:()=>n(s.code),disabled:l,loading:l,children:d("button.install")}),e.jsx(Qe,{title:d("delete.title"),description:d("delete.description"),cancelText:d("common:cancel"),confirmText:d("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(P,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(cs,{className:"h-4 w-4"})})})]})})})]})}function oa(){return e.jsxs(We,{children:[e.jsxs(es,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-6 w-[200px]"}),e.jsx(oe,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(oe,{className:"h-5 w-[120px]"}),e.jsx(oe,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(oe,{className:"h-4 w-[300px]"}),e.jsx(oe,{className:"h-4 w-[150px]"})]})]}),e.jsx(ss,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(oe,{className:"h-9 w-[100px]"}),e.jsx(oe,{className:"h-9 w-[100px]"}),e.jsx(oe,{className:"h-8 w-8"})]})})]})}const Sm=Object.freeze(Object.defineProperty({__proto__:null,default:Cm},Symbol.toStringTag,{value:"Module"})),km=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(D,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(Ns,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:N(st({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Tm({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=u.useState(!1),[i,l]=u.useState(!1),[d,m]=u.useState(!1),o=fe({defaultValues:n.configs.reduce((_,E)=>(_[E.field_name]="",_),{})}),c=async()=>{l(!0),Nc(s).then(({data:_})=>{Object.entries(_).forEach(([E,C])=>{o.setValue(E,C)})}).finally(()=>{l(!1)})},h=async _=>{m(!0),_c(s,_).then(()=>{$.success(t("config.success")),a(!1)}).finally(()=>{m(!1)})};return e.jsxs(_e,{open:r,onOpenChange:_=>{a(_),_?c():o.reset()},children:[e.jsx(Je,{asChild:!0,children:e.jsx(P,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(ve,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(Se,{children:[e.jsx(we,{children:t("config.title",{name:n.name})}),e.jsx(Pe,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})}):e.jsx(ye,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(h),className:"space-y-4",children:[n.configs.map(_=>e.jsx(g,{control:o.control,name:_.field_name,render:({field:E})=>e.jsxs(f,{children:[e.jsx(j,{children:_.label}),e.jsx(y,{children:km(_,E)}),e.jsx(T,{})]})},_.field_name)),e.jsxs(Ke,{className:"mt-6 gap-2",children:[e.jsx(P,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(P,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function Dm(){const{t:s}=V("theme"),[n,t]=u.useState(null),[r,a]=u.useState(!1),[i,l]=u.useState(!1),[d,m]=u.useState(!1),[o,c]=u.useState(null),h=u.useRef(null),[_,E]=u.useState(0),{data:C,isLoading:S,refetch:w}=ie({queryKey:["themeList"],queryFn:async()=>{const{data:L}=await yc();return L}}),b=async L=>{t(L),Sc({frontend_theme:L}).then(()=>{$.success("主题切换成功"),w()}).finally(()=>{t(null)})},k=async L=>{if(!L.name.endsWith(".zip")){$.error(s("upload.error.format"));return}a(!0),wc(L).then(()=>{$.success("主题上传成功"),l(!1),w()}).finally(()=>{a(!1),h.current&&(h.current.value="")})},p=L=>{L.preventDefault(),L.stopPropagation(),L.type==="dragenter"||L.type==="dragover"?m(!0):L.type==="dragleave"&&m(!1)},v=L=>{L.preventDefault(),L.stopPropagation(),m(!1),L.dataTransfer.files&&L.dataTransfer.files[0]&&k(L.dataTransfer.files[0])},M=()=>{o&&E(L=>L===0?o.images.length-1:L-1)},U=()=>{o&&E(L=>L===o.images.length-1?0:L+1)},se=(L,Z)=>{E(0),c({name:L,images:Z})};return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Be,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(P,{onClick:()=>l(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:S?e.jsxs(e.Fragment,{children:[e.jsx(cn,{}),e.jsx(cn,{})]}):C?.themes&&Object.entries(C.themes).map(([L,Z])=>e.jsx(We,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:Z.background_url?`url(${Z.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:N("relative z-10 h-full transition-colors",Z.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!Z.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Qe,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(L===C?.active){$.error(s("card.delete.error.active"));return}t(L),Cc(L).then(()=>{$.success("主题删除成功"),w()}).finally(()=>{t(null)})},children:e.jsx(P,{disabled:n===L,loading:n===L,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(es,{children:[e.jsx(Cs,{children:Z.name}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:Z.description}),Z.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:Z.version})})]})})]}),e.jsxs(ss,{className:"flex items-center justify-end space-x-3",children:[Z.images&&Array.isArray(Z.images)&&Z.images.length>0&&e.jsx(P,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>se(Z.name,Z.images),children:e.jsx(Io,{className:"h-4 w-4"})}),e.jsx(Tm,{themeKey:L,themeInfo:Z}),e.jsx(P,{onClick:()=>b(L),disabled:n===L||L===C.active,loading:n===L,variant:L===C.active?"secondary":"default",children:L===C.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},L))}),e.jsx(_e,{open:i,onOpenChange:l,children:e.jsxs(ve,{className:"sm:max-w-md",children:[e.jsxs(Se,{children:[e.jsx(we,{children:s("upload.title")}),e.jsx(Pe,{children:s("upload.description")})]}),e.jsxs("div",{className:N("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",d&&"border-primary/50 bg-muted/50"),onDragEnter:p,onDragLeave:p,onDragOver:p,onDrop:v,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:L=>{const Z=L.target.files?.[0];Z&&k(Z)}}),r?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(pt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(_e,{open:!!o,onOpenChange:L=>{L||(c(null),E(0))},children:e.jsxs(ve,{className:"max-w-4xl",children:[e.jsxs(Se,{children:[e.jsxs(we,{children:[o?.name," ",s("preview.title")]}),e.jsx(Pe,{className:"text-center",children:o&&s("preview.imageCount",{current:_+1,total:o.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:o?.images[_]&&e.jsx("img",{src:o.images[_],alt:`${o.name} 预览图 ${_+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:M,children:e.jsx(Vo,{className:"h-4 w-4"})}),e.jsx(P,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:U,children:e.jsx(Mo,{className:"h-4 w-4"})})]})]}),o&&o.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:o.images.map((L,Z)=>e.jsx("button",{onClick:()=>E(Z),className:N("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",_===Z?"border-primary":"border-transparent"),children:e.jsx("img",{src:L,alt:`缩略图 ${Z+1}`,className:"h-full w-full object-cover"})},Z))})]})})]})]})}function cn(){return e.jsxs(We,{children:[e.jsxs(es,{children:[e.jsx(oe,{className:"h-6 w-[200px]"}),e.jsx(oe,{className:"h-4 w-[300px]"})]}),e.jsxs(ss,{className:"flex items-center justify-end space-x-3",children:[e.jsx(oe,{className:"h-10 w-[100px]"}),e.jsx(oe,{className:"h-10 w-[100px]"})]})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:Dm},Symbol.toStringTag,{value:"Module"})),La=u.forwardRef(({className:s,value:n,onChange:t,...r},a)=>{const[i,l]=u.useState("");u.useEffect(()=>{if(i.includes(",")){const m=new Set([...n,...i.split(",").map(o=>o.trim())]);t(Array.from(m)),l("")}},[i,t,n]);const d=()=>{if(i){const m=new Set([...n,i]);t(Array.from(m)),l("")}};return e.jsxs("div",{className:N(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(m=>e.jsxs(q,{variant:"secondary",children:[m,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(o=>o!==m))},children:e.jsx(ga,{className:"w-3"})})]},m)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d()):m.key==="Backspace"&&i.length===0&&n.length>0&&(m.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});La.displayName="InputTags";const Em=x.object({id:x.number().nullable(),title:x.string().min(1).max(250),content:x.string().min(1),show:x.boolean(),tags:x.array(x.string()),img_url:x.string().nullable()}),Rm={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Wr({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Rm}){const{t:a}=V("notice"),[i,l]=u.useState(!1),d=fe({resolver:be(Em),defaultValues:r,mode:"onChange",shouldFocusError:!0}),m=new Pa({html:!0});return e.jsx(ye,{...d,children:e.jsxs(_e,{onOpenChange:l,open:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(ve,{className:"sm:max-w-[1025px]",children:[e.jsxs(Se,{children:[e.jsx(we,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Pe,{})]}),e.jsx(g,{control:d.control,name:"title",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(D,{placeholder:a("form.fields.title.placeholder"),...o})})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"content",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.content.label")}),e.jsx(y,{children:e.jsx(Ea,{style:{height:"500px"},value:o.value,renderHTML:c=>m.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"img_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(D,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"tags",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.tags.label")}),e.jsx(y,{children:e.jsx(La,{value:o.value,onChange:o.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(T,{})]})}),e.jsxs(Ke,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",onClick:o=>{o.preventDefault(),d.handleSubmit(async c=>{Uc(c).then(({data:h})=>{h&&($.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function Im({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("notice"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!r&&e.jsx(Wr,{refetch:n}),!r&&e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),i&&!r&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(Ze,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const Vm=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Fo,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(q,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Y,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await Kc({id:t.original.id});r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Wr,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:t.original}),e.jsx(Qe,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{qc({id:t.original.id}).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function Mm(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState(!1),[c,h]=u.useState({}),[_,E]=u.useState({pageSize:50,pageIndex:0}),[C,S]=u.useState([]),{refetch:w}=ie({queryKey:["notices"],queryFn:async()=>{const{data:M}=await rn.getList();return S(M),M}});u.useEffect(()=>{r({"drag-handle":m,content:!m,created_at:!m,actions:!m}),E({pageSize:m?99999:50,pageIndex:0})},[m]);const b=(M,U)=>{m&&(M.dataTransfer.setData("text/plain",U.toString()),M.currentTarget.classList.add("opacity-50"))},k=(M,U)=>{if(!m)return;M.preventDefault(),M.currentTarget.classList.remove("bg-muted");const se=parseInt(M.dataTransfer.getData("text/plain"));if(se===U)return;const L=[...C],[Z]=L.splice(se,1);L.splice(U,0,Z),S(L)},p=async()=>{if(!m){o(!0);return}rn.sort(C.map(M=>M.id)).then(()=>{$.success("排序保存成功"),o(!1),w()}).finally(()=>{o(!1)})},v=ts({data:C??[],columns:Vm(w),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:c,pagination:_},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:h,onPaginationChange:E,getCoreRowModel:as(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:v,toolbar:M=>e.jsx(Im,{table:M,refetch:w,saveOrder:p,isSortMode:m}),draggable:m,onDragStart:b,onDragEnd:M=>M.currentTarget.classList.remove("opacity-50"),onDragOver:M=>{M.preventDefault(),M.currentTarget.classList.add("bg-muted")},onDragLeave:M=>M.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!m})})}function Fm(){const{t:s}=V("notice");return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Be,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Mm,{})})]})]})}const Om=Object.freeze(Object.defineProperty({__proto__:null,default:Fm},Symbol.toStringTag,{value:"Module"})),Lm=x.object({id:x.number().nullable(),language:x.string().max(250),category:x.string().max(250),title:x.string().min(1).max(250),body:x.string().min(1),show:x.boolean()}),zm={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Yr({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=zm}){const{t:a}=V("knowledge"),[i,l]=u.useState(!1),d=fe({resolver:be(Lm),defaultValues:r,mode:"onChange",shouldFocusError:!0}),m=new Pa({html:!0});return u.useEffect(()=>{i&&r.id&&Gc(r.id).then(({data:o})=>{d.reset(o)})},[r.id,d,i]),e.jsxs(_e,{onOpenChange:l,open:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(ve,{className:"sm:max-w-[1025px]",children:[e.jsxs(Se,{children:[e.jsx(we,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Pe,{})]}),e.jsxs(ye,{...d,children:[e.jsx(g,{control:d.control,name:"title",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(D,{placeholder:a("form.titlePlaceholder"),...o})})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"category",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(D,{placeholder:a("form.categoryPlaceholder"),...o})})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"language",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.language")}),e.jsx(y,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(c=>e.jsx(z,{value:c.value,className:"cursor-pointer",children:a(`languages.${c.value}`)},c.value))})]})})]})}),e.jsx(g,{control:d.control,name:"body",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.content")}),e.jsx(y,{children:e.jsx(Ea,{style:{height:"500px"},value:o.value,renderHTML:c=>m.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(T,{})]})}),e.jsxs(Ke,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{d.handleSubmit(o=>{Wc(o).then(({data:c})=>{c&&(d.reset(),$.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function Am({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(qs,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Ks,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(As,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(lt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function $m({table:s,refetch:n,saveOrder:t,isSortMode:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yr,{refreshData:n}),e.jsx(D,{placeholder:i("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(Am,{column:s.getColumn("category"),title:i("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(Ze,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const Hm=({refetch:s,isSortMode:n=!1})=>{const{t}=V("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ut,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(q,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Y,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Qc({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.title")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:r.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(q,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Yr,{refreshData:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(Qe,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Yc({id:r.original.id}).then(({data:a})=>{a&&($.success(t("messages.operationSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function Um(){const[s,n]=u.useState([]),[t,r]=u.useState([]),[a,i]=u.useState(!1),[l,d]=u.useState([]),[m,o]=u.useState({"drag-handle":!1}),[c,h]=u.useState({pageSize:20,pageIndex:0}),{refetch:_,isLoading:E,data:C}=ie({queryKey:["knowledge"],queryFn:async()=>{const{data:p}=await Bc();return d(p||[]),p}});u.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const S=(p,v)=>{a&&(p.dataTransfer.setData("text/plain",v.toString()),p.currentTarget.classList.add("opacity-50"))},w=(p,v)=>{if(!a)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const M=parseInt(p.dataTransfer.getData("text/plain"));if(M===v)return;const U=[...l],[se]=U.splice(M,1);U.splice(v,0,se),d(U)},b=async()=>{a?Jc({ids:l.map(p=>p.id)}).then(()=>{_(),i(!1),$.success("排序保存成功")}):i(!0)},k=ts({data:l,columns:Hm({refetch:_,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:m,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,onPaginationChange:h,getCoreRowModel:as(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:k,toolbar:p=>e.jsx($m,{table:p,refetch:_,saveOrder:b,isSortMode:a}),draggable:a,onDragStart:S,onDragEnd:p=>p.currentTarget.classList.remove("opacity-50"),onDragOver:p=>{p.preventDefault(),p.currentTarget.classList.add("bg-muted")},onDragLeave:p=>p.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!a})}function qm(){const{t:s}=V("knowledge");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Be,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Um,{})})]})]})}const Km=Object.freeze(Object.defineProperty({__proto__:null,default:qm},Symbol.toStringTag,{value:"Module"}));function Bm(s,n){const[t,r]=u.useState(s);return u.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function ca(s,n){if(s.length===0)return{};if(!n)return{"":s};const t={};return s.forEach(r=>{const a=r[n]||"";t[a]||(t[a]=[]),t[a].push(r)}),t}function Gm(s,n){const t=JSON.parse(JSON.stringify(s));for(const[r,a]of Object.entries(t))t[r]=a.filter(i=>!n.find(l=>l.value===i.value));return t}function Wm(s,n){for(const[,t]of Object.entries(s))if(t.some(r=>n.find(a=>a.value===r.value)))return!0;return!1}const Qr=u.forwardRef(({className:s,...n},t)=>Oo(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:N("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Qr.displayName="CommandEmpty";const nt=u.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:m,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:c,hidePlaceholderWhenSelected:h,disabled:_,groupBy:E,className:C,badgeClassName:S,selectFirstItem:w=!0,creatable:b=!1,triggerSearchOnFocus:k=!1,commandProps:p,inputProps:v,hideClearAllButton:M=!1},U)=>{const se=u.useRef(null),[L,Z]=u.useState(!1),de=u.useRef(!1),[Q,te]=u.useState(!1),[A,R]=u.useState(s||[]),[X,_s]=u.useState(ca(r,E)),[Te,ne]=u.useState(""),Os=Bm(Te,i||500);u.useImperativeHandle(U,()=>({selectedValue:[...A],input:se.current,focus:()=>se.current?.focus()}),[A]);const Gs=u.useCallback(ee=>{const ue=A.filter($e=>$e.value!==ee.value);R(ue),n?.(ue)},[n,A]),bl=u.useCallback(ee=>{const ue=se.current;ue&&((ee.key==="Delete"||ee.key==="Backspace")&&ue.value===""&&A.length>0&&(A[A.length-1].fixed||Gs(A[A.length-1])),ee.key==="Escape"&&ue.blur())},[Gs,A]);u.useEffect(()=>{s&&R(s)},[s]),u.useEffect(()=>{if(!a||l)return;const ee=ca(a||[],E);JSON.stringify(ee)!==JSON.stringify(X)&&_s(ee)},[r,a,E,l,X]),u.useEffect(()=>{const ee=async()=>{te(!0);const $e=await l?.(Os);_s(ca($e||[],E)),te(!1)};(async()=>{!l||!L||(k&&await ee(),Os&&await ee())})()},[Os,E,L,k]);const yl=()=>{if(!b||Wm(X,[{value:Te,label:Te}])||A.find(ue=>ue.value===Te))return;const ee=e.jsx(Me,{value:Te,className:"cursor-pointer",onMouseDown:ue=>{ue.preventDefault(),ue.stopPropagation()},onSelect:ue=>{if(A.length>=o){c?.(A.length);return}ne("");const $e=[...A,{value:ue,label:ue}];R($e),n?.($e)},children:`Create "${Te}"`});if(!l&&Te.length>0||l&&Os.length>0&&!Q)return ee},Nl=u.useCallback(()=>{if(m)return l&&!b&&Object.keys(X).length===0?e.jsx(Me,{value:"-",disabled:!0,children:m}):e.jsx(Qr,{children:m})},[b,m,l,X]),_l=u.useMemo(()=>Gm(X,A),[X,A]),wl=u.useCallback(()=>{if(p?.filter)return p.filter;if(b)return(ee,ue)=>ee.toLowerCase().includes(ue.toLowerCase())?1:-1},[b,p?.filter]),Cl=u.useCallback(()=>{const ee=A.filter(ue=>ue.fixed);R(ee),n?.(ee)},[n,A]);return e.jsxs(Ms,{...p,onKeyDown:ee=>{bl(ee),p?.onKeyDown?.(ee)},className:N("h-auto overflow-visible bg-transparent",p?.className),shouldFilter:p?.shouldFilter!==void 0?p.shouldFilter:!l,filter:wl(),children:[e.jsx("div",{className:N("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":A.length!==0,"cursor-text":!_&&A.length!==0},C),onClick:()=>{_||se.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[A.map(ee=>e.jsxs(q,{className:N("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",S),"data-fixed":ee.fixed,"data-disabled":_||void 0,children:[ee.label,e.jsx("button",{className:N("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(_||ee.fixed)&&"hidden"),onKeyDown:ue=>{ue.key==="Enter"&&Gs(ee)},onMouseDown:ue=>{ue.preventDefault(),ue.stopPropagation()},onClick:()=>Gs(ee),children:e.jsx(ga,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},ee.value)),e.jsx(Le.Input,{...v,ref:se,value:Te,disabled:_,onValueChange:ee=>{ne(ee),v?.onValueChange?.(ee)},onBlur:ee=>{de.current===!1&&Z(!1),v?.onBlur?.(ee)},onFocus:ee=>{Z(!0),k&&l?.(Os),v?.onFocus?.(ee)},placeholder:h&&A.length!==0?"":t,className:N("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":A.length===0,"ml-1":A.length!==0},v?.className)}),e.jsx("button",{type:"button",onClick:Cl,className:N((M||_||A.length<1||A.filter(ee=>ee.fixed).length===A.length)&&"hidden"),children:e.jsx(ga,{})})]})}),e.jsx("div",{className:"relative",children:L&&e.jsx(Fs,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{de.current=!1},onMouseEnter:()=>{de.current=!0},onMouseUp:()=>{se.current?.focus()},children:Q?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Nl(),yl(),!w&&e.jsx(Me,{value:"-",className:"hidden"}),Object.entries(_l).map(([ee,ue])=>e.jsx(Ye,{heading:ee,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ue.map($e=>e.jsx(Me,{value:$e.value,disabled:$e.disable,onMouseDown:it=>{it.preventDefault(),it.stopPropagation()},onSelect:()=>{if(A.length>=o){c?.(A.length);return}ne("");const it=[...A,$e];R(it),n?.(it)},className:N("cursor-pointer",$e.disable&&"cursor-default text-muted-foreground"),children:$e.label},$e.value))})},ee))]})})})]})});nt.displayName="MultipleSelector";const Ym=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function ta({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),i=fe({resolver:be(Ym(a)),defaultValues:t,mode:"onChange"}),[l,d]=u.useState(!1),[m,o]=u.useState(!1),c=async h=>{o(!0),Rc(h).then(()=>{$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{o(!1)})};return e.jsxs(_e,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(ve,{className:"sm:max-w-[425px]",children:[e.jsxs(Se,{children:[e.jsx(we,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Pe,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(ye,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(g,{control:i.control,name:"name",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.name")}),e.jsx(y,{children:e.jsx(D,{placeholder:a("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(F,{children:a("form.nameDescription")}),e.jsx(T,{})]})}),e.jsxs(Ke,{className:"gap-2",children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(P,{type:"submit",disabled:m||!i.formState.isValid,children:[m&&e.jsx(Da,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Jr=u.createContext(void 0);function Qm({children:s,refetch:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null),[l,d]=u.useState(re.Shadowsocks);return e.jsx(Jr.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function Xr(){const s=u.useContext(Jr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function da({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=V("server");u.useEffect(()=>{console.log(n)},[n]);const[i,l]=u.useState(!1),[d,m]=u.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,c]=u.useState(null),h=b=>{if(!b)return null;try{const k=JSON.parse(b);return typeof k!="object"||k===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},_={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},E=()=>{switch(r){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},C=()=>{const b=h(d||"");if(b){$.error(b);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{$.error(a("network_settings.errors.save_failed"))}},S=b=>{m(b),c(h(b))},w=b=>{const k=_[b];if(k){const p=JSON.stringify(k.content,null,2);m(p),c(null)}};return u.useEffect(()=>{i&&console.log(n)},[i,n]),u.useEffect(()=>{i&&n&&Object.keys(n).length>0&&m(JSON.stringify(n,null,2))},[i,n]),e.jsxs(_e,{open:i,onOpenChange:b=>{!b&&i&&C(),l(b)},children:[e.jsx(Je,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(ve,{className:"sm:max-w-[425px]",children:[e.jsx(Se,{children:e.jsx(we,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[E().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:E().map(b=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>w(b),children:a("network_settings.use_template",{template:_[b].label})},b))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ns,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:E().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:b=>S(b.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Ke,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(J,{onClick:C,disabled:!!o,children:a("common.confirm")})]})]})]})}function up(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const Jm={},Xm=Object.freeze(Object.defineProperty({__proto__:null,default:Jm},Symbol.toStringTag,{value:"Module"})),mp=Jo(Xm),dn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Zm=()=>{try{const s=Lo.box.keyPair(),n=dn(Ja.encodeBase64(s.secretKey)),t=dn(Ja.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},ex=()=>{try{return Zm()}catch(s){throw console.error("Error generating key pair:",s),s}},sx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},tx=()=>{const s=Math.floor(Math.random()*8)*2+2;return sx(s)},ax=x.object({cipher:x.string().default("aes-128-gcm"),obfs:x.string().default("0"),obfs_settings:x.object({path:x.string().default(""),host:x.string().default("")}).default({})}),nx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),rx=x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),lx=x.object({version:x.coerce.number().default(2),alpn:x.string().default("h2"),obfs:x.object({open:x.coerce.boolean().default(!1),type:x.string().default("salamander"),password:x.string().default("")}).default({}),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),bandwidth:x.object({up:x.string().default(""),down:x.string().default("")}).default({})}),ix=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),reality_settings:x.object({server_port:x.coerce.number().default(443),server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),public_key:x.string().default(""),private_key:x.string().default(""),short_id:x.string().default("")}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({}),flow:x.string().default("")}),ox=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),cx=x.object({}),dx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),ux=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),mx=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),Ie={shadowsocks:{schema:ax,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]},vmess:{schema:nx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:rx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:lx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:ix,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:ox,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:cx},naive:{schema:ux},http:{schema:dx},mieru:{schema:mx,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]}},xx=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Ie[s]:null,i=a?.schema||x.record(x.any()),l=s?i.parse({}):{},d=fe({resolver:be(i),defaultValues:l,mode:"onChange"});if(u.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const p=i.parse({});d.reset(p)}}else d.reset(n)},[s,n,t,d,i]),u.useEffect(()=>{const p=d.watch(v=>{t(v)});return()=>p.unsubscribe()},[d,t]),!s||!a)return null;const k={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"cipher",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.shadowsocks.ciphers.map(v=>e.jsx(z,{value:v,children:v},v))})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.obfs.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(He,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.shadowsocks.obfs.none")}),e.jsx(z,{value:"http",children:r("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),d.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs_settings.path",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(y,{children:e.jsx(D,{type:"text",placeholder:r("dynamic_form.shadowsocks.obfs_settings.path"),...p})}),e.jsx(T,{})]})}),e.jsx(g,{control:d.control,name:"obfs_settings.host",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(y,{children:e.jsx(D,{type:"text",placeholder:r("dynamic_form.shadowsocks.obfs_settings.host"),...p})}),e.jsx(T,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.vmess.network.label"),e.jsx(da,{value:d.watch("network_settings"),setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.vmess.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(g,{control:d.control,name:"allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.trojan.network.label"),e.jsx(da,{value:d.watch("network_settings")||{},setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")||"tcp"})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value||"tcp",children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.trojan.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"version",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(y,{children:e.jsxs(G,{value:(p.value||2).toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.hysteria.versions.map(v=>e.jsxs(z,{value:v,className:"cursor-pointer",children:["V",v]},v))})})]})})]})}),d.watch("version")==1&&e.jsx(g,{control:d.control,name:"alpn",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value||"h2",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.hysteria.alpnOptions.map(v=>e.jsx(z,{value:v,children:v},v))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs.open",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(g,{control:d.control,name:"obfs.type",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value||"salamander",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:e.jsx(z,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs.password",render:({field:p})=>e.jsxs(f,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...p,value:p.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",M=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(U=>v[U%v.length]).join("");d.setValue("obfs.password",M),$.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"bandwidth.up",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:r("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(g,{control:d.control,name:"bandwidth.down",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:r("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(z,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(z,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"reality_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.server_port",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(g,{control:d.control,name:"reality_settings.private_key",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(D,{...p,className:"pr-9"})}),e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const v=ex();d.setValue("reality_settings.private_key",v.privateKey),d.setValue("reality_settings.public_key",v.publicKey),$.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(It,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(g,{control:d.control,name:"reality_settings.public_key",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(y,{children:e.jsx(D,{...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.short_id",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(D,{...p,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const v=tx();d.setValue("reality_settings.short_id",v),$.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(It,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.vless.network.label"),e.jsx(da,{value:d.watch("network_settings"),setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.vless.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"flow",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.flow.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:v=>p.onChange(v==="none"?null:v),value:p.value||"none",children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:Ie.vless.flowOptions.map(v=>e.jsx(z,{value:v,children:v},v))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"version",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.version.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.versions.map(v=>e.jsxs(z,{value:v,children:["V",v]},v))})})]})})]})}),e.jsx(g,{control:d.control,name:"congestion_control",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.congestionControls.map(v=>e.jsx(z,{value:v,children:v.toUpperCase()},v))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"alpn",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(y,{children:e.jsx(nt,{options:Ie.tuic.alpnOptions,onChange:v=>p.onChange(v.map(M=>M.value)),value:Ie.tuic.alpnOptions.filter(v=>p.value?.includes(v.value)),placeholder:r("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:r("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(g,{control:d.control,name:"udp_relay_mode",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.udpRelayModes.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.http.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"transport",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.mieru.transportOptions.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"multiplexing",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.mieru.multiplexingOptions.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})})]})};return e.jsx(je,{children:k[s]?.()})},hx=x.object({id:x.number().optional().nullable(),code:x.string().optional(),name:x.string().min(1,"form.name.error"),rate:x.string().min(1,"form.rate.error"),tags:x.array(x.string()).default([]),excludes:x.array(x.string()).default([]),ips:x.array(x.string()).default([]),group_ids:x.array(x.string()).default([]),host:x.string().min(1,"form.host.error"),port:x.string().min(1,"form.port.error"),server_port:x.string().min(1,"form.server_port.error"),parent_id:x.string().default("0").nullable(),route_ids:x.array(x.string()).default([]),protocol_settings:x.record(x.any()).default({}).nullable()}),wt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function px(){const{t:s}=V("server"),{isOpen:n,setIsOpen:t,editingServer:r,setEditingServer:a,serverType:i,setServerType:l,refetch:d}=Xr(),[m,o]=u.useState([]),[c,h]=u.useState([]),[_,E]=u.useState([]),C=fe({resolver:be(hx),defaultValues:wt,mode:"onChange"});u.useEffect(()=>{S()},[n]),u.useEffect(()=>{r?.type&&r.type!==i&&l(r.type)},[r,i,l]),u.useEffect(()=>{r?r.type===i&&C.reset({...wt,...r}):C.reset({...wt,protocol_settings:Ie[i].schema.parse({})})},[r,C,i]);const S=async()=>{if(!n)return;const[v,M,U]=await Promise.all([bt(),Sr(),Cr()]);o(v.data?.map(se=>({label:se.name,value:se.id.toString()}))||[]),h(M.data?.map(se=>({label:se.remarks,value:se.id.toString()}))||[]),E(U.data||[])},w=u.useMemo(()=>_?.filter(v=>(v.parent_id===0||v.parent_id===null)&&v.type===i&&v.id!==C.watch("id")),[i,_,C]),b=()=>e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(gs,{align:"start",children:e.jsx(Od,{children:Xe.map(({type:v,label:M})=>e.jsx(ge,{onClick:()=>{l(v),t(!0)},className:"cursor-pointer",children:e.jsx(q,{variant:"outline",className:"text-white",style:{background:Ue[v]},children:M})},v))})})]}),k=()=>{t(!1),a(null),C.reset(wt)},p=async()=>{const v=C.getValues();(await kc({...v,type:i})).data&&(k(),$.success(s("form.success")),d())};return e.jsxs(_e,{open:n,onOpenChange:k,children:[b(),e.jsxs(ve,{className:"sm:max-w-[425px]",children:[e.jsxs(Se,{children:[e.jsx(we,{children:s(r?"form.edit_node":"form.new_node")}),e.jsx(Pe,{})]}),e.jsxs(ye,{...C,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:C.control,name:"name",render:({field:v})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:s("form.name.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...v})}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"rate",render:({field:v})=>e.jsxs(f,{className:"flex-[1]",children:[e.jsx(j,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(y,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...v})})}),e.jsx(T,{})]})})]}),e.jsx(g,{control:C.control,name:"code",render:({field:v})=>e.jsxs(f,{children:[e.jsxs(j,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(y,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...v,value:v.value||""})}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"tags",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.tags.label")}),e.jsx(y,{children:e.jsx(La,{value:v.value,onChange:v.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"group_ids",render:({field:v})=>e.jsxs(f,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(ta,{dialogTrigger:e.jsx(P,{variant:"link",children:s("form.groups.add")}),refetch:S})]}),e.jsx(y,{children:e.jsx(nt,{options:m,onChange:M=>v.onChange(M.map(U=>U.value)),value:m?.filter(M=>v.value.includes(M.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(T,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"host",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.host.label")}),e.jsx(y,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...v})}),e.jsx(T,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(g,{control:C.control,name:"port",render:({field:v})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(It,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...v})}),e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const M=v.value;M&&C.setValue("server_port",M)},children:e.jsx(Ve,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ce,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"server_port",render:({field:v})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(It,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(y,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...v})}),e.jsx(T,{})]})})]})]}),n&&e.jsx(xx,{serverType:i,value:C.watch("protocol_settings"),onChange:v=>C.setValue("protocol_settings",v,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(g,{control:C.control,name:"parent_id",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.parent.label")}),e.jsxs(G,{onValueChange:v.onChange,value:v.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("form.parent.none")}),w?.map(M=>e.jsx(z,{value:M.id.toString(),className:"cursor-pointer",children:M.name},M.id))]})]}),e.jsx(T,{})]})}),e.jsx(g,{control:C.control,name:"route_ids",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.route.label")}),e.jsx(y,{children:e.jsx(nt,{options:c,onChange:M=>v.onChange(M.map(U=>U.value)),value:c?.filter(M=>v.value.includes(M.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(T,{})]})})]}),e.jsxs(Ke,{className:"mt-6",children:[e.jsx(P,{type:"button",variant:"outline",onClick:k,children:s("form.cancel")}),e.jsx(P,{type:"submit",onClick:p,children:s("form.submit")})]})]})]})]})}function un({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(bs,{children:[e.jsx(ys,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(qs,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Ks,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(As,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(lt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const fx=[{value:re.Shadowsocks,label:Xe.find(s=>s.type===re.Shadowsocks)?.label,color:Ue[re.Shadowsocks]},{value:re.Vmess,label:Xe.find(s=>s.type===re.Vmess)?.label,color:Ue[re.Vmess]},{value:re.Trojan,label:Xe.find(s=>s.type===re.Trojan)?.label,color:Ue[re.Trojan]},{value:re.Hysteria,label:Xe.find(s=>s.type===re.Hysteria)?.label,color:Ue[re.Hysteria]},{value:re.Vless,label:Xe.find(s=>s.type===re.Vless)?.label,color:Ue[re.Vless]},{value:re.Tuic,label:Xe.find(s=>s.type===re.Tuic)?.label,color:Ue[re.Tuic]},{value:re.Socks,label:Xe.find(s=>s.type===re.Socks)?.label,color:Ue[re.Socks]},{value:re.Naive,label:Xe.find(s=>s.type===re.Naive)?.label,color:Ue[re.Naive]},{value:re.Http,label:Xe.find(s=>s.type===re.Http)?.label,color:Ue[re.Http]},{value:re.Mieru,label:Xe.find(s=>s.type===re.Mieru)?.label,color:Ue[re.Mieru]}];function gx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("server");return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(px,{}),e.jsx(D,{placeholder:i("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(un,{column:s.getColumn("type"),title:i("toolbar.type"),options:fx}),s.getColumn("group_ids")&&e.jsx(un,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(Ze,{className:"ml-2 h-4 w-4"})]})]}),t&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const gt=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),Ct={0:"bg-destructive/80 shadow-sm shadow-destructive/50",1:"bg-yellow-500/80 shadow-sm shadow-yellow-500/50",2:"bg-emerald-500/80 shadow-sm shadow-emerald-500/50"},jx=s=>{const{t:n}=V("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ut,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(q,{variant:"outline",className:N("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:Ue[t.original.type]},children:[e.jsx(ur,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:a??r}),t.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:t.original.parent?.code||t.original.parent?.id})]}):""]})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:i=>{i.stopPropagation(),Ft(a||r.toString()).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(Xa,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Xe.find(i=>i.type===t.original.type)?.label,t.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=u.useState(!!t.getValue("show"));return e.jsx(Y,{checked:r,onCheckedChange:async i=>{a(i),Pc({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?Ue[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:t,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[0])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.0")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[1])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.1")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(je,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",Ct[t.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:t.getValue("name")})]})}),e.jsx(ce,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.address")}),cell:({row:t})=>{const r=`${t.original.host}:${t.original.port}`,a=t.original.port!==t.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[t.original.host,":",t.original.port]})}),a&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",t.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(je,{delayDuration:0,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:i=>{i.stopPropagation(),Ft(r).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(Xa,{className:"size-3"})})}),e.jsx(ce,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(gt,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(q,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:t})=>{const r=t.original.groups||[];return e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[r.map((a,i)=>e.jsx(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:a.name},i)),r.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})]})},enableSorting:!1,filterFn:(t,r,a)=>{const i=t.getValue(r);return i?a.some(l=>i.includes(l)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(q,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:Ue[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:i}=Xr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Ss,{modal:!1,children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Vt,{className:"size-4"})})}),e.jsxs(gs,{align:"end",className:"w-40",children:[e.jsx(ge,{className:"cursor-pointer",onClick:()=>{i(t.original.type),a(t.original),r(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(zo,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(ge,{className:"cursor-pointer",onClick:async()=>{Dc({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Ao,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(tt,{}),e.jsx(ge,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(Qe,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Tc({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(cs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function vx(){const[s,n]=u.useState({}),[t,r]=u.useState({"drag-handle":!1}),[a,i]=u.useState([]),[l,d]=u.useState({pageSize:500,pageIndex:0}),[m,o]=u.useState([]),[c,h]=u.useState(!1),[_,E]=u.useState({}),[C,S]=u.useState([]),{refetch:w}=ie({queryKey:["nodeList"],queryFn:async()=>{const{data:U}=await Cr();return S(U),U}}),{data:b}=ie({queryKey:["groups"],queryFn:async()=>{const{data:U}=await bt();return U}});u.useEffect(()=>{r({"drag-handle":c,show:!c,host:!c,online:!c,rate:!c,groups:!c,type:!1,actions:!c}),E({name:c?2e3:200}),d({pageSize:c?99999:500,pageIndex:0})},[c]);const k=(U,se)=>{c&&(U.dataTransfer.setData("text/plain",se.toString()),U.currentTarget.classList.add("opacity-50"))},p=(U,se)=>{if(!c)return;U.preventDefault(),U.currentTarget.classList.remove("bg-muted");const L=parseInt(U.dataTransfer.getData("text/plain"));if(L===se)return;const Z=[...C],[de]=Z.splice(L,1);Z.splice(se,0,de),S(Z)},v=async()=>{if(!c){h(!0);return}const U=C?.map((se,L)=>({id:se.id,order:L+1}));Ec(U).then(()=>{$.success("排序保存成功"),h(!1),w()}).finally(()=>{h(!1)})},M=ts({data:C||[],columns:jx(w),state:{sorting:m,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:_,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:E,onPaginationChange:d,getCoreRowModel:as(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Qm,{refetch:w,children:e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:M,toolbar:U=>e.jsx(gx,{table:U,refetch:w,saveOrder:v,isSortMode:c,groups:b||[]}),draggable:c,onDragStart:k,onDragEnd:U=>U.currentTarget.classList.remove("opacity-50"),onDragOver:U=>{U.preventDefault(),U.currentTarget.classList.add("bg-muted")},onDragLeave:U=>U.currentTarget.classList.remove("bg-muted"),onDrop:p,showPagination:!c})})})}function bx(){const{t:s}=V("server");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Be,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(vx,{})})]})]})}const yx=Object.freeze(Object.defineProperty({__proto__:null,default:bx},Symbol.toStringTag,{value:"Module"}));function Nx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(ta,{refetch:n}),e.jsx(D,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:N("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(Ze,{className:"ml-2 h-4 w-4"})]})]})})}const _x=s=>{const{t:n}=V("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:t.getValue("name")})})},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(ta,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ic({id:t.original.id}).then(({data:r})=>{r&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function wx(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),{data:m,refetch:o,isLoading:c}=ie({queryKey:["serverGroupList"],queryFn:async()=>{const{data:_}=await bt();return _}}),h=ts({data:m||[],columns:_x(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:as(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:h,toolbar:_=>e.jsx(Nx,{table:_,refetch:o}),isLoading:c})}function Cx(){const{t:s}=V("group");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Be,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(ze,{}),e.jsx(Ae,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(wx,{})})]})]})}const Sx=Object.freeze(Object.defineProperty({__proto__:null,default:Cx},Symbol.toStringTag,{value:"Module"})),kx=s=>x.object({remarks:x.string().min(1,s("form.validation.remarks")),match:x.array(x.string()),action:x.enum(["block","dns"]),action_value:x.string().optional()});function Zr({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="add"}){const{t:a}=V("route"),i=fe({resolver:be(kx(a)),defaultValues:t,mode:"onChange"}),[l,d]=u.useState(!1);return e.jsxs(_e,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(ve,{className:"sm:max-w-[425px]",children:[e.jsxs(Se,{children:[e.jsx(we,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Pe,{})]}),e.jsxs(ye,{...i,children:[e.jsx(g,{control:i.control,name:"remarks",render:({field:m})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(D,{type:"text",placeholder:a("form.remarksPlaceholder"),...m})})}),e.jsx(T,{})]})}),e.jsx(g,{control:i.control,name:"match",render:({field:m})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(Ns,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:m.value.join(` `),onChange:o=>{m.onChange(o.target.value.split(` diff --git a/public/assets/admin/locales/en-US.js b/public/assets/admin/locales/en-US.js index 06f1dcf..2e5a43a 100644 --- a/public/assets/admin/locales/en-US.js +++ b/public/assets/admin/locales/en-US.js @@ -798,6 +798,10 @@ window.XBOARD_TRANSLATIONS['en-US'] = { "surge": { "title": "Surge Template", "description": "Configure subscription template format for Surge" + }, + "surfboard": { + "title": "Surfboard Template", + "description": "Configure subscription template format for Surfboard" } } }, diff --git a/public/assets/admin/locales/ko-KR.js b/public/assets/admin/locales/ko-KR.js index c33eeb6..22d9a62 100644 --- a/public/assets/admin/locales/ko-KR.js +++ b/public/assets/admin/locales/ko-KR.js @@ -796,6 +796,10 @@ window.XBOARD_TRANSLATIONS['ko-KR'] = { "surge": { "title": "Surge 템플릿", "description": "Surge의 구독 템플릿 형식 설정" + }, + "surfboard": { + "title": "Surfboard 템플릿", + "description": "Surfboard의 구독 템플릿 형식 설정" } } }, diff --git a/public/assets/admin/locales/zh-CN.js b/public/assets/admin/locales/zh-CN.js index 7311746..ece6d8f 100644 --- a/public/assets/admin/locales/zh-CN.js +++ b/public/assets/admin/locales/zh-CN.js @@ -803,6 +803,10 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "surge": { "title": "Surge 配置模板", "description": "配置 Surge 订阅模板,支持 Surge 配置文件格式" + }, + "surfboard": { + "title": "Surfboard 配置模版", + "description": "配额 Surfboard 订阅模版" } } },