From 895a870dfcb6a48bfeacb1253c390d7dab9f4d96 Mon Sep 17 00:00:00 2001 From: xboard Date: Sun, 25 May 2025 08:43:00 +0800 Subject: [PATCH] fix(admin): fix shadowsocks plugin issue - save empty string instead of 'none' when plugin is set to none --- public/assets/admin/assets/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index def1cce..2531c3d 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -4,7 +4,7 @@ import{r as m,j as e,t as di,c as mi,I as Vn,a as Zs,S as on,u as Is,b as ui,d a File: ${oi} Line: ${ci}`}return JSON.stringify(Q,null,2)}catch{return g.context}})()})})]})]}),e.jsx(Re,{children:e.jsx(qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})})]})})]})}function Xd(){const{t:s}=V();return e.jsxs(Ve,{children:[e.jsxs(Fe,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Xe,{}),e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsx(Ae,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Bd,{}),e.jsx(Ad,{}),e.jsx(Gd,{}),e.jsx(Qd,{})]})})})]})}const Zd=Object.freeze(Object.defineProperty({__proto__:null,default:Xd},Symbol.toStringTag,{value:"Module"}));function em({className:s,items:a,...t}){const{pathname:l}=cn(),n=Is(),[o,r]=m.useState(l??"/settings"),c=i=>{r(i),n(i)},{t:u}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(X,{value:o,onValueChange:c,children:[e.jsx(Y,{className:"h-12 sm:w-48",children:e.jsx(Z,{placeholder:"Theme"})}),e.jsx(J,{children:a.map(i=>e.jsx($,{value:i.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:i.icon}),e.jsx("span",{className:"text-md",children:u(i.title)})]})},i.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),...t,children:a.map(i=>e.jsxs(st,{to:i.href,className:y(wt({variant:"ghost"}),l===i.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:i.icon}),u(i.title)]},i.href))})})]})}const sm=[{title:"site.title",key:"site",icon:e.jsx(Zo,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(wl,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Cl,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(ec,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(_l,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(sc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(tc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Nl,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(ac,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function tm(){const{t:s}=V("settings");return e.jsxs(Ve,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Fe,{children:[e.jsx(Xe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(ke,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(em,{items:sm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(dn,{})})})]})]})]})}const am=Object.freeze(Object.defineProperty({__proto__:null,default:tm},Symbol.toStringTag,{value:"Module"})),ee=m.forwardRef(({className:s,...a},t)=>e.jsx(Ul,{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),...a,ref:t,children:e.jsx(nc,{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")})}));ee.displayName=Ul.displayName;const Ts=m.forwardRef(({className:s,...a},t)=>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:t,...a}));Ts.displayName="Textarea";const nm=x.object({logo:x.string().nullable().default(""),force_https:x.number().nullable().default(0),stop_register:x.number().nullable().default(0),app_name:x.string().nullable().default(""),app_description:x.string().nullable().default(""),app_url:x.string().nullable().default(""),subscribe_url:x.string().nullable().default(""),try_out_plan_id:x.number().nullable().default(0),try_out_hour:x.coerce.number().nullable().default(0),tos_url:x.string().nullable().default(""),currency:x.string().nullable().default(""),currency_symbol:x.string().nullable().default("")});function lm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),{data:n}=ne({queryKey:["settings","site"],queryFn:()=>me.getSettings("site")}),{data:o}=ne({queryKey:["plans"],queryFn:()=>es.getList()}),r=ye({resolver:_e(nm),defaultValues:{},mode:"onBlur"}),{mutateAsync:c}=gs({mutationFn:me.saveSettings,onSuccess:d=>{d.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(n?.data?.site){const d=n?.data?.site;Object.entries(d).forEach(([h,_])=>{r.setValue(h,_)}),l.current=d}},[n]);const u=m.useCallback(Se.debounce(async d=>{if(!Se.isEqual(d,l.current)){t(!0);try{const h=Object.entries(d).reduce((_,[T,S])=>(_[T]=S===null?"":S,_),{});await c(h),l.current=d}finally{t(!1)}}},1e3),[c]),i=m.useCallback(d=>{u(d)},[u]);return m.useEffect(()=>{const d=r.watch(h=>{i(h)});return()=>d.unsubscribe()},[r.watch,i]),e.jsx(we,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:r.control,name:"app_name",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"app_description",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"app_url",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"force_https",render:({field:d})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:!!d.value,onCheckedChange:h=>{d.onChange(Number(h)),i(r.getValues())}})})]})}),e.jsx(v,{control:r.control,name:"logo",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"subscribe_url",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(b,{children:e.jsx(Ts,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"tos_url",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"stop_register",render:({field:d})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:!!d.value,onCheckedChange:h=>{d.onChange(Number(h)),i(r.getValues())}})})]})}),e.jsx(v,{control:r.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(b,{children:e.jsxs(X,{value:d.value?.toString(),onValueChange:h=>{d.onChange(Number(h)),i(r.getValues())},children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("site.form.tryOut.placeholder")}),o?.data?.map(h=>e.jsx($,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(P,{})]})}),!!r.watch("try_out_plan_id")&&e.jsx(v,{control:r.control,name:"try_out_hour",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"currency",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:r.control,name:"currency_symbol",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:h=>{d.onChange(h),i(r.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function rm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(ke,{}),e.jsx(lm,{})]})}const im=Object.freeze(Object.defineProperty({__proto__:null,default:rm},Symbol.toStringTag,{value:"Module"})),om=x.object({email_verify:x.boolean().nullable(),safe_mode_enable:x.boolean().nullable(),secure_path:x.string().nullable(),email_whitelist_enable:x.boolean().nullable(),email_whitelist_suffix:x.array(x.string().nullable()).nullable(),email_gmail_limit_enable:x.boolean().nullable(),recaptcha_enable:x.boolean().nullable(),recaptcha_key:x.string().nullable(),recaptcha_site_key:x.string().nullable(),register_limit_by_ip_enable:x.boolean().nullable(),register_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:x.boolean().nullable(),password_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable()}),cm={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 dm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(om),defaultValues:cm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","safe"],queryFn:()=>me.getSettings("safe")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(o?.data.safe){const i=o.data.safe;Object.entries(i).forEach(([d,h])=>{typeof h=="number"?n.setValue(d,String(h)):n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"email_verify",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"email_gmail_limit_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"safe_mode_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"secure_path",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"email_whitelist_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("email_whitelist_enable")&&e.jsx(v,{control:n.control,name:"email_whitelist_suffix",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(b,{children:e.jsx(Ts,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...i,value:(i.value||[]).join(` `),onChange:d=>{const h=d.target.value.split(` -`).filter(Boolean);i.onChange(h),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"recaptcha_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(F,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"recaptcha_site_key",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"recaptcha_key",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.key.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.key.description")}),e.jsx(P,{})]})})]}),e.jsx(v,{control:n.control,name:"register_limit_by_ip_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(F,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"register_limit_count",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.count.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"register_limit_expire",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(P,{})]})})]}),e.jsx(v,{control:n.control,name:"password_limit_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(F,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"password_limit_count",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"password_limit_expire",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(P,{})]})})]}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function mm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ke,{}),e.jsx(dm,{})]})}const um=Object.freeze(Object.defineProperty({__proto__:null,default:mm},Symbol.toStringTag,{value:"Module"})),xm=x.object({plan_change_enable:x.boolean().nullable().default(!1),reset_traffic_method:x.coerce.number().nullable().default(0),surplus_enable:x.boolean().nullable().default(!1),new_order_event_id:x.coerce.number().nullable().default(0),renew_order_event_id:x.coerce.number().nullable().default(0),change_order_event_id:x.coerce.number().nullable().default(0),show_info_to_server_enable:x.boolean().nullable().default(!1),show_protocol_to_server_enable:x.boolean().nullable().default(!1),default_remind_expire:x.boolean().nullable().default(!1),default_remind_traffic:x.boolean().nullable().default(!1),subscribe_path:x.string().nullable().default("s")}),hm={plan_change_enable:!1,reset_traffic_method:0,surplus_enable:!1,new_order_event_id:0,renew_order_event_id:0,change_order_event_id:0,show_info_to_server_enable:!1,show_protocol_to_server_enable:!1,default_remind_expire:!1,default_remind_traffic:!1,subscribe_path:"s"};function pm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(xm),defaultValues:hm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","subscribe"],queryFn:()=>me.getSettings("subscribe")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(o?.data?.subscribe){const i=o?.data?.subscribe;Object.entries(i).forEach(([d,h])=>{n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"plan_change_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(F,{children:s("subscribe.plan_change_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"reset_traffic_method",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择重置方式"})})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx($,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx($,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx($,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx($,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(F,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"surplus_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(F,{children:s("subscribe.surplus_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"new_order_event_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.new_order_event.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"renew_order_event_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.renew_order_event.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"change_order_event_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.change_order_event.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"subscribe_path",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:"subscribe",...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:i.value||"s"})]}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"show_info_to_server_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(F,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"show_protocol_to_server_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(F,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function gm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ke,{}),e.jsx(pm,{})]})}const fm=Object.freeze(Object.defineProperty({__proto__:null,default:gm},Symbol.toStringTag,{value:"Module"})),jm=x.object({invite_force:x.boolean().default(!1),invite_commission:x.coerce.string().default("0"),invite_gen_limit:x.coerce.string().default("0"),invite_never_expire:x.boolean().default(!1),commission_first_time_enable:x.boolean().default(!1),commission_auto_check_enable:x.boolean().default(!1),commission_withdraw_limit:x.coerce.string().default("0"),commission_withdraw_method:x.array(x.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:x.boolean().default(!1),commission_distribution_enable:x.boolean().default(!1),commission_distribution_l1:x.coerce.number().default(0),commission_distribution_l2:x.coerce.number().default(0),commission_distribution_l3:x.coerce.number().default(0)}),vm={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 bm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(jm),defaultValues:vm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","invite"],queryFn:()=>me.getSettings("invite")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(o?.data?.invite){const i=o?.data?.invite;Object.entries(i).forEach(([d,h])=>{typeof h=="number"?n.setValue(d,String(h)):n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"invite_force",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(F,{children:s("invite.invite_force.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"invite_commission",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("invite.invite_commission.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"invite_gen_limit",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("invite.invite_gen_limit.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"invite_never_expire",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(F,{children:s("invite.invite_never_expire.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_first_time_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(F,{children:s("invite.commission_first_time.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_auto_check_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(F,{children:s("invite.commission_auto_check.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_withdraw_limit",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"commission_withdraw_method",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_method.placeholder"),...i,value:Array.isArray(i.value)?i.value.join(","):"",onChange:d=>{const h=d.target.value.split(",").filter(Boolean);i.onChange(h),u(n.getValues())}})}),e.jsx(F,{children:s("invite.commission_withdraw_method.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"withdraw_close_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(F,{children:s("invite.withdraw_close.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_distribution_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(F,{children:s("invite.commission_distribution.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"commission_distribution_l1",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l1")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const h=d.target.value?Number(d.target.value):0;i.onChange(h),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"commission_distribution_l2",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l2")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const h=d.target.value?Number(d.target.value):0;i.onChange(h),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"commission_distribution_l3",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l3")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const h=d.target.value?Number(d.target.value):0;i.onChange(h),u(n.getValues())}})}),e.jsx(P,{})]})})]}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function ym(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ke,{}),e.jsx(bm,{})]})}const Nm=Object.freeze(Object.defineProperty({__proto__:null,default:ym},Symbol.toStringTag,{value:"Module"})),_m=x.object({frontend_theme:x.string().nullable(),frontend_theme_sidebar:x.string().nullable(),frontend_theme_header:x.string().nullable(),frontend_theme_color:x.string().nullable(),frontend_background_url:x.string().url().nullable()}),wm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Cm(){const{data:s}=ne({queryKey:["settings","frontend"],queryFn:()=>me.getSettings("frontend")}),a=ye({resolver:_e(_m),defaultValues:wm,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([n,o])=>{a.setValue(n,o)})}},[s]);function t(l){me.saveSettings(l).then(({data:n})=>{n&&A.success("更新成功")})}return e.jsx(we,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(t),className:"space-y-8",children:[e.jsx(v,{control:a.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(v,{control:a.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(v,{control:a.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(f,{children:[e.jsx(j,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(b,{children:e.jsxs("select",{className:y(wt({variant:"outline"}),"w-[200px] appearance-none font-normal"),...l,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(pn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(P,{})]})}),e.jsx(v,{control:a.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(f,{children:[e.jsx(j,{children:"背景"}),e.jsx(b,{children:e.jsx(D,{placeholder:"请输入图片地址",...l})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(P,{})]})}),e.jsx(E,{type:"submit",children:"保存设置"})]})})}function Sm(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"个性化设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自定义系统界面外观,包括主题风格、布局、颜色方案、背景图等个性化选项。"})]}),e.jsx(ke,{}),e.jsx(Cm,{})]})}const km=Object.freeze(Object.defineProperty({__proto__:null,default:Sm},Symbol.toStringTag,{value:"Module"})),Tm=x.object({server_pull_interval:x.coerce.number().nullable(),server_push_interval:x.coerce.number().nullable(),server_token:x.string().nullable(),device_limit_mode:x.coerce.number().nullable()}),Dm={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Pm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(Tm),defaultValues:Dm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","server"],queryFn:()=>me.getSettings("server")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:d=>{d.data&&A.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(o?.data.server){const d=o.data.server;Object.entries(d).forEach(([h,_])=>{n.setValue(h,_)}),l.current=d}},[o]);const c=m.useCallback(Se.debounce(async d=>{if(!Se.isEqual(d,l.current)){t(!0);try{await r(d),l.current=d}finally{t(!1)}}},1e3),[r]),u=m.useCallback(d=>{c(d)},[c]);m.useEffect(()=>{const d=n.watch(h=>{u(h)});return()=>d.unsubscribe()},[n.watch,u]);const i=()=>{const d=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let _="";for(let T=0;Te.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_token.title")}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(be,{children:e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:h=>{h.preventDefault(),i()},children:e.jsx(lc,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(de,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(F,{children:s("server.server_token.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;d.onChange(_)}})}),e.jsx(F,{children:s("server.server_pull_interval.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"server_push_interval",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;d.onChange(_)}})}),e.jsx(F,{children:s("server.server_push_interval.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(X,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx($,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(F,{children:s("server.device_limit_mode.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Em(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ke,{}),e.jsx(Pm,{})]})}const Rm=Object.freeze(Object.defineProperty({__proto__:null,default:Em},Symbol.toStringTag,{value:"Module"}));function Im({open:s,onOpenChange:a,result:t}){const l=!t.error;return e.jsx(pe,{open:s,onOpenChange:a,children:e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(ql,{className:"h-5 w-5 text-green-500"}):e.jsx(Hl,{className:"h-5 w-5 text-destructive"}),e.jsx(ge,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Le,{children:l?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(Nt,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const Lm=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function Vm(){const{t:s}=V("settings"),[a,t]=m.useState(null),[l,n]=m.useState(!1),o=m.useRef(null),[r,c]=m.useState(!1),u=ye({resolver:_e(Lm),defaultValues:{},mode:"onBlur"}),{data:i}=ne({queryKey:["settings","email"],queryFn:()=>me.getSettings("email")}),{data:d}=ne({queryKey:["emailTemplate"],queryFn:()=>me.getEmailTemplate()}),{mutateAsync:h}=gs({mutationFn:me.saveSettings,onSuccess:N=>{N.data&&A.success(s("common.autoSaved"))}}),{mutate:_,isPending:T}=gs({mutationFn:me.sendTestMail,onMutate:()=>{t(null),n(!1)},onSuccess:N=>{t(N.data),n(!0),N.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});m.useEffect(()=>{if(i?.data.email){const N=i.data.email;Object.entries(N).forEach(([g,k])=>{u.setValue(g,k)}),o.current=N}},[i]);const S=m.useCallback(Se.debounce(async N=>{if(!Se.isEqual(N,o.current)){c(!0);try{await h(N),o.current=N}finally{c(!1)}}},1e3),[h]),C=m.useCallback(N=>{S(N)},[S]);return m.useEffect(()=>{const N=u.watch(g=>{C(g)});return()=>N.unsubscribe()},[u.watch,C]),e.jsxs(e.Fragment,{children:[e.jsx(we,{...u,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"email_host",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_host.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_host.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_port",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_port.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...N,value:N.value||"",onChange:g=>{const k=g.target.value?Number(g.target.value):null;N.onChange(k)}})}),e.jsx(F,{children:s("email.email_port.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_encryption",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(X,{onValueChange:g=>{const k=g==="none"?"":g;N.onChange(k)},value:N.value===""||N.value===null||N.value===void 0?"none":N.value,children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择加密方式"})})}),e.jsxs(J,{children:[e.jsx($,{value:"none",children:s("email.email_encryption.none")}),e.jsx($,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx($,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(F,{children:s("email.email_encryption.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_username",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_username.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_username.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_password",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_password.title")}),e.jsx(b,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_password.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_from_address",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_from.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_from.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_template",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(X,{onValueChange:g=>{N.onChange(g),C(u.getValues())},value:N.value||void 0,children:[e.jsx(b,{children:e.jsx(Y,{className:"w-[200px]",children:e.jsx(Z,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(J,{children:d?.data?.map(g=>e.jsx($,{value:g,children:g},g))})]}),e.jsx(F,{children:s("email.email_template.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"remind_mail_enable",render:({field:N})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(F,{children:s("email.remind_mail.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:N.value||!1,onCheckedChange:g=>{N.onChange(g),C(u.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(E,{onClick:()=>_(),loading:T,disabled:T,children:s(T?"email.test.sending":"email.test.title")})})]})}),r&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),a&&e.jsx(Im,{open:l,onOpenChange:n,result:a})]})}function Fm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ke,{}),e.jsx(Vm,{})]})}const Mm=Object.freeze(Object.defineProperty({__proto__:null,default:Fm},Symbol.toStringTag,{value:"Module"})),Om=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),zm={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function $m(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(Om),defaultValues:zm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","telegram"],queryFn:()=>me.getSettings("telegram")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}}),{mutate:c,isPending:u}=gs({mutationFn:me.setTelegramWebhook,onSuccess:h=>{h.data&&A.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(o?.data.telegram){const h=o.data.telegram;Object.entries(h).forEach(([_,T])=>{n.setValue(_,T)}),l.current=h}},[o]);const i=m.useCallback(Se.debounce(async h=>{if(!Se.isEqual(h,l.current)){t(!0);try{await r(h),l.current=h}finally{t(!1)}}},1e3),[r]),d=m.useCallback(h=>{i(h)},[i]);return m.useEffect(()=>{const h=n.watch(_=>{d(_)});return()=>h.unsubscribe()},[n.watch,d]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.bot_token.description")}),e.jsx(P,{})]})}),n.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(E,{loading:u,disabled:u,onClick:()=>c(),children:s(u?"telegram.webhook.setting":"telegram.webhook.button")}),a&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(F,{children:s("telegram.webhook.description")}),e.jsx(P,{})]}),e.jsx(v,{control:n.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(F,{children:s("telegram.bot_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:h.value||!1,onCheckedChange:_=>{h.onChange(_),d(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.discuss_link.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Am(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ke,{}),e.jsx($m,{})]})}const qm=Object.freeze(Object.defineProperty({__proto__:null,default:Am},Symbol.toStringTag,{value:"Module"})),Hm=x.object({windows_version:x.string().nullable(),windows_download_url:x.string().nullable(),macos_version:x.string().nullable(),macos_download_url:x.string().nullable(),android_version:x.string().nullable(),android_download_url:x.string().nullable()}),Um={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Km(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(Hm),defaultValues:Um,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","app"],queryFn:()=>me.getSettings("app")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("app.save_success"))}});m.useEffect(()=>{if(o?.data.app){const i=o.data.app;Object.entries(i).forEach(([d,h])=>{n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"windows_version",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.windows.version.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"windows_download_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.windows.download.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"macos_version",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.macos.version.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"macos_download_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.macos.download.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"android_version",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.android.version.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"android_download_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.android.download.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Bm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ke,{}),e.jsx(Km,{})]})}const Gm=Object.freeze(Object.defineProperty({__proto__:null,default:Bm},Symbol.toStringTag,{value:"Module"})),Wm=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),Wn={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function kr({refetch:s,dialogTrigger:a,type:t="add",defaultFormValues:l=Wn}){const{t:n}=V("payment"),[o,r]=m.useState(!1),[c,u]=m.useState(!1),[i,d]=m.useState([]),[h,_]=m.useState([]),T=Wm(n),S=ye({resolver:_e(T),defaultValues:l,mode:"onChange"}),C=S.watch("payment");m.useEffect(()=>{o&&(async()=>{const{data:k}=await Qs.getMethodList();d(k)})()},[o]),m.useEffect(()=>{if(!C||!o)return;(async()=>{const k={payment:C,...t==="edit"&&{id:Number(S.getValues("id"))}};Qs.getMethodForm(k).then(({data:R})=>{_(R);const p=R.reduce((w,I)=>(I.field_name&&(w[I.field_name]=I.value??""),w),{});S.setValue("config",p)})})()},[C,o,S,t]);const N=async g=>{u(!0);try{(await Qs.save(g)).data&&(A.success(n("form.messages.success")),S.reset(Wn),s(),r(!1))}finally{u(!1)}};return e.jsxs(pe,{open:o,onOpenChange:r,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"})," ",e.jsx("div",{children:n("form.add.button")})]})}),e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(ge,{children:n(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(we,{...S,children:e.jsxs("form",{onSubmit:S.handleSubmit(N),className:"space-y-4",children:[e.jsx(v,{control:S.control,name:"name",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:n("form.fields.name.placeholder"),...g})}),e.jsx(F,{children:n("form.fields.name.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:S.control,name:"icon",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.icon.label")}),e.jsx(b,{children:e.jsx(D,{...g,value:g.value||"",placeholder:n("form.fields.icon.placeholder")})}),e.jsx(F,{children:n("form.fields.icon.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:S.control,name:"notify_domain",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.notify_domain.label")}),e.jsx(b,{children:e.jsx(D,{...g,value:g.value||"",placeholder:n("form.fields.notify_domain.placeholder")})}),e.jsx(F,{children:n("form.fields.notify_domain.description")}),e.jsx(P,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:S.control,name:"handling_fee_percent",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.handling_fee_percent.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...g,value:g.value||"",placeholder:n("form.fields.handling_fee_percent.placeholder")})}),e.jsx(P,{})]})}),e.jsx(v,{control:S.control,name:"handling_fee_fixed",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.handling_fee_fixed.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...g,value:g.value||"",placeholder:n("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(P,{})]})})]}),e.jsx(v,{control:S.control,name:"payment",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.payment.label")}),e.jsxs(X,{onValueChange:g.onChange,defaultValue:g.value,children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:n("form.fields.payment.placeholder")})})}),e.jsx(J,{children:i.map(k=>e.jsx($,{value:k,children:k},k))})]}),e.jsx(F,{children:n("form.fields.payment.description")}),e.jsx(P,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(g=>e.jsx(v,{control:S.control,name:`config.${g.field_name}`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(j,{children:g.label}),e.jsx(b,{children:e.jsx(D,{...k,value:k.value||""})}),e.jsx(P,{})]})},g.field_name))}),e.jsxs(Re,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.buttons.cancel")})}),e.jsx(E,{type:"submit",disabled:c,children:n("form.buttons.submit")})]})]})})]})]})}function z({column:s,title:a,tooltip:t,className:l}){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(E,{variant:"ghost",size:"default",className:y("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",l),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:a}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(An,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(de,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(Xa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Za,{className:"h-4 w-4 text-foreground/70"}):e.jsx(rc,{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",l),children:[e.jsx("span",{children:a}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(xe,{children:[e.jsx(he,{children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(de,{children:t})]})})]})}const Cn=ic,Tr=oc,Ym=cc,Dr=m.forwardRef(({className:s,...a},t)=>e.jsx(Kl,{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),...a,ref:t}));Dr.displayName=Kl.displayName;const Ta=m.forwardRef(({className:s,...a},t)=>e.jsxs(Ym,{children:[e.jsx(Dr,{}),e.jsx(Bl,{ref:t,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),...a})]}));Ta.displayName=Bl.displayName;const Da=({className:s,...a})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...a});Da.displayName="AlertDialogHeader";const Pa=({className:s,...a})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});Pa.displayName="AlertDialogFooter";const Ea=m.forwardRef(({className:s,...a},t)=>e.jsx(Gl,{ref:t,className:y("text-lg font-semibold",s),...a}));Ea.displayName=Gl.displayName;const Ra=m.forwardRef(({className:s,...a},t)=>e.jsx(Wl,{ref:t,className:y("text-sm text-muted-foreground",s),...a}));Ra.displayName=Wl.displayName;const Ia=m.forwardRef(({className:s,...a},t)=>e.jsx(Yl,{ref:t,className:y(bt(),s),...a}));Ia.displayName=Yl.displayName;const La=m.forwardRef(({className:s,...a},t)=>e.jsx(Jl,{ref:t,className:y(bt({variant:"outline"}),"mt-2 sm:mt-0",s),...a}));La.displayName=Jl.displayName;function ns({onConfirm:s,children:a,title:t="确认操作",description:l="确定要执行此操作吗?",cancelText:n="取消",confirmText:o="确认",variant:r="default",className:c}){return e.jsxs(Cn,{children:[e.jsx(Tr,{asChild:!0,children:a}),e.jsxs(Ta,{className:y("sm:max-w-[425px]",c),children:[e.jsxs(Da,{children:[e.jsx(Ea,{children:t}),e.jsx(Ra,{children:l})]}),e.jsxs(Pa,{children:[e.jsx(La,{asChild:!0,children:e.jsx(E,{variant:"outline",children:n})}),e.jsx(Ia,{asChild:!0,children:e.jsx(E,{variant:r,onClick:s,children:o})})]})]})]})}const Pr=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"})}),Jm=({refetch:s,isSortMode:a=!1})=>{const{t}=V("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:a?"cursor-move":"opacity-0",children:e.jsx(Na,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.id")}),cell:({row:l})=>e.jsx(B,{variant:"outline",children:l.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.enable")}),cell:({row:l})=>e.jsx(ee,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:n}=await Qs.updateStatus({id:l.original.id});n||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.name")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.payment")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:l})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(z,{column:l,title:t("table.columns.notify_url")}),e.jsx(be,{delayDuration:100,children:e.jsxs(xe,{children:[e.jsx(he,{className:"ml-1",children:e.jsx(Pr,{className:"h-4 w-4"})}),e.jsx(de,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:l.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:l})=>e.jsx(z,{className:"justify-end",column:l,title:t("table.columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(kr,{refetch:s,dialogTrigger:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(ns,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:n}=await Qs.drop({id:l.original.id});n&&s()},children:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function Qm({table:s,refetch:a,saveOrder:t,isSortMode:l}){const{t:n}=V("payment"),o=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kr,{refetch:a}),e.jsx(D,{placeholder:n("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:"h-8 w-[250px]"}),o&&e.jsxs(E,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[n("table.toolbar.reset"),e.jsx(ds,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(E,{variant:l?"default":"outline",onClick:t,size:"sm",children:n(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Xm(){const[s,a]=m.useState([]),[t,l]=m.useState([]),[n,o]=m.useState(!1),[r,c]=m.useState([]),[u,i]=m.useState({"drag-handle":!1}),[d,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:_}=ne({queryKey:["paymentList"],queryFn:async()=>{const{data:g}=await Qs.getList();return c(g?.map(k=>({...k,enable:!!k.enable}))||[]),g}});m.useEffect(()=>{i({"drag-handle":n,actions:!n}),h({pageSize:n?99999:10,pageIndex:0})},[n]);const T=(g,k)=>{n&&(g.dataTransfer.setData("text/plain",k.toString()),g.currentTarget.classList.add("opacity-50"))},S=(g,k)=>{if(!n)return;g.preventDefault(),g.currentTarget.classList.remove("bg-muted");const R=parseInt(g.dataTransfer.getData("text/plain"));if(R===k)return;const p=[...r],[w]=p.splice(R,1);p.splice(k,0,w),c(p)},C=async()=>{n?Qs.sort({ids:r.map(g=>g.id)}).then(()=>{_(),o(!1),A.success("排序保存成功")}):o(!0)},N=Je({data:r,columns:Jm({refetch:_,isSortMode:n}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:d},onSortingChange:l,onColumnFiltersChange:a,onColumnVisibilityChange:i,getCoreRowModel:Qe(),getFilteredRowModel:js(),getPaginationRowModel:ls(),getSortedRowModel:vs(),initialState:{columnPinning:{right:["actions"]}},pageCount:n?1:void 0});return e.jsx(is,{table:N,toolbar:g=>e.jsx(Qm,{table:g,refetch:_,saveOrder:C,isSortMode:n}),draggable:n,onDragStart:T,onDragEnd:g=>g.currentTarget.classList.remove("opacity-50"),onDragOver:g=>{g.preventDefault(),g.currentTarget.classList.add("bg-muted")},onDragLeave:g=>g.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!n})}function Zm(){const{t:s}=V("payment");return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Xm,{})})]})]})}const eu=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"}));function su({pluginName:s,onClose:a,onSuccess:t}){const{t:l}=V("plugin"),[n,o]=m.useState(!0),[r,c]=m.useState(!1),[u,i]=m.useState(null),d=dc({config:mc(uc())}),h=ye({resolver:_e(d),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:C}=await Ps.getPluginConfig(s);i(C),h.reset({config:Object.fromEntries(Object.entries(C).map(([N,g])=>[N,g.value]))})}catch{A.error(l("messages.configLoadError"))}finally{o(!1)}})()},[s]);const _=async S=>{c(!0);try{await Ps.updatePluginConfig(s,S.config),A.success(l("messages.configSaveSuccess")),t()}catch{A.error(l("messages.configSaveError"))}finally{c(!1)}},T=(S,C)=>{switch(C.type){case"string":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsx(b,{children:e.jsx(D,{placeholder:C.placeholder,...N})}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);case"number":case"percentage":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:C.placeholder,...N,onChange:g=>{const k=Number(g.target.value);C.type==="percentage"?N.onChange(Math.min(100,Math.max(0,k))):N.onChange(k)},className:C.type==="percentage"?"pr-8":"",min:C.type==="percentage"?0:void 0,max:C.type==="percentage"?100:void 0,step:C.type==="percentage"?1:void 0}),C.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(xc,{className:"h-4 w-4 text-muted-foreground"})})]})}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);case"select":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsxs(X,{onValueChange:N.onChange,defaultValue:N.value,children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:C.placeholder})})}),e.jsx(J,{children:C.options?.map(g=>e.jsx($,{value:g.value,children:g.label},g.value))})]}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);case"boolean":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:C.label||C.description}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description})]}),e.jsx(b,{children:e.jsx(ee,{checked:N.value,onCheckedChange:N.onChange})})]})},S);case"text":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsx(b,{children:e.jsx(Ts,{placeholder:C.placeholder,...N})}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);default:return null}};return n?e.jsxs("div",{className:"space-y-4",children:[e.jsx(ce,{className:"h-4 w-[200px]"}),e.jsx(ce,{className:"h-10 w-full"}),e.jsx(ce,{className:"h-4 w-[200px]"}),e.jsx(ce,{className:"h-10 w-full"})]}):e.jsx(we,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(_),className:"space-y-4",children:[u&&Object.entries(u).map(([S,C])=>T(S,C)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(E,{type:"button",variant:"outline",onClick:a,disabled:r,children:l("config.cancel")}),e.jsx(E,{type:"submit",loading:r,disabled:r,children:l("config.save")})]})]})})}function tu(){const{t:s}=V("plugin"),[a,t]=m.useState(null),[l,n]=m.useState(!1),[o,r]=m.useState(null),[c,u]=m.useState(""),[i,d]=m.useState("all"),[h,_]=m.useState(!1),[T,S]=m.useState(!1),[C,N]=m.useState(!1),g=m.useRef(null),{data:k,isLoading:R,refetch:p}=ne({queryKey:["pluginList"],queryFn:async()=>{const{data:L}=await Ps.getPluginList();return L}});k&&[...new Set(k.map(L=>L.category||"other"))];const w=k?.filter(L=>{const U=L.name.toLowerCase().includes(c.toLowerCase())||L.description.toLowerCase().includes(c.toLowerCase())||L.code.toLowerCase().includes(c.toLowerCase()),ms=i==="all"||L.category===i;return U&&ms}),I=async L=>{t(L),Ps.installPlugin(L).then(()=>{A.success(s("messages.installSuccess")),p()}).catch(U=>{A.error(U.message||s("messages.installError"))}).finally(()=>{t(null)})},H=async L=>{t(L),Ps.uninstallPlugin(L).then(()=>{A.success(s("messages.uninstallSuccess")),p()}).catch(U=>{A.error(U.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},O=async(L,U)=>{t(L),(U?Ps.disablePlugin:Ps.enablePlugin)(L).then(()=>{A.success(s(U?"messages.disableSuccess":"messages.enableSuccess")),p()}).catch(De=>{A.error(De.message||s(U?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},K=L=>{k?.find(U=>U.code===L),r(L),n(!0)},oe=async L=>{if(!L.name.endsWith(".zip")){A.error(s("upload.error.format"));return}_(!0),Ps.uploadPlugin(L).then(()=>{A.success(s("messages.uploadSuccess")),S(!1),p()}).catch(U=>{A.error(U.message||s("messages.uploadError"))}).finally(()=>{_(!1),g.current&&(g.current.value="")})},W=L=>{L.preventDefault(),L.stopPropagation(),L.type==="dragenter"||L.type==="dragover"?N(!0):L.type==="dragleave"&&N(!1)},te=L=>{L.preventDefault(),L.stopPropagation(),N(!1),L.dataTransfer.files&&L.dataTransfer.files[0]&&oe(L.dataTransfer.files[0])},q=async L=>{t(L),Ps.deletePlugin(L).then(()=>{A.success(s("messages.deleteSuccess")),p()}).catch(U=>{A.error(U.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(xn,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(hn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:c,onChange:L=>u(L.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(E,{onClick:()=>S(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Bt,{defaultValue:"all",className:"w-full",children:[e.jsxs(Ct,{children:[e.jsx(Ee,{value:"all",children:s("tabs.all")}),e.jsx(Ee,{value:"installed",children:s("tabs.installed")}),e.jsx(Ee,{value:"available",children:s("tabs.available")})]}),e.jsx(We,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Ka,{}),e.jsx(Ka,{}),e.jsx(Ka,{})]}):w?.map(L=>e.jsx(Ua,{plugin:L,onInstall:I,onUninstall:H,onToggleEnable:O,onOpenConfig:K,onDelete:q,isLoading:a===L.name},L.name))})}),e.jsx(We,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(L=>L.is_installed).map(L=>e.jsx(Ua,{plugin:L,onInstall:I,onUninstall:H,onToggleEnable:O,onOpenConfig:K,onDelete:q,isLoading:a===L.name},L.name))})}),e.jsx(We,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(L=>!L.is_installed).map(L=>e.jsx(Ua,{plugin:L,onInstall:I,onUninstall:H,onToggleEnable:O,onOpenConfig:K,onDelete:q,isLoading:a===L.name},L.code))})})]})]}),e.jsx(pe,{open:l,onOpenChange:n,children:e.jsxs(ue,{className:"sm:max-w-lg",children:[e.jsxs(ve,{children:[e.jsxs(ge,{children:[k?.find(L=>L.code===o)?.name," ",s("config.title")]}),e.jsx(Le,{children:s("config.description")})]}),o&&e.jsx(su,{pluginName:o,onClose:()=>n(!1),onSuccess:()=>{n(!1),p()}})]})}),e.jsx(pe,{open:T,onOpenChange:S,children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:s("upload.title")}),e.jsx(Le,{children:s("upload.description")})]}),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",C&&"border-primary/50 bg-muted/50"),onDragEnter:W,onDragLeave:W,onDragOver:W,onDrop:te,children:[e.jsx("input",{type:"file",ref:g,className:"hidden",accept:".zip",onChange:L=>{const U=L.target.files?.[0];U&&oe(U)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(At,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>g.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function Ua({plugin:s,onInstall:a,onUninstall:t,onToggleEnable:l,onOpenConfig:n,onDelete:o,isLoading:r}){const{t:c}=V("plugin");return e.jsxs(Ye,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(ss,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_s,{children:s.name}),s.is_installed&&e.jsx(B,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?c("status.enabled"):c("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Xs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[c("author"),": ",s.author]})})]})})]}),e.jsx(ts,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(E,{variant:"outline",size:"sm",onClick:()=>n(s.code),disabled:!s.is_enabled||r,children:[e.jsx(hc,{className:"mr-2 h-4 w-4"}),c("button.config")]}),e.jsxs(E,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>l(s.code,s.is_enabled),disabled:r,children:[e.jsx(pc,{className:"mr-2 h-4 w-4"}),s.is_enabled?c("button.disable"):c("button.enable")]}),e.jsx(ns,{title:c("uninstall.title"),description:c("uninstall.description"),cancelText:c("common:cancel"),confirmText:c("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(E,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:r,children:[e.jsx(fs,{className:"mr-2 h-4 w-4"}),c("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{onClick:()=>a(s.code),disabled:r,loading:r,children:c("button.install")}),e.jsx(ns,{title:c("delete.title"),description:c("delete.description"),cancelText:c("common:cancel"),confirmText:c("delete.button"),variant:"destructive",onConfirm:()=>o(s.code),children:e.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:r,children:e.jsx(fs,{className:"h-4 w-4"})})})]})})})]})}function Ka(){return e.jsxs(Ye,{children:[e.jsxs(ss,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-6 w-[200px]"}),e.jsx(ce,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ce,{className:"h-5 w-[120px]"}),e.jsx(ce,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(ce,{className:"h-4 w-[300px]"}),e.jsx(ce,{className:"h-4 w-[150px]"})]})]}),e.jsx(ts,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(ce,{className:"h-9 w-[100px]"}),e.jsx(ce,{className:"h-9 w-[100px]"}),e.jsx(ce,{className:"h-8 w-8"})]})})]})}const au=Object.freeze(Object.defineProperty({__proto__:null,default:tu},Symbol.toStringTag,{value:"Module"})),nu=(s,a)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(D,{placeholder:s.placeholder,...a});break;case"textarea":t=e.jsx(Ts,{placeholder:s.placeholder,...a});break;case"select":t=e.jsx("select",{className:y(bt({variant:"outline"}),"w-full appearance-none font-normal"),...a,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:t=null;break}return t};function lu({themeKey:s,themeInfo:a}){const{t}=V("theme"),[l,n]=m.useState(!1),[o,r]=m.useState(!1),[c,u]=m.useState(!1),i=ye({defaultValues:a.configs.reduce((_,T)=>(_[T.field_name]="",_),{})}),d=async()=>{r(!0),Mt.getConfig(s).then(({data:_})=>{Object.entries(_).forEach(([T,S])=>{i.setValue(T,S)})}).finally(()=>{r(!1)})},h=async _=>{u(!0),Mt.updateConfig(s,_).then(()=>{A.success(t("config.success")),n(!1)}).finally(()=>{u(!1)})};return e.jsxs(pe,{open:l,onOpenChange:_=>{n(_),_?d():i.reset()},children:[e.jsx(rs,{asChild:!0,children:e.jsx(E,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(ue,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:t("config.title",{name:a.name})}),e.jsx(Le,{children:t("config.description")})]}),o?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(gn,{className:"h-6 w-6 animate-spin"})}):e.jsx(we,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(h),className:"space-y-4",children:[a.configs.map(_=>e.jsx(v,{control:i.control,name:_.field_name,render:({field:T})=>e.jsxs(f,{children:[e.jsx(j,{children:_.label}),e.jsx(b,{children:nu(_,T)}),e.jsx(P,{})]})},_.field_name)),e.jsxs(Re,{className:"mt-6 gap-2",children:[e.jsx(E,{type:"button",variant:"secondary",onClick:()=>n(!1),children:t("config.cancel")}),e.jsx(E,{type:"submit",loading:c,children:t("config.save")})]})]})})]})]})}function ru(){const{t:s}=V("theme"),[a,t]=m.useState(null),[l,n]=m.useState(!1),[o,r]=m.useState(!1),[c,u]=m.useState(!1),[i,d]=m.useState(null),h=m.useRef(null),[_,T]=m.useState(0),{data:S,isLoading:C,refetch:N}=ne({queryKey:["themeList"],queryFn:async()=>{const{data:O}=await Mt.getList();return O}}),g=async O=>{t(O),me.updateSystemConfig({frontend_theme:O}).then(()=>{A.success("主题切换成功"),N()}).finally(()=>{t(null)})},k=async O=>{if(!O.name.endsWith(".zip")){A.error(s("upload.error.format"));return}n(!0),Mt.upload(O).then(()=>{A.success("主题上传成功"),r(!1),N()}).finally(()=>{n(!1),h.current&&(h.current.value="")})},R=O=>{O.preventDefault(),O.stopPropagation(),O.type==="dragenter"||O.type==="dragover"?u(!0):O.type==="dragleave"&&u(!1)},p=O=>{O.preventDefault(),O.stopPropagation(),u(!1),O.dataTransfer.files&&O.dataTransfer.files[0]&&k(O.dataTransfer.files[0])},w=()=>{i&&T(O=>O===0?i.images.length-1:O-1)},I=()=>{i&&T(O=>O===i.images.length-1?0:O+1)},H=(O,K)=>{T(0),d({name:O,images:K})};return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(E,{onClick:()=>r(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Yn,{}),e.jsx(Yn,{})]}):S?.themes&&Object.entries(S.themes).map(([O,K])=>e.jsx(Ye,{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(ns,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(O===S?.active){A.error(s("card.delete.error.active"));return}t(O),Mt.drop(O).then(()=>{A.success("主题删除成功"),N()}).finally(()=>{t(null)})},children:e.jsx(E,{disabled:a===O,loading:a===O,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(fs,{className:"h-4 w-4"})})})}),e.jsxs(ss,{children:[e.jsx(_s,{children:K.name}),e.jsx(Xs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:K.description}),K.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:K.version})})]})})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[K.images&&Array.isArray(K.images)&&K.images.length>0&&e.jsx(E,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>H(K.name,K.images),children:e.jsx(gc,{className:"h-4 w-4"})}),e.jsx(lu,{themeKey:O,themeInfo:K}),e.jsx(E,{onClick:()=>g(O),disabled:a===O||O===S.active,loading:a===O,variant:O===S.active?"secondary":"default",children:O===S.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},O))}),e.jsx(pe,{open:o,onOpenChange:r,children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:s("upload.title")}),e.jsx(Le,{children:s("upload.description")})]}),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",c&&"border-primary/50 bg-muted/50"),onDragEnter:R,onDragLeave:R,onDragOver:R,onDrop:p,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:O=>{const K=O.target.files?.[0];K&&k(K)}}),l?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(At,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(pe,{open:!!i,onOpenChange:O=>{O||(d(null),T(0))},children:e.jsxs(ue,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(ge,{children:[i?.name," ",s("preview.title")]}),e.jsx(Le,{className:"text-center",children:i&&s("preview.imageCount",{current:_+1,total:i.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:i?.images[_]&&e.jsx("img",{src:i.images[_],alt:`${i.name} 预览图 ${_+1}`,className:"h-full w-full object-contain"})}),i&&i.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(E,{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:w,children:e.jsx(fc,{className:"h-4 w-4"})}),e.jsx(E,{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:I,children:e.jsx(jc,{className:"h-4 w-4"})})]})]}),i&&i.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:i.images.map((O,K)=>e.jsx("button",{onClick:()=>T(K),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",_===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:O,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function Yn(){return e.jsxs(Ye,{children:[e.jsxs(ss,{children:[e.jsx(ce,{className:"h-6 w-[200px]"}),e.jsx(ce,{className:"h-4 w-[300px]"})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[e.jsx(ce,{className:"h-10 w-[100px]"}),e.jsx(ce,{className:"h-10 w-[100px]"})]})]})}const iu=Object.freeze(Object.defineProperty({__proto__:null,default:ru},Symbol.toStringTag,{value:"Module"})),Sn=m.forwardRef(({className:s,value:a,onChange:t,...l},n)=>{const[o,r]=m.useState("");m.useEffect(()=>{if(o.includes(",")){const u=new Set([...a,...o.split(",").map(i=>i.trim())]);t(Array.from(u)),r("")}},[o,t,a]);const c=()=>{if(o){const u=new Set([...a,o]);t(Array.from(u)),r("")}};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:[a.map(u=>e.jsxs(B,{variant:"secondary",children:[u,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(a.filter(i=>i!==u))},children:e.jsx(an,{className:"w-3"})})]},u)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:o,onChange:u=>r(u.target.value),onKeyDown:u=>{u.key==="Enter"||u.key===","?(u.preventDefault(),c()):u.key==="Backspace"&&o.length===0&&a.length>0&&(u.preventDefault(),t(a.slice(0,-1)))},...l,ref:n})]})});Sn.displayName="InputTags";const ou=x.object({id:x.number().nullable(),title:x.string().min(1).max(250),content:x.string().min(1),show:x.boolean(),tags:x.array(x.string()),img_url:x.string().nullable()}),cu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Er({refetch:s,dialogTrigger:a,type:t="add",defaultFormValues:l=cu}){const{t:n}=V("notice"),[o,r]=m.useState(!1),c=ye({resolver:_e(ou),defaultValues:l,mode:"onChange",shouldFocusError:!0}),u=new fn({html:!0});return e.jsx(we,{...c,children:e.jsxs(pe,{onOpenChange:r,open:o,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"})," ",e.jsx("div",{children:n("form.add.button")})]})}),e.jsxs(ue,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:n(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Le,{})]}),e.jsx(v,{control:c.control,name:"title",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:n("form.fields.title.placeholder"),...i})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"content",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.content.label")}),e.jsx(b,{children:e.jsx(jn,{style:{height:"500px"},value:i.value,renderHTML:d=>u.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"img_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:n("form.fields.img_url.placeholder"),...i,value:i.value||""})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"show",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"tags",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.tags.label")}),e.jsx(b,{children:e.jsx(Sn,{value:i.value,onChange:i.onChange,placeholder:n("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(P,{})]})}),e.jsxs(Re,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.buttons.cancel")})}),e.jsx(E,{type:"submit",onClick:i=>{i.preventDefault(),c.handleSubmit(async d=>{Ht.save(d).then(({data:h})=>{h&&(A.success(n("form.buttons.success")),s(),r(!1))})})()},children:n("form.buttons.submit")})]})]})]})})}function du({table:s,refetch:a,saveOrder:t,isSortMode:l}){const{t:n}=V("notice"),o=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:[!l&&e.jsx(Er,{refetch:a}),!l&&e.jsx(D,{placeholder:n("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:r=>s.getColumn("title")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),o&&!l&&e.jsxs(E,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[n("table.toolbar.reset"),e.jsx(ds,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(E,{variant:l?"default":"outline",onClick:t,className:"h-8",size:"sm",children:n(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const mu=s=>{const{t:a}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(vc,{className:"h-4 w-4 cursor-move text-muted-foreground"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:a("table.columns.id")}),cell:({row:t})=>e.jsx(B,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:a("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:l}=await Ht.updateStatus(t.original.id);l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(z,{column:t,title:a("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:a("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Er,{refetch:s,dialogTrigger:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("table.actions.edit")})]}),type:"edit",defaultFormValues:t.original}),e.jsx(ns,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{Ht.drop(t.original.id).then(()=>{A.success(a("table.actions.delete.success")),s()})},children:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:a("table.actions.delete.title")})]})})]}),size:100}]};function uu(){const[s,a]=m.useState({}),[t,l]=m.useState({}),[n,o]=m.useState([]),[r,c]=m.useState([]),[u,i]=m.useState(!1),[d,h]=m.useState({}),[_,T]=m.useState({pageSize:50,pageIndex:0}),[S,C]=m.useState([]),{refetch:N}=ne({queryKey:["notices"],queryFn:async()=>{const{data:w}=await Ht.getList();return C(w),w}});m.useEffect(()=>{l({"drag-handle":u,content:!u,created_at:!u,actions:!u}),T({pageSize:u?99999:50,pageIndex:0})},[u]);const g=(w,I)=>{u&&(w.dataTransfer.setData("text/plain",I.toString()),w.currentTarget.classList.add("opacity-50"))},k=(w,I)=>{if(!u)return;w.preventDefault(),w.currentTarget.classList.remove("bg-muted");const H=parseInt(w.dataTransfer.getData("text/plain"));if(H===I)return;const O=[...S],[K]=O.splice(H,1);O.splice(I,0,K),C(O)},R=async()=>{if(!u){i(!0);return}Ht.sort(S.map(w=>w.id)).then(()=>{A.success("排序保存成功"),i(!1),N()}).finally(()=>{i(!1)})},p=Je({data:S??[],columns:mu(N),state:{sorting:r,columnVisibility:t,rowSelection:s,columnFilters:n,columnSizing:d,pagination:_},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:c,onColumnFiltersChange:o,onColumnVisibilityChange:l,onColumnSizingChange:h,onPaginationChange:T,getCoreRowModel:Qe(),getFilteredRowModel:js(),getPaginationRowModel:ls(),getSortedRowModel:vs(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Vs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(is,{table:p,toolbar:w=>e.jsx(du,{table:w,refetch:N,saveOrder:R,isSortMode:u}),draggable:u,onDragStart:g,onDragEnd:w=>w.currentTarget.classList.remove("opacity-50"),onDragOver:w=>{w.preventDefault(),w.currentTarget.classList.add("bg-muted")},onDragLeave:w=>w.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!u})})}function xu(){const{t:s}=V("notice");return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(uu,{})})]})]})}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:xu},Symbol.toStringTag,{value:"Module"})),pu=x.object({id:x.number().nullable(),language:x.string().max(250),category:x.string().max(250),title:x.string().min(1).max(250),body:x.string().min(1),show:x.boolean()}),gu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Rr({refreshData:s,dialogTrigger:a,type:t="add",defaultFormValues:l=gu}){const{t:n}=V("knowledge"),[o,r]=m.useState(!1),c=ye({resolver:_e(pu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),u=new fn({html:!0});return m.useEffect(()=>{o&&l.id&&vt.getInfo(l.id).then(({data:i})=>{c.reset(i)})},[l.id,c,o]),e.jsxs(pe,{onOpenChange:r,open:o,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"})," ",e.jsx("div",{children:n("form.add")})]})}),e.jsxs(ue,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:n(t==="add"?"form.add":"form.edit")}),e.jsx(Le,{})]}),e.jsxs(we,{...c,children:[e.jsx(v,{control:c.control,name:"title",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:n("form.titlePlaceholder"),...i})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"category",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:n("form.categoryPlaceholder"),...i})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"language",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.language")}),e.jsx(b,{children:e.jsxs(X,{value:i.value,onValueChange:i.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:n("form.languagePlaceholder")})}),e.jsx(J,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx($,{value:d.value,className:"cursor-pointer",children:n(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(v,{control:c.control,name:"body",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.content")}),e.jsx(b,{children:e.jsx(jn,{style:{height:"500px"},value:i.value,renderHTML:d=>u.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"show",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(P,{})]})}),e.jsxs(Re,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.cancel")})}),e.jsx(E,{type:"submit",onClick:()=>{c.handleSubmit(i=>{vt.save(i).then(({data:d})=>{d&&(c.reset(),A.success(n("messages.operationSuccess")),r(!1),s())})})()},children:n("form.submit")})]})]})]})]})}function fu({column:s,title:a,options:t}){const l=s?.getFacetedUniqueValues(),n=new Set(s?.getFilterValue());return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(_a,{className:"mr-2 h-4 w-4"}),a,n?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(B,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:n.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:n.size>2?e.jsxs(B,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[n.size," selected"]}):t.filter(o=>n.has(o.value)).map(o=>e.jsx(B,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(bs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Us,{children:[e.jsx(nt,{placeholder:a}),e.jsxs(Ks,{children:[e.jsx(lt,{children:"No results found."}),e.jsx(as,{children:t.map(o=>{const r=n.has(o.value);return e.jsxs($e,{onSelect:()=>{r?n.delete(o.value):n.add(o.value);const c=Array.from(n);s?.setFilterValue(c.length?c:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",r?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(et,{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}),l?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(o.value)})]},o.value)})}),n.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(St,{}),e.jsx(as,{children:e.jsx($e,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function ju({table:s,refetch:a,saveOrder:t,isSortMode:l}){const n=s.getState().columnFilters.length>0,{t:o}=V("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:o("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{refreshData:a}),e.jsx(D,{placeholder:o("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:r=>s.getColumn("title")?.setFilterValue(r.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(fu,{column:s.getColumn("category"),title:o("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(r=>r.getValue("category")))).map(r=>({label:r,value:r}))}),n&&e.jsxs(E,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[o("toolbar.reset"),e.jsx(ds,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(E,{variant:l?"default":"outline",onClick:t,size:"sm",children:o(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const vu=({refetch:s,isSortMode:a=!1})=>{const{t}=V("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:a?"cursor-move":"opacity-0",children:e.jsx(Na,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.id")}),cell:({row:l})=>e.jsx(B,{variant:"outline",className:"justify-center",children:l.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{vt.updateStatus({id:l.original.id}).then(({data:n})=>{n||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.title")}),cell:({row:l})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:l.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.category")}),cell:({row:l})=>e.jsx(B,{variant:"secondary",className:"max-w-[180px] truncate",children:l.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:l})=>e.jsx(z,{className:"justify-end",column:l,title:t("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Rr,{refreshData:s,dialogTrigger:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(ns,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{vt.drop({id:l.original.id}).then(({data:n})=>{n&&(A.success(t("messages.operationSuccess")),s())})},children:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function bu(){const[s,a]=m.useState([]),[t,l]=m.useState([]),[n,o]=m.useState(!1),[r,c]=m.useState([]),[u,i]=m.useState({"drag-handle":!1}),[d,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:_,isLoading:T,data:S}=ne({queryKey:["knowledge"],queryFn:async()=>{const{data:R}=await vt.getList();return c(R||[]),R}});m.useEffect(()=>{i({"drag-handle":n,actions:!n}),h({pageSize:n?99999:10,pageIndex:0})},[n]);const C=(R,p)=>{n&&(R.dataTransfer.setData("text/plain",p.toString()),R.currentTarget.classList.add("opacity-50"))},N=(R,p)=>{if(!n)return;R.preventDefault(),R.currentTarget.classList.remove("bg-muted");const w=parseInt(R.dataTransfer.getData("text/plain"));if(w===p)return;const I=[...r],[H]=I.splice(w,1);I.splice(p,0,H),c(I)},g=async()=>{n?vt.sort({ids:r.map(R=>R.id)}).then(()=>{_(),o(!1),A.success("排序保存成功")}):o(!0)},k=Je({data:r,columns:vu({refetch:_,isSortMode:n}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:d},onSortingChange:l,onColumnFiltersChange:a,onColumnVisibilityChange:i,onPaginationChange:h,getCoreRowModel:Qe(),getFilteredRowModel:js(),getPaginationRowModel:ls(),getSortedRowModel:vs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(is,{table:k,toolbar:R=>e.jsx(ju,{table:R,refetch:_,saveOrder:g,isSortMode:n}),draggable:n,onDragStart:C,onDragEnd:R=>R.currentTarget.classList.remove("opacity-50"),onDragOver:R=>{R.preventDefault(),R.currentTarget.classList.add("bg-muted")},onDragLeave:R=>R.currentTarget.classList.remove("bg-muted"),onDrop:N,showPagination:!n})}function yu(){const{t:s}=V("knowledge");return e.jsxs(Ve,{children:[e.jsxs(Fe,{children:[e.jsx(Xe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(bu,{})})]})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:yu},Symbol.toStringTag,{value:"Module"}));function _u(s,a){const[t,l]=m.useState(s);return m.useEffect(()=>{const n=setTimeout(()=>l(s),a);return()=>{clearTimeout(n)}},[s,a]),t}function Ba(s,a){if(s.length===0)return{};if(!a)return{"":s};const t={};return s.forEach(l=>{const n=l[a]||"";t[n]||(t[n]=[]),t[n].push(l)}),t}function wu(s,a){const t=JSON.parse(JSON.stringify(s));for(const[l,n]of Object.entries(t))t[l]=n.filter(o=>!a.find(r=>r.value===o.value));return t}function Cu(s,a){for(const[,t]of Object.entries(s))if(t.some(l=>a.find(n=>n.value===l.value)))return!0;return!1}const Ir=m.forwardRef(({className:s,...a},t)=>bc(n=>n.filtered.count===0)?e.jsx("div",{ref:t,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...a}):null);Ir.displayName="CommandEmpty";const _t=m.forwardRef(({value:s,onChange:a,placeholder:t,defaultOptions:l=[],options:n,delay:o,onSearch:r,loadingIndicator:c,emptyIndicator:u,maxSelected:i=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:h,disabled:_,groupBy:T,className:S,badgeClassName:C,selectFirstItem:N=!0,creatable:g=!1,triggerSearchOnFocus:k=!1,commandProps:R,inputProps:p,hideClearAllButton:w=!1},I)=>{const H=m.useRef(null),[O,K]=m.useState(!1),oe=m.useRef(!1),[W,te]=m.useState(!1),[q,L]=m.useState(s||[]),[U,ms]=m.useState(Ba(l,T)),[De,le]=m.useState(""),ys=_u(De,o||500);m.useImperativeHandle(I,()=>({selectedValue:[...q],input:H.current,focus:()=>H.current?.focus()}),[q]);const Fs=m.useCallback(se=>{const ie=q.filter(Me=>Me.value!==se.value);L(ie),a?.(ie)},[a,q]),Fa=m.useCallback(se=>{const ie=H.current;ie&&((se.key==="Delete"||se.key==="Backspace")&&ie.value===""&&q.length>0&&(q[q.length-1].fixed||Fs(q[q.length-1])),se.key==="Escape"&&ie.blur())},[Fs,q]);m.useEffect(()=>{s&&L(s)},[s]),m.useEffect(()=>{if(!n||r)return;const se=Ba(n||[],T);JSON.stringify(se)!==JSON.stringify(U)&&ms(se)},[l,n,T,r,U]),m.useEffect(()=>{const se=async()=>{te(!0);const Me=await r?.(ys);ms(Ba(Me||[],T)),te(!1)};(async()=>{!r||!O||(k&&await se(),ys&&await se())})()},[ys,T,O,k]);const Gt=()=>{if(!g||Cu(U,[{value:De,label:De}])||q.find(ie=>ie.value===De))return;const se=e.jsx($e,{value:De,className:"cursor-pointer",onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onSelect:ie=>{if(q.length>=i){d?.(q.length);return}le("");const Me=[...q,{value:ie,label:ie}];L(Me),a?.(Me)},children:`Create "${De}"`});if(!r&&De.length>0||r&&ys.length>0&&!W)return se},it=m.useCallback(()=>{if(u)return r&&!g&&Object.keys(U).length===0?e.jsx($e,{value:"-",disabled:!0,children:u}):e.jsx(Ir,{children:u})},[g,u,r,U]),Ma=m.useMemo(()=>wu(U,q),[U,q]),Wt=m.useCallback(()=>{if(R?.filter)return R.filter;if(g)return(se,ie)=>se.toLowerCase().includes(ie.toLowerCase())?1:-1},[g,R?.filter]),Oa=m.useCallback(()=>{const se=q.filter(ie=>ie.fixed);L(se),a?.(se)},[a,q]);return e.jsxs(Us,{...R,onKeyDown:se=>{Fa(se),R?.onKeyDown?.(se)},className:y("h-auto overflow-visible bg-transparent",R?.className),shouldFilter:R?.shouldFilter!==void 0?R.shouldFilter:!r,filter:Wt(),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":q.length!==0,"cursor-text":!_&&q.length!==0},S),onClick:()=>{_||H.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[q.map(se=>e.jsxs(B,{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",C),"data-fixed":se.fixed,"data-disabled":_||void 0,children:[se.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",(_||se.fixed)&&"hidden"),onKeyDown:ie=>{ie.key==="Enter"&&Fs(se)},onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:()=>Fs(se),children:e.jsx(an,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},se.value)),e.jsx(He.Input,{...p,ref:H,value:De,disabled:_,onValueChange:se=>{le(se),p?.onValueChange?.(se)},onBlur:se=>{oe.current===!1&&K(!1),p?.onBlur?.(se)},onFocus:se=>{K(!0),k&&r?.(ys),p?.onFocus?.(se)},placeholder:h&&q.length!==0?"":t,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":q.length===0,"ml-1":q.length!==0},p?.className)}),e.jsx("button",{type:"button",onClick:Oa,className:y((w||_||q.length<1||q.filter(se=>se.fixed).length===q.length)&&"hidden"),children:e.jsx(an,{})})]})}),e.jsx("div",{className:"relative",children:O&&e.jsx(Ks,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{oe.current=!1},onMouseEnter:()=>{oe.current=!0},onMouseUp:()=>{H.current?.focus()},children:W?e.jsx(e.Fragment,{children:c}):e.jsxs(e.Fragment,{children:[it(),Gt(),!N&&e.jsx($e,{value:"-",className:"hidden"}),Object.entries(Ma).map(([se,ie])=>e.jsx(as,{heading:se,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ie.map(Me=>e.jsx($e,{value:Me.value,disabled:Me.disable,onMouseDown:Ms=>{Ms.preventDefault(),Ms.stopPropagation()},onSelect:()=>{if(q.length>=i){d?.(q.length);return}le("");const Ms=[...q,Me];L(Ms),a?.(Ms)},className:y("cursor-pointer",Me.disable&&"cursor-default text-muted-foreground"),children:Me.label},Me.value))})},se))]})})})]})});_t.displayName="MultipleSelector";const Su=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function Va({refetch:s,dialogTrigger:a,defaultValues:t={name:""},type:l="add"}){const{t:n}=V("group"),o=ye({resolver:_e(Su(n)),defaultValues:t,mode:"onChange"}),[r,c]=m.useState(!1),[u,i]=m.useState(!1),d=async h=>{i(!0),at.save(h).then(()=>{A.success(n(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),o.reset(),c(!1)}).finally(()=>{i(!1)})};return e.jsxs(pe,{open:r,onOpenChange:c,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"}),e.jsx("span",{children:n("form.add")})]})}),e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:n(l==="edit"?"form.edit":"form.create")}),e.jsx(Le,{children:n(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(we,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(d),className:"space-y-4",children:[e.jsx(v,{control:o.control,name:"name",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.name")}),e.jsx(b,{children:e.jsx(D,{placeholder:n("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(F,{children:n("form.nameDescription")}),e.jsx(P,{})]})}),e.jsxs(Re,{className:"gap-2",children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.cancel")})}),e.jsxs(E,{type:"submit",disabled:u||!o.formState.isValid,children:[u&&e.jsx(gn,{className:"mr-2 h-4 w-4 animate-spin"}),n(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Lr=m.createContext(void 0);function ku({children:s,refetch:a}){const[t,l]=m.useState(!1),[n,o]=m.useState(null),[r,c]=m.useState(re.Shadowsocks);return e.jsx(Lr.Provider,{value:{isOpen:t,setIsOpen:l,editingServer:n,setEditingServer:o,serverType:r,setServerType:c,refetch:a},children:s})}function Vr(){const s=m.useContext(Lr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Ga({dialogTrigger:s,value:a,setValue:t,templateType:l}){const{t:n}=V("server");m.useEffect(()=>{console.log(a)},[a]);const[o,r]=m.useState(!1),[c,u]=m.useState(()=>{if(!a||Object.keys(a).length===0)return"";try{return JSON.stringify(a,null,2)}catch{return""}}),[i,d]=m.useState(null),h=g=>{if(!g)return null;try{const k=JSON.parse(g);return typeof k!="object"||k===null?n("network_settings.validation.must_be_object"):null}catch{return n("network_settings.validation.invalid_json")}},_={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},T=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},S=()=>{const g=h(c||"");if(g){A.error(g);return}try{if(!c){t(null),r(!1);return}t(JSON.parse(c)),r(!1)}catch{A.error(n("network_settings.errors.save_failed"))}},C=g=>{u(g),d(h(g))},N=g=>{const k=_[g];if(k){const R=JSON.stringify(k.content,null,2);u(R),d(null)}};return m.useEffect(()=>{o&&console.log(a)},[o,a]),m.useEffect(()=>{o&&a&&Object.keys(a).length>0&&u(JSON.stringify(a,null,2))},[o,a]),e.jsxs(pe,{open:o,onOpenChange:g=>{!g&&o&&S(),r(g)},children:[e.jsx(rs,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:n("network_settings.edit_protocol")})}),e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(ge,{children:n("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[T().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:T().map(g=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>N(g),children:n("network_settings.use_template",{template:_[g].label})},g))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ts,{className:`min-h-[200px] font-mono text-sm ${i?"border-red-500 focus-visible:ring-red-500":""}`,value:c,placeholder:T().length>0?n("network_settings.json_config_placeholder_with_template"):n("network_settings.json_config_placeholder"),onChange:g=>C(g.target.value)}),i&&e.jsx("p",{className:"text-sm text-red-500",children:i})]})]}),e.jsxs(Re,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:n("common.cancel")}),e.jsx(G,{onClick:S,disabled:!!i,children:n("common.confirm")})]})]})]})}function qh(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 Tu={},Du=Object.freeze(Object.defineProperty({__proto__:null,default:Tu},Symbol.toStringTag,{value:"Module"})),Hh=Lc(Du),Jn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Pu=()=>{try{const s=yc.box.keyPair(),a=Jn(qn.encodeBase64(s.secretKey)),t=Jn(qn.encodeBase64(s.publicKey));return{privateKey:a,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Eu=()=>{try{return Pu()}catch(s){throw console.error("Error generating key pair:",s),s}},Ru=s=>{const a=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(a),Array.from(a).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},Iu=()=>{const s=Math.floor(Math.random()*8)*2+2;return Ru(s)},Lu=x.object({cipher:x.string().default("aes-128-gcm"),plugin:x.string().optional().default("none"),plugin_opts:x.string().optional().default(""),client_fingerprint:x.string().optional().default("chrome")}),Vu=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),Fu=x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),Mu=x.object({version:x.coerce.number().default(2),alpn:x.string().default("h2"),obfs:x.object({open:x.coerce.boolean().default(!1),type:x.string().default("salamander"),password:x.string().default("")}).default({}),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),bandwidth:x.object({up:x.string().default(""),down:x.string().default("")}).default({}),hop_interval:x.number().optional(),port_range:x.string().optional()}),Ou=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),reality_settings:x.object({server_port:x.coerce.number().default(443),server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),public_key:x.string().default(""),private_key:x.string().default(""),short_id:x.string().default("")}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({}),flow:x.string().default("")}),zu=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),$u=x.object({}),Au=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),qu=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),Hu=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),Uu=x.object({padding_scheme:x.array(x.string()).optional().default([]),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),Te={shadowsocks:{schema:Lu,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"],plugins:[{value:"none",label:"None"},{value:"obfs",label:"Simple Obfs"},{value:"v2ray-plugin",label:"V2Ray Plugin"}],clientFingerprints:[{value:"chrome",label:"Chrome"},{value:"firefox",label:"Firefox"},{value:"safari",label:"Safari"},{value:"ios",label:"iOS"}]},vmess:{schema:Vu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Fu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Mu,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Ou,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:zu,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:$u},naive:{schema:qu},http:{schema:Au},mieru:{schema:Hu,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:Uu,defaultPaddingScheme:["stop=8","0=30-30","1=100-400","2=400-500,c,500-1000,c,500-1000,c,500-1000,c,500-1000","3=9-9,500-1000","4=500-1000","5=500-1000","6=500-1000","7=500-1000"]}},Ku=({serverType:s,value:a,onChange:t})=>{const{t:l}=V("server"),n=s?Te[s]:null,o=n?.schema||x.record(x.any()),r=s?o.parse({}):{},c=ye({resolver:_e(o),defaultValues:r,mode:"onChange"});if(m.useEffect(()=>{if(!a||Object.keys(a).length===0){if(s){const p=o.parse({});c.reset(p)}}else c.reset(a)},[s,a,t,c,o]),m.useEffect(()=>{const p=c.watch(w=>{t(w)});return()=>p.unsubscribe()},[c,t]),!s||!n)return null;const R={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"cipher",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.shadowsocks.ciphers.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})}),e.jsx(v,{control:c.control,name:"plugin",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.plugin.label","插件")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value||"none",children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.plugin.placeholder","选择插件")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.shadowsocks.plugins.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})}),e.jsx(F,{children:p.value&&p.value!=="none"&&e.jsxs(e.Fragment,{children:[p.value==="obfs"&&l("dynamic_form.shadowsocks.plugin.obfs_hint","提示:配置格式如 obfs=http;obfs-host=www.bing.com;path=/"),p.value==="v2ray-plugin"&&l("dynamic_form.shadowsocks.plugin.v2ray_hint","提示:WebSocket模式格式为 mode=websocket;host=mydomain.me;path=/;tls=true,QUIC模式格式为 mode=quic;host=mydomain.me")]})})]})}),c.watch("plugin")&&c.watch("plugin")!=="none"&&e.jsx(v,{control:c.control,name:"plugin_opts",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.plugin_opts.label","插件选项")}),e.jsx(F,{children:l("dynamic_form.shadowsocks.plugin_opts.description","按照 key=value;key2=value2 格式输入插件选项")}),e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.plugin_opts.placeholder","例如: mode=tls;host=bing.com"),...p})})]})}),(c.watch("plugin")==="shadow-tls"||c.watch("plugin")==="restls")&&e.jsx(v,{control:c.control,name:"client_fingerprint",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.client_fingerprint","客户端指纹")}),e.jsx(b,{children:e.jsxs(X,{value:p.value||"chrome",onValueChange:p.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.client_fingerprint_placeholder","选择客户端指纹")})}),e.jsx(J,{children:Te.shadowsocks.clientFingerprints.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})]})}),e.jsx(F,{children:l("dynamic_form.shadowsocks.client_fingerprint_description","客户端伪装指纹,用于降低被识别风险")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),c.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Ga,{value:c.watch("network_settings"),setValue:w=>c.setValue("network_settings",w),templateType:c.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.vmess.networkOptions.map(w=>e.jsx($,{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(v,{control:c.control,name:"server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(v,{control:c.control,name:"allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Ga,{value:c.watch("network_settings")||{},setValue:w=>c.setValue("network_settings",w),templateType:c.watch("network")||"tcp"})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value||"tcp",children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.trojan.networkOptions.map(w=>e.jsx($,{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(v,{control:c.control,name:"version",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:(p.value||2).toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.hysteria.versions.map(w=>e.jsxs($,{value:w,className:"cursor-pointer",children:["V",w]},w))})})]})})]})}),c.watch("version")==1&&e.jsx(v,{control:c.control,name:"alpn",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value||"h2",onValueChange:p.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.hysteria.alpnOptions.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"obfs.open",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})}),!!c.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[c.watch("version")=="2"&&e.jsx(v,{control:c.control,name:"obfs.type",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value||"salamander",onValueChange:p.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:e.jsx($,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(v,{control:c.control,name:"obfs.password",render:({field:p})=>e.jsxs(f,{className:c.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...p,value:p.value||"",className:"pr-9"})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",I=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(H=>w[H%w.length]).join("");c.setValue("obfs.password",I),A.success(l("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(ze,{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(v,{control:c.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(v,{control:c.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"bandwidth.up",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(c.watch("version")==2?l("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(v,{control:c.control,name:"bandwidth.down",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(c.watch("version")==2?l("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})}),e.jsx(e.Fragment,{children:e.jsx(v,{control:c.control,name:"hop_interval",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...p,value:p.value||"",onChange:w=>{const I=w.target.value?parseInt(w.target.value):void 0;p.onChange(I)}})}),e.jsx(F,{children:l("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx($,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx($,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),c.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),c.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"reality_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"reality_settings.server_port",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"reality_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(v,{control:c.control,name:"reality_settings.private_key",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...p,className:"pr-9"})}),e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const w=Eu();c.setValue("reality_settings.private_key",w.privateKey),c.setValue("reality_settings.public_key",w.publicKey),A.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.error(l("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(ze,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(ma,{children:e.jsx(de,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(v,{control:c.control,name:"reality_settings.public_key",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(b,{children:e.jsx(D,{...p})})]})}),e.jsx(v,{control:c.control,name:"reality_settings.short_id",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...p,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const w=Iu();c.setValue("reality_settings.short_id",w),A.success(l("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(ze,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(ma,{children:e.jsx(de,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(v,{control:c.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[l("dynamic_form.vless.network.label"),e.jsx(Ga,{value:c.watch("network_settings"),setValue:w=>c.setValue("network_settings",w),templateType:c.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.vless.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})}),e.jsx(v,{control:c.control,name:"flow",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.flow.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:w=>p.onChange(w==="none"?null:w),value:p.value||"none",children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(J,{children:Te.vless.flowOptions.map(w=>e.jsx($,{value:w,children:w},w))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"version",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.tuic.version.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.tuic.versions.map(w=>e.jsxs($,{value:w,children:["V",w]},w))})})]})})]})}),e.jsx(v,{control:c.control,name:"congestion_control",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.congestion_control.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.tuic.congestionControls.map(w=>e.jsx($,{value:w,children:w.toUpperCase()},w))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.tuic.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.tuic.tls.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"alpn",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.tls.alpn.label")}),e.jsx(b,{children:e.jsx(_t,{options:Te.tuic.alpnOptions,onChange:w=>p.onChange(w.map(I=>I.value)),value:Te.tuic.alpnOptions.filter(w=>p.value?.includes(w.value)),placeholder:l("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:l("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(v,{control:c.control,name:"udp_relay_mode",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.tuic.udpRelayModes.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.naive.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.naive.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.naive.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.naive.tls.enabled")})]})]})})]})}),c.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.naive.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.http.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.http.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.http.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.http.tls.enabled")})]})]})})]})}),c.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.http.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"transport",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.mieru.transport.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.mieru.transport.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.mieru.transportOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})}),e.jsx(v,{control:c.control,name:"multiplexing",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.mieru.multiplexing.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.mieru.multiplexingOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:c.control,name:"padding_scheme",render:({field:p})=>e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(j,{children:l("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{c.setValue("padding_scheme",Te.anytls.defaultPaddingScheme),A.success(l("dynamic_form.anytls.padding_scheme.default_success","已设置默认填充方案"))},className:"h-7 px-2",children:l("dynamic_form.anytls.padding_scheme.use_default","使用默认方案")})]}),e.jsx(F,{children:l("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(b,{children:e.jsx("textarea",{className:"flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:l("dynamic_form.anytls.padding_scheme.placeholder",`例如: +`).filter(Boolean);i.onChange(h),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"recaptcha_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(F,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"recaptcha_site_key",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"recaptcha_key",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.key.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.key.description")}),e.jsx(P,{})]})})]}),e.jsx(v,{control:n.control,name:"register_limit_by_ip_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(F,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"register_limit_count",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.count.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"register_limit_expire",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(P,{})]})})]}),e.jsx(v,{control:n.control,name:"password_limit_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(F,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"password_limit_count",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"password_limit_expire",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(P,{})]})})]}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function mm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ke,{}),e.jsx(dm,{})]})}const um=Object.freeze(Object.defineProperty({__proto__:null,default:mm},Symbol.toStringTag,{value:"Module"})),xm=x.object({plan_change_enable:x.boolean().nullable().default(!1),reset_traffic_method:x.coerce.number().nullable().default(0),surplus_enable:x.boolean().nullable().default(!1),new_order_event_id:x.coerce.number().nullable().default(0),renew_order_event_id:x.coerce.number().nullable().default(0),change_order_event_id:x.coerce.number().nullable().default(0),show_info_to_server_enable:x.boolean().nullable().default(!1),show_protocol_to_server_enable:x.boolean().nullable().default(!1),default_remind_expire:x.boolean().nullable().default(!1),default_remind_traffic:x.boolean().nullable().default(!1),subscribe_path:x.string().nullable().default("s")}),hm={plan_change_enable:!1,reset_traffic_method:0,surplus_enable:!1,new_order_event_id:0,renew_order_event_id:0,change_order_event_id:0,show_info_to_server_enable:!1,show_protocol_to_server_enable:!1,default_remind_expire:!1,default_remind_traffic:!1,subscribe_path:"s"};function pm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(xm),defaultValues:hm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","subscribe"],queryFn:()=>me.getSettings("subscribe")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(o?.data?.subscribe){const i=o?.data?.subscribe;Object.entries(i).forEach(([d,h])=>{n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"plan_change_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(F,{children:s("subscribe.plan_change_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"reset_traffic_method",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择重置方式"})})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx($,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx($,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx($,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx($,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(F,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"surplus_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(F,{children:s("subscribe.surplus_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"new_order_event_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.new_order_event.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"renew_order_event_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.renew_order_event.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"change_order_event_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.change_order_event.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"subscribe_path",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:"subscribe",...i,value:i.value||"",onChange:d=>{i.onChange(d),u(n.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:i.value||"s"})]}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"show_info_to_server_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(F,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"show_protocol_to_server_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(F,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function gm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ke,{}),e.jsx(pm,{})]})}const fm=Object.freeze(Object.defineProperty({__proto__:null,default:gm},Symbol.toStringTag,{value:"Module"})),jm=x.object({invite_force:x.boolean().default(!1),invite_commission:x.coerce.string().default("0"),invite_gen_limit:x.coerce.string().default("0"),invite_never_expire:x.boolean().default(!1),commission_first_time_enable:x.boolean().default(!1),commission_auto_check_enable:x.boolean().default(!1),commission_withdraw_limit:x.coerce.string().default("0"),commission_withdraw_method:x.array(x.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:x.boolean().default(!1),commission_distribution_enable:x.boolean().default(!1),commission_distribution_l1:x.coerce.number().default(0),commission_distribution_l2:x.coerce.number().default(0),commission_distribution_l3:x.coerce.number().default(0)}),vm={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 bm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(jm),defaultValues:vm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","invite"],queryFn:()=>me.getSettings("invite")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(o?.data?.invite){const i=o?.data?.invite;Object.entries(i).forEach(([d,h])=>{typeof h=="number"?n.setValue(d,String(h)):n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"invite_force",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(F,{children:s("invite.invite_force.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"invite_commission",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("invite.invite_commission.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"invite_gen_limit",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("invite.invite_gen_limit.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"invite_never_expire",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(F,{children:s("invite.invite_never_expire.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_first_time_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(F,{children:s("invite.commission_first_time.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_auto_check_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(F,{children:s("invite.commission_auto_check.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_withdraw_limit",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"commission_withdraw_method",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_method.placeholder"),...i,value:Array.isArray(i.value)?i.value.join(","):"",onChange:d=>{const h=d.target.value.split(",").filter(Boolean);i.onChange(h),u(n.getValues())}})}),e.jsx(F,{children:s("invite.commission_withdraw_method.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"withdraw_close_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(F,{children:s("invite.withdraw_close.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),e.jsx(v,{control:n.control,name:"commission_distribution_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(F,{children:s("invite.commission_distribution.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:d=>{i.onChange(d),u(n.getValues())}})})]})}),n.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:n.control,name:"commission_distribution_l1",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l1")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const h=d.target.value?Number(d.target.value):0;i.onChange(h),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"commission_distribution_l2",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l2")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const h=d.target.value?Number(d.target.value):0;i.onChange(h),u(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"commission_distribution_l3",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l3")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const h=d.target.value?Number(d.target.value):0;i.onChange(h),u(n.getValues())}})}),e.jsx(P,{})]})})]}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function ym(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ke,{}),e.jsx(bm,{})]})}const Nm=Object.freeze(Object.defineProperty({__proto__:null,default:ym},Symbol.toStringTag,{value:"Module"})),_m=x.object({frontend_theme:x.string().nullable(),frontend_theme_sidebar:x.string().nullable(),frontend_theme_header:x.string().nullable(),frontend_theme_color:x.string().nullable(),frontend_background_url:x.string().url().nullable()}),wm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Cm(){const{data:s}=ne({queryKey:["settings","frontend"],queryFn:()=>me.getSettings("frontend")}),a=ye({resolver:_e(_m),defaultValues:wm,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([n,o])=>{a.setValue(n,o)})}},[s]);function t(l){me.saveSettings(l).then(({data:n})=>{n&&A.success("更新成功")})}return e.jsx(we,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(t),className:"space-y-8",children:[e.jsx(v,{control:a.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(v,{control:a.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(v,{control:a.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(f,{children:[e.jsx(j,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(b,{children:e.jsxs("select",{className:y(wt({variant:"outline"}),"w-[200px] appearance-none font-normal"),...l,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(pn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(P,{})]})}),e.jsx(v,{control:a.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(f,{children:[e.jsx(j,{children:"背景"}),e.jsx(b,{children:e.jsx(D,{placeholder:"请输入图片地址",...l})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(P,{})]})}),e.jsx(E,{type:"submit",children:"保存设置"})]})})}function Sm(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"个性化设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自定义系统界面外观,包括主题风格、布局、颜色方案、背景图等个性化选项。"})]}),e.jsx(ke,{}),e.jsx(Cm,{})]})}const km=Object.freeze(Object.defineProperty({__proto__:null,default:Sm},Symbol.toStringTag,{value:"Module"})),Tm=x.object({server_pull_interval:x.coerce.number().nullable(),server_push_interval:x.coerce.number().nullable(),server_token:x.string().nullable(),device_limit_mode:x.coerce.number().nullable()}),Dm={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Pm(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(Tm),defaultValues:Dm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","server"],queryFn:()=>me.getSettings("server")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:d=>{d.data&&A.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(o?.data.server){const d=o.data.server;Object.entries(d).forEach(([h,_])=>{n.setValue(h,_)}),l.current=d}},[o]);const c=m.useCallback(Se.debounce(async d=>{if(!Se.isEqual(d,l.current)){t(!0);try{await r(d),l.current=d}finally{t(!1)}}},1e3),[r]),u=m.useCallback(d=>{c(d)},[c]);m.useEffect(()=>{const d=n.watch(h=>{u(h)});return()=>d.unsubscribe()},[n.watch,u]);const i=()=>{const d=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let _="";for(let T=0;Te.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_token.title")}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(be,{children:e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:h=>{h.preventDefault(),i()},children:e.jsx(lc,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(de,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(F,{children:s("server.server_token.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;d.onChange(_)}})}),e.jsx(F,{children:s("server.server_pull_interval.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"server_push_interval",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;d.onChange(_)}})}),e.jsx(F,{children:s("server.server_push_interval.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(X,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx($,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(F,{children:s("server.device_limit_mode.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Em(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ke,{}),e.jsx(Pm,{})]})}const Rm=Object.freeze(Object.defineProperty({__proto__:null,default:Em},Symbol.toStringTag,{value:"Module"}));function Im({open:s,onOpenChange:a,result:t}){const l=!t.error;return e.jsx(pe,{open:s,onOpenChange:a,children:e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(ql,{className:"h-5 w-5 text-green-500"}):e.jsx(Hl,{className:"h-5 w-5 text-destructive"}),e.jsx(ge,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Le,{children:l?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(Nt,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const Lm=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function Vm(){const{t:s}=V("settings"),[a,t]=m.useState(null),[l,n]=m.useState(!1),o=m.useRef(null),[r,c]=m.useState(!1),u=ye({resolver:_e(Lm),defaultValues:{},mode:"onBlur"}),{data:i}=ne({queryKey:["settings","email"],queryFn:()=>me.getSettings("email")}),{data:d}=ne({queryKey:["emailTemplate"],queryFn:()=>me.getEmailTemplate()}),{mutateAsync:h}=gs({mutationFn:me.saveSettings,onSuccess:N=>{N.data&&A.success(s("common.autoSaved"))}}),{mutate:_,isPending:T}=gs({mutationFn:me.sendTestMail,onMutate:()=>{t(null),n(!1)},onSuccess:N=>{t(N.data),n(!0),N.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});m.useEffect(()=>{if(i?.data.email){const N=i.data.email;Object.entries(N).forEach(([g,k])=>{u.setValue(g,k)}),o.current=N}},[i]);const S=m.useCallback(Se.debounce(async N=>{if(!Se.isEqual(N,o.current)){c(!0);try{await h(N),o.current=N}finally{c(!1)}}},1e3),[h]),C=m.useCallback(N=>{S(N)},[S]);return m.useEffect(()=>{const N=u.watch(g=>{C(g)});return()=>N.unsubscribe()},[u.watch,C]),e.jsxs(e.Fragment,{children:[e.jsx(we,{...u,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"email_host",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_host.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_host.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_port",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_port.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...N,value:N.value||"",onChange:g=>{const k=g.target.value?Number(g.target.value):null;N.onChange(k)}})}),e.jsx(F,{children:s("email.email_port.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_encryption",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(X,{onValueChange:g=>{const k=g==="none"?"":g;N.onChange(k)},value:N.value===""||N.value===null||N.value===void 0?"none":N.value,children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:"请选择加密方式"})})}),e.jsxs(J,{children:[e.jsx($,{value:"none",children:s("email.email_encryption.none")}),e.jsx($,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx($,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(F,{children:s("email.email_encryption.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_username",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_username.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_username.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_password",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_password.title")}),e.jsx(b,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_password.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_from_address",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_from.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(F,{children:s("email.email_from.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"email_template",render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(X,{onValueChange:g=>{N.onChange(g),C(u.getValues())},value:N.value||void 0,children:[e.jsx(b,{children:e.jsx(Y,{className:"w-[200px]",children:e.jsx(Z,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(J,{children:d?.data?.map(g=>e.jsx($,{value:g,children:g},g))})]}),e.jsx(F,{children:s("email.email_template.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:u.control,name:"remind_mail_enable",render:({field:N})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(F,{children:s("email.remind_mail.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:N.value||!1,onCheckedChange:g=>{N.onChange(g),C(u.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(E,{onClick:()=>_(),loading:T,disabled:T,children:s(T?"email.test.sending":"email.test.title")})})]})}),r&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),a&&e.jsx(Im,{open:l,onOpenChange:n,result:a})]})}function Fm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ke,{}),e.jsx(Vm,{})]})}const Mm=Object.freeze(Object.defineProperty({__proto__:null,default:Fm},Symbol.toStringTag,{value:"Module"})),Om=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),zm={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function $m(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(Om),defaultValues:zm,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","telegram"],queryFn:()=>me.getSettings("telegram")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}}),{mutate:c,isPending:u}=gs({mutationFn:me.setTelegramWebhook,onSuccess:h=>{h.data&&A.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(o?.data.telegram){const h=o.data.telegram;Object.entries(h).forEach(([_,T])=>{n.setValue(_,T)}),l.current=h}},[o]);const i=m.useCallback(Se.debounce(async h=>{if(!Se.isEqual(h,l.current)){t(!0);try{await r(h),l.current=h}finally{t(!1)}}},1e3),[r]),d=m.useCallback(h=>{i(h)},[i]);return m.useEffect(()=>{const h=n.watch(_=>{d(_)});return()=>h.unsubscribe()},[n.watch,d]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.bot_token.description")}),e.jsx(P,{})]})}),n.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(E,{loading:u,disabled:u,onClick:()=>c(),children:s(u?"telegram.webhook.setting":"telegram.webhook.button")}),a&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(F,{children:s("telegram.webhook.description")}),e.jsx(P,{})]}),e.jsx(v,{control:n.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(F,{children:s("telegram.bot_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:h.value||!1,onCheckedChange:_=>{h.onChange(_),d(n.getValues())}})}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.discuss_link.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Am(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ke,{}),e.jsx($m,{})]})}const qm=Object.freeze(Object.defineProperty({__proto__:null,default:Am},Symbol.toStringTag,{value:"Module"})),Hm=x.object({windows_version:x.string().nullable(),windows_download_url:x.string().nullable(),macos_version:x.string().nullable(),macos_download_url:x.string().nullable(),android_version:x.string().nullable(),android_download_url:x.string().nullable()}),Um={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Km(){const{t:s}=V("settings"),[a,t]=m.useState(!1),l=m.useRef(null),n=ye({resolver:_e(Hm),defaultValues:Um,mode:"onBlur"}),{data:o}=ne({queryKey:["settings","app"],queryFn:()=>me.getSettings("app")}),{mutateAsync:r}=gs({mutationFn:me.saveSettings,onSuccess:i=>{i.data&&A.success(s("app.save_success"))}});m.useEffect(()=>{if(o?.data.app){const i=o.data.app;Object.entries(i).forEach(([d,h])=>{n.setValue(d,h)}),l.current=i}},[o]);const c=m.useCallback(Se.debounce(async i=>{if(!Se.isEqual(i,l.current)){t(!0);try{await r(i),l.current=i}finally{t(!1)}}},1e3),[r]),u=m.useCallback(i=>{c(i)},[c]);return m.useEffect(()=>{const i=n.watch(d=>{u(d)});return()=>i.unsubscribe()},[n.watch,u]),e.jsx(we,{...n,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:n.control,name:"windows_version",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.windows.version.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"windows_download_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.windows.download.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"macos_version",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.macos.version.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"macos_download_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.macos.download.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"android_version",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.android.version.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:n.control,name:"android_download_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(F,{children:s("app.android.download.description")}),e.jsx(P,{})]})}),a&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Bm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ke,{}),e.jsx(Km,{})]})}const Gm=Object.freeze(Object.defineProperty({__proto__:null,default:Bm},Symbol.toStringTag,{value:"Module"})),Wm=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),Wn={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function kr({refetch:s,dialogTrigger:a,type:t="add",defaultFormValues:l=Wn}){const{t:n}=V("payment"),[o,r]=m.useState(!1),[c,u]=m.useState(!1),[i,d]=m.useState([]),[h,_]=m.useState([]),T=Wm(n),S=ye({resolver:_e(T),defaultValues:l,mode:"onChange"}),C=S.watch("payment");m.useEffect(()=>{o&&(async()=>{const{data:k}=await Qs.getMethodList();d(k)})()},[o]),m.useEffect(()=>{if(!C||!o)return;(async()=>{const k={payment:C,...t==="edit"&&{id:Number(S.getValues("id"))}};Qs.getMethodForm(k).then(({data:R})=>{_(R);const p=R.reduce((w,I)=>(I.field_name&&(w[I.field_name]=I.value??""),w),{});S.setValue("config",p)})})()},[C,o,S,t]);const N=async g=>{u(!0);try{(await Qs.save(g)).data&&(A.success(n("form.messages.success")),S.reset(Wn),s(),r(!1))}finally{u(!1)}};return e.jsxs(pe,{open:o,onOpenChange:r,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"})," ",e.jsx("div",{children:n("form.add.button")})]})}),e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(ge,{children:n(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(we,{...S,children:e.jsxs("form",{onSubmit:S.handleSubmit(N),className:"space-y-4",children:[e.jsx(v,{control:S.control,name:"name",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:n("form.fields.name.placeholder"),...g})}),e.jsx(F,{children:n("form.fields.name.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:S.control,name:"icon",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.icon.label")}),e.jsx(b,{children:e.jsx(D,{...g,value:g.value||"",placeholder:n("form.fields.icon.placeholder")})}),e.jsx(F,{children:n("form.fields.icon.description")}),e.jsx(P,{})]})}),e.jsx(v,{control:S.control,name:"notify_domain",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.notify_domain.label")}),e.jsx(b,{children:e.jsx(D,{...g,value:g.value||"",placeholder:n("form.fields.notify_domain.placeholder")})}),e.jsx(F,{children:n("form.fields.notify_domain.description")}),e.jsx(P,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:S.control,name:"handling_fee_percent",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.handling_fee_percent.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...g,value:g.value||"",placeholder:n("form.fields.handling_fee_percent.placeholder")})}),e.jsx(P,{})]})}),e.jsx(v,{control:S.control,name:"handling_fee_fixed",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.handling_fee_fixed.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...g,value:g.value||"",placeholder:n("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(P,{})]})})]}),e.jsx(v,{control:S.control,name:"payment",render:({field:g})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.payment.label")}),e.jsxs(X,{onValueChange:g.onChange,defaultValue:g.value,children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:n("form.fields.payment.placeholder")})})}),e.jsx(J,{children:i.map(k=>e.jsx($,{value:k,children:k},k))})]}),e.jsx(F,{children:n("form.fields.payment.description")}),e.jsx(P,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(g=>e.jsx(v,{control:S.control,name:`config.${g.field_name}`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(j,{children:g.label}),e.jsx(b,{children:e.jsx(D,{...k,value:k.value||""})}),e.jsx(P,{})]})},g.field_name))}),e.jsxs(Re,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.buttons.cancel")})}),e.jsx(E,{type:"submit",disabled:c,children:n("form.buttons.submit")})]})]})})]})]})}function z({column:s,title:a,tooltip:t,className:l}){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(E,{variant:"ghost",size:"default",className:y("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",l),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:a}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(An,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(de,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(Xa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Za,{className:"h-4 w-4 text-foreground/70"}):e.jsx(rc,{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",l),children:[e.jsx("span",{children:a}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(xe,{children:[e.jsx(he,{children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(de,{children:t})]})})]})}const Cn=ic,Tr=oc,Ym=cc,Dr=m.forwardRef(({className:s,...a},t)=>e.jsx(Kl,{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),...a,ref:t}));Dr.displayName=Kl.displayName;const Ta=m.forwardRef(({className:s,...a},t)=>e.jsxs(Ym,{children:[e.jsx(Dr,{}),e.jsx(Bl,{ref:t,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),...a})]}));Ta.displayName=Bl.displayName;const Da=({className:s,...a})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...a});Da.displayName="AlertDialogHeader";const Pa=({className:s,...a})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});Pa.displayName="AlertDialogFooter";const Ea=m.forwardRef(({className:s,...a},t)=>e.jsx(Gl,{ref:t,className:y("text-lg font-semibold",s),...a}));Ea.displayName=Gl.displayName;const Ra=m.forwardRef(({className:s,...a},t)=>e.jsx(Wl,{ref:t,className:y("text-sm text-muted-foreground",s),...a}));Ra.displayName=Wl.displayName;const Ia=m.forwardRef(({className:s,...a},t)=>e.jsx(Yl,{ref:t,className:y(bt(),s),...a}));Ia.displayName=Yl.displayName;const La=m.forwardRef(({className:s,...a},t)=>e.jsx(Jl,{ref:t,className:y(bt({variant:"outline"}),"mt-2 sm:mt-0",s),...a}));La.displayName=Jl.displayName;function ns({onConfirm:s,children:a,title:t="确认操作",description:l="确定要执行此操作吗?",cancelText:n="取消",confirmText:o="确认",variant:r="default",className:c}){return e.jsxs(Cn,{children:[e.jsx(Tr,{asChild:!0,children:a}),e.jsxs(Ta,{className:y("sm:max-w-[425px]",c),children:[e.jsxs(Da,{children:[e.jsx(Ea,{children:t}),e.jsx(Ra,{children:l})]}),e.jsxs(Pa,{children:[e.jsx(La,{asChild:!0,children:e.jsx(E,{variant:"outline",children:n})}),e.jsx(Ia,{asChild:!0,children:e.jsx(E,{variant:r,onClick:s,children:o})})]})]})]})}const Pr=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"})}),Jm=({refetch:s,isSortMode:a=!1})=>{const{t}=V("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:a?"cursor-move":"opacity-0",children:e.jsx(Na,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.id")}),cell:({row:l})=>e.jsx(B,{variant:"outline",children:l.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.enable")}),cell:({row:l})=>e.jsx(ee,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:n}=await Qs.updateStatus({id:l.original.id});n||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.name")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:l})=>e.jsx(z,{column:l,title:t("table.columns.payment")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:l})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(z,{column:l,title:t("table.columns.notify_url")}),e.jsx(be,{delayDuration:100,children:e.jsxs(xe,{children:[e.jsx(he,{className:"ml-1",children:e.jsx(Pr,{className:"h-4 w-4"})}),e.jsx(de,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:l.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:l})=>e.jsx(z,{className:"justify-end",column:l,title:t("table.columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(kr,{refetch:s,dialogTrigger:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(ns,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:n}=await Qs.drop({id:l.original.id});n&&s()},children:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function Qm({table:s,refetch:a,saveOrder:t,isSortMode:l}){const{t:n}=V("payment"),o=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:n("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kr,{refetch:a}),e.jsx(D,{placeholder:n("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:"h-8 w-[250px]"}),o&&e.jsxs(E,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[n("table.toolbar.reset"),e.jsx(ds,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(E,{variant:l?"default":"outline",onClick:t,size:"sm",children:n(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Xm(){const[s,a]=m.useState([]),[t,l]=m.useState([]),[n,o]=m.useState(!1),[r,c]=m.useState([]),[u,i]=m.useState({"drag-handle":!1}),[d,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:_}=ne({queryKey:["paymentList"],queryFn:async()=>{const{data:g}=await Qs.getList();return c(g?.map(k=>({...k,enable:!!k.enable}))||[]),g}});m.useEffect(()=>{i({"drag-handle":n,actions:!n}),h({pageSize:n?99999:10,pageIndex:0})},[n]);const T=(g,k)=>{n&&(g.dataTransfer.setData("text/plain",k.toString()),g.currentTarget.classList.add("opacity-50"))},S=(g,k)=>{if(!n)return;g.preventDefault(),g.currentTarget.classList.remove("bg-muted");const R=parseInt(g.dataTransfer.getData("text/plain"));if(R===k)return;const p=[...r],[w]=p.splice(R,1);p.splice(k,0,w),c(p)},C=async()=>{n?Qs.sort({ids:r.map(g=>g.id)}).then(()=>{_(),o(!1),A.success("排序保存成功")}):o(!0)},N=Je({data:r,columns:Jm({refetch:_,isSortMode:n}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:d},onSortingChange:l,onColumnFiltersChange:a,onColumnVisibilityChange:i,getCoreRowModel:Qe(),getFilteredRowModel:js(),getPaginationRowModel:ls(),getSortedRowModel:vs(),initialState:{columnPinning:{right:["actions"]}},pageCount:n?1:void 0});return e.jsx(is,{table:N,toolbar:g=>e.jsx(Qm,{table:g,refetch:_,saveOrder:C,isSortMode:n}),draggable:n,onDragStart:T,onDragEnd:g=>g.currentTarget.classList.remove("opacity-50"),onDragOver:g=>{g.preventDefault(),g.currentTarget.classList.add("bg-muted")},onDragLeave:g=>g.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!n})}function Zm(){const{t:s}=V("payment");return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Xm,{})})]})]})}const eu=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"}));function su({pluginName:s,onClose:a,onSuccess:t}){const{t:l}=V("plugin"),[n,o]=m.useState(!0),[r,c]=m.useState(!1),[u,i]=m.useState(null),d=dc({config:mc(uc())}),h=ye({resolver:_e(d),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:C}=await Ps.getPluginConfig(s);i(C),h.reset({config:Object.fromEntries(Object.entries(C).map(([N,g])=>[N,g.value]))})}catch{A.error(l("messages.configLoadError"))}finally{o(!1)}})()},[s]);const _=async S=>{c(!0);try{await Ps.updatePluginConfig(s,S.config),A.success(l("messages.configSaveSuccess")),t()}catch{A.error(l("messages.configSaveError"))}finally{c(!1)}},T=(S,C)=>{switch(C.type){case"string":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsx(b,{children:e.jsx(D,{placeholder:C.placeholder,...N})}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);case"number":case"percentage":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:C.placeholder,...N,onChange:g=>{const k=Number(g.target.value);C.type==="percentage"?N.onChange(Math.min(100,Math.max(0,k))):N.onChange(k)},className:C.type==="percentage"?"pr-8":"",min:C.type==="percentage"?0:void 0,max:C.type==="percentage"?100:void 0,step:C.type==="percentage"?1:void 0}),C.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(xc,{className:"h-4 w-4 text-muted-foreground"})})]})}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);case"select":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsxs(X,{onValueChange:N.onChange,defaultValue:N.value,children:[e.jsx(b,{children:e.jsx(Y,{children:e.jsx(Z,{placeholder:C.placeholder})})}),e.jsx(J,{children:C.options?.map(g=>e.jsx($,{value:g.value,children:g.label},g.value))})]}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);case"boolean":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:C.label||C.description}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description})]}),e.jsx(b,{children:e.jsx(ee,{checked:N.value,onCheckedChange:N.onChange})})]})},S);case"text":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(f,{children:[e.jsx(j,{children:C.label||C.description}),e.jsx(b,{children:e.jsx(Ts,{placeholder:C.placeholder,...N})}),C.description&&C.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.description}),e.jsx(P,{})]})},S);default:return null}};return n?e.jsxs("div",{className:"space-y-4",children:[e.jsx(ce,{className:"h-4 w-[200px]"}),e.jsx(ce,{className:"h-10 w-full"}),e.jsx(ce,{className:"h-4 w-[200px]"}),e.jsx(ce,{className:"h-10 w-full"})]}):e.jsx(we,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(_),className:"space-y-4",children:[u&&Object.entries(u).map(([S,C])=>T(S,C)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(E,{type:"button",variant:"outline",onClick:a,disabled:r,children:l("config.cancel")}),e.jsx(E,{type:"submit",loading:r,disabled:r,children:l("config.save")})]})]})})}function tu(){const{t:s}=V("plugin"),[a,t]=m.useState(null),[l,n]=m.useState(!1),[o,r]=m.useState(null),[c,u]=m.useState(""),[i,d]=m.useState("all"),[h,_]=m.useState(!1),[T,S]=m.useState(!1),[C,N]=m.useState(!1),g=m.useRef(null),{data:k,isLoading:R,refetch:p}=ne({queryKey:["pluginList"],queryFn:async()=>{const{data:L}=await Ps.getPluginList();return L}});k&&[...new Set(k.map(L=>L.category||"other"))];const w=k?.filter(L=>{const U=L.name.toLowerCase().includes(c.toLowerCase())||L.description.toLowerCase().includes(c.toLowerCase())||L.code.toLowerCase().includes(c.toLowerCase()),ms=i==="all"||L.category===i;return U&&ms}),I=async L=>{t(L),Ps.installPlugin(L).then(()=>{A.success(s("messages.installSuccess")),p()}).catch(U=>{A.error(U.message||s("messages.installError"))}).finally(()=>{t(null)})},H=async L=>{t(L),Ps.uninstallPlugin(L).then(()=>{A.success(s("messages.uninstallSuccess")),p()}).catch(U=>{A.error(U.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},O=async(L,U)=>{t(L),(U?Ps.disablePlugin:Ps.enablePlugin)(L).then(()=>{A.success(s(U?"messages.disableSuccess":"messages.enableSuccess")),p()}).catch(De=>{A.error(De.message||s(U?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},K=L=>{k?.find(U=>U.code===L),r(L),n(!0)},oe=async L=>{if(!L.name.endsWith(".zip")){A.error(s("upload.error.format"));return}_(!0),Ps.uploadPlugin(L).then(()=>{A.success(s("messages.uploadSuccess")),S(!1),p()}).catch(U=>{A.error(U.message||s("messages.uploadError"))}).finally(()=>{_(!1),g.current&&(g.current.value="")})},W=L=>{L.preventDefault(),L.stopPropagation(),L.type==="dragenter"||L.type==="dragover"?N(!0):L.type==="dragleave"&&N(!1)},te=L=>{L.preventDefault(),L.stopPropagation(),N(!1),L.dataTransfer.files&&L.dataTransfer.files[0]&&oe(L.dataTransfer.files[0])},q=async L=>{t(L),Ps.deletePlugin(L).then(()=>{A.success(s("messages.deleteSuccess")),p()}).catch(U=>{A.error(U.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(xn,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(hn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:c,onChange:L=>u(L.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(E,{onClick:()=>S(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Bt,{defaultValue:"all",className:"w-full",children:[e.jsxs(Ct,{children:[e.jsx(Ee,{value:"all",children:s("tabs.all")}),e.jsx(Ee,{value:"installed",children:s("tabs.installed")}),e.jsx(Ee,{value:"available",children:s("tabs.available")})]}),e.jsx(We,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Ka,{}),e.jsx(Ka,{}),e.jsx(Ka,{})]}):w?.map(L=>e.jsx(Ua,{plugin:L,onInstall:I,onUninstall:H,onToggleEnable:O,onOpenConfig:K,onDelete:q,isLoading:a===L.name},L.name))})}),e.jsx(We,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(L=>L.is_installed).map(L=>e.jsx(Ua,{plugin:L,onInstall:I,onUninstall:H,onToggleEnable:O,onOpenConfig:K,onDelete:q,isLoading:a===L.name},L.name))})}),e.jsx(We,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(L=>!L.is_installed).map(L=>e.jsx(Ua,{plugin:L,onInstall:I,onUninstall:H,onToggleEnable:O,onOpenConfig:K,onDelete:q,isLoading:a===L.name},L.code))})})]})]}),e.jsx(pe,{open:l,onOpenChange:n,children:e.jsxs(ue,{className:"sm:max-w-lg",children:[e.jsxs(ve,{children:[e.jsxs(ge,{children:[k?.find(L=>L.code===o)?.name," ",s("config.title")]}),e.jsx(Le,{children:s("config.description")})]}),o&&e.jsx(su,{pluginName:o,onClose:()=>n(!1),onSuccess:()=>{n(!1),p()}})]})}),e.jsx(pe,{open:T,onOpenChange:S,children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:s("upload.title")}),e.jsx(Le,{children:s("upload.description")})]}),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",C&&"border-primary/50 bg-muted/50"),onDragEnter:W,onDragLeave:W,onDragOver:W,onDrop:te,children:[e.jsx("input",{type:"file",ref:g,className:"hidden",accept:".zip",onChange:L=>{const U=L.target.files?.[0];U&&oe(U)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(At,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>g.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function Ua({plugin:s,onInstall:a,onUninstall:t,onToggleEnable:l,onOpenConfig:n,onDelete:o,isLoading:r}){const{t:c}=V("plugin");return e.jsxs(Ye,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(ss,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_s,{children:s.name}),s.is_installed&&e.jsx(B,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?c("status.enabled"):c("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Xs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[c("author"),": ",s.author]})})]})})]}),e.jsx(ts,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(E,{variant:"outline",size:"sm",onClick:()=>n(s.code),disabled:!s.is_enabled||r,children:[e.jsx(hc,{className:"mr-2 h-4 w-4"}),c("button.config")]}),e.jsxs(E,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>l(s.code,s.is_enabled),disabled:r,children:[e.jsx(pc,{className:"mr-2 h-4 w-4"}),s.is_enabled?c("button.disable"):c("button.enable")]}),e.jsx(ns,{title:c("uninstall.title"),description:c("uninstall.description"),cancelText:c("common:cancel"),confirmText:c("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(E,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:r,children:[e.jsx(fs,{className:"mr-2 h-4 w-4"}),c("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{onClick:()=>a(s.code),disabled:r,loading:r,children:c("button.install")}),e.jsx(ns,{title:c("delete.title"),description:c("delete.description"),cancelText:c("common:cancel"),confirmText:c("delete.button"),variant:"destructive",onConfirm:()=>o(s.code),children:e.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:r,children:e.jsx(fs,{className:"h-4 w-4"})})})]})})})]})}function Ka(){return e.jsxs(Ye,{children:[e.jsxs(ss,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-6 w-[200px]"}),e.jsx(ce,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ce,{className:"h-5 w-[120px]"}),e.jsx(ce,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(ce,{className:"h-4 w-[300px]"}),e.jsx(ce,{className:"h-4 w-[150px]"})]})]}),e.jsx(ts,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(ce,{className:"h-9 w-[100px]"}),e.jsx(ce,{className:"h-9 w-[100px]"}),e.jsx(ce,{className:"h-8 w-8"})]})})]})}const au=Object.freeze(Object.defineProperty({__proto__:null,default:tu},Symbol.toStringTag,{value:"Module"})),nu=(s,a)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(D,{placeholder:s.placeholder,...a});break;case"textarea":t=e.jsx(Ts,{placeholder:s.placeholder,...a});break;case"select":t=e.jsx("select",{className:y(bt({variant:"outline"}),"w-full appearance-none font-normal"),...a,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:t=null;break}return t};function lu({themeKey:s,themeInfo:a}){const{t}=V("theme"),[l,n]=m.useState(!1),[o,r]=m.useState(!1),[c,u]=m.useState(!1),i=ye({defaultValues:a.configs.reduce((_,T)=>(_[T.field_name]="",_),{})}),d=async()=>{r(!0),Mt.getConfig(s).then(({data:_})=>{Object.entries(_).forEach(([T,S])=>{i.setValue(T,S)})}).finally(()=>{r(!1)})},h=async _=>{u(!0),Mt.updateConfig(s,_).then(()=>{A.success(t("config.success")),n(!1)}).finally(()=>{u(!1)})};return e.jsxs(pe,{open:l,onOpenChange:_=>{n(_),_?d():i.reset()},children:[e.jsx(rs,{asChild:!0,children:e.jsx(E,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(ue,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:t("config.title",{name:a.name})}),e.jsx(Le,{children:t("config.description")})]}),o?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(gn,{className:"h-6 w-6 animate-spin"})}):e.jsx(we,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(h),className:"space-y-4",children:[a.configs.map(_=>e.jsx(v,{control:i.control,name:_.field_name,render:({field:T})=>e.jsxs(f,{children:[e.jsx(j,{children:_.label}),e.jsx(b,{children:nu(_,T)}),e.jsx(P,{})]})},_.field_name)),e.jsxs(Re,{className:"mt-6 gap-2",children:[e.jsx(E,{type:"button",variant:"secondary",onClick:()=>n(!1),children:t("config.cancel")}),e.jsx(E,{type:"submit",loading:c,children:t("config.save")})]})]})})]})]})}function ru(){const{t:s}=V("theme"),[a,t]=m.useState(null),[l,n]=m.useState(!1),[o,r]=m.useState(!1),[c,u]=m.useState(!1),[i,d]=m.useState(null),h=m.useRef(null),[_,T]=m.useState(0),{data:S,isLoading:C,refetch:N}=ne({queryKey:["themeList"],queryFn:async()=>{const{data:O}=await Mt.getList();return O}}),g=async O=>{t(O),me.updateSystemConfig({frontend_theme:O}).then(()=>{A.success("主题切换成功"),N()}).finally(()=>{t(null)})},k=async O=>{if(!O.name.endsWith(".zip")){A.error(s("upload.error.format"));return}n(!0),Mt.upload(O).then(()=>{A.success("主题上传成功"),r(!1),N()}).finally(()=>{n(!1),h.current&&(h.current.value="")})},R=O=>{O.preventDefault(),O.stopPropagation(),O.type==="dragenter"||O.type==="dragover"?u(!0):O.type==="dragleave"&&u(!1)},p=O=>{O.preventDefault(),O.stopPropagation(),u(!1),O.dataTransfer.files&&O.dataTransfer.files[0]&&k(O.dataTransfer.files[0])},w=()=>{i&&T(O=>O===0?i.images.length-1:O-1)},I=()=>{i&&T(O=>O===i.images.length-1?0:O+1)},H=(O,K)=>{T(0),d({name:O,images:K})};return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(E,{onClick:()=>r(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Yn,{}),e.jsx(Yn,{})]}):S?.themes&&Object.entries(S.themes).map(([O,K])=>e.jsx(Ye,{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(ns,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(O===S?.active){A.error(s("card.delete.error.active"));return}t(O),Mt.drop(O).then(()=>{A.success("主题删除成功"),N()}).finally(()=>{t(null)})},children:e.jsx(E,{disabled:a===O,loading:a===O,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(fs,{className:"h-4 w-4"})})})}),e.jsxs(ss,{children:[e.jsx(_s,{children:K.name}),e.jsx(Xs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:K.description}),K.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:K.version})})]})})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[K.images&&Array.isArray(K.images)&&K.images.length>0&&e.jsx(E,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>H(K.name,K.images),children:e.jsx(gc,{className:"h-4 w-4"})}),e.jsx(lu,{themeKey:O,themeInfo:K}),e.jsx(E,{onClick:()=>g(O),disabled:a===O||O===S.active,loading:a===O,variant:O===S.active?"secondary":"default",children:O===S.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},O))}),e.jsx(pe,{open:o,onOpenChange:r,children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:s("upload.title")}),e.jsx(Le,{children:s("upload.description")})]}),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",c&&"border-primary/50 bg-muted/50"),onDragEnter:R,onDragLeave:R,onDragOver:R,onDrop:p,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:O=>{const K=O.target.files?.[0];K&&k(K)}}),l?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(At,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(pe,{open:!!i,onOpenChange:O=>{O||(d(null),T(0))},children:e.jsxs(ue,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(ge,{children:[i?.name," ",s("preview.title")]}),e.jsx(Le,{className:"text-center",children:i&&s("preview.imageCount",{current:_+1,total:i.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:i?.images[_]&&e.jsx("img",{src:i.images[_],alt:`${i.name} 预览图 ${_+1}`,className:"h-full w-full object-contain"})}),i&&i.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(E,{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:w,children:e.jsx(fc,{className:"h-4 w-4"})}),e.jsx(E,{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:I,children:e.jsx(jc,{className:"h-4 w-4"})})]})]}),i&&i.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:i.images.map((O,K)=>e.jsx("button",{onClick:()=>T(K),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",_===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:O,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function Yn(){return e.jsxs(Ye,{children:[e.jsxs(ss,{children:[e.jsx(ce,{className:"h-6 w-[200px]"}),e.jsx(ce,{className:"h-4 w-[300px]"})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[e.jsx(ce,{className:"h-10 w-[100px]"}),e.jsx(ce,{className:"h-10 w-[100px]"})]})]})}const iu=Object.freeze(Object.defineProperty({__proto__:null,default:ru},Symbol.toStringTag,{value:"Module"})),Sn=m.forwardRef(({className:s,value:a,onChange:t,...l},n)=>{const[o,r]=m.useState("");m.useEffect(()=>{if(o.includes(",")){const u=new Set([...a,...o.split(",").map(i=>i.trim())]);t(Array.from(u)),r("")}},[o,t,a]);const c=()=>{if(o){const u=new Set([...a,o]);t(Array.from(u)),r("")}};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:[a.map(u=>e.jsxs(B,{variant:"secondary",children:[u,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(a.filter(i=>i!==u))},children:e.jsx(an,{className:"w-3"})})]},u)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:o,onChange:u=>r(u.target.value),onKeyDown:u=>{u.key==="Enter"||u.key===","?(u.preventDefault(),c()):u.key==="Backspace"&&o.length===0&&a.length>0&&(u.preventDefault(),t(a.slice(0,-1)))},...l,ref:n})]})});Sn.displayName="InputTags";const ou=x.object({id:x.number().nullable(),title:x.string().min(1).max(250),content:x.string().min(1),show:x.boolean(),tags:x.array(x.string()),img_url:x.string().nullable()}),cu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Er({refetch:s,dialogTrigger:a,type:t="add",defaultFormValues:l=cu}){const{t:n}=V("notice"),[o,r]=m.useState(!1),c=ye({resolver:_e(ou),defaultValues:l,mode:"onChange",shouldFocusError:!0}),u=new fn({html:!0});return e.jsx(we,{...c,children:e.jsxs(pe,{onOpenChange:r,open:o,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"})," ",e.jsx("div",{children:n("form.add.button")})]})}),e.jsxs(ue,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:n(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Le,{})]}),e.jsx(v,{control:c.control,name:"title",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:n("form.fields.title.placeholder"),...i})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"content",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.content.label")}),e.jsx(b,{children:e.jsx(jn,{style:{height:"500px"},value:i.value,renderHTML:d=>u.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"img_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:n("form.fields.img_url.placeholder"),...i,value:i.value||""})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"show",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"tags",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.fields.tags.label")}),e.jsx(b,{children:e.jsx(Sn,{value:i.value,onChange:i.onChange,placeholder:n("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(P,{})]})}),e.jsxs(Re,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.buttons.cancel")})}),e.jsx(E,{type:"submit",onClick:i=>{i.preventDefault(),c.handleSubmit(async d=>{Ht.save(d).then(({data:h})=>{h&&(A.success(n("form.buttons.success")),s(),r(!1))})})()},children:n("form.buttons.submit")})]})]})]})})}function du({table:s,refetch:a,saveOrder:t,isSortMode:l}){const{t:n}=V("notice"),o=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:[!l&&e.jsx(Er,{refetch:a}),!l&&e.jsx(D,{placeholder:n("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:r=>s.getColumn("title")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),o&&!l&&e.jsxs(E,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[n("table.toolbar.reset"),e.jsx(ds,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(E,{variant:l?"default":"outline",onClick:t,className:"h-8",size:"sm",children:n(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const mu=s=>{const{t:a}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(vc,{className:"h-4 w-4 cursor-move text-muted-foreground"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:a("table.columns.id")}),cell:({row:t})=>e.jsx(B,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:a("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:l}=await Ht.updateStatus(t.original.id);l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(z,{column:t,title:a("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:a("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Er,{refetch:s,dialogTrigger:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("table.actions.edit")})]}),type:"edit",defaultFormValues:t.original}),e.jsx(ns,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{Ht.drop(t.original.id).then(()=>{A.success(a("table.actions.delete.success")),s()})},children:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:a("table.actions.delete.title")})]})})]}),size:100}]};function uu(){const[s,a]=m.useState({}),[t,l]=m.useState({}),[n,o]=m.useState([]),[r,c]=m.useState([]),[u,i]=m.useState(!1),[d,h]=m.useState({}),[_,T]=m.useState({pageSize:50,pageIndex:0}),[S,C]=m.useState([]),{refetch:N}=ne({queryKey:["notices"],queryFn:async()=>{const{data:w}=await Ht.getList();return C(w),w}});m.useEffect(()=>{l({"drag-handle":u,content:!u,created_at:!u,actions:!u}),T({pageSize:u?99999:50,pageIndex:0})},[u]);const g=(w,I)=>{u&&(w.dataTransfer.setData("text/plain",I.toString()),w.currentTarget.classList.add("opacity-50"))},k=(w,I)=>{if(!u)return;w.preventDefault(),w.currentTarget.classList.remove("bg-muted");const H=parseInt(w.dataTransfer.getData("text/plain"));if(H===I)return;const O=[...S],[K]=O.splice(H,1);O.splice(I,0,K),C(O)},R=async()=>{if(!u){i(!0);return}Ht.sort(S.map(w=>w.id)).then(()=>{A.success("排序保存成功"),i(!1),N()}).finally(()=>{i(!1)})},p=Je({data:S??[],columns:mu(N),state:{sorting:r,columnVisibility:t,rowSelection:s,columnFilters:n,columnSizing:d,pagination:_},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:c,onColumnFiltersChange:o,onColumnVisibilityChange:l,onColumnSizingChange:h,onPaginationChange:T,getCoreRowModel:Qe(),getFilteredRowModel:js(),getPaginationRowModel:ls(),getSortedRowModel:vs(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Vs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(is,{table:p,toolbar:w=>e.jsx(du,{table:w,refetch:N,saveOrder:R,isSortMode:u}),draggable:u,onDragStart:g,onDragEnd:w=>w.currentTarget.classList.remove("opacity-50"),onDragOver:w=>{w.preventDefault(),w.currentTarget.classList.add("bg-muted")},onDragLeave:w=>w.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!u})})}function xu(){const{t:s}=V("notice");return e.jsxs(Ve,{children:[e.jsxs(Fe,{className:"flex items-center justify-between",children:[e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(uu,{})})]})]})}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:xu},Symbol.toStringTag,{value:"Module"})),pu=x.object({id:x.number().nullable(),language:x.string().max(250),category:x.string().max(250),title:x.string().min(1).max(250),body:x.string().min(1),show:x.boolean()}),gu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Rr({refreshData:s,dialogTrigger:a,type:t="add",defaultFormValues:l=gu}){const{t:n}=V("knowledge"),[o,r]=m.useState(!1),c=ye({resolver:_e(pu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),u=new fn({html:!0});return m.useEffect(()=>{o&&l.id&&vt.getInfo(l.id).then(({data:i})=>{c.reset(i)})},[l.id,c,o]),e.jsxs(pe,{onOpenChange:r,open:o,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"})," ",e.jsx("div",{children:n("form.add")})]})}),e.jsxs(ue,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:n(t==="add"?"form.add":"form.edit")}),e.jsx(Le,{})]}),e.jsxs(we,{...c,children:[e.jsx(v,{control:c.control,name:"title",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:n("form.titlePlaceholder"),...i})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"category",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:n("form.categoryPlaceholder"),...i})})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"language",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.language")}),e.jsx(b,{children:e.jsxs(X,{value:i.value,onValueChange:i.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:n("form.languagePlaceholder")})}),e.jsx(J,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx($,{value:d.value,className:"cursor-pointer",children:n(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(v,{control:c.control,name:"body",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.content")}),e.jsx(b,{children:e.jsx(jn,{style:{height:"500px"},value:i.value,renderHTML:d=>u.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(P,{})]})}),e.jsx(v,{control:c.control,name:"show",render:({field:i})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(P,{})]})}),e.jsxs(Re,{children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.cancel")})}),e.jsx(E,{type:"submit",onClick:()=>{c.handleSubmit(i=>{vt.save(i).then(({data:d})=>{d&&(c.reset(),A.success(n("messages.operationSuccess")),r(!1),s())})})()},children:n("form.submit")})]})]})]})]})}function fu({column:s,title:a,options:t}){const l=s?.getFacetedUniqueValues(),n=new Set(s?.getFilterValue());return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(_a,{className:"mr-2 h-4 w-4"}),a,n?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(B,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:n.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:n.size>2?e.jsxs(B,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[n.size," selected"]}):t.filter(o=>n.has(o.value)).map(o=>e.jsx(B,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(bs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Us,{children:[e.jsx(nt,{placeholder:a}),e.jsxs(Ks,{children:[e.jsx(lt,{children:"No results found."}),e.jsx(as,{children:t.map(o=>{const r=n.has(o.value);return e.jsxs($e,{onSelect:()=>{r?n.delete(o.value):n.add(o.value);const c=Array.from(n);s?.setFilterValue(c.length?c:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",r?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(et,{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}),l?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(o.value)})]},o.value)})}),n.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(St,{}),e.jsx(as,{children:e.jsx($e,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function ju({table:s,refetch:a,saveOrder:t,isSortMode:l}){const n=s.getState().columnFilters.length>0,{t:o}=V("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:o("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{refreshData:a}),e.jsx(D,{placeholder:o("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:r=>s.getColumn("title")?.setFilterValue(r.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(fu,{column:s.getColumn("category"),title:o("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(r=>r.getValue("category")))).map(r=>({label:r,value:r}))}),n&&e.jsxs(E,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[o("toolbar.reset"),e.jsx(ds,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(E,{variant:l?"default":"outline",onClick:t,size:"sm",children:o(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const vu=({refetch:s,isSortMode:a=!1})=>{const{t}=V("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:a?"cursor-move":"opacity-0",children:e.jsx(Na,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.id")}),cell:({row:l})=>e.jsx(B,{variant:"outline",className:"justify-center",children:l.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{vt.updateStatus({id:l.original.id}).then(({data:n})=>{n||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.title")}),cell:({row:l})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:l.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:l})=>e.jsx(z,{column:l,title:t("columns.category")}),cell:({row:l})=>e.jsx(B,{variant:"secondary",className:"max-w-[180px] truncate",children:l.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:l})=>e.jsx(z,{className:"justify-end",column:l,title:t("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Rr,{refreshData:s,dialogTrigger:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(ns,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{vt.drop({id:l.original.id}).then(({data:n})=>{n&&(A.success(t("messages.operationSuccess")),s())})},children:e.jsxs(E,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function bu(){const[s,a]=m.useState([]),[t,l]=m.useState([]),[n,o]=m.useState(!1),[r,c]=m.useState([]),[u,i]=m.useState({"drag-handle":!1}),[d,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:_,isLoading:T,data:S}=ne({queryKey:["knowledge"],queryFn:async()=>{const{data:R}=await vt.getList();return c(R||[]),R}});m.useEffect(()=>{i({"drag-handle":n,actions:!n}),h({pageSize:n?99999:10,pageIndex:0})},[n]);const C=(R,p)=>{n&&(R.dataTransfer.setData("text/plain",p.toString()),R.currentTarget.classList.add("opacity-50"))},N=(R,p)=>{if(!n)return;R.preventDefault(),R.currentTarget.classList.remove("bg-muted");const w=parseInt(R.dataTransfer.getData("text/plain"));if(w===p)return;const I=[...r],[H]=I.splice(w,1);I.splice(p,0,H),c(I)},g=async()=>{n?vt.sort({ids:r.map(R=>R.id)}).then(()=>{_(),o(!1),A.success("排序保存成功")}):o(!0)},k=Je({data:r,columns:vu({refetch:_,isSortMode:n}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:d},onSortingChange:l,onColumnFiltersChange:a,onColumnVisibilityChange:i,onPaginationChange:h,getCoreRowModel:Qe(),getFilteredRowModel:js(),getPaginationRowModel:ls(),getSortedRowModel:vs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(is,{table:k,toolbar:R=>e.jsx(ju,{table:R,refetch:_,saveOrder:g,isSortMode:n}),draggable:n,onDragStart:C,onDragEnd:R=>R.currentTarget.classList.remove("opacity-50"),onDragOver:R=>{R.preventDefault(),R.currentTarget.classList.add("bg-muted")},onDragLeave:R=>R.currentTarget.classList.remove("bg-muted"),onDrop:N,showPagination:!n})}function yu(){const{t:s}=V("knowledge");return e.jsxs(Ve,{children:[e.jsxs(Fe,{children:[e.jsx(Xe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ue,{}),e.jsx(Ke,{})]})]}),e.jsxs(Ae,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(bu,{})})]})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:yu},Symbol.toStringTag,{value:"Module"}));function _u(s,a){const[t,l]=m.useState(s);return m.useEffect(()=>{const n=setTimeout(()=>l(s),a);return()=>{clearTimeout(n)}},[s,a]),t}function Ba(s,a){if(s.length===0)return{};if(!a)return{"":s};const t={};return s.forEach(l=>{const n=l[a]||"";t[n]||(t[n]=[]),t[n].push(l)}),t}function wu(s,a){const t=JSON.parse(JSON.stringify(s));for(const[l,n]of Object.entries(t))t[l]=n.filter(o=>!a.find(r=>r.value===o.value));return t}function Cu(s,a){for(const[,t]of Object.entries(s))if(t.some(l=>a.find(n=>n.value===l.value)))return!0;return!1}const Ir=m.forwardRef(({className:s,...a},t)=>bc(n=>n.filtered.count===0)?e.jsx("div",{ref:t,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...a}):null);Ir.displayName="CommandEmpty";const _t=m.forwardRef(({value:s,onChange:a,placeholder:t,defaultOptions:l=[],options:n,delay:o,onSearch:r,loadingIndicator:c,emptyIndicator:u,maxSelected:i=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:h,disabled:_,groupBy:T,className:S,badgeClassName:C,selectFirstItem:N=!0,creatable:g=!1,triggerSearchOnFocus:k=!1,commandProps:R,inputProps:p,hideClearAllButton:w=!1},I)=>{const H=m.useRef(null),[O,K]=m.useState(!1),oe=m.useRef(!1),[W,te]=m.useState(!1),[q,L]=m.useState(s||[]),[U,ms]=m.useState(Ba(l,T)),[De,le]=m.useState(""),ys=_u(De,o||500);m.useImperativeHandle(I,()=>({selectedValue:[...q],input:H.current,focus:()=>H.current?.focus()}),[q]);const Fs=m.useCallback(se=>{const ie=q.filter(Me=>Me.value!==se.value);L(ie),a?.(ie)},[a,q]),Fa=m.useCallback(se=>{const ie=H.current;ie&&((se.key==="Delete"||se.key==="Backspace")&&ie.value===""&&q.length>0&&(q[q.length-1].fixed||Fs(q[q.length-1])),se.key==="Escape"&&ie.blur())},[Fs,q]);m.useEffect(()=>{s&&L(s)},[s]),m.useEffect(()=>{if(!n||r)return;const se=Ba(n||[],T);JSON.stringify(se)!==JSON.stringify(U)&&ms(se)},[l,n,T,r,U]),m.useEffect(()=>{const se=async()=>{te(!0);const Me=await r?.(ys);ms(Ba(Me||[],T)),te(!1)};(async()=>{!r||!O||(k&&await se(),ys&&await se())})()},[ys,T,O,k]);const Gt=()=>{if(!g||Cu(U,[{value:De,label:De}])||q.find(ie=>ie.value===De))return;const se=e.jsx($e,{value:De,className:"cursor-pointer",onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onSelect:ie=>{if(q.length>=i){d?.(q.length);return}le("");const Me=[...q,{value:ie,label:ie}];L(Me),a?.(Me)},children:`Create "${De}"`});if(!r&&De.length>0||r&&ys.length>0&&!W)return se},it=m.useCallback(()=>{if(u)return r&&!g&&Object.keys(U).length===0?e.jsx($e,{value:"-",disabled:!0,children:u}):e.jsx(Ir,{children:u})},[g,u,r,U]),Ma=m.useMemo(()=>wu(U,q),[U,q]),Wt=m.useCallback(()=>{if(R?.filter)return R.filter;if(g)return(se,ie)=>se.toLowerCase().includes(ie.toLowerCase())?1:-1},[g,R?.filter]),Oa=m.useCallback(()=>{const se=q.filter(ie=>ie.fixed);L(se),a?.(se)},[a,q]);return e.jsxs(Us,{...R,onKeyDown:se=>{Fa(se),R?.onKeyDown?.(se)},className:y("h-auto overflow-visible bg-transparent",R?.className),shouldFilter:R?.shouldFilter!==void 0?R.shouldFilter:!r,filter:Wt(),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":q.length!==0,"cursor-text":!_&&q.length!==0},S),onClick:()=>{_||H.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[q.map(se=>e.jsxs(B,{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",C),"data-fixed":se.fixed,"data-disabled":_||void 0,children:[se.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",(_||se.fixed)&&"hidden"),onKeyDown:ie=>{ie.key==="Enter"&&Fs(se)},onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:()=>Fs(se),children:e.jsx(an,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},se.value)),e.jsx(He.Input,{...p,ref:H,value:De,disabled:_,onValueChange:se=>{le(se),p?.onValueChange?.(se)},onBlur:se=>{oe.current===!1&&K(!1),p?.onBlur?.(se)},onFocus:se=>{K(!0),k&&r?.(ys),p?.onFocus?.(se)},placeholder:h&&q.length!==0?"":t,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":q.length===0,"ml-1":q.length!==0},p?.className)}),e.jsx("button",{type:"button",onClick:Oa,className:y((w||_||q.length<1||q.filter(se=>se.fixed).length===q.length)&&"hidden"),children:e.jsx(an,{})})]})}),e.jsx("div",{className:"relative",children:O&&e.jsx(Ks,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{oe.current=!1},onMouseEnter:()=>{oe.current=!0},onMouseUp:()=>{H.current?.focus()},children:W?e.jsx(e.Fragment,{children:c}):e.jsxs(e.Fragment,{children:[it(),Gt(),!N&&e.jsx($e,{value:"-",className:"hidden"}),Object.entries(Ma).map(([se,ie])=>e.jsx(as,{heading:se,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ie.map(Me=>e.jsx($e,{value:Me.value,disabled:Me.disable,onMouseDown:Ms=>{Ms.preventDefault(),Ms.stopPropagation()},onSelect:()=>{if(q.length>=i){d?.(q.length);return}le("");const Ms=[...q,Me];L(Ms),a?.(Ms)},className:y("cursor-pointer",Me.disable&&"cursor-default text-muted-foreground"),children:Me.label},Me.value))})},se))]})})})]})});_t.displayName="MultipleSelector";const Su=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function Va({refetch:s,dialogTrigger:a,defaultValues:t={name:""},type:l="add"}){const{t:n}=V("group"),o=ye({resolver:_e(Su(n)),defaultValues:t,mode:"onChange"}),[r,c]=m.useState(!1),[u,i]=m.useState(!1),d=async h=>{i(!0),at.save(h).then(()=>{A.success(n(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),o.reset(),c(!1)}).finally(()=>{i(!1)})};return e.jsxs(pe,{open:r,onOpenChange:c,children:[e.jsx(rs,{asChild:!0,children:a||e.jsxs(E,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ze,{icon:"ion:add"}),e.jsx("span",{children:n("form.add")})]})}),e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(ge,{children:n(l==="edit"?"form.edit":"form.create")}),e.jsx(Le,{children:n(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(we,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(d),className:"space-y-4",children:[e.jsx(v,{control:o.control,name:"name",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{children:n("form.name")}),e.jsx(b,{children:e.jsx(D,{placeholder:n("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(F,{children:n("form.nameDescription")}),e.jsx(P,{})]})}),e.jsxs(Re,{className:"gap-2",children:[e.jsx(qs,{asChild:!0,children:e.jsx(E,{type:"button",variant:"outline",children:n("form.cancel")})}),e.jsxs(E,{type:"submit",disabled:u||!o.formState.isValid,children:[u&&e.jsx(gn,{className:"mr-2 h-4 w-4 animate-spin"}),n(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Lr=m.createContext(void 0);function ku({children:s,refetch:a}){const[t,l]=m.useState(!1),[n,o]=m.useState(null),[r,c]=m.useState(re.Shadowsocks);return e.jsx(Lr.Provider,{value:{isOpen:t,setIsOpen:l,editingServer:n,setEditingServer:o,serverType:r,setServerType:c,refetch:a},children:s})}function Vr(){const s=m.useContext(Lr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Ga({dialogTrigger:s,value:a,setValue:t,templateType:l}){const{t:n}=V("server");m.useEffect(()=>{console.log(a)},[a]);const[o,r]=m.useState(!1),[c,u]=m.useState(()=>{if(!a||Object.keys(a).length===0)return"";try{return JSON.stringify(a,null,2)}catch{return""}}),[i,d]=m.useState(null),h=g=>{if(!g)return null;try{const k=JSON.parse(g);return typeof k!="object"||k===null?n("network_settings.validation.must_be_object"):null}catch{return n("network_settings.validation.invalid_json")}},_={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},T=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},S=()=>{const g=h(c||"");if(g){A.error(g);return}try{if(!c){t(null),r(!1);return}t(JSON.parse(c)),r(!1)}catch{A.error(n("network_settings.errors.save_failed"))}},C=g=>{u(g),d(h(g))},N=g=>{const k=_[g];if(k){const R=JSON.stringify(k.content,null,2);u(R),d(null)}};return m.useEffect(()=>{o&&console.log(a)},[o,a]),m.useEffect(()=>{o&&a&&Object.keys(a).length>0&&u(JSON.stringify(a,null,2))},[o,a]),e.jsxs(pe,{open:o,onOpenChange:g=>{!g&&o&&S(),r(g)},children:[e.jsx(rs,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:n("network_settings.edit_protocol")})}),e.jsxs(ue,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(ge,{children:n("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[T().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:T().map(g=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>N(g),children:n("network_settings.use_template",{template:_[g].label})},g))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ts,{className:`min-h-[200px] font-mono text-sm ${i?"border-red-500 focus-visible:ring-red-500":""}`,value:c,placeholder:T().length>0?n("network_settings.json_config_placeholder_with_template"):n("network_settings.json_config_placeholder"),onChange:g=>C(g.target.value)}),i&&e.jsx("p",{className:"text-sm text-red-500",children:i})]})]}),e.jsxs(Re,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:n("common.cancel")}),e.jsx(G,{onClick:S,disabled:!!i,children:n("common.confirm")})]})]})]})}function qh(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 Tu={},Du=Object.freeze(Object.defineProperty({__proto__:null,default:Tu},Symbol.toStringTag,{value:"Module"})),Hh=Lc(Du),Jn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Pu=()=>{try{const s=yc.box.keyPair(),a=Jn(qn.encodeBase64(s.secretKey)),t=Jn(qn.encodeBase64(s.publicKey));return{privateKey:a,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Eu=()=>{try{return Pu()}catch(s){throw console.error("Error generating key pair:",s),s}},Ru=s=>{const a=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(a),Array.from(a).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},Iu=()=>{const s=Math.floor(Math.random()*8)*2+2;return Ru(s)},Lu=x.object({cipher:x.string().default("aes-128-gcm"),plugin:x.string().optional().default(""),plugin_opts:x.string().optional().default(""),client_fingerprint:x.string().optional().default("chrome")}),Vu=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),Fu=x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),Mu=x.object({version:x.coerce.number().default(2),alpn:x.string().default("h2"),obfs:x.object({open:x.coerce.boolean().default(!1),type:x.string().default("salamander"),password:x.string().default("")}).default({}),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),bandwidth:x.object({up:x.string().default(""),down:x.string().default("")}).default({}),hop_interval:x.number().optional(),port_range:x.string().optional()}),Ou=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),reality_settings:x.object({server_port:x.coerce.number().default(443),server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),public_key:x.string().default(""),private_key:x.string().default(""),short_id:x.string().default("")}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({}),flow:x.string().default("")}),zu=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),$u=x.object({}),Au=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),qu=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),Hu=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),Uu=x.object({padding_scheme:x.array(x.string()).optional().default([]),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),Te={shadowsocks:{schema:Lu,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"],plugins:[{value:"none",label:"None"},{value:"obfs",label:"Simple Obfs"},{value:"v2ray-plugin",label:"V2Ray Plugin"}],clientFingerprints:[{value:"chrome",label:"Chrome"},{value:"firefox",label:"Firefox"},{value:"safari",label:"Safari"},{value:"ios",label:"iOS"}]},vmess:{schema:Vu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Fu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Mu,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Ou,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:zu,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:$u},naive:{schema:qu},http:{schema:Au},mieru:{schema:Hu,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:Uu,defaultPaddingScheme:["stop=8","0=30-30","1=100-400","2=400-500,c,500-1000,c,500-1000,c,500-1000,c,500-1000","3=9-9,500-1000","4=500-1000","5=500-1000","6=500-1000","7=500-1000"]}},Ku=({serverType:s,value:a,onChange:t})=>{const{t:l}=V("server"),n=s?Te[s]:null,o=n?.schema||x.record(x.any()),r=s?o.parse({}):{},c=ye({resolver:_e(o),defaultValues:r,mode:"onChange"});if(m.useEffect(()=>{if(!a||Object.keys(a).length===0){if(s){const p=o.parse({});c.reset(p)}}else c.reset(a)},[s,a,t,c,o]),m.useEffect(()=>{const p=c.watch(w=>{t(w)});return()=>p.unsubscribe()},[c,t]),!s||!n)return null;const R={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"cipher",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.shadowsocks.ciphers.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})}),e.jsx(v,{control:c.control,name:"plugin",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.plugin.label","插件")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:w=>p.onChange(w==="none"?"":w),value:p.value===""?"none":p.value||"none",children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.plugin.placeholder","选择插件")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.shadowsocks.plugins.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})}),e.jsx(F,{children:p.value&&p.value!=="none"&&p.value!==""&&e.jsxs(e.Fragment,{children:[p.value==="obfs"&&l("dynamic_form.shadowsocks.plugin.obfs_hint","提示:配置格式如 obfs=http;obfs-host=www.bing.com;path=/"),p.value==="v2ray-plugin"&&l("dynamic_form.shadowsocks.plugin.v2ray_hint","提示:WebSocket模式格式为 mode=websocket;host=mydomain.me;path=/;tls=true,QUIC模式格式为 mode=quic;host=mydomain.me")]})})]})}),c.watch("plugin")&&c.watch("plugin")!=="none"&&c.watch("plugin")!==""&&e.jsx(v,{control:c.control,name:"plugin_opts",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.plugin_opts.label","插件选项")}),e.jsx(F,{children:l("dynamic_form.shadowsocks.plugin_opts.description","按照 key=value;key2=value2 格式输入插件选项")}),e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.plugin_opts.placeholder","例如: mode=tls;host=bing.com"),...p})})]})}),(c.watch("plugin")==="shadow-tls"||c.watch("plugin")==="restls")&&e.jsx(v,{control:c.control,name:"client_fingerprint",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.shadowsocks.client_fingerprint","客户端指纹")}),e.jsx(b,{children:e.jsxs(X,{value:p.value||"chrome",onValueChange:p.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.client_fingerprint_placeholder","选择客户端指纹")})}),e.jsx(J,{children:Te.shadowsocks.clientFingerprints.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})]})}),e.jsx(F,{children:l("dynamic_form.shadowsocks.client_fingerprint_description","客户端伪装指纹,用于降低被识别风险")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),c.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Ga,{value:c.watch("network_settings"),setValue:w=>c.setValue("network_settings",w),templateType:c.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.vmess.networkOptions.map(w=>e.jsx($,{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(v,{control:c.control,name:"server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(v,{control:c.control,name:"allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Ga,{value:c.watch("network_settings")||{},setValue:w=>c.setValue("network_settings",w),templateType:c.watch("network")||"tcp"})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value||"tcp",children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.trojan.networkOptions.map(w=>e.jsx($,{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(v,{control:c.control,name:"version",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:(p.value||2).toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.hysteria.versions.map(w=>e.jsxs($,{value:w,className:"cursor-pointer",children:["V",w]},w))})})]})})]})}),c.watch("version")==1&&e.jsx(v,{control:c.control,name:"alpn",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value||"h2",onValueChange:p.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.hysteria.alpnOptions.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"obfs.open",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})}),!!c.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[c.watch("version")=="2"&&e.jsx(v,{control:c.control,name:"obfs.type",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value||"salamander",onValueChange:p.onChange,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:e.jsx($,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(v,{control:c.control,name:"obfs.password",render:({field:p})=>e.jsxs(f,{className:c.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...p,value:p.value||"",className:"pr-9"})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",I=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(H=>w[H%w.length]).join("");c.setValue("obfs.password",I),A.success(l("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(ze,{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(v,{control:c.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(v,{control:c.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"bandwidth.up",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(c.watch("version")==2?l("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(v,{control:c.control,name:"bandwidth.down",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(c.watch("version")==2?l("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})}),e.jsx(e.Fragment,{children:e.jsx(v,{control:c.control,name:"hop_interval",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...p,value:p.value||"",onChange:w=>{const I=w.target.value?parseInt(w.target.value):void 0;p.onChange(I)}})}),e.jsx(F,{children:l("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx($,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx($,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),c.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),c.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"reality_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"reality_settings.server_port",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"reality_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(v,{control:c.control,name:"reality_settings.private_key",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...p,className:"pr-9"})}),e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const w=Eu();c.setValue("reality_settings.private_key",w.privateKey),c.setValue("reality_settings.public_key",w.publicKey),A.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.error(l("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(ze,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(ma,{children:e.jsx(de,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(v,{control:c.control,name:"reality_settings.public_key",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(b,{children:e.jsx(D,{...p})})]})}),e.jsx(v,{control:c.control,name:"reality_settings.short_id",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...p,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(xe,{children:[e.jsx(he,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const w=Iu();c.setValue("reality_settings.short_id",w),A.success(l("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(ze,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(ma,{children:e.jsx(de,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(v,{control:c.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[l("dynamic_form.vless.network.label"),e.jsx(Ga,{value:c.watch("network_settings"),setValue:w=>c.setValue("network_settings",w),templateType:c.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.vless.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})}),e.jsx(v,{control:c.control,name:"flow",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.vless.flow.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:w=>p.onChange(w==="none"?null:w),value:p.value||"none",children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(J,{children:Te.vless.flowOptions.map(w=>e.jsx($,{value:w,children:w},w))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"version",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.tuic.version.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.tuic.versions.map(w=>e.jsxs($,{value:w,children:["V",w]},w))})})]})})]})}),e.jsx(v,{control:c.control,name:"congestion_control",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.congestion_control.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.tuic.congestionControls.map(w=>e.jsx($,{value:w,children:w.toUpperCase()},w))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.tuic.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.tuic.tls.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(v,{control:c.control,name:"alpn",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.tls.alpn.label")}),e.jsx(b,{children:e.jsx(_t,{options:Te.tuic.alpnOptions,onChange:w=>p.onChange(w.map(I=>I.value)),value:Te.tuic.alpnOptions.filter(w=>p.value?.includes(w.value)),placeholder:l("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:l("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(v,{control:c.control,name:"udp_relay_mode",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.tuic.udpRelayModes.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.naive.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.naive.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.naive.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.naive.tls.enabled")})]})]})})]})}),c.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.naive.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.http.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:p.value?.toString(),onValueChange:w=>p.onChange(Number(w)),children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.http.tls.placeholder")})}),e.jsxs(J,{children:[e.jsx($,{value:"0",children:l("dynamic_form.http.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.http.tls.enabled")})]})]})})]})}),c.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:c.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:l("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:l("dynamic_form.http.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(v,{control:c.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:c.control,name:"transport",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.mieru.transport.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.mieru.transport.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.mieru.transportOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})}),e.jsx(v,{control:c.control,name:"multiplexing",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:l("dynamic_form.mieru.multiplexing.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:p.onChange,value:p.value,children:[e.jsx(Y,{children:e.jsx(Z,{placeholder:l("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(J,{children:e.jsx(Be,{children:Te.mieru.multiplexingOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:c.control,name:"padding_scheme",render:({field:p})=>e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(j,{children:l("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{c.setValue("padding_scheme",Te.anytls.defaultPaddingScheme),A.success(l("dynamic_form.anytls.padding_scheme.default_success","已设置默认填充方案"))},className:"h-7 px-2",children:l("dynamic_form.anytls.padding_scheme.use_default","使用默认方案")})]}),e.jsx(F,{children:l("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(b,{children:e.jsx("textarea",{className:"flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:l("dynamic_form.anytls.padding_scheme.placeholder",`例如: stop=8 0=30-30 1=100-400