diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 83c5016..adad236 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -52,7 +52,7 @@ import{r as m,j as e,t as il,c as ol,I as Na,a as Ts,S as Xt,u as os,b as ea,d a - 禁止滥用 - 遵守当地法律法规 - 支持随时更换套餐`}},force_update:{label:"强制更新到用户"},submit:{submitting:"提交中...",submit:"提交",cancel:"取消",success:{add:"套餐添加成功",update:"套餐更新成功"}}},page:{description:"在这里可以配置订阅计划,包括添加、删除、编辑等操作。"}}},email:{title:"邮件设置",description:"配置系统邮件服务,用于发送验证码、密码重置、通知等邮件,支持多种SMTP服务商。",email_host:{title:"SMTP主机",description:"SMTP服务器地址,例如:smtp.gmail.com"},email_port:{title:"SMTP端口",description:"SMTP服务器端口,常用端口:25, 465, 587"},email_username:{title:"SMTP用户名",description:"SMTP认证用户名"},email_password:{title:"SMTP密码",description:"SMTP认证密码或应用专用密码"},email_encryption:{title:"加密方式",description:"邮件加密方式",none:"无",ssl:"SSL/TLS",tls:"STARTTLS"},email_from:{title:"发件人地址",description:"发件人邮箱地址"},email_from_name:{title:"发件人名称",description:"发件人显示名称"},email_template:{title:"邮件模板",description:"自定义邮件模板方式请查看文档",placeholder:"选择邮件模板"},remind_mail:{title:"邮件提醒",description:"开启后用户订阅即将到期或流量不足时会收到邮件通知。"},test:{title:"发送测试邮件",sending:"发送中...",description:"发送测试邮件以验证配置",success:"测试邮件发送成功",error:"测试邮件发送失败"}},telegram:{title:"Telegram设置",description:"配置Telegram机器人功能,实现用户通知、账户绑定、指令交互等自动化服务。",bot_token:{title:"机器人令牌",description:"请输入从Botfather获取的令牌。",placeholder:"0000000000:xxxxxxxxx_xxxxxxxxxxxxxxx"},webhook:{title:"设置Webhook",description:"设置机器人的webhook,不设置将无法收到Telegram通知。",button:"一键设置",setting:"设置中..."},bot_enable:{title:"启用机器人通知",description:"开启后机器人将向管理员和已绑定Telegram的用户发送基础通知。"},discuss_link:{title:"群组链接",description:"填写后将在用户端显示或在需要的地方使用。",placeholder:"https://t.me/xxxxxx"}},app:{title:"APP设置",description:"管理移动应用程序相关配置,包括API接口、版本控制、推送通知等功能设置。",common:{placeholder:"请输入"},windows:{version:{title:"Windows版本",description:"Windows客户端当前版本号"},download:{title:"Windows下载地址",description:"Windows客户端下载链接"}},macos:{version:{title:"macOS版本",description:"macOS客户端当前版本号"},download:{title:"macOS下载地址",description:"macOS客户端下载链接"}},android:{version:{title:"Android版本",description:"Android客户端当前版本号"},download:{title:"Android下载地址",description:"Android客户端下载链接"}}},common:{saving:"保存中...",save_success:"已自动保存",placeholder:"请输入"},invite:{title:"邀请&佣金设置",description:"邀请注册、佣金相关设置。",invite_force:{title:"开启强制邀请",description:"开启后只有被邀请的用户才可以进行注册。"},invite_commission:{title:"邀请佣金百分比",description:"默认全局的佣金分配比例,你可以在用户管理单独配置单个比例。",placeholder:"请输入佣金百分比"},invite_gen_limit:{title:"用户可创建邀请码上限",description:"用户可创建邀请码上限",placeholder:"请输入创建上限"},invite_never_expire:{title:"邀请码永不失效",description:"开启后邀请码被使用后将不会失效,否则使用过后即失效。"},commission_first_time:{title:"佣金仅首次发放",description:"开启后被邀请人首次支付时才会产生佣金,可以在用户管理对用户进行单独配置。"},commission_auto_check:{title:"佣金自动确认",description:"开启后佣金将会在订单完成3日后自动进行确认。"},commission_withdraw_limit:{title:"提现单申请门槛(元)",description:"小于门槛金额的提现单将不会被提交。",placeholder:"请输入提现门槛"},commission_withdraw_method:{title:"提现方式",description:"可以支持的提现方式,多个用逗号分隔。",placeholder:"请输入提现方式,多个用逗号分隔"},withdraw_close:{title:"关闭提现",description:"关闭后将禁止用户申请提现,且邀请佣金将会直接进入用户余额。"},commission_distribution:{title:"三级分销",description:"开启后将佣金将按照设置的3成比例进行分成,三成比例合计请不要大于100%。",l1:"一级邀请人比例",l2:"二级邀请人比例",l3:"三级邀请人比例",placeholder:"请输入比例,如:50"},saving:"保存中..."},server:{title:"节点配置",description:"配置节点通信和同步设置,包括通信密钥、轮询间隔、负载均衡等高级选项。",server_token:{title:"通讯密钥",description:"Xboard与节点通讯的密钥,以便数据不会被他人获取。",placeholder:"请输入通讯密钥",generate_tooltip:"点击生成随机通信密钥"},server_pull_interval:{title:"节点拉取动作轮询间隔",description:"节点从面板获取数据的间隔频率。",placeholder:"请输入拉取间隔"},server_push_interval:{title:"节点推送动作轮询间隔",description:"节点推送数据到面板的间隔频率。",placeholder:"请输入推送间隔"},device_limit_mode:{title:"设备限制模式",description:"宽松模式下,同一IP地址使用多个节点只统计为一个设备。",strict:"严格模式",relaxed:"宽松模式",placeholder:"请选择设备限制模式"},saving:"保存中...",manage:{title:"节点管理",description:"管理所有节点,包括添加、删除、编辑等操作。"}}},wc={trafficRecord:{title:"流量使用记录",time:"时间",upload:"上行流量",download:"下行流量",rate:"倍率",total:"总计",noRecords:"暂无记录",perPage:"每页显示",records:"条记录",page:"第 {{current}} / {{total}} 页",multiplier:"{{value}}x"}},Cc={title:"工单管理",description:"在这里可以查看用户工单,包括查看、回复、关闭等操作。",columns:{id:"工单号",subject:"主题",level:"优先级",status:"状态",updated_at:"最后更新",created_at:"创建时间",actions:"操作"},status:{closed:"已关闭",replied:"已回复",pending:"待回复",processing:"处理中"},level:{low:"低",medium:"中",high:"高"},filter:{placeholder:"搜索{field}...",no_results:"未找到结果",selected:"已选择 {count} 项",clear:"清除筛选"},actions:{view_details:"查看详情",close_ticket:"关闭工单",close_confirm_title:"确认关闭工单",close_confirm_description:"关闭后将无法继续回复,是否确认关闭该工单?",close_confirm_button:"关闭工单",close_success:"工单已关闭",view_ticket:"查看工单"},detail:{no_messages:"暂无消息记录",created_at:"创建于",user_info:"用户信息",traffic_records:"流量记录",order_records:"订单记录",input:{closed_placeholder:"工单已关闭",reply_placeholder:"请输入回复内容...",sending:"发送中...",send:"发送"}}},Sc={manage:{title:"用户管理",description:"在这里可以管理用户,包括增加、删除、编辑、查询等操作。"},columns:{is_admin:"管理员",is_staff:"员工",id:"ID",email:"邮箱",online_count:"在线设备",status:"状态",subscription:"订阅",group:"权限组",used_traffic:"已用流量",total_traffic:"总流量",expire_time:"到期时间",balance:"余额",commission:"佣金",register_time:"注册时间",actions:"操作",device_limit:{unlimited:"无设备数限制",limited:"最多可同时在线 {{count}} 台设备"},status_text:{normal:"正常",banned:"封禁"},online_status:{online:"当前在线",never:"从未在线",last_online:"最后在线时间: {{time}}",offline_duration:{days:"离线时长: {{count}}天",hours:"离线时长: {{count}}小时",minutes:"离线时长: {{count}}分钟",seconds:"离线时长: {{count}}秒"}},expire_status:{permanent:"长期有效",expired:"已过期 {{days}} 天",remaining:"剩余 {{days}} 天"},actions_menu:{edit:"编辑",assign_order:"分配订单",copy_url:"复制订阅URL",reset_secret:"重置UUID及订阅URL",orders:"TA的订单",invites:"TA的邀请",traffic_records:"TA的流量记录"}},filter:{selected:"已选择 {{count}} 项",no_results:"未找到结果",clear:"清除筛选",search_placeholder:"搜索...",email_search:"搜索用户邮箱...",advanced:"高级筛选",reset:"重置筛选",sheet:{title:"高级筛选",description:"添加一个或多个筛选条件来精确查找用户",conditions:"筛选条件",add:"添加条件",condition:"条件 {{number}}",field:"选择字段",operator:"选择操作符",value:"输入值",value_number:"输入数值({{unit}})",reset:"重置",apply:"应用筛选"},fields:{email:"邮箱",id:"用户ID",plan_id:"订阅",transfer_enable:"流量",total_used:"已用流量",online_count:"在线设备",expired_at:"到期时间",uuid:"UUID",token:"Token",banned:"账号状态",remark:"备注",inviter_email:"邀请人邮箱",invite_user_id:"邀请人ID",is_admin:"管理员",is_staff:"员工"},operators:{contains:"包含",eq:"等于",gt:"大于",lt:"小于"},status:{normal:"正常",banned:"禁用"},boolean:{true:"是",false:"否"}},generate:{button:"创建用户",title:"创建用户",form:{email:"邮箱",email_prefix:"帐号(批量生成请留空)",email_domain:"域",password:"密码",password_placeholder:"留空则密码与邮件相同",expire_time:"到期时间",expire_time_placeholder:"请选择用户到期日期,留空为长期有效",permanent:"长期有效",subscription:"订阅计划",subscription_none:"无",generate_count:"生成数量",generate_count_placeholder:"如果为批量生产请输入生成数量",cancel:"取消",submit:"生成",success:"生成成功"}},edit:{button:"编辑用户信息",title:"用户管理",form:{email:"邮箱",email_placeholder:"请输入邮箱",inviter_email:"邀请人邮箱",inviter_email_placeholder:"请输入邮箱",password:"密码",password_placeholder:"如需修改密码请输入",balance:"余额",balance_placeholder:"请输入余额",commission_balance:"佣金余额",commission_balance_placeholder:"请输入佣金余额",upload:"已用上行",upload_placeholder:"已用上行",download:"已用下行",download_placeholder:"已用下行",total_traffic:"流量",total_traffic_placeholder:"请输入流量",expire_time:"到期时间",expire_time_placeholder:"请选择用户到期日期,留空为长期有效",expire_time_specific:"具体时间",expire_time_today:"设为当天结束",expire_time_permanent:"长期有效",expire_time_1month:"一个月",expire_time_3months:"三个月",expire_time_confirm:"确定",subscription:"订阅计划",subscription_none:"无",account_status:"账户状态",commission_type:"佣金类型",commission_type_system:"跟随系统设置",commission_type_cycle:"循环返利",commission_type_onetime:"首次返利",commission_rate:"推荐返利比例",commission_rate_placeholder:"为空则跟随站点设置返利比例",discount:"专享折扣比例",discount_placeholder:"为空则不享受专享折扣",speed_limit:"限速",speed_limit_placeholder:"留空则不限速",device_limit:"设备限制",device_limit_placeholder:"留空则不限制",is_admin:"是否管理员",is_staff:"是否员工",remarks:"备注",remarks_placeholder:"请在这里记录",cancel:"取消",submit:"提交",success:"修改成功"}}},kc={title:"路由管理",description:"管理所有路由组,包括添加、删除、编辑等操作。",columns:{id:"组ID",remarks:"备注",action:"动作",actions:"操作",matchRules:"匹配{{count}}条规则"},actions:{dns:"指定DNS服务器进行解析",block:"禁止访问"},form:{add:"添加路由",edit:"编辑路由",create:"创建路由",remarks:"备注",remarksPlaceholder:"请输入备注",match:"匹配规则",matchPlaceholder:`example.com -*.example.com`,action:"动作",actionPlaceholder:"请选择动作",dns:"DNS服务器",dnsPlaceholder:"请输入DNS服务器",cancel:"取消",submit:"提交",validation:{remarks:"请输入有效的备注"}},toolbar:{searchPlaceholder:"搜索路由...",reset:"重置"},messages:{deleteConfirm:"确认删除",deleteDescription:"此操作将永久删除该路由组,删除后无法恢复。确定要继续吗?",deleteButton:"删除",deleteSuccess:"删除成功",createSuccess:"创建成功",updateSuccess:"更新成功"}},Pc={title:"支付配置",description:"在这里可以配置支付方式,包括支付宝、微信等。",table:{columns:{id:"ID",enable:"启用",name:"显示名称",payment:"支付接口",notify_url:"通知地址",notify_url_tooltip:"支付网关将会把数据通知到本地址,请通过防火墙放行本地址。",actions:"操作"},actions:{edit:"编辑",delete:{title:"删除确认",description:"确定要删除该支付方式吗?此操作无法撤销。",success:"删除成功"}},toolbar:{search:"搜索支付方式...",reset:"重置",sort:{hint:"拖拽支付方式进行排序,完成后点击保存",save:"保存排序",edit:"编辑排序"}}},form:{add:{button:"添加支付方式",title:"添加支付方式"},edit:{title:"编辑支付方式"},fields:{name:{label:"显示名称",placeholder:"请输入支付名称",description:"用于前端显示"},icon:{label:"图标URL",placeholder:"https://example.com/icon.svg",description:"用于前端显示的图标地址"},notify_domain:{label:"通知域名",placeholder:"https://example.com",description:"网关通知将发送到该域名"},handling_fee_percent:{label:"百分比手续费(%)",placeholder:"0-100"},handling_fee_fixed:{label:"固定手续费",placeholder:"0"},payment:{label:"支付接口",placeholder:"请选择支付接口",description:"选择要使用的支付接口"}},validation:{name:{min:"名称至少需要2个字符",max:"名称不能超过30个字符"},notify_domain:{url:"请输入有效的URL"},payment:{required:"请选择支付接口"}},buttons:{cancel:"取消",submit:"提交"},messages:{success:"保存成功"}}},Tc={title:"公告管理",description:"在这里可以配置公告,包括添加、删除、编辑等操作。",table:{columns:{id:"ID",show:"显示状态",title:"标题",actions:"操作"},toolbar:{search:"搜索公告标题...",reset:"重置",sort:{edit:"编辑排序",save:"保存排序"}},actions:{edit:"编辑",delete:{title:"删除确认",description:"确定要删除该条公告吗?此操作无法撤销。",success:"删除成功"}}},form:{add:{title:"添加公告",button:"添加公告"},edit:{title:"编辑公告"},fields:{title:{label:"标题",placeholder:"请输入公告标题"},content:{label:"公告内容"},img_url:{label:"公告背景",placeholder:"请输入公告背景图片URL"},show:{label:"显示"},tags:{label:"节点标签",placeholder:"输入后回车添加标签"}},buttons:{cancel:"取消",submit:"提交",success:"提交成功"}}},Dc={title:"主题配置",description:"主题配置,包括主题色、字体大小等。如果你采用前后分离的方式部署V2board,那么主题配置将不会生效。",upload:{button:"上传主题",title:"上传主题",description:"请上传一个有效的主题压缩包(.zip 格式)。主题包应包含完整的主题文件结构。",dragText:"将主题文件拖放到此处,或者",clickText:"点击选择",supportText:"支持 .zip 格式的主题包",uploading:"正在上传...",error:{format:"只支持上传 ZIP 格式的主题文件"}},preview:{title:"主题预览",imageCount:"{{current}} / {{total}}"},card:{version:"版本: {{version}}",currentTheme:"当前主题",activateTheme:"激活主题",configureTheme:"主题设置",preview:"预览",delete:{title:"删除主题",description:"确定要删除该主题吗?删除后无法恢复。",button:"删除",error:{active:"不能删除当前使用的主题"}}},config:{title:"配置{{name}}主题",description:"修改主题的样式、布局和其他显示选项。",cancel:"取消",save:"保存",success:"保存成功"}},Rc={title:"优惠券管理",description:"在这里可以查看优惠券,包括增加、查看、删除等操作。",table:{columns:{id:"ID",show:"启用",name:"卷名称",type:"类型",code:"卷码",limitUse:"剩余次数",limitUseWithUser:"可用次数/用户",validity:"有效期",actions:"操作"},validity:{expired:"已过期{{days}}天",notStarted:"{{days}}天后开始",remaining:"剩余{{days}}天",startTime:"开始时间",endTime:"结束时间",unlimited:"无限次",noLimit:"无限制"},actions:{edit:"编辑",delete:"删除",deleteConfirm:{title:"确认删除",description:"此操作将永久删除该优惠券,删除后无法恢复。确定要继续吗?",confirmText:"删除"}},toolbar:{search:"搜索优惠券...",type:"类型",reset:"重置",types:{1:"按金额优惠",2:"按比例优惠"}}},form:{add:"添加优惠券",edit:"编辑优惠券",name:{label:"优惠券名称",placeholder:"请输入优惠券名称",required:"请输入优惠券名称"},type:{label:"优惠券类型和值",placeholder:"优惠券类型"},value:{placeholder:"请输入值"},validity:{label:"优惠券有效期",to:"至",endTimeError:"结束时间必须晚于开始时间"},limitUse:{label:"最大使用次数",placeholder:"限制最大使用次数,留空则不限制",description:"设置优惠券的总使用次数限制,留空表示不限制使用次数"},limitUseWithUser:{label:"每个用户可使用次数",placeholder:"限制每个用户可使用次数,留空则不限制",description:"限制每个用户可使用该优惠券的次数,留空表示不限制单用户使用次数"},limitPeriod:{label:"指定周期",placeholder:"限制指定周期可以使用优惠,留空则不限制",description:"选择可以使用优惠券的订阅周期,留空表示不限制使用周期",empty:"没有找到匹配的周期"},limitPlan:{label:"指定订阅",placeholder:"限制指定订阅可以使用优惠,留空则不限制",empty:"没有找到匹配的订阅"},code:{label:"自定义优惠码",placeholder:"自定义优惠码,留空则自动生成",description:"可以自定义优惠码,留空则系统自动生成"},generateCount:{label:"批量生成数量",placeholder:"批量生成优惠码数量,留空则生成单个",description:"批量生成多个优惠码,留空则只生成单个优惠码"},submit:{saving:"保存中...",save:"保存"},error:{saveFailed:"保存优惠券失败"}}},Ec={title:"权限组管理",description:"管理所有权限组,包括添加、删除、编辑等操作。",columns:{id:"组ID",name:"组名称",usersCount:"用户数量",serverCount:"节点数量",actions:"操作"},form:{add:"添加权限组",edit:"编辑权限组",create:"创建权限组",update:"更新",name:"组名称",namePlaceholder:"请输入权限组名称",nameDescription:"权限组名称用于标识不同的用户组,建议使用有意义的名称。",cancel:"取消",editDescription:"修改权限组信息,更新后会立即生效。",createDescription:"创建新的权限组,可以为不同的用户分配不同的权限。"},toolbar:{searchPlaceholder:"搜索权限组...",reset:"重置"},messages:{deleteConfirm:"确认删除",deleteDescription:"此操作将永久删除该权限组,删除后无法恢复。确定要继续吗?",deleteButton:"删除",createSuccess:"创建成功",updateSuccess:"更新成功",nameValidation:{min:"组名至少需要2个字符",max:"组名不能超过50个字符",pattern:"组名只能包含字母、数字、中文、下划线和连字符"}}},Ic={title:"知识库管理",description:"在这里可以配置知识库,包括添加、删除、编辑等操作。",columns:{id:"ID",status:"状态",title:"标题",category:"分类",actions:"操作"},form:{add:"添加知识",edit:"编辑知识",title:"标题",titlePlaceholder:"请输入知识标题",category:"分类",categoryPlaceholder:"请输入分类,分类将会自动归类",language:"语言",languagePlaceholder:"请选择语言",content:"内容",show:"显示",cancel:"取消",submit:"提交"},languages:{"en-US":"English","ja-JP":"日本語","ko-KR":"한국어","vi-VN":"Tiếng Việt","zh-CN":"简体中文","zh-TW":"繁體中文"},messages:{deleteConfirm:"确认删除",deleteDescription:"此操作将永久删除该知识库记录,删除后无法恢复。确定要继续吗?",deleteButton:"删除",operationSuccess:"操作成功"},toolbar:{searchPlaceholder:"搜索知识...",reset:"重置",sortModeHint:"拖拽知识条目进行排序,完成后点击保存",editSort:"编辑排序",saveSort:"保存排序"}},Mc={en:{common:Jo,dashboard:Qo,search:Zo,nav:Xo,sidebar:ec,server:sc,subscribe:tc,order:ac,settings:nc,traffic:rc,ticket:lc,user:ic,route:oc,payment:cc,notice:dc,theme:mc,coupon:uc,group:hc,knowledge:xc},zh:{common:pc,dashboard:fc,search:gc,nav:jc,sidebar:vc,server:bc,subscribe:yc,order:_c,settings:Nc,traffic:wc,ticket:Cc,user:Sc,route:kc,payment:Pc,notice:Tc,theme:Dc,coupon:Rc,group:Ec,knowledge:Ic}};xl.use(pl).use(fl).init({resources:Mc,fallbackLng:"en",supportedLngs:["en","zh"],ns:["common","dashboard","search","nav","sidebar","server","subscribe","order","settings","traffic","ticket","user","route","payment","notice","theme","coupon","group","knowledge"],defaultNS:"common",fallbackNS:"common",detection:{order:["localStorage","navigator"],caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const Oc=new gl;jl.createRoot(document.getElementById("root")).render(e.jsx(vl.StrictMode,{children:e.jsx(bl,{client:Oc,children:e.jsx(yl,{store:Xn,children:e.jsxs(ko,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(_l,{router:zo}),e.jsx(Nl,{richColors:!0,position:"top-right"})]})})})}));const qe=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...n}));qe.displayName="Card";const ss=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex flex-col space-y-1.5 p-6",s),...n}));ss.displayName="CardHeader";const bs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:y("font-semibold leading-none tracking-tight",s),...n}));bs.displayName="CardTitle";const tt=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:y("text-sm text-muted-foreground",s),...n}));tt.displayName="CardDescription";const ts=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("p-6 pt-0",s),...n}));ts.displayName="CardContent";const Vc=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex items-center p-6 pt-0",s),...n}));Vc.displayName="CardFooter";const Lc=Ts("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Nt=m.forwardRef(({className:s,...n},a)=>e.jsx(Ga,{ref:a,className:y(Lc(),s),...n}));Nt.displayName=Ga.displayName;const he=wl,er=m.createContext({}),j=({...s})=>e.jsx(er.Provider,{value:{name:s.name},children:e.jsx(Cl,{...s})}),Et=()=>{const s=m.useContext(er),n=m.useContext(sr),{getFieldState:a,formState:l}=Sl(),r=a(s.name,l);if(!s)throw new Error("useFormField should be used within ");const{id:c}=n;return{id:c,name:s.name,formItemId:`${c}-form-item`,formDescriptionId:`${c}-form-item-description`,formMessageId:`${c}-form-item-message`,...r}},sr=m.createContext({}),g=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(sr.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:y("space-y-2",s),...n})})});g.displayName="FormItem";const v=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=Et();return e.jsx(Nt,{ref:a,className:y(l&&"text-destructive",s),htmlFor:r,...n})});v.displayName="FormLabel";const _=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=Et();return e.jsx(Xt,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});_.displayName="FormControl";const O=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=Et();return e.jsx("p",{ref:a,id:l,className:y("text-[0.8rem] text-muted-foreground",s),...n})});O.displayName="FormDescription";const D=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=Et(),o=r?String(r?.message):n;return o?e.jsx("p",{ref:l,id:c,className:y("text-[0.8rem] font-medium text-destructive",s),...a,children:o}):null});D.displayName="FormMessage";const T=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:l,...a}));T.displayName="Input";const tr=m.forwardRef(({className:s,...n},a)=>{const[l,r]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:l?"text":"password",className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}),e.jsx(R,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>r(c=>!c),children:l?e.jsx(kl,{size:18}):e.jsx(Pl,{size:18})})]})});tr.displayName="PasswordInput";const Ac=s=>L({url:"/passport/auth/login",method:"post",data:s}),Yt=s=>s;function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Dl(s).format(n))}function Fc(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function zs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const a=typeof s=="string"?parseFloat(s):s;if(isNaN(a))return n?"¥0.00":"0.00";const r=(a/100).toFixed(2).replace(/\.?0+$/,c=>c.includes(".")?".00":c);return n?`¥${r}`:r}function wt(s){navigator.clipboard?navigator.clipboard.writeText(s).then(()=>{$.success(Yt("复制成功"))}).catch(n=>{console.error("复制到剪贴板时出错:",n),Ma(s)}):Ma(s)}function Ma(s){const n=document.createElement("button"),a=new Tl(n,{text:()=>s});a.on("success",()=>{$.success(Yt("复制成功")),a.destroy()}),a.on("error",()=>{$.error(Yt("复制失败")),a.destroy()}),n.click()}function Ze(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?zs(r)+" TB":l>=1?zs(l)+" GB":a>=1?zs(a)+" MB":zs(n)+" KB"}const zc="access_token";function Uc(s){Rt.set(zc,s)}const $c=x.object({email:x.string().min(1,{message:"请输入邮箱地址"}).email({message:"邮箱地址格式不正确"}),password:x.string().min(1,{message:"请输入密码"}).min(7,{message:"密码长度至少为7个字符"})});function Hc({className:s,onForgotPassword:n,...a}){const l=os(),r=Ka(),c=ce({resolver:ue($c),defaultValues:{email:"",password:""}});async function o(u){Ac(u).then(({data:h})=>{Uc(h.auth_data),r(Ko(h.auth_data)),r(Xs()).unwrap(),l("/")})}return e.jsx("div",{className:y("grid gap-6",s),...a,children:e.jsx(he,{...c,children:e.jsx("form",{onSubmit:c.handleSubmit(o),children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(j,{control:c.control,name:"email",render:({field:u})=>e.jsxs(g,{className:"space-y-1",children:[e.jsx(v,{children:"邮箱地址"}),e.jsx(_,{children:e.jsx(T,{placeholder:"name@example.com",...u})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"password",render:({field:u})=>e.jsxs(g,{className:"space-y-1",children:[e.jsx(v,{children:"密码"}),e.jsx(_,{children:e.jsx(tr,{placeholder:"请输入密码",...u})}),e.jsx(D,{})]})}),e.jsx(R,{className:"mt-2",loading:c.formState.isSubmitting,children:"登录"}),e.jsx(R,{variant:"link",type:"button",className:"mt-1 text-sm text-muted-foreground hover:text-primary",onClick:n,children:"忘记密码?"})]})})})})}const ge=Ba,Oe=Wa,qc=Ya,dt=ta,ar=m.forwardRef(({className:s,...n},a)=>e.jsx(St,{ref:a,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));ar.displayName=St.displayName;const xe=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(qc,{children:[e.jsx(ar,{}),e.jsxs(kt,{ref:l,className:y("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a,children:[n,e.jsxs(ta,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));xe.displayName=kt.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ve.displayName="DialogFooter";const je=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{ref:a,className:y("text-lg font-semibold leading-none tracking-tight",s),...n}));je.displayName=Pt.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Tt,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Te.displayName=Tt.displayName;const $s=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const o=l?Xt:"button";return e.jsx(o,{className:y($s({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";function Gc(){const[s,n]=m.useState(!1),a="php artisan reset:password 管理员邮箱";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"container grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-2 sm:w-[480px] lg:p-8",children:[e.jsx("div",{className:"mb-4 flex items-center justify-center",children:e.jsx("h1",{className:"text-3xl font-medium",children:window?.settings?.title})}),e.jsxs(qe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"登录"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请输入您的邮箱和密码登录系统"})]}),e.jsx(Hc,{onForgotPassword:()=>n(!0)})]})]})}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(xe,{children:e.jsxs(ve,{children:[e.jsx(je,{children:"忘记密码"}),e.jsx(Te,{children:"在站点目录下执行以下命令找回密码"}),e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12",children:a}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>wt(a),children:e.jsx(Rl,{className:"h-4 w-4"})})]})})]})})})]})}const Kc=Object.freeze(Object.defineProperty({__proto__:null,default:Gc},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:y("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",a&&"md:h-svh",s),...l}));we.displayName="Layout";const Ce=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const ke=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));ke.displayName="LayoutBody";const nr=El,rr=Il,lr=Ml,ys=Ll,_s=Al,Bc=Fl,Wc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(Ja,{ref:r,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...l,children:[a,e.jsx(aa,{className:"ml-auto h-4 w-4"})]}));Wc.displayName=Ja.displayName;const Yc=m.forwardRef(({className:s,...n},a)=>e.jsx(Qa,{ref:a,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));Yc.displayName=Qa.displayName;const is=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Ol,{children:e.jsx(Za,{ref:l,sideOffset:n,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a})}));is.displayName=Za.displayName;const pe=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(Xa,{ref:l,className:y("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...a}));pe.displayName=Xa.displayName;const Jc=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(en,{ref:r,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:a,...l,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(sn,{children:e.jsx(Ds,{className:"h-4 w-4"})})}),n]}));Jc.displayName=en.displayName;const Qc=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(tn,{ref:l,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(sn,{children:e.jsx(Vl,{className:"h-4 w-4 fill-current"})})}),n]}));Qc.displayName=tn.displayName;const oa=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(an,{ref:l,className:y("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));oa.displayName=an.displayName;const at=m.forwardRef(({className:s,...n},a)=>e.jsx(nn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));at.displayName=nn.displayName;const Jt=({className:s,...n})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...n});Jt.displayName="DropdownMenuShortcut";const oe=zl,re=Ul,le=$l,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(rn,{ref:l,sideOffset:n,className:y("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a}));te.displayName=rn.displayName;function It(){const{pathname:s}=ea();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function ir({key:s,defaultValue:n}){const[a,l]=m.useState(()=>{const r=localStorage.getItem(s);return r!==null?JSON.parse(r):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,l]}function Zc(){const[s,n]=ir({key:"collapsed-sidebar-items",defaultValue:[]}),a=r=>!s.includes(r);return{isExpanded:a,toggleItem:r=>{a(r)?n([...s,r]):n(s.filter(c=>c!==r))}}}function Xc({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=M(),c=({sub:o,...u})=>{const h=`${r(u.title)}-${u.href}`;return n&&o?m.createElement(td,{...u,sub:o,key:h,closeNav:l}):n?m.createElement(sd,{...u,key:h,closeNav:l}):o?m.createElement(ed,{...u,sub:o,key:h,closeNav:l}):m.createElement(or,{...u,key:h,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",a),children:e.jsx(oe,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(c)})})})}function or({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:o}=It(),{t:u}=M();return e.jsxs(Rs,{to:l,onClick:r,className:y(Hs({variant:o(l)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",c&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":o(l)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),u(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(a)})]})}function ed({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=It(),{isExpanded:o,toggleItem:u}=Zc(),{t:h}=M(),i=!!l?.find(P=>c(P.href)),d=h(s),f=o(d)||i;return e.jsxs(nr,{open:f,onOpenChange:()=>u(d),children:[e.jsxs(rr,{className:y(Hs({variant:i?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),h(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:h(a)}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(ln,{stroke:1})})]}),e.jsx(lr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(P=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(or,{...P,subLink:!0,closeNav:r})},h(P.title)))})})]})}function sd({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=It(),{t:o}=M();return e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsxs(Rs,{to:l,onClick:r,className:y(Hs({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:o(s)})]})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[o(s),a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:o(a)})]})]})}function td({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=It(),{t:o}=M(),u=!!l?.find(h=>c(h.href));return e.jsxs(ys,{children:[e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:u?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[o(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:o(a)}),e.jsx(ln,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(is,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(oa,{children:[o(s)," ",a?`(${o(a)})`:""]}),e.jsx(at,{}),l.map(({title:h,icon:i,label:d,href:f})=>e.jsx(pe,{asChild:!0,children:e.jsxs(Rs,{to:f,onClick:r,className:`${c(f)?"bg-secondary":""}`,children:[i," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:o(h)}),d&&e.jsx("span",{className:"ml-auto text-xs",children:o(d)})]})},`${o(h)}-${f}`))]})]})}const cr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Hl,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(ql,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(on,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Gl,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Kl,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(wa,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Bl,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(cn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Wl,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(dn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Yl,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Jl,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Ql,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(wa,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Zl,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Xl,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(ei,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(mn,{size:18})}]}];function ad({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=m.useState(!1),{t:c}=M();return m.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:y(`fixed left-0 right-0 top-0 z-50 w-full border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>r(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${l?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(we,{children:[e.jsxs(Ce,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":c("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":l,onClick:()=>r(o=>!o),children:l?e.jsx(si,{}):e.jsx(ti,{})})]}),e.jsx(Xc,{id:"sidebar-menu",className:`h-full flex-1 overflow-auto ${l?"max-h-screen":"max-h-0 py-0 md:max-h-screen md:py-2"}`,closeNav:()=>r(!1),isCollapsed:n,links:cr}),e.jsx("div",{className:y("px-4 py-3 text-xs text-muted-foreground/70 border-t border-border/50 bg-muted/20","transition-all duration-200 ease-in-out",n?"text-center":"text-left"),children:e.jsxs("div",{className:y("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500/70"}),e.jsxs("span",{className:"tracking-wide",children:["v",window?.settings?.version]})]})}),e.jsx(R,{onClick:()=>a(o=>!o),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":c("common:toggleSidebar"),children:e.jsx(ai,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function nd(){const[s,n]=ir({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const a=()=>{n(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),[s,n]}function rd(){const[s,n]=nd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(ad,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(sa,{})})]})}const ld=Object.freeze(Object.defineProperty({__proto__:null,default:rd},Symbol.toStringTag,{value:"Module"})),Ns=m.forwardRef(({className:s,...n},a)=>e.jsx(Se,{ref:a,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ns.displayName=Se.displayName;const id=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(xe,{className:"overflow-hidden p-0",children:e.jsx(Ns,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Is=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ni,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Se.Input,{ref:a,className:y("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Is.displayName=Se.Input.displayName;const ws=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.List,{ref:a,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));ws.displayName=Se.List.displayName;const Ms=m.forwardRef((s,n)=>e.jsx(Se.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ms.displayName=Se.Empty.displayName;const Me=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Group,{ref:a,className:y("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Me.displayName=Se.Group.displayName;const qs=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Separator,{ref:a,className:y("-mx-1 h-px bg-border",s),...n}));qs.displayName=Se.Separator.displayName;const Ne=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Item,{ref:a,className:y("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Ne.displayName=Se.Item.displayName;function od(){const s=[];for(const n of cr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function De(){const[s,n]=m.useState(!1),a=os(),l=od(),{t:r}=M("search"),{t:c}=M("nav");m.useEffect(()=>{const u=h=>{h.key==="k"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),n(i=>!i))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const o=m.useCallback(u=>{n(!1),a(u)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(ri,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:r("placeholder")}),e.jsx("span",{className:"sr-only",children:r("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:r("shortcut.key")})]}),e.jsxs(id,{open:s,onOpenChange:n,children:[e.jsx(Is,{placeholder:r("placeholder")}),e.jsxs(ws,{children:[e.jsx(Ms,{children:r("noResults")}),e.jsx(Me,{heading:r("title"),children:l.map(u=>e.jsxs(Ne,{value:`${u.parent?u.parent+" ":""}${u.title}`,onSelect:()=>o(u.href),children:[e.jsx("div",{className:"mr-2",children:u.icon}),e.jsx("span",{children:c(u.title)}),u.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c(u.parent)})]},u.href))})]})]})]})}const At=[{code:"en",name:"English",flag:li,shortName:"EN"},{code:"zh",name:"中文",flag:ii,shortName:"CN"}];function cd(){const{i18n:s}=M(),n=r=>{s.changeLanguage(r)},a=At.find(r=>r.code===s.language)||At[0],l=a.flag;return e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(l,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:a.shortName})]})}),e.jsx(is,{align:"end",className:"w-[120px]",children:At.map(r=>{const c=r.flag,o=r.code===s.language;return e.jsxs(pe,{onClick:()=>n(r.code),className:y("flex items-center gap-2 px-2 py-1.5 cursor-pointer",o&&"bg-accent"),children:[e.jsx(c,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:y("text-sm",o&&"font-medium"),children:r.name})]},r.code)})})]})}function Re(){const{theme:s,setTheme:n}=Po();return m.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",l=document.querySelector("meta[name='theme-color']");l&&l.setAttribute("content",a)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(oi,{size:20}):e.jsx(ci,{size:20})}),e.jsx(cd,{})]})}const dr=m.forwardRef(({className:s,...n},a)=>e.jsx(un,{ref:a,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));dr.displayName=un.displayName;const mr=m.forwardRef(({className:s,...n},a)=>e.jsx(hn,{ref:a,className:y("aspect-square h-full w-full",s),...n}));mr.displayName=hn.displayName;const ur=m.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ur.displayName=xn.displayName;function Ee(){const s=os(),n=Ka(),a=di(Wo),{t:l}=M(["common"]),r=()=>{Jn(),n(Bo()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),o=c.substring(0,2).toUpperCase();return e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(dr,{className:"h-8 w-8",children:[e.jsx(mr,{src:a?.avatar_url,alt:c}),e.jsx(ur,{children:o})]})})}),e.jsxs(is,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(oa,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:c}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:a?.email||l("common:defaultEmail")})]})}),e.jsx(at,{}),e.jsx(pe,{asChild:!0,children:e.jsxs(Rs,{to:"/config/system",children:[l("common:settings"),e.jsx(Jt,{children:"⌘S"})]})}),e.jsx(at,{}),e.jsxs(pe,{onClick:r,children:[l("common:logout"),e.jsx(Jt,{children:"⇧⌘Q"})]})]})]})}const Qe=window?.settings?.secure_path,hr=5*60*1e3,Qt=new Map,dd=s=>{const n=Qt.get(s);return n?Date.now()-n.timestamp>hr?(Qt.delete(s),null):n.data:null},md=(s,n)=>{Qt.set(s,{data:n,timestamp:Date.now()})},ud=async(s,n=hr)=>{const a=dd(s);if(a)return a;const l=await L.get(s);return md(s,l),l},hd={getList:()=>ud(`${Qe}/notice/fetch`),save:s=>L.post(`${Qe}/notice/save`,s),drop:s=>L.post(`${Qe}/notice/drop`,{id:s}),updateStatus:s=>L.post(`${Qe}/notice/show`,{id:s}),sort:s=>L.post(`${Qe}/notice/sort`,{ids:s})},Oa={getSystemStatus:()=>L.get(`${Qe}/system/getSystemStatus`),getQueueStats:()=>L.get(`${Qe}/system/getQueueStats`),getQueueWorkload:()=>L.get(`${Qe}/system/getQueueWorkload`),getQueueMasters:()=>L.get(`${Qe}/system/getQueueMasters`),getSystemLog:s=>L.get(`${Qe}/system/getSystemLog`,{params:s})},F=window?.settings?.secure_path,xd=s=>L.get(F+"/stat/getOrder",{params:s}),pd=()=>L.get(F+"/stat/getStats"),Va=s=>L.get(F+"/stat/getTrafficRank",{params:s}),fd=()=>L.get(F+"/theme/getThemes"),gd=s=>L.post(F+"/theme/getThemeConfig",{name:s}),jd=(s,n)=>L.post(F+"/theme/saveThemeConfig",{name:s,config:n}),vd=s=>{const n=new FormData;return n.append("file",s),L.post(F+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},bd=s=>L.post(F+"/theme/delete",{name:s}),yd=s=>L.post(F+"/config/save",s),xr=()=>L.get(F+"/server/manage/getNodes"),_d=s=>L.post(F+"/server/manage/save",s),Nd=s=>L.post(F+"/server/manage/drop",s),wd=s=>L.post(F+"/server/manage/copy",s),Cd=s=>L.post(F+"/server/manage/update",s),Sd=s=>L.post(F+"/server/manage/sort",s),Mt=()=>L.get(F+"/server/group/fetch"),kd=s=>L.post(F+"/server/group/save",s),Pd=s=>L.post(F+"/server/group/drop",s),pr=()=>L.get(F+"/server/route/fetch"),Td=s=>L.post(F+"/server/route/save",s),Dd=s=>L.post(F+"/server/route/drop",s),Rd=()=>L.get(F+"/payment/fetch"),Ed=()=>L.get(F+"/payment/getPaymentMethods"),Id=s=>L.post(F+"/payment/getPaymentForm",s),Md=s=>L.post(F+"/payment/save",s),Od=s=>L.post(F+"/payment/drop",s),Vd=s=>L.post(F+"/payment/show",s),Ld=s=>L.post(F+"/payment/sort",s),Ad=()=>L.get(F+"/notice/fetch"),Fd=s=>L.post(F+"/notice/save",s),zd=s=>L.post(F+"/notice/drop",s),Ud=s=>L.post(F+"/notice/show",s),$d=()=>L.get(F+"/knowledge/fetch"),Hd=s=>L.get(F+"/knowledge/fetch?id="+s),qd=s=>L.post(F+"/knowledge/save",s),Gd=s=>L.post(F+"/knowledge/drop",s),Kd=s=>L.post(F+"/knowledge/show",s),Bd=s=>L.post(F+"/knowledge/sort",s),Os=()=>L.get(F+"/plan/fetch"),Wd=s=>L.post(F+"/plan/save",s),Ft=s=>L.post(F+"/plan/update",s),Yd=s=>L.post(F+"/plan/drop",s),Jd=s=>L.post(F+"/plan/sort",{ids:s}),Qd=async s=>L.post(F+"/order/fetch",s),Zd=s=>L.post(F+"/order/detail",s),Xd=s=>L.post(F+"/order/paid",s),em=s=>L.post(F+"/order/cancel",s),La=s=>L.post(F+"/order/update",s),sm=s=>L.post(F+"/order/assign",s),tm=s=>L.post(F+"/coupon/fetch",s),am=s=>L.post(F+"/coupon/generate",s),nm=s=>L.post(F+"/coupon/drop",s),rm=s=>L.post(F+"/coupon/update",s),lm=s=>L.post(F+"/user/fetch",s),im=s=>L.post(F+"/user/update",s),om=s=>L.post(F+"/user/resetSecret",s),cm=s=>L.post(F+"/user/generate",s),dm=s=>L.post(F+"/stat/getStatUser",s),mm=s=>L.post(F+"/ticket/fetch",s),um=s=>L.get(F+"/ticket/fetch?id= "+s),hm=s=>L.post(F+"/ticket/reply",s),fr=s=>L.post(F+"/ticket/close",{id:s}),us=(s="")=>L.get(F+"/config/fetch?key="+s),hs=s=>L.post(F+"/config/save",s),xm=()=>L.get(F+"/config/getEmailTemplate"),pm=()=>L.post(F+"/config/testSendMail"),fm=()=>L.post(F+"/config/setTelegramWebhook"),gm=hd.sort,gr=mi,ca=m.forwardRef(({className:s,...n},a)=>e.jsx(pn,{ref:a,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));ca.displayName=pn.displayName;const nt=m.forwardRef(({className:s,...n},a)=>e.jsx(fn,{ref:a,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));nt.displayName=fn.displayName;const jm=m.forwardRef(({className:s,...n},a)=>e.jsx(gn,{ref:a,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));jm.displayName=gn.displayName;const W=ui,ps=bi,Y=hi,K=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(jn,{ref:l,className:y("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...a,children:[n,e.jsx(xi,{asChild:!0,children:e.jsx(na,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=jn.displayName;const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(vn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(pi,{className:"h-4 w-4"})}));jr.displayName=vn.displayName;const vr=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(na,{className:"h-4 w-4"})}));vr.displayName=bn.displayName;const B=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(fi,{children:e.jsxs(yn,{ref:r,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:a,...l,children:[e.jsx(jr,{}),e.jsx(gi,{className:y("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(vr,{})]})}));B.displayName=yn.displayName;const vm=m.forwardRef(({className:s,...n},a)=>e.jsx(_n,{ref:a,className:y("px-2 py-1.5 text-sm font-semibold",s),...n}));vm.displayName=_n.displayName;const U=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Nn,{ref:l,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ji,{children:e.jsx(Ds,{className:"h-4 w-4"})})}),e.jsx(vi,{children:n})]}));U.displayName=Nn.displayName;const bm=m.forwardRef(({className:s,...n},a)=>e.jsx(wn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));bm.displayName=wn.displayName;function Vs({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(yi,{showOutsideDays:a,className:y("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:y($s({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:y("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",l.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:y($s({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx(Cn,{className:y("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(aa,{className:y("h-4 w-4",r),...c})},...l})}Vs.displayName="Calendar";const as=Ni,ns=wi,We=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(_i,{children:e.jsx(Sn,{ref:r,align:n,sideOffset:a,className:y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...l})}));We.displayName=Sn.displayName;const fs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Qs=s=>(s/100).toFixed(2),ym=({active:s,payload:n,label:a})=>{const{t:l}=M();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:a}),n.map((r,c)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[l(r.name),":"]}),e.jsx("span",{className:"font-medium",children:r.name.includes(l("dashboard:overview.amount"))?`¥${Qs(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},_m=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],Nm=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=$e(a,7);break;case"30d":l=$e(a,30);break;case"90d":l=$e(a,90);break;case"180d":l=$e(a,180);break;case"365d":l=$e(a,365);break;default:l=$e(a,30)}return{startDate:l,endDate:a}};function wm(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:$e(new Date,7),to:new Date}),{t:o}=M(),{startDate:u,endDate:h}=Nm(a,r),{data:i}=se({queryKey:["orderStat",{start_date:Ue(u,"yyyy-MM-dd"),end_date:Ue(h,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await xd({start_date:Ue(u,"yyyy-MM-dd"),end_date:Ue(h,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(qe,{children:[e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(bs,{children:o("dashboard:overview.title")}),e.jsxs(tt,{children:[i?.summary.start_date," ",o("dashboard:overview.to")," ",i?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(W,{value:a,onValueChange:d=>l(d),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(Y,{placeholder:o("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:_m.map(d=>e.jsx(U,{value:d.value,children:o(d.label)},d.value))})]}),a==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r?.from?r.to?e.jsxs(e.Fragment,{children:[Ue(r.from,"yyyy-MM-dd")," -"," ",Ue(r.to,"yyyy-MM-dd")]}):Ue(r.from,"yyyy-MM-dd"):o("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Vs,{mode:"range",defaultMonth:r?.from,selected:{from:r?.from,to:r?.to},onSelect:d=>{d?.from&&d?.to&&c({from:d.from,to:d.to})},numberOfMonths:2})})]})]}),e.jsx(gr,{value:s,onValueChange:d=>n(d),children:e.jsxs(ca,{children:[e.jsx(nt,{value:"amount",children:o("dashboard:overview.amount")}),e.jsx(nt,{value:"count",children:o("dashboard:overview.count")})]})})]})]})}),e.jsxs(ts,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:o("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(i?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("dashboard:overview.totalTransactions",{count:i?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o("dashboard:overview.avgOrderAmount")," ¥",Qs(i?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:o("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(i?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("dashboard:overview.totalTransactions",{count:i?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o("dashboard:overview.commissionRate")," ",i?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Ci,{width:"100%",height:"100%",children:e.jsxs(Si,{data:i?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:fs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:fs.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:fs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:fs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(ki,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Ue(new Date(d),"MM-dd",{locale:Ri})}),e.jsx(Pi,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${Qs(d)}`:o("dashboard:overview.transactions",{count:d})}),e.jsx(Ti,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Di,{content:e.jsx(ym,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{type:"monotone",dataKey:"paid_total",name:o("dashboard:overview.orderAmount"),stroke:fs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ca,{type:"monotone",dataKey:"commission_total",name:o("dashboard:overview.commissionAmount"),stroke:fs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{dataKey:"paid_count",name:o("dashboard:overview.orderCount"),fill:fs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Sa,{dataKey:"commission_count",name:o("dashboard:overview.commissionCount"),fill:fs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function Ie({className:s,...n}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...n})}function Cm(){return e.jsxs(qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ie,{className:"h-4 w-[120px]"}),e.jsx(Ie,{className:"h-4 w-4"})]}),e.jsxs(ts,{children:[e.jsx(Ie,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx(Ie,{className:"h-4 w-[100px]"})]})]})]})}function Sm(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:8}).map((s,n)=>e.jsx(Cm,{},n))})}var Q=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(Q||{});const Ys={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Js={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var He=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(He||{}),ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(ne||{});const ut={0:"待确认",1:"发放中",2:"有效",3:"无效"},ht={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var de=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(de||{});const km={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ye=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(ye||{});const Ps=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ls={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var js=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(js||{});const Pm={1:"按金额优惠",2:"按比例优惠"};var et=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(et||{}),Xe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Xe||{});function gs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:o,className:u}){return e.jsxs(qe,{className:y("transition-colors",c&&"cursor-pointer hover:bg-muted/50",o&&"border-primary/50",u),onClick:c,children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(bs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Li,{className:y("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("ml-1 text-xs",l.isPositive?"text-emerald-500":"text-red-500"),children:[l.isPositive?"+":"-",Math.abs(l.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:l.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]})}function Tm({className:s}){const n=os(),{t:a}=M(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await pd()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Sm,{});const c=()=>{const o=new URLSearchParams;o.set("commission_status",ne.PENDING.toString()),o.set("status",Q.COMPLETED.toString()),o.set("commission_balance","gt:0"),n(`/finance/order?${o.toString()}`)};return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(gs,{title:a("dashboard:stats.todayIncome"),value:ks(l.todayIncome),icon:e.jsx(Ei,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.monthlyIncome"),value:ks(l.currentMonthIncome),icon:e.jsx(Ii,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Mi,{className:y("h-4 w-4",l.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:l.ticketPendingTotal>0?a("dashboard:stats.hasPendingTickets"):a("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:l.ticketPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Oi,{className:y("h-4 w-4",l.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:l.commissionPendingTotal>0?a("dashboard:stats.hasPendingCommission"):a("dashboard:stats.noPendingCommission"),onClick:c,highlight:l.commissionPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Ht,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Ht,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(gs,{title:a("dashboard:stats.monthlyUpload"),value:Ze(l.monthTraffic.upload),icon:e.jsx(qt,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.upload)})}),e.jsx(gs,{title:a("dashboard:stats.monthlyDownload"),value:Ze(l.monthTraffic.download),icon:e.jsx(Vi,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.download)})})]})}const rt=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(kn,{ref:l,className:y("relative overflow-hidden",s),...a,children:[e.jsx(Ai,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ct,{}),e.jsx(Fi,{})]}));rt.displayName=kn.displayName;const Ct=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Pn,{ref:l,orientation:n,className:y("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...a,children:e.jsx(zi,{className:"relative flex-1 rounded-full bg-border"})}));Ct.displayName=Pn.displayName;const Zt={today:{getValue:()=>{const s=$i();return{start:s,end:Hi(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:$e(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:$e(s,30),end:s}}},custom:{getValue:()=>null}};function Aa({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=M(),c={today:r("dashboard:trafficRank.today"),last7days:r("dashboard:trafficRank.last7days"),last30days:r("dashboard:trafficRank.last30days"),custom:r("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(W,{value:s,onValueChange:a,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(Zt).map(([o])=>e.jsx(U,{value:o,children:c[o]},o))})]}),s==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[Ue(n.from,"yyyy-MM-dd")," -"," ",Ue(n.to,"yyyy-MM-dd")]}):Ue(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Vs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:o=>{o?.from&&o?.to&&l({from:o.from,to:o.to})},numberOfMonths:2})})]})]})}const As=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Dm({className:s}){const{t:n}=M(),[a,l]=m.useState("today"),[r,c]=m.useState({from:$e(new Date,7),to:new Date}),[o,u]=m.useState("today"),[h,i]=m.useState({from:$e(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:Zt[a].getValue(),[a,r]),f=m.useMemo(()=>o==="custom"?{start:h.from,end:h.to}:Zt[o].getValue(),[o,h]),{data:P}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Va({type:"node",start_time:fe.round(d.start.getTime()/1e3),end_time:fe.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:I}=se({queryKey:["userTrafficRank",f.start,f.end],queryFn:()=>Va({type:"user",start_time:fe.round(f.start.getTime()/1e3),end_time:fe.round(f.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(qe,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx(Ui,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Aa,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(ka,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:P?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:P.data.map(p=>e.jsx(oe,{delayDuration:200,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:p.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?e.jsx(Gt,{className:"mr-1 h-3 w-3"}):e.jsx(Kt,{className:"mr-1 h-3 w-3"}),Math.abs(p.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${p.value/P.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(p.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?"+":"",p.change,"%"]})]})})]})},p.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(qe,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx(Ht,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Aa,{selectedRange:o,customDateRange:h,onRangeChange:u,onCustomRangeChange:i}),e.jsx(ka,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:I?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:I.data.map(p=>e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:p.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?e.jsx(Gt,{className:"mr-1 h-3 w-3"}):e.jsx(Kt,{className:"mr-1 h-3 w-3"}),Math.abs(p.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${p.value/I.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(p.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?"+":"",p.change,"%"]})]})})]})},p.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const Rm=Ts("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function H({className:s,variant:n,...a}){return e.jsx("div",{className:y(Rm({variant:n}),s),...a})}const vt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Tn,{ref:l,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(qi,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));vt.displayName=Tn.displayName;function Em(){const{t:s}=M(),[n,a]=m.useState(null),[l,r]=m.useState(null),[c,o]=m.useState(!0),[u,h]=m.useState(!1),i=async()=>{try{h(!0);const[P,I]=await Promise.all([Oa.getSystemStatus(),Oa.getQueueStats()]);a(P.data.data),r(I.data.data)}catch(P){console.error("Error fetching system data:",P)}finally{o(!1),h(!1)}};m.useEffect(()=>{i();const P=setInterval(i,3e4);return()=>clearInterval(P)},[]);const d=()=>{i()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(ra,{className:"h-6 w-6 animate-spin"})});const f=P=>P?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Rn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Gi,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(tt,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Ki,{className:y("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f(l?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(H,{variant:l?.status?"secondary":"destructive",children:l?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:l?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.recentJobs||0}),e.jsx(vt,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.jobsPerMinute||0}),e.jsx(vt,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(qe,{children:[e.jsxs(ss,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Bi,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(tt,{children:s("dashboard:queue.details.description")})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:l?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:l?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[l?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[l?.processes||0," /"," ",(l?.processes||0)+(l?.pausedMasters||0)]})]}),e.jsx(vt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Im(){const{t:s}=M();return e.jsxs(we,{children:[e.jsxs(Ce,{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(De,{}),e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsx(ke,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Tm,{}),e.jsx(wm,{}),e.jsx(Dm,{}),e.jsx(Em,{})]})})})]})}const Mm=Object.freeze(Object.defineProperty({__proto__:null,default:Im},Symbol.toStringTag,{value:"Module"})),be=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(En,{ref:r,decorative:a,orientation:n,className:y("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));be.displayName=En.displayName;function Om({className:s,items:n,...a}){const{pathname:l}=ea(),r=os(),[c,o]=m.useState(l??"/settings"),u=i=>{o(i),r(i)},{t:h}=M("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(W,{value:c,onValueChange:u,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(i=>e.jsx(U,{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:h(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),...a,children:n.map(i=>e.jsxs(Rs,{to:i.href,className:y(Hs({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}),h(i.title)]},i.href))})})]})}const Vm=[{title:"site.title",key:"site",icon:e.jsx(Wi,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(dn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(mn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Yi,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(cn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Ji,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Qi,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(on,{size:18}),href:"/config/system/app",description:"app.description"}];function Lm(){const{t:s}=M("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{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(be,{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(Om,{items:Vm})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(sa,{})})})]})]})]})}const Am=Object.freeze(Object.defineProperty({__proto__:null,default:Lm},Symbol.toStringTag,{value:"Module"})),q=m.forwardRef(({className:s,...n},a)=>e.jsx(In,{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),...n,ref:a,children:e.jsx(Zi,{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")})}));q.displayName=In.displayName;const Cs=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:y("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}));Cs.displayName="Textarea";const Fm=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 zm(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>us("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Os()}),o=ce({resolver:ue(Fm),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=es({mutationFn:hs,onSuccess:d=>{d.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(r?.data?.site){const d=r?.data?.site;Object.entries(d).forEach(([f,P])=>{o.setValue(f,P)}),l.current=d}},[r]);const h=m.useCallback(fe.debounce(async d=>{if(!fe.isEqual(d,l.current)){a(!0);try{const f=Object.entries(d).reduce((P,[I,p])=>(P[I]=p===null?"":p,P),{});await u(f),l.current=d}finally{a(!1)}}},1e3),[u]),i=m.useCallback(d=>{h(d)},[h]);return m.useEffect(()=>{const d=o.watch(f=>{i(f)});return()=>d.unsubscribe()},[o.watch,i]),e.jsx(he,{...o,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:o.control,name:"app_name",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.siteName.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"app_description",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.siteDescription.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"app_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.siteUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"force_https",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(O,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:!!d.value,onCheckedChange:f=>{d.onChange(Number(f)),i(o.getValues())}})})]})}),e.jsx(j,{control:o.control,name:"logo",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.logo.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"subscribe_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(Cs,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.subscribeUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"tos_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.tosUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"stop_register",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(O,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:!!d.value,onCheckedChange:f=>{d.onChange(Number(f)),i(o.getValues())}})})]})}),e.jsx(j,{control:o.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(W,{value:d.value?.toString(),onValueChange:f=>{d.onChange(Number(f)),i(o.getValues())},children:[e.jsx(K,{children:e.jsx(Y,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(f=>e.jsx(U,{value:f.id.toString(),children:f.name},f.id.toString()))]})]})}),e.jsx(O,{children:s("site.form.tryOut.description")}),e.jsx(D,{})]})}),!!o.watch("try_out_plan_id")&&e.jsx(j,{control:o.control,name:"try_out_hour",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.tryOut.duration.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"currency",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.currency.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"currency_symbol",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.currencySymbol.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Um(){const{t:s}=M("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(be,{}),e.jsx(zm,{})]})}const $m=Object.freeze(Object.defineProperty({__proto__:null,default:Um},Symbol.toStringTag,{value:"Module"})),Hm=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()}),qm={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 Gm(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Hm),defaultValues:qm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>us("safe")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data.safe){const i=c.data.safe;Object.entries(i).forEach(([d,f])=>{typeof f=="number"?r.setValue(d,String(f)):r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"email_verify",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(O,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"email_gmail_limit_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(O,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"safe_mode_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(O,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"secure_path",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.securePath.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"email_whitelist_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(O,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(j,{control:r.control,name:"email_whitelist_suffix",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(Cs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...i,value:(i.value||[]).join(` +*.example.com`,action:"动作",actionPlaceholder:"请选择动作",dns:"DNS服务器",dnsPlaceholder:"请输入DNS服务器",cancel:"取消",submit:"提交",validation:{remarks:"请输入有效的备注"}},toolbar:{searchPlaceholder:"搜索路由...",reset:"重置"},messages:{deleteConfirm:"确认删除",deleteDescription:"此操作将永久删除该路由组,删除后无法恢复。确定要继续吗?",deleteButton:"删除",deleteSuccess:"删除成功",createSuccess:"创建成功",updateSuccess:"更新成功"}},Pc={title:"支付配置",description:"在这里可以配置支付方式,包括支付宝、微信等。",table:{columns:{id:"ID",enable:"启用",name:"显示名称",payment:"支付接口",notify_url:"通知地址",notify_url_tooltip:"支付网关将会把数据通知到本地址,请通过防火墙放行本地址。",actions:"操作"},actions:{edit:"编辑",delete:{title:"删除确认",description:"确定要删除该支付方式吗?此操作无法撤销。",success:"删除成功"}},toolbar:{search:"搜索支付方式...",reset:"重置",sort:{hint:"拖拽支付方式进行排序,完成后点击保存",save:"保存排序",edit:"编辑排序"}}},form:{add:{button:"添加支付方式",title:"添加支付方式"},edit:{title:"编辑支付方式"},fields:{name:{label:"显示名称",placeholder:"请输入支付名称",description:"用于前端显示"},icon:{label:"图标URL",placeholder:"https://example.com/icon.svg",description:"用于前端显示的图标地址"},notify_domain:{label:"通知域名",placeholder:"https://example.com",description:"网关通知将发送到该域名"},handling_fee_percent:{label:"百分比手续费(%)",placeholder:"0-100"},handling_fee_fixed:{label:"固定手续费",placeholder:"0"},payment:{label:"支付接口",placeholder:"请选择支付接口",description:"选择要使用的支付接口"}},validation:{name:{min:"名称至少需要2个字符",max:"名称不能超过30个字符"},notify_domain:{url:"请输入有效的URL"},payment:{required:"请选择支付接口"}},buttons:{cancel:"取消",submit:"提交"},messages:{success:"保存成功"}}},Tc={title:"公告管理",description:"在这里可以配置公告,包括添加、删除、编辑等操作。",table:{columns:{id:"ID",show:"显示状态",title:"标题",actions:"操作"},toolbar:{search:"搜索公告标题...",reset:"重置",sort:{edit:"编辑排序",save:"保存排序"}},actions:{edit:"编辑",delete:{title:"删除确认",description:"确定要删除该条公告吗?此操作无法撤销。",success:"删除成功"}}},form:{add:{title:"添加公告",button:"添加公告"},edit:{title:"编辑公告"},fields:{title:{label:"标题",placeholder:"请输入公告标题"},content:{label:"公告内容"},img_url:{label:"公告背景",placeholder:"请输入公告背景图片URL"},show:{label:"显示"},tags:{label:"节点标签",placeholder:"输入后回车添加标签"}},buttons:{cancel:"取消",submit:"提交",success:"提交成功"}}},Dc={title:"主题配置",description:"主题配置,包括主题色、字体大小等。如果你采用前后分离的方式部署V2board,那么主题配置将不会生效。",upload:{button:"上传主题",title:"上传主题",description:"请上传一个有效的主题压缩包(.zip 格式)。主题包应包含完整的主题文件结构。",dragText:"将主题文件拖放到此处,或者",clickText:"点击选择",supportText:"支持 .zip 格式的主题包",uploading:"正在上传...",error:{format:"只支持上传 ZIP 格式的主题文件"}},preview:{title:"主题预览",imageCount:"{{current}} / {{total}}"},card:{version:"版本: {{version}}",currentTheme:"当前主题",activateTheme:"激活主题",configureTheme:"主题设置",preview:"预览",delete:{title:"删除主题",description:"确定要删除该主题吗?删除后无法恢复。",button:"删除",error:{active:"不能删除当前使用的主题"}}},config:{title:"配置{{name}}主题",description:"修改主题的样式、布局和其他显示选项。",cancel:"取消",save:"保存",success:"保存成功"}},Rc={title:"优惠券管理",description:"在这里可以查看优惠券,包括增加、查看、删除等操作。",table:{columns:{id:"ID",show:"启用",name:"卷名称",type:"类型",code:"卷码",limitUse:"剩余次数",limitUseWithUser:"可用次数/用户",validity:"有效期",actions:"操作"},validity:{expired:"已过期{{days}}天",notStarted:"{{days}}天后开始",remaining:"剩余{{days}}天",startTime:"开始时间",endTime:"结束时间",unlimited:"无限次",noLimit:"无限制"},actions:{edit:"编辑",delete:"删除",deleteConfirm:{title:"确认删除",description:"此操作将永久删除该优惠券,删除后无法恢复。确定要继续吗?",confirmText:"删除"}},toolbar:{search:"搜索优惠券...",type:"类型",reset:"重置",types:{1:"按金额优惠",2:"按比例优惠"}}},form:{add:"添加优惠券",edit:"编辑优惠券",name:{label:"优惠券名称",placeholder:"请输入优惠券名称",required:"请输入优惠券名称"},type:{label:"优惠券类型和值",placeholder:"优惠券类型"},value:{placeholder:"请输入值"},validity:{label:"优惠券有效期",to:"至",endTimeError:"结束时间必须晚于开始时间"},limitUse:{label:"最大使用次数",placeholder:"限制最大使用次数,留空则不限制",description:"设置优惠券的总使用次数限制,留空表示不限制使用次数"},limitUseWithUser:{label:"每个用户可使用次数",placeholder:"限制每个用户可使用次数,留空则不限制",description:"限制每个用户可使用该优惠券的次数,留空表示不限制单用户使用次数"},limitPeriod:{label:"指定周期",placeholder:"限制指定周期可以使用优惠,留空则不限制",description:"选择可以使用优惠券的订阅周期,留空表示不限制使用周期",empty:"没有找到匹配的周期"},limitPlan:{label:"指定订阅",placeholder:"限制指定订阅可以使用优惠,留空则不限制",empty:"没有找到匹配的订阅"},code:{label:"自定义优惠码",placeholder:"自定义优惠码,留空则自动生成",description:"可以自定义优惠码,留空则系统自动生成"},generateCount:{label:"批量生成数量",placeholder:"批量生成优惠码数量,留空则生成单个",description:"批量生成多个优惠码,留空则只生成单个优惠码"},submit:{saving:"保存中...",save:"保存"},error:{saveFailed:"保存优惠券失败"}}},Ec={title:"权限组管理",description:"管理所有权限组,包括添加、删除、编辑等操作。",columns:{id:"组ID",name:"组名称",usersCount:"用户数量",serverCount:"节点数量",actions:"操作"},form:{add:"添加权限组",edit:"编辑权限组",create:"创建权限组",update:"更新",name:"组名称",namePlaceholder:"请输入权限组名称",nameDescription:"权限组名称用于标识不同的用户组,建议使用有意义的名称。",cancel:"取消",editDescription:"修改权限组信息,更新后会立即生效。",createDescription:"创建新的权限组,可以为不同的用户分配不同的权限。"},toolbar:{searchPlaceholder:"搜索权限组...",reset:"重置"},messages:{deleteConfirm:"确认删除",deleteDescription:"此操作将永久删除该权限组,删除后无法恢复。确定要继续吗?",deleteButton:"删除",createSuccess:"创建成功",updateSuccess:"更新成功",nameValidation:{min:"组名至少需要2个字符",max:"组名不能超过50个字符",pattern:"组名只能包含字母、数字、中文、下划线和连字符"}}},Ic={title:"知识库管理",description:"在这里可以配置知识库,包括添加、删除、编辑等操作。",columns:{id:"ID",status:"状态",title:"标题",category:"分类",actions:"操作"},form:{add:"添加知识",edit:"编辑知识",title:"标题",titlePlaceholder:"请输入知识标题",category:"分类",categoryPlaceholder:"请输入分类,分类将会自动归类",language:"语言",languagePlaceholder:"请选择语言",content:"内容",show:"显示",cancel:"取消",submit:"提交"},languages:{"en-US":"English","ja-JP":"日本語","ko-KR":"한국어","vi-VN":"Tiếng Việt","zh-CN":"简体中文","zh-TW":"繁體中文"},messages:{deleteConfirm:"确认删除",deleteDescription:"此操作将永久删除该知识库记录,删除后无法恢复。确定要继续吗?",deleteButton:"删除",operationSuccess:"操作成功"},toolbar:{searchPlaceholder:"搜索知识...",reset:"重置",sortModeHint:"拖拽知识条目进行排序,完成后点击保存",editSort:"编辑排序",saveSort:"保存排序"}},Mc={en:{common:Jo,dashboard:Qo,search:Zo,nav:Xo,sidebar:ec,server:sc,subscribe:tc,order:ac,settings:nc,traffic:rc,ticket:lc,user:ic,route:oc,payment:cc,notice:dc,theme:mc,coupon:uc,group:hc,knowledge:xc},zh:{common:pc,dashboard:fc,search:gc,nav:jc,sidebar:vc,server:bc,subscribe:yc,order:_c,settings:Nc,traffic:wc,ticket:Cc,user:Sc,route:kc,payment:Pc,notice:Tc,theme:Dc,coupon:Rc,group:Ec,knowledge:Ic}};xl.use(pl).use(fl).init({resources:Mc,fallbackLng:"en",supportedLngs:["en","zh"],ns:["common","dashboard","search","nav","sidebar","server","subscribe","order","settings","traffic","ticket","user","route","payment","notice","theme","coupon","group","knowledge"],defaultNS:"common",fallbackNS:"common",detection:{order:["localStorage","navigator"],caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const Oc=new gl;jl.createRoot(document.getElementById("root")).render(e.jsx(vl.StrictMode,{children:e.jsx(bl,{client:Oc,children:e.jsx(yl,{store:Xn,children:e.jsxs(ko,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(_l,{router:zo}),e.jsx(Nl,{richColors:!0,position:"top-right"})]})})})}));const qe=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...n}));qe.displayName="Card";const ss=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex flex-col space-y-1.5 p-6",s),...n}));ss.displayName="CardHeader";const bs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:y("font-semibold leading-none tracking-tight",s),...n}));bs.displayName="CardTitle";const tt=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:y("text-sm text-muted-foreground",s),...n}));tt.displayName="CardDescription";const ts=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("p-6 pt-0",s),...n}));ts.displayName="CardContent";const Vc=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex items-center p-6 pt-0",s),...n}));Vc.displayName="CardFooter";const Lc=Ts("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Nt=m.forwardRef(({className:s,...n},a)=>e.jsx(Ga,{ref:a,className:y(Lc(),s),...n}));Nt.displayName=Ga.displayName;const he=wl,er=m.createContext({}),j=({...s})=>e.jsx(er.Provider,{value:{name:s.name},children:e.jsx(Cl,{...s})}),Et=()=>{const s=m.useContext(er),n=m.useContext(sr),{getFieldState:a,formState:l}=Sl(),r=a(s.name,l);if(!s)throw new Error("useFormField should be used within ");const{id:c}=n;return{id:c,name:s.name,formItemId:`${c}-form-item`,formDescriptionId:`${c}-form-item-description`,formMessageId:`${c}-form-item-message`,...r}},sr=m.createContext({}),g=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(sr.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:y("space-y-2",s),...n})})});g.displayName="FormItem";const v=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=Et();return e.jsx(Nt,{ref:a,className:y(l&&"text-destructive",s),htmlFor:r,...n})});v.displayName="FormLabel";const _=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=Et();return e.jsx(Xt,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});_.displayName="FormControl";const O=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=Et();return e.jsx("p",{ref:a,id:l,className:y("text-[0.8rem] text-muted-foreground",s),...n})});O.displayName="FormDescription";const D=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=Et(),o=r?String(r?.message):n;return o?e.jsx("p",{ref:l,id:c,className:y("text-[0.8rem] font-medium text-destructive",s),...a,children:o}):null});D.displayName="FormMessage";const T=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:l,...a}));T.displayName="Input";const tr=m.forwardRef(({className:s,...n},a)=>{const[l,r]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:l?"text":"password",className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}),e.jsx(R,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>r(c=>!c),children:l?e.jsx(kl,{size:18}):e.jsx(Pl,{size:18})})]})});tr.displayName="PasswordInput";const Ac=s=>L({url:"/passport/auth/login",method:"post",data:s}),Yt=s=>s;function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Dl(s).format(n))}function Fc(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function zs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const a=typeof s=="string"?parseFloat(s):s;if(isNaN(a))return n?"¥0.00":"0.00";const r=(a/100).toFixed(2).replace(/\.?0+$/,c=>c.includes(".")?".00":c);return n?`¥${r}`:r}function wt(s){navigator.clipboard?navigator.clipboard.writeText(s).then(()=>{$.success(Yt("复制成功"))}).catch(n=>{console.error("复制到剪贴板时出错:",n),Ma(s)}):Ma(s)}function Ma(s){const n=document.createElement("button"),a=new Tl(n,{text:()=>s});a.on("success",()=>{$.success(Yt("复制成功")),a.destroy()}),a.on("error",()=>{$.error(Yt("复制失败")),a.destroy()}),n.click()}function Ze(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?zs(r)+" TB":l>=1?zs(l)+" GB":a>=1?zs(a)+" MB":zs(n)+" KB"}const zc="access_token";function Uc(s){Rt.set(zc,s)}const $c=x.object({email:x.string().min(1,{message:"请输入邮箱地址"}).email({message:"邮箱地址格式不正确"}),password:x.string().min(1,{message:"请输入密码"}).min(7,{message:"密码长度至少为7个字符"})});function Hc({className:s,onForgotPassword:n,...a}){const l=os(),r=Ka(),c=ce({resolver:ue($c),defaultValues:{email:"",password:""}});async function o(u){Ac(u).then(({data:h})=>{Uc(h.auth_data),r(Ko(h.auth_data)),r(Xs()).unwrap(),l("/")})}return e.jsx("div",{className:y("grid gap-6",s),...a,children:e.jsx(he,{...c,children:e.jsx("form",{onSubmit:c.handleSubmit(o),children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(j,{control:c.control,name:"email",render:({field:u})=>e.jsxs(g,{className:"space-y-1",children:[e.jsx(v,{children:"邮箱地址"}),e.jsx(_,{children:e.jsx(T,{placeholder:"name@example.com",...u})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"password",render:({field:u})=>e.jsxs(g,{className:"space-y-1",children:[e.jsx(v,{children:"密码"}),e.jsx(_,{children:e.jsx(tr,{placeholder:"请输入密码",...u})}),e.jsx(D,{})]})}),e.jsx(R,{className:"mt-2",loading:c.formState.isSubmitting,children:"登录"}),e.jsx(R,{variant:"link",type:"button",className:"mt-1 text-sm text-muted-foreground hover:text-primary",onClick:n,children:"忘记密码?"})]})})})})}const ge=Ba,Oe=Wa,qc=Ya,dt=ta,ar=m.forwardRef(({className:s,...n},a)=>e.jsx(St,{ref:a,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));ar.displayName=St.displayName;const xe=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(qc,{children:[e.jsx(ar,{}),e.jsxs(kt,{ref:l,className:y("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a,children:[n,e.jsxs(ta,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));xe.displayName=kt.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ve.displayName="DialogFooter";const je=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{ref:a,className:y("text-lg font-semibold leading-none tracking-tight",s),...n}));je.displayName=Pt.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Tt,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Te.displayName=Tt.displayName;const $s=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const o=l?Xt:"button";return e.jsx(o,{className:y($s({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";function Gc(){const[s,n]=m.useState(!1),a="php artisan reset:password 管理员邮箱";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"container grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-2 sm:w-[480px] lg:p-8",children:[e.jsx("div",{className:"mb-4 flex items-center justify-center",children:e.jsx("h1",{className:"text-3xl font-medium",children:window?.settings?.title})}),e.jsxs(qe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"登录"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请输入您的邮箱和密码登录系统"})]}),e.jsx(Hc,{onForgotPassword:()=>n(!0)})]})]})}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(xe,{children:e.jsxs(ve,{children:[e.jsx(je,{children:"忘记密码"}),e.jsx(Te,{children:"在站点目录下执行以下命令找回密码"}),e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12",children:a}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>wt(a),children:e.jsx(Rl,{className:"h-4 w-4"})})]})})]})})})]})}const Kc=Object.freeze(Object.defineProperty({__proto__:null,default:Gc},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:y("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",a&&"md:h-svh",s),...l}));we.displayName="Layout";const Ce=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const ke=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));ke.displayName="LayoutBody";const nr=El,rr=Il,lr=Ml,ys=Ll,_s=Al,Bc=Fl,Wc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(Ja,{ref:r,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...l,children:[a,e.jsx(aa,{className:"ml-auto h-4 w-4"})]}));Wc.displayName=Ja.displayName;const Yc=m.forwardRef(({className:s,...n},a)=>e.jsx(Qa,{ref:a,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));Yc.displayName=Qa.displayName;const is=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Ol,{children:e.jsx(Za,{ref:l,sideOffset:n,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a})}));is.displayName=Za.displayName;const pe=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(Xa,{ref:l,className:y("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...a}));pe.displayName=Xa.displayName;const Jc=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(en,{ref:r,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:a,...l,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(sn,{children:e.jsx(Ds,{className:"h-4 w-4"})})}),n]}));Jc.displayName=en.displayName;const Qc=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(tn,{ref:l,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(sn,{children:e.jsx(Vl,{className:"h-4 w-4 fill-current"})})}),n]}));Qc.displayName=tn.displayName;const oa=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(an,{ref:l,className:y("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));oa.displayName=an.displayName;const at=m.forwardRef(({className:s,...n},a)=>e.jsx(nn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));at.displayName=nn.displayName;const Jt=({className:s,...n})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...n});Jt.displayName="DropdownMenuShortcut";const oe=zl,re=Ul,le=$l,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(rn,{ref:l,sideOffset:n,className:y("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a}));te.displayName=rn.displayName;function It(){const{pathname:s}=ea();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function ir({key:s,defaultValue:n}){const[a,l]=m.useState(()=>{const r=localStorage.getItem(s);return r!==null?JSON.parse(r):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,l]}function Zc(){const[s,n]=ir({key:"collapsed-sidebar-items",defaultValue:[]}),a=r=>!s.includes(r);return{isExpanded:a,toggleItem:r=>{a(r)?n([...s,r]):n(s.filter(c=>c!==r))}}}function Xc({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=M(),c=({sub:o,...u})=>{const h=`${r(u.title)}-${u.href}`;return n&&o?m.createElement(td,{...u,sub:o,key:h,closeNav:l}):n?m.createElement(sd,{...u,key:h,closeNav:l}):o?m.createElement(ed,{...u,sub:o,key:h,closeNav:l}):m.createElement(or,{...u,key:h,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",a),children:e.jsx(oe,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(c)})})})}function or({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:o}=It(),{t:u}=M();return e.jsxs(Rs,{to:l,onClick:r,className:y(Hs({variant:o(l)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",c&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":o(l)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),u(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(a)})]})}function ed({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=It(),{isExpanded:o,toggleItem:u}=Zc(),{t:h}=M(),i=!!l?.find(P=>c(P.href)),d=h(s),f=o(d)||i;return e.jsxs(nr,{open:f,onOpenChange:()=>u(d),children:[e.jsxs(rr,{className:y(Hs({variant:i?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),h(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:h(a)}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(ln,{stroke:1})})]}),e.jsx(lr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(P=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(or,{...P,subLink:!0,closeNav:r})},h(P.title)))})})]})}function sd({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=It(),{t:o}=M();return e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsxs(Rs,{to:l,onClick:r,className:y(Hs({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:o(s)})]})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[o(s),a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:o(a)})]})]})}function td({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=It(),{t:o}=M(),u=!!l?.find(h=>c(h.href));return e.jsxs(ys,{children:[e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:u?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[o(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:o(a)}),e.jsx(ln,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(is,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(oa,{children:[o(s)," ",a?`(${o(a)})`:""]}),e.jsx(at,{}),l.map(({title:h,icon:i,label:d,href:f})=>e.jsx(pe,{asChild:!0,children:e.jsxs(Rs,{to:f,onClick:r,className:`${c(f)?"bg-secondary":""}`,children:[i," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:o(h)}),d&&e.jsx("span",{className:"ml-auto text-xs",children:o(d)})]})},`${o(h)}-${f}`))]})]})}const cr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Hl,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(ql,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(on,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Gl,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Kl,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(wa,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Bl,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(cn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Wl,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(dn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Yl,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Jl,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Ql,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(wa,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Zl,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Xl,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(ei,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(mn,{size:18})}]}];function ad({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=m.useState(!1),{t:c}=M();return m.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:y(`fixed left-0 right-0 top-0 z-50 w-full border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>r(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${l?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(we,{children:[e.jsxs(Ce,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":c("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":l,onClick:()=>r(o=>!o),children:l?e.jsx(si,{}):e.jsx(ti,{})})]}),e.jsx(Xc,{id:"sidebar-menu",className:`h-full flex-1 overflow-auto ${l?"max-h-screen":"max-h-0 py-0 md:max-h-screen md:py-2"}`,closeNav:()=>r(!1),isCollapsed:n,links:cr}),e.jsx("div",{className:y("px-4 py-3 text-xs text-muted-foreground/70 border-t border-border/50 bg-muted/20","transition-all duration-200 ease-in-out",n?"text-center":"text-left"),children:e.jsxs("div",{className:y("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500/70"}),e.jsxs("span",{className:"tracking-wide",children:["v",window?.settings?.version]})]})}),e.jsx(R,{onClick:()=>a(o=>!o),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":c("common:toggleSidebar"),children:e.jsx(ai,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function nd(){const[s,n]=ir({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const a=()=>{n(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),[s,n]}function rd(){const[s,n]=nd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(ad,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(sa,{})})]})}const ld=Object.freeze(Object.defineProperty({__proto__:null,default:rd},Symbol.toStringTag,{value:"Module"})),Ns=m.forwardRef(({className:s,...n},a)=>e.jsx(Se,{ref:a,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ns.displayName=Se.displayName;const id=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(xe,{className:"overflow-hidden p-0",children:e.jsx(Ns,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Is=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ni,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Se.Input,{ref:a,className:y("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Is.displayName=Se.Input.displayName;const ws=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.List,{ref:a,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));ws.displayName=Se.List.displayName;const Ms=m.forwardRef((s,n)=>e.jsx(Se.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ms.displayName=Se.Empty.displayName;const Me=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Group,{ref:a,className:y("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Me.displayName=Se.Group.displayName;const qs=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Separator,{ref:a,className:y("-mx-1 h-px bg-border",s),...n}));qs.displayName=Se.Separator.displayName;const Ne=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Item,{ref:a,className:y("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Ne.displayName=Se.Item.displayName;function od(){const s=[];for(const n of cr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function De(){const[s,n]=m.useState(!1),a=os(),l=od(),{t:r}=M("search"),{t:c}=M("nav");m.useEffect(()=>{const u=h=>{h.key==="k"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),n(i=>!i))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const o=m.useCallback(u=>{n(!1),a(u)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(ri,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:r("placeholder")}),e.jsx("span",{className:"sr-only",children:r("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:r("shortcut.key")})]}),e.jsxs(id,{open:s,onOpenChange:n,children:[e.jsx(Is,{placeholder:r("placeholder")}),e.jsxs(ws,{children:[e.jsx(Ms,{children:r("noResults")}),e.jsx(Me,{heading:r("title"),children:l.map(u=>e.jsxs(Ne,{value:`${u.parent?u.parent+" ":""}${u.title}`,onSelect:()=>o(u.href),children:[e.jsx("div",{className:"mr-2",children:u.icon}),e.jsx("span",{children:c(u.title)}),u.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c(u.parent)})]},u.href))})]})]})]})}const At=[{code:"en",name:"English",flag:li,shortName:"EN"},{code:"zh",name:"中文",flag:ii,shortName:"CN"}];function cd(){const{i18n:s}=M(),n=r=>{s.changeLanguage(r)},a=At.find(r=>r.code===s.language)||At[0],l=a.flag;return e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(l,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:a.shortName})]})}),e.jsx(is,{align:"end",className:"w-[120px]",children:At.map(r=>{const c=r.flag,o=r.code===s.language;return e.jsxs(pe,{onClick:()=>n(r.code),className:y("flex items-center gap-2 px-2 py-1.5 cursor-pointer",o&&"bg-accent"),children:[e.jsx(c,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:y("text-sm",o&&"font-medium"),children:r.name})]},r.code)})})]})}function Re(){const{theme:s,setTheme:n}=Po();return m.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",l=document.querySelector("meta[name='theme-color']");l&&l.setAttribute("content",a)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(oi,{size:20}):e.jsx(ci,{size:20})}),e.jsx(cd,{})]})}const dr=m.forwardRef(({className:s,...n},a)=>e.jsx(un,{ref:a,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));dr.displayName=un.displayName;const mr=m.forwardRef(({className:s,...n},a)=>e.jsx(hn,{ref:a,className:y("aspect-square h-full w-full",s),...n}));mr.displayName=hn.displayName;const ur=m.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ur.displayName=xn.displayName;function Ee(){const s=os(),n=Ka(),a=di(Wo),{t:l}=M(["common"]),r=()=>{Jn(),n(Bo()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),o=c.substring(0,2).toUpperCase();return e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(dr,{className:"h-8 w-8",children:[e.jsx(mr,{src:a?.avatar_url,alt:c}),e.jsx(ur,{children:o})]})})}),e.jsxs(is,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(oa,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:c}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:a?.email||l("common:defaultEmail")})]})}),e.jsx(at,{}),e.jsx(pe,{asChild:!0,children:e.jsxs(Rs,{to:"/config/system",children:[l("common:settings"),e.jsx(Jt,{children:"⌘S"})]})}),e.jsx(at,{}),e.jsxs(pe,{onClick:r,children:[l("common:logout"),e.jsx(Jt,{children:"⇧⌘Q"})]})]})]})}const Qe=window?.settings?.secure_path,hr=5*60*1e3,Qt=new Map,dd=s=>{const n=Qt.get(s);return n?Date.now()-n.timestamp>hr?(Qt.delete(s),null):n.data:null},md=(s,n)=>{Qt.set(s,{data:n,timestamp:Date.now()})},ud=async(s,n=hr)=>{const a=dd(s);if(a)return a;const l=await L.get(s);return md(s,l),l},hd={getList:()=>ud(`${Qe}/notice/fetch`),save:s=>L.post(`${Qe}/notice/save`,s),drop:s=>L.post(`${Qe}/notice/drop`,{id:s}),updateStatus:s=>L.post(`${Qe}/notice/show`,{id:s}),sort:s=>L.post(`${Qe}/notice/sort`,{ids:s})},Oa={getSystemStatus:()=>L.get(`${Qe}/system/getSystemStatus`),getQueueStats:()=>L.get(`${Qe}/system/getQueueStats`),getQueueWorkload:()=>L.get(`${Qe}/system/getQueueWorkload`),getQueueMasters:()=>L.get(`${Qe}/system/getQueueMasters`),getSystemLog:s=>L.get(`${Qe}/system/getSystemLog`,{params:s})},F=window?.settings?.secure_path,xd=s=>L.get(F+"/stat/getOrder",{params:s}),pd=()=>L.get(F+"/stat/getStats"),Va=s=>L.get(F+"/stat/getTrafficRank",{params:s}),fd=()=>L.get(F+"/theme/getThemes"),gd=s=>L.post(F+"/theme/getThemeConfig",{name:s}),jd=(s,n)=>L.post(F+"/theme/saveThemeConfig",{name:s,config:n}),vd=s=>{const n=new FormData;return n.append("file",s),L.post(F+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},bd=s=>L.post(F+"/theme/delete",{name:s}),yd=s=>L.post(F+"/config/save",s),xr=()=>L.get(F+"/server/manage/getNodes"),_d=s=>L.post(F+"/server/manage/save",s),Nd=s=>L.post(F+"/server/manage/drop",s),wd=s=>L.post(F+"/server/manage/copy",s),Cd=s=>L.post(F+"/server/manage/update",s),Sd=s=>L.post(F+"/server/manage/sort",s),Mt=()=>L.get(F+"/server/group/fetch"),kd=s=>L.post(F+"/server/group/save",s),Pd=s=>L.post(F+"/server/group/drop",s),pr=()=>L.get(F+"/server/route/fetch"),Td=s=>L.post(F+"/server/route/save",s),Dd=s=>L.post(F+"/server/route/drop",s),Rd=()=>L.get(F+"/payment/fetch"),Ed=()=>L.get(F+"/payment/getPaymentMethods"),Id=s=>L.post(F+"/payment/getPaymentForm",s),Md=s=>L.post(F+"/payment/save",s),Od=s=>L.post(F+"/payment/drop",s),Vd=s=>L.post(F+"/payment/show",s),Ld=s=>L.post(F+"/payment/sort",s),Ad=()=>L.get(F+"/notice/fetch"),Fd=s=>L.post(F+"/notice/save",s),zd=s=>L.post(F+"/notice/drop",s),Ud=s=>L.post(F+"/notice/show",s),$d=()=>L.get(F+"/knowledge/fetch"),Hd=s=>L.get(F+"/knowledge/fetch?id="+s),qd=s=>L.post(F+"/knowledge/save",s),Gd=s=>L.post(F+"/knowledge/drop",s),Kd=s=>L.post(F+"/knowledge/show",s),Bd=s=>L.post(F+"/knowledge/sort",s),Os=()=>L.get(F+"/plan/fetch"),Wd=s=>L.post(F+"/plan/save",s),Ft=s=>L.post(F+"/plan/update",s),Yd=s=>L.post(F+"/plan/drop",s),Jd=s=>L.post(F+"/plan/sort",{ids:s}),Qd=async s=>L.post(F+"/order/fetch",s),Zd=s=>L.post(F+"/order/detail",s),Xd=s=>L.post(F+"/order/paid",s),em=s=>L.post(F+"/order/cancel",s),La=s=>L.post(F+"/order/update",s),sm=s=>L.post(F+"/order/assign",s),tm=s=>L.post(F+"/coupon/fetch",s),am=s=>L.post(F+"/coupon/generate",s),nm=s=>L.post(F+"/coupon/drop",s),rm=s=>L.post(F+"/coupon/update",s),lm=s=>L.post(F+"/user/fetch",s),im=s=>L.post(F+"/user/update",s),om=s=>L.post(F+"/user/resetSecret",s),cm=s=>L.post(F+"/user/generate",s),dm=s=>L.post(F+"/stat/getStatUser",s),mm=s=>L.post(F+"/ticket/fetch",s),um=s=>L.get(F+"/ticket/fetch?id= "+s),hm=s=>L.post(F+"/ticket/reply",s),fr=s=>L.post(F+"/ticket/close",{id:s}),us=(s="")=>L.get(F+"/config/fetch?key="+s),hs=s=>L.post(F+"/config/save",s),xm=()=>L.get(F+"/config/getEmailTemplate"),pm=()=>L.post(F+"/config/testSendMail"),fm=()=>L.post(F+"/config/setTelegramWebhook"),gm=hd.sort,gr=mi,ca=m.forwardRef(({className:s,...n},a)=>e.jsx(pn,{ref:a,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));ca.displayName=pn.displayName;const nt=m.forwardRef(({className:s,...n},a)=>e.jsx(fn,{ref:a,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));nt.displayName=fn.displayName;const jm=m.forwardRef(({className:s,...n},a)=>e.jsx(gn,{ref:a,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));jm.displayName=gn.displayName;const W=ui,ps=bi,Y=hi,K=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(jn,{ref:l,className:y("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...a,children:[n,e.jsx(xi,{asChild:!0,children:e.jsx(na,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=jn.displayName;const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(vn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(pi,{className:"h-4 w-4"})}));jr.displayName=vn.displayName;const vr=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(na,{className:"h-4 w-4"})}));vr.displayName=bn.displayName;const B=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(fi,{children:e.jsxs(yn,{ref:r,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:a,...l,children:[e.jsx(jr,{}),e.jsx(gi,{className:y("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(vr,{})]})}));B.displayName=yn.displayName;const vm=m.forwardRef(({className:s,...n},a)=>e.jsx(_n,{ref:a,className:y("px-2 py-1.5 text-sm font-semibold",s),...n}));vm.displayName=_n.displayName;const U=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Nn,{ref:l,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ji,{children:e.jsx(Ds,{className:"h-4 w-4"})})}),e.jsx(vi,{children:n})]}));U.displayName=Nn.displayName;const bm=m.forwardRef(({className:s,...n},a)=>e.jsx(wn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));bm.displayName=wn.displayName;function Vs({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(yi,{showOutsideDays:a,className:y("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:y($s({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:y("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",l.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:y($s({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx(Cn,{className:y("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(aa,{className:y("h-4 w-4",r),...c})},...l})}Vs.displayName="Calendar";const as=Ni,ns=wi,We=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(_i,{children:e.jsx(Sn,{ref:r,align:n,sideOffset:a,className:y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...l})}));We.displayName=Sn.displayName;const fs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Qs=s=>(s/100).toFixed(2),ym=({active:s,payload:n,label:a})=>{const{t:l}=M();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:a}),n.map((r,c)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[l(r.name),":"]}),e.jsx("span",{className:"font-medium",children:r.name.includes(l("dashboard:overview.amount"))?`¥${Qs(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},_m=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],Nm=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=$e(a,7);break;case"30d":l=$e(a,30);break;case"90d":l=$e(a,90);break;case"180d":l=$e(a,180);break;case"365d":l=$e(a,365);break;default:l=$e(a,30)}return{startDate:l,endDate:a}};function wm(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:$e(new Date,7),to:new Date}),{t:o}=M(),{startDate:u,endDate:h}=Nm(a,r),{data:i}=se({queryKey:["orderStat",{start_date:Ue(u,"yyyy-MM-dd"),end_date:Ue(h,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await xd({start_date:Ue(u,"yyyy-MM-dd"),end_date:Ue(h,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(qe,{children:[e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(bs,{children:o("dashboard:overview.title")}),e.jsxs(tt,{children:[i?.summary.start_date," ",o("dashboard:overview.to")," ",i?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(W,{value:a,onValueChange:d=>l(d),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(Y,{placeholder:o("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:_m.map(d=>e.jsx(U,{value:d.value,children:o(d.label)},d.value))})]}),a==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r?.from?r.to?e.jsxs(e.Fragment,{children:[Ue(r.from,"yyyy-MM-dd")," -"," ",Ue(r.to,"yyyy-MM-dd")]}):Ue(r.from,"yyyy-MM-dd"):o("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Vs,{mode:"range",defaultMonth:r?.from,selected:{from:r?.from,to:r?.to},onSelect:d=>{d?.from&&d?.to&&c({from:d.from,to:d.to})},numberOfMonths:2})})]})]}),e.jsx(gr,{value:s,onValueChange:d=>n(d),children:e.jsxs(ca,{children:[e.jsx(nt,{value:"amount",children:o("dashboard:overview.amount")}),e.jsx(nt,{value:"count",children:o("dashboard:overview.count")})]})})]})]})}),e.jsxs(ts,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:o("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(i?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("dashboard:overview.totalTransactions",{count:i?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o("dashboard:overview.avgOrderAmount")," ¥",Qs(i?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:o("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(i?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("dashboard:overview.totalTransactions",{count:i?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o("dashboard:overview.commissionRate")," ",i?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Ci,{width:"100%",height:"100%",children:e.jsxs(Si,{data:i?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:fs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:fs.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:fs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:fs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(ki,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Ue(new Date(d),"MM-dd",{locale:Ri})}),e.jsx(Pi,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${Qs(d)}`:o("dashboard:overview.transactions",{count:d})}),e.jsx(Ti,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Di,{content:e.jsx(ym,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{type:"monotone",dataKey:"paid_total",name:o("dashboard:overview.orderAmount"),stroke:fs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ca,{type:"monotone",dataKey:"commission_total",name:o("dashboard:overview.commissionAmount"),stroke:fs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{dataKey:"paid_count",name:o("dashboard:overview.orderCount"),fill:fs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Sa,{dataKey:"commission_count",name:o("dashboard:overview.commissionCount"),fill:fs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function Ie({className:s,...n}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...n})}function Cm(){return e.jsxs(qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ie,{className:"h-4 w-[120px]"}),e.jsx(Ie,{className:"h-4 w-4"})]}),e.jsxs(ts,{children:[e.jsx(Ie,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4"}),e.jsx(Ie,{className:"h-4 w-[100px]"})]})]})]})}function Sm(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:8}).map((s,n)=>e.jsx(Cm,{},n))})}var Q=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(Q||{});const Ys={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Js={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var He=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(He||{}),ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(ne||{});const ut={0:"待确认",1:"发放中",2:"有效",3:"无效"},ht={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var de=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(de||{});const km={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ye=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(ye||{});const Ps=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ls={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var js=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(js||{});const Pm={1:"按金额优惠",2:"按比例优惠"};var et=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(et||{}),Xe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Xe||{});function gs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:o,className:u}){return e.jsxs(qe,{className:y("transition-colors",c&&"cursor-pointer hover:bg-muted/50",o&&"border-primary/50",u),onClick:c,children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(bs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Li,{className:y("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("ml-1 text-xs",l.isPositive?"text-emerald-500":"text-red-500"),children:[l.isPositive?"+":"-",Math.abs(l.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:l.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]})}function Tm({className:s}){const n=os(),{t:a}=M(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await pd()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Sm,{});const c=()=>{const o=new URLSearchParams;o.set("commission_status",ne.PENDING.toString()),o.set("status",Q.COMPLETED.toString()),o.set("commission_balance","gt:0"),n(`/finance/order?${o.toString()}`)};return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(gs,{title:a("dashboard:stats.todayIncome"),value:ks(l.todayIncome),icon:e.jsx(Ei,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.monthlyIncome"),value:ks(l.currentMonthIncome),icon:e.jsx(Ii,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Mi,{className:y("h-4 w-4",l.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:l.ticketPendingTotal>0?a("dashboard:stats.hasPendingTickets"):a("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:l.ticketPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Oi,{className:y("h-4 w-4",l.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:l.commissionPendingTotal>0?a("dashboard:stats.hasPendingCommission"):a("dashboard:stats.noPendingCommission"),onClick:c,highlight:l.commissionPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Ht,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Ht,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(gs,{title:a("dashboard:stats.monthlyUpload"),value:Ze(l.monthTraffic.upload),icon:e.jsx(qt,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.upload)})}),e.jsx(gs,{title:a("dashboard:stats.monthlyDownload"),value:Ze(l.monthTraffic.download),icon:e.jsx(Vi,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.download)})})]})}const rt=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(kn,{ref:l,className:y("relative overflow-hidden",s),...a,children:[e.jsx(Ai,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ct,{}),e.jsx(Fi,{})]}));rt.displayName=kn.displayName;const Ct=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Pn,{ref:l,orientation:n,className:y("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...a,children:e.jsx(zi,{className:"relative flex-1 rounded-full bg-border"})}));Ct.displayName=Pn.displayName;const Zt={today:{getValue:()=>{const s=$i();return{start:s,end:Hi(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:$e(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:$e(s,30),end:s}}},custom:{getValue:()=>null}};function Aa({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=M(),c={today:r("dashboard:trafficRank.today"),last7days:r("dashboard:trafficRank.last7days"),last30days:r("dashboard:trafficRank.last30days"),custom:r("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(W,{value:s,onValueChange:a,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(Zt).map(([o])=>e.jsx(U,{value:o,children:c[o]},o))})]}),s==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[Ue(n.from,"yyyy-MM-dd")," -"," ",Ue(n.to,"yyyy-MM-dd")]}):Ue(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Vs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:o=>{o?.from&&o?.to&&l({from:o.from,to:o.to})},numberOfMonths:2})})]})]})}const As=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Dm({className:s}){const{t:n}=M(),[a,l]=m.useState("today"),[r,c]=m.useState({from:$e(new Date,7),to:new Date}),[o,u]=m.useState("today"),[h,i]=m.useState({from:$e(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:Zt[a].getValue(),[a,r]),f=m.useMemo(()=>o==="custom"?{start:h.from,end:h.to}:Zt[o].getValue(),[o,h]),{data:P}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Va({type:"node",start_time:fe.round(d.start.getTime()/1e3),end_time:fe.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:I}=se({queryKey:["userTrafficRank",f.start,f.end],queryFn:()=>Va({type:"user",start_time:fe.round(f.start.getTime()/1e3),end_time:fe.round(f.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(qe,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx(Ui,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Aa,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(ka,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:P?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:P.data.map(p=>e.jsx(oe,{delayDuration:200,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:p.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?e.jsx(Gt,{className:"mr-1 h-3 w-3"}):e.jsx(Kt,{className:"mr-1 h-3 w-3"}),Math.abs(p.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${p.value/P.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(p.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?"+":"",p.change,"%"]})]})})]})},p.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(qe,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx(Ht,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Aa,{selectedRange:o,customDateRange:h,onRangeChange:u,onCustomRangeChange:i}),e.jsx(ka,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:I?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:I.data.map(p=>e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:p.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?e.jsx(Gt,{className:"mr-1 h-3 w-3"}):e.jsx(Kt,{className:"mr-1 h-3 w-3"}),Math.abs(p.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${p.value/I.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(p.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(p.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",p.change>=0?"text-green-600":"text-red-600"),children:[p.change>=0?"+":"",p.change,"%"]})]})})]})},p.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const Rm=Ts("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function H({className:s,variant:n,...a}){return e.jsx("div",{className:y(Rm({variant:n}),s),...a})}const vt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Tn,{ref:l,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(qi,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));vt.displayName=Tn.displayName;function Em(){const{t:s}=M(),[n,a]=m.useState(null),[l,r]=m.useState(null),[c,o]=m.useState(!0),[u,h]=m.useState(!1),i=async()=>{try{h(!0);const[P,I]=await Promise.all([Oa.getSystemStatus(),Oa.getQueueStats()]);a(P.data),r(I.data)}catch(P){console.error("Error fetching system data:",P)}finally{o(!1),h(!1)}};m.useEffect(()=>{i();const P=setInterval(i,3e4);return()=>clearInterval(P)},[]);const d=()=>{i()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(ra,{className:"h-6 w-6 animate-spin"})});const f=P=>P?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Rn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Gi,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(tt,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Ki,{className:y("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f(l?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(H,{variant:l?.status?"secondary":"destructive",children:l?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:l?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.recentJobs||0}),e.jsx(vt,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.jobsPerMinute||0}),e.jsx(vt,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(qe,{children:[e.jsxs(ss,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Bi,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(tt,{children:s("dashboard:queue.details.description")})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:l?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:l?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[l?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[l?.processes||0," /"," ",(l?.processes||0)+(l?.pausedMasters||0)]})]}),e.jsx(vt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Im(){const{t:s}=M();return e.jsxs(we,{children:[e.jsxs(Ce,{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(De,{}),e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsx(ke,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Tm,{}),e.jsx(wm,{}),e.jsx(Dm,{}),e.jsx(Em,{})]})})})]})}const Mm=Object.freeze(Object.defineProperty({__proto__:null,default:Im},Symbol.toStringTag,{value:"Module"})),be=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(En,{ref:r,decorative:a,orientation:n,className:y("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));be.displayName=En.displayName;function Om({className:s,items:n,...a}){const{pathname:l}=ea(),r=os(),[c,o]=m.useState(l??"/settings"),u=i=>{o(i),r(i)},{t:h}=M("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(W,{value:c,onValueChange:u,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(i=>e.jsx(U,{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:h(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),...a,children:n.map(i=>e.jsxs(Rs,{to:i.href,className:y(Hs({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}),h(i.title)]},i.href))})})]})}const Vm=[{title:"site.title",key:"site",icon:e.jsx(Wi,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(dn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(mn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Yi,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(cn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Ji,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Qi,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(on,{size:18}),href:"/config/system/app",description:"app.description"}];function Lm(){const{t:s}=M("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{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(be,{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(Om,{items:Vm})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(sa,{})})})]})]})]})}const Am=Object.freeze(Object.defineProperty({__proto__:null,default:Lm},Symbol.toStringTag,{value:"Module"})),q=m.forwardRef(({className:s,...n},a)=>e.jsx(In,{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),...n,ref:a,children:e.jsx(Zi,{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")})}));q.displayName=In.displayName;const Cs=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:y("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}));Cs.displayName="Textarea";const Fm=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 zm(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>us("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Os()}),o=ce({resolver:ue(Fm),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=es({mutationFn:hs,onSuccess:d=>{d.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(r?.data?.site){const d=r?.data?.site;Object.entries(d).forEach(([f,P])=>{o.setValue(f,P)}),l.current=d}},[r]);const h=m.useCallback(fe.debounce(async d=>{if(!fe.isEqual(d,l.current)){a(!0);try{const f=Object.entries(d).reduce((P,[I,p])=>(P[I]=p===null?"":p,P),{});await u(f),l.current=d}finally{a(!1)}}},1e3),[u]),i=m.useCallback(d=>{h(d)},[h]);return m.useEffect(()=>{const d=o.watch(f=>{i(f)});return()=>d.unsubscribe()},[o.watch,i]),e.jsx(he,{...o,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:o.control,name:"app_name",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.siteName.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"app_description",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.siteDescription.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"app_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.siteUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"force_https",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(O,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:!!d.value,onCheckedChange:f=>{d.onChange(Number(f)),i(o.getValues())}})})]})}),e.jsx(j,{control:o.control,name:"logo",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.logo.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"subscribe_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(Cs,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.subscribeUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"tos_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.tosUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"stop_register",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(O,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:!!d.value,onCheckedChange:f=>{d.onChange(Number(f)),i(o.getValues())}})})]})}),e.jsx(j,{control:o.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(W,{value:d.value?.toString(),onValueChange:f=>{d.onChange(Number(f)),i(o.getValues())},children:[e.jsx(K,{children:e.jsx(Y,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(f=>e.jsx(U,{value:f.id.toString(),children:f.name},f.id.toString()))]})]})}),e.jsx(O,{children:s("site.form.tryOut.description")}),e.jsx(D,{})]})}),!!o.watch("try_out_plan_id")&&e.jsx(j,{control:o.control,name:"try_out_hour",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.tryOut.duration.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"currency",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.currency.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"currency_symbol",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(O,{children:s("site.form.currencySymbol.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Um(){const{t:s}=M("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(be,{}),e.jsx(zm,{})]})}const $m=Object.freeze(Object.defineProperty({__proto__:null,default:Um},Symbol.toStringTag,{value:"Module"})),Hm=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()}),qm={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 Gm(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Hm),defaultValues:qm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>us("safe")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data.safe){const i=c.data.safe;Object.entries(i).forEach(([d,f])=>{typeof f=="number"?r.setValue(d,String(f)):r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"email_verify",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(O,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"email_gmail_limit_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(O,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"safe_mode_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(O,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"secure_path",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.securePath.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"email_whitelist_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(O,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(j,{control:r.control,name:"email_whitelist_suffix",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(Cs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...i,value:(i.value||[]).join(` `),onChange:d=>{const f=d.target.value.split(` `).filter(Boolean);i.onChange(f),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(O,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"recaptcha_key",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.key.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.recaptcha.key.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_site_key",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(D,{})]})})]}),e.jsx(j,{control:r.control,name:"register_limit_by_ip_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(O,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"register_limit_count",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.registerLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"register_limit_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(D,{})]})})]}),e.jsx(j,{control:r.control,name:"password_limit_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(O,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"password_limit_count",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"password_limit_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(O,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function Km(){const{t:s}=M("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(be,{}),e.jsx(Gm,{})]})}const Bm=Object.freeze(Object.defineProperty({__proto__:null,default:Km},Symbol.toStringTag,{value:"Module"})),Wm=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")}),Ym={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 Jm(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Wm),defaultValues:Ym,mode:"onBlur"}),{data:c}=se({queryKey:["settings","subscribe"],queryFn:()=>us("subscribe")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.subscribe){const i=c?.data?.subscribe;Object.entries(i).forEach(([d,f])=>{r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"plan_change_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(O,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"reset_traffic_method",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(U,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(U,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(U,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(U,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(O,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"surplus_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(O,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"new_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.new_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"renew_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("renew_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"change_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.change_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"subscribe_path",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:"subscribe",...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.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(D,{})]})}),e.jsx(j,{control:r.control,name:"show_info_to_server_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(O,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"show_protocol_to_server_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(O,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Qm(){const{t:s}=M("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(be,{}),e.jsx(Jm,{})]})}const Zm=Object.freeze(Object.defineProperty({__proto__:null,default:Qm},Symbol.toStringTag,{value:"Module"})),Xm=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)}),eu={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 su(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Xm),defaultValues:eu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","invite"],queryFn:()=>us("invite")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.invite){const i=c?.data?.invite;Object.entries(i).forEach(([d,f])=>{typeof f=="number"?r.setValue(d,String(f)):r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"invite_force",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(O,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"invite_commission",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.invite_commission.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("invite.invite_commission.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"invite_gen_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.invite_gen_limit.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("invite.invite_gen_limit.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"invite_never_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(O,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_first_time_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(O,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_auto_check_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(O,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_method",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_method.placeholder"),...i,value:Array.isArray(i.value)?i.value.join(","):"",onChange:d=>{const f=d.target.value.split(",").filter(Boolean);i.onChange(f),h(r.getValues())}})}),e.jsx(O,{children:s("invite.commission_withdraw_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"withdraw_close_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(O,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(O,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"commission_distribution_l1",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:s("invite.commission_distribution.l1")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l2",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:s("invite.commission_distribution.l2")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l3",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:s("invite.commission_distribution.l3")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function tu(){const{t:s}=M("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(be,{}),e.jsx(su,{})]})}const au=Object.freeze(Object.defineProperty({__proto__:null,default:tu},Symbol.toStringTag,{value:"Module"})),nu=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()}),ru={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function lu(){const{data:s}=se({queryKey:["settings","frontend"],queryFn:()=>us("frontend")}),n=ce({resolver:ue(nu),defaultValues:ru,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([r,c])=>{n.setValue(r,c)})}},[s]);function a(l){hs(l).then(({data:r})=>{r&&$.success("更新成功")})}return e.jsx(he,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(j,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:"边栏风格"}),e.jsx(O,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(q,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:"头部风格"}),e.jsx(O,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(q,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(g,{children:[e.jsx(v,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:y(Hs({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(na,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(O,{children:"主题色"}),e.jsx(D,{})]})}),e.jsx(j,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(g,{children:[e.jsx(v,{children:"背景"}),e.jsx(_,{children:e.jsx(T,{placeholder:"请输入图片地址",...l})}),e.jsx(O,{children:"将会在后台登录页面进行展示。"}),e.jsx(D,{})]})}),e.jsx(R,{type:"submit",children:"保存设置"})]})})}function iu(){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(be,{}),e.jsx(lu,{})]})}const ou=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),cu=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()}),du={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function mu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(cu),defaultValues:du,mode:"onBlur"}),{data:c}=se({queryKey:["settings","server"],queryFn:()=>us("server")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:d=>{d.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(c?.data.server){const d=c.data.server;Object.entries(d).forEach(([f,P])=>{r.setValue(f,P)}),l.current=d}},[c]);const u=m.useCallback(fe.debounce(async d=>{if(!fe.isEqual(d,l.current)){a(!0);try{await o(d),l.current=d}finally{a(!1)}}},1e3),[o]),h=m.useCallback(d=>{u(d)},[u]);m.useEffect(()=>{const d=r.watch(f=>{h(f)});return()=>d.unsubscribe()},[r.watch,h]);const i=()=>{const d=Math.floor(Math.random()*17)+16,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let P="";for(let I=0;Ie.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.server_token.title")}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:f=>{f.preventDefault(),i()},children:e.jsx(Xi,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(te,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(O,{children:s("server.server_token.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:f=>{const P=f.target.value?Number(f.target.value):null;d.onChange(P)}})}),e.jsx(O,{children:s("server.server_pull_interval.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:f=>{const P=f.target.value?Number(f.target.value):null;d.onChange(P)}})}),e.jsx(O,{children:s("server.server_push_interval.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(W,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(U,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(O,{children:s("server.device_limit_mode.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function uu(){const{t:s}=M("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(be,{}),e.jsx(mu,{})]})}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:uu},Symbol.toStringTag,{value:"Module"}));function xu({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(xe,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Rn,{className:"h-5 w-5 text-destructive"}),e.jsx(je,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Te,{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:a.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:a.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:a.template_name})]})]}),a.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:a.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(rt,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:a.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:a.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:a.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:a.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:a.config.from.address?`${a.config.from.address}${a.config.from.name?` (${a.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:a.config.username||"未设置"})]})})})]})]})]})})}const pu=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.string().regex(/^\d+$/).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 fu(){const{t:s}=M("settings"),[n,a]=m.useState(null),[l,r]=m.useState(!1),c=m.useRef(null),[o,u]=m.useState(!1),h=ce({resolver:ue(pu),defaultValues:{},mode:"onBlur"}),{data:i}=se({queryKey:["settings","email"],queryFn:()=>us("email")}),{data:d}=se({queryKey:["emailTemplate"],queryFn:()=>xm()}),{mutateAsync:f}=es({mutationFn:hs,onSuccess:k=>{k.data&&$.success(s("common.autoSaved"))}}),{mutate:P,isPending:I}=es({mutationFn:pm,onMutate:()=>{a(null),r(!1)},onSuccess:k=>{a(k.data),r(!0),k.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(i?.data.email){const k=i.data.email;Object.entries(k).forEach(([b,w])=>{h.setValue(b,w)}),c.current=k}},[i]);const p=m.useCallback(fe.debounce(async k=>{if(!fe.isEqual(k,c.current)){u(!0);try{await f(k),c.current=k}finally{u(!1)}}},1e3),[f]),N=m.useCallback(k=>{p(k)},[p]);return m.useEffect(()=>{const k=h.watch(b=>{N(b)});return()=>k.unsubscribe()},[h.watch,N]),e.jsxs(e.Fragment,{children:[e.jsx(he,{...h,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:h.control,name:"email_host",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_host.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(O,{children:s("email.email_host.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_port",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_port.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("common.placeholder"),...k,value:k.value||"",onChange:b=>{const w=b.target.value?Number(b.target.value):null;k.onChange(w)}})}),e.jsx(O,{children:s("email.email_port.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_encryption",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(W,{onValueChange:k.onChange,value:k.value||"none",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(U,{value:"none",children:s("email.email_encryption.none")}),e.jsx(U,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(U,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(O,{children:s("email.email_encryption.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_username",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_username.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(O,{children:s("email.email_username.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_password",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email_password.title")}),e.jsx(_,{children:e.jsx(T,{type:"password",placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(O,{children:s("email_password.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_from_address",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email_from.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(O,{children:s("email_from.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_template",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email_template.title")}),e.jsxs(W,{onValueChange:b=>{k.onChange(b),N(h.getValues())},value:k.value||void 0,children:[e.jsx(_,{children:e.jsx(K,{className:"w-[200px]",children:e.jsx(Y,{placeholder:s("email_template.placeholder")})})}),e.jsx(B,{children:d?.data?.map(b=>e.jsx(U,{value:b,children:b},b))})]}),e.jsx(O,{children:s("email_template.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"remind_mail_enable",render:({field:k})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("remind_mail.title")}),e.jsx(O,{children:s("remind_mail.description")})]}),e.jsx(_,{children:e.jsx(q,{checked:k.value||!1,onCheckedChange:b=>{k.onChange(b),N(h.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{onClick:()=>P(),loading:I,disabled:I,children:s(I?"test.sending":"test.title")})})]})}),o&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(xu,{open:l,onOpenChange:r,result:n})]})}function gu(){const{t:s}=M("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(be,{}),e.jsx(fu,{})]})}const ju=Object.freeze(Object.defineProperty({__proto__:null,default:gu},Symbol.toStringTag,{value:"Module"})),vu=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),bu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function yu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(vu),defaultValues:bu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","telegram"],queryFn:()=>us("telegram")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:f=>{f.data&&$.success(s("common.autoSaved"))}}),{mutate:u,isPending:h}=es({mutationFn:fm,onSuccess:f=>{f.data&&$.success(s("telegram.webhook_success"))}});m.useEffect(()=>{if(c?.data.telegram){const f=c.data.telegram;Object.entries(f).forEach(([P,I])=>{r.setValue(P,I)}),l.current=f}},[c]);const i=m.useCallback(fe.debounce(async f=>{if(!fe.isEqual(f,l.current)){a(!0);try{await o(f),l.current=f}finally{a(!1)}}},1e3),[o]),d=m.useCallback(f=>{i(f)},[i]);return m.useEffect(()=>{const f=r.watch(P=>{d(P)});return()=>f.unsubscribe()},[r.watch,d]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"telegram_bot_token",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("telegram.bot_token.placeholder"),...f,value:f.value||""})}),e.jsx(O,{children:s("telegram.bot_token.description")}),e.jsx(D,{})]})}),r.watch("telegram_bot_token")&&e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(R,{loading:h,disabled:h,onClick:()=>u(),children:s(h?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(O,{children:s("telegram.webhook.description")}),e.jsx(D,{})]}),e.jsx(j,{control:r.control,name:"telegram_bot_enable",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(O,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(q,{checked:f.value||!1,onCheckedChange:P=>{f.onChange(P),d(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"telegram_discuss_link",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("telegram.discuss_link.placeholder"),...f,value:f.value||""})}),e.jsx(O,{children:s("telegram.discuss_link.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function _u(){const{t:s}=M("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(be,{}),e.jsx(yu,{})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"})),wu=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()}),Cu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Su(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(wu),defaultValues:Cu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","app"],queryFn:()=>us("app")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(c?.data.app){const i=c.data.app;Object.entries(i).forEach(([d,f])=>{r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"windows_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("app.windows.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"windows_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("app.windows.download.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"macos_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("app.macos.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"macos_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("app.macos.download.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"android_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.android.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("app.android.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"android_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.android.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(O,{children:s("app.android.download.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function ku(){const{t:s}=M("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(be,{}),e.jsx(Su,{})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:ku},Symbol.toStringTag,{value:"Module"})),da=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:y("w-full caption-bottom text-sm",s),...n})}));da.displayName="Table";const ma=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:y("[&_tr]:border-b",s),...n}));ma.displayName="TableHeader";const ua=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:y("[&_tr:last-child]:border-0",s),...n}));ua.displayName="TableBody";const Tu=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Tu.displayName="TableFooter";const vs=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));vs.displayName="TableRow";const ha=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:y("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));ha.displayName="TableHead";const Us=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:y("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Us.displayName="TableCell";const Du=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:y("mt-4 text-sm text-muted-foreground",s),...n}));Du.displayName="TableCaption";function Ru({table:s}){const[n,a]=m.useState("");m.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const l=r=>{const c=parseInt(r);!isNaN(c)&&c>=1&&c<=s.getPageCount()?s.setPageIndex(c-1):a((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex-1 text-sm text-muted-foreground",children:["已选择 ",s.getFilteredSelectedRowModel().rows.length," 项, 共"," ",s.getFilteredRowModel().rows.length," 项"]}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"每页显示"}),e.jsxs(W,{value:`${s.getState().pagination.pageSize}`,onValueChange:r=>{s.setPageSize(Number(r))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(r=>e.jsx(U,{value:`${r}`,children:r},r))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:"第"}),e.jsx(T,{type:"text",value:n,onChange:r=>a(r.target.value),onBlur:r=>l(r.target.value),onKeyDown:r=>{r.key==="Enter"&&l(r.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsxs("span",{children:["页,共 ",s.getPageCount()," 页"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到第一页"}),e.jsx(eo,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"上一页"}),e.jsx(Cn,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"下一页"}),e.jsx(aa,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到最后一页"}),e.jsx(so,{className:"h-4 w-4"})]})]})]})]})}function Ye({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:o,onDrop:u,showPagination:h=!0,isLoading:i=!1}){const d=m.useRef(null),f=s.getAllColumns().filter(N=>N.getIsPinned()==="left"),P=s.getAllColumns().filter(N=>N.getIsPinned()==="right"),I=N=>f.slice(0,N).reduce((k,b)=>k+(b.getSize()??0),0),p=N=>P.slice(N+1).reduce((k,b)=>k+(b.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:d,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(da,{children:[e.jsx(ma,{children:s.getHeaderGroups().map(N=>e.jsx(vs,{className:"hover:bg-transparent",children:N.headers.map((k,b)=>{const w=k.column.getIsPinned()==="left",S=k.column.getIsPinned()==="right",C=w?I(f.indexOf(k.column)):void 0,E=S?p(P.indexOf(k.column)):void 0;return e.jsx(ha,{colSpan:k.colSpan,style:{width:k.getSize(),...w&&{left:C},...S&&{right:E}},className:y("h-11 bg-card px-4 text-muted-foreground",(w||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",w&&"before:right-0",S&&"before:left-0"]),children:k.isPlaceholder?null:bt(k.column.columnDef.header,k.getContext())},k.id)})},N.id))}),e.jsx(ua,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((N,k)=>e.jsx(vs,{"data-state":N.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:b=>l?.(b,k),onDragEnd:r,onDragOver:c,onDragLeave:o,onDrop:b=>u?.(b,k),children:N.getVisibleCells().map((b,w)=>{const S=b.column.getIsPinned()==="left",C=b.column.getIsPinned()==="right",E=S?I(f.indexOf(b.column)):void 0,A=C?p(P.indexOf(b.column)):void 0;return e.jsx(Us,{style:{width:b.column.getSize(),...S&&{left:E},...C&&{right:A}},className:y("bg-card",(S||C)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",S&&"before:right-0",C&&"before:left-0"]),children:bt(b.column.columnDef.cell,b.getContext())},b.id)})},N.id)):e.jsx(vs,{children:e.jsx(Us,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:"暂无数据"})})})]})})}),h&&e.jsx(Ru,{table:s})]})}const Eu=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(a=>!a||/^https?:\/\/\S+/.test(a),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())}),Fa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function br({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Fa}){const{t:r}=M("payment"),[c,o]=m.useState(!1),[u,h]=m.useState(!1),[i,d]=m.useState([]),[f,P]=m.useState([]),I=Eu(r),p=ce({resolver:ue(I),defaultValues:l,mode:"onChange"}),N=p.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:w}=await Ed();d(w)})()},[c]),m.useEffect(()=>{if(!N||!c)return;(async()=>{const w={payment:N,...a==="edit"&&{id:Number(p.getValues("id"))}};Id(w).then(({data:S})=>{P(S);const C=S.reduce((E,A)=>(A.field_name&&(E[A.field_name]=A.value??""),E),{});p.setValue("config",C)})})()},[N,c,p,a]);const k=async b=>{h(!0);try{(await Md(b)).data&&($.success(r("form.messages.success")),p.reset(Fa),s(),o(!1))}finally{h(!1)}};return e.jsxs(ge,{open:c,onOpenChange:o,children:[e.jsx(Oe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(xe,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(he,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(k),className:"space-y-4",children:[e.jsx(j,{control:p.control,name:"name",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:r("form.fields.name.placeholder"),...b})}),e.jsx(O,{children:r("form.fields.name.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"icon",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.icon.label")}),e.jsx(_,{children:e.jsx(T,{...b,value:b.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(O,{children:r("form.fields.icon.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"notify_domain",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.notify_domain.label")}),e.jsx(_,{children:e.jsx(T,{...b,value:b.value||"",placeholder:r("form.fields.notify_domain.placeholder")})}),e.jsx(O,{children:r("form.fields.notify_domain.description")}),e.jsx(D,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:p.control,name:"handling_fee_percent",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"handling_fee_fixed",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(D,{})]})})]}),e.jsx(j,{control:p.control,name:"payment",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.payment.label")}),e.jsxs(W,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(B,{children:i.map(w=>e.jsx(U,{value:w,children:w},w))})]}),e.jsx(O,{children:r("form.fields.payment.description")}),e.jsx(D,{})]})}),f.length>0&&e.jsx("div",{className:"space-y-4",children:f.map(b=>e.jsx(j,{control:p.control,name:`config.${b.field_name}`,render:({field:w})=>e.jsxs(g,{children:[e.jsx(v,{children:b.label}),e.jsx(_,{children:e.jsx(T,{...w,value:w.value||""})}),e.jsx(D,{})]})},b.field_name))}),e.jsxs(Ve,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",disabled:u,children:r("form.buttons.submit")})]})]})})]})]})}function V({column:s,title:n,tooltip:a,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(R,{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:n}),a&&e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(Pa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(te,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(Gt,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Kt,{className:"h-4 w-4 text-foreground/70"}):e.jsx(to,{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:n}),a&&e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(te,{children:a})]})})]})}const Iu=ao,Mu=no,Ou=ro,yr=m.forwardRef(({className:s,...n},a)=>e.jsx(Mn,{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),...n,ref:a}));yr.displayName=Mn.displayName;const _r=m.forwardRef(({className:s,...n},a)=>e.jsxs(Ou,{children:[e.jsx(yr,{}),e.jsx(On,{ref:a,className:y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));_r.displayName=On.displayName;const Nr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...n});Nr.displayName="AlertDialogHeader";const wr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});wr.displayName="AlertDialogFooter";const Cr=m.forwardRef(({className:s,...n},a)=>e.jsx(Vn,{ref:a,className:y("text-lg font-semibold",s),...n}));Cr.displayName=Vn.displayName;const Sr=m.forwardRef(({className:s,...n},a)=>e.jsx(Ln,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Sr.displayName=Ln.displayName;const kr=m.forwardRef(({className:s,...n},a)=>e.jsx(An,{ref:a,className:y($s(),s),...n}));kr.displayName=An.displayName;const Pr=m.forwardRef(({className:s,...n},a)=>e.jsx(Fn,{ref:a,className:y($s({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Pr.displayName=Fn.displayName;function Je({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:o="default",className:u}){return e.jsxs(Iu,{children:[e.jsx(Mu,{asChild:!0,children:n}),e.jsxs(_r,{className:y("sm:max-w-[425px]",u),children:[e.jsxs(Nr,{children:[e.jsx(Cr,{children:a}),e.jsx(Sr,{children:l})]}),e.jsxs(wr,{children:[e.jsx(Pr,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r})}),e.jsx(kr,{asChild:!0,children:e.jsx(R,{variant:o,onClick:s,children:c})})]})]})]})}const Tr=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"})}),Vu=({refetch:s,isSortMode:n=!1})=>{const{t:a}=M("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(V,{column:l,title:a("table.columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",children:l.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:l})=>e.jsx(V,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(q,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await Vd({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(V,{column:l,title:a("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(V,{column:l,title:a("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(V,{column:l,title:a("table.columns.notify_url")}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{className:"ml-1",children:e.jsx(Tr,{className:"h-4 w-4"})}),e.jsx(te,{children:a("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(V,{className:"justify-end",column:l,title:a("table.columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(br,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{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:l.original}),e.jsx(Je,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await Od({id:l.original.id});r&&s()},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:a("table.actions.delete.title")})]})})]}),size:100}]};function Lu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=M("payment"),c=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:r("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(br,{refetch:n}),e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:o=>s.getColumn("name")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),c&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Le,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Au(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[o,u]=m.useState([]),[h,i]=m.useState({"drag-handle":!1}),[d,f]=m.useState({pageSize:20,pageIndex:0}),{refetch:P}=se({queryKey:["paymentList"],queryFn:async()=>{const{data:b}=await Rd();return u(b?.map(w=>({...w,enable:!!w.enable}))||[]),b}});m.useEffect(()=>{i({"drag-handle":r,actions:!r}),f({pageSize:r?99999:10,pageIndex:0})},[r]);const I=(b,w)=>{r&&(b.dataTransfer.setData("text/plain",w.toString()),b.currentTarget.classList.add("opacity-50"))},p=(b,w)=>{if(!r)return;b.preventDefault(),b.currentTarget.classList.remove("bg-muted");const S=parseInt(b.dataTransfer.getData("text/plain"));if(S===w)return;const C=[...o],[E]=C.splice(S,1);C.splice(w,0,E),u(C)},N=async()=>{r?Ld({ids:o.map(b=>b.id)}).then(()=>{P(),c(!1),$.success("排序保存成功")}):c(!0)},k=Ae({data:o,columns:Vu({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:h,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:i,getCoreRowModel:Fe(),getFilteredRowModel:Ge(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(Ye,{table:k,toolbar:b=>e.jsx(Lu,{table:b,refetch:P,saveOrder:N,isSortMode:r}),draggable:r,onDragStart:I,onDragEnd:b=>b.currentTarget.classList.remove("opacity-50"),onDragOver:b=>{b.preventDefault(),b.currentTarget.classList.add("bg-muted")},onDragLeave:b=>b.currentTarget.classList.remove("bg-muted"),onDrop:p,showPagination:!r})}function Fu(){const{t:s}=M("payment");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{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(Au,{})})]})]})}const zu=Object.freeze(Object.defineProperty({__proto__:null,default:Fu},Symbol.toStringTag,{value:"Module"})),Uu=(s,n)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(T,{placeholder:s.placeholder,...n});break;case"textarea":a=e.jsx(Cs,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:y($s({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:a=null;break}return a};function $u({themeKey:s,themeInfo:n}){const{t:a}=M("theme"),[l,r]=m.useState(!1),[c,o]=m.useState(!1),[u,h]=m.useState(!1),i=ce({defaultValues:n.configs.reduce((P,I)=>(P[I.field_name]="",P),{})}),d=async()=>{o(!0),gd(s).then(({data:P})=>{Object.entries(P).forEach(([I,p])=>{i.setValue(I,p)})}).finally(()=>{o(!1)})},f=async P=>{h(!0),jd(s,P).then(()=>{$.success(a("config.success")),r(!1)}).finally(()=>{h(!1)})};return e.jsxs(ge,{open:l,onOpenChange:P=>{r(P),P?d():i.reset()},children:[e.jsx(Oe,{asChild:!0,children:e.jsx(R,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(xe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:a("config.title",{name:n.name})}),e.jsx(Te,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ra,{className:"h-6 w-6 animate-spin"})}):e.jsx(he,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(f),className:"space-y-4",children:[n.configs.map(P=>e.jsx(j,{control:i.control,name:P.field_name,render:({field:I})=>e.jsxs(g,{children:[e.jsx(v,{children:P.label}),e.jsx(_,{children:Uu(P,I)}),e.jsx(D,{})]})},P.field_name)),e.jsxs(Ve,{className:"mt-6 gap-2",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(R,{type:"submit",loading:u,children:a("config.save")})]})]})})]})]})}function Hu(){const{t:s}=M("theme"),[n,a]=m.useState(null),[l,r]=m.useState(!1),[c,o]=m.useState(!1),[u,h]=m.useState(!1),[i,d]=m.useState(null),f=m.useRef(null),[P,I]=m.useState(0),{data:p,isLoading:N,refetch:k}=se({queryKey:["themeList"],queryFn:async()=>{const{data:z}=await fd();return z}}),b=async z=>{a(z),yd({frontend_theme:z}).then(()=>{$.success("主题切换成功"),k()}).finally(()=>{a(null)})},w=async z=>{if(!z.name.endsWith(".zip")){$.error(s("upload.error.format"));return}r(!0),vd(z).then(()=>{$.success("主题上传成功"),o(!1),k()}).finally(()=>{r(!1),f.current&&(f.current.value="")})},S=z=>{z.preventDefault(),z.stopPropagation(),z.type==="dragenter"||z.type==="dragover"?h(!0):z.type==="dragleave"&&h(!1)},C=z=>{z.preventDefault(),z.stopPropagation(),h(!1),z.dataTransfer.files&&z.dataTransfer.files[0]&&w(z.dataTransfer.files[0])},E=()=>{i&&I(z=>z===0?i.images.length-1:z-1)},A=()=>{i&&I(z=>z===i.images.length-1?0:z+1)},Z=(z,X)=>{I(0),d({name:z,images:X})};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{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(R,{onClick:()=>o(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(qt,{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:N?e.jsxs(e.Fragment,{children:[e.jsx(za,{}),e.jsx(za,{})]}):p?.themes&&Object.entries(p.themes).map(([z,X])=>e.jsx(qe,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:X.background_url?`url(${X.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:y("relative z-10 h-full transition-colors",X.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:[!!X.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Je,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(z===p?.active){$.error(s("card.delete.error.active"));return}a(z),bd(z).then(()=>{$.success("主题删除成功"),k()}).finally(()=>{a(null)})},children:e.jsx(R,{disabled:n===z,loading:n===z,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(ss,{children:[e.jsx(bs,{children:X.name}),e.jsx(tt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:X.description}),X.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:X.version})})]})})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(X.name,X.images),children:e.jsx(lo,{className:"h-4 w-4"})}),e.jsx($u,{themeKey:z,themeInfo:X}),e.jsx(R,{onClick:()=>b(z),disabled:n===z||z===p.active,loading:n===z,variant:z===p.active?"secondary":"default",children:z===p.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},z))}),e.jsx(ge,{open:c,onOpenChange:o,children:e.jsxs(xe,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(je,{children:s("upload.title")}),e.jsx(Te,{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",u&&"border-primary/50 bg-muted/50"),onDragEnter:S,onDragLeave:S,onDragOver:S,onDrop:C,children:[e.jsx("input",{type:"file",ref:f,className:"hidden",accept:".zip",onChange:z=>{const X=z.target.files?.[0];X&&w(X)}}),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(qt,{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:()=>f.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(ge,{open:!!i,onOpenChange:z=>{z||(d(null),I(0))},children:e.jsxs(xe,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(je,{children:[i?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:i&&s("preview.imageCount",{current:P+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[P]&&e.jsx("img",{src:i.images[P],alt:`${i.name} 预览图 ${P+1}`,className:"h-full w-full object-contain"})}),i&&i.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(R,{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:E,children:e.jsx(io,{className:"h-4 w-4"})}),e.jsx(R,{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:A,children:e.jsx(oo,{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((z,X)=>e.jsx("button",{onClick:()=>I(X),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",P===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:z,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function za(){return e.jsxs(qe,{children:[e.jsxs(ss,{children:[e.jsx(Ie,{className:"h-6 w-[200px]"}),e.jsx(Ie,{className:"h-4 w-[300px]"})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[e.jsx(Ie,{className:"h-10 w-[100px]"}),e.jsx(Ie,{className:"h-10 w-[100px]"})]})]})}const qu=Object.freeze(Object.defineProperty({__proto__:null,default:Hu},Symbol.toStringTag,{value:"Module"})),xa=m.forwardRef(({className:s,value:n,onChange:a,...l},r)=>{const[c,o]=m.useState("");m.useEffect(()=>{if(c.includes(",")){const h=new Set([...n,...c.split(",").map(i=>i.trim())]);a(Array.from(h)),o("")}},[c,a,n]);const u=()=>{if(c){const h=new Set([...n,c]);a(Array.from(h)),o("")}};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:[n.map(h=>e.jsxs(H,{variant:"secondary",children:[h,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(n.filter(i=>i!==h))},children:e.jsx(Bt,{className:"w-3"})})]},h)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:c,onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),u()):h.key==="Backspace"&&c.length===0&&n.length>0&&(h.preventDefault(),a(n.slice(0,-1)))},...l,ref:r})]})});xa.displayName="InputTags";const Gu=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()}),Ku={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Dr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Ku}){const{t:r}=M("notice"),[c,o]=m.useState(!1),u=ce({resolver:ue(Gu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),h=new la({html:!0});return e.jsx(he,{...u,children:e.jsxs(ge,{onOpenChange:o,open:c,children:[e.jsx(Oe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(xe,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(j,{control:u.control,name:"title",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.fields.title.placeholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"content",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.content.label")}),e.jsx(_,{children:e.jsx(ia,{style:{height:"500px"},value:i.value,renderHTML:d=>h.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"img_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...i,value:i.value||""})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"tags",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(xa,{value:i.value,onChange:i.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsxs(Ve,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",onClick:i=>{i.preventDefault(),u.handleSubmit(async d=>{Fd(d).then(({data:f})=>{f&&($.success(r("form.buttons.success")),s(),o(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function Bu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=M("notice"),c=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(Dr,{refetch:n}),!l&&e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),c&&!l&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Le,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const Wu=s=>{const{t:n}=M("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(co,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(V,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(H,{variant:"outline",className:"font-mono",children:a.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:a})=>e.jsx(V,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(q,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{const{data:l}=await Ud({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(V,{column:a,title:n("table.columns.title")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:a.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:a})=>e.jsx(V,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Dr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:a.original}),e.jsx(Je,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{zd({id:a.original.id}).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function Yu(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),[h,i]=m.useState(!1),[d,f]=m.useState({}),[P,I]=m.useState({pageSize:50,pageIndex:0}),[p,N]=m.useState([]),{refetch:k}=se({queryKey:["notices"],queryFn:async()=>{const{data:E}=await Ad();return N(E),E}});m.useEffect(()=>{l({"drag-handle":h,content:!h,created_at:!h,actions:!h}),I({pageSize:h?99999:50,pageIndex:0})},[h]);const b=(E,A)=>{h&&(E.dataTransfer.setData("text/plain",A.toString()),E.currentTarget.classList.add("opacity-50"))},w=(E,A)=>{if(!h)return;E.preventDefault(),E.currentTarget.classList.remove("bg-muted");const Z=parseInt(E.dataTransfer.getData("text/plain"));if(Z===A)return;const z=[...p],[X]=z.splice(Z,1);z.splice(A,0,X),N(z)},S=async()=>{if(!h){i(!0);return}gm(p.map(E=>E.id)).then(()=>{$.success("排序保存成功"),i(!1),k()}).finally(()=>{i(!1)})},C=Ae({data:p??[],columns:Wu(k),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:P},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:f,onPaginationChange:I,getCoreRowModel:Fe(),getFilteredRowModel:Ge(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:C,toolbar:E=>e.jsx(Bu,{table:E,refetch:k,saveOrder:S,isSortMode:h}),draggable:h,onDragStart:b,onDragEnd:E=>E.currentTarget.classList.remove("opacity-50"),onDragOver:E=>{E.preventDefault(),E.currentTarget.classList.add("bg-muted")},onDragLeave:E=>E.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!h})})}function Ju(){const{t:s}=M("notice");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{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(Yu,{})})]})]})}const Qu=Object.freeze(Object.defineProperty({__proto__:null,default:Ju},Symbol.toStringTag,{value:"Module"})),Zu=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()}),Xu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Rr({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Xu}){const{t:r}=M("knowledge"),[c,o]=m.useState(!1),u=ce({resolver:ue(Zu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),h=new la({html:!0});return m.useEffect(()=>{c&&l.id&&Hd(l.id).then(({data:i})=>{u.reset(i)})},[l.id,u,c]),e.jsxs(ge,{onOpenChange:o,open:c,children:[e.jsx(Oe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(xe,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(he,{...u,children:[e.jsx(j,{control:u.control,name:"title",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.titlePlaceholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"category",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.categoryPlaceholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"language",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.language")}),e.jsx(_,{children:e.jsxs(W,{value:i.value,onValueChange:i.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx(U,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(j,{control:u.control,name:"body",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.content")}),e.jsx(_,{children:e.jsx(ia,{style:{height:"500px"},value:i.value,renderHTML:d=>h.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:i})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(q,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(D,{})]})}),e.jsxs(Ve,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{u.handleSubmit(i=>{qd(i).then(({data:d})=>{d&&(u.reset(),$.success(r("messages.operationSuccess")),o(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function eh({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(be,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Is,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(qs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function sh({table:s,refetch:n,saveOrder:a,isSortMode:l}){const r=s.getState().columnFilters.length>0,{t:c}=M("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{refreshData:n}),e.jsx(T,{placeholder:c("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(eh,{column:s.getColumn("category"),title:c("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(o=>o.getValue("category")))).map(o=>({label:o,value:o}))}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Le,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const th=({refetch:s,isSortMode:n=!1})=>{const{t:a}=M("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(V,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",className:"justify-center",children:l.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:l})=>e.jsx(V,{column:l,title:a("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(q,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{Kd({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(V,{column:l,title:a("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(V,{column:l,title:a("columns.category")}),cell:({row:l})=>e.jsx(H,{variant:"secondary",className:"max-w-[180px] truncate",children:l.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:l})=>e.jsx(V,{className:"justify-end",column:l,title:a("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(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("form.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Gd({id:l.original.id}).then(({data:r})=>{r&&($.success(a("messages.operationSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:a("messages.deleteButton")})]})})]}),size:100}]};function ah(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[o,u]=m.useState([]),[h,i]=m.useState({"drag-handle":!1}),[d,f]=m.useState({pageSize:20,pageIndex:0}),{refetch:P,isLoading:I,data:p}=se({queryKey:["knowledge"],queryFn:async()=>{const{data:S}=await $d();return u(S||[]),S}});m.useEffect(()=>{i({"drag-handle":r,actions:!r}),f({pageSize:r?99999:10,pageIndex:0})},[r]);const N=(S,C)=>{r&&(S.dataTransfer.setData("text/plain",C.toString()),S.currentTarget.classList.add("opacity-50"))},k=(S,C)=>{if(!r)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const E=parseInt(S.dataTransfer.getData("text/plain"));if(E===C)return;const A=[...o],[Z]=A.splice(E,1);A.splice(C,0,Z),u(A)},b=async()=>{r?Bd({ids:o.map(S=>S.id)}).then(()=>{P(),c(!1),$.success("排序保存成功")}):c(!0)},w=Ae({data:o,columns:th({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:h,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:i,getCoreRowModel:Fe(),getFilteredRowModel:Ge(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:w,toolbar:S=>e.jsx(sh,{table:S,refetch:P,saveOrder:b,isSortMode:r}),draggable:r,onDragStart:N,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!r})}function nh(){const{t:s}=M("knowledge");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{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(ah,{})})]})]})}const rh=Object.freeze(Object.defineProperty({__proto__:null,default:nh},Symbol.toStringTag,{value:"Module"}));function lh(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function zt(s,n){if(s.length===0)return{};if(!n)return{"":s};const a={};return s.forEach(l=>{const r=l[n]||"";a[r]||(a[r]=[]),a[r].push(l)}),a}function ih(s,n){const a=JSON.parse(JSON.stringify(s));for(const[l,r]of Object.entries(a))a[l]=r.filter(c=>!n.find(o=>o.value===c.value));return a}function oh(s,n){for(const[,a]of Object.entries(s))if(a.some(l=>n.find(r=>r.value===l.value)))return!0;return!1}const Er=m.forwardRef(({className:s,...n},a)=>mo(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Er.displayName="CommandEmpty";const lt=m.forwardRef(({value:s,onChange:n,placeholder:a,defaultOptions:l=[],options:r,delay:c,onSearch:o,loadingIndicator:u,emptyIndicator:h,maxSelected:i=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:f,disabled:P,groupBy:I,className:p,badgeClassName:N,selectFirstItem:k=!0,creatable:b=!1,triggerSearchOnFocus:w=!1,commandProps:S,inputProps:C,hideClearAllButton:E=!1},A)=>{const Z=m.useRef(null),[z,X]=m.useState(!1),Gs=m.useRef(!1),[ba,ya]=m.useState(!1),[ee,Ks]=m.useState(s||[]),[Ss,_a]=m.useState(zt(l,I)),[xs,Vt]=m.useState(""),Bs=lh(xs,c||500);m.useImperativeHandle(A,()=>({selectedValue:[...ee],input:Z.current,focus:()=>Z.current?.focus()}),[ee]);const mt=m.useCallback(G=>{const ae=ee.filter(Pe=>Pe.value!==G.value);Ks(ae),n?.(ae)},[n,ee]),sl=m.useCallback(G=>{const ae=Z.current;ae&&((G.key==="Delete"||G.key==="Backspace")&&ae.value===""&&ee.length>0&&(ee[ee.length-1].fixed||mt(ee[ee.length-1])),G.key==="Escape"&&ae.blur())},[mt,ee]);m.useEffect(()=>{s&&Ks(s)},[s]),m.useEffect(()=>{if(!r||o)return;const G=zt(r||[],I);JSON.stringify(G)!==JSON.stringify(Ss)&&_a(G)},[l,r,I,o,Ss]),m.useEffect(()=>{const G=async()=>{ya(!0);const Pe=await o?.(Bs);_a(zt(Pe||[],I)),ya(!1)};(async()=>{!o||!z||(w&&await G(),Bs&&await G())})()},[Bs,I,z,w]);const tl=()=>{if(!b||oh(Ss,[{value:xs,label:xs}])||ee.find(ae=>ae.value===xs))return;const G=e.jsx(Ne,{value:xs,className:"cursor-pointer",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onSelect:ae=>{if(ee.length>=i){d?.(ee.length);return}Vt("");const Pe=[...ee,{value:ae,label:ae}];Ks(Pe),n?.(Pe)},children:`Create "${xs}"`});if(!o&&xs.length>0||o&&Bs.length>0&&!ba)return G},al=m.useCallback(()=>{if(h)return o&&!b&&Object.keys(Ss).length===0?e.jsx(Ne,{value:"-",disabled:!0,children:h}):e.jsx(Er,{children:h})},[b,h,o,Ss]),nl=m.useMemo(()=>ih(Ss,ee),[Ss,ee]),rl=m.useCallback(()=>{if(S?.filter)return S.filter;if(b)return(G,ae)=>G.toLowerCase().includes(ae.toLowerCase())?1:-1},[b,S?.filter]),ll=m.useCallback(()=>{const G=ee.filter(ae=>ae.fixed);Ks(G),n?.(G)},[n,ee]);return e.jsxs(Ns,{...S,onKeyDown:G=>{sl(G),S?.onKeyDown?.(G)},className:y("h-auto overflow-visible bg-transparent",S?.className),shouldFilter:S?.shouldFilter!==void 0?S.shouldFilter:!o,filter:rl(),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":ee.length!==0,"cursor-text":!P&&ee.length!==0},p),onClick:()=>{P||Z.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(G=>e.jsxs(H,{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",N),"data-fixed":G.fixed,"data-disabled":P||void 0,children:[G.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",(P||G.fixed)&&"hidden"),onKeyDown:ae=>{ae.key==="Enter"&&mt(G)},onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:()=>mt(G),children:e.jsx(Bt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},G.value)),e.jsx(Se.Input,{...C,ref:Z,value:xs,disabled:P,onValueChange:G=>{Vt(G),C?.onValueChange?.(G)},onBlur:G=>{Gs.current===!1&&X(!1),C?.onBlur?.(G)},onFocus:G=>{X(!0),w&&o?.(Bs),C?.onFocus?.(G)},placeholder:f&&ee.length!==0?"":a,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":f,"px-3 py-2":ee.length===0,"ml-1":ee.length!==0},C?.className)}),e.jsx("button",{type:"button",onClick:ll,className:y((E||P||ee.length<1||ee.filter(G=>G.fixed).length===ee.length)&&"hidden"),children:e.jsx(Bt,{})})]})}),e.jsx("div",{className:"relative",children:z&&e.jsx(ws,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Gs.current=!1},onMouseEnter:()=>{Gs.current=!0},onMouseUp:()=>{Z.current?.focus()},children:ba?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[al(),tl(),!k&&e.jsx(Ne,{value:"-",className:"hidden"}),Object.entries(nl).map(([G,ae])=>e.jsx(Me,{heading:G,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ae.map(Pe=>e.jsx(Ne,{value:Pe.value,disabled:Pe.disable,onMouseDown:Ws=>{Ws.preventDefault(),Ws.stopPropagation()},onSelect:()=>{if(ee.length>=i){d?.(ee.length);return}Vt("");const Ws=[...ee,Pe];Ks(Ws),n?.(Ws)},className:y("cursor-pointer",Pe.disable&&"cursor-default text-muted-foreground"),children:Pe.label},Pe.value))})},G))]})})})]})});lt.displayName="MultipleSelector";const ch=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 Ot({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=M("group"),c=ce({resolver:ue(ch(r)),defaultValues:a,mode:"onChange"}),[o,u]=m.useState(!1),[h,i]=m.useState(!1),d=async f=>{i(!0),kd(f).then(()=>{$.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{i(!1)})};return e.jsxs(ge,{open:o,onOpenChange:u,children:[e.jsx(Oe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(xe,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(he,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(j,{control:c.control,name:"name",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.name")}),e.jsx(_,{children:e.jsx(T,{placeholder:r("form.namePlaceholder"),...f,className:"w-full"})}),e.jsx(O,{children:r("form.nameDescription")}),e.jsx(D,{})]})}),e.jsxs(Ve,{className:"gap-2",children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(R,{type:"submit",disabled:h||!c.formState.isValid,children:[h&&e.jsx(ra,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Ir=m.createContext(void 0);function dh({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[o,u]=m.useState(ye.Shadowsocks);return e.jsx(Ir.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:o,setServerType:u,refetch:n},children:s})}function Mr(){const s=m.useContext(Ir);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Ut({dialogTrigger:s,value:n,setValue:a,templateType:l}){const{t:r}=M("server");m.useEffect(()=>{console.log(n)},[n]);const[c,o]=m.useState(!1),[u,h]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[i,d]=m.useState(null),f=b=>{if(!b)return null;try{const w=JSON.parse(b);return typeof w!="object"||w===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},P={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"}}}},I=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},p=()=>{const b=f(u||"");if(b){$.error(b);return}try{if(!u){a(null),o(!1);return}a(JSON.parse(u)),o(!1)}catch{$.error(r("network_settings.errors.save_failed"))}},N=b=>{h(b),d(f(b))},k=b=>{const w=P[b];if(w){const S=JSON.stringify(w.content,null,2);h(S),d(null)}};return m.useEffect(()=>{c&&console.log(n)},[c,n]),m.useEffect(()=>{c&&n&&Object.keys(n).length>0&&h(JSON.stringify(n,null,2))},[c,n]),e.jsxs(ge,{open:c,onOpenChange:b=>{!b&&c&&p(),o(b)},children:[e.jsx(Oe,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:r("network_settings.edit_protocol")})}),e.jsxs(xe,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(je,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[I().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:I().map(b=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>k(b),children:r("network_settings.use_template",{template:P[b].label})},b))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Cs,{className:`min-h-[200px] font-mono text-sm ${i?"border-red-500 focus-visible:ring-red-500":""}`,value:u,placeholder:I().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:b=>N(b.target.value)}),i&&e.jsx("p",{className:"text-sm text-red-500",children:i})]})]}),e.jsxs(Ve,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>o(!1),children:r("common.cancel")}),e.jsx(J,{onClick:p,disabled:!!i,children:r("common.confirm")})]})]})]})}function dp(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 mh={},uh=Object.freeze(Object.defineProperty({__proto__:null,default:mh},Symbol.toStringTag,{value:"Module"})),mp=Co(uh),Ua=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),hh=()=>{try{const s=uo.box.keyPair(),n=Ua(Ta.encodeBase64(s.secretKey)),a=Ua(Ta.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},xh=()=>{try{return hh()}catch(s){throw console.error("Error generating key pair:",s),s}},ph=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("").substring(0,s)},fh=()=>{const s=Math.floor(Math.random()*8)*2+2;return ph(s)},gh=x.object({cipher:x.string().default("aes-128-gcm"),obfs:x.string().default("0"),obfs_settings:x.object({path:x.string().default(""),host:x.string().default("")}).default({})}),jh=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({})}),vh=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({})}),bh=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({})}),yh=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("")}),rs={shadowsocks:{schema:gh,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]},vmess:{schema:jh,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:vh,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:bh,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:yh,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"]}},_h=({serverType:s,value:n,onChange:a})=>{const{t:l}=M("server"),r=s?rs[s]:null,c=r?.schema||x.record(x.any()),o=s?c.parse({}):{},u=ce({resolver:ue(c),defaultValues:o,mode:"onChange"});if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const p=c.parse({});u.reset(p)}}else u.reset(n)},[s,n,a,u,c]),m.useEffect(()=>{const p=u.watch(N=>{a(N)});return()=>p.unsubscribe()},[u,a]),!s||!r)return null;const I={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"cipher",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:rs.shadowsocks.ciphers.map(N=>e.jsx(U,{value:N,children:N},N))})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(ps,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(U,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs_settings.path",render:({field:p})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...p})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"obfs_settings.host",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.host"),...p})}),e.jsx(D,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(W,{value:p.value?.toString(),onValueChange:N=>p.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(U,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(q,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:p})=>e.jsxs(g,{children:[e.jsxs(v,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Ut,{value:u.watch("network_settings"),setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:rs.vmess.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"server_name",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(j,{control:u.control,name:"allow_insecure",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(q,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:p})=>e.jsxs(g,{children:[e.jsxs(v,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Ut,{value:u.watch("network_settings")||{},setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:p.onChange,value:p.value||"tcp",children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:rs.trojan.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"version",render:({field:p})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(W,{value:(p.value||2).toString(),onValueChange:N=>p.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:rs.hysteria.versions.map(N=>e.jsxs(U,{value:N,className:"cursor-pointer",children:["V",N]},N))})})]})})]})}),u.watch("version")==1&&e.jsx(j,{control:u.control,name:"alpn",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(W,{value:p.value||"h2",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:rs.hysteria.alpnOptions.map(N=>e.jsx(U,{value:N,children:N},N))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs.open",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(q,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})}),!!u.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[u.watch("version")=="2"&&e.jsx(j,{control:u.control,name:"obfs.type",render:({field:p})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(W,{value:p.value||"salamander",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:e.jsx(U,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs.password",render:({field:p})=>e.jsxs(g,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...p,value:p.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",k=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(b=>N[b%N.length]).join("");u.setValue("obfs.password",k),$.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(_e,{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(j,{control:u.control,name:"tls.server_name",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(j,{control:u.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(q,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"bandwidth.up",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(u.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(j,{control:u.control,name:"bandwidth.down",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(u.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")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(W,{value:p.value?.toString(),onValueChange:N=>p.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(U,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(U,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(q,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),u.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"reality_settings.server_name",render:({field:p})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...p})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.server_port",render:({field:p})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...p})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.allow_insecure",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(q,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(j,{control:u.control,name:"reality_settings.private_key",render:({field:p})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{...p,className:"pr-9"})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const N=xh();u.setValue("reality_settings.private_key",N.privateKey),u.setValue("reality_settings.public_key",N.publicKey),$.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.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(_e,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(j,{control:u.control,name:"reality_settings.public_key",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(T,{...p})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.short_id",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{...p,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const N=fh();u.setValue("reality_settings.short_id",N),$.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(_e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(O,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:p})=>e.jsxs(g,{children:[e.jsxs(v,{children:[l("dynamic_form.vless.network.label"),e.jsx(Ut,{value:u.watch("network_settings"),setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(ps,{children:rs.vless.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})}),e.jsx(j,{control:u.control,name:"flow",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:N=>p.onChange(N==="none"?null:N),value:p.value||"none",children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:rs.vless.flowOptions.map(N=>e.jsx(U,{value:N,children:N},N))})]})})]})})]})};return e.jsx(oe,{children:I[s]?.()})},Nh=x.object({id:x.number().optional().nullable(),code:x.string().optional(),name:x.string().min(1,"form.name.error"),rate:x.string().min(1,"form.rate.error"),tags:x.array(x.string()).default([]),excludes:x.array(x.string()).default([]),ips:x.array(x.string()).default([]),group_ids:x.array(x.string()).default([]),host:x.string().min(1,"form.host.error"),port:x.string().min(1,"form.port.error"),server_port:x.string().min(1,"form.server_port.error"),parent_id:x.string().default("0").nullable(),route_ids:x.array(x.string()).default([]),protocol_settings:x.record(x.any()).default({}).nullable()}),xt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function wh(){const{t:s}=M("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:o,refetch:u}=Mr(),[h,i]=m.useState([]),[d,f]=m.useState([]),[P,I]=m.useState([]),p=ce({resolver:ue(Nh),defaultValues:xt,mode:"onChange"});m.useEffect(()=>{N()},[n]),m.useEffect(()=>{l?.type&&l.type!==c&&o(l.type)},[l,c,o]),m.useEffect(()=>{l?l.type===c&&p.reset({...xt,...l}):p.reset({...xt,protocol_settings:rs[c].schema.parse({})})},[l,p,c]);const N=async()=>{if(!n)return;const[C,E,A]=await Promise.all([Mt(),pr(),xr()]);i(C.data?.map(Z=>({label:Z.name,value:Z.id.toString()}))||[]),f(E.data?.map(Z=>({label:Z.remarks,value:Z.id.toString()}))||[]),I(A.data||[])},k=m.useMemo(()=>P?.filter(C=>(C.parent_id===0||C.parent_id===null)&&C.type===c&&C.id!==p.watch("id")),[c,P,p]),b=()=>e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(is,{align:"start",children:e.jsx(Bc,{children:Ps.map(({type:C,label:E})=>e.jsx(pe,{onClick:()=>{o(C),a(!0)},className:"cursor-pointer",children:e.jsx(H,{variant:"outline",className:"text-white",style:{background:ls[C]},children:E})},C))})})]}),w=()=>{a(!1),r(null),p.reset(xt)},S=async()=>{const C=p.getValues();(await _d({...C,type:c})).data&&(w(),$.success(s("form.success")),u())};return e.jsxs(ge,{open:n,onOpenChange:w,children:[b(),e.jsxs(xe,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(he,{...p,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:p.control,name:"name",render:({field:C})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:s("form.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.name.placeholder"),...C})}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"rate",render:({field:C})=>e.jsxs(g,{className:"flex-[1]",children:[e.jsx(v,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(_,{children:e.jsx(T,{type:"number",min:"0",step:"0.1",...C})})}),e.jsx(D,{})]})})]}),e.jsx(j,{control:p.control,name:"code",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(v,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.code.placeholder"),...C,value:C.value||""})}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"tags",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(xa,{value:C.value,onChange:C.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"group_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Ot,{dialogTrigger:e.jsx(R,{variant:"link",children:s("form.groups.add")}),refetch:N})]}),e.jsx(_,{children:e.jsx(lt,{options:h,onChange:E=>C.onChange(E.map(A=>A.value)),value:h?.filter(E=>C.value.includes(E.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:p.control,name:"host",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.host.placeholder"),...C})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{control:p.control,name:"port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(_e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_,{children:e.jsx(T,{placeholder:s("form.port.placeholder"),...C})}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const E=C.value;E&&p.setValue("server_port",E)},children:e.jsx(_e,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(te,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"server_port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(_e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.server_port.placeholder"),...C})}),e.jsx(D,{})]})})]})]}),n&&e.jsx(_h,{serverType:c,value:p.watch("protocol_settings"),onChange:C=>p.setValue("protocol_settings",C,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(j,{control:p.control,name:"parent_id",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.parent.label")}),e.jsxs(W,{onValueChange:C.onChange,value:C.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("form.parent.none")}),k?.map(E=>e.jsx(U,{value:E.id.toString(),className:"cursor-pointer",children:E.name},E.id))]})]}),e.jsx(D,{})]})}),e.jsx(j,{control:p.control,name:"route_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(lt,{options:d,onChange:E=>C.onChange(E.map(A=>A.value)),value:d?.filter(E=>C.value.includes(E.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(D,{})]})})]}),e.jsxs(Ve,{className:"mt-6",children:[e.jsx(R,{type:"button",variant:"outline",onClick:w,children:s("form.cancel")}),e.jsx(R,{type:"submit",onClick:S,children:s("form.submit")})]})]})]})]})}function $a({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(be,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Is,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${c.color}`}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(qs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Ch=[{value:ye.Shadowsocks,label:Ps.find(s=>s.type===ye.Shadowsocks)?.label,color:ls[ye.Shadowsocks]},{value:ye.Vmess,label:Ps.find(s=>s.type===ye.Vmess)?.label,color:ls[ye.Vmess]},{value:ye.Trojan,label:Ps.find(s=>s.type===ye.Trojan)?.label,color:ls[ye.Trojan]},{value:ye.Hysteria,label:Ps.find(s=>s.type===ye.Hysteria)?.label,color:ls[ye.Hysteria]},{value:ye.Vless,label:Ps.find(s=>s.type===ye.Vless)?.label,color:ls[ye.Vless]}];function Sh({table:s,saveOrder:n,isSortMode:a,groups:l}){const r=s.getState().columnFilters.length>0,{t:c}=M("server"),o=l.map(u=>({label:u,value:u}));return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!a&&e.jsxs(e.Fragment,{children:[e.jsx(wh,{}),e.jsx(T,{placeholder:c("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:u=>s.getColumn("name")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx($a,{column:s.getColumn("type"),title:c("toolbar.type"),options:Ch}),s.getColumn("groups")&&e.jsx($a,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:o})]}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Le,{className:"ml-2 h-4 w-4"})]})]}),a&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const it=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),pt={0:"bg-destructive/80 shadow-sm shadow-destructive/50",1:"bg-yellow-500/80 shadow-sm shadow-yellow-500/50",2:"bg-emerald-500/80 shadow-sm shadow-emerald-500/50"},kh=s=>{const{t:n}=M("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Dt,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(H,{variant:"outline",className:y("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:ls[a.original.type]},children:[e.jsx(zn,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:r??l}),a.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:a.original.parent?.code||a.original.parent?.id})]}):""]})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:c=>{c.stopPropagation(),wt(r||l.toString())},children:e.jsx(Da,{className:"size-3"})})]})}),e.jsxs(te,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ps.find(c=>c.type===a.original.type)?.label,a.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:200,enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.show")}),cell:({row:a})=>{const[l,r]=m.useState(!!a.getValue("show"));return e.jsx(q,{checked:l,onCheckedChange:async c=>{r(c),Cd({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?ls[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(V,{column:a,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",pt[0])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.0")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",pt[1])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.1")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",pt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",pt[a.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:a.getValue("name")})]})}),e.jsx(te,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${a.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.address")}),cell:({row:a})=>{const l=`${a.original.host}:${a.original.port}`,r=a.original.port!==a.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[a.original.host,":",a.original.port]})}),r&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",a.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(oe,{delayDuration:0,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:c=>{c.stopPropagation(),wt(l)},children:e.jsx(Da,{className:"size-3"})})}),e.jsx(te,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:a})=>e.jsxs(H,{variant:"secondary",className:"font-medium",children:[a.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"groups",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:a})=>{const l=a.getValue("groups")||[];return e.jsx("div",{className:"flex min-w-[300px] max-w-[600px] flex-wrap items-center gap-1.5",children:l.length>0?l.map((r,c)=>e.jsx(H,{variant:"secondary",className:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:r.name},c)):e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})})},enableSorting:!1,size:600,filterFn:(a,l,r)=>{const c=a.getValue(l);return c?r.some(o=>c.includes(o)):!1}},{accessorKey:"type",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.type")}),cell:({row:a})=>{const l=a.getValue("type");return e.jsx(H,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:ls[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(V,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=Mr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(ys,{modal:!1,children:[e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(_t,{className:"size-4"})})}),e.jsxs(is,{align:"end",className:"w-40",children:[e.jsx(pe,{className:"cursor-pointer",onClick:()=>{c(a.original.type),r(a.original),l(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(ho,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(pe,{className:"cursor-pointer",onClick:async()=>{wd({id:a.original.id}).then(({data:o})=>{o&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(xo,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(at,{}),e.jsx(pe,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:o=>o.preventDefault(),children:e.jsx(Je,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Nd({id:a.original.id}).then(({data:o})=>{o&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(cs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Ph(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[o,u]=m.useState({pageSize:500,pageIndex:0}),[h,i]=m.useState([]),[d,f]=m.useState(!1),[P,I]=m.useState({}),[p,N]=m.useState([]),{refetch:k}=se({queryKey:["nodeList"],queryFn:async()=>{const{data:A}=await xr();return N(A),A}}),b=m.useMemo(()=>{const A=new Set;return p.forEach(Z=>{Z.groups&&Z.groups.forEach(z=>A.add(z.name))}),Array.from(A).sort()},[p]);m.useEffect(()=>{l({"drag-handle":d,show:!d,host:!d,online:!d,rate:!d,groups:!d,type:!1,actions:!d}),I({name:d?2e3:200}),u({pageSize:d?99999:500,pageIndex:0})},[d]);const w=(A,Z)=>{d&&(A.dataTransfer.setData("text/plain",Z.toString()),A.currentTarget.classList.add("opacity-50"))},S=(A,Z)=>{if(!d)return;A.preventDefault(),A.currentTarget.classList.remove("bg-muted");const z=parseInt(A.dataTransfer.getData("text/plain"));if(z===Z)return;const X=[...p],[Gs]=X.splice(z,1);X.splice(Z,0,Gs),N(X)},C=async()=>{if(!d){f(!0);return}const A=p?.map((Z,z)=>({id:Z.id,order:z+1}));Sd(A).then(()=>{$.success("排序保存成功"),f(!1),k()}).finally(()=>{f(!1)})},E=Ae({data:p||[],columns:kh(k),state:{sorting:h,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:P,pagination:o},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:i,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:I,onPaginationChange:u,getCoreRowModel:Fe(),getFilteredRowModel:Ge(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(dh,{refetch:k,children:e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:E,toolbar:A=>e.jsx(Sh,{table:A,refetch:k,saveOrder:C,isSortMode:d,groups:b}),draggable:d,onDragStart:w,onDragEnd:A=>A.currentTarget.classList.remove("opacity-50"),onDragOver:A=>{A.preventDefault(),A.currentTarget.classList.add("bg-muted")},onDragLeave:A=>A.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!d})})})}function Th(){const{t:s}=M("server");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Ph,{})})]})]})}const Dh=Object.freeze(Object.defineProperty({__proto__:null,default:Th},Symbol.toStringTag,{value:"Module"}));function Rh({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=M("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(Ot,{refetch:n}),e.jsx(T,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:y("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Le,{className:"ml-2 h-4 w-4"})]})]})})}const Eh=s=>{const{t:n}=M("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(H,{variant:"outline",children:a.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:a.getValue("name")})})},{accessorKey:"users_count",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:a})=>e.jsx(V,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(zn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:a})=>e.jsx(V,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Ot,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Je,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Pd({id:a.original.id}).then(({data:l})=>{l&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Ih(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),{data:h,refetch:i,isLoading:d}=se({queryKey:["serverGroupList"],queryFn:async()=>{const{data:P}=await Mt();return P}}),f=Ae({data:h||[],columns:Eh(i),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Fe(),getFilteredRowModel:Ge(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:f,toolbar:P=>e.jsx(Rh,{table:P,refetch:i}),isLoading:d})}function Mh(){const{t:s}=M("group");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Ih,{})})]})]})}const Oh=Object.freeze(Object.defineProperty({__proto__:null,default:Mh},Symbol.toStringTag,{value:"Module"})),Vh=s=>x.object({remarks:x.string().min(1,s("form.validation.remarks")),match:x.array(x.string()),action:x.enum(["block","dns"]),action_value:x.string().optional()});function Or({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=M("route"),c=ce({resolver:ue(Vh(r)),defaultValues:a,mode:"onChange"}),[o,u]=m.useState(!1);return e.jsxs(ge,{open:o,onOpenChange:u,children:[e.jsx(Oe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(xe,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(he,{...c,children:[e.jsx(j,{control:c.control,name:"remarks",render:({field:h})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.remarksPlaceholder"),...h})})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"match",render:({field:h})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(Cs,{className:"min-h-[120px]",placeholder:r("form.matchPlaceholder"),value:h.value.join(` `),onChange:i=>{h.onChange(i.target.value.split(`