From 3bd4cf05dd8d0635ec34f8a4874c5b8a63021d7e Mon Sep 17 00:00:00 2001 From: xboard Date: Mon, 13 Jan 2025 10:39:15 +0800 Subject: [PATCH] fix: correct know file issues --- app/Http/Controllers/V2/Admin/PlanController.php | 2 +- public/assets/admin/assets/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/V2/Admin/PlanController.php b/app/Http/Controllers/V2/Admin/PlanController.php index c3394c3..9d7063a 100644 --- a/app/Http/Controllers/V2/Admin/PlanController.php +++ b/app/Http/Controllers/V2/Admin/PlanController.php @@ -29,7 +29,7 @@ class PlanController extends Controller 'id' => 'nullable|integer', 'name' => 'required|string', 'content' => 'nullable|string', - 'period_reset_method' => 'integer|required_if:type,0', + 'reset_traffic_method' => 'integer|nullable', 'transfer_enable' => 'integer|required', 'prices' => 'array|nullable', 'group_id' => 'integer|nullable', diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 03883d6..8e25f82 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,7 +1,7 @@ import{r as c,j as e,t as hl,c as jl,I as ba,a as _s,S as Wt,u as ns,b as Jt,d as gl,O as Qt,e as fl,f as A,g as pl,h as vl,i as bl,Q as yl,k as Nl,R as wl,l as _l,P as Cl,m as Sl,B as kl,n as qa,F as Dl,C as Tl,o as Pl,p as Il,q as Vl,s as Rl,v as El,z as u,w as Ua,x as ae,y as ie,A as Ba,D as _t,E as Ct,G as Zt,H as Me,T as St,J as kt,K as Ga,L as Ya,M as Fl,N as Ml,U as zl,V as Ol,W as Wa,X as Xt,Y as Ja,Z as Ll,_ as Qa,$ as Za,a0 as Xa,a1 as en,a2 as Cs,a3 as sn,a4 as $l,a5 as tn,a6 as an,a7 as Al,a8 as Hl,a9 as Kl,aa as ql,ab as nn,ac as Ul,ad as Bl,ae as Ss,af as rn,ag as Gl,ah as Yl,ai as ln,aj as Wl,ak as Jl,al as ya,am as Ql,an as on,ao as Zl,ap as cn,aq as Xl,ar as ei,as as si,at as ti,au as ai,av as ni,aw as dn,ax as ri,ay as li,az as ii,aA as we,aB as oi,aC as ci,aD as di,aE as ui,aF as un,aG as xn,aH as mn,aI as xi,aJ as hn,aK as jn,aL as gn,aM as mi,aN as hi,aO as ji,aP as fn,aQ as gi,aR as ea,aS as pn,aT as fi,aU as vn,aV as pi,aW as bn,aX as vi,aY as yn,aZ as Nn,a_ as bi,a$ as yi,b0 as wn,b1 as Ni,b2 as wi,b3 as _n,b4 as _i,b5 as Cn,b6 as Ci,b7 as Si,b8 as He,b9 as Q,ba as Pe,bb as rt,bc as ki,bd as Di,be as Ti,bf as Pi,bg as Ii,bh as Vi,bi as Na,bj as wa,bk as Ri,bl as Ei,bm as Fi,bn as Mi,bo as zi,bp as Oi,bq as Sn,br as Li,bs as kn,bt as $i,bu as Ai,bv as Dn,bw as Hi,bx as de,by as Ki,bz as _a,bA as At,bB as Ht,bC as qi,bD as Ui,bE as Tn,bF as Bi,bG as sa,bH as Gi,bI as Yi,bJ as Wi,bK as Pn,bL as In,bM as Vn,bN as Ji,bO as Qi,bP as Zi,bQ as Xi,bR as Rn,bS as eo,bT as Je,bU as so,bV as to,bW as vt,bX as ve,bY as Ca,bZ as ao,b_ as En,b$ as Fn,c0 as Mn,c1 as zn,c2 as On,c3 as Ln,c4 as no,c5 as ro,c6 as lo,c7 as Dt,c8 as ks,c9 as rs,ca as Le,cb as $e,cc as Ke,cd as qe,ce as Ue,cf as Sa,cg as io,ch as oo,ci as co,cj as Kt,ck as ta,cl as aa,cm as uo,cn as ls,co as is,cp as lt,cq as xo,cr as mo,cs as ka,ct as Da,cu as $n,cv as Ta,cw as bt,cx as ho,cy as jo,cz as An,cA as go,cB as fo,cC as Hn,cD as qt,cE as Kn,cF as po,cG as qn,cH as Un,cI as vo,cJ as bo,cK as yo,cL as No,cM as wo}from"./vendor.js";import"./index.js";var ph=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function _o(s){if(s.__esModule)return s;var t=s.default;if(typeof t=="function"){var a=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};a.prototype=t.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var l=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(a,n,l.get?l:{enumerable:!0,get:function(){return s[n]}})}),a}const Co={theme:"system",setTheme:()=>null},Bn=c.createContext(Co);function So({children:s,defaultTheme:t="system",storageKey:a="vite-ui-theme",...n}){const[l,o]=c.useState(()=>localStorage.getItem(a)||t);c.useEffect(()=>{const x=window.document.documentElement;if(x.classList.remove("light","dark"),l==="system"){const r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";x.classList.add(r);return}x.classList.add(l)},[l]);const d={theme:l,setTheme:x=>{localStorage.setItem(a,x),o(x)}};return e.jsx(Bn.Provider,{...n,value:d,children:s})}const ko=()=>{const s=c.useContext(Bn);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Do=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),To=function(s,t){return new URL(s,t).href},Pa={},X=function(t,a,n){let l=Promise.resolve();if(a&&a.length>0){const d=document.getElementsByTagName("link"),x=document.querySelector("meta[property=csp-nonce]"),r=x?.nonce||x?.getAttribute("nonce");l=Promise.allSettled(a.map(i=>{if(i=To(i,n),i in Pa)return;Pa[i]=!0;const h=i.endsWith(".css"),T=h?'[rel="stylesheet"]':"";if(!!n)for(let w=d.length-1;w>=0;w--){const _=d[w];if(_.href===i&&(!h||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${T}`))return;const m=document.createElement("link");if(m.rel=h?"stylesheet":Do,h||(m.as="script"),m.crossOrigin="",m.href=i,r&&m.setAttribute("nonce",r),document.head.appendChild(m),h)return new Promise((w,_)=>{m.addEventListener("load",w),m.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${i}`)))})}))}function o(d){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=d,window.dispatchEvent(x),!x.defaultPrevented)throw d}return l.then(d=>{for(const x of d||[])x.status==="rejected"&&o(x.reason);return t().catch(o)})};function y(...s){return hl(jl(s))}const $s=_s("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"}}),D=c.forwardRef(({className:s,variant:t,size:a,asChild:n=!1,children:l,disabled:o,loading:d=!1,leftSection:x,rightSection:r,...i},h)=>{const T=n?Wt:"button";return e.jsxs(T,{className:y($s({variant:t,size:a,className:s})),disabled:d||o,ref:h,...i,children:[(x&&d||!x&&!r&&d)&&e.jsx(ba,{className:"mr-2 h-4 w-4 animate-spin"}),!d&&x&&e.jsx("div",{className:"mr-2",children:x}),l,!d&&r&&e.jsx("div",{className:"ml-2",children:r}),r&&d&&e.jsx(ba,{className:"ml-2 h-4 w-4 animate-spin"})]})});D.displayName="Button";function Vs({className:s,minimal:t=!1}){const a=ns();return e.jsx("div",{className:y("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:[!t&&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",{})," Please try again later."]}),!t&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(D,{variant:"outline",onClick:()=>a(-1),children:"Go Back"}),e.jsx(D,{onClick:()=>a("/"),children:"Back to Home"})]})]})})}function Ia(){const s=ns();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(D,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(D,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Po(){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(D,{variant:"outline",children:"Learn more"})})]})})}function Io(s){return typeof s>"u"}function Vo(s){return s===null}function Ro(s){return Vo(s)||Io(s)}class Eo{storage;prefixKey;constructor(t){this.storage=t.storage,this.prefixKey=t.prefixKey}getKey(t){return`${this.prefixKey}${t}`.toUpperCase()}set(t,a,n=null){const l=JSON.stringify({value:a,time:Date.now(),expire:n!==null?new Date().getTime()+n*1e3:null});this.storage.setItem(this.getKey(t),l)}get(t,a=null){const n=this.storage.getItem(this.getKey(t));if(!n)return{value:a,time:0};try{const l=JSON.parse(n),{value:o,time:d,expire:x}=l;return Ro(x)||x>new Date().getTime()?{value:o,time:d}:(this.remove(t),{value:a,time:0})}catch{return this.remove(t),{value:a,time:0}}}remove(t){this.storage.removeItem(this.getKey(t))}clear(){this.storage.clear()}}function Gn({prefixKey:s="",storage:t=sessionStorage}){return new Eo({prefixKey:s,storage:t})}const Yn="Xboard_",Fo=function(s={}){return Gn({prefixKey:s.prefixKey||"",storage:localStorage})},Mo=function(s={}){return Gn({prefixKey:s.prefixKey||"",storage:sessionStorage})},Tt=Fo({prefixKey:Yn});Mo({prefixKey:Yn});const Wn="access_token";function Qs(){return Tt.get(Wn)}function Jn(){Tt.remove(Wn)}const Va=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function zo({children:s}){const t=ns(),a=Jt(),n=Qs();return c.useEffect(()=>{if(!n.value&&!Va.includes(a.pathname)){const l=encodeURIComponent(a.pathname+a.search);t(`/sign-in?redirect=${l}`)}},[n.value,a.pathname,a.search,t]),Va.includes(a.pathname)||n.value?e.jsx(e.Fragment,{children:s}):null}const Oo=()=>e.jsx(zo,{children:e.jsx(Qt,{})}),Lo=gl([{path:"/sign-in",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>lc);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Oo,{}),children:[{path:"/",lazy:async()=>({Component:(await X(()=>Promise.resolve().then(()=>bc),void 0,import.meta.url)).default}),errorElement:e.jsx(Vs,{}),children:[{index:!0,lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Bd);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Vs,{}),children:[{path:"system",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Wd);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>eu);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>ru);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>du);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>ju);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>bu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Cu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Pu);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Fu);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>$u);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Zu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>sx);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>ox);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>gx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Vs,{}),children:[{path:"manage",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Ax);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Bx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Zx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Vs,{}),children:[{path:"plan",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>im);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>bm);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Tm);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Vs,{}),children:[{path:"manage",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>Zm);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await X(async()=>{const{default:s}=await Promise.resolve().then(()=>jh);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Vs},{path:"/404",Component:Ia},{path:"/503",Component:Po},{path:"*",Component:Ia}]),$o="locale";function Ao(){return Tt.get($o)}function Qn(){Jn();const s=window.location.pathname,t=s&&!["/404","/sign-in"].includes(s),a=new URL(window.location.href),l=`${a.pathname.split("/")[1]?`/${a.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=l+(t?`?redirect=${s}`:"")}const Ho=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Ko(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const V=fl.create({baseURL:Ko(),timeout:12e3,headers:{"Content-Type":"application/json"}});V.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const t=Qs();if(!Ho.includes(s.url?.split("?")[0]||"")){if(!t.value)return Qn(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=t.value}return s.headers["Content-Language"]=Ao().value||"zh-CN",s},s=>Promise.reject(s));V.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const t=s.response?.status,a=s.response?.data?.message;return(t===401||t===403)&&Qn(),A.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[t]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function qo(){return V.get("/user/info")}const Mt={token:Qs()?.value||"",userInfo:null,isLoggedIn:!!Qs()?.value,loading:!1,error:null},Ws=pl("user/fetchUserInfo",async()=>(await qo()).data,{condition:(s,{getState:t})=>{const{user:a}=t();return!!a.token&&!a.loading}}),Zn=vl({name:"user",initialState:Mt,reducers:{setToken(s,t){s.token=t.payload,s.isLoggedIn=!!t.payload},resetUserState:()=>Mt},extraReducers:s=>{s.addCase(Ws.pending,t=>{t.loading=!0,t.error=null}).addCase(Ws.fulfilled,(t,a)=>{t.loading=!1,t.userInfo=a.payload,t.error=null}).addCase(Ws.rejected,(t,a)=>{if(t.loading=!1,t.error=a.error.message||"Failed to fetch user info",!t.token)return Mt})}}),{setToken:Uo,resetUserState:Bo}=Zn.actions,Go=s=>s.user.userInfo,Yo=Zn.reducer,Xn=bl({reducer:{user:Yo}});Qs()?.value&&Xn.dispatch(Ws());const Wo=new yl;Nl.createRoot(document.getElementById("root")).render(e.jsx(wl.StrictMode,{children:e.jsx(_l,{client:Wo,children:e.jsx(Cl,{store:Xn,children:e.jsxs(So,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Sl,{router:Lo}),e.jsx(kl,{richColors:!0,position:"top-right"})]})})})}));const Ie=c.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...t}));Ie.displayName="Card";const ze=c.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:y("flex flex-col space-y-1.5 p-6",s),...t}));ze.displayName="CardHeader";const Qe=c.forwardRef(({className:s,...t},a)=>e.jsx("h3",{ref:a,className:y("font-semibold leading-none tracking-tight",s),...t}));Qe.displayName="CardTitle";const Zs=c.forwardRef(({className:s,...t},a)=>e.jsx("p",{ref:a,className:y("text-sm text-muted-foreground",s),...t}));Zs.displayName="CardDescription";const Oe=c.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:y("p-6 pt-0",s),...t}));Oe.displayName="CardContent";const Jo=c.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:y("flex items-center p-6 pt-0",s),...t}));Jo.displayName="CardFooter";const Qo=_s("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),yt=c.forwardRef(({className:s,...t},a)=>e.jsx(qa,{ref:a,className:y(Qo(),s),...t}));yt.displayName=qa.displayName;const oe=Dl,er=c.createContext({}),g=({...s})=>e.jsx(er.Provider,{value:{name:s.name},children:e.jsx(Tl,{...s})}),Pt=()=>{const s=c.useContext(er),t=c.useContext(sr),{getFieldState:a,formState:n}=Pl(),l=a(s.name,n);if(!s)throw new Error("useFormField should be used within ");const{id:o}=t;return{id:o,name:s.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...l}},sr=c.createContext({}),j=c.forwardRef(({className:s,...t},a)=>{const n=c.useId();return e.jsx(sr.Provider,{value:{id:n},children:e.jsx("div",{ref:a,className:y("space-y-2",s),...t})})});j.displayName="FormItem";const p=c.forwardRef(({className:s,...t},a)=>{const{error:n,formItemId:l}=Pt();return e.jsx(yt,{ref:a,className:y(n&&"text-destructive",s),htmlFor:l,...t})});p.displayName="FormLabel";const b=c.forwardRef(({...s},t)=>{const{error:a,formItemId:n,formDescriptionId:l,formMessageId:o}=Pt();return e.jsx(Wt,{ref:t,id:n,"aria-describedby":a?`${l} ${o}`:`${l}`,"aria-invalid":!!a,...s})});b.displayName="FormControl";const F=c.forwardRef(({className:s,...t},a)=>{const{formDescriptionId:n}=Pt();return e.jsx("p",{ref:a,id:n,className:y("text-[0.8rem] text-muted-foreground",s),...t})});F.displayName="FormDescription";const k=c.forwardRef(({className:s,children:t,...a},n)=>{const{error:l,formMessageId:o}=Pt(),d=l?String(l?.message):t;return d?e.jsx("p",{ref:n,id:o,className:y("text-[0.8rem] font-medium text-destructive",s),...a,children:d}):null});k.displayName="FormMessage";const S=c.forwardRef(({className:s,type:t,...a},n)=>e.jsx("input",{type:t,className:y("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:n,...a}));S.displayName="Input";const tr=c.forwardRef(({className:s,...t},a)=>{const[n,l]=c.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:n?"text":"password",className:y("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:a,...t}),e.jsx(D,{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:()=>l(o=>!o),children:n?e.jsx(Il,{size:18}):e.jsx(Vl,{size:18})})]})});tr.displayName="PasswordInput";const Zo=s=>V({url:"/passport/auth/login",method:"post",data:s}),Ut=s=>s;function re(s=void 0,t="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),El(s).format(t))}function Xo(s=void 0,t="YYYY-MM-DD"){return re(s,t)}function Fs(s){const t=typeof s=="string"?parseFloat(s):s;return isNaN(t)?"0.00":t.toFixed(2)}function hs(s,t=!0){if(s==null)return t?"¥0.00":"0.00";const a=typeof s=="string"?parseFloat(s):s;if(isNaN(a))return t?"¥0.00":"0.00";const l=(a/100).toFixed(2).replace(/\.?0+$/,o=>o.includes(".")?".00":o);return t?`¥${l}`:l}function Nt(s){navigator.clipboard?navigator.clipboard.writeText(s).then(()=>{A.success(Ut("复制成功"))}).catch(t=>{console.error("复制到剪贴板时出错:",t),Ra(s)}):Ra(s)}function Ra(s){const t=document.createElement("button"),a=new Rl(t,{text:()=>s});a.on("success",()=>{A.success(Ut("复制成功")),a.destroy()}),a.on("error",()=>{A.error(Ut("复制失败")),a.destroy()}),t.click()}function zs(s){const t=s/1024,a=t/1024,n=a/1024,l=n/1024;return l>=1?Fs(l)+" TB":n>=1?Fs(n)+" GB":a>=1?Fs(a)+" MB":Fs(t)+" KB"}const ec="access_token";function sc(s){Tt.set(ec,s)}const tc=u.object({email:u.string().min(1,{message:"请输入邮箱地址"}).email({message:"邮箱地址格式不正确"}),password:u.string().min(1,{message:"请输入密码"}).min(7,{message:"密码长度至少为7个字符"})});function ac({className:s,onForgotPassword:t,...a}){const n=ns(),l=Ua(),o=ae({resolver:ie(tc),defaultValues:{email:"",password:""}});async function d(x){Zo(x).then(({data:r})=>{sc(r.auth_data),l(Uo(r.auth_data)),l(Ws()).unwrap(),n("/")})}return e.jsx("div",{className:y("grid gap-6",s),...a,children:e.jsx(oe,{...o,children:e.jsx("form",{onSubmit:o.handleSubmit(d),children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(g,{control:o.control,name:"email",render:({field:x})=>e.jsxs(j,{className:"space-y-1",children:[e.jsx(p,{children:"邮箱地址"}),e.jsx(b,{children:e.jsx(S,{placeholder:"name@example.com",...x})}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"password",render:({field:x})=>e.jsxs(j,{className:"space-y-1",children:[e.jsx(p,{children:"密码"}),e.jsx(b,{children:e.jsx(tr,{placeholder:"请输入密码",...x})}),e.jsx(k,{})]})}),e.jsx(D,{className:"mt-2",loading:o.formState.isSubmitting,children:"登录"}),e.jsx(D,{variant:"link",type:"button",className:"mt-1 text-sm text-muted-foreground hover:text-primary",onClick:t,children:"忘记密码?"})]})})})})}const ue=Ba,Re=Ga,nc=Ya,it=Zt,ar=c.forwardRef(({className:s,...t},a)=>e.jsx(_t,{ref:a,className:y("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),...t}));ar.displayName=_t.displayName;const ce=c.forwardRef(({className:s,children:t,...a},n)=>e.jsxs(nc,{children:[e.jsx(ar,{}),e.jsxs(Ct,{ref:n,className:y("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),...a,children:[t,e.jsxs(Zt,{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(Me,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ce.displayName=Ct.displayName;const je=({className:s,...t})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...t});je.displayName="DialogHeader";const Ee=({className:s,...t})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...t});Ee.displayName="DialogFooter";const xe=c.forwardRef(({className:s,...t},a)=>e.jsx(St,{ref:a,className:y("text-lg font-semibold leading-none tracking-tight",s),...t}));xe.displayName=St.displayName;const Se=c.forwardRef(({className:s,...t},a)=>e.jsx(kt,{ref:a,className:y("text-sm text-muted-foreground",s),...t}));Se.displayName=kt.displayName;const Ls=_s("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"}}),W=c.forwardRef(({className:s,variant:t,size:a,asChild:n=!1,...l},o)=>{const d=n?Wt:"button";return e.jsx(d,{className:y(Ls({variant:t,size:a,className:s})),ref:o,...l})});W.displayName="Button";function rc(){const[s,t]=c.useState(!1),a="php artisan reset:password 管理员邮箱";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"container grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-2 sm:w-[480px] lg:p-8",children:[e.jsx("div",{className:"mb-4 flex items-center justify-center",children:e.jsx("h1",{className:"text-3xl font-medium",children:window?.settings?.title})}),e.jsxs(Ie,{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:"登录"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请输入您的邮箱和密码登录系统"})]}),e.jsx(ac,{onForgotPassword:()=>t(!0)})]})]})}),e.jsx(ue,{open:s,onOpenChange:t,children:e.jsx(ce,{children:e.jsxs(je,{children:[e.jsx(xe,{children:"忘记密码"}),e.jsx(Se,{children:"在站点目录下执行以下命令找回密码"}),e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12",children:a}),e.jsx(W,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Nt(a),children:e.jsx(Fl,{className:"h-4 w-4"})})]})})]})})})]})}const lc=Object.freeze(Object.defineProperty({__proto__:null,default:rc},Symbol.toStringTag,{value:"Module"})),ye=c.forwardRef(({className:s,fadedBelow:t=!1,fixedHeight:a=!1,...n},l)=>e.jsx("div",{ref:l,className:y("relative flex h-full w-full flex-col",t&&"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",a&&"md:h-svh",s),...n}));ye.displayName="Layout";const Ne=c.forwardRef(({className:s,...t},a)=>e.jsx("div",{ref:a,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...t}));Ne.displayName="LayoutHeader";const _e=c.forwardRef(({className:s,fixedHeight:t,...a},n)=>e.jsx("div",{ref:n,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",t&&"h-[calc(100%-var(--header-height))]",s),...a}));_e.displayName="LayoutBody";const nr=Ml,rr=zl,lr=Ol,Ns=Al,ws=Hl,ic=Kl,oc=c.forwardRef(({className:s,inset:t,children:a,...n},l)=>e.jsxs(Wa,{ref:l,className:y("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",t&&"pl-8",s),...n,children:[a,e.jsx(Xt,{className:"ml-auto h-4 w-4"})]}));oc.displayName=Wa.displayName;const cc=c.forwardRef(({className:s,...t},a)=>e.jsx(Ja,{ref:a,className:y("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),...t}));cc.displayName=Ja.displayName;const gs=c.forwardRef(({className:s,sideOffset:t=4,...a},n)=>e.jsx(Ll,{children:e.jsx(Qa,{ref:n,sideOffset:t,className:y("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),...a})}));gs.displayName=Qa.displayName;const he=c.forwardRef(({className:s,inset:t,...a},n)=>e.jsx(Za,{ref:n,className:y("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",t&&"pl-8",s),...a}));he.displayName=Za.displayName;const dc=c.forwardRef(({className:s,children:t,checked:a,...n},l)=>e.jsxs(Xa,{ref:l,className:y("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:a,...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(en,{children:e.jsx(Cs,{className:"h-4 w-4"})})}),t]}));dc.displayName=Xa.displayName;const uc=c.forwardRef(({className:s,children:t,...a},n)=>e.jsxs(sn,{ref:n,className:y("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),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(en,{children:e.jsx($l,{className:"h-4 w-4 fill-current"})})}),t]}));uc.displayName=sn.displayName;const na=c.forwardRef(({className:s,inset:t,...a},n)=>e.jsx(tn,{ref:n,className:y("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",s),...a}));na.displayName=tn.displayName;const Xs=c.forwardRef(({className:s,...t},a)=>e.jsx(an,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...t}));Xs.displayName=an.displayName;const Bt=({className:s,...t})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...t});Bt.displayName="DropdownMenuShortcut";const le=ql,se=Ul,te=Bl,ee=c.forwardRef(({className:s,sideOffset:t=4,...a},n)=>e.jsx(nn,{ref:n,sideOffset:t,className:y("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),...a}));ee.displayName=nn.displayName;function It(){const{pathname:s}=Jt();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const n=a.replace(/^\//,""),l=s.replace(/^\//,"");return n?l.startsWith(n):!1}}}function ir({key:s,defaultValue:t}){const[a,n]=c.useState(()=>{const l=localStorage.getItem(s);return l!==null?JSON.parse(l):t});return c.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,n]}function xc(){const[s,t]=ir({key:"expanded-sidebar-items",defaultValue:["仪表盘","系统管理","节点管理","订阅管理","用户管理"]});return{expandedItems:s,toggleItem:n=>{t(l=>l.includes(n)?l.filter(o=>o!==n):[...l,n])},isExpanded:n=>s.includes(n)}}function mc({links:s,isCollapsed:t,className:a,closeNav:n}){const l=({sub:o,...d})=>{const x=`${d.title}-${d.href}`;return t&&o?c.createElement(gc,{...d,sub:o,key:x,closeNav:n}):t?c.createElement(jc,{...d,key:x,closeNav:n}):o?c.createElement(hc,{...d,sub:o,key:x,closeNav:n}):c.createElement(or,{...d,key:x,closeNav:n})};return e.jsx("div",{"data-collapsed":t,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",a),children:e.jsx(le,{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(l)})})})}function or({title:s,icon:t,label:a,href:n,closeNav:l,subLink:o=!1}){const{checkActiveNav:d}=It();return e.jsxs(Ss,{to:n,onClick:l,className:y($s({variant:d(n)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",o&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":d(n)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:t}),s,a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:a})]})}function hc({title:s,icon:t,label:a,sub:n,closeNav:l}){const{checkActiveNav:o}=It(),{isExpanded:d,toggleItem:x}=xc(),r=!!n?.find(h=>o(h.href)),i=d(s)||r;return e.jsxs(nr,{open:i,onOpenChange:()=>x(s),children:[e.jsxs(rr,{className:y($s({variant:"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:t}),s,a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:a}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(rn,{stroke:1})})]}),e.jsx(lr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:n.map(h=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(or,{...h,subLink:!0,closeNav:l})},h.title))})})]})}function jc({title:s,icon:t,label:a,href:n}){const{checkActiveNav:l}=It();return e.jsxs(se,{delayDuration:0,children:[e.jsx(te,{asChild:!0,children:e.jsxs(Ss,{to:n,className:y($s({variant:l(n)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[t,e.jsx("span",{className:"sr-only",children:s})]})}),e.jsxs(ee,{side:"right",className:"flex items-center gap-4",children:[s,a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:a})]})]})}function gc({title:s,icon:t,label:a,sub:n}){const{checkActiveNav:l}=It(),o=!!n?.find(d=>l(d.href));return e.jsxs(Ns,{children:[e.jsxs(se,{delayDuration:0,children:[e.jsx(te,{asChild:!0,children:e.jsx(ws,{asChild:!0,children:e.jsx(D,{variant:o?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:t})})}),e.jsxs(ee,{side:"right",className:"flex items-center gap-4",children:[s," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:a}),e.jsx(rn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(gs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(na,{children:[s," ",a?`(${a})`:""]}),e.jsx(Xs,{}),n.map(({title:d,icon:x,label:r,href:i})=>e.jsx(he,{asChild:!0,children:e.jsxs(Ss,{to:i,className:`${l(i)?"bg-secondary":""}`,children:[x," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:d}),r&&e.jsx("span",{className:"ml-auto text-xs",children:r})]})},`${d}-${i}`))]})]})}const cr=[{title:"仪表盘",label:"",href:"/",icon:e.jsx(Gl,{size:18})},{title:"系统管理",label:"",href:"",icon:e.jsx(Yl,{size:18}),sub:[{title:"系统配置",label:"",href:"/config/system",icon:e.jsx(ln,{size:18})},{title:"主题配置",label:"",href:"/config/theme",icon:e.jsx(Wl,{size:18})},{title:"公告管理",label:"",href:"/config/notice",icon:e.jsx(Jl,{size:18})},{title:"支付配置",label:"",href:"/config/payment",icon:e.jsx(ya,{size:18})},{title:"知识库管理",label:"",href:"/config/knowledge",icon:e.jsx(Ql,{size:18})}]},{title:"节点管理",label:"",href:"",icon:e.jsx(on,{size:18}),sub:[{title:"节点管理",label:"",href:"/server/manage",icon:e.jsx(Zl,{size:18})},{title:"权限组管理",label:"",href:"/server/group",icon:e.jsx(cn,{size:18})},{title:"路由管理",label:"",href:"/server/route",icon:e.jsx(Xl,{size:18})}]},{title:"订阅管理",label:"",href:"",icon:e.jsx(ei,{size:18}),sub:[{title:"套餐管理",label:"",href:"/finance/plan",icon:e.jsx(si,{size:18})},{title:"订单管理",label:"",href:"/finance/order",icon:e.jsx(ya,{size:18})},{title:"优惠券管理",label:"",href:"/finance/coupon",icon:e.jsx(ti,{size:18})}]},{title:"用户管理",label:"",href:"",icon:e.jsx(ai,{size:18}),sub:[{title:"用户管理",label:"",href:"/user/manage",icon:e.jsx(ni,{size:18})},{title:"工单管理",label:"",href:"/user/ticket",icon:e.jsx(dn,{size:18})}]}];function fc({className:s,isCollapsed:t,setIsCollapsed:a}){const[n,l]=c.useState(!1);return c.useEffect(()=>{n?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[n]),e.jsxs("aside",{className:y(`fixed left-0 right-0 top-0 z-50 w-full border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${t?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>l(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${n?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(ye,{children:[e.jsxs(Ne,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${t?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${t?"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 ${t?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(D,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":"Toggle Navigation","aria-controls":"sidebar-menu","aria-expanded":n,onClick:()=>l(o=>!o),children:n?e.jsx(ri,{}):e.jsx(li,{})})]}),e.jsx(mc,{id:"sidebar-menu",className:`h-full flex-1 overflow-auto ${n?"max-h-screen":"max-h-0 py-0 md:max-h-screen md:py-2"}`,closeNav:()=>l(!1),isCollapsed:t,links:cr}),e.jsx(D,{onClick:()=>a(o=>!o),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex",children:e.jsx(ii,{stroke:1.5,className:`h-5 w-5 ${t?"rotate-180":""}`})})]})]})}function pc(){const[s,t]=ir({key:"collapsed-sidebar",defaultValue:!1});return c.useEffect(()=>{const a=()=>{t(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,t]),[s,t]}function vc(){const[s,t]=pc();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(fc,{isCollapsed:s,setIsCollapsed:t}),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(Qt,{})})]})}const bc=Object.freeze(Object.defineProperty({__proto__:null,default:vc},Symbol.toStringTag,{value:"Module"})),fs=c.forwardRef(({className:s,...t},a)=>e.jsx(we,{ref:a,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...t}));fs.displayName=we.displayName;const yc=({children:s,...t})=>e.jsx(ue,{...t,children:e.jsx(ce,{className:"overflow-hidden p-0",children:e.jsx(fs,{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})})}),Ds=c.forwardRef(({className:s,...t},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(oi,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(we.Input,{ref:a,className:y("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),...t})]}));Ds.displayName=we.Input.displayName;const ps=c.forwardRef(({className:s,...t},a)=>e.jsx(we.List,{ref:a,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...t}));ps.displayName=we.List.displayName;const Ts=c.forwardRef((s,t)=>e.jsx(we.Empty,{ref:t,className:"py-6 text-center text-sm",...s}));Ts.displayName=we.Empty.displayName;const Ve=c.forwardRef(({className:s,...t},a)=>e.jsx(we.Group,{ref:a,className:y("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),...t}));Ve.displayName=we.Group.displayName;const As=c.forwardRef(({className:s,...t},a)=>e.jsx(we.Separator,{ref:a,className:y("-mx-1 h-px bg-border",s),...t}));As.displayName=we.Separator.displayName;const be=c.forwardRef(({className:s,...t},a)=>e.jsx(we.Item,{ref:a,className:y("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),...t}));be.displayName=we.Item.displayName;function Nc(){const s=[];for(const t of cr)if(t.href&&s.push(t),t.sub)for(const a of t.sub)s.push({...a,parent:t.title});return s}function ke(){const[s,t]=c.useState(!1),a=ns(),n=Nc();c.useEffect(()=>{const o=d=>{d.key==="k"&&(d.metaKey||d.ctrlKey)&&(d.preventDefault(),t(x=>!x))};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[]);const l=c.useCallback(o=>{t(!1),a(o)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{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:()=>t(!0),children:[e.jsx(ci,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:"搜索..."}),e.jsx("span",{className:"sr-only",children:"搜索"}),e.jsxs("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:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsxs(yc,{open:s,onOpenChange:t,children:[e.jsx(Ds,{placeholder:"搜索所有菜单和功能..."}),e.jsxs(ps,{children:[e.jsx(Ts,{children:"未找到相关结果"}),e.jsx(Ve,{heading:"菜单导航",children:n.map(o=>e.jsxs(be,{value:`${o.parent?o.parent+" ":""}${o.title}`,onSelect:()=>l(o.href),children:[e.jsx("div",{className:"mr-2",children:o.icon}),e.jsx("span",{children:o.title}),o.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:o.parent})]},o.href))})]})]})]})}function De(){const{theme:s,setTheme:t}=ko();return c.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",n=document.querySelector("meta[name='theme-color']");n&&n.setAttribute("content",a)},[s]),e.jsx(D,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>t(s==="light"?"dark":"light"),children:s==="light"?e.jsx(di,{size:20}):e.jsx(ui,{size:20})})}const dr=c.forwardRef(({className:s,...t},a)=>e.jsx(un,{ref:a,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...t}));dr.displayName=un.displayName;const ur=c.forwardRef(({className:s,...t},a)=>e.jsx(xn,{ref:a,className:y("aspect-square h-full w-full",s),...t}));ur.displayName=xn.displayName;const xr=c.forwardRef(({className:s,...t},a)=>e.jsx(mn,{ref:a,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...t}));xr.displayName=mn.displayName;function Te(){const s=ns(),t=Ua(),a=xi(Go),n=()=>{Jn(),t(Bo()),s("/sign-in")},l=a?.email?.split("@")[0]||"User",o=l.substring(0,2).toUpperCase();return e.jsxs(Ns,{children:[e.jsx(ws,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(dr,{className:"h-8 w-8",children:[e.jsx(ur,{src:a?.avatar_url,alt:l}),e.jsx(xr,{children:o})]})})}),e.jsxs(gs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(na,{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:l}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:a?.email||"user@example.com"})]})}),e.jsx(Xs,{}),e.jsx(he,{asChild:!0,children:e.jsxs(Ss,{to:"/config/system",children:["设置",e.jsx(Bt,{children:"⌘S"})]})}),e.jsx(Xs,{}),e.jsxs(he,{onClick:n,children:["退出登录",e.jsx(Bt,{children:"⇧⌘Q"})]})]})]})}const We=window?.settings?.secure_path,mr=5*60*1e3,Gt=new Map,wc=s=>{const t=Gt.get(s);return t?Date.now()-t.timestamp>mr?(Gt.delete(s),null):t.data:null},_c=(s,t)=>{Gt.set(s,{data:t,timestamp:Date.now()})},Cc=async(s,t=mr)=>{const a=wc(s);if(a)return a;const n=await V.get(s);return _c(s,n),n},Sc={getList:()=>Cc(`${We}/notice/fetch`),save:s=>V.post(`${We}/notice/save`,s),drop:s=>V.post(`${We}/notice/drop`,{id:s}),updateStatus:s=>V.post(`${We}/notice/show`,{id:s}),sort:s=>V.post(`${We}/notice/sort`,{ids:s})},Ea={getSystemStatus:()=>V.get(`${We}/system/getSystemStatus`),getQueueStats:()=>V.get(`${We}/system/getQueueStats`),getQueueWorkload:()=>V.get(`${We}/system/getQueueWorkload`),getQueueMasters:()=>V.get(`${We}/system/getQueueMasters`),getSystemLog:s=>V.get(`${We}/system/getSystemLog`,{params:s})},M=window?.settings?.secure_path,kc=s=>V.get(M+"/stat/getOrder",{params:s}),Dc=()=>V.get(M+"/stat/getStats"),Fa=s=>V.get(M+"/stat/getTrafficRank",{params:s}),Tc=()=>V.get(M+"/theme/getThemes"),Pc=s=>V.post(M+"/theme/getThemeConfig",{name:s}),Ic=(s,t)=>V.post(M+"/theme/saveThemeConfig",{name:s,config:t}),Vc=s=>{const t=new FormData;return t.append("file",s),V.post(M+"/theme/upload",t,{headers:{"Content-Type":"multipart/form-data"}})},Rc=s=>V.post(M+"/theme/delete",{name:s}),Ec=s=>V.post(M+"/config/save",s),hr=()=>V.get(M+"/server/manage/getNodes"),Fc=s=>V.post(M+"/server/manage/save",s),Mc=s=>V.post(M+"/server/manage/drop",s),zc=s=>V.post(M+"/server/manage/copy",s),Oc=s=>V.post(M+"/server/manage/update",s),Lc=s=>V.post(M+"/server/manage/sort",s),Vt=()=>V.get(M+"/server/group/fetch"),$c=s=>V.post(M+"/server/group/save",s),Ac=s=>V.post(M+"/server/group/drop",s),jr=()=>V.get(M+"/server/route/fetch"),Hc=s=>V.post(M+"/server/route/save",s),Kc=s=>V.post(M+"/server/route/drop",s),qc=()=>V.get(M+"/payment/fetch"),Uc=()=>V.get(M+"/payment/getPaymentMethods"),Bc=s=>V.post(M+"/payment/getPaymentForm",s),Gc=s=>V.post(M+"/payment/save",s),Yc=s=>V.post(M+"/payment/drop",s),Wc=s=>V.post(M+"/payment/show",s),Jc=s=>V.post(M+"/payment/sort",s),Qc=()=>V.get(M+"/notice/fetch"),Zc=s=>V.post(M+"/notice/save",s),Xc=s=>V.post(M+"/notice/drop",s),ed=s=>V.post(M+"/notice/show",s),sd=()=>V.get(M+"/knowledge/fetch"),td=s=>V.get(M+"/knowledge/fetch?id="+s),ad=s=>V.post(M+"/knowledge/save",s),nd=s=>V.post(M+"/knowledge/drop",s),rd=s=>V.post(M+"/knowledge/show",s),ld=s=>V.post(M+"/knowledge/sort",s),Ps=()=>V.get(M+"/plan/fetch"),id=s=>V.post(M+"/plan/save",s),zt=s=>V.post(M+"/plan/update",s),od=s=>V.post(M+"/plan/drop",s),cd=s=>V.post(M+"/plan/sort",{ids:s}),gr=async s=>V.post(M+"/order/fetch",s),dd=s=>V.post(M+"/order/detail",s),ud=s=>V.post(M+"/order/paid",s),xd=s=>V.post(M+"/order/cancel",s),Ma=s=>V.post(M+"/order/update",s),md=s=>V.post(M+"/order/assign",s),hd=s=>V.post(M+"/coupon/fetch",s),jd=s=>V.post(M+"/coupon/generate",s),gd=s=>V.post(M+"/coupon/drop",s),fd=s=>V.post(M+"/coupon/update",s),pd=s=>V.post(M+"/user/fetch",s),vd=s=>V.post(M+"/user/update",s),bd=s=>V.post(M+"/user/resetSecret",s),yd=s=>V.post(M+"/user/generate",s),Nd=s=>V.post(M+"/stat/getStatUser",s),fr=s=>V.post(M+"/ticket/fetch",s),wd=s=>V.get(M+"/ticket/fetch?id= "+s),_d=s=>V.post(M+"/ticket/reply",s),pr=s=>V.post(M+"/ticket/close",{id:s}),os=(s="")=>V.get(M+"/config/fetch?key="+s),cs=s=>V.post(M+"/config/save",s),Cd=()=>V.get(M+"/config/getEmailTemplate"),Sd=()=>V.post(M+"/config/testSendMail"),kd=()=>V.post(M+"/config/setTelegramWebhook"),Dd=Sc.sort,vr=mi,ra=c.forwardRef(({className:s,...t},a)=>e.jsx(hn,{ref:a,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...t}));ra.displayName=hn.displayName;const et=c.forwardRef(({className:s,...t},a)=>e.jsx(jn,{ref:a,className:y("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),...t}));et.displayName=jn.displayName;const Td=c.forwardRef(({className:s,...t},a)=>e.jsx(gn,{ref:a,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...t}));Td.displayName=gn.displayName;const G=hi,xs=Ni,Y=ji,U=c.forwardRef(({className:s,children:t,...a},n)=>e.jsxs(fn,{ref:n,className:y("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),...a,children:[t,e.jsx(gi,{asChild:!0,children:e.jsx(ea,{className:"h-4 w-4 opacity-50"})})]}));U.displayName=fn.displayName;const br=c.forwardRef(({className:s,...t},a)=>e.jsx(pn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...t,children:e.jsx(fi,{className:"h-4 w-4"})}));br.displayName=pn.displayName;const yr=c.forwardRef(({className:s,...t},a)=>e.jsx(vn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...t,children:e.jsx(ea,{className:"h-4 w-4"})}));yr.displayName=vn.displayName;const B=c.forwardRef(({className:s,children:t,position:a="popper",...n},l)=>e.jsx(pi,{children:e.jsxs(bn,{ref:l,className:y("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",a==="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:a,...n,children:[e.jsx(br,{}),e.jsx(vi,{className:y("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),e.jsx(yr,{})]})}));B.displayName=bn.displayName;const Pd=c.forwardRef(({className:s,...t},a)=>e.jsx(yn,{ref:a,className:y("px-2 py-1.5 text-sm font-semibold",s),...t}));Pd.displayName=yn.displayName;const O=c.forwardRef(({className:s,children:t,...a},n)=>e.jsxs(Nn,{ref:n,className:y("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),...a,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(bi,{children:e.jsx(Cs,{className:"h-4 w-4"})})}),e.jsx(yi,{children:t})]}));O.displayName=Nn.displayName;const Id=c.forwardRef(({className:s,...t},a)=>e.jsx(wn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...t}));Id.displayName=wn.displayName;function Is({className:s,classNames:t,showOutsideDays:a=!0,...n}){return e.jsx(wi,{showOutsideDays:a,className:y("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:y(Ls({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:y("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",n.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:y(Ls({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",...t},components:{IconLeft:({className:l,...o})=>e.jsx(_n,{className:y("h-4 w-4",l),...o}),IconRight:({className:l,...o})=>e.jsx(Xt,{className:y("h-4 w-4",l),...o})},...n})}Is.displayName="Calendar";const Ze=Ci,Xe=Si,Be=c.forwardRef(({className:s,align:t="center",sideOffset:a=4,...n},l)=>e.jsx(_i,{children:e.jsx(Cn,{ref:l,align:t,sideOffset:a,className:y("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),...n})}));Be.displayName=Cn.displayName;const ms={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Ys=s=>(s/100).toFixed(2),Vd=({active:s,payload:t,label:a})=>s&&t&&t.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:a}),t.map((n,l)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:n.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[n.name,":"]}),e.jsx("span",{className:"font-medium",children:n.name.includes("金额")?`¥${Ys(n.value)}`:`${n.value}笔`})]},l))]}):null,Rd=[{value:"7d",label:"最近7天"},{value:"30d",label:"最近30天"},{value:"90d",label:"最近90天"},{value:"180d",label:"最近180天"},{value:"365d",label:"最近一年"},{value:"custom",label:"自定义范围"}],Ed=(s,t)=>{const a=new Date;if(s==="custom"&&t)return{startDate:t.from,endDate:t.to};let n;switch(s){case"7d":n=He(a,7);break;case"30d":n=He(a,30);break;case"90d":n=He(a,90);break;case"180d":n=He(a,180);break;case"365d":n=He(a,365);break;default:n=He(a,30)}return{startDate:n,endDate:a}};function Fd(){const[s,t]=c.useState("amount"),[a,n]=c.useState("30d"),[l,o]=c.useState({from:He(new Date,7),to:new Date}),{startDate:d,endDate:x}=Ed(a,l),{data:r}=Q({queryKey:["orderStat",{start_date:Pe(d,"yyyy-MM-dd"),end_date:Pe(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:i}=await kc({start_date:Pe(d,"yyyy-MM-dd"),end_date:Pe(x,"yyyy-MM-dd")});return i},refetchInterval:3e4});return e.jsxs(Ie,{children:[e.jsxs(ze,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Qe,{children:"收入趋势"}),e.jsx(Zs,{children:`${r?.summary.start_date||""} 至 ${r?.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:a,onValueChange:i=>n(i),children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(Y,{placeholder:"选择时间范围"})}),e.jsx(B,{children:Rd.map(i=>e.jsx(O,{value:i.value,children:i.label},i.value))})]}),a==="custom"&&e.jsxs(Ze,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(rt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:l?.from?l.to?e.jsxs(e.Fragment,{children:[Pe(l.from,"yyyy-MM-dd")," -"," ",Pe(l.to,"yyyy-MM-dd")]}):Pe(l.from,"yyyy-MM-dd"):e.jsx("span",{children:"选择日期范围"})})]})}),e.jsx(Be,{className:"w-auto p-0",align:"end",children:e.jsx(Is,{mode:"range",defaultMonth:l?.from,selected:{from:l?.from,to:l?.to},onSelect:i=>{i?.from&&i?.to&&o({from:i.from,to:i.to})},numberOfMonths:2})})]})]}),e.jsx(vr,{value:s,onValueChange:i=>t(i),children:e.jsxs(ra,{children:[e.jsx(et,{value:"amount",children:"金额"}),e.jsx(et,{value:"count",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:"总收入"}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Ys(r?.summary?.paid_total||0)]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["共 ",r?.summary?.paid_count||0," 笔"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["平均订单金额 ¥",Ys(r?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总佣金"}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Ys(r?.summary?.commission_total||0)]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["共 ",r?.summary?.commission_count||0," 笔"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["佣金比率 ",r?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]})]}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(ki,{width:"100%",height:"100%",children:e.jsxs(Di,{data:r?.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:ms.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:ms.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:ms.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:ms.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Ti,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:i=>Pe(new Date(i),"MM-dd",{locale:Ri})}),e.jsx(Pi,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:i=>s==="amount"?`¥${Ys(i)}`:`${i}笔`}),e.jsx(Ii,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Vi,{content:e.jsx(Vd,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Na,{type:"monotone",dataKey:"paid_total",name:"收款金额",stroke:ms.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Na,{type:"monotone",dataKey:"commission_total",name:"佣金金额",stroke:ms.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(wa,{dataKey:"paid_count",name:"收款笔数",fill:ms.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(wa,{dataKey:"commission_count",name:"佣金笔数",fill:ms.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})})]})}var me=(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))(me||{});const Es={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Bs={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var as=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(as||{});const Nr={1:"新购",2:"续费",3:"升级",4:"流量重置"};var fe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(fe||{});const ct={0:"待确认",1:"发放中",2:"有效",3:"无效"},dt={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var ne=(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))(ne||{});const st={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var pe=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(pe||{});const ys=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ts={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var Rt=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Rt||{});const la={1:"按金额优惠",2:"按比例优惠"},Md={0:"正常",1:"锁定"};var Ms=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Ms||{});const zd={0:"开启",1:"已关闭"};var ss=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(ss||{});const Js={0:"低",1:"中",2:"高"};function Od(){const s=ns(),{data:t}=Q({queryKey:["pendingTickets"],queryFn:()=>fr({filter:[{id:"status",value:0}],pageSize:999}),staleTime:1e3*30,refetchInterval:1e3*30}),{data:a}=Q({queryKey:["pendingCommissions"],queryFn:()=>gr({filter:[{id:"commission_status",value:fe.PENDING},{id:"status",value:me.COMPLETED},{id:"commission_balance",value:"gt:0"}]}),staleTime:1e3*30,refetchInterval:1e3*30}),n=t?.data||[],l=a?.data||[],o=()=>{const d=new URLSearchParams;d.set("commission_status",fe.PENDING.toString()),d.set("status",me.COMPLETED.toString()),d.set("commission_balance","gt:0"),d.set("page_size","999"),s(`/finance/order?${d.toString()}`)};return e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ie,{className:`cursor-pointer transition-colors hover:bg-muted/50 ${n.length>0?"border-orange-500/50":""}`,onClick:()=>s("/user/ticket"),children:[e.jsxs(ze,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Qe,{className:"text-sm font-medium",children:"待处理工单"}),e.jsx(Ei,{className:`h-4 w-4 ${n.length>0?"text-orange-500":"text-muted-foreground"}`})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.length>0?"有待处理的工单需要关注":"暂无待处理工单"})]})]}),e.jsxs(Ie,{className:`cursor-pointer transition-colors hover:bg-muted/50 ${l.length>0?"border-blue-500/50":""}`,onClick:o,children:[e.jsxs(ze,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Qe,{className:"text-sm font-medium",children:"待处理佣金"}),e.jsx(Fi,{className:`h-4 w-4 ${l.length>0?"text-blue-500":"text-muted-foreground"}`})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:l.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.length>0?"有待处理的佣金需要确认":"暂无待处理佣金"})]})]})]})}function Fe({className:s,...t}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...t})}function Ld(){return e.jsxs(Ie,{children:[e.jsxs(ze,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Fe,{className:"h-4 w-[100px]"}),e.jsx(Fe,{className:"h-4 w-4"})]}),e.jsxs(Oe,{children:[e.jsx(Fe,{className:"h-8 w-[120px]"}),e.jsx("div",{className:"flex items-center pt-1",children:e.jsx(Fe,{className:"h-4 w-[100px]"})})]})]})}function $d(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:4}).map((s,t)=>e.jsx(Ld,{},t))})}function ut({title:s,value:t,icon:a,trend:n,className:l}){return e.jsxs(Ie,{className:y("transition-colors hover:border-primary/50",l),children:[e.jsxs(ze,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Qe,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:t}),e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Li,{className:y("h-4 w-4",n.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("ml-1 text-xs",n.isPositive?"text-emerald-500":"text-red-500"),children:[n.isPositive?"+":"-",Math.abs(n.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:n.label})]})]})]})}function Ad({className:s}){const{data:t,isLoading:a}=Q({queryKey:["dashboardStats"],queryFn:async()=>(await Dc()).data,refetchInterval:3e5});return a||!t?e.jsx($d,{}):e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(ut,{title:"今日收入",value:hs(t.todayIncome),icon:e.jsx(Mi,{className:"h-4 w-4 text-emerald-500"}),trend:{value:t.dayIncomeGrowth,label:"vs 昨日",isPositive:t.dayIncomeGrowth>0}}),e.jsx(ut,{title:"本月收入",value:hs(t.currentMonthIncome),icon:e.jsx(zi,{className:"h-4 w-4 text-blue-500"}),trend:{value:t.monthIncomeGrowth,label:"vs 上月",isPositive:t.monthIncomeGrowth>0}}),e.jsx(ut,{title:"上月佣金支出",value:hs(t.lastMonthCommissionPayout),icon:e.jsx(Oi,{className:"h-4 w-4 text-destructive"}),trend:{value:t.commissionGrowth,label:"vs 上上月",isPositive:t.commissionGrowth>0}}),e.jsx(ut,{title:"本月新增用户",value:t.currentMonthNewUsers,icon:e.jsx(Sn,{className:"h-4 w-4 text-blue-500"}),trend:{value:t.userGrowth,label:"vs 上月",isPositive:t.userGrowth>0}})]})}const tt=c.forwardRef(({className:s,children:t,...a},n)=>e.jsxs(kn,{ref:n,className:y("relative overflow-hidden",s),...a,children:[e.jsx($i,{className:"h-full w-full rounded-[inherit]",children:t}),e.jsx(wt,{}),e.jsx(Ai,{})]}));tt.displayName=kn.displayName;const wt=c.forwardRef(({className:s,orientation:t="vertical",...a},n)=>e.jsx(Dn,{ref:n,orientation:t,className:y("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...a,children:e.jsx(Hi,{className:"relative flex-1 rounded-full bg-border"})}));wt.displayName=Dn.displayName;const Yt={today:{label:"今天",getValue:()=>{const s=qi();return{start:s,end:Ui(s,1)}}},last7days:{label:"最近7天",getValue:()=>{const s=new Date;return{start:He(s,7),end:s}}},last30days:{label:"最近30天",getValue:()=>{const s=new Date;return{start:He(s,30),end:s}}},custom:{label:"自定义范围",getValue:()=>null}};function za({selectedRange:s,customDateRange:t,onRangeChange:a,onCustomRangeChange:n}){return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(G,{value:s,onValueChange:a,children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(Y,{placeholder:"选择时间范围"})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(Yt).map(([l,{label:o}])=>e.jsx(O,{value:l,children:o},l))})]}),s==="custom"&&e.jsxs(Ze,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(W,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!t&&"text-muted-foreground"),children:[e.jsx(rt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:t?.from?t.to?e.jsxs(e.Fragment,{children:[Pe(t.from,"yyyy-MM-dd")," -"," ",Pe(t.to,"yyyy-MM-dd")]}):Pe(t.from,"yyyy-MM-dd"):e.jsx("span",{children:"选择日期范围"})})]})}),e.jsx(Be,{className:"w-auto p-0",align:"end",children:e.jsx(Is,{mode:"range",defaultMonth:t?.from,selected:{from:t?.from,to:t?.to},onSelect:l=>{l?.from&&l?.to&&n({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const Rs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Hd({className:s}){const[t,a]=c.useState("today"),[n,l]=c.useState({from:He(new Date,7),to:new Date}),[o,d]=c.useState("today"),[x,r]=c.useState({from:He(new Date,7),to:new Date}),i=c.useMemo(()=>t==="custom"?{start:n.from,end:n.to}:Yt[t].getValue(),[t,n]),h=c.useMemo(()=>o==="custom"?{start:x.from,end:x.to}:Yt[o].getValue(),[o,x]),{data:T}=Q({queryKey:["nodeTrafficRank",i.start,i.end],queryFn:()=>Fa({type:"node",start_time:de.round(i.start.getTime()/1e3),end_time:de.round(i.end.getTime()/1e3)}),refetchInterval:3e4}),{data:C}=Q({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>Fa({type:"user",start_time:de.round(h.start.getTime()/1e3),end_time:de.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Ie,{children:[e.jsx(ze,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Qe,{className:"flex items-center text-base font-medium",children:[e.jsx(Ki,{className:"mr-2 h-4 w-4"}),"节点流量排行"]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(za,{selectedRange:t,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}),e.jsx(_a,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"flex-1",children:T?.data?e.jsxs(tt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:T.data.map(m=>e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{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:m.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",m.change>=0?"text-green-600":"text-red-600"),children:[m.change>=0?e.jsx(At,{className:"mr-1 h-3 w-3"}):e.jsx(Ht,{className:"mr-1 h-3 w-3"}),Math.abs(m.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:`${m.value/T.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Rs(m.value)})]})]})})}),e.jsx(ee,{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.jsx("span",{className:"text-muted-foreground",children:"当前流量:"}),e.jsx("span",{className:"font-medium",children:Rs(m.value)}),e.jsx("span",{className:"text-muted-foreground",children:"上期流量:"}),e.jsx("span",{className:"font-medium",children:Rs(m.previousValue)}),e.jsx("span",{className:"text-muted-foreground",children:"变化率:"}),e.jsxs("span",{className:y("font-medium",m.change>=0?"text-green-600":"text-red-600"),children:[m.change>=0?"+":"",m.change,"%"]}),e.jsx("span",{className:"text-muted-foreground",children:"记录时间:"}),e.jsx("span",{className:"font-medium",children:Pe(new Date(m.timestamp),"yyyy-MM-dd HH:mm")})]})})]})},m.id))}),e.jsx(wt,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:"Loading..."})})})]}),e.jsxs(Ie,{children:[e.jsx(ze,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Qe,{className:"flex items-center text-base font-medium",children:[e.jsx(Sn,{className:"mr-2 h-4 w-4"}),"用户流量排行"]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(za,{selectedRange:o,customDateRange:x,onRangeChange:d,onCustomRangeChange:r}),e.jsx(_a,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"flex-1",children:C?.data?e.jsxs(tt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:C.data.map(m=>e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{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:m.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",m.change>=0?"text-green-600":"text-red-600"),children:[m.change>=0?e.jsx(At,{className:"mr-1 h-3 w-3"}):e.jsx(Ht,{className:"mr-1 h-3 w-3"}),Math.abs(m.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:`${m.value/C.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Rs(m.value)})]})]})})}),e.jsx(ee,{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.jsx("span",{className:"text-muted-foreground",children:"当前流量:"}),e.jsx("span",{className:"font-medium",children:Rs(m.value)}),e.jsx("span",{className:"text-muted-foreground",children:"上期流量:"}),e.jsx("span",{className:"font-medium",children:Rs(m.previousValue)}),e.jsx("span",{className:"text-muted-foreground",children:"变化率:"}),e.jsxs("span",{className:y("font-medium",m.change>=0?"text-green-600":"text-red-600"),children:[m.change>=0?"+":"",m.change,"%"]}),e.jsx("span",{className:"text-muted-foreground",children:"记录时间:"}),e.jsx("span",{className:"font-medium",children:Pe(new Date(m.timestamp),"yyyy-MM-dd HH:mm")})]})})]})},m.id))}),e.jsx(wt,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:"Loading..."})})})]})]})}const Kd=_s("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 L({className:s,variant:t,...a}){return e.jsx("div",{className:y(Kd({variant:t}),s),...a})}const pt=c.forwardRef(({className:s,value:t,...a},n)=>e.jsx(Tn,{ref:n,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(Bi,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));pt.displayName=Tn.displayName;function qd(){const[s,t]=c.useState(null),[a,n]=c.useState(null),[l,o]=c.useState(!0),[d,x]=c.useState(!1),r=async()=>{try{x(!0);const[T,C]=await Promise.all([Ea.getSystemStatus(),Ea.getQueueStats()]);t(T.data),n(C.data)}catch(T){console.error("Error fetching system data:",T)}finally{o(!1),x(!1)}};c.useEffect(()=>{r();const T=setInterval(r,3e4);return()=>clearInterval(T)},[]);const i=()=>{r()};if(l)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(sa,{className:"h-6 w-6 animate-spin"})});const h=T=>T?e.jsx(Pn,{className:"h-5 w-5 text-green-500"}):e.jsx(In,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ie,{children:[e.jsxs(ze,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(Gi,{className:"h-5 w-5"}),"队列状态"]}),e.jsx(Zs,{children:"当前队列运行状态"})]}),e.jsx(W,{variant:"outline",size:"icon",onClick:i,disabled:d,children:e.jsx(Yi,{className:y("h-4 w-4",d&&"animate-spin")})})]}),e.jsx(Oe,{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(a?.status||!1),e.jsx("span",{className:"font-medium",children:"运行状态"})]}),e.jsx(L,{variant:a?.status?"secondary":"destructive",children:a?.status?"正常":"异常"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["当前等待时间:",a?.wait?.default||0," 秒"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{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:"近期任务数"}),e.jsx("p",{className:"text-2xl font-bold",children:a?.recentJobs||0}),e.jsx(pt,{value:(a?.recentJobs||0)/(a?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ee,{children:e.jsxs("p",{children:["统计时间范围: ",a?.periods?.recentJobs||0," 小时"]})})]})}),e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{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:"每分钟处理量"}),e.jsx("p",{className:"text-2xl font-bold",children:a?.jobsPerMinute||0}),e.jsx(pt,{value:(a?.jobsPerMinute||0)/(a?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ee,{children:e.jsxs("p",{children:["最高吞吐量:"," ",a?.queueWithMaxThroughput?.throughput||0]})})]})})]})]})})]}),e.jsxs(Ie,{children:[e.jsxs(ze,{children:[e.jsxs(Qe,{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-5 w-5"}),"作业详情"]}),e.jsx(Zs,{children:"队列处理详细信息"})]}),e.jsx(Oe,{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:"7日报错数量"}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:a?.failedJobs||0}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["保留 ",a?.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:"最长运行队列"}),e.jsxs("p",{className:"text-2xl font-bold",children:[a?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:a?.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:"活跃进程"}),e.jsxs("span",{className:"font-medium",children:[a?.processes||0," /"," ",(a?.processes||0)+(a?.pausedMasters||0)]})]}),e.jsx(pt,{value:(a?.processes||0)/((a?.processes||0)+(a?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Ud(){return e.jsxs(ye,{children:[e.jsxs(Ne,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:"仪表盘"})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(ke,{}),e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsx(_e,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"border-b pb-6",children:e.jsx(Od,{})}),e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Ad,{}),e.jsx(Fd,{}),e.jsx(Hd,{}),e.jsx(qd,{})]})]})})]})}const Bd=Object.freeze(Object.defineProperty({__proto__:null,default:Ud},Symbol.toStringTag,{value:"Module"})),ge=c.forwardRef(({className:s,orientation:t="horizontal",decorative:a=!0,...n},l)=>e.jsx(Vn,{ref:l,decorative:a,orientation:t,className:y("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...n}));ge.displayName=Vn.displayName;function Gd({className:s,items:t,...a}){const{pathname:n}=Jt(),l=ns(),[o,d]=c.useState(n??"/settings"),x=r=>{d(r),l(r)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(G,{value:o,onValueChange:x,children:[e.jsx(U,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(B,{children:t.map(r=>e.jsx(O,{value:r.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:r.icon}),e.jsx("span",{className:"text-md",children:r.title})]})},r.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:y("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:t.map(r=>e.jsxs(Ss,{to:r.href,className:y($s({variant:"ghost"}),n===r.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:r.icon}),r.title]},r.href))})})]})}const wr=[{title:"站点设置",key:"site",icon:e.jsx(Ji,{size:18}),href:"/config/system",description:"配置站点基本信息,包括站点名称、描述、货币单位等核心设置。"},{title:"安全设置",key:"safe",icon:e.jsx(cn,{size:18}),href:"/config/system/safe",description:"配置系统安全相关选项,包括登录验证、密码策略、API访问等安全设置。"},{title:"订阅设置",key:"subscribe",icon:e.jsx(dn,{size:18}),href:"/config/system/subscribe",description:"管理用户订阅相关配置,包括订阅链接格式、更新频率、流量统计等设置。"},{title:"邀请&佣金",key:"invite",icon:e.jsx(Qi,{size:18}),href:"/config/system/invite",description:"管理用户邀请和佣金系统,配置邀请奖励、分销规则等。"},{title:"节点配置",key:"server",icon:e.jsx(on,{size:18}),href:"/config/system/server",description:"配置节点通信和同步设置,包括通信密钥、轮询间隔、负载均衡等高级选项。"},{title:"邮件设置",key:"email",icon:e.jsx(Zi,{size:18}),href:"/config/system/email",description:"配置系统邮件服务,用于发送验证码、密码重置、通知等邮件,支持多种SMTP服务商。"},{title:"Telegram设置",key:"telegram",icon:e.jsx(Xi,{size:18}),href:"/config/system/telegram",description:"配置Telegram机器人功能,实现用户通知、账户绑定、指令交互等自动化服务。"},{title:"APP设置",key:"app",icon:e.jsx(ln,{size:18}),href:"/config/system/app",description:"管理移动应用程序相关配置,包括API接口、版本控制、推送通知等功能设置。"}];function Yd(){return e.jsxs(ye,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ne,{children:[e.jsx(ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"系统设置"}),e.jsx("div",{className:"text-muted-foreground",children:"管理系统核心配置,包括站点、安全、订阅、邀请佣金、节点、邮件和通知等设置"})]}),e.jsx(ge,{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(Gd,{items:wr})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(Qt,{})})})]})]})]})}const Wd=Object.freeze(Object.defineProperty({__proto__:null,default:Yd},Symbol.toStringTag,{value:"Module"}));function Jd({title:s,description:t,children:a}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t})]}),e.jsx(ge,{}),a]})}const H=c.forwardRef(({className:s,...t},a)=>e.jsx(Rn,{className:y("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),...t,ref:a,children:e.jsx(eo,{className:y("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")})}));H.displayName=Rn.displayName;const vs=c.forwardRef(({className:s,...t},a)=>e.jsx("textarea",{className:y("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:a,...t}));vs.displayName="Textarea";const Qd=u.object({logo:u.string().nullable().default(""),force_https:u.number().nullable().default(0),stop_register:u.number().nullable().default(0),app_name:u.string().nullable().default(""),app_description:u.string().nullable().default(""),app_url:u.string().nullable().default(""),subscribe_url:u.string().nullable().default(""),try_out_plan_id:u.number().nullable().default(0),try_out_hour:u.coerce.number().nullable().default(0),tos_url:u.string().nullable().default(""),currency:u.string().nullable().default(""),currency_symbol:u.string().nullable().default("")});function Zd(){const[s,t]=c.useState(!1),a=c.useRef(null),{data:n}=Q({queryKey:["settings","site"],queryFn:()=>os("site")}),{data:l}=Q({queryKey:["plans"],queryFn:()=>Ps()}),o=ae({resolver:ie(Qd),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=Je({mutationFn:cs,onSuccess:i=>{i.data&&A.success("已自动保存")}});c.useEffect(()=>{if(n?.data?.site){const i=n?.data?.site;Object.entries(i).forEach(([h,T])=>{o.setValue(h,T)}),a.current=i}},[n]);const x=c.useCallback(de.debounce(async i=>{if(!de.isEqual(i,a.current)){t(!0);try{const h=Object.entries(i).reduce((T,[C,m])=>(T[C]=m===null?"":m,T),{});await d(h),a.current=i}finally{t(!1)}}},1e3),[d]),r=c.useCallback(i=>{x(i)},[x]);return c.useEffect(()=>{const i=o.watch(h=>{r(h)});return()=>i.unsubscribe()},[o.watch,r]),e.jsx(oe,{...o,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:o.control,name:"app_name",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"站点名称"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入站点名称",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"用于显示需要站点名称的地方。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"app_description",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"站点描述"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入站点描述",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"用于显示需要站点描述的地方。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"app_url",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"站点网址"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入站点URL,末尾不要/",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"当前网站最新网址,将会在邮件等需要用于网址处体现。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"force_https",render:({field:i})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"强制HTTPS"}),e.jsx(F,{children:"当站点没有使用HTTPS,CDN或反代开启强制HTTPS时需要开启。"})]}),e.jsx(b,{children:e.jsx(H,{checked:!!i.value,onCheckedChange:h=>{i.onChange(Number(h)),r(o.getValues())}})})]})}),e.jsx(g,{control:o.control,name:"logo",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"LOGO"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入LOGO URL,末尾不要/",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"用于显示需要LOGO的地方。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"subscribe_url",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"订阅URL"}),e.jsx(b,{children:e.jsx(vs,{placeholder:"用于订阅所使用,多个订阅地址用','隔开.留空则为站点URL。",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"用于订阅所使用,留空则为站点URL。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"tos_url",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"用户条款(TOS)URL"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入用户条款URL,末尾不要/",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"用于跳转到用户条款(TOS)"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"stop_register",render:({field:i})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"停止新用户注册"}),e.jsx(F,{children:"开启后任何人都将无法进行注册。"})]}),e.jsx(b,{children:e.jsx(H,{checked:!!i.value,onCheckedChange:h=>{i.onChange(Number(h)),r(o.getValues())}})})]})}),e.jsx(g,{control:o.control,name:"try_out_plan_id",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"注册试用"}),e.jsx(b,{children:e.jsxs(G,{value:i.value?.toString(),onValueChange:h=>{i.onChange(Number(h)),r(o.getValues())},children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"关闭"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"关闭"}),l?.data?.map(h=>e.jsx(O,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(F,{children:"选择需要试用的订阅,如果没有选项请先前往订阅管理添加。"}),e.jsx(k,{})]})}),!!o.watch("try_out_plan_id")&&e.jsx(g,{control:o.control,name:"try_out_hour",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"",children:"注册试用时长"}),e.jsx(b,{children:e.jsx(S,{placeholder:"0",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"注册试用时长,单位为小时。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"currency",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"货币单位"}),e.jsx(b,{children:e.jsx(S,{placeholder:"CNY",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"仅用于展示使用,更改后系统中所有的货币单位都将发生变更。"}),e.jsx(k,{})]})}),e.jsx(g,{control:o.control,name:"currency_symbol",render:({field:i})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"货币符号"}),e.jsx(b,{children:e.jsx(S,{placeholder:"¥",...i,value:i.value||"",onChange:h=>{i.onChange(h),r(o.getValues())}})}),e.jsx(F,{children:"仅用于展示使用,更改后系统中所有的货币单位都将发生变更。"}),e.jsx(k,{})]})}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function Xd(){const s=wr.find(t=>t.key==="site");return e.jsx(Jd,{title:s.title,description:s.description,children:e.jsx(Zd,{})})}const eu=Object.freeze(Object.defineProperty({__proto__:null,default:Xd},Symbol.toStringTag,{value:"Module"})),su=u.object({email_verify:u.boolean().nullable(),safe_mode_enable:u.boolean().nullable(),secure_path:u.string().nullable(),email_whitelist_enable:u.boolean().nullable(),email_whitelist_suffix:u.array(u.string().nullable()).nullable(),email_gmail_limit_enable:u.boolean().nullable(),recaptcha_enable:u.boolean().nullable(),recaptcha_key:u.string().nullable(),recaptcha_site_key:u.string().nullable(),register_limit_by_ip_enable:u.boolean().nullable(),register_limit_count:u.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:u.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:u.boolean().nullable(),password_limit_count:u.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:u.coerce.string().transform(s=>s===""?null:s).nullable()}),tu={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 au(){const[s,t]=c.useState(!1),a=c.useRef(null),n=ae({resolver:ie(su),defaultValues:tu,mode:"onBlur"}),{data:l}=Q({queryKey:["settings","safe"],queryFn:()=>os("safe")}),{mutateAsync:o}=Je({mutationFn:cs,onSuccess:r=>{r.data&&A.success("已自动保存")}});c.useEffect(()=>{if(l?.data.safe){const r=l.data.safe;Object.entries(r).forEach(([i,h])=>{typeof h=="number"?n.setValue(i,String(h)):n.setValue(i,h)}),a.current=r}},[l]);const d=c.useCallback(de.debounce(async r=>{if(!de.isEqual(r,a.current)){t(!0);try{await o(r),a.current=r}finally{t(!1)}}},1e3),[o]),x=c.useCallback(r=>{d(r)},[d]);return c.useEffect(()=>{const r=n.watch(i=>{x(i)});return()=>r.unsubscribe()},[n.watch,x]),e.jsx(oe,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:n.control,name:"email_verify",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"邮箱验证"}),e.jsx(F,{children:"开启后将会强制要求用户进行邮箱验证。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"email_gmail_limit_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"禁止使用Gmail多别名"}),e.jsx(F,{children:"开启后Gmail多别名将无法注册。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"safe_mode_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"安全模式"}),e.jsx(F,{children:"开启后除了站点URL以外的绑定本站点的域名访问都将会被403。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"secure_path",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"后台路径"}),e.jsx(b,{children:e.jsx(S,{placeholder:"admin",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(F,{children:"后台管理路径,修改后将会改变原有的admin路径"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"email_whitelist_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"邮箱后缀白名单"}),e.jsx(F,{children:"开启后在名单中的邮箱后缀才允许进行注册。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),n.watch("email_whitelist_enable")&&e.jsx(g,{control:n.control,name:"email_whitelist_suffix",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"白名单后缀"}),e.jsx(b,{children:e.jsx(vs,{placeholder:"请输入后缀域名,逗号分割 如:qq.com,gmail.com",value:r.value?.length?r.value.join(","):"",onChange:i=>{const h=i.target.value?i.target.value.split(","):[];r.onChange(h),x(n.getValues())}})}),e.jsx(F,{children:"请使用逗号进行分割,如:qq.com,gmail.com。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"recaptcha_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"防机器人"}),e.jsx(F,{children:"开启后将会使用Google reCAPTCHA防止机器人。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),n.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:n.control,name:"recaptcha_key",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"密钥"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入密钥",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"recaptcha_site_key",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"站点密钥"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入站点密钥",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(k,{})]})})]}),e.jsx(g,{control:n.control,name:"register_limit_by_ip_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"IP注册限制"}),e.jsx(F,{children:"开启后同一IP将会被限制注册次数。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),n.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:n.control,name:"register_limit_count",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"限制次数"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入限制次数",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"register_limit_expire",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"限制时长(分钟)"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入限制时长",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(k,{})]})})]}),e.jsx(g,{control:n.control,name:"password_limit_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"密码错误限制"}),e.jsx(F,{children:"开启后密码错误将会被限制登录。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),n.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:n.control,name:"password_limit_count",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"限制次数"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入限制次数",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"password_limit_expire",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"限制时长(分钟)"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入限制时长",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsx(k,{})]})})]}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function nu(){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:"配置系统安全相关选项,包括登录验证、密码策略、API访问等安全设置。"})]}),e.jsx(ge,{}),e.jsx(au,{})]})}const ru=Object.freeze(Object.defineProperty({__proto__:null,default:nu},Symbol.toStringTag,{value:"Module"})),lu=u.object({plan_change_enable:u.boolean().nullable().default(!1),reset_traffic_method:u.coerce.number().nullable().default(0),surplus_enable:u.boolean().nullable().default(!1),new_order_event_id:u.coerce.number().nullable().default(0),renew_order_event_id:u.coerce.number().nullable().default(0),change_order_event_id:u.coerce.number().nullable().default(0),show_info_to_server_enable:u.boolean().nullable().default(!1),show_protocol_to_server_enable:u.boolean().nullable().default(!1),default_remind_expire:u.boolean().nullable().default(!1),default_remind_traffic:u.boolean().nullable().default(!1),remind_mail_enable:u.boolean().nullable().default(!1),subscribe_path:u.string().nullable().default("s")}),iu={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,remind_mail_enable:!1,subscribe_path:"s"};function ou(){const[s,t]=c.useState(!1),a=c.useRef(null),n=ae({resolver:ie(lu),defaultValues:iu,mode:"onBlur"}),{data:l}=Q({queryKey:["settings","subscribe"],queryFn:()=>os("subscribe")}),{mutateAsync:o}=Je({mutationFn:cs,onSuccess:r=>{r.data&&A.success("已自动保存")}});c.useEffect(()=>{if(l?.data?.subscribe){const r=l?.data?.subscribe;Object.entries(r).forEach(([i,h])=>{n.setValue(i,h)}),a.current=r}},[l]);const d=c.useCallback(de.debounce(async r=>{if(!de.isEqual(r,a.current)){t(!0);try{await o(r),a.current=r}finally{t(!1)}}},1e3),[o]),x=c.useCallback(r=>{d(r)},[d]);return c.useEffect(()=>{const r=n.watch(i=>{x(i)});return()=>r.unsubscribe()},[n.watch,x]),e.jsx(oe,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:n.control,name:"plan_change_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"允许用户更改订阅"}),e.jsx(F,{children:"开启后用户将会可以对订阅计划进行变更。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"reset_traffic_method",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"月流量重置方式"}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(G,{onValueChange:r.onChange,value:r.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"每月1号"}),e.jsx(O,{value:"1",children:"按月重置"}),e.jsx(O,{value:"2",children:"不重置"}),e.jsx(O,{value:"3",children:"每年1月1号"}),e.jsx(O,{value:"4",children:"按年重置"})]})]})})}),e.jsx(F,{children:"全局流量重置方式,默认每月1号。可以在订阅管理为订阅单独设置。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"surplus_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"开启折抵方案"}),e.jsx(F,{children:"开启后用户更换订阅将会由系统对原有订阅进行折抵,方案参考文档。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"new_order_event_id",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"当订阅新购时触发事件"}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(G,{onValueChange:r.onChange,value:r.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"不执行任何动作"}),e.jsx(O,{value:"1",children:"重置用户流量"})]})]})})}),e.jsx(F,{children:"新购订阅完成时将触发该任务。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"renew_order_event_id",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"当订阅续费时触发事件"}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(G,{onValueChange:r.onChange,value:r.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"不执行任何动作"}),e.jsx(O,{value:"1",children:"重置用户流量"})]})]})})}),e.jsx(F,{children:"续费订阅完成时将触发该任务。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"change_order_event_id",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"当订阅变更时触发事件"}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(G,{onValueChange:r.onChange,value:r.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"不执行任何动作"}),e.jsx(O,{value:"1",children:"重置用户流量"})]})]})})}),e.jsx(F,{children:"变更订阅完成时将触发该任务。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"subscribe_path",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"订阅路径"}),e.jsx(b,{children:e.jsx(S,{placeholder:"subscribe",...r,value:r.value||"",onChange:i=>{r.onChange(i),x(n.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["订阅路径,修改后将会改变原有的subscribe路径",e.jsx("br",{}),"当前订阅路径格式:",r.value?`${r.value}/xxxxxxxxxx`:"s/xxxxxxxxxx"]}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"show_info_to_server_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"在订阅中展示订阅信息"}),e.jsx(F,{children:"开启后将会在用户订阅节点时输出订阅信息。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"show_protocol_to_server_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"在订阅中线路名称中显示协议名称"}),e.jsx(F,{children:"开启后订阅线路会附带协议名称(例如: [Hy2]香港)"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"remind_mail_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"邮件提醒"}),e.jsx(F,{children:"开启后用户订阅即将到期时和流量告急时时将发送邮件通知。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value||!1,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function cu(){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(ge,{}),e.jsx(ou,{})]})}const du=Object.freeze(Object.defineProperty({__proto__:null,default:cu},Symbol.toStringTag,{value:"Module"})),uu=u.object({invite_force:u.boolean().default(!1),invite_commission:u.coerce.string().default("0"),invite_gen_limit:u.coerce.string().default("0"),invite_never_expire:u.boolean().default(!1),commission_first_time_enable:u.boolean().default(!1),commission_auto_check_enable:u.boolean().default(!1),commission_withdraw_limit:u.coerce.string().default("0"),commission_withdraw_method:u.array(u.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:u.boolean().default(!1),commission_distribution_enable:u.boolean().default(!1),commission_distribution_l1:u.coerce.number().default(0),commission_distribution_l2:u.coerce.number().default(0),commission_distribution_l3:u.coerce.number().default(0)}),xu={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 mu(){const[s,t]=c.useState(!1),a=c.useRef(null),n=ae({resolver:ie(uu),defaultValues:xu,mode:"onBlur"}),{data:l}=Q({queryKey:["settings","invite"],queryFn:()=>os("invite")}),{mutateAsync:o}=Je({mutationFn:cs,onSuccess:r=>{r.data&&A.success("已自动保存")}});c.useEffect(()=>{if(l?.data?.invite){const r=l?.data?.invite;Object.entries(r).forEach(([i,h])=>{typeof h=="number"?n.setValue(i,String(h)):n.setValue(i,h)}),a.current=r}},[l]);const d=c.useCallback(de.debounce(async r=>{if(!de.isEqual(r,a.current)){t(!0);try{await o(r),a.current=r}finally{t(!1)}}},1e3),[o]),x=c.useCallback(r=>{d(r)},[d]);return c.useEffect(()=>{const r=n.watch(i=>{x(i)});return()=>r.unsubscribe()},[n.watch,x]),e.jsx(oe,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:n.control,name:"invite_force",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"开启强制邀请"}),e.jsx(F,{children:"开启后只有被邀请的用户才可以进行注册。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"invite_commission",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:" 邀请佣金百分比"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",...r,value:r.value||""})}),e.jsx(F,{children:"默认全局的佣金分配比例,你可以在用户管理单独配置单个比例。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"invite_gen_limit",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"用户可创建邀请码上限"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",...r,value:r.value||""})}),e.jsx(F,{children:"用户可创建邀请码上限"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"invite_never_expire",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"邀请码永不失效"}),e.jsx(F,{children:"开启后邀请码被使用后将不会失效,否则使用过后即失效。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"commission_first_time_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"佣金仅首次发放"}),e.jsx(F,{children:"开启后被邀请人首次支付时才会产生佣金,可以在用户管理对用户进行单独配置。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"commission_auto_check_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"佣金自动确认"}),e.jsx(F,{children:"开启后佣金将会在订单完成3日后自动进行确认。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"commission_withdraw_limit",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"提现单申请门槛(元)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",...r,value:r.value||""})}),e.jsx(F,{children:"小于门槛金额的提现单将不会被提交。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"commission_withdraw_method",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"提现方式"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",...r,value:Array.isArray(r.value)?r.value.join(","):"",onChange:i=>{const h=i.target.value.split(",").filter(Boolean);r.onChange(h),x(n.getValues())}})}),e.jsx(F,{children:"可以支持的提现方式,多个用逗号分隔。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"withdraw_close_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"关闭提现"}),e.jsx(F,{children:"关闭后将禁止用户申请提现,且邀请佣金将会直接进入用户余额。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),e.jsx(g,{control:n.control,name:"commission_distribution_enable",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"三级分销"}),e.jsx(F,{children:"开启后将佣金将按照设置的3成比例进行分成,三成比例合计请不要大于100%。"})]}),e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:i=>{r.onChange(i),x(n.getValues())}})})]})}),n.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:n.control,name:"commission_distribution_l1",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"一级邀请人比例"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入比例如:50",...r,value:r.value||"",onChange:i=>{const h=i.target.value?Number(i.target.value):0;r.onChange(h),x(n.getValues())}})}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"commission_distribution_l2",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"二级邀请人比例"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入比例如:50",...r,value:r.value||"",onChange:i=>{const h=i.target.value?Number(i.target.value):0;r.onChange(h),x(n.getValues())}})}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"commission_distribution_l3",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"三级邀请人比例"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入比例如:50",...r,value:r.value||"",onChange:i=>{const h=i.target.value?Number(i.target.value):0;r.onChange(h),x(n.getValues())}})}),e.jsx(k,{})]})})]}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function hu(){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(ge,{}),e.jsx(mu,{})]})}const ju=Object.freeze(Object.defineProperty({__proto__:null,default:hu},Symbol.toStringTag,{value:"Module"})),gu=u.object({frontend_theme:u.string().nullable(),frontend_theme_sidebar:u.string().nullable(),frontend_theme_header:u.string().nullable(),frontend_theme_color:u.string().nullable(),frontend_background_url:u.string().url().nullable()}),fu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function pu(){const{data:s}=Q({queryKey:["settings","frontend"],queryFn:()=>os("frontend")}),t=ae({resolver:ie(gu),defaultValues:fu,mode:"onChange"});c.useEffect(()=>{if(s?.data?.frontend){const n=s?.data?.frontend;Object.entries(n).forEach(([l,o])=>{t.setValue(l,o)})}},[s]);function a(n){cs(n).then(({data:l})=>{l&&A.success("更新成功")})}return e.jsx(oe,{...t,children:e.jsxs("form",{onSubmit:t.handleSubmit(a),className:"space-y-8",children:[e.jsx(g,{control:t.control,name:"frontend_theme_sidebar",render:({field:n})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(H,{checked:n.value,onCheckedChange:n.onChange})})]})}),e.jsx(g,{control:t.control,name:"frontend_theme_header",render:({field:n})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(p,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(H,{checked:n.value,onCheckedChange:n.onChange})})]})}),e.jsx(g,{control:t.control,name:"frontend_theme_color",render:({field:n})=>e.jsxs(j,{children:[e.jsx(p,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(b,{children:e.jsxs("select",{className:y($s({variant:"outline"}),"w-[200px] appearance-none font-normal"),...n,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(ea,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(k,{})]})}),e.jsx(g,{control:t.control,name:"frontend_background_url",render:({field:n})=>e.jsxs(j,{children:[e.jsx(p,{children:"背景"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入图片地址",...n})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(k,{})]})}),e.jsx(D,{type:"submit",children:"保存设置"})]})})}function vu(){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(ge,{}),e.jsx(pu,{})]})}const bu=Object.freeze(Object.defineProperty({__proto__:null,default:vu},Symbol.toStringTag,{value:"Module"})),yu=u.object({server_pull_interval:u.coerce.number().nullable(),server_push_interval:u.coerce.number().nullable(),server_token:u.string().nullable(),device_limit_mode:u.coerce.number().nullable()}),Nu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function wu(){const[s,t]=c.useState(!1),a=c.useRef(null),n=ae({resolver:ie(yu),defaultValues:Nu,mode:"onBlur"}),{data:l}=Q({queryKey:["settings","server"],queryFn:()=>os("server")}),{mutateAsync:o}=Je({mutationFn:cs,onSuccess:r=>{r.data&&A.success("已自动保存")}});c.useEffect(()=>{if(l?.data.server){const r=l.data.server;Object.entries(r).forEach(([i,h])=>{n.setValue(i,h)}),a.current=r}},[l]);const d=c.useCallback(de.debounce(async r=>{if(!de.isEqual(r,a.current)){t(!0);try{await o(r),a.current=r}finally{t(!1)}}},1e3),[o]),x=c.useCallback(r=>{d(r)},[d]);return c.useEffect(()=>{const r=n.watch(i=>{x(i)});return()=>r.unsubscribe()},[n.watch,x]),e.jsx(oe,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:n.control,name:"server_token",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"通讯密钥"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",...r,value:r.value||""})}),e.jsx(F,{children:"Xboard与节点通讯的密钥,以便数据不会被他人获取。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"server_pull_interval",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"节点拉取动作轮询间隔"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入",...r,value:r.value||"",onChange:i=>{const h=i.target.value?Number(i.target.value):null;r.onChange(h)}})}),e.jsx(F,{children:"节点从面板获取数据的间隔频率。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"server_push_interval",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"节点推送动作轮询间隔"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入",...r,value:r.value||"",onChange:i=>{const h=i.target.value?Number(i.target.value):null;r.onChange(h)}})}),e.jsx(F,{children:"节点推送数据到面板的间隔频率。"}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"device_limit_mode",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"设备限制模式"}),e.jsxs(G,{onValueChange:r.onChange,value:r.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择设备限制模式"})})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"严格模式"}),e.jsx(O,{value:"1",children:"宽松模式"})]})]}),e.jsx(F,{children:"宽松模式下,同一IP地址使用多个节点只统计为一个设备。"}),e.jsx(k,{})]})}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function _u(){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(ge,{}),e.jsx(wu,{})]})}const Cu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"}));function Su({open:s,onOpenChange:t,result:a}){const n=!a.error;return e.jsx(ue,{open:s,onOpenChange:t,children:e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(je,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[n?e.jsx(Pn,{className:"h-5 w-5 text-green-500"}):e.jsx(In,{className:"h-5 w-5 text-destructive"}),e.jsx(xe,{children:n?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Se,{children:n?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),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:a.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:a.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:a.template_name})]})]}),a.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:a.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(tt,{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:a.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:a.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:a.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:a.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:a.config.from.address?`${a.config.from.address}${a.config.from.name?` (${a.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:a.config.username||"未设置"})]})})})]})]})]})})}const ku=u.object({email_template:u.string().nullable().default("classic"),email_host:u.string().nullable().default(""),email_port:u.string().regex(/^\d+$/).nullable().default("465"),email_username:u.string().nullable().default(""),email_password:u.string().nullable().default(""),email_encryption:u.string().nullable().default(""),email_from_address:u.string().email().nullable().default("")});function Du(){const[s,t]=c.useState(null),[a,n]=c.useState(!1),l=c.useRef(null),[o,d]=c.useState(!1),x=ae({resolver:ie(ku),defaultValues:{},mode:"onBlur"}),{data:r}=Q({queryKey:["settings","email"],queryFn:()=>os("email")}),{data:i}=Q({queryKey:["emailTemplate"],queryFn:()=>Cd()}),{mutateAsync:h}=Je({mutationFn:cs,onSuccess:_=>{_.data&&A.success("已自动保存")}}),{mutate:T,isPending:C}=Je({mutationFn:Sd,onMutate:()=>{t(null),n(!1)},onSuccess:_=>{t(_.data),n(!0),_.data.error||A.success("发送成功")}});c.useEffect(()=>{if(r?.data.email){const _=r.data.email;Object.entries(_).forEach(([v,N])=>{x.setValue(v,N)}),l.current=_}},[r]);const m=c.useCallback(de.debounce(async _=>{if(!de.isEqual(_,l.current)){d(!0);try{await h(_),l.current=_}finally{d(!1)}}},1e3),[h]),w=c.useCallback(_=>{m(_)},[m]);return c.useEffect(()=>{const _=x.watch(v=>{w(v)});return()=>_.unsubscribe()},[x.watch,w]),e.jsxs(e.Fragment,{children:[e.jsx(oe,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:x.control,name:"email_host",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"SMTP服务器地址"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",..._,value:_.value||""})}),e.jsx(F,{children:"由邮件服务商提供的服务地址"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"email_port",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"SMTP服务端口"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",..._,value:_.value||""})}),e.jsx(F,{children:"常见的端口有25, 465, 587"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"email_encryption",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"SMTP加密方式"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",..._,value:_.value||""})}),e.jsx(F,{children:"465端口加密方式一般为SSL,587端口加密方式一般为TLS"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"email_username",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"SMTP账号"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",..._,value:_.value||""})}),e.jsx(F,{children:"由邮件服务商提供的账号"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"email_password",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"SMTP密码"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",..._,value:_.value||"",type:"password"})}),e.jsx(F,{children:"由邮件服务商提供的密码"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"email_from_address",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"发件地址"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入",..._,value:_.value||""})}),e.jsx(F,{children:"由邮件服务商提供的发件地址"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"email_template",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"邮件模板"}),e.jsxs(G,{onValueChange:v=>{_.onChange(v),w(x.getValues())},value:_.value||void 0,children:[e.jsx(b,{children:e.jsx(U,{className:"w-[200px]",children:e.jsx(Y,{placeholder:"选择邮件模板"})})}),e.jsx(B,{children:i?.data?.map(v=>e.jsx(O,{value:v,children:v},v))})]}),e.jsx(F,{children:"你可以在文档查看如何自定义邮件模板"}),e.jsx(k,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{onClick:()=>T(),loading:C,disabled:C,children:C?"发送中...":"发送测试邮件"})})]})}),o&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."}),s&&e.jsx(Su,{open:a,onOpenChange:n,result:s})]})}function Tu(){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:"配置系统邮件服务,用于发送验证码、密码重置、通知等邮件,支持多种SMTP服务商。"})]}),e.jsx(ge,{}),e.jsx(Du,{})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:Tu},Symbol.toStringTag,{value:"Module"})),Iu=u.object({telegram_bot_enable:u.boolean().nullable(),telegram_bot_token:u.string().nullable(),telegram_discuss_link:u.string().nullable()}),Vu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Ru(){const[s,t]=c.useState(!1),a=c.useRef(null),n=ae({resolver:ie(Iu),defaultValues:Vu,mode:"onBlur"}),{data:l}=Q({queryKey:["settings","telegram"],queryFn:()=>os("telegram")}),{mutateAsync:o}=Je({mutationFn:cs,onSuccess:h=>{h.data&&A.success("已自动保存")}}),{mutate:d,isPending:x}=Je({mutationFn:kd,onSuccess:h=>{h.data&&A.success("Webhook设置成功")}});c.useEffect(()=>{if(l?.data.telegram){const h=l.data.telegram;Object.entries(h).forEach(([T,C])=>{n.setValue(T,C)}),a.current=h}},[l]);const r=c.useCallback(de.debounce(async h=>{if(!de.isEqual(h,a.current)){t(!0);try{await o(h),a.current=h}finally{t(!1)}}},1e3),[o]),i=c.useCallback(h=>{r(h)},[r]);return c.useEffect(()=>{const h=n.watch(T=>{i(T)});return()=>h.unsubscribe()},[n.watch,i]),e.jsx(oe,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:n.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"机器人Token"}),e.jsx(b,{children:e.jsx(S,{placeholder:"0000000000:xxxxxxxxx_xxxxxxxxxxxxxxx",...h,value:h.value||""})}),e.jsx(F,{children:"请输入由Botfather提供的token。"}),e.jsx(k,{})]})}),n.watch("telegram_bot_token")&&e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"设置Webhook"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{loading:x,disabled:x,onClick:()=>d(),children:x?"Webhook设置中...":"一键设置"}),s&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"保存中..."})]}),e.jsx(F,{children:"对机器人进行Webhook设置,不设置将无法收到Telegram通知。"}),e.jsx(k,{})]}),e.jsx(g,{control:n.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"开启机器人通知"}),e.jsx(F,{children:"开启后bot将会对绑定了telegram的管理员和用户进行基础通知。"}),e.jsx(b,{children:e.jsx(H,{checked:h.value||!1,onCheckedChange:T=>{h.onChange(T),i(n.getValues())}})}),e.jsx(k,{})]})}),e.jsx(g,{control:n.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(j,{children:[e.jsx(p,{className:"text-base",children:"群组地址"}),e.jsx(b,{children:e.jsx(S,{placeholder:"https://t.me/xxxxxx",...h,value:h.value||""})}),e.jsx(F,{children:"填写后将会在用户端展示,或者被用于需要的地方。"}),e.jsx(k,{})]})}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function Eu(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Telegram设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置Telegram机器人功能,实现用户通知、账户绑定、指令交互等自动化服务。"})]}),e.jsx(ge,{}),e.jsx(Ru,{})]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Eu},Symbol.toStringTag,{value:"Module"})),Mu=u.object({windows_version:u.string().nullable(),windows_download_url:u.string().nullable(),macos_version:u.string().nullable(),macos_download_url:u.string().nullable(),android_version:u.string().nullable(),android_download_url:u.string().nullable()}),zu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Ou(){const[s,t]=c.useState(!1),a=c.useRef(null),n=ae({resolver:ie(Mu),defaultValues:zu,mode:"onBlur"}),{data:l}=Q({queryKey:["settings","app"],queryFn:()=>os("app")}),{mutateAsync:o}=Je({mutationFn:cs,onSuccess:r=>{r.data&&A.success("已自动保存")}});c.useEffect(()=>{if(l?.data.app){const r=l.data.app;Object.entries(r).forEach(([i,h])=>{n.setValue(i,h)}),a.current=r}},[l]);const d=c.useCallback(de.debounce(async r=>{if(!de.isEqual(r,a.current)){t(!0);try{await o(r),a.current=r}finally{t(!1)}}},1e3),[o]),x=c.useCallback(r=>{d(r)},[d]);return c.useEffect(()=>{const r=n.watch(i=>{x(i)});return()=>r.unsubscribe()},[n.watch,x]),e.jsx(oe,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Windows"}),e.jsx("div",{className:"text-[0.8rem] text-muted-foreground",children:"Windows端版本号及下载地址"}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1",children:e.jsx(g,{control:n.control,name:"windows_version",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:e.jsx(S,{placeholder:"1.0.0",...r,value:r.value||""})}),e.jsx(k,{})]})})}),e.jsx("div",{children:e.jsx(g,{control:n.control,name:"windows_download_url",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:e.jsx(S,{placeholder:"https://xxx.com/xxx.exe",...r,value:r.value||""})}),e.jsx(k,{})]})})})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"macOS"}),e.jsx("div",{className:"text-[0.8rem] text-muted-foreground",children:"macOS端版本号及下载地址"}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1",children:e.jsx(g,{control:n.control,name:"macos_version",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:e.jsx(S,{placeholder:"1.0.0",...r,value:r.value||""})}),e.jsx(k,{})]})})}),e.jsx("div",{children:e.jsx(g,{control:n.control,name:"macos_download_url",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:e.jsx(S,{placeholder:"https://xxx.com/xxx.dmg",...r,value:r.value||""})}),e.jsx(k,{})]})})})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Android"}),e.jsx("div",{className:"text-[0.8rem] text-muted-foreground",children:"Android端版本号及下载地址"}),e.jsxs("div",{children:[e.jsx("div",{className:"mb-1",children:e.jsx(g,{control:n.control,name:"android_version",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:e.jsx(S,{placeholder:"1.0.0",...r,value:r.value||""})}),e.jsx(k,{})]})})}),e.jsx("div",{children:e.jsx(g,{control:n.control,name:"android_download_url",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:e.jsx(S,{placeholder:"https://xxx.com/xxx.apk",...r,value:r.value||""})}),e.jsx(k,{})]})})})]})]}),s&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"保存中..."})]})})}function Lu(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"APP设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"管理移动应用程序相关配置,包括API接口、版本控制、推送通知等功能设置。"})]}),e.jsx(ge,{}),e.jsx(Ou,{})]})}const $u=Object.freeze(Object.defineProperty({__proto__:null,default:Lu},Symbol.toStringTag,{value:"Module"})),ia=c.forwardRef(({className:s,...t},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:y("w-full caption-bottom text-sm",s),...t})}));ia.displayName="Table";const oa=c.forwardRef(({className:s,...t},a)=>e.jsx("thead",{ref:a,className:y("[&_tr]:border-b",s),...t}));oa.displayName="TableHeader";const ca=c.forwardRef(({className:s,...t},a)=>e.jsx("tbody",{ref:a,className:y("[&_tr:last-child]:border-0",s),...t}));ca.displayName="TableBody";const Au=c.forwardRef(({className:s,...t},a)=>e.jsx("tfoot",{ref:a,className:y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...t}));Au.displayName="TableFooter";const js=c.forwardRef(({className:s,...t},a)=>e.jsx("tr",{ref:a,className:y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...t}));js.displayName="TableRow";const da=c.forwardRef(({className:s,...t},a)=>e.jsx("th",{ref:a,className:y("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t}));da.displayName="TableHead";const Os=c.forwardRef(({className:s,...t},a)=>e.jsx("td",{ref:a,className:y("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...t}));Os.displayName="TableCell";const Hu=c.forwardRef(({className:s,...t},a)=>e.jsx("caption",{ref:a,className:y("mt-4 text-sm text-muted-foreground",s),...t}));Hu.displayName="TableCaption";function Ku({table:s}){const[t,a]=c.useState("");c.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const n=l=>{const o=parseInt(l);!isNaN(o)&&o>=1&&o<=s.getPageCount()?s.setPageIndex(o-1):a((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.jsxs("div",{className:"flex-1 text-sm text-muted-foreground",children:["已选择 ",s.getFilteredSelectedRowModel().rows.length," 项, 共"," ",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:"每页显示"}),e.jsxs(G,{value:`${s.getState().pagination.pageSize}`,onValueChange:l=>{s.setPageSize(Number(l))},children:[e.jsx(U,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(l=>e.jsx(O,{value:`${l}`,children:l},l))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:"第"}),e.jsx(S,{type:"text",value:t,onChange:l=>a(l.target.value),onBlur:l=>n(l.target.value),onKeyDown:l=>{l.key==="Enter"&&n(l.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsxs("span",{children:["页,共 ",s.getPageCount()," 页"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(D,{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:"跳转到第一页"}),e.jsx(so,{className:"h-4 w-4"})]}),e.jsxs(D,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"上一页"}),e.jsx(_n,{className:"h-4 w-4"})]}),e.jsxs(D,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"下一页"}),e.jsx(Xt,{className:"h-4 w-4"})]}),e.jsxs(D,{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:"跳转到最后一页"}),e.jsx(to,{className:"h-4 w-4"})]})]})]})]})}function Ge({table:s,toolbar:t,draggable:a=!1,onDragStart:n,onDragEnd:l,onDragOver:o,onDragLeave:d,onDrop:x,showPagination:r=!0,isLoading:i=!1}){const h=c.useRef(null),T=s.getAllColumns().filter(_=>_.getIsPinned()==="left"),C=s.getAllColumns().filter(_=>_.getIsPinned()==="right"),m=_=>T.slice(0,_).reduce((v,N)=>v+(N.getSize()??0),0),w=_=>C.slice(_+1).reduce((v,N)=>v+(N.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof t=="function"?t(s):t,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(oa,{children:s.getHeaderGroups().map(_=>e.jsx(js,{className:"hover:bg-transparent",children:_.headers.map((v,N)=>{const P=v.column.getIsPinned()==="left",f=v.column.getIsPinned()==="right",R=P?m(T.indexOf(v.column)):void 0,z=f?w(C.indexOf(v.column)):void 0;return e.jsx(da,{colSpan:v.colSpan,style:{width:v.getSize(),...P&&{left:R},...f&&{right:z}},className:y("h-11 bg-card px-4 text-muted-foreground",(P||f)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",P&&"before:right-0",f&&"before:left-0"]),children:v.isPlaceholder?null:vt(v.column.columnDef.header,v.getContext())},v.id)})},_.id))}),e.jsx(ca,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((_,v)=>e.jsx(js,{"data-state":_.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:N=>n?.(N,v),onDragEnd:l,onDragOver:o,onDragLeave:d,onDrop:N=>x?.(N,v),children:_.getVisibleCells().map((N,P)=>{const f=N.column.getIsPinned()==="left",R=N.column.getIsPinned()==="right",z=f?m(T.indexOf(N.column)):void 0,$=R?w(C.indexOf(N.column)):void 0;return e.jsx(Os,{style:{width:N.column.getSize(),...f&&{left:z},...R&&{right:$}},className:y("bg-card",(f||R)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",f&&"before:right-0",R&&"before:left-0"]),children:vt(N.column.columnDef.cell,N.getContext())},N.id)})},_.id)):e.jsx(js,{children:e.jsx(Os,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:"暂无数据"})})})]})})}),r&&e.jsx(Ku,{table:s})]})}const _r=(s,t)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(S,{placeholder:s.placeholder,...t});break;case"textarea":a=e.jsx(vs,{placeholder:s.placeholder,...t});break;case"select":a=e.jsx("select",{className:y(Ls({variant:"outline"}),"w-full appearance-none font-normal"),...t,children:s.select_options&&Object.keys(s.select_options).map(n=>e.jsx("option",{value:n,children:s.select_options?.[n]},n))});break;default:a=null;break}return a},qu=u.object({id:u.number().nullable(),name:u.string().min(2,"名称至少需要2个字符").max(30,"名称不能超过30个字符"),icon:u.string().optional().nullable(),notify_domain:u.string().refine(s=>!s||/^https?:\/\/\S+/.test(s),"请输入有效的URL").optional().nullable(),handling_fee_fixed:u.coerce.number().min(0).optional().nullable(),handling_fee_percent:u.coerce.number().min(0).max(100).optional().nullable(),payment:u.string().min(1,"请选择支付接口"),config:u.record(u.string(),u.string())}),Oa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function Cr({refetch:s,dialogTrigger:t,type:a="add",defaultFormValues:n=Oa}){const[l,o]=c.useState(!1),[d,x]=c.useState(!1),[r,i]=c.useState([]),[h,T]=c.useState([]),C=ae({resolver:ie(qu),defaultValues:n,mode:"onChange"}),m=C.watch("payment");c.useEffect(()=>{l&&(async()=>{const{data:v}=await Uc();i(v)})()},[l]),c.useEffect(()=>{if(!m||!l)return;(async()=>{const v={payment:m,...a==="edit"&&{id:Number(C.getValues("id"))}};Bc(v).then(({data:N})=>{T(N);const P=N.reduce((f,R)=>(R.field_name&&(f[R.field_name]=R.value??""),f),{});C.setValue("config",P)})})()},[m,l,C,a]);const w=async _=>{x(!0),(await Gc(_)).data&&(A.success("保存成功"),C.reset(Oa),s(),o(!1)),x(!1)};return e.jsxs(ue,{open:l,onOpenChange:o,children:[e.jsx(Re,{asChild:!0,children:t||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ve,{icon:"ion:add"})," ",e.jsx("div",{children:"添加支付方式"})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(je,{children:e.jsx(xe,{children:a==="add"?"添加支付方式":"编辑支付方式"})}),e.jsx(oe,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(w),className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"name",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{children:"显示名称"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入支付名称",..._})}),e.jsx(F,{children:"用于前端显示"}),e.jsx(k,{})]})}),e.jsx(g,{control:C.control,name:"icon",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{children:"图标URL"}),e.jsx(b,{children:e.jsx(S,{placeholder:"https://example.com/icon.svg",..._})}),e.jsx(F,{children:"用于前端显示的图标地址"}),e.jsx(k,{})]})}),e.jsx(g,{control:C.control,name:"notify_domain",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{children:"通知域名"}),e.jsx(b,{children:e.jsx(S,{placeholder:"https://example.com",..._})}),e.jsx(F,{children:"网关通知将发送到该域名"}),e.jsx(k,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{control:C.control,name:"handling_fee_percent",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{children:"百分比手续费(%)"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"0-100",..._})}),e.jsx(k,{})]})}),e.jsx(g,{control:C.control,name:"handling_fee_fixed",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{children:"固定手续费"}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"0",..._})}),e.jsx(k,{})]})})]}),e.jsx(g,{control:C.control,name:"payment",render:({field:_})=>e.jsxs(j,{children:[e.jsx(p,{children:"支付接口"}),e.jsxs(G,{value:_.value,onValueChange:_.onChange,children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择支付接口"})})}),e.jsx(B,{children:r.map(v=>e.jsx(O,{value:v,children:v},v))})]}),e.jsx(k,{})]})}),h.map(_=>e.jsx(g,{control:C.control,name:`config.${_.field_name}`,render:({field:v})=>e.jsxs(j,{children:[e.jsx(p,{children:_.label}),e.jsx(b,{children:_r(_,v)}),e.jsx(k,{})]})},_.field_name)),e.jsxs(Ee,{className:"gap-2",children:[e.jsx(it,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:"取消"})}),e.jsx(D,{type:"submit",disabled:d,className:y(d&&"cursor-not-allowed opacity-50"),children:d?"保存中...":"提交"})]})]})})]})]})}function I({column:s,title:t,tooltip:a,className:n}){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(D,{variant:"ghost",size:"default",className:y("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",n),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:t}),a&&e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(Ca,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ee,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(At,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Ht,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ao,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:y("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",n),children:[e.jsx("span",{children:t}),a&&e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{children:e.jsx(Ca,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ee,{children:a})]})})]})}const Uu=no,Bu=ro,Gu=lo,Sr=c.forwardRef(({className:s,...t},a)=>e.jsx(En,{className:y("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),...t,ref:a}));Sr.displayName=En.displayName;const kr=c.forwardRef(({className:s,...t},a)=>e.jsxs(Gu,{children:[e.jsx(Sr,{}),e.jsx(Fn,{ref:a,className:y("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})]}));kr.displayName=Fn.displayName;const Dr=({className:s,...t})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...t});Dr.displayName="AlertDialogHeader";const Tr=({className:s,...t})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...t});Tr.displayName="AlertDialogFooter";const Pr=c.forwardRef(({className:s,...t},a)=>e.jsx(Mn,{ref:a,className:y("text-lg font-semibold",s),...t}));Pr.displayName=Mn.displayName;const Ir=c.forwardRef(({className:s,...t},a)=>e.jsx(zn,{ref:a,className:y("text-sm text-muted-foreground",s),...t}));Ir.displayName=zn.displayName;const Vr=c.forwardRef(({className:s,...t},a)=>e.jsx(On,{ref:a,className:y(Ls(),s),...t}));Vr.displayName=On.displayName;const Rr=c.forwardRef(({className:s,...t},a)=>e.jsx(Ln,{ref:a,className:y(Ls({variant:"outline"}),"mt-2 sm:mt-0",s),...t}));Rr.displayName=Ln.displayName;function Ye({onConfirm:s,children:t,title:a="确认操作",description:n="确定要执行此操作吗?",cancelText:l="取消",confirmText:o="确认",variant:d="default",className:x}){return e.jsxs(Uu,{children:[e.jsx(Bu,{asChild:!0,children:t}),e.jsxs(kr,{className:y("sm:max-w-[425px]",x),children:[e.jsxs(Dr,{children:[e.jsx(Pr,{children:a}),e.jsx(Ir,{children:n})]}),e.jsxs(Tr,{children:[e.jsx(Rr,{asChild:!0,children:e.jsx(D,{variant:"outline",children:l})}),e.jsx(Vr,{asChild:!0,children:e.jsx(D,{variant:d,onClick:s,children:o})})]})]})]})}const Er=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"})}),Yu=({refetch:s,isSortMode:t=!1})=>[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:t?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(I,{column:a,title:"ID"}),cell:({row:a})=>e.jsx(L,{variant:"outline",children:a.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:a})=>e.jsx(I,{column:a,title:"启用"}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("enable"),onCheckedChange:async()=>{const{data:n}=await Wc({id:a.original.id});n||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:a})=>e.jsx(I,{column:a,title:"显示名称"}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:a.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:a})=>e.jsx(I,{column:a,title:"支付接口"}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:a.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:a})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(I,{column:a,title:"通知地址"}),e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{className:"ml-1",children:e.jsx(Er,{className:"h-4 w-4"})}),e.jsx(ee,{children:"支付网关将会把数据通知到本地址,请通过防火墙放行本地址。"})]})})]}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:a.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:a})=>e.jsx(I,{className:"justify-end",column:a,title:"操作"}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Cr,{refetch:s,dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]}),type:"edit",defaultFormValues:a.original}),e.jsx(Ye,{title:"删除确认",description:"确定要删除该支付方式吗?此操作无法撤销。",onConfirm:async()=>{const{data:n}=await Yc({id:a.original.id});n&&s()},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]}),size:100}];function Wu({table:s,refetch:t,saveOrder:a,isSortMode:n}){const l=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"拖拽支付方式进行排序,完成后点击保存"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cr,{refetch:t}),e.jsx(S,{placeholder:"搜索支付方式...",value:s.getColumn("name")?.getFilterValue()??"",onChange:o=>s.getColumn("name")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),l&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:["重置",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:n?"default":"outline",onClick:a,size:"sm",children:n?"保存排序":"编辑排序"})})]})}function Ju(){const[s,t]=c.useState([]),[a,n]=c.useState([]),[l,o]=c.useState(!1),[d,x]=c.useState([]),[r,i]=c.useState({"drag-handle":!1}),[h,T]=c.useState({pageSize:20,pageIndex:0}),{refetch:C}=Q({queryKey:["paymentList"],queryFn:async()=>{const{data:N}=await qc();return x(N?.map(P=>({...P,enable:!!P.enable}))||[]),N}});c.useEffect(()=>{i({"drag-handle":l}),T({pageSize:l?99999:10,pageIndex:0})},[l]);const m=(N,P)=>{l&&(N.dataTransfer.setData("text/plain",P.toString()),N.currentTarget.classList.add("opacity-50"))},w=(N,P)=>{if(!l)return;N.preventDefault(),N.currentTarget.classList.remove("bg-muted");const f=parseInt(N.dataTransfer.getData("text/plain"));if(f===P)return;const R=[...d],[z]=R.splice(f,1);R.splice(P,0,z),x(R)},_=async()=>{l?Jc({ids:d.map(N=>N.id)}).then(()=>{C(),o(!1),A.success("排序保存成功")}):o(!0)},v=Le({data:d,columns:Yu({refetch:C,isSortMode:l}),state:{sorting:a,columnFilters:s,columnVisibility:r,pagination:h},onSortingChange:n,onColumnFiltersChange:t,onColumnVisibilityChange:i,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),initialState:{columnPinning:{right:["actions"]}},pageCount:l?1:void 0});return e.jsx(Ge,{table:v,toolbar:N=>e.jsx(Wu,{table:N,refetch:C,saveOrder:_,isSortMode:l}),draggable:l,onDragStart:m,onDragEnd:N=>N.currentTarget.classList.remove("opacity-50"),onDragOver:N=>{N.preventDefault(),N.currentTarget.classList.add("bg-muted")},onDragLeave:N=>N.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!l})}function Qu(){return e.jsxs(ye,{children:[e.jsxs(Ne,{className:"flex items-center justify-between",children:[e.jsx(ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"支付配置"})}),e.jsx("p",{className:"text-muted-foreground",children:"在这里可以配置支付方式,包括支付宝、微信等。"})]})}),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(Ju,{})})]})]})}const Zu=Object.freeze(Object.defineProperty({__proto__:null,default:Qu},Symbol.toStringTag,{value:"Module"}));function Xu({themeKey:s,themeInfo:t}){const[a,n]=c.useState(!1),[l,o]=c.useState(!1),[d,x]=c.useState(!1),r=ae({defaultValues:t.configs.reduce((T,C)=>(T[C.field_name]="",T),{})}),i=async()=>{o(!0),Pc(s).then(({data:T})=>{Object.entries(T).forEach(([C,m])=>{r.setValue(C,m)})}).finally(()=>{o(!1)})},h=async T=>{x(!0),Ic(s,T).then(()=>{A.success("保存成功"),n(!1)}).finally(()=>{x(!1)})};return e.jsxs(ue,{open:a,onOpenChange:T=>{n(T),T?i():r.reset()},children:[e.jsx(Re,{asChild:!0,children:e.jsx(D,{variant:"outline",children:"主题设置"})}),e.jsxs(ce,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(je,{children:[e.jsxs(xe,{children:["配置",t.name,"主题"]}),e.jsx(Se,{children:"修改主题的样式、布局和其他显示选项。"})]}),l?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(sa,{className:"h-6 w-6 animate-spin"})}):e.jsx(oe,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(h),className:"space-y-4",children:[t.configs.map(T=>e.jsx(g,{control:r.control,name:T.field_name,render:({field:C})=>e.jsxs(j,{children:[e.jsx(p,{children:T.label}),e.jsx(b,{children:_r(T,C)}),e.jsx(k,{})]})},T.field_name)),e.jsxs(Ee,{className:"mt-6 gap-2",children:[e.jsx(D,{type:"button",variant:"secondary",onClick:()=>n(!1),children:"取消"}),e.jsx(D,{type:"submit",loading:d,children:"保存"})]})]})})]})]})}function ex(){const[s,t]=c.useState(null),[a,n]=c.useState(!1),[l,o]=c.useState(!1),[d,x]=c.useState(!1),[r,i]=c.useState(null),h=c.useRef(null),[T,C]=c.useState(0),{data:m,isLoading:w,refetch:_}=Q({queryKey:["themeList"],queryFn:async()=>{const{data:E}=await Tc();return E}}),v=async E=>{t(E),Ec({frontend_theme:E}).then(()=>{A.success("主题切换成功"),_()}).finally(()=>{t(null)})},N=async E=>{if(!E.name.endsWith(".zip")){A.error("只支持上传 ZIP 格式的主题文件");return}n(!0),Vc(E).then(()=>{A.success("主题上传成功"),o(!1),_()}).finally(()=>{n(!1),h.current&&(h.current.value="")})},P=E=>{E.preventDefault(),E.stopPropagation(),E.type==="dragenter"||E.type==="dragover"?x(!0):E.type==="dragleave"&&x(!1)},f=E=>{E.preventDefault(),E.stopPropagation(),x(!1),E.dataTransfer.files&&E.dataTransfer.files[0]&&N(E.dataTransfer.files[0])},R=()=>{r&&C(E=>E===0?r.images.length-1:E-1)},z=()=>{r&&C(E=>E===r.images.length-1?0:E+1)},$=(E,K)=>{C(0),i({name:E,images:K})};return e.jsxs(ye,{children:[e.jsxs(Ne,{className:"flex items-center justify-between",children:[e.jsx(ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"主题配置"})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:"主题配置,包括主题色、字体大小等。如果你采用前后分离的方式部署V2board,那么主题配置将不会生效。"}),e.jsxs(D,{onClick:()=>o(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Sa,{className:"mr-2 h-4 w-4"}),"上传主题"]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:w?e.jsxs(e.Fragment,{children:[e.jsx(La,{}),e.jsx(La,{})]}):m?.themes&&Object.entries(m.themes).map(([E,K])=>e.jsx(Ie,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:K.background_url?`url(${K.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:y("relative z-10 h-full transition-colors",K.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:[!!K.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Ye,{title:"删除主题",description:"确定要删除该主题吗?删除后无法恢复。",confirmText:"删除",variant:"destructive",onConfirm:async()=>{if(E===m?.active){A.error("不能删除当前使用的主题");return}t(E),Rc(E).then(()=>{A.success("主题删除成功"),_()}).finally(()=>{t(null)})},children:e.jsx(D,{disabled:s===E,loading:s===E,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(rs,{className:"h-4 w-4"})})})}),e.jsxs(ze,{children:[e.jsx(Qe,{children:K.name}),e.jsx(Zs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:K.description}),K.version&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:["版本: ",K.version]})]})})]}),e.jsxs(Oe,{className:"flex items-center justify-end space-x-3",children:[K.images&&Array.isArray(K.images)&&K.images.length>0&&e.jsx(D,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>$(K.name,K.images),children:e.jsx(io,{className:"h-4 w-4"})}),e.jsx(Xu,{themeKey:E,themeInfo:K}),e.jsx(D,{onClick:()=>v(E),disabled:s===E||E===m.active,loading:s===E,variant:E===m.active?"secondary":"default",children:E===m.active?"当前主题":"激活主题"})]})]})},E))}),e.jsx(ue,{open:l,onOpenChange:o,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(je,{children:[e.jsx(xe,{children:"上传主题"}),e.jsx(Se,{children:"请上传一个有效的主题压缩包(.zip 格式)。主题包应包含完整的主题文件结构。"})]}),e.jsxs("div",{className:y("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:f,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:E=>{const K=E.target.files?.[0];K&&N(K)}}),a?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:"正在上传..."})]}):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(Sa,{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:["将主题文件拖放到此处,或者",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:"点击选择"})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"支持 .zip 格式的主题包"})]})]})})]})]})}),e.jsx(ue,{open:!!r,onOpenChange:E=>{E||(i(null),C(0))},children:e.jsxs(ce,{className:"max-w-4xl",children:[e.jsxs(je,{children:[e.jsxs(xe,{children:[r?.name," 主题预览"]}),e.jsx(Se,{className:"text-center",children:r&&`${T+1} / ${r.images.length}`})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:r?.images[T]&&e.jsx("img",{src:r.images[T],alt:`${r.name} 预览图 ${T+1}`,className:"h-full w-full object-contain"})}),r&&r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(D,{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:R,children:e.jsx(oo,{className:"h-4 w-4"})}),e.jsx(D,{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:z,children:e.jsx(co,{className:"h-4 w-4"})})]})]}),r&&r.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:r.images.map((E,K)=>e.jsx("button",{onClick:()=>C(K),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",T===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:E,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function La(){return e.jsxs(Ie,{children:[e.jsxs(ze,{children:[e.jsx(Fe,{className:"h-6 w-[200px]"}),e.jsx(Fe,{className:"h-4 w-[300px]"})]}),e.jsxs(Oe,{className:"flex items-center justify-end space-x-3",children:[e.jsx(Fe,{className:"h-10 w-[100px]"}),e.jsx(Fe,{className:"h-10 w-[100px]"})]})]})}const sx=Object.freeze(Object.defineProperty({__proto__:null,default:ex},Symbol.toStringTag,{value:"Module"})),ua=c.forwardRef(({className:s,value:t,onChange:a,...n},l)=>{const[o,d]=c.useState("");c.useEffect(()=>{if(o.includes(",")){const r=new Set([...t,...o.split(",").map(i=>i.trim())]);a(Array.from(r)),d("")}},[o,a,t]);const x=()=>{if(o){const r=new Set([...t,o]);a(Array.from(r)),d("")}};return e.jsxs("div",{className:y(" 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:[t.map(r=>e.jsxs(L,{variant:"secondary",children:[r,e.jsx(W,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(t.filter(i=>i!==r))},children:e.jsx(Kt,{className:"w-3"})})]},r)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:o,onChange:r=>d(r.target.value),onKeyDown:r=>{r.key==="Enter"||r.key===","?(r.preventDefault(),x()):r.key==="Backspace"&&o.length===0&&t.length>0&&(r.preventDefault(),a(t.slice(0,-1)))},...n,ref:l})]})});ua.displayName="InputTags";const tx=u.object({id:u.number().nullable(),title:u.string().min(1).max(250),content:u.string().min(1),show:u.boolean(),tags:u.array(u.string()),img_url:u.string().nullable()}),ax={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Fr({refetch:s,dialogTrigger:t,type:a="add",defaultFormValues:n=ax}){const[l,o]=c.useState(!1),d=ae({resolver:ie(tx),defaultValues:n,mode:"onChange",shouldFocusError:!0}),x=new ta({html:!0});return e.jsx(oe,{...d,children:e.jsxs(ue,{onOpenChange:o,open:l,children:[e.jsx(Re,{asChild:!0,children:t||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ve,{icon:"ion:add"})," ",e.jsx("div",{children:"添加公告"})]})}),e.jsxs(ce,{className:"sm:max-w-[1025px]",children:[e.jsxs(je,{children:[e.jsx(xe,{children:a==="add"?"添加公告":"编辑公告"}),e.jsx(Se,{})]}),e.jsx(g,{control:d.control,name:"title",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"标题"}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(S,{placeholder:"请输入公告标题",...r})})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"content",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"公告内容"}),e.jsx(b,{children:e.jsx(aa,{style:{height:"500px"},value:r.value,renderHTML:i=>x.render(i),onChange:({text:i})=>{r.onChange(i)}})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"img_url",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"公告背景"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(S,{type:"text",placeholder:"请输入公告背景图片URL",...r,value:r.value||""})})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"显示"}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:r.onChange})})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"tags",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"节点标签"}),e.jsx(b,{children:e.jsx(ua,{value:r.value,onChange:r.onChange,placeholder:"输入后回车添加标签",className:"w-full"})}),e.jsx(k,{})]})}),e.jsxs(Ee,{children:[e.jsx(it,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:"取消"})}),e.jsx(D,{type:"submit",onClick:r=>{r.preventDefault(),d.handleSubmit(async i=>{Zc(i).then(({data:h})=>{h&&(A.success("提交成功"),s(),o(!1))})})()},children:"提交"})]})]})]})})}function nx({table:s,refetch:t,saveOrder:a,isSortMode:n}){const l=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:[!n&&e.jsx(Fr,{refetch:t}),!n&&e.jsx(S,{placeholder:"搜索公告标题...",value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),l&&!n&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:["重置",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(D,{variant:n?"default":"outline",onClick:a,className:"h-8",size:"sm",children:n?"保存排序":"编辑排序"})})]})}const rx=s=>[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(uo,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(I,{column:t,title:"ID"}),cell:({row:t})=>e.jsx(L,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(I,{column:t,title:"显示状态"}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(H,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:a}=await ed({id:t.original.id});a||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(I,{column:t,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(I,{className:"justify-end",column:t,title:"操作"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Fr,{refetch:s,dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]}),type:"edit",defaultFormValues:t.original}),e.jsx(Ye,{title:"删除确认",description:"确定要删除该条公告吗?此操作无法撤销。",onConfirm:async()=>{Xc({id:t.original.id}).then(()=>{A.success("删除成功"),s()})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]}),size:100}];function lx(){const[s,t]=c.useState({}),[a,n]=c.useState({}),[l,o]=c.useState([]),[d,x]=c.useState([]),[r,i]=c.useState(!1),[h,T]=c.useState({}),[C,m]=c.useState({pageSize:50,pageIndex:0}),[w,_]=c.useState([]),{refetch:v}=Q({queryKey:["notices"],queryFn:async()=>{const{data:z}=await Qc();return _(z),z}});c.useEffect(()=>{n({"drag-handle":r,content:!r,created_at:!r,actions:!r}),m({pageSize:r?99999:50,pageIndex:0})},[r]);const N=(z,$)=>{r&&(z.dataTransfer.setData("text/plain",$.toString()),z.currentTarget.classList.add("opacity-50"))},P=(z,$)=>{if(!r)return;z.preventDefault(),z.currentTarget.classList.remove("bg-muted");const E=parseInt(z.dataTransfer.getData("text/plain"));if(E===$)return;const K=[...w],[ds]=K.splice(E,1);K.splice($,0,ds),_(K)},f=async()=>{if(!r){i(!0);return}Dd(w.map(z=>z.id)).then(()=>{A.success("排序保存成功"),i(!1),v()}).finally(()=>{i(!1)})},R=Le({data:w??[],columns:rx(v),state:{sorting:d,columnVisibility:a,rowSelection:s,columnFilters:l,columnSizing:h,pagination:C},enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:x,onColumnFiltersChange:o,onColumnVisibilityChange:n,onColumnSizingChange:T,onPaginationChange:m,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),getFacetedRowModel:ls(),getFacetedUniqueValues:is(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(Ge,{table:R,toolbar:z=>e.jsx(nx,{table:z,refetch:v,saveOrder:f,isSortMode:r}),draggable:r,onDragStart:N,onDragEnd:z=>z.currentTarget.classList.remove("opacity-50"),onDragOver:z=>{z.preventDefault(),z.currentTarget.classList.add("bg-muted")},onDragLeave:z=>z.currentTarget.classList.remove("bg-muted"),onDrop:P,showPagination:!r})})}function ix(){return e.jsxs(ye,{children:[e.jsxs(Ne,{className:"flex items-center justify-between",children:[e.jsx(ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"公告管理"})}),e.jsx("p",{className:"text-muted-foreground",children:"在这里可以配置公告,包括添加、删除、编辑等操作。"})]})}),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(lx,{})})]})]})}const ox=Object.freeze(Object.defineProperty({__proto__:null,default:ix},Symbol.toStringTag,{value:"Module"})),cx=u.object({id:u.number().nullable(),language:u.string().max(250),category:u.string().max(250),title:u.string().min(1).max(250),body:u.string().min(1),show:u.boolean()}),dx={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Mr({refreshData:s,dialogTrigger:t,type:a="add",defaultFormValues:n=dx}){const[l,o]=c.useState(!1),d=ae({resolver:ie(cx),defaultValues:n,mode:"onChange",shouldFocusError:!0}),x=new ta({html:!0});return c.useEffect(()=>{l&&n.id&&td(n.id).then(({data:r})=>{d.reset(r)})},[n.id,d,l]),e.jsxs(ue,{onOpenChange:o,open:l,children:[e.jsx(Re,{asChild:!0,children:t||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ve,{icon:"ion:add"})," ",e.jsx("div",{children:"添加知识"})]})}),e.jsxs(ce,{className:"sm:max-w-[1025px]",children:[e.jsxs(je,{children:[e.jsx(xe,{children:a==="add"?"添加知识":"编辑知识"}),e.jsx(Se,{})]}),e.jsxs(oe,{...d,children:[e.jsx(g,{control:d.control,name:"title",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"标题"}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(S,{placeholder:"请输入知识标题",...r})})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"category",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"分类"}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(S,{placeholder:"请输入分类,分类将会自动归类",...r})})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"language",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"语言"}),e.jsx(b,{children:e.jsxs(G,{value:r.value,onValueChange:r.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择语言"})}),e.jsx(B,{children:[{field:"English",value:"en-US"},{field:"日本語",value:"ja-JP"},{field:"한국어",value:"ko-KR"},{field:"Tiếng Việt",value:"vi-VN"},{field:"简体中文",value:"zh-CN"},{field:"繁體中文",value:"zh-TW"}].map(i=>e.jsx(O,{value:i.value,className:"cursor-pointer",children:i.field},i.value))})]})})]})}),e.jsx(g,{control:d.control,name:"body",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"内容"}),e.jsx(b,{children:e.jsx(aa,{style:{height:"500px"},value:r.value,renderHTML:i=>x.render(i),onChange:({text:i})=>{r.onChange(i)}})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:r})=>e.jsxs(j,{children:[e.jsx(p,{children:"显示"}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(H,{checked:r.value,onCheckedChange:r.onChange})})}),e.jsx(k,{})]})}),e.jsxs(Ee,{children:[e.jsx(it,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:"取消"})}),e.jsx(D,{type:"submit",onClick:()=>{d.handleSubmit(r=>{ad(r).then(({data:i})=>{i&&(d.reset(),A.success("操作成功"),o(!1),s())})})()},children:"提交"})]})]})]})]})}function ux({column:s,title:t,options:a}){const n=s?.getFacetedUniqueValues(),l=new Set(s?.getFilterValue());return e.jsxs(Ze,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(lt,{className:"mr-2 h-4 w-4"}),t,l?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ge,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(L,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:l.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:l.size>2?e.jsxs(L,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[l.size," selected"]}):a.filter(o=>l.has(o.value)).map(o=>e.jsx(L,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(Be,{className:"w-[200px] p-0",align:"start",children:e.jsxs(fs,{children:[e.jsx(Ds,{placeholder:t}),e.jsxs(ps,{children:[e.jsx(Ts,{children:"No results found."}),e.jsx(Ve,{children:a.map(o=>{const d=l.has(o.value);return e.jsxs(be,{onSelect:()=>{d?l.delete(o.value):l.add(o.value);const x=Array.from(l);s?.setFilterValue(x.length?x:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Cs,{className:y("h-4 w-4")})}),o.icon&&e.jsx(o.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:o.label}),n?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:n.get(o.value)})]},o.value)})}),l.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(As,{}),e.jsx(Ve,{children:e.jsx(be,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function xx({table:s,refetch:t,saveOrder:a,isSortMode:n}){const l=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"拖拽知识条目进行排序,完成后点击保存"}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mr,{refreshData:t}),e.jsx(S,{placeholder:"搜索知识...",value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(ux,{column:s.getColumn("category"),title:"分类",options:Array.from(new Set(s.getCoreRowModel().rows.map(o=>o.getValue("category")))).map(o=>({label:o,value:o}))}),l&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:["重置",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:n?"default":"outline",onClick:a,size:"sm",children:n?"保存排序":"编辑排序"})})]})}const mx=({refetch:s,isSortMode:t=!1})=>[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:t?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(I,{column:a,title:"ID"}),cell:({row:a})=>e.jsx(L,{variant:"outline",className:"justify-center",children:a.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:a})=>e.jsx(I,{column:a,title:"状态"}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(H,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{rd({id:a.original.id}).then(({data:n})=>{n||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(I,{column:a,title:"标题"}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:a.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:a})=>e.jsx(I,{column:a,title:"分类"}),cell:({row:a})=>e.jsx(L,{variant:"secondary",className:"max-w-[180px] truncate",children:a.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:a})=>e.jsx(I,{className:"justify-end",column:a,title:"操作"}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Mr,{refreshData:s,dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]}),type:"edit",defaultFormValues:a.original}),e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该知识库记录,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{nd({id:a.original.id}).then(({data:n})=>{n&&(A.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]}),size:100}];function hx(){const[s,t]=c.useState([]),[a,n]=c.useState([]),[l,o]=c.useState(!1),[d,x]=c.useState([]),[r,i]=c.useState({"drag-handle":!1}),[h,T]=c.useState({pageSize:20,pageIndex:0}),{refetch:C,isLoading:m,data:w}=Q({queryKey:["knowledge"],queryFn:async()=>{const{data:f}=await sd();return x(f||[]),f}});c.useEffect(()=>{i({"drag-handle":l}),T({pageSize:l?99999:10,pageIndex:0})},[l]);const _=(f,R)=>{l&&(f.dataTransfer.setData("text/plain",R.toString()),f.currentTarget.classList.add("opacity-50"))},v=(f,R)=>{if(!l)return;f.preventDefault(),f.currentTarget.classList.remove("bg-muted");const z=parseInt(f.dataTransfer.getData("text/plain"));if(z===R)return;const $=[...d],[E]=$.splice(z,1);$.splice(R,0,E),x($)},N=async()=>{l?ld({ids:d.map(f=>f.id)}).then(()=>{C(),o(!1),A.success("排序保存成功")}):o(!0)},P=Le({data:d,columns:mx({refetch:C,isSortMode:l}),state:{sorting:a,columnFilters:s,columnVisibility:r,pagination:h},onSortingChange:n,onColumnFiltersChange:t,onColumnVisibilityChange:i,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ge,{table:P,toolbar:f=>e.jsx(xx,{table:f,refetch:C,saveOrder:N,isSortMode:l}),draggable:l,onDragStart:_,onDragEnd:f=>f.currentTarget.classList.remove("opacity-50"),onDragOver:f=>{f.preventDefault(),f.currentTarget.classList.add("bg-muted")},onDragLeave:f=>f.currentTarget.classList.remove("bg-muted"),onDrop:v,showPagination:!l})}function jx(){return e.jsxs(ye,{children:[e.jsxs(Ne,{children:[e.jsx(ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"知识库管理"}),e.jsx("p",{className:"text-muted-foreground",children:"在这里可以配置知识库,包括添加、删除、编辑等操作。"})]})}),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(hx,{})})]})]})}const gx=Object.freeze(Object.defineProperty({__proto__:null,default:jx},Symbol.toStringTag,{value:"Module"}));function fx(s,t){const[a,n]=c.useState(s);return c.useEffect(()=>{const l=setTimeout(()=>n(s),t);return()=>{clearTimeout(l)}},[s,t]),a}function Ot(s,t){if(s.length===0)return{};if(!t)return{"":s};const a={};return s.forEach(n=>{const l=n[t]||"";a[l]||(a[l]=[]),a[l].push(n)}),a}function px(s,t){const a=JSON.parse(JSON.stringify(s));for(const[n,l]of Object.entries(a))a[n]=l.filter(o=>!t.find(d=>d.value===o.value));return a}function vx(s,t){for(const[,a]of Object.entries(s))if(a.some(n=>t.find(l=>l.value===n.value)))return!0;return!1}const zr=c.forwardRef(({className:s,...t},a)=>xo(l=>l.filtered.count===0)?e.jsx("div",{ref:a,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...t}):null);zr.displayName="CommandEmpty";const at=c.forwardRef(({value:s,onChange:t,placeholder:a,defaultOptions:n=[],options:l,delay:o,onSearch:d,loadingIndicator:x,emptyIndicator:r,maxSelected:i=Number.MAX_SAFE_INTEGER,onMaxSelected:h,hidePlaceholderWhenSelected:T,disabled:C,groupBy:m,className:w,badgeClassName:_,selectFirstItem:v=!0,creatable:N=!1,triggerSearchOnFocus:P=!1,commandProps:f,inputProps:R,hideClearAllButton:z=!1},$)=>{const E=c.useRef(null),[K,ds]=c.useState(!1),Hs=c.useRef(!1),[fa,pa]=c.useState(!1),[J,Ks]=c.useState(s||[]),[bs,va]=c.useState(Ot(n,m)),[us,Ft]=c.useState(""),qs=fx(us,o||500);c.useImperativeHandle($,()=>({selectedValue:[...J],input:E.current,focus:()=>E.current?.focus()}),[J]);const ot=c.useCallback(q=>{const Z=J.filter(Ce=>Ce.value!==q.value);Ks(Z),t?.(Z)},[t,J]),ol=c.useCallback(q=>{const Z=E.current;Z&&((q.key==="Delete"||q.key==="Backspace")&&Z.value===""&&J.length>0&&(J[J.length-1].fixed||ot(J[J.length-1])),q.key==="Escape"&&Z.blur())},[ot,J]);c.useEffect(()=>{s&&Ks(s)},[s]),c.useEffect(()=>{if(!l||d)return;const q=Ot(l||[],m);JSON.stringify(q)!==JSON.stringify(bs)&&va(q)},[n,l,m,d,bs]),c.useEffect(()=>{const q=async()=>{pa(!0);const Ce=await d?.(qs);va(Ot(Ce||[],m)),pa(!1)};(async()=>{!d||!K||(P&&await q(),qs&&await q())})()},[qs,m,K,P]);const cl=()=>{if(!N||vx(bs,[{value:us,label:us}])||J.find(Z=>Z.value===us))return;const q=e.jsx(be,{value:us,className:"cursor-pointer",onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation()},onSelect:Z=>{if(J.length>=i){h?.(J.length);return}Ft("");const Ce=[...J,{value:Z,label:Z}];Ks(Ce),t?.(Ce)},children:`Create "${us}"`});if(!d&&us.length>0||d&&qs.length>0&&!fa)return q},dl=c.useCallback(()=>{if(r)return d&&!N&&Object.keys(bs).length===0?e.jsx(be,{value:"-",disabled:!0,children:r}):e.jsx(zr,{children:r})},[N,r,d,bs]),ul=c.useMemo(()=>px(bs,J),[bs,J]),xl=c.useCallback(()=>{if(f?.filter)return f.filter;if(N)return(q,Z)=>q.toLowerCase().includes(Z.toLowerCase())?1:-1},[N,f?.filter]),ml=c.useCallback(()=>{const q=J.filter(Z=>Z.fixed);Ks(q),t?.(q)},[t,J]);return e.jsxs(fs,{...f,onKeyDown:q=>{ol(q),f?.onKeyDown?.(q)},className:y("h-auto overflow-visible bg-transparent",f?.className),shouldFilter:f?.shouldFilter!==void 0?f.shouldFilter:!d,filter:xl(),children:[e.jsx("div",{className:y("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":J.length!==0,"cursor-text":!C&&J.length!==0},w),onClick:()=>{C||E.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[J.map(q=>e.jsxs(L,{className:y("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",_),"data-fixed":q.fixed,"data-disabled":C||void 0,children:[q.label,e.jsx("button",{className:y("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(C||q.fixed)&&"hidden"),onKeyDown:Z=>{Z.key==="Enter"&&ot(q)},onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation()},onClick:()=>ot(q),children:e.jsx(Kt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},q.value)),e.jsx(we.Input,{...R,ref:E,value:us,disabled:C,onValueChange:q=>{Ft(q),R?.onValueChange?.(q)},onBlur:q=>{Hs.current===!1&&ds(!1),R?.onBlur?.(q)},onFocus:q=>{ds(!0),P&&d?.(qs),R?.onFocus?.(q)},placeholder:T&&J.length!==0?"":a,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":T,"px-3 py-2":J.length===0,"ml-1":J.length!==0},R?.className)}),e.jsx("button",{type:"button",onClick:ml,className:y((z||C||J.length<1||J.filter(q=>q.fixed).length===J.length)&&"hidden"),children:e.jsx(Kt,{})})]})}),e.jsx("div",{className:"relative",children:K&&e.jsx(ps,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Hs.current=!1},onMouseEnter:()=>{Hs.current=!0},onMouseUp:()=>{E.current?.focus()},children:fa?e.jsx(e.Fragment,{children:x}):e.jsxs(e.Fragment,{children:[dl(),cl(),!v&&e.jsx(be,{value:"-",className:"hidden"}),Object.entries(ul).map(([q,Z])=>e.jsx(Ve,{heading:q,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:Z.map(Ce=>e.jsx(be,{value:Ce.value,disabled:Ce.disable,onMouseDown:Us=>{Us.preventDefault(),Us.stopPropagation()},onSelect:()=>{if(J.length>=i){h?.(J.length);return}Ft("");const Us=[...J,Ce];Ks(Us),t?.(Us)},className:y("cursor-pointer",Ce.disable&&"cursor-default text-muted-foreground"),children:Ce.label},Ce.value))})},q))]})})})]})});at.displayName="MultipleSelector";const bx=u.object({id:u.number().optional(),name:u.string().min(2,"组名至少需要2个字符").max(50,"组名不能超过50个字符").regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,"组名只能包含字母、数字、中文、下划线和连字符")});function Et({refetch:s,dialogTrigger:t,defaultValues:a={name:""},type:n="add"}){const l=ae({resolver:ie(bx),defaultValues:a,mode:"onChange"}),[o,d]=c.useState(!1),[x,r]=c.useState(!1),i=async h=>{r(!0),$c(h).then(()=>{A.success(n==="edit"?"更新成功":"创建成功"),s&&s(),l.reset(),d(!1)}).finally(()=>{r(!1)})};return e.jsxs(ue,{open:o,onOpenChange:d,children:[e.jsx(Re,{asChild:!0,children:t||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ve,{icon:"ion:add"}),e.jsx("span",{children:"添加权限组"})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(je,{children:[e.jsx(xe,{children:n==="edit"?"编辑权限组":"创建权限组"}),e.jsx(Se,{children:n==="edit"?"修改权限组信息,更新后会立即生效。":"创建新的权限组,可以为不同的用户分配不同的权限。"})]}),e.jsx(oe,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(g,{control:l.control,name:"name",render:({field:h})=>e.jsxs(j,{children:[e.jsx(p,{children:"组名称"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入权限组名称",...h,className:"w-full"})}),e.jsx(F,{children:"权限组名称用于标识不同的用户组,建议使用有意义的名称。"}),e.jsx(k,{})]})}),e.jsxs(Ee,{className:"gap-2",children:[e.jsx(it,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:"取消"})}),e.jsxs(D,{type:"submit",disabled:x||!l.formState.isValid,children:[x&&e.jsx(sa,{className:"mr-2 h-4 w-4 animate-spin"}),n==="edit"?"更新":"创建"]})]})]})})]})]})}const Or=c.createContext(void 0);function yx({children:s,refetch:t}){const[a,n]=c.useState(!1),[l,o]=c.useState(null),[d,x]=c.useState(pe.Shadowsocks);return e.jsx(Or.Provider,{value:{isOpen:a,setIsOpen:n,editingServer:l,setEditingServer:o,serverType:d,setServerType:x,refetch:t},children:s})}function Lr(){const s=c.useContext(Or);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Lt({dialogTrigger:s,value:t,setValue:a,templateType:n}){c.useEffect(()=>{console.log(t)},[t]);const[l,o]=c.useState(!1),[d,x]=c.useState(()=>{if(!t||Object.keys(t).length===0)return"";try{return JSON.stringify(t,null,2)}catch{return""}}),[r,i]=c.useState(null),h=v=>{if(!v)return null;try{const N=JSON.parse(v);return typeof N!="object"||N===null?"配置必须是一个JSON对象":null}catch{return"无效的JSON格式"}},T={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"}}}},C=()=>{switch(n){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},m=()=>{const v=h(d||"");if(v){A.error(v);return}try{if(!d){a(null),o(!1);return}a(JSON.parse(d)),o(!1)}catch{A.error("保存时发生错误")}},w=v=>{x(v),i(h(v))},_=v=>{const N=T[v];if(N){const P=JSON.stringify(N.content,null,2);x(P),i(null)}};return c.useEffect(()=>{l&&console.log(t)},[l,t]),c.useEffect(()=>{l&&t&&Object.keys(t).length>0&&x(JSON.stringify(t,null,2))},[l,t]),e.jsxs(ue,{open:l,onOpenChange:v=>{!v&&l&&m(),o(v)},children:[e.jsx(Re,{asChild:!0,children:s??e.jsx(W,{variant:"link",children:"编辑协议"})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(je,{children:e.jsx(xe,{children:"编辑协议配置"})}),e.jsxs("div",{className:"space-y-4",children:[C().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:C().map(v=>e.jsxs(W,{variant:"outline",size:"sm",onClick:()=>_(v),children:["使用",T[v].label,"模板"]},v))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(vs,{className:`min-h-[200px] font-mono text-sm ${r?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:`请输入JSON配置${C().length>0?"或选择上方模板":""}`,onChange:v=>w(v.target.value)}),r&&e.jsx("p",{className:"text-sm text-red-500",children:r})]})]}),e.jsxs(Ee,{className:"gap-2",children:[e.jsx(W,{variant:"outline",onClick:()=>o(!1),children:"取消"}),e.jsx(W,{onClick:m,disabled:!!r,children:"确定"})]})]})]})}function bh(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 Nx={},wx=Object.freeze(Object.defineProperty({__proto__:null,default:Nx},Symbol.toStringTag,{value:"Module"})),yh=_o(wx),$a=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),_x=()=>{try{const s=mo.box.keyPair(),t=$a(ka.encodeBase64(s.secretKey)),a=$a(ka.encodeBase64(s.publicKey));return{privateKey:t,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Cx=()=>{try{return _x()}catch(s){throw console.error("Error generating key pair:",s),s}},Sx=s=>{const t=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(t),Array.from(t).map(a=>a.toString(16).padStart(2,"0")).join("").substring(0,s)},kx=()=>{const s=Math.floor(Math.random()*8)*2+2;return Sx(s)},Dx=u.object({cipher:u.string().default("aes-128-gcm"),obfs:u.string().default("0"),obfs_settings:u.object({path:u.string().default(""),host:u.string().default("")}).default({})}),Tx=u.object({tls:u.coerce.number().default(0),tls_settings:u.object({server_name:u.string().default(""),allow_insecure:u.boolean().default(!1)}).default({}),network:u.string().default("tcp"),network_settings:u.record(u.any()).default({})}),Px=u.object({server_name:u.string().default(""),allow_insecure:u.boolean().default(!1),network:u.string().default("tcp"),network_settings:u.record(u.any()).default({})}),Ix=u.object({version:u.coerce.number().default(2),alpn:u.string().default("h2"),obfs:u.object({open:u.coerce.boolean().default(!1),type:u.string().default("salamander"),password:u.string().default("")}).default({}),tls:u.object({server_name:u.string().default(""),allow_insecure:u.boolean().default(!1)}).default({}),bandwidth:u.object({up:u.string().default(""),down:u.string().default("")}).default({})}),Vx=u.object({tls:u.coerce.number().default(0),tls_settings:u.object({server_name:u.string().default(""),allow_insecure:u.boolean().default(!1)}).default({}),reality_settings:u.object({server_port:u.coerce.number().default(443),server_name:u.string().default(""),allow_insecure:u.boolean().default(!1),public_key:u.string().default(""),private_key:u.string().default(""),short_id:u.string().default("")}).default({}),network:u.string().default("tcp"),network_settings:u.record(u.any()).default({}),flow:u.string().default("")}),es={shadowsocks:{schema:Dx,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:Tx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Px,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Ix,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Vx,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"]}},Rx=({serverType:s,value:t,onChange:a})=>{const n=s?es[s]:null,l=n?.schema||u.record(u.any()),o=s?l.parse({}):{},d=ae({resolver:ie(l),defaultValues:o,mode:"onChange"});return c.useEffect(()=>{if(!t||Object.keys(t).length===0){if(s){const m=l.parse({});d.reset(m)}}else d.reset(t)},[s,t,a,d,l]),c.useEffect(()=>{const m=d.watch(w=>{a(w)});return()=>m.unsubscribe()},[d,a]),!s||!n?null:{shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"cipher",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"加密算法"}),e.jsx(b,{children:e.jsxs(G,{onValueChange:m.onChange,value:m.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择加密算法"})}),e.jsx(B,{children:e.jsx(xs,{children:es.shadowsocks.ciphers.map(w=>e.jsx(O,{value:w,children:w},w))})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"混淆"}),e.jsx(b,{children:e.jsxs(G,{onValueChange:m.onChange,value:m.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择混淆方式"})}),e.jsx(B,{children:e.jsxs(xs,{children:[e.jsx(O,{value:"0",children:"无"}),e.jsx(O,{value:"http",children:"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:m})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:e.jsx(S,{type:"text",placeholder:"路径",...m})}),e.jsx(k,{})]})}),e.jsx(g,{control:d.control,name:"obfs_settings.host",render:({field:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:e.jsx(S,{type:"text",placeholder:"Host",...m})}),e.jsx(k,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"TLS"}),e.jsx(b,{children:e.jsxs(G,{value:m.value?.toString(),onValueChange:w=>m.onChange(Number(w)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择安全性"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"不支持"}),e.jsx(O,{value:"1",children:"支持"})]})]})})]})}),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:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"服务器名称指示(SNI)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"不使用请留空",...m})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"允许不安全?"}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(H,{checked:m.value,onCheckedChange:m.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:m})=>e.jsxs(j,{children:[e.jsxs(p,{children:["传输协议",e.jsx(Lt,{value:d.watch("network_settings"),setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")})]}),e.jsx(b,{children:e.jsxs(G,{onValueChange:m.onChange,value:m.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择传输协议"})}),e.jsx(B,{children:e.jsx(xs,{children:es.vmess.networkOptions.map(w=>e.jsx(O,{value:w.value,className:"cursor-pointer",children:w.label},w.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:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"服务器名称指示(SNI)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"当节点地址于证书不一致时用于证书验证",...m,value:m.value||""})})]})}),e.jsx(g,{control:d.control,name:"allow_insecure",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"允许不安全?"}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(H,{checked:m.value||!1,onCheckedChange:m.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:m})=>e.jsxs(j,{children:[e.jsxs(p,{children:["传输协议",e.jsx(Lt,{value:d.watch("network_settings")||{},setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")||"tcp"})]}),e.jsx(b,{children:e.jsxs(G,{onValueChange:m.onChange,value:m.value||"tcp",children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择传输协议"})}),e.jsx(B,{children:e.jsx(xs,{children:es.trojan.networkOptions.map(w=>e.jsx(O,{value:w.value,className:"cursor-pointer",children:w.label},w.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:m})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"协议版本"}),e.jsx(b,{children:e.jsxs(G,{value:(m.value||2).toString(),onValueChange:w=>m.onChange(Number(w)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"协议版本"})}),e.jsx(B,{children:e.jsx(xs,{children:es.hysteria.versions.map(w=>e.jsxs(O,{value:w,className:"cursor-pointer",children:["V",w]},w))})})]})})]})}),d.watch("version")==1&&e.jsx(g,{control:d.control,name:"alpn",render:({field:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"ALPN"}),e.jsx(b,{children:e.jsxs(G,{value:m.value||"h2",onValueChange:m.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"ALPN"})}),e.jsx(B,{children:e.jsx(xs,{children:es.hysteria.alpnOptions.map(w=>e.jsx(O,{value:w,children:w},w))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs.open",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"混淆"}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(H,{checked:m.value||!1,onCheckedChange:m.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:m})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"混淆实现"}),e.jsx(b,{children:e.jsxs(G,{value:m.value||"salamander",onValueChange:m.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择混淆实现"})}),e.jsx(B,{children:e.jsx(xs,{children:e.jsx(O,{value:"salamander",children:"Salamander"})})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs.password",render:({field:m})=>e.jsxs(j,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(p,{children:"混淆密码"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(S,{placeholder:"请输入混淆密码",...m,value:m.value||"",className:"pr-9"})}),e.jsx(W,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",_=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(v=>w[v%w.length]).join("");d.setValue("obfs.password",_),A.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:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"服务器名称指示(SNI)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"当节点地址于证书不一致时用于证书验证",...m,value:m.value||""})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"允许不安全?"}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(H,{checked:m.value||!1,onCheckedChange:m.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"bandwidth.up",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"上行宽带"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入上行宽带"+(d.watch("version")==2?",留空则使用BBR":""),className:"rounded-br-none rounded-tr-none",...m,value:m.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:"Mbps"})})]})]})}),e.jsx(g,{control:d.control,name:"bandwidth.down",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"下行宽带"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"请输入下行宽带"+(d.watch("version")==2?",留空则使用BBR":""),className:"rounded-br-none rounded-tr-none",...m,value:m.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:"Mbps"})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"安全性"}),e.jsx(b,{children:e.jsxs(G,{value:m.value?.toString(),onValueChange:w=>m.onChange(Number(w)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择安全性"})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"无"}),e.jsx(O,{value:"1",children:"TLS"}),e.jsx(O,{value:"2",children:"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:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"服务器名称指示(SNI)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"不使用请留空",...m})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"允许不安全?"}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(H,{checked:m.value,onCheckedChange:m.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:m})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"伪装站点(dest)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"例如:example.com",...m})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.server_port",render:({field:m})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"端口(port)"}),e.jsx(b,{children:e.jsx(S,{placeholder:"例如:443",...m})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.allow_insecure",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"允许不安全?"}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(H,{checked:m.value,onCheckedChange:m.onChange})})})]})})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx(g,{control:d.control,name:"reality_settings.private_key",render:({field:m})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"私钥(Private key)"}),e.jsx(b,{children:e.jsx(S,{...m})})]})}),e.jsxs(W,{variant:"outline",className:"",onClick:()=>{try{const m=Cx();d.setValue("reality_settings.private_key",m.privateKey),d.setValue("reality_settings.public_key",m.publicKey),A.success("密钥对生成成功")}catch{A.error("生成密钥对失败")}},children:[e.jsx(ve,{icon:"ion:key-outline",className:"mr-2 h-4 w-4"}),"生成密钥对"]})]}),e.jsx(g,{control:d.control,name:"reality_settings.public_key",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"公钥(Public key)"}),e.jsx(b,{children:e.jsx(S,{...m})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.short_id",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"Short ID"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{children:e.jsx(S,{...m,placeholder:"可留空,长度为2的倍数,最长16位"})}),e.jsxs(W,{variant:"outline",onClick:()=>{const w=kx();d.setValue("reality_settings.short_id",w),A.success("Short ID 生成成功")},children:[e.jsx(ve,{icon:"ion:refresh-outline",className:"mr-2 h-4 w-4"}),"生成"]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:"客户端可用的 shortId 列表,可用于区分不同的客户端,使用0-f的十六进制字符"})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:m})=>e.jsxs(j,{children:[e.jsxs(p,{children:["传输协议",e.jsx(Lt,{value:d.watch("network_settings"),setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")})]}),e.jsx(b,{children:e.jsxs(G,{onValueChange:m.onChange,value:m.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择传输协议"})}),e.jsx(B,{children:e.jsx(xs,{children:es.vless.networkOptions.map(w=>e.jsx(O,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"flow",render:({field:m})=>e.jsxs(j,{children:[e.jsx(p,{children:"流控"}),e.jsx(b,{children:e.jsxs(G,{onValueChange:w=>m.onChange(w==="none"?null:w),value:m.value||"none",children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"选择流控"})}),e.jsx(B,{children:es.vless.flowOptions.map(w=>e.jsx(O,{value:w,children:w},w))})]})})]})})]})}[s]?.()},Ex=u.object({id:u.number().optional().nullable(),code:u.string().optional(),name:u.string().min(1,"Please enter a valid name."),rate:u.string().min(1,"Please enter a valid rate."),tags:u.array(u.string()).default([]),excludes:u.array(u.string()).default([]),ips:u.array(u.string()).default([]),group_ids:u.array(u.string()).default([]),host:u.string().min(1,"Please enter a valid host."),port:u.string().min(1,"Please enter a valid port."),server_port:u.string().min(1,"Please enter a valid server port."),parent_id:u.string().default("0").nullable(),route_ids:u.array(u.string()).default([]),protocol_settings:u.record(u.any()).default({}).nullable()}),xt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Fx(){const{isOpen:s,setIsOpen:t,editingServer:a,setEditingServer:n,serverType:l,setServerType:o,refetch:d}=Lr(),[x,r]=c.useState([]),[i,h]=c.useState([]),[T,C]=c.useState([]),m=ae({resolver:ie(Ex),defaultValues:xt,mode:"onChange"});c.useEffect(()=>{w()},[s]),c.useEffect(()=>{a?.type&&a.type!==l&&o(a.type)},[a,l,o]),c.useEffect(()=>{a?a.type===l&&m.reset({...xt,...a}):m.reset({...xt,protocol_settings:es[l].schema.parse({})})},[a,m,l]);const w=async()=>{if(!s)return;const[f,R,z]=await Promise.all([Vt(),jr(),hr()]);r(f.data?.map($=>({label:$.name,value:$.id.toString()}))||[]),h(R.data?.map($=>({label:$.remarks,value:$.id.toString()}))||[]),C(z.data||[])},_=c.useMemo(()=>T?.filter(f=>(f.parent_id===0||f.parent_id===null)&&f.type===l&&f.id!==m.watch("id")),[l,T,m]),v=()=>e.jsxs(Ns,{children:[e.jsx(ws,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ve,{icon:"ion:add"}),e.jsx("div",{children:"添加节点"})]})}),e.jsx(gs,{align:"start",children:e.jsx(ic,{children:ys.map(({type:f,label:R})=>e.jsx(he,{onClick:()=>{o(f),t(!0)},className:"cursor-pointer",children:e.jsx(L,{variant:"outline",className:"text-white",style:{background:ts[f]},children:R})},f))})})]}),N=()=>{t(!1),n(null),m.reset(xt)},P=async()=>{const f=m.getValues();(await Fc({...f,type:l})).data&&(N(),A.success("提交成功"),d())};return e.jsxs(ue,{open:s,onOpenChange:N,children:[v(),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(je,{children:[e.jsx(xe,{children:a?"编辑节点":"新建节点"}),e.jsx(Se,{})]}),e.jsxs(oe,{...m,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:m.control,name:"name",render:({field:f})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"节点名称"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入节点名称",...f})}),e.jsx(k,{})]})}),e.jsx(g,{control:m.control,name:"rate",render:({field:f})=>e.jsxs(j,{className:"flex-[1]",children:[e.jsx(p,{children:"倍率"}),e.jsx("div",{className:"relative flex",children:e.jsx(b,{children:e.jsx(S,{type:"number",min:"0",step:"0.1",...f})})}),e.jsx(k,{})]})})]}),e.jsx(g,{control:m.control,name:"code",render:({field:f})=>e.jsxs(j,{children:[e.jsxs(p,{children:["自定义节点ID",e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:"(选填)"})]}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入自定义节点ID",...f,value:f.value||""})}),e.jsx(k,{})]})}),e.jsx(g,{control:m.control,name:"tags",render:({field:f})=>e.jsxs(j,{children:[e.jsx(p,{children:"节点标签"}),e.jsx(b,{children:e.jsx(ua,{value:f.value,onChange:f.onChange,placeholder:"输入后回车添加标签",className:"w-full"})}),e.jsx(k,{})]})}),e.jsx(g,{control:m.control,name:"group_ids",render:({field:f})=>e.jsxs(j,{children:[e.jsxs(p,{className:"flex items-center justify-between",children:["权限组",e.jsx(Et,{dialogTrigger:e.jsx(D,{variant:"link",children:"添加权限组"}),refetch:w})]}),e.jsx(b,{children:e.jsx(at,{options:x,onChange:R=>f.onChange(R.map(z=>z.value)),value:x?.filter(R=>f.value.includes(R.value)),placeholder:"请选择权限组",emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:"no results found."})})}),e.jsx(k,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:m.control,name:"host",render:({field:f})=>e.jsxs(j,{children:[e.jsx(p,{children:"节点地址"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入节点域名或者IP",...f})}),e.jsx(k,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(g,{control:m.control,name:"port",render:({field:f})=>e.jsxs(j,{className:"flex-1",children:[e.jsxs(p,{className:"flex items-center gap-1.5",children:["连接端口",e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Da,{children:e.jsx(ee,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:"用户实际连接使用的端口,这是客户端配置中需要填写的端口号。如果使用了中转或隧道,这个端口可能与服务器实际监听的端口不同。"})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(b,{children:e.jsx(S,{placeholder:"用户连接端口",...f})}),e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const R=f.value;R&&m.setValue("server_port",R)},children:e.jsx(ve,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ee,{side:"right",children:e.jsx("p",{children:"同步到服务端口"})})]})})]}),e.jsx(k,{})]})}),e.jsx(g,{control:m.control,name:"server_port",render:({field:f})=>e.jsxs(j,{className:"flex-1",children:[e.jsxs(p,{className:"flex items-center gap-1.5",children:["服务端口",e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Da,{children:e.jsx(ee,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:"服务器实际监听的端口,这是在服务器上开放的真实端口。如果使用了中转或隧道,这个端口可能与用户连接端口不同。"})})})]})})]}),e.jsx(b,{children:e.jsx(S,{placeholder:"服务端开放端口",...f})}),e.jsx(k,{})]})})]})]}),s&&e.jsx(Rx,{serverType:l,value:m.watch("protocol_settings"),onChange:f=>m.setValue("protocol_settings",f,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(g,{control:m.control,name:"parent_id",render:({field:f})=>e.jsxs(j,{children:[e.jsx(p,{children:"父节点"}),e.jsxs(G,{onValueChange:f.onChange,value:f.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"选择父节点"})})}),e.jsxs(B,{children:[e.jsx(O,{value:"0",children:"无"}),_?.map(R=>e.jsx(O,{value:R.id.toString(),className:"cursor-pointer",children:R.name},R.id))]})]}),e.jsx(k,{})]})}),e.jsx(g,{control:m.control,name:"route_ids",render:({field:f})=>e.jsxs(j,{children:[e.jsx(p,{children:"路由组"}),e.jsx(b,{children:e.jsx(at,{options:i,onChange:R=>f.onChange(R.map(z=>z.value)),value:i?.filter(R=>f.value.includes(R.value)),placeholder:"选择路由组",emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:"no results found."})})}),e.jsx(k,{})]})})]}),e.jsxs(Ee,{className:"mt-6",children:[e.jsx(D,{type:"button",variant:"outline",onClick:N,children:"取消"}),e.jsx(D,{type:"submit",onClick:P,children:"提交"})]})]})]})]})}function Aa({column:s,title:t,options:a}){const n=s?.getFacetedUniqueValues(),l=new Set(s?.getFilterValue());return e.jsxs(Ze,{children:[e.jsx(Xe,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(lt,{className:"mr-2 h-4 w-4"}),t,l?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ge,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(L,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:l.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:l.size>2?e.jsxs(L,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[l.size," selected"]}):a.filter(o=>l.has(o.value)).map(o=>e.jsx(L,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(Be,{className:"w-[200px] p-0",align:"start",children:e.jsxs(fs,{children:[e.jsx(Ds,{placeholder:t}),e.jsxs(ps,{children:[e.jsx(Ts,{children:"No results found."}),e.jsx(Ve,{children:a.map(o=>{const d=l.has(o.value);return e.jsxs(be,{onSelect:()=>{d?l.delete(o.value):l.add(o.value);const x=Array.from(l);s?.setFilterValue(x.length?x:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Cs,{className:y("h-4 w-4")})}),o.icon&&e.jsx(o.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${o.color}`}),e.jsx("span",{children:o.label}),n?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:n.get(o.value)})]},o.value)})}),l.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(As,{}),e.jsx(Ve,{children:e.jsx(be,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Mx=[{value:pe.Shadowsocks,label:ys.find(s=>s.type===pe.Shadowsocks)?.label,color:ts[pe.Shadowsocks]},{value:pe.Vmess,label:ys.find(s=>s.type===pe.Vmess)?.label,color:ts[pe.Vmess]},{value:pe.Trojan,label:ys.find(s=>s.type===pe.Trojan)?.label,color:ts[pe.Trojan]},{value:pe.Hysteria,label:ys.find(s=>s.type===pe.Hysteria)?.label,color:ts[pe.Hysteria]},{value:pe.Vless,label:ys.find(s=>s.type===pe.Vless)?.label,color:ts[pe.Vless]}];function zx({table:s,saveOrder:t,isSortMode:a,groups:n}){const l=s.getState().columnFilters.length>0,o=n.map(d=>({label:d,value:d}));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:[!a&&e.jsxs(e.Fragment,{children:[e.jsx(Fx,{}),e.jsx(S,{placeholder:"搜索节点...",value:s.getColumn("name")?.getFilterValue()??"",onChange:d=>s.getColumn("name")?.setFilterValue(d.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(Aa,{column:s.getColumn("type"),title:"类型",options:Mx}),s.getColumn("groups")&&e.jsx(Aa,{column:s.getColumn("groups"),title:"权限组",options:o})]}),l&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:["重置",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]}),a&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"拖拽节点进行排序,完成后点击保存"})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:a?"default":"outline",onClick:t,size:"sm",children:a?"保存排序":"编辑排序"})})]})}const nt=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"})}),mt={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"},ht={0:"未运行",1:"无人使用或异常",2:"运行正常"},Ox=s=>[{id:"drag-handle",header:({column:t})=>e.jsx(I,{column:t,title:"排序"}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Dt,{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(I,{column:t,title:"节点ID"}),cell:({row:t})=>{const a=t.getValue("id"),n=t.original.code;return e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(L,{variant:"outline",className:y("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:ts[t.original.type]},children:[e.jsx($n,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:n??a}),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(D,{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:l=>{l.stopPropagation(),Nt(n||a.toString())},children:e.jsx(Ta,{className:"size-3"})})]})}),e.jsxs(ee,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[ys.find(l=>l.type===t.original.type)?.label,t.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:200,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(I,{column:t,title:"显隐"}),cell:({row:t})=>{const[a,n]=c.useState(!!t.getValue("show"));return e.jsx(H,{checked:a,onCheckedChange:async l=>{n(l),Oc({id:t.original.id,type:t.original.type,show:l?1:0}).catch(()=>{n(!l),s()})},style:{backgroundColor:a?ts[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(I,{column:t,title:"节点",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:y("h-2.5 w-2.5 rounded-full",mt[0])}),e.jsx("span",{className:"text-sm font-medium",children:ht[0]})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",mt[1])}),e.jsx("span",{className:"text-sm font-medium",children:ht[1]})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",mt[2])}),e.jsx("span",{className:"text-sm font-medium",children:ht[2]})]})]})})}),cell:({row:t})=>e.jsx(le,{delayDuration:100,children:e.jsxs(se,{children:[e.jsx(te,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",mt[t.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:t.getValue("name")})]})}),e.jsx(ee,{children:e.jsx("p",{className:"font-medium",children:ht[t.original.available_status]})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(I,{column:t,title:"地址"}),cell:({row:t})=>{const a=`${t.original.host}:${t.original.port}`,n=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]})}),n&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(内部端口 ",t.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(le,{delayDuration:0,children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{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:l=>{l.stopPropagation(),Nt(a)},children:e.jsx(Ta,{className:"size-3"})})}),e.jsx(ee,{side:"top",sideOffset:10,children:"复制连接地址"})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(I,{column:t,title:"在线人数",tooltip:"在线人数根据服务端上报频率而定"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(nt,{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(I,{column:t,title:"倍率",tooltip:"流量扣费倍率"}),cell:({row:t})=>e.jsxs(L,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"groups",header:({column:t})=>e.jsx(I,{column:t,title:"权限组",tooltip:"可订阅到该节点的权限组"}),cell:({row:t})=>{const a=t.getValue("groups")||[];return e.jsx("div",{className:"flex min-w-[300px] max-w-[600px] flex-wrap items-center gap-1.5",children:a.length>0?a.map((n,l)=>e.jsx(L,{variant:"secondary",className:y("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:n.name},l)):e.jsx("span",{className:"text-sm text-muted-foreground",children:"--"})})},enableSorting:!1,size:600,filterFn:(t,a,n)=>{const l=t.getValue(a);return l?n.some(o=>l.includes(o)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(I,{column:t,title:"类型"}),cell:({row:t})=>{const a=t.getValue("type");return e.jsx(L,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:ts[a]},children:a})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(I,{className:"justify-end",column:t,title:"操作"}),cell:({row:t})=>{const{setIsOpen:a,setEditingServer:n,setServerType:l}=Lr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Ns,{modal:!1,children:[e.jsx(ws,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":"打开操作菜单",children:e.jsx(bt,{className:"size-4"})})}),e.jsxs(gs,{align:"end",className:"w-40",children:[e.jsx(he,{className:"cursor-pointer",onClick:()=>{l(t.original.type),n(t.original),a(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(ho,{className:"mr-2 size-4"}),"编辑"]})}),e.jsxs(he,{className:"cursor-pointer",onClick:async()=>{zc({id:t.original.id}).then(({data:o})=>{o&&(A.success("复制成功"),s())})},children:[e.jsx(jo,{className:"mr-2 size-4"}),"复制"]}),e.jsx(Xs,{}),e.jsx(he,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:o=>o.preventDefault(),children:e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该节点,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{Mc({id:t.original.id}).then(({data:o})=>{o&&(A.success("删除成功"),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(rs,{className:"mr-2 size-4"}),"删除"]})})})]})]})})},size:50}];function Lx(){const[s,t]=c.useState({}),[a,n]=c.useState({"drag-handle":!1}),[l,o]=c.useState([]),[d,x]=c.useState({pageSize:500,pageIndex:0}),[r,i]=c.useState([]),[h,T]=c.useState(!1),[C,m]=c.useState({}),[w,_]=c.useState([]),{refetch:v}=Q({queryKey:["nodeList"],queryFn:async()=>{const{data:$}=await hr();return _($),$}}),N=c.useMemo(()=>{const $=new Set;return w.forEach(E=>{E.groups&&E.groups.forEach(K=>$.add(K.name))}),Array.from($).sort()},[w]);c.useEffect(()=>{n({"drag-handle":h,show:!h,host:!h,online:!h,rate:!h,groups:!h,type:!1,actions:!h}),m({name:h?2e3:200}),x({pageSize:h?99999:500,pageIndex:0})},[h]);const P=($,E)=>{h&&($.dataTransfer.setData("text/plain",E.toString()),$.currentTarget.classList.add("opacity-50"))},f=($,E)=>{if(!h)return;$.preventDefault(),$.currentTarget.classList.remove("bg-muted");const K=parseInt($.dataTransfer.getData("text/plain"));if(K===E)return;const ds=[...w],[Hs]=ds.splice(K,1);ds.splice(E,0,Hs),_(ds)},R=async()=>{if(!h){T(!0);return}const $=w?.map((E,K)=>({id:E.id,order:K+1}));Lc($).then(()=>{A.success("排序保存成功"),T(!1),v()}).finally(()=>{T(!1)})},z=Le({data:w||[],columns:Ox(v),state:{sorting:r,columnVisibility:a,rowSelection:s,columnFilters:l,columnSizing:C,pagination:d},enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:i,onColumnFiltersChange:o,onColumnVisibilityChange:n,onColumnSizingChange:m,onPaginationChange:x,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),getFacetedRowModel:ls(),getFacetedUniqueValues:is(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(yx,{refetch:v,children:e.jsx("div",{className:"space-y-4",children:e.jsx(Ge,{table:z,toolbar:$=>e.jsx(zx,{table:$,refetch:v,saveOrder:R,isSortMode:h,groups:N}),draggable:h,onDragStart:P,onDragEnd:$=>$.currentTarget.classList.remove("opacity-50"),onDragOver:$=>{$.preventDefault(),$.currentTarget.classList.add("bg-muted")},onDragLeave:$=>$.currentTarget.classList.remove("bg-muted"),onDrop:f,showPagination:!h})})})}function $x(){return e.jsxs(ye,{children:[e.jsxs(Ne,{children:[e.jsx(ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"节点管理"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"管理所有节点,包括添加、删除、编辑等操作。"})]})}),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(Lx,{})})]})]})}const Ax=Object.freeze(Object.defineProperty({__proto__:null,default:$x},Symbol.toStringTag,{value:"Module"}));function Hx({table:s,refetch:t}){const a=s.getState().columnFilters.length>0;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(Et,{refetch:t}),e.jsx(S,{placeholder:"搜索权限组...",value:s.getColumn("name")?.getFilterValue()??"",onChange:n=>s.getColumn("name")?.setFilterValue(n.target.value),className:y("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:["重置",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]})})}const Kx=s=>[{accessorKey:"id",header:({column:t})=>e.jsx(I,{column:t,title:"组ID"}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(I,{column:t,title:"组名称"}),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(I,{column:t,title:"用户数量"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(nt,{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(I,{column:t,title:"节点数量"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx($n,{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(I,{className:"justify-end",column:t,title:"操作"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Et,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]})}),e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该权限组,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{Ac({id:t.original.id}).then(({data:a})=>{a&&(A.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]})}];function qx(){const[s,t]=c.useState({}),[a,n]=c.useState({}),[l,o]=c.useState([]),[d,x]=c.useState([]),{data:r,refetch:i,isLoading:h}=Q({queryKey:["serverGroupList"],queryFn:async()=>{const{data:C}=await Vt();return C}}),T=Le({data:r||[],columns:Kx(i),state:{sorting:d,columnVisibility:a,rowSelection:s,columnFilters:l},enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:x,onColumnFiltersChange:o,onColumnVisibilityChange:n,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),getFacetedRowModel:ls(),getFacetedUniqueValues:is(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ge,{table:T,toolbar:C=>e.jsx(Hx,{table:C,refetch:i}),isLoading:h})}function Ux(){return e.jsxs(ye,{children:[e.jsxs(Ne,{children:[e.jsx(ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"权限组管理"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"管理所有权限组,包括添加、删除、编辑等操作。"})]})}),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(qx,{})})]})]})}const Bx=Object.freeze(Object.defineProperty({__proto__:null,default:Ux},Symbol.toStringTag,{value:"Module"})),Gx=u.object({remarks:u.string().min(1,"Please enter a valid remarks."),match:u.array(u.string()),action:u.enum(["block","dns"]),action_value:u.string().optional()});function $r({refetch:s,dialogTrigger:t,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:n="add"}){const l=ae({resolver:ie(Gx),defaultValues:a,mode:"onChange"}),[o,d]=c.useState(!1);return e.jsxs(ue,{open:o,onOpenChange:d,children:[e.jsx(Re,{asChild:!0,children:t||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ve,{icon:"ion:add"})," ",e.jsx("div",{children:"添加路由"})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(je,{children:[e.jsx(xe,{children:n==="edit"?"编辑路由":"创建路由"}),e.jsx(Se,{})]}),e.jsxs(oe,{...l,children:[e.jsx(g,{control:l.control,name:"remarks",render:({field:x})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"备注"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(S,{type:"text",placeholder:"请输入备注",...x})})}),e.jsx(k,{})]})}),e.jsx(g,{control:l.control,name:"match",render:({field:x})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(p,{children:"备注"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(vs,{className:"min-h-[120px]",placeholder:`example.com *.example.com`,value:x.value.join(` `),onChange:r=>{x.onChange(r.target.value.split(` -`))}})})}),e.jsx(k,{})]})}),e.jsx(g,{control:l.control,name:"action",render:({field:x})=>e.jsxs(j,{children:[e.jsx(p,{children:"动作"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsxs(G,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择动作"})}),e.jsxs(B,{children:[e.jsx(O,{value:"block",children:"禁止访问"}),e.jsx(O,{value:"dns",children:"指定DNS服务器进行解析"})]})]})})}),e.jsx(k,{})]})}),l.watch("action")==="dns"&&e.jsx(g,{control:l.control,name:"action_value",render:({field:x})=>e.jsxs(j,{children:[e.jsx(p,{children:"DNS服务器"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(S,{type:"text",placeholder:"请输入DNS服务器",...x})})})]})}),e.jsxs(Ee,{children:[e.jsx(it,{asChild:!0,children:e.jsx(D,{variant:"outline",children:"取消"})}),e.jsx(D,{type:"submit",onClick:()=>{Hc(l.getValues()).then(({data:x})=>{x&&(d(!1),s&&s(),l.reset())})},children:"提交"})]})]})]})]})}function Yx({table:s,refetch:t}){const a=s.getState().columnFilters.length>0;return e.jsx("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:[e.jsx($r,{refetch:t}),e.jsx(S,{placeholder:"搜索路由...",value:s.getColumn("remarks")?.getFilterValue()??"",onChange:n=>s.getColumn("remarks")?.setFilterValue(n.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),a&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:["Reset",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]})})}function Wx({columns:s,data:t,refetch:a}){const[n,l]=c.useState({}),[o,d]=c.useState({}),[x,r]=c.useState([]),[i,h]=c.useState([]),T=Le({data:t,columns:s,state:{sorting:i,columnVisibility:o,rowSelection:n,columnFilters:x},enableRowSelection:!0,onRowSelectionChange:l,onSortingChange:h,onColumnFiltersChange:r,onColumnVisibilityChange:d,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),getFacetedRowModel:ls(),getFacetedUniqueValues:is(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ge,{table:T,toolbar:C=>e.jsx(Yx,{table:C,refetch:a})})}const Jx=s=>[{accessorKey:"id",header:({column:t})=>e.jsx(I,{column:t,title:"组ID"}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:t})=>e.jsx(I,{column:t,title:"备注"}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsxs("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:["匹配 ",t.original.match?.length," 条规则"]})}),enableHiding:!1,enableSorting:!1},{accessorKey:"action",header:({column:t})=>e.jsx(I,{column:t,title:"动作"}),cell:({row:t})=>{const a={dns:"指定DNS服务器进行解析",block:"禁止访问"};return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a[t.getValue("action")]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:"操作"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx($r,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]})}),e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该权限组,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{Kc({id:t.original.id}).then(({data:a})=>{a&&(A.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]})}];function Qx(){const[s,t]=c.useState([]);function a(){jr().then(({data:n})=>{t(n)})}return c.useEffect(()=>{a()},[]),e.jsxs(ye,{children:[e.jsxs(Ne,{children:[e.jsx(ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"路由管理"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"管理所有路由组,包括添加、删除、编辑等操作。"})]})}),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,{data:s,columns:Jx(a),refetch:a})})]})]})}const Zx=Object.freeze(Object.defineProperty({__proto__:null,default:Qx},Symbol.toStringTag,{value:"Module"})),Ar=c.createContext(void 0);function Xx({children:s,refreshData:t}){const[a,n]=c.useState(!1),[l,o]=c.useState(null);return e.jsx(Ar.Provider,{value:{isOpen:a,setIsOpen:n,editingPlan:l,setEditingPlan:o,refreshData:t},children:s})}function xa(){const s=c.useContext(Ar);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function em({table:s,saveOrder:t,isSortMode:a}){const{setIsOpen:n}=xa();return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(D,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>n(!0),children:[e.jsx(ve,{icon:"ion:add"}),e.jsx("div",{children:"添加套餐"})]}),e.jsx(S,{placeholder:"搜索套餐...",value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:a?"default":"outline",onClick:t,size:"sm",children:a?"保存排序":"编辑排序"})})]})}const Ha={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},sm=s=>[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(I,{column:t,title:"ID"}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(I,{column:t,title:"显示"}),cell:({row:t})=>e.jsx(H,{defaultChecked:t.getValue("show"),onCheckedChange:a=>{zt({id:t.original.id,show:a}).then(({data:n})=>{!n&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(I,{column:t,title:"新购"}),cell:({row:t})=>e.jsx(H,{defaultChecked:t.getValue("sell"),onCheckedChange:a=>{zt({id:t.original.id,sell:a}).then(({data:n})=>{!n&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(I,{column:t,title:"续费",tooltip:"在订阅停止销售时,已购用户是否可以续费"}),cell:({row:t})=>e.jsx(H,{defaultChecked:t.getValue("renew"),onCheckedChange:a=>{zt({id:t.original.id,renew:a}).then(({data:n})=>{!n&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(I,{column:t,title:"名称"}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:t})=>e.jsx(I,{column:t,title:"统计"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(nt,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:t})=>e.jsx(I,{column:t,title:"权限组"}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(L,{variant:"secondary",className:y("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:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(I,{column:t,title:"价格"}),cell:({row:t})=>{const a=t.getValue("prices"),n=[{period:"月付",key:"monthly",unit:"元/月"},{period:"季付",key:"quarterly",unit:"元/季"},{period:"半年付",key:"half_yearly",unit:"元/半年"},{period:"年付",key:"yearly",unit:"元/年"},{period:"两年付",key:"two_yearly",unit:"元/两年"},{period:"三年付",key:"three_yearly",unit:"元/三年"},{period:"流量包",key:"onetime",unit:"元"},{period:"重置包",key:"reset_traffic",unit:"元/次"}];return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(({period:l,key:o,unit:d})=>a[o]!=null&&e.jsxs(L,{variant:"secondary",className:y("px-2 py-0.5 font-medium transition-colors text-nowrap",Ha[o].color,Ha[o].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[l," ¥",a[o],d]},o))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(I,{className:"justify-end",column:t,title:"操作"}),cell:({row:t})=>{const{setIsOpen:a,setEditingPlan:n}=xa();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{n(t.original),a(!0)},children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]}),e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该订阅,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{od({id:t.original.id}).then(({data:l})=>{l&&(A.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]})}}],tm=u.object({id:u.number().nullable(),group_id:u.union([u.number(),u.string()]).nullable().optional(),name:u.string().min(1).max(250),content:u.string().nullable().optional(),transfer_enable:u.union([u.number().min(0),u.string().min(1)]),prices:u.object({monthly:u.union([u.number(),u.string()]).nullable().optional(),quarterly:u.union([u.number(),u.string()]).nullable().optional(),half_yearly:u.union([u.number(),u.string()]).nullable().optional(),yearly:u.union([u.number(),u.string()]).nullable().optional(),two_yearly:u.union([u.number(),u.string()]).nullable().optional(),three_yearly:u.union([u.number(),u.string()]).nullable().optional(),onetime:u.union([u.number(),u.string()]).nullable().optional(),reset_traffic:u.union([u.number(),u.string()]).nullable().optional()}).default({}),speed_limit:u.union([u.number(),u.string()]).nullable().optional(),capacity_limit:u.union([u.number(),u.string()]).nullable().optional(),device_limit:u.union([u.number(),u.string()]).nullable().optional(),force_update:u.boolean().optional(),reset_traffic_method:u.number().nullable(),users_count:u.number().optional()}),Hr=c.forwardRef(({className:s,...t},a)=>e.jsx(An,{ref:a,className:y("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...t,children:e.jsx(go,{className:y("flex items-center justify-center text-current"),children:e.jsx(Cs,{className:"h-4 w-4"})})}));Hr.displayName=An.displayName;const jt={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},gt={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},am=[{value:0,label:"跟随系统设置"},{value:1,label:"每月1号"},{value:2,label:"按月重置"},{value:3,label:"不重置"},{value:4,label:"每年1月1日"},{value:5,label:"按年重置"}];function nm(){const{isOpen:s,setIsOpen:t,editingPlan:a,setEditingPlan:n,refreshData:l}=xa(),[o,d]=c.useState(!1),x=ae({resolver:ie(tm),defaultValues:{...jt,...a||{}},mode:"onChange"});c.useEffect(()=>{a?x.reset({...jt,...a}):x.reset(jt)},[a,x]);const r=new ta({html:!0}),[i,h]=c.useState();async function T(){Vt().then(({data:w})=>{h(w)})}c.useEffect(()=>{s&&T()},[s]);const C=w=>{if(isNaN(w))return;const _=Object.entries(gt).reduce((v,[N,P])=>{const f=w*P.months*P.discount;return{...v,[N]:f.toFixed(2)}},{});x.setValue("prices",_,{shouldDirty:!0})},m=()=>{t(!1),n(null),x.reset(jt)};return e.jsx(ue,{open:s,onOpenChange:m,children:e.jsxs(ce,{children:[e.jsxs(je,{children:[e.jsx(xe,{children:a?"编辑套餐":"添加套餐"}),e.jsx(Se,{})]}),e.jsxs(oe,{...x,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:x.control,name:"name",render:({field:w})=>e.jsxs(j,{children:[e.jsx(p,{children:"套餐名称"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入套餐名称",...w})}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"group_id",render:({field:w})=>e.jsxs(j,{children:[e.jsxs(p,{className:"flex items-center justify-between",children:["权限组",e.jsx(Et,{dialogTrigger:e.jsx(D,{variant:"link",children:"添加权限组"}),refetch:T})]}),e.jsxs(G,{value:w.value||"",onValueChange:w.onChange,children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"选择权限组"})})}),e.jsx(B,{children:i?.map(_=>e.jsx(O,{value:_.id,children:_.name},_.id))})]}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"transfer_enable",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"流量"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"请输入流量大小",className:"rounded-r-none",...w})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"GB"})]}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"speed_limit",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"限速"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"请输入限速",className:"rounded-r-none",...w})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"Mbps"})]}),e.jsx(k,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:"售价设置"}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(S,{type:"number",placeholder:"基础月付价格",className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:w=>{const _=parseFloat(w.target.value);C(_)}})]}),e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const w=Object.keys(gt).reduce((_,v)=>({..._,[v]:""}),{});x.setValue("prices",w,{shouldDirty:!0})},children:"清空价格"})}),e.jsx(ee,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:"清空所有周期的价格设置"})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(gt).filter(([w])=>!["onetime","reset_traffic"].includes(w)).map(([w,_])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(g,{control:x.control,name:`prices.${w}`,render:({field:v})=>e.jsxs(j,{children:[e.jsxs(p,{className:"text-xs font-medium text-muted-foreground",children:[_.label,e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",_.months===1?"每月":`每${_.months}个月`,"结算)"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"0.00",min:0,...v,value:v.value??"",onChange:N=>v.onChange(N.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},w))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(gt).filter(([w])=>["onetime","reset_traffic"].includes(w)).map(([w,_])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(g,{control:x.control,name:`prices.${w}`,render:({field:v})=>e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(p,{className:"text-xs font-medium",children:_.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:w==="onetime"?"一次性流量包,购买后立即生效":"用户可随时购买流量重置包,立即重置流量"})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"0.00",min:0,...v,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},w))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(g,{control:x.control,name:"device_limit",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"设备限制"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"留空则不限制",className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"台"})]}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"capacity_limit",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"容量限制"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"留空则不限制",className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"人"})]}),e.jsx(k,{})]})})]}),e.jsx(g,{control:x.control,name:"reset_traffic_method",render:({field:w})=>e.jsxs(j,{children:[e.jsx(p,{children:"流量重置方式"}),e.jsxs(G,{value:w.value?.toString()??"0",onValueChange:_=>w.onChange(Number(_)),children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"选择流量重置方式"})})}),e.jsx(B,{children:am.map(_=>e.jsx(O,{value:_.value.toString(),children:_.label},_.value))})]}),e.jsx(F,{className:"text-xs",children:"设置订阅流量的重置方式,不同的重置方式会影响用户的流量计算方式"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"content",render:({field:w})=>{const[_,v]=c.useState(!1);return e.jsxs(j,{className:"space-y-2",children:[e.jsxs(p,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:["套餐描述",e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>v(!_),children:_?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(ee,{side:"top",children:e.jsx("p",{className:"text-xs",children:_?"隐藏预览":"显示预览"})})]})})]}),e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",onClick:()=>{w.onChange(`## 套餐特点 +`))}})})}),e.jsx(k,{})]})}),e.jsx(g,{control:l.control,name:"action",render:({field:x})=>e.jsxs(j,{children:[e.jsx(p,{children:"动作"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsxs(G,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择动作"})}),e.jsxs(B,{children:[e.jsx(O,{value:"block",children:"禁止访问"}),e.jsx(O,{value:"dns",children:"指定DNS服务器进行解析"})]})]})})}),e.jsx(k,{})]})}),l.watch("action")==="dns"&&e.jsx(g,{control:l.control,name:"action_value",render:({field:x})=>e.jsxs(j,{children:[e.jsx(p,{children:"DNS服务器"}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(S,{type:"text",placeholder:"请输入DNS服务器",...x})})})]})}),e.jsxs(Ee,{children:[e.jsx(it,{asChild:!0,children:e.jsx(D,{variant:"outline",children:"取消"})}),e.jsx(D,{type:"submit",onClick:()=>{Hc(l.getValues()).then(({data:x})=>{x&&(d(!1),s&&s(),l.reset())})},children:"提交"})]})]})]})]})}function Yx({table:s,refetch:t}){const a=s.getState().columnFilters.length>0;return e.jsx("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:[e.jsx($r,{refetch:t}),e.jsx(S,{placeholder:"搜索路由...",value:s.getColumn("remarks")?.getFilterValue()??"",onChange:n=>s.getColumn("remarks")?.setFilterValue(n.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),a&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:["Reset",e.jsx(Me,{className:"ml-2 h-4 w-4"})]})]})})}function Wx({columns:s,data:t,refetch:a}){const[n,l]=c.useState({}),[o,d]=c.useState({}),[x,r]=c.useState([]),[i,h]=c.useState([]),T=Le({data:t,columns:s,state:{sorting:i,columnVisibility:o,rowSelection:n,columnFilters:x},enableRowSelection:!0,onRowSelectionChange:l,onSortingChange:h,onColumnFiltersChange:r,onColumnVisibilityChange:d,getCoreRowModel:$e(),getFilteredRowModel:Ke(),getPaginationRowModel:qe(),getSortedRowModel:Ue(),getFacetedRowModel:ls(),getFacetedUniqueValues:is(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ge,{table:T,toolbar:C=>e.jsx(Yx,{table:C,refetch:a})})}const Jx=s=>[{accessorKey:"id",header:({column:t})=>e.jsx(I,{column:t,title:"组ID"}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:t})=>e.jsx(I,{column:t,title:"备注"}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsxs("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:["匹配 ",t.original.match?.length," 条规则"]})}),enableHiding:!1,enableSorting:!1},{accessorKey:"action",header:({column:t})=>e.jsx(I,{column:t,title:"动作"}),cell:({row:t})=>{const a={dns:"指定DNS服务器进行解析",block:"禁止访问"};return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a[t.getValue("action")]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:"操作"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx($r,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]})}),e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该权限组,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{Kc({id:t.original.id}).then(({data:a})=>{a&&(A.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]})}];function Qx(){const[s,t]=c.useState([]);function a(){jr().then(({data:n})=>{t(n)})}return c.useEffect(()=>{a()},[]),e.jsxs(ye,{children:[e.jsxs(Ne,{children:[e.jsx(ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Te,{})]})]}),e.jsxs(_e,{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:"路由管理"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"管理所有路由组,包括添加、删除、编辑等操作。"})]})}),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,{data:s,columns:Jx(a),refetch:a})})]})]})}const Zx=Object.freeze(Object.defineProperty({__proto__:null,default:Qx},Symbol.toStringTag,{value:"Module"})),Ar=c.createContext(void 0);function Xx({children:s,refreshData:t}){const[a,n]=c.useState(!1),[l,o]=c.useState(null);return e.jsx(Ar.Provider,{value:{isOpen:a,setIsOpen:n,editingPlan:l,setEditingPlan:o,refreshData:t},children:s})}function xa(){const s=c.useContext(Ar);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function em({table:s,saveOrder:t,isSortMode:a}){const{setIsOpen:n}=xa();return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(D,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>n(!0),children:[e.jsx(ve,{icon:"ion:add"}),e.jsx("div",{children:"添加套餐"})]}),e.jsx(S,{placeholder:"搜索套餐...",value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:a?"default":"outline",onClick:t,size:"sm",children:a?"保存排序":"编辑排序"})})]})}const Ha={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},sm=s=>[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(I,{column:t,title:"ID"}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(I,{column:t,title:"显示"}),cell:({row:t})=>e.jsx(H,{defaultChecked:t.getValue("show"),onCheckedChange:a=>{zt({id:t.original.id,show:a}).then(({data:n})=>{!n&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(I,{column:t,title:"新购"}),cell:({row:t})=>e.jsx(H,{defaultChecked:t.getValue("sell"),onCheckedChange:a=>{zt({id:t.original.id,sell:a}).then(({data:n})=>{!n&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(I,{column:t,title:"续费",tooltip:"在订阅停止销售时,已购用户是否可以续费"}),cell:({row:t})=>e.jsx(H,{defaultChecked:t.getValue("renew"),onCheckedChange:a=>{zt({id:t.original.id,renew:a}).then(({data:n})=>{!n&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(I,{column:t,title:"名称"}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:t})=>e.jsx(I,{column:t,title:"统计"}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(nt,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:t})=>e.jsx(I,{column:t,title:"权限组"}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(L,{variant:"secondary",className:y("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:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(I,{column:t,title:"价格"}),cell:({row:t})=>{const a=t.getValue("prices"),n=[{period:"月付",key:"monthly",unit:"元/月"},{period:"季付",key:"quarterly",unit:"元/季"},{period:"半年付",key:"half_yearly",unit:"元/半年"},{period:"年付",key:"yearly",unit:"元/年"},{period:"两年付",key:"two_yearly",unit:"元/两年"},{period:"三年付",key:"three_yearly",unit:"元/三年"},{period:"流量包",key:"onetime",unit:"元"},{period:"重置包",key:"reset_traffic",unit:"元/次"}];return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(({period:l,key:o,unit:d})=>a[o]!=null&&e.jsxs(L,{variant:"secondary",className:y("px-2 py-0.5 font-medium transition-colors text-nowrap",Ha[o].color,Ha[o].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[l," ¥",a[o],d]},o))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(I,{className:"justify-end",column:t,title:"操作"}),cell:({row:t})=>{const{setIsOpen:a,setEditingPlan:n}=xa();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{n(t.original),a(!0)},children:[e.jsx(ks,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:"编辑"})]}),e.jsx(Ye,{title:"确认删除",description:"此操作将永久删除该订阅,删除后无法恢复。确定要继续吗?",confirmText:"删除",variant:"destructive",onConfirm:async()=>{od({id:t.original.id}).then(({data:l})=>{l&&(A.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(rs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:"删除"})]})})]})}}],tm=u.object({id:u.number().nullable(),group_id:u.union([u.number(),u.string()]).nullable().optional(),name:u.string().min(1).max(250),content:u.string().nullable().optional(),transfer_enable:u.union([u.number().min(0),u.string().min(1)]),prices:u.object({monthly:u.union([u.number(),u.string()]).nullable().optional(),quarterly:u.union([u.number(),u.string()]).nullable().optional(),half_yearly:u.union([u.number(),u.string()]).nullable().optional(),yearly:u.union([u.number(),u.string()]).nullable().optional(),two_yearly:u.union([u.number(),u.string()]).nullable().optional(),three_yearly:u.union([u.number(),u.string()]).nullable().optional(),onetime:u.union([u.number(),u.string()]).nullable().optional(),reset_traffic:u.union([u.number(),u.string()]).nullable().optional()}).default({}),speed_limit:u.union([u.number(),u.string()]).nullable().optional(),capacity_limit:u.union([u.number(),u.string()]).nullable().optional(),device_limit:u.union([u.number(),u.string()]).nullable().optional(),force_update:u.boolean().optional(),reset_traffic_method:u.number().nullable(),users_count:u.number().optional()}),Hr=c.forwardRef(({className:s,...t},a)=>e.jsx(An,{ref:a,className:y("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...t,children:e.jsx(go,{className:y("flex items-center justify-center text-current"),children:e.jsx(Cs,{className:"h-4 w-4"})})}));Hr.displayName=An.displayName;const jt={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},gt={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},am=[{value:null,label:"跟随系统设置"},{value:0,label:"每月1号"},{value:1,label:"按月重置"},{value:2,label:"不重置"},{value:3,label:"每年1月1日"},{value:4,label:"按年重置"}];function nm(){const{isOpen:s,setIsOpen:t,editingPlan:a,setEditingPlan:n,refreshData:l}=xa(),[o,d]=c.useState(!1),x=ae({resolver:ie(tm),defaultValues:{...jt,...a||{}},mode:"onChange"});c.useEffect(()=>{a?x.reset({...jt,...a}):x.reset(jt)},[a,x]);const r=new ta({html:!0}),[i,h]=c.useState();async function T(){Vt().then(({data:w})=>{h(w)})}c.useEffect(()=>{s&&T()},[s]);const C=w=>{if(isNaN(w))return;const _=Object.entries(gt).reduce((v,[N,P])=>{const f=w*P.months*P.discount;return{...v,[N]:f.toFixed(2)}},{});x.setValue("prices",_,{shouldDirty:!0})},m=()=>{t(!1),n(null),x.reset(jt)};return e.jsx(ue,{open:s,onOpenChange:m,children:e.jsxs(ce,{children:[e.jsxs(je,{children:[e.jsx(xe,{children:a?"编辑套餐":"添加套餐"}),e.jsx(Se,{})]}),e.jsxs(oe,{...x,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:x.control,name:"name",render:({field:w})=>e.jsxs(j,{children:[e.jsx(p,{children:"套餐名称"}),e.jsx(b,{children:e.jsx(S,{placeholder:"请输入套餐名称",...w})}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"group_id",render:({field:w})=>e.jsxs(j,{children:[e.jsxs(p,{className:"flex items-center justify-between",children:["权限组",e.jsx(Et,{dialogTrigger:e.jsx(D,{variant:"link",children:"添加权限组"}),refetch:T})]}),e.jsxs(G,{value:w.value||"",onValueChange:w.onChange,children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"选择权限组"})})}),e.jsx(B,{children:i?.map(_=>e.jsx(O,{value:_.id,children:_.name},_.id))})]}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"transfer_enable",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"流量"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"请输入流量大小",className:"rounded-r-none",...w})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"GB"})]}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"speed_limit",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"限速"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"请输入限速",className:"rounded-r-none",...w})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"Mbps"})]}),e.jsx(k,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:"售价设置"}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(S,{type:"number",placeholder:"基础月付价格",className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:w=>{const _=parseFloat(w.target.value);C(_)}})]}),e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const w=Object.keys(gt).reduce((_,v)=>({..._,[v]:""}),{});x.setValue("prices",w,{shouldDirty:!0})},children:"清空价格"})}),e.jsx(ee,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:"清空所有周期的价格设置"})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(gt).filter(([w])=>!["onetime","reset_traffic"].includes(w)).map(([w,_])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(g,{control:x.control,name:`prices.${w}`,render:({field:v})=>e.jsxs(j,{children:[e.jsxs(p,{className:"text-xs font-medium text-muted-foreground",children:[_.label,e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",_.months===1?"每月":`每${_.months}个月`,"结算)"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"0.00",min:0,...v,value:v.value??"",onChange:N=>v.onChange(N.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},w))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(gt).filter(([w])=>["onetime","reset_traffic"].includes(w)).map(([w,_])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(g,{control:x.control,name:`prices.${w}`,render:({field:v})=>e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(p,{className:"text-xs font-medium",children:_.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:w==="onetime"?"一次性流量包,购买后立即生效":"用户可随时购买流量重置包,立即重置流量"})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(b,{children:e.jsx(S,{type:"number",placeholder:"0.00",min:0,...v,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},w))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(g,{control:x.control,name:"device_limit",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"设备限制"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"留空则不限制",className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"台"})]}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"capacity_limit",render:({field:w})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(p,{children:"容量限制"}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(S,{type:"number",min:0,placeholder:"留空则不限制",className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:"人"})]}),e.jsx(k,{})]})})]}),e.jsx(g,{control:x.control,name:"reset_traffic_method",render:({field:w})=>e.jsxs(j,{children:[e.jsx(p,{children:"流量重置方式"}),e.jsxs(G,{value:w.value?.toString()??"null",onValueChange:_=>w.onChange(_=="null"?null:Number(_)),children:[e.jsx(b,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"选择流量重置方式"})})}),e.jsx(B,{children:am.map(_=>e.jsx(O,{value:_.value?.toString()??"null",children:_.label},_.value))})]}),e.jsx(F,{className:"text-xs",children:"设置订阅流量的重置方式,不同的重置方式会影响用户的流量计算方式"}),e.jsx(k,{})]})}),e.jsx(g,{control:x.control,name:"content",render:({field:w})=>{const[_,v]=c.useState(!1);return e.jsxs(j,{className:"space-y-2",children:[e.jsxs(p,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:["套餐描述",e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>v(!_),children:_?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(ee,{side:"top",children:e.jsx("p",{className:"text-xs",children:_?"隐藏预览":"显示预览"})})]})})]}),e.jsx(le,{children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",onClick:()=>{w.onChange(`## 套餐特点 • 高速稳定的全球网络接入 • 支持多设备同时在线 • 无限制的流量重置