diff --git a/app/Http/Controllers/V2/Admin/OrderController.php b/app/Http/Controllers/V2/Admin/OrderController.php index 05ebdb6..95c69f5 100644 --- a/app/Http/Controllers/V2/Admin/OrderController.php +++ b/app/Http/Controllers/V2/Admin/OrderController.php @@ -221,7 +221,7 @@ class OrderController extends Controller $order->user_id = $user->id; $order->plan_id = $plan->id; $period = $request->input('period'); - $order->period = (int) PlanService::getPeriodKey((string) $period); + $order->period = PlanService::getPeriodKey((string) $period); $order->trade_no = Helper::guid(); $order->total_amount = $request->input('total_amount'); diff --git a/app/Models/Order.php b/app/Models/Order.php index 4ee0b14..8ba1420 100755 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; * @property int $user_id * @property int $plan_id * @property int|null $payment_id - * @property int $period + * @property string $period * @property string $trade_no * @property int $total_amount * @property int|null $handling_amount diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 9dce2a5..60d2261 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,9 +1,9 @@ -import{r as u,j as e,t as Sl,c as kl,I as Ka,a as As,S as Na,u as Ts,b as _a,R as fn,d as gn,e as Tl,F as Dl,C as Pl,L as jn,T as vn,f as bn,g as El,h as Rl,i as Il,k as A,z as x,l as V,m as ge,n as Ne,o as re,p as es,q as Se,s as it,v as Vl,O as wa,w as Ml,x as Fl,y as Ol,A as Ll,B as zl,D as Al,Q as $l,E as Ul,G as Hl,H as ql,P as Kl,J as Bl,K as Gl,M as Wl,N as Yl,U as yn,V as Nn,W as zt,X as At,Y as Ca,Z as ss,_ as $t,$ as Ut,a0 as _n,a1 as wn,a2 as Cn,a3 as Sa,a4 as Sn,a5 as Ql,a6 as kn,a7 as Tn,a8 as Dn,a9 as Pn,aa as $s,ab as En,ac as Jl,ad as Rn,ae as In,af as Xl,ag as Zl,ah as ei,ai as si,aj as ti,ak as ai,al as ni,am as ri,an as li,ao as ii,ap as oi,aq as Vn,ar as ci,as as di,at as Us,au as Mn,av as ui,aw as mi,ax as Fn,ay as ka,az as xi,aA as hi,aB as Ba,aC as pi,aD as On,aE as fi,aF as Ln,aG as gi,aH as ji,aI as vi,aJ as bi,aK as yi,aL as Ni,aM as zn,aN as _i,aO as wi,aP as Ci,aQ as Le,aR as Si,aS as An,aT as $n,aU as ki,aV as Ti,aW as Un,aX as Di,aY as Pi,aZ as Ze,a_ as Ei,a$ as Ri,b0 as Hn,b1 as qn,b2 as Kn,b3 as Ii,b4 as Vi,b5 as Mi,b6 as Bn,b7 as Fi,b8 as Ta,b9 as Gn,ba as Oi,bb as Wn,bc as Li,bd as Yn,be as zi,bf as Qn,bg as Jn,bh as Ai,bi as $i,bj as Xn,bk as Ui,bl as Hi,bm as Zn,bn as qi,bo as er,bp as Ki,bq as Bi,br as is,bs as jt,bt as Gi,bu as Wi,bv as Yi,bw as Qi,bx as Ji,by as Xi,bz as Ga,bA as Wa,bB as Zi,bC as eo,bD as so,bE as to,bF as ao,bG as ha,bH as pt,bI as no,bJ as ro,bK as lo,bL as Ya,bM as pa,bN as fa,bO as io,bP as oo,bQ as sr,bR as co,bS as Da,bT as uo,bU as mo,bV as xo,bW as tr,bX as ar,bY as ho,bZ as po,b_ as fo,b$ as go,c0 as jo,c1 as nr,c2 as vo,c3 as bo,c4 as yo,c5 as No,c6 as Rt,c7 as Ve,c8 as Qa,c9 as _o,ca as rr,cb as lr,cc as ir,cd as or,ce as cr,cf as dr,cg as wo,ch as Co,ci as So,cj as Ht,ck as Hs,cl as cs,cm as ns,cn as rs,co as ds,cp as us,cq as ms,cr as ko,cs as To,ct as Do,cu as Po,cv as Eo,cw as Ro,cx as Io,cy as Vo,cz as Mo,cA as ga,cB as Pa,cC as Ea,cD as Fo,cE as Ds,cF as Ps,cG as qt,cH as Oo,cI as It,cJ as Lo,cK as Ja,cL as ur,cM as Xa,cN as Vt,cO as zo,cP as Ao,cQ as $o,cR as Uo,cS as mr,cT as Ho,cU as qo,cV as xr,cW as ja,cX as hr,cY as Ko,cZ as pr,c_ as fr,c$ as Bo,d0 as Go,d1 as Wo,d2 as Yo,d3 as Qo}from"./vendor.js";import"./index.js";var mp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Jo(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var t=function r(){return this instanceof r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return s[r]}})}),t}const Xo={theme:"system",setTheme:()=>null},gr=u.createContext(Xo);function Zo({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=u.useState(()=>localStorage.getItem(t)||n);u.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const m=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(m);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(gr.Provider,{...r,value:l,children:s})}const ec=()=>{const s=u.useContext(gr);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},sc=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),tc=function(s,n){return new URL(s,n).href},Za={},me=function(n,t,r){let a=Promise.resolve();if(t&&t.length>0){const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(o=>{if(o=tc(o,r),o in Za)return;Za[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(!!r)for(let C=l.length-1;C>=0;C--){const S=l[C];if(S.href===o&&(!c||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const E=document.createElement("link");if(E.rel=c?"stylesheet":sc,c||(E.as="script"),E.crossOrigin="",E.href=o,m&&E.setAttribute("nonce",m),document.head.appendChild(E),c)return new Promise((C,S)=>{E.addEventListener("load",C),E.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function N(...s){return Sl(kl(s))}const nt=As("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),P=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:m,...o},c)=>{const h=r?Na:"button";return e.jsxs(h,{className:N(nt({variant:n,size:t,className:s})),disabled:l||i,ref:c,...o,children:[(d&&l||!d&&!m&&l)&&e.jsx(Ka,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&m&&e.jsx("div",{className:"ml-2",children:m}),m&&l&&e.jsx(Ka,{className:"ml-2 h-4 w-4 animate-spin"})]})});P.displayName="Button";function Ys({className:s,minimal:n=!1}){const t=Ts();return e.jsx("div",{className:N("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{})," Please try again later."]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function en(){const s=Ts();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function ac(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(P,{variant:"outline",children:"Learn more"})})]})})}function nc(s){return typeof s>"u"}function rc(s){return s===null}function lc(s){return rc(s)||nc(s)}class ic{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,t,r=null){const a=JSON.stringify({value:t,time:Date.now(),expire:r!==null?new Date().getTime()+r*1e3:null});this.storage.setItem(this.getKey(n),a)}get(n,t=null){const r=this.storage.getItem(this.getKey(n));if(!r)return{value:t,time:0};try{const a=JSON.parse(r),{value:i,time:l,expire:d}=a;return lc(d)||d>new Date().getTime()?{value:i,time:l}:(this.remove(n),{value:t,time:0})}catch{return this.remove(n),{value:t,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function jr({prefixKey:s="",storage:n=sessionStorage}){return new ic({prefixKey:s,storage:n})}const vr="Xboard_",oc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:localStorage})},cc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:sessionStorage})},Kt=oc({prefixKey:vr});cc({prefixKey:vr});const br="access_token";function ft(){return Kt.get(br)}function yr(){Kt.remove(br)}const sn=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function dc({children:s}){const n=Ts(),t=_a(),r=ft();return u.useEffect(()=>{if(!r.value&&!sn.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),sn.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const ke=u.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(fn,{ref:a,decorative:t,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));ke.displayName=fn.displayName;const uc=As("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mt=u.forwardRef(({className:s,...n},t)=>e.jsx(gn,{ref:t,className:N(uc(),s),...n}));Mt.displayName=gn.displayName;const _e=Dl,Nr=u.createContext({}),g=({...s})=>e.jsx(Nr.Provider,{value:{name:s.name},children:e.jsx(Pl,{...s})}),Bt=()=>{const s=u.useContext(Nr),n=u.useContext(_r),{getFieldState:t,formState:r}=Tl(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:i}=n;return{id:i,name:s.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},_r=u.createContext({}),f=u.forwardRef(({className:s,...n},t)=>{const r=u.useId();return e.jsx(_r.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:N("space-y-2",s),...n})})});f.displayName="FormItem";const j=u.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Bt();return e.jsx(Mt,{ref:t,className:N(r&&"text-destructive",s),htmlFor:a,...n})});j.displayName="FormLabel";const y=u.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Bt();return e.jsx(Na,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});y.displayName="FormControl";const F=u.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Bt();return e.jsx("p",{ref:t,id:r,className:N("text-[0.8rem] text-muted-foreground",s),...n})});F.displayName="FormDescription";const D=u.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Bt(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:N("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});D.displayName="FormMessage";const Gt=El,vt=u.forwardRef(({className:s,...n},t)=>e.jsx(jn,{ref:t,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));vt.displayName=jn.displayName;const Ge=u.forwardRef(({className:s,...n},t)=>e.jsx(vn,{ref:t,className:N("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));Ge.displayName=vn.displayName;const ws=u.forwardRef(({className:s,...n},t)=>e.jsx(bn,{ref:t,className:N("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ws.displayName=bn.displayName;function we(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Rl(s).format(n))}function mc(s=void 0,n="YYYY-MM-DD"){return we(s,n)}function Xs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ls(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,i=>i.includes(".")?".00":i);return n?`¥${a}`:a}function Ft(s){return new Promise(n=>{(async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(s);else{const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),!a)throw new Error("execCommand failed")}n(!0)}catch(r){console.error(r),n(!1)}})()})}function ps(s){const n=s/1024,t=n/1024,r=t/1024,a=r/1024;return a>=1?Xs(a)+" TB":r>=1?Xs(r)+" GB":t>=1?Xs(t)+" MB":Xs(n)+" KB"}const xc="locale";function hc(){return Kt.get(xc)}function wr(){yr();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),t=new URL(window.location.href),a=`${t.pathname.split("/")[1]?`/${t.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=a+(n?`?redirect=${s}`:"")}const pc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function fc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const I=Il.create({baseURL:fc(),timeout:12e3,headers:{"Content-Type":"application/json"}});I.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=ft();if(!pc.includes(s.url?.split("?")[0]||"")){if(!n.value)return wr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=hc().value||"zh-CN",s},s=>Promise.reject(s));I.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,t=s.response?.data?.message;return(n===401||n===403)&&wr(),A.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const gc="access_token";function jc(s){Kt.set(gc,s)}const U=window?.settings?.secure_path,vc=s=>I.get(U+"/stat/getOrder",{params:s}),bc=()=>I.get(U+"/stat/getStats"),tn=s=>I.get(U+"/stat/getTrafficRank",{params:s}),yc=()=>I.get(U+"/theme/getThemes"),Nc=s=>I.post(U+"/theme/getThemeConfig",{name:s}),_c=(s,n)=>I.post(U+"/theme/saveThemeConfig",{name:s,config:n}),wc=s=>{const n=new FormData;return n.append("file",s),I.post(U+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Cc=s=>I.post(U+"/theme/delete",{name:s}),Sc=s=>I.post(U+"/config/save",s),Cr=()=>I.get(U+"/server/manage/getNodes"),kc=s=>I.post(U+"/server/manage/save",s),Tc=s=>I.post(U+"/server/manage/drop",s),Dc=s=>I.post(U+"/server/manage/copy",s),Pc=s=>I.post(U+"/server/manage/update",s),Ec=s=>I.post(U+"/server/manage/sort",s),bt=()=>I.get(U+"/server/group/fetch"),Rc=s=>I.post(U+"/server/group/save",s),Ic=s=>I.post(U+"/server/group/drop",s),Sr=()=>I.get(U+"/server/route/fetch"),Vc=s=>I.post(U+"/server/route/save",s),Mc=s=>I.post(U+"/server/route/drop",s),Fc=()=>I.get(U+"/payment/fetch"),Oc=()=>I.get(U+"/payment/getPaymentMethods"),Lc=s=>I.post(U+"/payment/getPaymentForm",s),zc=s=>I.post(U+"/payment/save",s),Ac=s=>I.post(U+"/payment/drop",s),$c=s=>I.post(U+"/payment/show",s),Uc=s=>I.post(U+"/payment/sort",s),Hc=s=>I.post(U+"/notice/save",s),qc=s=>I.post(U+"/notice/drop",s),Kc=s=>I.post(U+"/notice/show",s),Bc=()=>I.get(U+"/knowledge/fetch"),Gc=s=>I.get(U+"/knowledge/fetch?id="+s),Wc=s=>I.post(U+"/knowledge/save",s),Yc=s=>I.post(U+"/knowledge/drop",s),Qc=s=>I.post(U+"/knowledge/show",s),Jc=s=>I.post(U+"/knowledge/sort",s),qs=()=>I.get(U+"/plan/fetch"),Xc=s=>I.post(U+"/plan/save",s),aa=s=>I.post(U+"/plan/update",s),Zc=s=>I.post(U+"/plan/drop",s),ed=s=>I.post(U+"/plan/sort",{ids:s}),sd=async s=>I.post(U+"/order/fetch",s),td=s=>I.post(U+"/order/detail",s),ad=s=>I.post(U+"/order/paid",s),nd=s=>I.post(U+"/order/cancel",s),an=s=>I.post(U+"/order/update",s),rd=s=>I.post(U+"/order/assign",s),ld=s=>I.post(U+"/coupon/fetch",s),id=s=>I.post(U+"/coupon/generate",s),od=s=>I.post(U+"/coupon/drop",s),cd=s=>I.post(U+"/coupon/update",s),dd=s=>I.post(U+"/user/fetch",s),ud=s=>I.post(U+"/user/update",s),md=s=>I.post(U+"/user/resetSecret",s),xd=s=>I.post(U+"/user/generate",s),hd=s=>I.post(U+"/stat/getStatUser",s),pd=s=>I.post(U+"/ticket/fetch",s),fd=s=>I.get(U+"/ticket/fetch?id= "+s),gd=s=>I.post(U+"/ticket/close",{id:s}),gs=(s="")=>I.get(U+"/config/fetch?key="+s),js=s=>I.post(U+"/config/save",s),jd=()=>I.get(U+"/config/getEmailTemplate"),vd=()=>I.post(U+"/config/testSendMail"),bd=()=>I.post(U+"/config/setTelegramWebhook"),yd=x.object({subscribe_template_singbox:x.string().nullable(),subscribe_template_clash:x.string().nullable(),subscribe_template_clashmeta:x.string().nullable(),subscribe_template_stash:x.string().nullable(),subscribe_template_surge:x.string().nullable()}),Nd={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:""};function _d(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),[a,i]=u.useState("singbox"),l=ge({resolver:Ne(yd),defaultValues:Nd,mode:"onBlur"}),{data:d}=re({queryKey:["settings","client"],queryFn:()=>gs("subscribe_template")}),{mutateAsync:m}=es({mutationFn:js,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(d?.data.subscribe_template){const h=d.data.subscribe_template;Object.entries(h).forEach(([_,E])=>{l.setValue(_,E)}),r.current=h}},[d]),console.log(l.getValues());const o=u.useCallback(Se.debounce(async h=>{if(!Se.isEqual(h,r.current)){t(!0);try{await m(h),r.current=h}finally{t(!1)}}},1e3),[m]),c=u.useCallback(h=>{o(h)},[o]);return e.jsx(_e,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Gt,{value:a,onValueChange:i,children:[e.jsxs(vt,{children:[e.jsx(Ge,{value:"singbox",children:"Sing-box"}),e.jsx(Ge,{value:"clash",children:"Clash"}),e.jsx(Ge,{value:"clashmeta",children:"Clash Meta"}),e.jsx(Ge,{value:"stash",children:"Stash"}),e.jsx(Ge,{value:"surge",children:"Surge"})]}),e.jsx(ws,{value:"singbox",children:e.jsx(g,{control:l.control,name:"subscribe_template_singbox",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.singbox.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"json",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.singbox.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"clash",children:e.jsx(g,{control:l.control,name:"subscribe_template_clash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clash.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clash.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"clashmeta",children:e.jsx(g,{control:l.control,name:"subscribe_template_clashmeta",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clashmeta.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clashmeta.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"stash",children:e.jsx(g,{control:l.control,name:"subscribe_template_stash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.stash.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.stash.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"surge",children:e.jsx(g,{control:l.control,name:"subscribe_template_surge",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.surge.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"ini",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.surge.description")}),e.jsx(D,{})]})})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function wd(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(ke,{}),e.jsx(_d,{})]})}const Cd=()=>e.jsx(dc,{children:e.jsx(wa,{})}),Sd=Vl([{path:"/sign-in",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Hd);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Cd,{}),children:[{path:"/",lazy:async()=>({Component:(await me(()=>Promise.resolve().then(()=>Xd),void 0,import.meta.url)).default}),errorElement:e.jsx(Ys,{}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Nu);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ys,{}),children:[{path:"system",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Su);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Pu);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Mu);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Au);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ku);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Qu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>sm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>lm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>um);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>fm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(wd,{})}]},{path:"payment",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Sm);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Dm);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Im);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Am);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Wm);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>wx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Dx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Mx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ys,{}),children:[{path:"plan",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>qx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>nh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>xh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Hh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>cp);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ys},{path:"/404",Component:en},{path:"/503",Component:ac},{path:"*",Component:en}]);function kd(){return I.get("/user/info")}const na={token:ft()?.value||"",userInfo:null,isLoggedIn:!!ft()?.value,loading:!1,error:null},mt=Ml("user/fetchUserInfo",async()=>(await kd()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),kr=Fl({name:"user",initialState:na,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>na},extraReducers:s=>{s.addCase(mt.pending,n=>{n.loading=!0,n.error=null}).addCase(mt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(mt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return na})}}),{setToken:Td,resetUserState:Dd}=kr.actions,Pd=s=>s.user.userInfo,Ed=kr.reducer,Tr=Ol({reducer:{user:Ed}});ft()?.value&&Tr.dispatch(mt());Ll.use(zl).use(Al).init({resources:{"en-US":window.XBOARD_TRANSLATIONS?.["en-US"]||{},"zh-CN":window.XBOARD_TRANSLATIONS?.["zh-CN"]||{},"ko-KR":window.XBOARD_TRANSLATIONS?.["ko-KR"]||{}},fallbackLng:"zh-CN",supportedLngs:["en-US","zh-CN","ko-KR"],detection:{order:["querystring","localStorage","navigator"],lookupQuerystring:"lang",lookupLocalStorage:"i18nextLng",caches:["localStorage"]},interpolation:{escapeValue:!1}});const Rd=new $l;Ul.createRoot(document.getElementById("root")).render(e.jsx(Hl.StrictMode,{children:e.jsx(ql,{client:Rd,children:e.jsx(Kl,{store:Tr,children:e.jsxs(Zo,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Bl,{router:Sd}),e.jsx(Gl,{richColors:!0,position:"top-right"})]})})})}));const We=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));We.displayName="Card";const ts=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex flex-col space-y-1.5 p-6",s),...n}));ts.displayName="CardHeader";const Cs=u.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:N("font-semibold leading-none tracking-tight",s),...n}));Cs.displayName="CardTitle";const et=u.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:N("text-sm text-muted-foreground",s),...n}));et.displayName="CardDescription";const as=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("p-6 pt-0",s),...n}));as.displayName="CardContent";const Id=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex items-center p-6 pt-0",s),...n}));Id.displayName="CardFooter";const T=u.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));T.displayName="Input";const Dr=u.forwardRef(({className:s,...n},t)=>{const[r,a]=u.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}),e.jsx(P,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>a(i=>!i),children:r?e.jsx(Wl,{size:18}):e.jsx(Yl,{size:18})})]})});Dr.displayName="PasswordInput";const Vd=s=>I({url:"/passport/auth/login",method:"post",data:s});function Md({className:s,onForgotPassword:n,...t}){const r=Ts(),a=yn(),{t:i}=V("auth"),l=x.object({email:x.string().min(1,{message:i("signIn.validation.emailRequired")}),password:x.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=ge({resolver:Ne(l),defaultValues:{email:"",password:""}});async function m(o){try{const{data:c}=await Vd(o);jc(c.auth_data),a(Td(c.auth_data)),await a(mt()).unwrap(),r("/")}catch(c){console.error("Login failed:",c),c.response?.data?.message&&d.setError("root",{message:c.response.data.message})}}return e.jsx("div",{className:N("grid gap-6",s),...t,children:e.jsx(_e,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(m),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[d.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:d.formState.errors.root.message}),e.jsx(g,{control:d.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.email")}),e.jsx(y,{children:e.jsx(T,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"password",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.password")}),e.jsx(y,{children:e.jsx(Dr,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(D,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(P,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const be=Nn,Je=_n,Fd=wn,yt=Ca,Pr=u.forwardRef(({className:s,...n},t)=>e.jsx(zt,{ref:t,className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));Pr.displayName=zt.displayName;const fe=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Fd,{children:[e.jsx(Pr,{}),e.jsxs(At,{ref:r,className:N("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...t,children:[n,e.jsxs(Ca,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(ss,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fe.displayName=At.displayName;const Ce=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});Ce.displayName="DialogHeader";const ze=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});ze.displayName="DialogFooter";const ye=u.forwardRef(({className:s,...n},t)=>e.jsx($t,{ref:t,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));ye.displayName=$t.displayName;const Te=u.forwardRef(({className:s,...n},t)=>e.jsx(Ut,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Te.displayName=Ut.displayName;const st=As("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?Na:"button";return e.jsx(l,{className:N(st({variant:n,size:t,className:s})),ref:i,...a})});J.displayName="Button";const Ss=Xl,ks=Zl,Od=ei,Ld=u.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Cn,{ref:a,className:N("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...r,children:[t,e.jsx(Sa,{className:"ml-auto h-4 w-4"})]}));Ld.displayName=Cn.displayName;const zd=u.forwardRef(({className:s,...n},t)=>e.jsx(Sn,{ref:t,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));zd.displayName=Sn.displayName;const fs=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Ql,{children:e.jsx(kn,{ref:r,sideOffset:n,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));fs.displayName=kn.displayName;const je=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Tn,{ref:r,className:N("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...t}));je.displayName=Tn.displayName;const Ad=u.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Dn,{ref:a,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx($s,{className:"h-4 w-4"})})}),n]}));Ad.displayName=Dn.displayName;const $d=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(En,{ref:r,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx(Jl,{className:"h-4 w-4 fill-current"})})}),n]}));$d.displayName=En.displayName;const Ra=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Rn,{ref:r,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ra.displayName=Rn.displayName;const tt=u.forwardRef(({className:s,...n},t)=>e.jsx(In,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));tt.displayName=In.displayName;const va=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});va.displayName="DropdownMenuShortcut";const ra=[{code:"en-US",name:"English",flag:si,shortName:"EN"},{code:"zh-CN",name:"中文",flag:ti,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:ai,shortName:"KR"}];function Er(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=ra.find(a=>a.code===s.language)||ra[1],r=t.flag;return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(r,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:t.shortName})]})}),e.jsx(fs,{align:"end",className:"w-[120px]",children:ra.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(je,{onClick:()=>n(a.code),className:N("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(i,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:N("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function Ud(){const[s,n]=u.useState(!1),{t}=V("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:[e.jsx("div",{className:"absolute right-4 top-4 md:right-8 md:top-8",children:e.jsx(Er,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[480px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(We,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(Md,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(be,{open:s,onOpenChange:n,children:e.jsx(fe,{children:e.jsxs(Ce,{children:[e.jsx(ye,{children:t("signIn.resetPassword.title")}),e.jsx(Te,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Ft(r).then(()=>{A.success(t("common:copy.success"))}),children:e.jsx(ni,{className:"h-4 w-4"})})]})})]})})})]})}const Hd=Object.freeze(Object.defineProperty({__proto__:null,default:Ud},Symbol.toStringTag,{value:"Module"})),Ee=u.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:N("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",t&&"md:h-svh",s),...r}));Ee.displayName="Layout";const Re=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Re.displayName="LayoutHeader";const Fe=u.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Fe.displayName="LayoutBody";const Rr=ri,Ir=li,Vr=ii,ve=oi,he=ci,pe=di,ce=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Vn,{ref:r,sideOffset:n,className:N("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t}));ce.displayName=Vn.displayName;function Wt(){const{pathname:s}=_a();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function Mr({key:s,defaultValue:n}){const[t,r]=u.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return u.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function qd(){const[s,n]=Mr({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(i=>i!==a))}}}function Kd({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const m=`${a(d.title)}-${d.href}`;return n&&l?u.createElement(Wd,{...d,sub:l,key:m,closeNav:r}):n?u.createElement(Gd,{...d,key:m,closeNav:r}):l?u.createElement(Bd,{...d,sub:l,key:m,closeNav:r}):u.createElement(Fr,{...d,key:m,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:N("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",t),children:e.jsx(ve,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(i)})})})}function Fr({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Wt(),{t:d}=V();return e.jsxs(Us,{to:r,onClick:a,className:N(nt({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",i&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":l(r)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),d(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:d(t)})]})}function Bd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{isExpanded:l,toggleItem:d}=qd(),{t:m}=V(),o=!!r?.find(_=>i(_.href)),c=m(s),h=l(c)||o;return e.jsxs(Rr,{open:h,onOpenChange:()=>d(c),children:[e.jsxs(Ir,{className:N(nt({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),m(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:m(t)}),e.jsx("span",{className:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Mn,{stroke:1})})]}),e.jsx(Vr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(_=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Fr,{..._,subLink:!0,closeNav:a})},m(_.title)))})})]})}function Gd({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V();return e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(Us,{to:r,onClick:a,className:N(nt({variant:i(r)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:l(s)})]})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s),t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)})]})]})}function Wd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V(),d=!!r?.find(m=>i(m.href));return e.jsxs(Ss,{children:[e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Mn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(fs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ra,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(tt,{}),r.map(({title:m,icon:o,label:c,href:h})=>e.jsx(je,{asChild:!0,children:e.jsxs(Us,{to:h,onClick:a,className:`${i(h)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(m)}),c&&e.jsx("span",{className:"ml-auto text-xs",children:l(c)})]})},`${l(m)}-${h}`))]})]})}const Or=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(ui,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(mi,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(Fn,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(ka,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(xi,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(hi,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Ba,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(pi,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(On,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(fi,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Ln,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(gi,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(ji,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(vi,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Ba,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(bi,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(yi,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(Ni,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(zn,{size:18})}]}];function Yd({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=u.useState(!1),{t:i}=V();return u.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:N(`fixed left-0 right-0 top-0 z-50 flex h-auto flex-col border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>a(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${r?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(Ee,{className:"flex h-full flex-col",children:[e.jsxs(Re,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(_i,{}):e.jsx(wi,{})})]}),e.jsx(Kd,{id:"sidebar-menu",className:N("flex-1 overflow-auto",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:Or}),e.jsx("div",{className:N("border-t border-border/50 bg-background","px-4 py-2.5 text-xs text-muted-foreground",r?"block":"hidden md:block",n?"text-center":"text-left"),children:e.jsxs("div",{className:N("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:N("tracking-wide whitespace-nowrap","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(P,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(Ci,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Qd(){const[s,n]=Mr({key:"collapsed-sidebar",defaultValue:!1});return u.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function Jd(){const[s,n]=Qd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Yd,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(wa,{})})]})}const Xd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"})),Ms=u.forwardRef(({className:s,...n},t)=>e.jsx(Le,{ref:t,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ms.displayName=Le.displayName;const Zd=({children:s,...n})=>e.jsx(be,{...n,children:e.jsx(fe,{className:"overflow-hidden p-0",children:e.jsx(Ms,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Ks=u.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Si,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Le.Input,{ref:t,className:N("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Ks.displayName=Le.Input.displayName;const Fs=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.List,{ref:t,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Fs.displayName=Le.List.displayName;const Bs=u.forwardRef((s,n)=>e.jsx(Le.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Bs.displayName=Le.Empty.displayName;const Ye=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Group,{ref:t,className:N("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Ye.displayName=Le.Group.displayName;const rt=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Separator,{ref:t,className:N("-mx-1 h-px bg-border",s),...n}));rt.displayName=Le.Separator.displayName;const Me=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Item,{ref:t,className:N("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Me.displayName=Le.Item.displayName;function eu(){const s=[];for(const n of Or)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function Ke(){const[s,n]=u.useState(!1),t=Ts(),r=eu(),{t:a}=V("search"),{t:i}=V("nav");u.useEffect(()=>{const d=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=u.useCallback(d=>{n(!1),t(d)},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(An,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:a("placeholder")}),e.jsx("span",{className:"sr-only",children:a("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:a("shortcut.key")})]}),e.jsxs(Zd,{open:s,onOpenChange:n,children:[e.jsx(Ks,{placeholder:a("placeholder")}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:a("noResults")}),e.jsx(Ye,{heading:a("title"),children:r.map(d=>e.jsxs(Me,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}const ne=window?.settings?.secure_path,Lr=5*60*1e3,ba=new Map,su=s=>{const n=ba.get(s);return n?Date.now()-n.timestamp>Lr?(ba.delete(s),null):n.data:null},tu=(s,n)=>{ba.set(s,{data:n,timestamp:Date.now()})},au=async(s,n=Lr)=>{const t=su(s);if(t)return t;const r=await I.get(s);return tu(s,r),r},Ot={getList:s=>I.post(`${ne}/user/fetch`,s),update:s=>I.post(`${ne}/user/update`,s),resetSecret:s=>I.post(`${ne}/user/resetSecret`,{id:s}),generate:s=>I.post(`${ne}/user/generate`,s),getStats:s=>I.post(`${ne}/stat/getStatUser`,s),destroy:s=>I.post(`${ne}/user/destroy`,{id:s}),sendMail:s=>I.post(`${ne}/user/sendMail`,s),dumpCSV:s=>I.post(`${ne}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>I.post(`${ne}/user/ban`,s)},nn={getList:()=>au(`${ne}/notice/fetch`),save:s=>I.post(`${ne}/notice/save`,s),drop:s=>I.post(`${ne}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${ne}/notice/show`,{id:s}),sort:s=>I.post(`${ne}/notice/sort`,{ids:s})},la={getList:s=>I.post(`${ne}/ticket/fetch`,s),getInfo:s=>I.get(`${ne}/ticket/fetch?id=${s}`),reply:s=>I.post(`${ne}/ticket/reply`,s),close:s=>I.post(`${ne}/ticket/close`,{id:s})},rn={getSystemStatus:()=>I.get(`${ne}/system/getSystemStatus`),getQueueStats:()=>I.get(`${ne}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${ne}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${ne}/system/getQueueMasters`),getSystemLog:s=>I.get(`${ne}/system/getSystemLog`,{params:s})},_s={getPluginList:()=>I.get(`${ne}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),I.post(`${ne}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>I.post(`${ne}/plugin/delete`,{code:s}),installPlugin:s=>I.post(`${ne}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${ne}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${ne}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${ne}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${ne}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${ne}/plugin/config`,{code:s,config:n})},nu=()=>I.get(`${ne}/update/check`),ru=()=>I.post(`${ne}/update/execute`),lu=As("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function q({className:s,variant:n,...t}){return e.jsx("div",{className:N(lu({variant:n}),s),...t})}const zs=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs($n,{ref:r,className:N("relative overflow-hidden",s),...t,children:[e.jsx(ki,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Lt,{}),e.jsx(Ti,{})]}));zs.displayName=$n.displayName;const Lt=u.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(Un,{ref:r,orientation:n,className:N("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:e.jsx(Di,{className:"relative flex-1 rounded-full bg-border"})}));Lt.displayName=Un.displayName;function iu(){const{t:s}=V("common"),[n,t]=u.useState(!1),{data:r}=re({queryKey:["checkUpdate"],queryFn:async()=>await nu(),refetchInterval:1e3*60*60}),a=r?.data,i=es({mutationFn:ru,onSuccess:l=>{const d=l.data;d.success?(A.success(s("update.updateSuccess")),t(!1)):A.error(d.message)},onError:()=>{A.error(s("update.updateFailed"))}});return a?.has_update?e.jsxs(e.Fragment,{children:[e.jsxs(P,{size:"icon",variant:"ghost",className:"rounded-full relative",onClick:()=>t(!0),children:[e.jsx(Pi,{size:20,className:"text-red-500"}),e.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-red-500 rounded-full"})]}),e.jsx(be,{open:n,onOpenChange:t,children:e.jsxs(fe,{className:"sm:max-w-[500px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s("update.title")}),e.jsxs(Te,{children:[s("update.newVersion")," ",a?.latest_version]})]}),e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[s("update.currentVersion"),":",a?.current_version]}),e.jsxs(q,{variant:"outline",children:[s("update.latestVersion"),":",a?.latest_version]})]}),e.jsx(zs,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"space-y-4",children:a?.update_logs.map(l=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{variant:"secondary",children:l.version}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Ze(new Date(l.date),"yyyy-MM-dd HH:mm")})]}),e.jsx("p",{className:"text-sm",children:l.message})]},l.version))})})]}),e.jsxs(ze,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:s("update.updateLater")}),e.jsx(P,{onClick:()=>i.mutate(),disabled:i.isPending,children:i.isPending?s("update.updating"):s("update.updateNow")})]})]})})]}):null}function Ae(){const{theme:s,setTheme:n}=ec();return u.useEffect(()=>{const t=s==="dark"?"#020817":"#fff",r=document.querySelector("meta[name='theme-color']");r&&r.setAttribute("content",t)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(P,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(Ei,{size:20}):e.jsx(Ri,{size:20})}),e.jsx(Er,{}),e.jsx(iu,{})]})}const zr=u.forwardRef(({className:s,...n},t)=>e.jsx(Hn,{ref:t,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));zr.displayName=Hn.displayName;const Ar=u.forwardRef(({className:s,...n},t)=>e.jsx(qn,{ref:t,className:N("aspect-square h-full w-full",s),...n}));Ar.displayName=qn.displayName;const $r=u.forwardRef(({className:s,...n},t)=>e.jsx(Kn,{ref:t,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));$r.displayName=Kn.displayName;function $e(){const s=Ts(),n=yn(),t=Ii(Pd),{t:r}=V(["common"]),a=()=>{yr(),n(Dd()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(zr,{className:"h-8 w-8",children:[e.jsx(Ar,{src:t?.avatar_url,alt:i}),e.jsx($r,{children:l})]})})}),e.jsxs(fs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ra,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:i}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(tt,{}),e.jsx(je,{asChild:!0,children:e.jsxs(Us,{to:"/config/system",children:[r("common:settings"),e.jsx(va,{children:"⌘S"})]})}),e.jsx(tt,{}),e.jsxs(je,{onClick:a,children:[r("common:logout"),e.jsx(va,{children:"⇧⌘Q"})]})]})]})}const G=Vi,He=Ui,W=Mi,K=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Bn,{ref:r,className:N("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[n,e.jsx(Fi,{asChild:!0,children:e.jsx(Ta,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=Bn.displayName;const Ur=u.forwardRef(({className:s,...n},t)=>e.jsx(Gn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Oi,{className:"h-4 w-4"})}));Ur.displayName=Gn.displayName;const Hr=u.forwardRef(({className:s,...n},t)=>e.jsx(Wn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Ta,{className:"h-4 w-4"})}));Hr.displayName=Wn.displayName;const B=u.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(Li,{children:e.jsxs(Yn,{ref:a,className:N("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:t,...r,children:[e.jsx(Ur,{}),e.jsx(zi,{className:N("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Hr,{})]})}));B.displayName=Yn.displayName;const ou=u.forwardRef(({className:s,...n},t)=>e.jsx(Qn,{ref:t,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));ou.displayName=Qn.displayName;const z=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Jn,{ref:r,className:N("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Ai,{children:e.jsx($s,{className:"h-4 w-4"})})}),e.jsx($i,{children:n})]}));z.displayName=Jn.displayName;const cu=u.forwardRef(({className:s,...n},t)=>e.jsx(Xn,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));cu.displayName=Xn.displayName;function Gs({className:s,classNames:n,showOutsideDays:t=!0,...r}){return e.jsx(Hi,{showOutsideDays:t,className:N("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:N(st({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:N("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:N(st({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:a,...i})=>e.jsx(Zn,{className:N("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(Sa,{className:N("h-4 w-4",a),...i})},...r})}Gs.displayName="Calendar";const vs=Ki,bs=Bi,xs=u.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(qi,{children:e.jsx(er,{ref:a,align:n,sideOffset:t,className:N("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})}));xs.displayName=er.displayName;const Es={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},dt=s=>(s/100).toFixed(2),du=({active:s,payload:n,label:t})=>{const{t:r}=V();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:t}),n.map((a,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[r(a.name),":"]}),e.jsx("span",{className:"font-medium",children:a.name.includes(r("dashboard:overview.amount"))?`¥${dt(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},uu=[{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"}],mu=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=is(t,7);break;case"30d":r=is(t,30);break;case"90d":r=is(t,90);break;case"180d":r=is(t,180);break;case"365d":r=is(t,365);break;default:r=is(t,30)}return{startDate:r,endDate:t}};function xu(){const[s,n]=u.useState("amount"),[t,r]=u.useState("30d"),[a,i]=u.useState({from:is(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:m}=mu(t,a),{data:o}=re({queryKey:["orderStat",{start_date:Ze(d,"yyyy-MM-dd"),end_date:Ze(m,"yyyy-MM-dd")}],queryFn:async()=>{const{data:c}=await vc({start_date:Ze(d,"yyyy-MM-dd"),end_date:Ze(m,"yyyy-MM-dd")});return c},refetchInterval:3e4});return e.jsxs(We,{children:[e.jsx(ts,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Cs,{children:l("dashboard:overview.title")}),e.jsxs(et,{children:[o?.summary.start_date," ",l("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(G,{value:t,onValueChange:c=>r(c),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:uu.map(c=>e.jsx(z,{value:c.value,children:l(c.label)},c.value))})]}),t==="custom"&&e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a?.from?a.to?e.jsxs(e.Fragment,{children:[Ze(a.from,"yyyy-MM-dd")," -"," ",Ze(a.to,"yyyy-MM-dd")]}):Ze(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Gs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:c=>{c?.from&&c?.to&&i({from:c.from,to:c.to})},numberOfMonths:2})})]})]}),e.jsx(Gt,{value:s,onValueChange:c=>n(c),children:e.jsxs(vt,{children:[e.jsx(Ge,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(Ge,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(as,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",dt(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Gi,{width:"100%",height:"100%",children:e.jsxs(Wi,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Yi,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>Ze(new Date(c),"MM-dd",{locale:Zi})}),e.jsx(Qi,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>s==="amount"?`¥${dt(c)}`:l("dashboard:overview.transactions",{count:c})}),e.jsx(Ji,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Xi,{content:e.jsx(du,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ga,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Es.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ga,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Es.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Es.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Wa,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Es.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function oe({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function hu(){return e.jsxs(We,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(oe,{className:"h-4 w-[120px]"}),e.jsx(oe,{className:"h-4 w-4"})]}),e.jsxs(as,{children:[e.jsx(oe,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(oe,{className:"h-4 w-[100px]"})]})]})]})}function pu(){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(hu,{},n))})}var ae=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(ae||{});const ot={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},ct={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var os=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(os||{}),xe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(xe||{});const Nt={0:"待确认",1:"发放中",2:"有效",3:"无效"},_t={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Pe=(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))(Pe||{});const fu={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ie=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s.Tuic="tuic",s.Socks="socks",s.Naive="naive",s.Http="http",s.Mieru="mieru",s))(ie||{});const Xe=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"},{type:"tuic",label:"TUIC"},{type:"socks",label:"SOCKS"},{type:"naive",label:"Naive"},{type:"http",label:"HTTP"},{type:"mieru",label:"Mieru"}],qe={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50"};var Be=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Be||{});const gu={1:"按金额优惠",2:"按比例优惠"};var Vs=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Vs||{}),Oe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Oe||{}),xt=(s=>(s.MONTH="monthly",s.QUARTER="quarterly",s.HALF_YEAR="half_yearly",s.YEAR="yearly",s.TWO_YEAR="two_yearly",s.THREE_YEAR="three_yearly",s.ONETIME="onetime",s.RESET="reset_traffic",s))(xt||{});function Rs({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(We,{className:N("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Cs,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(as,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(ro,{className:N("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("ml-1 text-xs",r.isPositive?"text-emerald-500":"text-red-500"),children:[r.isPositive?"+":"-",Math.abs(r.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function ju({className:s}){const n=Ts(),{t}=V(),{data:r,isLoading:a}=re({queryKey:["dashboardStats"],queryFn:async()=>(await bc()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(pu,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",xe.PENDING.toString()),l.set("status",ae.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Rs,{title:t("dashboard:stats.todayIncome"),value:Ls(r.todayIncome),icon:e.jsx(eo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.monthlyIncome"),value:Ls(r.currentMonthIncome),icon:e.jsx(so,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(to,{className:N("h-4 w-4",r.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:r.ticketPendingTotal>0?t("dashboard:stats.hasPendingTickets"):t("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:r.ticketPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(ao,{className:N("h-4 w-4",r.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:r.commissionPendingTotal>0?t("dashboard:stats.hasPendingCommission"):t("dashboard:stats.noPendingCommission"),onClick:i,highlight:r.commissionPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyUpload"),value:ps(r.monthTraffic.upload),icon:e.jsx(pt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:ps(r.todayTraffic.upload)})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyDownload"),value:ps(r.monthTraffic.download),icon:e.jsx(no,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:ps(r.todayTraffic.download)})})]})}const ya={today:{getValue:()=>{const s=io();return{start:s,end:oo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:is(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:is(s,30),end:s}}},custom:{getValue:()=>null}};function ln({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=V(),i={today:a("dashboard:trafficRank.today"),last7days:a("dashboard:trafficRank.last7days"),last30days:a("dashboard:trafficRank.last30days"),custom:a("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(G,{value:s,onValueChange:t,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(ya).map(([l])=>e.jsx(z,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[Ze(n.from,"yyyy-MM-dd")," -"," ",Ze(n.to,"yyyy-MM-dd")]}):Ze(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Gs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:l=>{l?.from&&l?.to&&r({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const Qs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function vu({className:s}){const{t:n}=V(),[t,r]=u.useState("today"),[a,i]=u.useState({from:is(new Date,7),to:new Date}),[l,d]=u.useState("today"),[m,o]=u.useState({from:is(new Date,7),to:new Date}),c=u.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:ya[t].getValue(),[t,a]),h=u.useMemo(()=>l==="custom"?{start:m.from,end:m.to}:ya[l].getValue(),[l,m]),{data:_}=re({queryKey:["nodeTrafficRank",c.start,c.end],queryFn:()=>tn({type:"node",start_time:Se.round(c.start.getTime()/1e3),end_time:Se.round(c.end.getTime()/1e3)}),refetchInterval:3e4}),{data:E}=re({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>tn({type:"user",start_time:Se.round(h.start.getTime()/1e3),end_time:Se.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(We,{children:[e.jsx(ts,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(lo,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(ln,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(as,{className:"flex-1",children:_?.data?e.jsxs(zs,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:_.data.map(C=>e.jsx(ve,{delayDuration:200,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/_.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Lt,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(We,{children:[e.jsx(ts,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(ha,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(ln,{selectedRange:l,customDateRange:m,onRangeChange:d,onCustomRangeChange:o}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(as,{className:"flex-1",children:E?.data?e.jsxs(zs,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:E.data.map(C=>e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/E.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Lt,{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 Dt=u.forwardRef(({className:s,value:n,...t},r)=>e.jsx(sr,{ref:r,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(co,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Dt.displayName=sr.displayName;function bu(){const{t:s}=V(),[n,t]=u.useState(null),[r,a]=u.useState(null),[i,l]=u.useState(!0),[d,m]=u.useState(!1),o=async()=>{try{m(!0);const[_,E]=await Promise.all([rn.getSystemStatus(),rn.getQueueStats()]);t(_.data),a(E.data)}catch(_){console.error("Error fetching system data:",_)}finally{l(!1),m(!1)}};u.useEffect(()=>{o();const _=setInterval(o,3e4);return()=>clearInterval(_)},[]);const c=()=>{o()};if(i)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})});const h=_=>_?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(We,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(uo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(et,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:c,disabled:d,children:e.jsx(mo,{className:N("h-4 w-4",d&&"animate-spin")})})]}),e.jsx(as,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h(r?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(q,{variant:r?.status?"secondary":"destructive",children:r?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:r?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.recentJobs||0}),e.jsx(Dt,{value:(r?.recentJobs||0)/(r?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:r?.periods?.recentJobs||0})})})]})}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.jobsPerMinute||0}),e.jsx(Dt,{value:(r?.jobsPerMinute||0)/(r?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:r?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(We,{children:[e.jsxs(ts,{children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(et,{children:s("dashboard:queue.details.description")})]}),e.jsx(as,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:r?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:r?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[r?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:r?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[r?.processes||0," /"," ",(r?.processes||0)+(r?.pausedMasters||0)]})]}),e.jsx(Dt,{value:(r?.processes||0)/((r?.processes||0)+(r?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function yu(){const{t:s}=V();return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ke,{}),e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(ju,{}),e.jsx(xu,{}),e.jsx(vu,{}),e.jsx(bu,{})]})})})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:yu},Symbol.toStringTag,{value:"Module"}));function _u({className:s,items:n,...t}){const{pathname:r}=_a(),a=Ts(),[i,l]=u.useState(r??"/settings"),d=o=>{l(o),a(o)},{t:m}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(G,{value:i,onValueChange:d,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(W,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(z,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:m(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:N("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(o=>e.jsxs(Us,{to:o.href,className:N(nt({variant:"ghost"}),r===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),m(o.title)]},o.href))})})]})}const wu=[{title:"site.title",key:"site",icon:e.jsx(ho,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Ln,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(zn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(po,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(On,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(fo,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(go,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Fn,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(jo,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Cu(){const{t:s}=V("settings");return e.jsxs(Ee,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(ke,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(_u,{items:wu})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(wa,{})})})]})]})]})}const Su=Object.freeze(Object.defineProperty({__proto__:null,default:Cu},Symbol.toStringTag,{value:"Module"})),Y=u.forwardRef(({className:s,...n},t)=>e.jsx(nr,{className:N("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:t,children:e.jsx(vo,{className:N("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Y.displayName=nr.displayName;const ys=u.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:N("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}));ys.displayName="Textarea";const ku=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 Tu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),{data:a}=re({queryKey:["settings","site"],queryFn:()=>gs("site")}),{data:i}=re({queryKey:["plans"],queryFn:()=>qs()}),l=ge({resolver:Ne(ku),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=es({mutationFn:js,onSuccess:c=>{c.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(a?.data?.site){const c=a?.data?.site;Object.entries(c).forEach(([h,_])=>{l.setValue(h,_)}),r.current=c}},[a]);const m=u.useCallback(Se.debounce(async c=>{if(!Se.isEqual(c,r.current)){t(!0);try{const h=Object.entries(c).reduce((_,[E,C])=>(_[E]=C===null?"":C,_),{});await d(h),r.current=c}finally{t(!1)}}},1e3),[d]),o=u.useCallback(c=>{m(c)},[m]);return u.useEffect(()=>{const c=l.watch(h=>{o(h)});return()=>c.unsubscribe()},[l.watch,o]),e.jsx(_e,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:l.control,name:"app_name",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"app_description",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"app_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"force_https",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"logo",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"subscribe_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(y,{children:e.jsx(ys,{placeholder:s("site.form.subscribeUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"tos_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"stop_register",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"try_out_plan_id",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(y,{children:e.jsxs(G,{value:c.value?.toString(),onValueChange:h=>{c.onChange(Number(h)),o(l.getValues())},children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(h=>e.jsx(z,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(D,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(g,{control:l.control,name:"try_out_hour",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"currency",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"currency_symbol",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Du(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(ke,{}),e.jsx(Tu,{})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"})),Eu=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()}),Ru={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 Iu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Eu),defaultValues:Ru,mode:"onBlur"}),{data:i}=re({queryKey:["settings","safe"],queryFn:()=>gs("safe")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data.safe){const o=i.data.safe;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"email_verify",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"secure_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("email_whitelist_enable")&&e.jsx(g,{control:a.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(y,{children:e.jsx(ys,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` +import{r as u,j as e,t as Sl,c as kl,I as Ka,a as As,S as Na,u as Ts,b as Tl,d as _a,R as fn,e as gn,f as Dl,F as Pl,C as El,L as jn,T as vn,g as bn,h as Rl,i as Il,k as Vl,l as A,z as x,m as V,n as ge,o as Ne,p as re,q as es,s as Se,v as it,w as Ml,O as wa,x as Fl,y as Ol,A as Ll,B as zl,D as Al,E as $l,Q as Ul,G as Hl,H as ql,J as Kl,P as Bl,K as Gl,M as Wl,N as Yl,U as Ql,V as yn,W as Nn,X as zt,Y as At,Z as Ca,_ as ss,$ as $t,a0 as Ut,a1 as _n,a2 as wn,a3 as Cn,a4 as Sa,a5 as Sn,a6 as Jl,a7 as kn,a8 as Tn,a9 as Dn,aa as Pn,ab as $s,ac as En,ad as Xl,ae as Rn,af as In,ag as Zl,ah as ei,ai as si,aj as ti,ak as ai,al as ni,am as ri,an as li,ao as ii,ap as oi,aq as ci,ar as Vn,as as di,at as ui,au as Us,av as Mn,aw as mi,ax as xi,ay as Fn,az as ka,aA as hi,aB as pi,aC as Ba,aD as fi,aE as On,aF as gi,aG as Ln,aH as ji,aI as vi,aJ as bi,aK as yi,aL as Ni,aM as _i,aN as zn,aO as wi,aP as Ci,aQ as Si,aR as Le,aS as ki,aT as An,aU as $n,aV as Ti,aW as Di,aX as Un,aY as Pi,aZ as Ei,a_ as Ze,a$ as Ri,b0 as Ii,b1 as Hn,b2 as qn,b3 as Kn,b4 as Vi,b5 as Mi,b6 as Fi,b7 as Bn,b8 as Oi,b9 as Ta,ba as Gn,bb as Li,bc as Wn,bd as zi,be as Yn,bf as Ai,bg as Qn,bh as Jn,bi as $i,bj as Ui,bk as Xn,bl as Hi,bm as qi,bn as Zn,bo as Ki,bp as er,bq as Bi,br as Gi,bs as is,bt as jt,bu as Wi,bv as Yi,bw as Qi,bx as Ji,by as Xi,bz as Zi,bA as Ga,bB as Wa,bC as eo,bD as so,bE as to,bF as ao,bG as no,bH as ha,bI as pt,bJ as ro,bK as lo,bL as io,bM as Ya,bN as pa,bO as fa,bP as oo,bQ as co,bR as sr,bS as uo,bT as Da,bU as mo,bV as xo,bW as ho,bX as tr,bY as ar,bZ as po,b_ as fo,b$ as go,c0 as jo,c1 as vo,c2 as nr,c3 as bo,c4 as yo,c5 as No,c6 as _o,c7 as Rt,c8 as Ve,c9 as Qa,ca as wo,cb as rr,cc as lr,cd as ir,ce as or,cf as cr,cg as dr,ch as Co,ci as So,cj as ko,ck as Ht,cl as Hs,cm as cs,cn as ns,co as rs,cp as ds,cq as us,cr as ms,cs as To,ct as Do,cu as Po,cv as Eo,cw as Ro,cx as Io,cy as Vo,cz as Mo,cA as Fo,cB as ga,cC as Pa,cD as Ea,cE as Oo,cF as Ds,cG as Ps,cH as qt,cI as Lo,cJ as It,cK as zo,cL as Ja,cM as ur,cN as Xa,cO as Vt,cP as Ao,cQ as $o,cR as Uo,cS as Ho,cT as mr,cU as qo,cV as Ko,cW as xr,cX as ja,cY as hr,cZ as Bo,c_ as pr,c$ as fr,d0 as Go,d1 as Wo,d2 as Yo,d3 as Qo,d4 as Jo}from"./vendor.js";import"./index.js";var xp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Xo(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var t=function r(){return this instanceof r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return s[r]}})}),t}const Zo={theme:"system",setTheme:()=>null},gr=u.createContext(Zo);function ec({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=u.useState(()=>localStorage.getItem(t)||n);u.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const m=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(m);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(gr.Provider,{...r,value:l,children:s})}const sc=()=>{const s=u.useContext(gr);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},tc=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),ac=function(s,n){return new URL(s,n).href},Za={},me=function(n,t,r){let a=Promise.resolve();if(t&&t.length>0){const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),m=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(o=>{if(o=ac(o,r),o in Za)return;Za[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(!!r)for(let C=l.length-1;C>=0;C--){const S=l[C];if(S.href===o&&(!c||S.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const E=document.createElement("link");if(E.rel=c?"stylesheet":tc,c||(E.as="script"),E.crossOrigin="",E.href=o,m&&E.setAttribute("nonce",m),document.head.appendChild(E),c)return new Promise((C,S)=>{E.addEventListener("load",C),E.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function N(...s){return Sl(kl(s))}const nt=As("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),P=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:m,...o},c)=>{const h=r?Na:"button";return e.jsxs(h,{className:N(nt({variant:n,size:t,className:s})),disabled:l||i,ref:c,...o,children:[(d&&l||!d&&!m&&l)&&e.jsx(Ka,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&m&&e.jsx("div",{className:"ml-2",children:m}),m&&l&&e.jsx(Ka,{className:"ml-2 h-4 w-4 animate-spin"})]})});P.displayName="Button";function Ys({className:s,minimal:n=!1}){const t=Ts(),r=Tl(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:N("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{}),a]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function en(){const s=Ts();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function nc(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(P,{variant:"outline",children:"Learn more"})})]})})}function rc(s){return typeof s>"u"}function lc(s){return s===null}function ic(s){return lc(s)||rc(s)}class oc{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,t,r=null){const a=JSON.stringify({value:t,time:Date.now(),expire:r!==null?new Date().getTime()+r*1e3:null});this.storage.setItem(this.getKey(n),a)}get(n,t=null){const r=this.storage.getItem(this.getKey(n));if(!r)return{value:t,time:0};try{const a=JSON.parse(r),{value:i,time:l,expire:d}=a;return ic(d)||d>new Date().getTime()?{value:i,time:l}:(this.remove(n),{value:t,time:0})}catch{return this.remove(n),{value:t,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function jr({prefixKey:s="",storage:n=sessionStorage}){return new oc({prefixKey:s,storage:n})}const vr="Xboard_",cc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:localStorage})},dc=function(s={}){return jr({prefixKey:s.prefixKey||"",storage:sessionStorage})},Kt=cc({prefixKey:vr});dc({prefixKey:vr});const br="access_token";function ft(){return Kt.get(br)}function yr(){Kt.remove(br)}const sn=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function uc({children:s}){const n=Ts(),t=_a(),r=ft();return u.useEffect(()=>{if(!r.value&&!sn.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),sn.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const ke=u.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(fn,{ref:a,decorative:t,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));ke.displayName=fn.displayName;const mc=As("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Mt=u.forwardRef(({className:s,...n},t)=>e.jsx(gn,{ref:t,className:N(mc(),s),...n}));Mt.displayName=gn.displayName;const _e=Pl,Nr=u.createContext({}),g=({...s})=>e.jsx(Nr.Provider,{value:{name:s.name},children:e.jsx(El,{...s})}),Bt=()=>{const s=u.useContext(Nr),n=u.useContext(_r),{getFieldState:t,formState:r}=Dl(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:i}=n;return{id:i,name:s.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},_r=u.createContext({}),f=u.forwardRef(({className:s,...n},t)=>{const r=u.useId();return e.jsx(_r.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:N("space-y-2",s),...n})})});f.displayName="FormItem";const j=u.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Bt();return e.jsx(Mt,{ref:t,className:N(r&&"text-destructive",s),htmlFor:a,...n})});j.displayName="FormLabel";const y=u.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Bt();return e.jsx(Na,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});y.displayName="FormControl";const F=u.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Bt();return e.jsx("p",{ref:t,id:r,className:N("text-[0.8rem] text-muted-foreground",s),...n})});F.displayName="FormDescription";const D=u.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Bt(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:N("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});D.displayName="FormMessage";const Gt=Rl,vt=u.forwardRef(({className:s,...n},t)=>e.jsx(jn,{ref:t,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));vt.displayName=jn.displayName;const Ge=u.forwardRef(({className:s,...n},t)=>e.jsx(vn,{ref:t,className:N("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));Ge.displayName=vn.displayName;const ws=u.forwardRef(({className:s,...n},t)=>e.jsx(bn,{ref:t,className:N("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ws.displayName=bn.displayName;function we(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Il(s).format(n))}function xc(s=void 0,n="YYYY-MM-DD"){return we(s,n)}function Xs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ls(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,i=>i.includes(".")?".00":i);return n?`¥${a}`:a}function Ft(s){return new Promise(n=>{(async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(s);else{const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),!a)throw new Error("execCommand failed")}n(!0)}catch(r){console.error(r),n(!1)}})()})}function ps(s){const n=s/1024,t=n/1024,r=t/1024,a=r/1024;return a>=1?Xs(a)+" TB":r>=1?Xs(r)+" GB":t>=1?Xs(t)+" MB":Xs(n)+" KB"}const hc="locale";function pc(){return Kt.get(hc)}function wr(){yr();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),t=new URL(window.location.href),a=`${t.pathname.split("/")[1]?`/${t.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=a+(n?`?redirect=${s}`:"")}const fc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function gc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const I=Vl.create({baseURL:gc(),timeout:12e3,headers:{"Content-Type":"application/json"}});I.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=ft();if(!fc.includes(s.url?.split("?")[0]||"")){if(!n.value)return wr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=pc().value||"zh-CN",s},s=>Promise.reject(s));I.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,t=s.response?.data?.message;return(n===401||n===403)&&wr(),A.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const jc="access_token";function vc(s){Kt.set(jc,s)}const U=window?.settings?.secure_path,bc=s=>I.get(U+"/stat/getOrder",{params:s}),yc=()=>I.get(U+"/stat/getStats"),tn=s=>I.get(U+"/stat/getTrafficRank",{params:s}),Nc=()=>I.get(U+"/theme/getThemes"),_c=s=>I.post(U+"/theme/getThemeConfig",{name:s}),wc=(s,n)=>I.post(U+"/theme/saveThemeConfig",{name:s,config:n}),Cc=s=>{const n=new FormData;return n.append("file",s),I.post(U+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Sc=s=>I.post(U+"/theme/delete",{name:s}),kc=s=>I.post(U+"/config/save",s),Cr=()=>I.get(U+"/server/manage/getNodes"),Tc=s=>I.post(U+"/server/manage/save",s),Dc=s=>I.post(U+"/server/manage/drop",s),Pc=s=>I.post(U+"/server/manage/copy",s),Ec=s=>I.post(U+"/server/manage/update",s),Rc=s=>I.post(U+"/server/manage/sort",s),bt=()=>I.get(U+"/server/group/fetch"),Ic=s=>I.post(U+"/server/group/save",s),Vc=s=>I.post(U+"/server/group/drop",s),Sr=()=>I.get(U+"/server/route/fetch"),Mc=s=>I.post(U+"/server/route/save",s),Fc=s=>I.post(U+"/server/route/drop",s),Oc=()=>I.get(U+"/payment/fetch"),Lc=()=>I.get(U+"/payment/getPaymentMethods"),zc=s=>I.post(U+"/payment/getPaymentForm",s),Ac=s=>I.post(U+"/payment/save",s),$c=s=>I.post(U+"/payment/drop",s),Uc=s=>I.post(U+"/payment/show",s),Hc=s=>I.post(U+"/payment/sort",s),qc=s=>I.post(U+"/notice/save",s),Kc=s=>I.post(U+"/notice/drop",s),Bc=s=>I.post(U+"/notice/show",s),Gc=()=>I.get(U+"/knowledge/fetch"),Wc=s=>I.get(U+"/knowledge/fetch?id="+s),Yc=s=>I.post(U+"/knowledge/save",s),Qc=s=>I.post(U+"/knowledge/drop",s),Jc=s=>I.post(U+"/knowledge/show",s),Xc=s=>I.post(U+"/knowledge/sort",s),qs=()=>I.get(U+"/plan/fetch"),Zc=s=>I.post(U+"/plan/save",s),aa=s=>I.post(U+"/plan/update",s),ed=s=>I.post(U+"/plan/drop",s),sd=s=>I.post(U+"/plan/sort",{ids:s}),td=async s=>I.post(U+"/order/fetch",s),ad=s=>I.post(U+"/order/detail",s),nd=s=>I.post(U+"/order/paid",s),rd=s=>I.post(U+"/order/cancel",s),an=s=>I.post(U+"/order/update",s),ld=s=>I.post(U+"/order/assign",s),id=s=>I.post(U+"/coupon/fetch",s),od=s=>I.post(U+"/coupon/generate",s),cd=s=>I.post(U+"/coupon/drop",s),dd=s=>I.post(U+"/coupon/update",s),ud=s=>I.post(U+"/user/fetch",s),md=s=>I.post(U+"/user/update",s),xd=s=>I.post(U+"/user/resetSecret",s),hd=s=>I.post(U+"/user/generate",s),pd=s=>I.post(U+"/stat/getStatUser",s),fd=s=>I.post(U+"/ticket/fetch",s),gd=s=>I.get(U+"/ticket/fetch?id= "+s),jd=s=>I.post(U+"/ticket/close",{id:s}),gs=(s="")=>I.get(U+"/config/fetch?key="+s),js=s=>I.post(U+"/config/save",s),vd=()=>I.get(U+"/config/getEmailTemplate"),bd=()=>I.post(U+"/config/testSendMail"),yd=()=>I.post(U+"/config/setTelegramWebhook"),Nd=x.object({subscribe_template_singbox:x.string().nullable(),subscribe_template_clash:x.string().nullable(),subscribe_template_clashmeta:x.string().nullable(),subscribe_template_stash:x.string().nullable(),subscribe_template_surge:x.string().nullable()}),_d={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:""};function wd(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),[a,i]=u.useState("singbox"),l=ge({resolver:Ne(Nd),defaultValues:_d,mode:"onBlur"}),{data:d}=re({queryKey:["settings","client"],queryFn:()=>gs("subscribe_template")}),{mutateAsync:m}=es({mutationFn:js,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(d?.data.subscribe_template){const h=d.data.subscribe_template;Object.entries(h).forEach(([_,E])=>{l.setValue(_,E)}),r.current=h}},[d]),console.log(l.getValues());const o=u.useCallback(Se.debounce(async h=>{if(!Se.isEqual(h,r.current)){t(!0);try{await m(h),r.current=h}finally{t(!1)}}},1e3),[m]),c=u.useCallback(h=>{o(h)},[o]);return e.jsx(_e,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Gt,{value:a,onValueChange:i,children:[e.jsxs(vt,{children:[e.jsx(Ge,{value:"singbox",children:"Sing-box"}),e.jsx(Ge,{value:"clash",children:"Clash"}),e.jsx(Ge,{value:"clashmeta",children:"Clash Meta"}),e.jsx(Ge,{value:"stash",children:"Stash"}),e.jsx(Ge,{value:"surge",children:"Surge"})]}),e.jsx(ws,{value:"singbox",children:e.jsx(g,{control:l.control,name:"subscribe_template_singbox",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.singbox.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"json",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.singbox.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"clash",children:e.jsx(g,{control:l.control,name:"subscribe_template_clash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clash.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clash.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"clashmeta",children:e.jsx(g,{control:l.control,name:"subscribe_template_clashmeta",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.clashmeta.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.clashmeta.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"stash",children:e.jsx(g,{control:l.control,name:"subscribe_template_stash",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.stash.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"yaml",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.stash.description")}),e.jsx(D,{})]})})}),e.jsx(ws,{value:"surge",children:e.jsx(g,{control:l.control,name:"subscribe_template_surge",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe_template.surge.title")}),e.jsx(y,{children:e.jsx(it,{height:"500px",defaultLanguage:"ini",value:h.value||"",onChange:_=>{typeof _=="string"&&(h.onChange(_),c(l.getValues()))},options:{minimap:{enabled:!1},fontSize:14}})}),e.jsx(F,{children:s("subscribe_template.surge.description")}),e.jsx(D,{})]})})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Cd(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(ke,{}),e.jsx(wd,{})]})}const Sd=()=>e.jsx(uc,{children:e.jsx(wa,{})}),kd=Ml([{path:"/sign-in",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>qd);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Sd,{}),children:[{path:"/",lazy:async()=>({Component:(await me(()=>Promise.resolve().then(()=>Zd),void 0,import.meta.url)).default}),errorElement:e.jsx(Ys,{}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>_u);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ys,{}),children:[{path:"system",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>ku);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Eu);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Fu);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>$u);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Bu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ju);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>tm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>im);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>mm);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>gm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(Cd,{})}]},{path:"payment",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>km);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Vm);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>$m);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Ym);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Cx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Px);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Fx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ys,{}),children:[{path:"plan",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>Kx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>rh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>hh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ys,{}),children:[{path:"manage",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>qh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await me(async()=>{const{default:s}=await Promise.resolve().then(()=>dp);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ys},{path:"/404",Component:en},{path:"/503",Component:nc},{path:"*",Component:en}]);function Td(){return I.get("/user/info")}const na={token:ft()?.value||"",userInfo:null,isLoggedIn:!!ft()?.value,loading:!1,error:null},mt=Fl("user/fetchUserInfo",async()=>(await Td()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),kr=Ol({name:"user",initialState:na,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>na},extraReducers:s=>{s.addCase(mt.pending,n=>{n.loading=!0,n.error=null}).addCase(mt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(mt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return na})}}),{setToken:Dd,resetUserState:Pd}=kr.actions,Ed=s=>s.user.userInfo,Rd=kr.reducer,Tr=Ll({reducer:{user:Rd}});ft()?.value&&Tr.dispatch(mt());zl.use(Al).use($l).init({resources:{"en-US":window.XBOARD_TRANSLATIONS?.["en-US"]||{},"zh-CN":window.XBOARD_TRANSLATIONS?.["zh-CN"]||{},"ko-KR":window.XBOARD_TRANSLATIONS?.["ko-KR"]||{}},fallbackLng:"zh-CN",supportedLngs:["en-US","zh-CN","ko-KR"],detection:{order:["querystring","localStorage","navigator"],lookupQuerystring:"lang",lookupLocalStorage:"i18nextLng",caches:["localStorage"]},interpolation:{escapeValue:!1}});const Id=new Ul;Hl.createRoot(document.getElementById("root")).render(e.jsx(ql.StrictMode,{children:e.jsx(Kl,{client:Id,children:e.jsx(Bl,{store:Tr,children:e.jsxs(ec,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Gl,{router:kd}),e.jsx(Wl,{richColors:!0,position:"top-right"})]})})})}));const We=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));We.displayName="Card";const ts=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex flex-col space-y-1.5 p-6",s),...n}));ts.displayName="CardHeader";const Cs=u.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:N("font-semibold leading-none tracking-tight",s),...n}));Cs.displayName="CardTitle";const et=u.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:N("text-sm text-muted-foreground",s),...n}));et.displayName="CardDescription";const as=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("p-6 pt-0",s),...n}));as.displayName="CardContent";const Vd=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex items-center p-6 pt-0",s),...n}));Vd.displayName="CardFooter";const T=u.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));T.displayName="Input";const Dr=u.forwardRef(({className:s,...n},t)=>{const[r,a]=u.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}),e.jsx(P,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>a(i=>!i),children:r?e.jsx(Yl,{size:18}):e.jsx(Ql,{size:18})})]})});Dr.displayName="PasswordInput";const Md=s=>I({url:"/passport/auth/login",method:"post",data:s});function Fd({className:s,onForgotPassword:n,...t}){const r=Ts(),a=yn(),{t:i}=V("auth"),l=x.object({email:x.string().min(1,{message:i("signIn.validation.emailRequired")}),password:x.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=ge({resolver:Ne(l),defaultValues:{email:"",password:""}});async function m(o){try{const{data:c}=await Md(o);vc(c.auth_data),a(Dd(c.auth_data)),await a(mt()).unwrap(),r("/")}catch(c){console.error("Login failed:",c),c.response?.data?.message&&d.setError("root",{message:c.response.data.message})}}return e.jsx("div",{className:N("grid gap-6",s),...t,children:e.jsx(_e,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(m),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[d.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:d.formState.errors.root.message}),e.jsx(g,{control:d.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.email")}),e.jsx(y,{children:e.jsx(T,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"password",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:i("signIn.password")}),e.jsx(y,{children:e.jsx(Dr,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(D,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(P,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const be=Nn,Je=_n,Od=wn,yt=Ca,Pr=u.forwardRef(({className:s,...n},t)=>e.jsx(zt,{ref:t,className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));Pr.displayName=zt.displayName;const fe=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Od,{children:[e.jsx(Pr,{}),e.jsxs(At,{ref:r,className:N("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...t,children:[n,e.jsxs(Ca,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(ss,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fe.displayName=At.displayName;const Ce=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});Ce.displayName="DialogHeader";const ze=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});ze.displayName="DialogFooter";const ye=u.forwardRef(({className:s,...n},t)=>e.jsx($t,{ref:t,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));ye.displayName=$t.displayName;const Te=u.forwardRef(({className:s,...n},t)=>e.jsx(Ut,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Te.displayName=Ut.displayName;const st=As("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=u.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?Na:"button";return e.jsx(l,{className:N(st({variant:n,size:t,className:s})),ref:i,...a})});J.displayName="Button";const Ss=Zl,ks=ei,Ld=si,zd=u.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Cn,{ref:a,className:N("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...r,children:[t,e.jsx(Sa,{className:"ml-auto h-4 w-4"})]}));zd.displayName=Cn.displayName;const Ad=u.forwardRef(({className:s,...n},t)=>e.jsx(Sn,{ref:t,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));Ad.displayName=Sn.displayName;const fs=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Jl,{children:e.jsx(kn,{ref:r,sideOffset:n,className:N("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));fs.displayName=kn.displayName;const je=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Tn,{ref:r,className:N("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...t}));je.displayName=Tn.displayName;const $d=u.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Dn,{ref:a,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx($s,{className:"h-4 w-4"})})}),n]}));$d.displayName=Dn.displayName;const Ud=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(En,{ref:r,className:N("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Pn,{children:e.jsx(Xl,{className:"h-4 w-4 fill-current"})})}),n]}));Ud.displayName=En.displayName;const Ra=u.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Rn,{ref:r,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ra.displayName=Rn.displayName;const tt=u.forwardRef(({className:s,...n},t)=>e.jsx(In,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));tt.displayName=In.displayName;const va=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});va.displayName="DropdownMenuShortcut";const ra=[{code:"en-US",name:"English",flag:ti,shortName:"EN"},{code:"zh-CN",name:"中文",flag:ai,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:ni,shortName:"KR"}];function Er(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=ra.find(a=>a.code===s.language)||ra[1],r=t.flag;return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(r,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:t.shortName})]})}),e.jsx(fs,{align:"end",className:"w-[120px]",children:ra.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(je,{onClick:()=>n(a.code),className:N("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(i,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:N("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function Hd(){const[s,n]=u.useState(!1),{t}=V("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:[e.jsx("div",{className:"absolute right-4 top-4 md:right-8 md:top-8",children:e.jsx(Er,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[480px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(We,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(Fd,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(be,{open:s,onOpenChange:n,children:e.jsx(fe,{children:e.jsxs(Ce,{children:[e.jsx(ye,{children:t("signIn.resetPassword.title")}),e.jsx(Te,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Ft(r).then(()=>{A.success(t("common:copy.success"))}),children:e.jsx(ri,{className:"h-4 w-4"})})]})})]})})})]})}const qd=Object.freeze(Object.defineProperty({__proto__:null,default:Hd},Symbol.toStringTag,{value:"Module"})),Ee=u.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:N("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",t&&"md:h-svh",s),...r}));Ee.displayName="Layout";const Re=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Re.displayName="LayoutHeader";const Fe=u.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Fe.displayName="LayoutBody";const Rr=li,Ir=ii,Vr=oi,ve=ci,he=di,pe=ui,ce=u.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Vn,{ref:r,sideOffset:n,className:N("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t}));ce.displayName=Vn.displayName;function Wt(){const{pathname:s}=_a();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function Mr({key:s,defaultValue:n}){const[t,r]=u.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return u.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function Kd(){const[s,n]=Mr({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(i=>i!==a))}}}function Bd({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const m=`${a(d.title)}-${d.href}`;return n&&l?u.createElement(Yd,{...d,sub:l,key:m,closeNav:r}):n?u.createElement(Wd,{...d,key:m,closeNav:r}):l?u.createElement(Gd,{...d,sub:l,key:m,closeNav:r}):u.createElement(Fr,{...d,key:m,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:N("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",t),children:e.jsx(ve,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(i)})})})}function Fr({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Wt(),{t:d}=V();return e.jsxs(Us,{to:r,onClick:a,className:N(nt({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",i&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":l(r)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),d(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:d(t)})]})}function Gd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{isExpanded:l,toggleItem:d}=Kd(),{t:m}=V(),o=!!r?.find(_=>i(_.href)),c=m(s),h=l(c)||o;return e.jsxs(Rr,{open:h,onOpenChange:()=>d(c),children:[e.jsxs(Ir,{className:N(nt({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),m(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:m(t)}),e.jsx("span",{className:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Mn,{stroke:1})})]}),e.jsx(Vr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(_=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Fr,{..._,subLink:!0,closeNav:a})},m(_.title)))})})]})}function Wd({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V();return e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(Us,{to:r,onClick:a,className:N(nt({variant:i(r)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:l(s)})]})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s),t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)})]})]})}function Yd({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Wt(),{t:l}=V(),d=!!r?.find(m=>i(m.href));return e.jsxs(Ss,{children:[e.jsxs(he,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Mn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(fs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ra,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(tt,{}),r.map(({title:m,icon:o,label:c,href:h})=>e.jsx(je,{asChild:!0,children:e.jsxs(Us,{to:h,onClick:a,className:`${i(h)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(m)}),c&&e.jsx("span",{className:"ml-auto text-xs",children:l(c)})]})},`${l(m)}-${h}`))]})]})}const Or=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(mi,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(xi,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(Fn,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(ka,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(hi,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(pi,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Ba,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(fi,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(On,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(gi,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Ln,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(ji,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(vi,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(bi,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Ba,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(yi,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Ni,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(_i,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(zn,{size:18})}]}];function Qd({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=u.useState(!1),{t:i}=V();return u.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:N(`fixed left-0 right-0 top-0 z-50 flex h-auto flex-col border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>a(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${r?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(Ee,{className:"flex h-full flex-col",children:[e.jsxs(Re,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(wi,{}):e.jsx(Ci,{})})]}),e.jsx(Bd,{id:"sidebar-menu",className:N("flex-1 overflow-auto",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:Or}),e.jsx("div",{className:N("border-t border-border/50 bg-background","px-4 py-2.5 text-xs text-muted-foreground",r?"block":"hidden md:block",n?"text-center":"text-left"),children:e.jsxs("div",{className:N("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:N("tracking-wide whitespace-nowrap","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(P,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(Si,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Jd(){const[s,n]=Mr({key:"collapsed-sidebar",defaultValue:!1});return u.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function Xd(){const[s,n]=Jd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Qd,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(wa,{})})]})}const Zd=Object.freeze(Object.defineProperty({__proto__:null,default:Xd},Symbol.toStringTag,{value:"Module"})),Ms=u.forwardRef(({className:s,...n},t)=>e.jsx(Le,{ref:t,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ms.displayName=Le.displayName;const eu=({children:s,...n})=>e.jsx(be,{...n,children:e.jsx(fe,{className:"overflow-hidden p-0",children:e.jsx(Ms,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Ks=u.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ki,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Le.Input,{ref:t,className:N("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Ks.displayName=Le.Input.displayName;const Fs=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.List,{ref:t,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Fs.displayName=Le.List.displayName;const Bs=u.forwardRef((s,n)=>e.jsx(Le.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Bs.displayName=Le.Empty.displayName;const Ye=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Group,{ref:t,className:N("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Ye.displayName=Le.Group.displayName;const rt=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Separator,{ref:t,className:N("-mx-1 h-px bg-border",s),...n}));rt.displayName=Le.Separator.displayName;const Me=u.forwardRef(({className:s,...n},t)=>e.jsx(Le.Item,{ref:t,className:N("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Me.displayName=Le.Item.displayName;function su(){const s=[];for(const n of Or)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function Ke(){const[s,n]=u.useState(!1),t=Ts(),r=su(),{t:a}=V("search"),{t:i}=V("nav");u.useEffect(()=>{const d=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=u.useCallback(d=>{n(!1),t(d)},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(An,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:a("placeholder")}),e.jsx("span",{className:"sr-only",children:a("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:a("shortcut.key")})]}),e.jsxs(eu,{open:s,onOpenChange:n,children:[e.jsx(Ks,{placeholder:a("placeholder")}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:a("noResults")}),e.jsx(Ye,{heading:a("title"),children:r.map(d=>e.jsxs(Me,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}const ne=window?.settings?.secure_path,Lr=5*60*1e3,ba=new Map,tu=s=>{const n=ba.get(s);return n?Date.now()-n.timestamp>Lr?(ba.delete(s),null):n.data:null},au=(s,n)=>{ba.set(s,{data:n,timestamp:Date.now()})},nu=async(s,n=Lr)=>{const t=tu(s);if(t)return t;const r=await I.get(s);return au(s,r),r},Ot={getList:s=>I.post(`${ne}/user/fetch`,s),update:s=>I.post(`${ne}/user/update`,s),resetSecret:s=>I.post(`${ne}/user/resetSecret`,{id:s}),generate:s=>I.post(`${ne}/user/generate`,s),getStats:s=>I.post(`${ne}/stat/getStatUser`,s),destroy:s=>I.post(`${ne}/user/destroy`,{id:s}),sendMail:s=>I.post(`${ne}/user/sendMail`,s),dumpCSV:s=>I.post(`${ne}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>I.post(`${ne}/user/ban`,s)},nn={getList:()=>nu(`${ne}/notice/fetch`),save:s=>I.post(`${ne}/notice/save`,s),drop:s=>I.post(`${ne}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${ne}/notice/show`,{id:s}),sort:s=>I.post(`${ne}/notice/sort`,{ids:s})},la={getList:s=>I.post(`${ne}/ticket/fetch`,s),getInfo:s=>I.get(`${ne}/ticket/fetch?id=${s}`),reply:s=>I.post(`${ne}/ticket/reply`,s),close:s=>I.post(`${ne}/ticket/close`,{id:s})},rn={getSystemStatus:()=>I.get(`${ne}/system/getSystemStatus`),getQueueStats:()=>I.get(`${ne}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${ne}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${ne}/system/getQueueMasters`),getSystemLog:s=>I.get(`${ne}/system/getSystemLog`,{params:s})},_s={getPluginList:()=>I.get(`${ne}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),I.post(`${ne}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>I.post(`${ne}/plugin/delete`,{code:s}),installPlugin:s=>I.post(`${ne}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${ne}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${ne}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${ne}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${ne}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${ne}/plugin/config`,{code:s,config:n})},ru=()=>I.get(`${ne}/update/check`),lu=()=>I.post(`${ne}/update/execute`),iu=As("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function q({className:s,variant:n,...t}){return e.jsx("div",{className:N(iu({variant:n}),s),...t})}const zs=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs($n,{ref:r,className:N("relative overflow-hidden",s),...t,children:[e.jsx(Ti,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Lt,{}),e.jsx(Di,{})]}));zs.displayName=$n.displayName;const Lt=u.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(Un,{ref:r,orientation:n,className:N("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:e.jsx(Pi,{className:"relative flex-1 rounded-full bg-border"})}));Lt.displayName=Un.displayName;function ou(){const{t:s}=V("common"),[n,t]=u.useState(!1),{data:r}=re({queryKey:["checkUpdate"],queryFn:async()=>await ru(),refetchInterval:1e3*60*60}),a=r?.data,i=es({mutationFn:lu,onSuccess:l=>{const d=l.data;d.success?(A.success(s("update.updateSuccess")),t(!1)):A.error(d.message)},onError:()=>{A.error(s("update.updateFailed"))}});return a?.has_update?e.jsxs(e.Fragment,{children:[e.jsxs(P,{size:"icon",variant:"ghost",className:"rounded-full relative",onClick:()=>t(!0),children:[e.jsx(Ei,{size:20,className:"text-red-500"}),e.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-red-500 rounded-full"})]}),e.jsx(be,{open:n,onOpenChange:t,children:e.jsxs(fe,{className:"sm:max-w-[500px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s("update.title")}),e.jsxs(Te,{children:[s("update.newVersion")," ",a?.latest_version]})]}),e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[s("update.currentVersion"),":",a?.current_version]}),e.jsxs(q,{variant:"outline",children:[s("update.latestVersion"),":",a?.latest_version]})]}),e.jsx(zs,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"space-y-4",children:a?.update_logs.map(l=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{variant:"secondary",children:l.version}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Ze(new Date(l.date),"yyyy-MM-dd HH:mm")})]}),e.jsx("p",{className:"text-sm",children:l.message})]},l.version))})})]}),e.jsxs(ze,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:s("update.updateLater")}),e.jsx(P,{onClick:()=>i.mutate(),disabled:i.isPending,children:i.isPending?s("update.updating"):s("update.updateNow")})]})]})})]}):null}function Ae(){const{theme:s,setTheme:n}=sc();return u.useEffect(()=>{const t=s==="dark"?"#020817":"#fff",r=document.querySelector("meta[name='theme-color']");r&&r.setAttribute("content",t)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(P,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(Ri,{size:20}):e.jsx(Ii,{size:20})}),e.jsx(Er,{}),e.jsx(ou,{})]})}const zr=u.forwardRef(({className:s,...n},t)=>e.jsx(Hn,{ref:t,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));zr.displayName=Hn.displayName;const Ar=u.forwardRef(({className:s,...n},t)=>e.jsx(qn,{ref:t,className:N("aspect-square h-full w-full",s),...n}));Ar.displayName=qn.displayName;const $r=u.forwardRef(({className:s,...n},t)=>e.jsx(Kn,{ref:t,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));$r.displayName=Kn.displayName;function $e(){const s=Ts(),n=yn(),t=Vi(Ed),{t:r}=V(["common"]),a=()=>{yr(),n(Pd()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(zr,{className:"h-8 w-8",children:[e.jsx(Ar,{src:t?.avatar_url,alt:i}),e.jsx($r,{children:l})]})})}),e.jsxs(fs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ra,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:i}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(tt,{}),e.jsx(je,{asChild:!0,children:e.jsxs(Us,{to:"/config/system",children:[r("common:settings"),e.jsx(va,{children:"⌘S"})]})}),e.jsx(tt,{}),e.jsxs(je,{onClick:a,children:[r("common:logout"),e.jsx(va,{children:"⇧⌘Q"})]})]})]})}const G=Mi,He=Hi,W=Fi,K=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Bn,{ref:r,className:N("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[n,e.jsx(Oi,{asChild:!0,children:e.jsx(Ta,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=Bn.displayName;const Ur=u.forwardRef(({className:s,...n},t)=>e.jsx(Gn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Li,{className:"h-4 w-4"})}));Ur.displayName=Gn.displayName;const Hr=u.forwardRef(({className:s,...n},t)=>e.jsx(Wn,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Ta,{className:"h-4 w-4"})}));Hr.displayName=Wn.displayName;const B=u.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(zi,{children:e.jsxs(Yn,{ref:a,className:N("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:t,...r,children:[e.jsx(Ur,{}),e.jsx(Ai,{className:N("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Hr,{})]})}));B.displayName=Yn.displayName;const cu=u.forwardRef(({className:s,...n},t)=>e.jsx(Qn,{ref:t,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));cu.displayName=Qn.displayName;const z=u.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Jn,{ref:r,className:N("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx($i,{children:e.jsx($s,{className:"h-4 w-4"})})}),e.jsx(Ui,{children:n})]}));z.displayName=Jn.displayName;const du=u.forwardRef(({className:s,...n},t)=>e.jsx(Xn,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));du.displayName=Xn.displayName;function Gs({className:s,classNames:n,showOutsideDays:t=!0,...r}){return e.jsx(qi,{showOutsideDays:t,className:N("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:N(st({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:N("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:N(st({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:a,...i})=>e.jsx(Zn,{className:N("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(Sa,{className:N("h-4 w-4",a),...i})},...r})}Gs.displayName="Calendar";const vs=Bi,bs=Gi,xs=u.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(Ki,{children:e.jsx(er,{ref:a,align:n,sideOffset:t,className:N("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})}));xs.displayName=er.displayName;const Es={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},dt=s=>(s/100).toFixed(2),uu=({active:s,payload:n,label:t})=>{const{t:r}=V();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:t}),n.map((a,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[r(a.name),":"]}),e.jsx("span",{className:"font-medium",children:a.name.includes(r("dashboard:overview.amount"))?`¥${dt(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},mu=[{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"}],xu=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=is(t,7);break;case"30d":r=is(t,30);break;case"90d":r=is(t,90);break;case"180d":r=is(t,180);break;case"365d":r=is(t,365);break;default:r=is(t,30)}return{startDate:r,endDate:t}};function hu(){const[s,n]=u.useState("amount"),[t,r]=u.useState("30d"),[a,i]=u.useState({from:is(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:m}=xu(t,a),{data:o}=re({queryKey:["orderStat",{start_date:Ze(d,"yyyy-MM-dd"),end_date:Ze(m,"yyyy-MM-dd")}],queryFn:async()=>{const{data:c}=await bc({start_date:Ze(d,"yyyy-MM-dd"),end_date:Ze(m,"yyyy-MM-dd")});return c},refetchInterval:3e4});return e.jsxs(We,{children:[e.jsx(ts,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Cs,{children:l("dashboard:overview.title")}),e.jsxs(et,{children:[o?.summary.start_date," ",l("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(G,{value:t,onValueChange:c=>r(c),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:mu.map(c=>e.jsx(z,{value:c.value,children:l(c.label)},c.value))})]}),t==="custom"&&e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a?.from?a.to?e.jsxs(e.Fragment,{children:[Ze(a.from,"yyyy-MM-dd")," -"," ",Ze(a.to,"yyyy-MM-dd")]}):Ze(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Gs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:c=>{c?.from&&c?.to&&i({from:c.from,to:c.to})},numberOfMonths:2})})]})]}),e.jsx(Gt,{value:s,onValueChange:c=>n(c),children:e.jsxs(vt,{children:[e.jsx(Ge,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(Ge,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(as,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",dt(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",dt(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Wi,{width:"100%",height:"100%",children:e.jsxs(Yi,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Es.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Es.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Qi,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>Ze(new Date(c),"MM-dd",{locale:eo})}),e.jsx(Ji,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>s==="amount"?`¥${dt(c)}`:l("dashboard:overview.transactions",{count:c})}),e.jsx(Xi,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Zi,{content:e.jsx(uu,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ga,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Es.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ga,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Es.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wa,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Es.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Wa,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Es.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function oe({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function pu(){return e.jsxs(We,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(oe,{className:"h-4 w-[120px]"}),e.jsx(oe,{className:"h-4 w-4"})]}),e.jsxs(as,{children:[e.jsx(oe,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx(oe,{className:"h-4 w-[100px]"})]})]})]})}function fu(){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(pu,{},n))})}var ae=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(ae||{});const ot={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},ct={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var os=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(os||{}),xe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(xe||{});const Nt={0:"待确认",1:"发放中",2:"有效",3:"无效"},_t={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Pe=(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))(Pe||{});const gu={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ie=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s.Tuic="tuic",s.Socks="socks",s.Naive="naive",s.Http="http",s.Mieru="mieru",s))(ie||{});const Xe=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"},{type:"tuic",label:"TUIC"},{type:"socks",label:"SOCKS"},{type:"naive",label:"Naive"},{type:"http",label:"HTTP"},{type:"mieru",label:"Mieru"}],qe={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50"};var Be=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Be||{});const ju={1:"按金额优惠",2:"按比例优惠"};var Vs=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Vs||{}),Oe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Oe||{}),xt=(s=>(s.MONTH="monthly",s.QUARTER="quarterly",s.HALF_YEAR="half_yearly",s.YEAR="yearly",s.TWO_YEAR="two_yearly",s.THREE_YEAR="three_yearly",s.ONETIME="onetime",s.RESET="reset_traffic",s))(xt||{});function Rs({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(We,{className:N("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Cs,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(as,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(lo,{className:N("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("ml-1 text-xs",r.isPositive?"text-emerald-500":"text-red-500"),children:[r.isPositive?"+":"-",Math.abs(r.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function vu({className:s}){const n=Ts(),{t}=V(),{data:r,isLoading:a}=re({queryKey:["dashboardStats"],queryFn:async()=>(await yc()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(fu,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",xe.PENDING.toString()),l.set("status",ae.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Rs,{title:t("dashboard:stats.todayIncome"),value:Ls(r.todayIncome),icon:e.jsx(so,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.monthlyIncome"),value:Ls(r.currentMonthIncome),icon:e.jsx(to,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(ao,{className:N("h-4 w-4",r.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:r.ticketPendingTotal>0?t("dashboard:stats.hasPendingTickets"):t("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:r.ticketPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(no,{className:N("h-4 w-4",r.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:r.commissionPendingTotal>0?t("dashboard:stats.hasPendingCommission"):t("dashboard:stats.noPendingCommission"),onClick:i,highlight:r.commissionPendingTotal>0}),e.jsx(Rs,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Rs,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(ha,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyUpload"),value:ps(r.monthTraffic.upload),icon:e.jsx(pt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:ps(r.todayTraffic.upload)})}),e.jsx(Rs,{title:t("dashboard:stats.monthlyDownload"),value:ps(r.monthTraffic.download),icon:e.jsx(ro,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:ps(r.todayTraffic.download)})})]})}const ya={today:{getValue:()=>{const s=oo();return{start:s,end:co(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:is(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:is(s,30),end:s}}},custom:{getValue:()=>null}};function ln({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=V(),i={today:a("dashboard:trafficRank.today"),last7days:a("dashboard:trafficRank.last7days"),last30days:a("dashboard:trafficRank.last30days"),custom:a("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(G,{value:s,onValueChange:t,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(W,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(ya).map(([l])=>e.jsx(z,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[Ze(n.from,"yyyy-MM-dd")," -"," ",Ze(n.to,"yyyy-MM-dd")]}):Ze(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(xs,{className:"w-auto p-0",align:"end",children:e.jsx(Gs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:l=>{l?.from&&l?.to&&r({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const Qs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function bu({className:s}){const{t:n}=V(),[t,r]=u.useState("today"),[a,i]=u.useState({from:is(new Date,7),to:new Date}),[l,d]=u.useState("today"),[m,o]=u.useState({from:is(new Date,7),to:new Date}),c=u.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:ya[t].getValue(),[t,a]),h=u.useMemo(()=>l==="custom"?{start:m.from,end:m.to}:ya[l].getValue(),[l,m]),{data:_}=re({queryKey:["nodeTrafficRank",c.start,c.end],queryFn:()=>tn({type:"node",start_time:Se.round(c.start.getTime()/1e3),end_time:Se.round(c.end.getTime()/1e3)}),refetchInterval:3e4}),{data:E}=re({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>tn({type:"user",start_time:Se.round(h.start.getTime()/1e3),end_time:Se.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(We,{children:[e.jsx(ts,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(io,{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(ln,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(as,{className:"flex-1",children:_?.data?e.jsxs(zs,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:_.data.map(C=>e.jsx(ve,{delayDuration:200,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/_.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Lt,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(We,{children:[e.jsx(ts,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Cs,{className:"flex items-center text-base font-medium",children:[e.jsx(ha,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(ln,{selectedRange:l,customDateRange:m,onRangeChange:d,onCustomRangeChange:o}),e.jsx(Ya,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(as,{className:"flex-1",children:E?.data?e.jsxs(zs,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:E.data.map(C=>e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:C.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?e.jsx(pa,{className:"mr-1 h-3 w-3"}):e.jsx(fa,{className:"mr-1 h-3 w-3"}),Math.abs(C.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${C.value/E.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Qs(C.value)})]})]})})}),e.jsx(ce,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Qs(C.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",C.change>=0?"text-green-600":"text-red-600"),children:[C.change>=0?"+":"",C.change,"%"]})]})})]})},C.id))}),e.jsx(Lt,{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 Dt=u.forwardRef(({className:s,value:n,...t},r)=>e.jsx(sr,{ref:r,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(uo,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Dt.displayName=sr.displayName;function yu(){const{t:s}=V(),[n,t]=u.useState(null),[r,a]=u.useState(null),[i,l]=u.useState(!0),[d,m]=u.useState(!1),o=async()=>{try{m(!0);const[_,E]=await Promise.all([rn.getSystemStatus(),rn.getQueueStats()]);t(_.data),a(E.data)}catch(_){console.error("Error fetching system data:",_)}finally{l(!1),m(!1)}};u.useEffect(()=>{o();const _=setInterval(o,3e4);return()=>clearInterval(_)},[]);const c=()=>{o()};if(i)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})});const h=_=>_?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(We,{children:[e.jsxs(ts,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(et,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:c,disabled:d,children:e.jsx(xo,{className:N("h-4 w-4",d&&"animate-spin")})})]}),e.jsx(as,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[h(r?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(q,{variant:r?.status?"secondary":"destructive",children:r?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:r?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.recentJobs||0}),e.jsx(Dt,{value:(r?.recentJobs||0)/(r?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:r?.periods?.recentJobs||0})})})]})}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:r?.jobsPerMinute||0}),e.jsx(Dt,{value:(r?.jobsPerMinute||0)/(r?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:r?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(We,{children:[e.jsxs(ts,{children:[e.jsxs(Cs,{className:"flex items-center gap-2",children:[e.jsx(ho,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(et,{children:s("dashboard:queue.details.description")})]}),e.jsx(as,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:r?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:r?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[r?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:r?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[r?.processes||0," /"," ",(r?.processes||0)+(r?.pausedMasters||0)]})]}),e.jsx(Dt,{value:(r?.processes||0)/((r?.processes||0)+(r?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Nu(){const{t:s}=V();return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ke,{}),e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsx(Fe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(vu,{}),e.jsx(hu,{}),e.jsx(bu,{}),e.jsx(yu,{})]})})})]})}const _u=Object.freeze(Object.defineProperty({__proto__:null,default:Nu},Symbol.toStringTag,{value:"Module"}));function wu({className:s,items:n,...t}){const{pathname:r}=_a(),a=Ts(),[i,l]=u.useState(r??"/settings"),d=o=>{l(o),a(o)},{t:m}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(G,{value:i,onValueChange:d,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(W,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(z,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:m(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:N("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(o=>e.jsxs(Us,{to:o.href,className:N(nt({variant:"ghost"}),r===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),m(o.title)]},o.href))})})]})}const Cu=[{title:"site.title",key:"site",icon:e.jsx(po,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Ln,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(zn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(fo,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(On,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(go,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(jo,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Fn,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(vo,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Su(){const{t:s}=V("settings");return e.jsxs(Ee,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(ke,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(wu,{items:Cu})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(wa,{})})})]})]})]})}const ku=Object.freeze(Object.defineProperty({__proto__:null,default:Su},Symbol.toStringTag,{value:"Module"})),Y=u.forwardRef(({className:s,...n},t)=>e.jsx(nr,{className:N("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:t,children:e.jsx(bo,{className:N("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Y.displayName=nr.displayName;const ys=u.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:N("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}));ys.displayName="Textarea";const Tu=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 Du(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),{data:a}=re({queryKey:["settings","site"],queryFn:()=>gs("site")}),{data:i}=re({queryKey:["plans"],queryFn:()=>qs()}),l=ge({resolver:Ne(Tu),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=es({mutationFn:js,onSuccess:c=>{c.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(a?.data?.site){const c=a?.data?.site;Object.entries(c).forEach(([h,_])=>{l.setValue(h,_)}),r.current=c}},[a]);const m=u.useCallback(Se.debounce(async c=>{if(!Se.isEqual(c,r.current)){t(!0);try{const h=Object.entries(c).reduce((_,[E,C])=>(_[E]=C===null?"":C,_),{});await d(h),r.current=c}finally{t(!1)}}},1e3),[d]),o=u.useCallback(c=>{m(c)},[m]);return u.useEffect(()=>{const c=l.watch(h=>{o(h)});return()=>c.unsubscribe()},[l.watch,o]),e.jsx(_e,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:l.control,name:"app_name",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"app_description",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"app_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"force_https",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"logo",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"subscribe_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(y,{children:e.jsx(ys,{placeholder:s("site.form.subscribeUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"tos_url",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"stop_register",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(g,{control:l.control,name:"try_out_plan_id",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(y,{children:e.jsxs(G,{value:c.value?.toString(),onValueChange:h=>{c.onChange(Number(h)),o(l.getValues())},children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(h=>e.jsx(z,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(D,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(g,{control:l.control,name:"try_out_hour",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"currency",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:l.control,name:"currency_symbol",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Pu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(ke,{}),e.jsx(Du,{})]})}const Eu=Object.freeze(Object.defineProperty({__proto__:null,default:Pu},Symbol.toStringTag,{value:"Module"})),Ru=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()}),Iu={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 Vu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Ru),defaultValues:Iu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","safe"],queryFn:()=>gs("safe")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data.safe){const o=i.data.safe;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"email_verify",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"secure_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("email_whitelist_enable")&&e.jsx(g,{control:a.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(y,{children:e.jsx(ys,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` `),onChange:c=>{const h=c.target.value.split(` -`).filter(Boolean);o.onChange(h),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(F,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.key.description")}),e.jsx(D,{})]})})]}),e.jsx(g,{control:a.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(F,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"register_limit_count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(D,{})]})})]}),e.jsx(g,{control:a.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(F,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"password_limit_count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function Vu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ke,{}),e.jsx(Iu,{})]})}const Mu=Object.freeze(Object.defineProperty({__proto__:null,default:Vu},Symbol.toStringTag,{value:"Module"})),Fu=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")}),Ou={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 Lu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Fu),defaultValues:Ou,mode:"onBlur"}),{data:i}=re({queryKey:["settings","subscribe"],queryFn:()=>gs("subscribe")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data?.subscribe){const o=i?.data?.subscribe;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(F,{children:s("subscribe.plan_change_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(z,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(z,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(z,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(z,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(F,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"surplus_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(F,{children:s("subscribe.surplus_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.new_order_event.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("renew_order_event.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.change_order_event.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"subscribe_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:"subscribe",...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:o.value||"s"})]}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(F,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(F,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function zu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ke,{}),e.jsx(Lu,{})]})}const Au=Object.freeze(Object.defineProperty({__proto__:null,default:zu},Symbol.toStringTag,{value:"Module"})),$u=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)}),Uu={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 Hu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne($u),defaultValues:Uu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","invite"],queryFn:()=>gs("invite")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data?.invite){const o=i?.data?.invite;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"invite_force",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(F,{children:s("invite.invite_force.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"invite_commission",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_commission.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_gen_limit.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(F,{children:s("invite.invite_never_expire.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(F,{children:s("invite.commission_first_time.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(F,{children:s("invite.commission_auto_check.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_method.placeholder"),...o,value:Array.isArray(o.value)?o.value.join(","):"",onChange:c=>{const h=c.target.value.split(",").filter(Boolean);o.onChange(h),m(a.getValues())}})}),e.jsx(F,{children:s("invite.commission_withdraw_method.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(F,{children:s("invite.withdraw_close.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(F,{children:s("invite.commission_distribution.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l1")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l2")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l3")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function qu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ke,{}),e.jsx(Hu,{})]})}const Ku=Object.freeze(Object.defineProperty({__proto__:null,default:qu},Symbol.toStringTag,{value:"Module"})),Bu=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()}),Gu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Wu(){const{data:s}=re({queryKey:["settings","frontend"],queryFn:()=>gs("frontend")}),n=ge({resolver:Ne(Bu),defaultValues:Gu,mode:"onChange"});u.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,i])=>{n.setValue(a,i)})}},[s]);function t(r){js(r).then(({data:a})=>{a&&A.success("更新成功")})}return e.jsx(_e,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(g,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Y,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(g,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Y,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(g,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(f,{children:[e.jsx(j,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(y,{children:e.jsxs("select",{className:N(nt({variant:"outline"}),"w-[200px] appearance-none font-normal"),...r,children:[e.jsx("option",{value:"default",children:"默认"}),e.jsx("option",{value:"black",children:"黑色"}),e.jsx("option",{value:"blackblue",children:"暗蓝色"}),e.jsx("option",{value:"green",children:"奶绿色"})]})}),e.jsx(Ta,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(D,{})]})}),e.jsx(g,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(f,{children:[e.jsx(j,{children:"背景"}),e.jsx(y,{children:e.jsx(T,{placeholder:"请输入图片地址",...r})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(D,{})]})}),e.jsx(P,{type:"submit",children:"保存设置"})]})})}function Yu(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"个性化设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自定义系统界面外观,包括主题风格、布局、颜色方案、背景图等个性化选项。"})]}),e.jsx(ke,{}),e.jsx(Wu,{})]})}const Qu=Object.freeze(Object.defineProperty({__proto__:null,default:Yu},Symbol.toStringTag,{value:"Module"})),Ju=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()}),Xu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Zu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Ju),defaultValues:Xu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","server"],queryFn:()=>gs("server")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:c=>{c.data&&A.success(s("common.AutoSaved"))}});u.useEffect(()=>{if(i?.data.server){const c=i.data.server;Object.entries(c).forEach(([h,_])=>{a.setValue(h,_)}),r.current=c}},[i]);const d=u.useCallback(Se.debounce(async c=>{if(!Se.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),m=u.useCallback(c=>{d(c)},[d]);u.useEffect(()=>{const c=a.watch(h=>{m(h)});return()=>c.unsubscribe()},[a.watch,m]);const o=()=>{const c=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let _="";for(let E=0;Ee.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_token.title")}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{placeholder:s("server.server_token.placeholder"),...c,value:c.value||"",className:"pr-10"}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:h=>{h.preventDefault(),o()},children:e.jsx(bo,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ce,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(F,{children:s("server.server_token.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"server_pull_interval",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;c.onChange(_)}})}),e.jsx(F,{children:s("server.server_pull_interval.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"server_push_interval",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;c.onChange(_)}})}),e.jsx(F,{children:s("server.server_push_interval.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"device_limit_mode",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(G,{onValueChange:c.onChange,value:c.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(z,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(F,{children:s("server.device_limit_mode.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function em(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ke,{}),e.jsx(Zu,{})]})}const sm=Object.freeze(Object.defineProperty({__proto__:null,default:em},Symbol.toStringTag,{value:"Module"}));function tm({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(be,{open:s,onOpenChange:n,children:e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-destructive"}),e.jsx(ye,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Te,{children:r?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(zs,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const am=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function nm(){const{t:s}=V("settings"),[n,t]=u.useState(null),[r,a]=u.useState(!1),i=u.useRef(null),[l,d]=u.useState(!1),m=ge({resolver:Ne(am),defaultValues:{},mode:"onBlur"}),{data:o}=re({queryKey:["settings","email"],queryFn:()=>gs("email")}),{data:c}=re({queryKey:["emailTemplate"],queryFn:()=>jd()}),{mutateAsync:h}=es({mutationFn:js,onSuccess:w=>{w.data&&A.success(s("common.autoSaved"))}}),{mutate:_,isPending:E}=es({mutationFn:vd,onMutate:()=>{t(null),a(!1)},onSuccess:w=>{t(w.data),a(!0),w.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});u.useEffect(()=>{if(o?.data.email){const w=o.data.email;Object.entries(w).forEach(([b,k])=>{m.setValue(b,k)}),i.current=w}},[o]);const C=u.useCallback(Se.debounce(async w=>{if(!Se.isEqual(w,i.current)){d(!0);try{await h(w),i.current=w}finally{d(!1)}}},1e3),[h]),S=u.useCallback(w=>{C(w)},[C]);return u.useEffect(()=>{const w=m.watch(b=>{S(b)});return()=>w.unsubscribe()},[m.watch,S]),e.jsxs(e.Fragment,{children:[e.jsx(_e,{...m,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:m.control,name:"email_host",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_host.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_host.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_port",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_port.title")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("common.placeholder"),...w,value:w.value||"",onChange:b=>{const k=b.target.value?Number(b.target.value):null;w.onChange(k)}})}),e.jsx(F,{children:s("email.email_port.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_encryption",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(G,{onValueChange:w.onChange,value:w.value||"none",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(z,{value:"none",children:s("email.email_encryption.none")}),e.jsx(z,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(z,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(F,{children:s("email.email_encryption.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_username",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_username.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_username.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_password",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_password.title")}),e.jsx(y,{children:e.jsx(T,{type:"password",placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_password.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_from_address",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_from.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_from.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_template",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(G,{onValueChange:b=>{w.onChange(b),S(m.getValues())},value:w.value||void 0,children:[e.jsx(y,{children:e.jsx(K,{className:"w-[200px]",children:e.jsx(W,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(B,{children:c?.data?.map(b=>e.jsx(z,{value:b,children:b},b))})]}),e.jsx(F,{children:s("email.email_template.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"remind_mail_enable",render:({field:w})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(F,{children:s("email.remind_mail.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:w.value||!1,onCheckedChange:b=>{w.onChange(b),S(m.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{onClick:()=>_(),loading:E,disabled:E,children:s(E?"test.sending":"test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(tm,{open:r,onOpenChange:a,result:n})]})}function rm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ke,{}),e.jsx(nm,{})]})}const lm=Object.freeze(Object.defineProperty({__proto__:null,default:rm},Symbol.toStringTag,{value:"Module"})),im=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),om={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function cm(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(im),defaultValues:om,mode:"onBlur"}),{data:i}=re({queryKey:["settings","telegram"],queryFn:()=>gs("telegram")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}}),{mutate:d,isPending:m}=es({mutationFn:bd,onSuccess:h=>{h.data&&A.success(s("telegram.webhook.success"))}});u.useEffect(()=>{if(i?.data.telegram){const h=i.data.telegram;Object.entries(h).forEach(([_,E])=>{a.setValue(_,E)}),r.current=h}},[i]);const o=u.useCallback(Se.debounce(async h=>{if(!Se.isEqual(h,r.current)){t(!0);try{await l(h),r.current=h}finally{t(!1)}}},1e3),[l]),c=u.useCallback(h=>{o(h)},[o]);return u.useEffect(()=>{const h=a.watch(_=>{c(_)});return()=>h.unsubscribe()},[a.watch,c]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.bot_token.description")}),e.jsx(D,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(P,{loading:m,disabled:m,onClick:()=>d(),children:s(m?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(F,{children:s("telegram.webhook.description")}),e.jsx(D,{})]}),e.jsx(g,{control:a.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(F,{children:s("telegram.bot_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:h.value||!1,onCheckedChange:_=>{h.onChange(_),c(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.discuss_link.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function dm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ke,{}),e.jsx(cm,{})]})}const um=Object.freeze(Object.defineProperty({__proto__:null,default:dm},Symbol.toStringTag,{value:"Module"})),mm=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()}),xm={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function hm(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(mm),defaultValues:xm,mode:"onBlur"}),{data:i}=re({queryKey:["settings","app"],queryFn:()=>gs("app")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("app.save_success"))}});u.useEffect(()=>{if(i?.data.app){const o=i.data.app;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"windows_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.version.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"windows_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.download.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"macos_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.version.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"macos_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.download.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"android_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.version.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.version.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"android_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.download.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.download.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function pm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ke,{}),e.jsx(hm,{})]})}const fm=Object.freeze(Object.defineProperty({__proto__:null,default:pm},Symbol.toStringTag,{value:"Module"})),Ia=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:N("w-full caption-bottom text-sm",s),...n})}));Ia.displayName="Table";const Va=u.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:N("[&_tr]:border-b",s),...n}));Va.displayName="TableHeader";const Ma=u.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:N("[&_tr:last-child]:border-0",s),...n}));Ma.displayName="TableBody";const gm=u.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:N("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));gm.displayName="TableFooter";const Is=u.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:N("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Is.displayName="TableRow";const Fa=u.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:N("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Fa.displayName="TableHead";const Zs=u.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:N("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Zs.displayName="TableCell";const jm=u.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:N("mt-4 text-sm text-muted-foreground",s),...n}));jm.displayName="TableCaption";function vm({table:s}){const[n,t]=u.useState(""),{t:r}=V("common");u.useEffect(()=>{t((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const a=i=>{const l=parseInt(i);!isNaN(l)&&l>=1&&l<=s.getPageCount()?s.setPageIndex(l-1):t((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:r("table.pagination.selected",{selected:s.getFilteredSelectedRowModel().rows.length,total:s.getFilteredRowModel().rows.length})}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("table.pagination.itemsPerPage")}),e.jsxs(G,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx(z,{value:`${i}`,children:i},i))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(T,{type:"text",value:n,onChange:i=>t(i.target.value),onBlur:i=>a(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a(i.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:r("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.firstPage")}),e.jsx(yo,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.previousPage")}),e.jsx(Zn,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.nextPage")}),e.jsx(Sa,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.lastPage")}),e.jsx(No,{className:"h-4 w-4"})]})]})]})]})}function hs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:m=!0,isLoading:o=!1}){const{t:c}=V("common"),h=u.useRef(null),_=s.getAllColumns().filter(w=>w.getIsPinned()==="left"),E=s.getAllColumns().filter(w=>w.getIsPinned()==="right"),C=w=>_.slice(0,w).reduce((b,k)=>b+(k.getSize()??0),0),S=w=>E.slice(w+1).reduce((b,k)=>b+(k.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:h,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(Ia,{children:[e.jsx(Va,{children:s.getHeaderGroups().map(w=>e.jsx(Is,{className:"hover:bg-transparent",children:w.headers.map((b,k)=>{const p=b.column.getIsPinned()==="left",v=b.column.getIsPinned()==="right",M=p?C(_.indexOf(b.column)):void 0,H=v?S(E.indexOf(b.column)):void 0;return e.jsx(Fa,{colSpan:b.colSpan,style:{width:b.getSize(),...p&&{left:M},...v&&{right:H}},className:N("h-11 bg-card px-4 text-muted-foreground",(p||v)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",p&&"before:right-0",v&&"before:left-0"]),children:b.isPlaceholder?null:Rt(b.column.columnDef.header,b.getContext())},b.id)})},w.id))}),e.jsx(Ma,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((w,b)=>e.jsx(Is,{"data-state":w.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:k=>r?.(k,b),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:k=>d?.(k,b),children:w.getVisibleCells().map((k,p)=>{const v=k.column.getIsPinned()==="left",M=k.column.getIsPinned()==="right",H=v?C(_.indexOf(k.column)):void 0,se=M?S(E.indexOf(k.column)):void 0;return e.jsx(Zs,{style:{width:k.column.getSize(),...v&&{left:H},...M&&{right:se}},className:N("bg-card",(v||M)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",v&&"before:right-0",M&&"before:left-0"]),children:Rt(k.column.columnDef.cell,k.getContext())},k.id)})},w.id)):e.jsx(Is,{children:e.jsx(Zs,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:c("table.noData")})})})]})})}),m&&e.jsx(vm,{table:s})]})}const bm=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),on={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function qr({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=on}){const{t:a}=V("payment"),[i,l]=u.useState(!1),[d,m]=u.useState(!1),[o,c]=u.useState([]),[h,_]=u.useState([]),E=bm(a),C=ge({resolver:Ne(E),defaultValues:r,mode:"onChange"}),S=C.watch("payment");u.useEffect(()=>{i&&(async()=>{const{data:k}=await Oc();c(k)})()},[i]),u.useEffect(()=>{if(!S||!i)return;(async()=>{const k={payment:S,...t==="edit"&&{id:Number(C.getValues("id"))}};Lc(k).then(({data:p})=>{_(p);const v=p.reduce((M,H)=>(H.field_name&&(M[H.field_name]=H.value??""),M),{});C.setValue("config",v)})})()},[S,i,C,t]);const w=async b=>{m(!0);try{(await zc(b)).data&&(A.success(a("form.messages.success")),C.reset(on),s(),l(!1))}finally{m(!1)}};return e.jsxs(be,{open:i,onOpenChange:l,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(_e,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(w),className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"name",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:a("form.fields.name.placeholder"),...b})}),e.jsx(F,{children:a("form.fields.name.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"icon",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.icon.label")}),e.jsx(y,{children:e.jsx(T,{...b,value:b.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(F,{children:a("form.fields.icon.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"notify_domain",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.notify_domain.label")}),e.jsx(y,{children:e.jsx(T,{...b,value:b.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(F,{children:a("form.fields.notify_domain.description")}),e.jsx(D,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{control:C.control,name:"handling_fee_percent",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(y,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"handling_fee_fixed",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(y,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(D,{})]})})]}),e.jsx(g,{control:C.control,name:"payment",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.payment.label")}),e.jsxs(G,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(B,{children:o.map(k=>e.jsx(z,{value:k,children:k},k))})]}),e.jsx(F,{children:a("form.fields.payment.description")}),e.jsx(D,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(b=>e.jsx(g,{control:C.control,name:`config.${b.field_name}`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(j,{children:b.label}),e.jsx(y,{children:e.jsx(T,{...k,value:k.value||""})}),e.jsx(D,{})]})},b.field_name))}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:t,className:r}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(P,{variant:"ghost",size:"default",className:N("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",r),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),t&&e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Qa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(pa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(fa,{className:"h-4 w-4 text-foreground/70"}):e.jsx(_o,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:N("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",r),children:[e.jsx("span",{children:n}),t&&e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const Oa=wo,Kr=Co,ym=So,Br=u.forwardRef(({className:s,...n},t)=>e.jsx(rr,{className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));Br.displayName=rr.displayName;const Yt=u.forwardRef(({className:s,...n},t)=>e.jsxs(ym,{children:[e.jsx(Br,{}),e.jsx(lr,{ref:t,className:N("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));Yt.displayName=lr.displayName;const Qt=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Qt.displayName="AlertDialogHeader";const Jt=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Jt.displayName="AlertDialogFooter";const Xt=u.forwardRef(({className:s,...n},t)=>e.jsx(ir,{ref:t,className:N("text-lg font-semibold",s),...n}));Xt.displayName=ir.displayName;const Zt=u.forwardRef(({className:s,...n},t)=>e.jsx(or,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Zt.displayName=or.displayName;const ea=u.forwardRef(({className:s,...n},t)=>e.jsx(cr,{ref:t,className:N(st(),s),...n}));ea.displayName=cr.displayName;const sa=u.forwardRef(({className:s,...n},t)=>e.jsx(dr,{ref:t,className:N(st({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));sa.displayName=dr.displayName;function Qe({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Oa,{children:[e.jsx(Kr,{asChild:!0,children:n}),e.jsxs(Yt,{className:N("sm:max-w-[425px]",d),children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:t}),e.jsx(Zt,{children:r})]}),e.jsxs(Jt,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a})}),e.jsx(ea,{asChild:!0,children:e.jsx(P,{variant:l,onClick:s,children:i})})]})]})]})}const Gr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),Nm=({refetch:s,isSortMode:n=!1})=>{const{t}=V("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ht,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(q,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(Y,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await $c({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.name")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.payment")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:r})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:r,title:t("table.columns.notify_url")}),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{className:"ml-1",children:e.jsx(Gr,{className:"h-4 w-4"})}),e.jsx(ce,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:r.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("table.columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(qr,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(Qe,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await Ac({id:r.original.id});a&&s()},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function _m({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("payment"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{refetch:n}),e.jsx(T,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),i&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function wm(){const[s,n]=u.useState([]),[t,r]=u.useState([]),[a,i]=u.useState(!1),[l,d]=u.useState([]),[m,o]=u.useState({"drag-handle":!1}),[c,h]=u.useState({pageSize:20,pageIndex:0}),{refetch:_}=re({queryKey:["paymentList"],queryFn:async()=>{const{data:b}=await Fc();return d(b?.map(k=>({...k,enable:!!k.enable}))||[]),b}});u.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const E=(b,k)=>{a&&(b.dataTransfer.setData("text/plain",k.toString()),b.currentTarget.classList.add("opacity-50"))},C=(b,k)=>{if(!a)return;b.preventDefault(),b.currentTarget.classList.remove("bg-muted");const p=parseInt(b.dataTransfer.getData("text/plain"));if(p===k)return;const v=[...l],[M]=v.splice(p,1);v.splice(k,0,M),d(v)},S=async()=>{a?Uc({ids:l.map(b=>b.id)}).then(()=>{_(),i(!1),A.success("排序保存成功")}):i(!0)},w=ns({data:l,columns:Nm({refetch:_,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:m,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(hs,{table:w,toolbar:b=>e.jsx(_m,{table:b,refetch:_,saveOrder:S,isSortMode:a}),draggable:a,onDragStart:E,onDragEnd:b=>b.currentTarget.classList.remove("opacity-50"),onDragOver:b=>{b.preventDefault(),b.currentTarget.classList.add("bg-muted")},onDragLeave:b=>b.currentTarget.classList.remove("bg-muted"),onDrop:C,showPagination:!a})}function Cm(){const{t:s}=V("payment");return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(wm,{})})]})]})}const Sm=Object.freeze(Object.defineProperty({__proto__:null,default:Cm},Symbol.toStringTag,{value:"Module"}));function km({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,i]=u.useState(!0),[l,d]=u.useState(!1),[m,o]=u.useState(null),c=ko({config:To(Do())}),h=ge({resolver:Ne(c),defaultValues:{config:{}}});u.useEffect(()=>{(async()=>{try{const{data:S}=await _s.getPluginConfig(s);o(S),h.reset({config:Object.fromEntries(Object.entries(S).map(([w,b])=>[w,b.value]))})}catch{A.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const _=async C=>{d(!0);try{await _s.updatePluginConfig(s,C.config),A.success(r("messages.configSaveSuccess")),t()}catch{A.error(r("messages.configSaveError"))}finally{d(!1)}},E=(C,S)=>{switch(S.type){case"string":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsx(T,{placeholder:S.placeholder,...w})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);case"number":case"percentage":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{type:"number",placeholder:S.placeholder,...w,onChange:b=>{const k=Number(b.target.value);S.type==="percentage"?w.onChange(Math.min(100,Math.max(0,k))):w.onChange(k)},className:S.type==="percentage"?"pr-8":"",min:S.type==="percentage"?0:void 0,max:S.type==="percentage"?100:void 0,step:S.type==="percentage"?1:void 0}),S.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(Po,{className:"h-4 w-4 text-muted-foreground"})})]})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);case"select":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsxs(G,{onValueChange:w.onChange,defaultValue:w.value,children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:S.placeholder})})}),e.jsx(B,{children:S.options?.map(b=>e.jsx(z,{value:b.value,children:b.label},b.value))})]}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);case"boolean":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:S.label||S.description}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description})]}),e.jsx(y,{children:e.jsx(Y,{checked:w.value,onCheckedChange:w.onChange})})]})},C);case"text":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsx(ys,{placeholder:S.placeholder,...w})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{className:"h-4 w-[200px]"}),e.jsx(oe,{className:"h-10 w-full"}),e.jsx(oe,{className:"h-4 w-[200px]"}),e.jsx(oe,{className:"h-10 w-full"})]}):e.jsx(_e,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(_),className:"space-y-4",children:[m&&Object.entries(m).map(([C,S])=>E(C,S)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(P,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function Tm(){const{t:s}=V("plugin"),[n,t]=u.useState(null),[r,a]=u.useState(!1),[i,l]=u.useState(null),[d,m]=u.useState(""),[o,c]=u.useState("all"),[h,_]=u.useState(!1),[E,C]=u.useState(!1),[S,w]=u.useState(!1),b=u.useRef(null),{data:k,isLoading:p,refetch:v}=re({queryKey:["pluginList"],queryFn:async()=>{const{data:R}=await _s.getPluginList();return R}});k&&[...new Set(k.map(R=>R.category||"other"))];const M=k?.filter(R=>{const X=R.name.toLowerCase().includes(d.toLowerCase())||R.description.toLowerCase().includes(d.toLowerCase())||R.code.toLowerCase().includes(d.toLowerCase()),Ns=o==="all"||R.category===o;return X&&Ns}),H=async R=>{t(R),_s.installPlugin(R).then(()=>{A.success(s("messages.installSuccess")),v()}).catch(X=>{A.error(X.message||s("messages.installError"))}).finally(()=>{t(null)})},se=async R=>{t(R),_s.uninstallPlugin(R).then(()=>{A.success(s("messages.uninstallSuccess")),v()}).catch(X=>{A.error(X.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},L=async(R,X)=>{t(R),(X?_s.disablePlugin:_s.enablePlugin)(R).then(()=>{A.success(s(X?"messages.disableSuccess":"messages.enableSuccess")),v()}).catch(De=>{A.error(De.message||s(X?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},Z=R=>{k?.find(X=>X.code===R),l(R),a(!0)},de=async R=>{if(!R.name.endsWith(".zip")){A.error(s("upload.error.format"));return}_(!0),_s.uploadPlugin(R).then(()=>{A.success(s("messages.uploadSuccess")),C(!1),v()}).catch(X=>{A.error(X.message||s("messages.uploadError"))}).finally(()=>{_(!1),b.current&&(b.current.value="")})},Q=R=>{R.preventDefault(),R.stopPropagation(),R.type==="dragenter"||R.type==="dragover"?w(!0):R.type==="dragleave"&&w(!1)},te=R=>{R.preventDefault(),R.stopPropagation(),w(!1),R.dataTransfer.files&&R.dataTransfer.files[0]&&de(R.dataTransfer.files[0])},$=async R=>{t(R),_s.deletePlugin(R).then(()=>{A.success(s("messages.deleteSuccess")),v()}).catch(X=>{A.error(X.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ka,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(An,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(T,{placeholder:s("search.placeholder"),value:d,onChange:R=>m(R.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(P,{onClick:()=>C(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Gt,{defaultValue:"all",className:"w-full",children:[e.jsxs(vt,{children:[e.jsx(Ge,{value:"all",children:s("tabs.all")}),e.jsx(Ge,{value:"installed",children:s("tabs.installed")}),e.jsx(Ge,{value:"available",children:s("tabs.available")})]}),e.jsx(ws,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:p?e.jsxs(e.Fragment,{children:[e.jsx(oa,{}),e.jsx(oa,{}),e.jsx(oa,{})]}):M?.map(R=>e.jsx(ia,{plugin:R,onInstall:H,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:$,isLoading:n===R.name},R.name))})}),e.jsx(ws,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M?.filter(R=>R.is_installed).map(R=>e.jsx(ia,{plugin:R,onInstall:H,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:$,isLoading:n===R.name},R.name))})}),e.jsx(ws,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M?.filter(R=>!R.is_installed).map(R=>e.jsx(ia,{plugin:R,onInstall:H,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:$,isLoading:n===R.name},R.code))})})]})]}),e.jsx(be,{open:r,onOpenChange:a,children:e.jsxs(fe,{className:"sm:max-w-lg",children:[e.jsxs(Ce,{children:[e.jsxs(ye,{children:[k?.find(R=>R.code===i)?.name," ",s("config.title")]}),e.jsx(Te,{children:s("config.description")})]}),i&&e.jsx(km,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),v()}})]})}),e.jsx(be,{open:E,onOpenChange:C,children:e.jsxs(fe,{className:"sm:max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:N("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",S&&"border-primary/50 bg-muted/50"),onDragEnter:Q,onDragLeave:Q,onDragOver:Q,onDrop:te,children:[e.jsx("input",{type:"file",ref:b,className:"hidden",accept:".zip",onChange:R=>{const X=R.target.files?.[0];X&&de(X)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(pt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>b.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function ia({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l}){const{t:d}=V("plugin");return e.jsxs(We,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(ts,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{children:s.name}),s.is_installed&&e.jsx(q,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?d("status.enabled"):d("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ka,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[d("author"),": ",s.author]})})]})})]}),e.jsx(as,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(Eo,{className:"mr-2 h-4 w-4"}),d("button.config")]}),e.jsxs(P,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(Ro,{className:"mr-2 h-4 w-4"}),s.is_enabled?d("button.disable"):d("button.enable")]}),e.jsx(Qe,{title:d("uninstall.title"),description:d("uninstall.description"),cancelText:d("common:cancel"),confirmText:d("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(P,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(cs,{className:"mr-2 h-4 w-4"}),d("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{onClick:()=>n(s.code),disabled:l,loading:l,children:d("button.install")}),e.jsx(Qe,{title:d("delete.title"),description:d("delete.description"),cancelText:d("common:cancel"),confirmText:d("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(P,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(cs,{className:"h-4 w-4"})})})]})})})]})}function oa(){return e.jsxs(We,{children:[e.jsxs(ts,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-6 w-[200px]"}),e.jsx(oe,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(oe,{className:"h-5 w-[120px]"}),e.jsx(oe,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(oe,{className:"h-4 w-[300px]"}),e.jsx(oe,{className:"h-4 w-[150px]"})]})]}),e.jsx(as,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(oe,{className:"h-9 w-[100px]"}),e.jsx(oe,{className:"h-9 w-[100px]"}),e.jsx(oe,{className:"h-8 w-8"})]})})]})}const Dm=Object.freeze(Object.defineProperty({__proto__:null,default:Tm},Symbol.toStringTag,{value:"Module"})),Pm=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(T,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(ys,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:N(st({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Em({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=u.useState(!1),[i,l]=u.useState(!1),[d,m]=u.useState(!1),o=ge({defaultValues:n.configs.reduce((_,E)=>(_[E.field_name]="",_),{})}),c=async()=>{l(!0),Nc(s).then(({data:_})=>{Object.entries(_).forEach(([E,C])=>{o.setValue(E,C)})}).finally(()=>{l(!1)})},h=async _=>{m(!0),_c(s,_).then(()=>{A.success(t("config.success")),a(!1)}).finally(()=>{m(!1)})};return e.jsxs(be,{open:r,onOpenChange:_=>{a(_),_?c():o.reset()},children:[e.jsx(Je,{asChild:!0,children:e.jsx(P,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(fe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:t("config.title",{name:n.name})}),e.jsx(Te,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})}):e.jsx(_e,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(h),className:"space-y-4",children:[n.configs.map(_=>e.jsx(g,{control:o.control,name:_.field_name,render:({field:E})=>e.jsxs(f,{children:[e.jsx(j,{children:_.label}),e.jsx(y,{children:Pm(_,E)}),e.jsx(D,{})]})},_.field_name)),e.jsxs(ze,{className:"mt-6 gap-2",children:[e.jsx(P,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(P,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function Rm(){const{t:s}=V("theme"),[n,t]=u.useState(null),[r,a]=u.useState(!1),[i,l]=u.useState(!1),[d,m]=u.useState(!1),[o,c]=u.useState(null),h=u.useRef(null),[_,E]=u.useState(0),{data:C,isLoading:S,refetch:w}=re({queryKey:["themeList"],queryFn:async()=>{const{data:L}=await yc();return L}}),b=async L=>{t(L),Sc({frontend_theme:L}).then(()=>{A.success("主题切换成功"),w()}).finally(()=>{t(null)})},k=async L=>{if(!L.name.endsWith(".zip")){A.error(s("upload.error.format"));return}a(!0),wc(L).then(()=>{A.success("主题上传成功"),l(!1),w()}).finally(()=>{a(!1),h.current&&(h.current.value="")})},p=L=>{L.preventDefault(),L.stopPropagation(),L.type==="dragenter"||L.type==="dragover"?m(!0):L.type==="dragleave"&&m(!1)},v=L=>{L.preventDefault(),L.stopPropagation(),m(!1),L.dataTransfer.files&&L.dataTransfer.files[0]&&k(L.dataTransfer.files[0])},M=()=>{o&&E(L=>L===0?o.images.length-1:L-1)},H=()=>{o&&E(L=>L===o.images.length-1?0:L+1)},se=(L,Z)=>{E(0),c({name:L,images:Z})};return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(P,{onClick:()=>l(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:S?e.jsxs(e.Fragment,{children:[e.jsx(cn,{}),e.jsx(cn,{})]}):C?.themes&&Object.entries(C.themes).map(([L,Z])=>e.jsx(We,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:Z.background_url?`url(${Z.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:N("relative z-10 h-full transition-colors",Z.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!Z.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Qe,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(L===C?.active){A.error(s("card.delete.error.active"));return}t(L),Cc(L).then(()=>{A.success("主题删除成功"),w()}).finally(()=>{t(null)})},children:e.jsx(P,{disabled:n===L,loading:n===L,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(ts,{children:[e.jsx(Cs,{children:Z.name}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:Z.description}),Z.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:Z.version})})]})})]}),e.jsxs(as,{className:"flex items-center justify-end space-x-3",children:[Z.images&&Array.isArray(Z.images)&&Z.images.length>0&&e.jsx(P,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>se(Z.name,Z.images),children:e.jsx(Io,{className:"h-4 w-4"})}),e.jsx(Em,{themeKey:L,themeInfo:Z}),e.jsx(P,{onClick:()=>b(L),disabled:n===L||L===C.active,loading:n===L,variant:L===C.active?"secondary":"default",children:L===C.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},L))}),e.jsx(be,{open:i,onOpenChange:l,children:e.jsxs(fe,{className:"sm:max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:N("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",d&&"border-primary/50 bg-muted/50"),onDragEnter:p,onDragLeave:p,onDragOver:p,onDrop:v,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:L=>{const Z=L.target.files?.[0];Z&&k(Z)}}),r?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(pt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(be,{open:!!o,onOpenChange:L=>{L||(c(null),E(0))},children:e.jsxs(fe,{className:"max-w-4xl",children:[e.jsxs(Ce,{children:[e.jsxs(ye,{children:[o?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:o&&s("preview.imageCount",{current:_+1,total:o.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:o?.images[_]&&e.jsx("img",{src:o.images[_],alt:`${o.name} 预览图 ${_+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:M,children:e.jsx(Vo,{className:"h-4 w-4"})}),e.jsx(P,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:H,children:e.jsx(Mo,{className:"h-4 w-4"})})]})]}),o&&o.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:o.images.map((L,Z)=>e.jsx("button",{onClick:()=>E(Z),className:N("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",_===Z?"border-primary":"border-transparent"),children:e.jsx("img",{src:L,alt:`缩略图 ${Z+1}`,className:"h-full w-full object-cover"})},Z))})]})})]})]})}function cn(){return e.jsxs(We,{children:[e.jsxs(ts,{children:[e.jsx(oe,{className:"h-6 w-[200px]"}),e.jsx(oe,{className:"h-4 w-[300px]"})]}),e.jsxs(as,{className:"flex items-center justify-end space-x-3",children:[e.jsx(oe,{className:"h-10 w-[100px]"}),e.jsx(oe,{className:"h-10 w-[100px]"})]})]})}const Im=Object.freeze(Object.defineProperty({__proto__:null,default:Rm},Symbol.toStringTag,{value:"Module"})),La=u.forwardRef(({className:s,value:n,onChange:t,...r},a)=>{const[i,l]=u.useState("");u.useEffect(()=>{if(i.includes(",")){const m=new Set([...n,...i.split(",").map(o=>o.trim())]);t(Array.from(m)),l("")}},[i,t,n]);const d=()=>{if(i){const m=new Set([...n,i]);t(Array.from(m)),l("")}};return e.jsxs("div",{className:N(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(m=>e.jsxs(q,{variant:"secondary",children:[m,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(o=>o!==m))},children:e.jsx(ga,{className:"w-3"})})]},m)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d()):m.key==="Backspace"&&i.length===0&&n.length>0&&(m.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});La.displayName="InputTags";const Vm=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()}),Mm={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Wr({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Mm}){const{t:a}=V("notice"),[i,l]=u.useState(!1),d=ge({resolver:Ne(Vm),defaultValues:r,mode:"onChange",shouldFocusError:!0}),m=new Pa({html:!0});return e.jsx(_e,{...d,children:e.jsxs(be,{onOpenChange:l,open:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(fe,{className:"sm:max-w-[1025px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(g,{control:d.control,name:"title",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(T,{placeholder:a("form.fields.title.placeholder"),...o})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"content",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.content.label")}),e.jsx(y,{children:e.jsx(Ea,{style:{height:"500px"},value:o.value,renderHTML:c=>m.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"img_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"tags",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.tags.label")}),e.jsx(y,{children:e.jsx(La,{value:o.value,onChange:o.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",onClick:o=>{o.preventDefault(),d.handleSubmit(async c=>{Hc(c).then(({data:h})=>{h&&(A.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function Fm({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("notice"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!r&&e.jsx(Wr,{refetch:n}),!r&&e.jsx(T,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),i&&!r&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const Om=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Fo,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(q,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Y,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await Kc({id:t.original.id});r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Wr,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:t.original}),e.jsx(Qe,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{qc({id:t.original.id}).then(()=>{A.success(n("table.actions.delete.success")),s()})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function Lm(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState(!1),[c,h]=u.useState({}),[_,E]=u.useState({pageSize:50,pageIndex:0}),[C,S]=u.useState([]),{refetch:w}=re({queryKey:["notices"],queryFn:async()=>{const{data:M}=await nn.getList();return S(M),M}});u.useEffect(()=>{r({"drag-handle":m,content:!m,created_at:!m,actions:!m}),E({pageSize:m?99999:50,pageIndex:0})},[m]);const b=(M,H)=>{m&&(M.dataTransfer.setData("text/plain",H.toString()),M.currentTarget.classList.add("opacity-50"))},k=(M,H)=>{if(!m)return;M.preventDefault(),M.currentTarget.classList.remove("bg-muted");const se=parseInt(M.dataTransfer.getData("text/plain"));if(se===H)return;const L=[...C],[Z]=L.splice(se,1);L.splice(H,0,Z),S(L)},p=async()=>{if(!m){o(!0);return}nn.sort(C.map(M=>M.id)).then(()=>{A.success("排序保存成功"),o(!1),w()}).finally(()=>{o(!1)})},v=ns({data:C??[],columns:Om(w),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:c,pagination:_},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:h,onPaginationChange:E,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:v,toolbar:M=>e.jsx(Fm,{table:M,refetch:w,saveOrder:p,isSortMode:m}),draggable:m,onDragStart:b,onDragEnd:M=>M.currentTarget.classList.remove("opacity-50"),onDragOver:M=>{M.preventDefault(),M.currentTarget.classList.add("bg-muted")},onDragLeave:M=>M.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!m})})}function zm(){const{t:s}=V("notice");return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Lm,{})})]})]})}const Am=Object.freeze(Object.defineProperty({__proto__:null,default:zm},Symbol.toStringTag,{value:"Module"})),$m=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()}),Um={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Yr({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Um}){const{t:a}=V("knowledge"),[i,l]=u.useState(!1),d=ge({resolver:Ne($m),defaultValues:r,mode:"onChange",shouldFocusError:!0}),m=new Pa({html:!0});return u.useEffect(()=>{i&&r.id&&Gc(r.id).then(({data:o})=>{d.reset(o)})},[r.id,d,i]),e.jsxs(be,{onOpenChange:l,open:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(fe,{className:"sm:max-w-[1025px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(_e,{...d,children:[e.jsx(g,{control:d.control,name:"title",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(T,{placeholder:a("form.titlePlaceholder"),...o})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"category",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(T,{placeholder:a("form.categoryPlaceholder"),...o})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"language",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.language")}),e.jsx(y,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(c=>e.jsx(z,{value:c.value,className:"cursor-pointer",children:a(`languages.${c.value}`)},c.value))})]})})]})}),e.jsx(g,{control:d.control,name:"body",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.content")}),e.jsx(y,{children:e.jsx(Ea,{style:{height:"500px"},value:o.value,renderHTML:c=>m.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(D,{})]})}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{d.handleSubmit(o=>{Wc(o).then(({data:c})=>{c&&(d.reset(),A.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function Hm({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function qm({table:s,refetch:n,saveOrder:t,isSortMode:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yr,{refreshData:n}),e.jsx(T,{placeholder:i("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(Hm,{column:s.getColumn("category"),title:i("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const Km=({refetch:s,isSortMode:n=!1})=>{const{t}=V("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ht,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(q,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Y,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Qc({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.title")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:r.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(q,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Yr,{refreshData:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(Qe,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Yc({id:r.original.id}).then(({data:a})=>{a&&(A.success(t("messages.operationSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function Bm(){const[s,n]=u.useState([]),[t,r]=u.useState([]),[a,i]=u.useState(!1),[l,d]=u.useState([]),[m,o]=u.useState({"drag-handle":!1}),[c,h]=u.useState({pageSize:20,pageIndex:0}),{refetch:_,isLoading:E,data:C}=re({queryKey:["knowledge"],queryFn:async()=>{const{data:p}=await Bc();return d(p||[]),p}});u.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const S=(p,v)=>{a&&(p.dataTransfer.setData("text/plain",v.toString()),p.currentTarget.classList.add("opacity-50"))},w=(p,v)=>{if(!a)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const M=parseInt(p.dataTransfer.getData("text/plain"));if(M===v)return;const H=[...l],[se]=H.splice(M,1);H.splice(v,0,se),d(H)},b=async()=>{a?Jc({ids:l.map(p=>p.id)}).then(()=>{_(),i(!1),A.success("排序保存成功")}):i(!0)},k=ns({data:l,columns:Km({refetch:_,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:m,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,onPaginationChange:h,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:k,toolbar:p=>e.jsx(qm,{table:p,refetch:_,saveOrder:b,isSortMode:a}),draggable:a,onDragStart:S,onDragEnd:p=>p.currentTarget.classList.remove("opacity-50"),onDragOver:p=>{p.preventDefault(),p.currentTarget.classList.add("bg-muted")},onDragLeave:p=>p.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!a})}function Gm(){const{t:s}=V("knowledge");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Bm,{})})]})]})}const Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"}));function Ym(s,n){const[t,r]=u.useState(s);return u.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function ca(s,n){if(s.length===0)return{};if(!n)return{"":s};const t={};return s.forEach(r=>{const a=r[n]||"";t[a]||(t[a]=[]),t[a].push(r)}),t}function Qm(s,n){const t=JSON.parse(JSON.stringify(s));for(const[r,a]of Object.entries(t))t[r]=a.filter(i=>!n.find(l=>l.value===i.value));return t}function Jm(s,n){for(const[,t]of Object.entries(s))if(t.some(r=>n.find(a=>a.value===r.value)))return!0;return!1}const Qr=u.forwardRef(({className:s,...n},t)=>Oo(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:N("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Qr.displayName="CommandEmpty";const at=u.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:m,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:c,hidePlaceholderWhenSelected:h,disabled:_,groupBy:E,className:C,badgeClassName:S,selectFirstItem:w=!0,creatable:b=!1,triggerSearchOnFocus:k=!1,commandProps:p,inputProps:v,hideClearAllButton:M=!1},H)=>{const se=u.useRef(null),[L,Z]=u.useState(!1),de=u.useRef(!1),[Q,te]=u.useState(!1),[$,R]=u.useState(s||[]),[X,Ns]=u.useState(ca(r,E)),[De,le]=u.useState(""),Os=Ym(De,i||500);u.useImperativeHandle(H,()=>({selectedValue:[...$],input:se.current,focus:()=>se.current?.focus()}),[$]);const Ws=u.useCallback(ee=>{const ue=$.filter(Ue=>Ue.value!==ee.value);R(ue),n?.(ue)},[n,$]),bl=u.useCallback(ee=>{const ue=se.current;ue&&((ee.key==="Delete"||ee.key==="Backspace")&&ue.value===""&&$.length>0&&($[$.length-1].fixed||Ws($[$.length-1])),ee.key==="Escape"&&ue.blur())},[Ws,$]);u.useEffect(()=>{s&&R(s)},[s]),u.useEffect(()=>{if(!a||l)return;const ee=ca(a||[],E);JSON.stringify(ee)!==JSON.stringify(X)&&Ns(ee)},[r,a,E,l,X]),u.useEffect(()=>{const ee=async()=>{te(!0);const Ue=await l?.(Os);Ns(ca(Ue||[],E)),te(!1)};(async()=>{!l||!L||(k&&await ee(),Os&&await ee())})()},[Os,E,L,k]);const yl=()=>{if(!b||Jm(X,[{value:De,label:De}])||$.find(ue=>ue.value===De))return;const ee=e.jsx(Me,{value:De,className:"cursor-pointer",onMouseDown:ue=>{ue.preventDefault(),ue.stopPropagation()},onSelect:ue=>{if($.length>=o){c?.($.length);return}le("");const Ue=[...$,{value:ue,label:ue}];R(Ue),n?.(Ue)},children:`Create "${De}"`});if(!l&&De.length>0||l&&Os.length>0&&!Q)return ee},Nl=u.useCallback(()=>{if(m)return l&&!b&&Object.keys(X).length===0?e.jsx(Me,{value:"-",disabled:!0,children:m}):e.jsx(Qr,{children:m})},[b,m,l,X]),_l=u.useMemo(()=>Qm(X,$),[X,$]),wl=u.useCallback(()=>{if(p?.filter)return p.filter;if(b)return(ee,ue)=>ee.toLowerCase().includes(ue.toLowerCase())?1:-1},[b,p?.filter]),Cl=u.useCallback(()=>{const ee=$.filter(ue=>ue.fixed);R(ee),n?.(ee)},[n,$]);return e.jsxs(Ms,{...p,onKeyDown:ee=>{bl(ee),p?.onKeyDown?.(ee)},className:N("h-auto overflow-visible bg-transparent",p?.className),shouldFilter:p?.shouldFilter!==void 0?p.shouldFilter:!l,filter:wl(),children:[e.jsx("div",{className:N("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":$.length!==0,"cursor-text":!_&&$.length!==0},C),onClick:()=>{_||se.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[$.map(ee=>e.jsxs(q,{className:N("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",S),"data-fixed":ee.fixed,"data-disabled":_||void 0,children:[ee.label,e.jsx("button",{className:N("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(_||ee.fixed)&&"hidden"),onKeyDown:ue=>{ue.key==="Enter"&&Ws(ee)},onMouseDown:ue=>{ue.preventDefault(),ue.stopPropagation()},onClick:()=>Ws(ee),children:e.jsx(ga,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},ee.value)),e.jsx(Le.Input,{...v,ref:se,value:De,disabled:_,onValueChange:ee=>{le(ee),v?.onValueChange?.(ee)},onBlur:ee=>{de.current===!1&&Z(!1),v?.onBlur?.(ee)},onFocus:ee=>{Z(!0),k&&l?.(Os),v?.onFocus?.(ee)},placeholder:h&&$.length!==0?"":t,className:N("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":$.length===0,"ml-1":$.length!==0},v?.className)}),e.jsx("button",{type:"button",onClick:Cl,className:N((M||_||$.length<1||$.filter(ee=>ee.fixed).length===$.length)&&"hidden"),children:e.jsx(ga,{})})]})}),e.jsx("div",{className:"relative",children:L&&e.jsx(Fs,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{de.current=!1},onMouseEnter:()=>{de.current=!0},onMouseUp:()=>{se.current?.focus()},children:Q?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Nl(),yl(),!w&&e.jsx(Me,{value:"-",className:"hidden"}),Object.entries(_l).map(([ee,ue])=>e.jsx(Ye,{heading:ee,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ue.map(Ue=>e.jsx(Me,{value:Ue.value,disabled:Ue.disable,onMouseDown:lt=>{lt.preventDefault(),lt.stopPropagation()},onSelect:()=>{if($.length>=o){c?.($.length);return}le("");const lt=[...$,Ue];R(lt),n?.(lt)},className:N("cursor-pointer",Ue.disable&&"cursor-default text-muted-foreground"),children:Ue.label},Ue.value))})},ee))]})})})]})});at.displayName="MultipleSelector";const Xm=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function ta({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),i=ge({resolver:Ne(Xm(a)),defaultValues:t,mode:"onChange"}),[l,d]=u.useState(!1),[m,o]=u.useState(!1),c=async h=>{o(!0),Rc(h).then(()=>{A.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{o(!1)})};return e.jsxs(be,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(_e,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(g,{control:i.control,name:"name",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.name")}),e.jsx(y,{children:e.jsx(T,{placeholder:a("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(F,{children:a("form.nameDescription")}),e.jsx(D,{})]})}),e.jsxs(ze,{className:"gap-2",children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(P,{type:"submit",disabled:m||!i.formState.isValid,children:[m&&e.jsx(Da,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Jr=u.createContext(void 0);function Zm({children:s,refetch:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null),[l,d]=u.useState(ie.Shadowsocks);return e.jsx(Jr.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function Xr(){const s=u.useContext(Jr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function da({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=V("server");u.useEffect(()=>{console.log(n)},[n]);const[i,l]=u.useState(!1),[d,m]=u.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,c]=u.useState(null),h=b=>{if(!b)return null;try{const k=JSON.parse(b);return typeof k!="object"||k===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},_={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},E=()=>{switch(r){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},C=()=>{const b=h(d||"");if(b){A.error(b);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{A.error(a("network_settings.errors.save_failed"))}},S=b=>{m(b),c(h(b))},w=b=>{const k=_[b];if(k){const p=JSON.stringify(k.content,null,2);m(p),c(null)}};return u.useEffect(()=>{i&&console.log(n)},[i,n]),u.useEffect(()=>{i&&n&&Object.keys(n).length>0&&m(JSON.stringify(n,null,2))},[i,n]),e.jsxs(be,{open:i,onOpenChange:b=>{!b&&i&&C(),l(b)},children:[e.jsx(Je,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[E().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:E().map(b=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>w(b),children:a("network_settings.use_template",{template:_[b].label})},b))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ys,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:E().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:b=>S(b.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(ze,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(J,{onClick:C,disabled:!!o,children:a("common.confirm")})]})]})]})}function hp(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 ex={},sx=Object.freeze(Object.defineProperty({__proto__:null,default:ex},Symbol.toStringTag,{value:"Module"})),pp=Jo(sx),dn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),tx=()=>{try{const s=Lo.box.keyPair(),n=dn(Ja.encodeBase64(s.secretKey)),t=dn(Ja.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},ax=()=>{try{return tx()}catch(s){throw console.error("Error generating key pair:",s),s}},nx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},rx=()=>{const s=Math.floor(Math.random()*8)*2+2;return nx(s)},lx=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({})}),ix=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),ox=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({})}),cx=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({})}),dx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),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("")}),ux=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),mx=x.object({}),xx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),hx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),px=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),Ie={shadowsocks:{schema:lx,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:ix,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:ox,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:cx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:dx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:ux,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:mx},naive:{schema:hx},http:{schema:xx},mieru:{schema:px,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]}},fx=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Ie[s]:null,i=a?.schema||x.record(x.any()),l=s?i.parse({}):{},d=ge({resolver:Ne(i),defaultValues:l,mode:"onChange"});if(u.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const p=i.parse({});d.reset(p)}}else d.reset(n)},[s,n,t,d,i]),u.useEffect(()=>{const p=d.watch(v=>{t(v)});return()=>p.unsubscribe()},[d,t]),!s||!a)return null;const k={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"cipher",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.shadowsocks.ciphers.map(v=>e.jsx(z,{value:v,children:v},v))})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.obfs.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(He,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.shadowsocks.obfs.none")}),e.jsx(z,{value:"http",children:r("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),d.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs_settings.path",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:r("dynamic_form.shadowsocks.obfs_settings.path"),...p})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"obfs_settings.host",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:r("dynamic_form.shadowsocks.obfs_settings.host"),...p})}),e.jsx(D,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.vmess.network.label"),e.jsx(da,{value:d.watch("network_settings"),setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.vmess.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(g,{control:d.control,name:"allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.trojan.network.label"),e.jsx(da,{value:d.watch("network_settings")||{},setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")||"tcp"})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value||"tcp",children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.trojan.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"version",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(y,{children:e.jsxs(G,{value:(p.value||2).toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.hysteria.versions.map(v=>e.jsxs(z,{value:v,className:"cursor-pointer",children:["V",v]},v))})})]})})]})}),d.watch("version")==1&&e.jsx(g,{control:d.control,name:"alpn",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value||"h2",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.hysteria.alpnOptions.map(v=>e.jsx(z,{value:v,children:v},v))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs.open",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(g,{control:d.control,name:"obfs.type",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value||"salamander",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:e.jsx(z,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs.password",render:({field:p})=>e.jsxs(f,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...p,value:p.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",M=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(H=>v[H%v.length]).join("");d.setValue("obfs.password",M),A.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"bandwidth.up",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:r("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(g,{control:d.control,name:"bandwidth.down",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:r("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(z,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(z,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"reality_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.server_port",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(g,{control:d.control,name:"reality_settings.private_key",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(T,{...p,className:"pr-9"})}),e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const v=ax();d.setValue("reality_settings.private_key",v.privateKey),d.setValue("reality_settings.public_key",v.publicKey),A.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(It,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(g,{control:d.control,name:"reality_settings.public_key",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(y,{children:e.jsx(T,{...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.short_id",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(T,{...p,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const v=rx();d.setValue("reality_settings.short_id",v),A.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(It,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.vless.network.label"),e.jsx(da,{value:d.watch("network_settings"),setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.vless.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"flow",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.flow.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:v=>p.onChange(v==="none"?null:v),value:p.value||"none",children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:Ie.vless.flowOptions.map(v=>e.jsx(z,{value:v,children:v},v))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"version",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.version.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.versions.map(v=>e.jsxs(z,{value:v,children:["V",v]},v))})})]})})]})}),e.jsx(g,{control:d.control,name:"congestion_control",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.congestionControls.map(v=>e.jsx(z,{value:v,children:v.toUpperCase()},v))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"alpn",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(y,{children:e.jsx(at,{options:Ie.tuic.alpnOptions,onChange:v=>p.onChange(v.map(M=>M.value)),value:Ie.tuic.alpnOptions.filter(v=>p.value?.includes(v.value)),placeholder:r("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:r("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(g,{control:d.control,name:"udp_relay_mode",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.udpRelayModes.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.http.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"transport",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.mieru.transportOptions.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"multiplexing",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.mieru.multiplexingOptions.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})})]})};return e.jsx(ve,{children:k[s]?.()})},gx=x.object({id:x.number().optional().nullable(),code:x.string().optional(),name:x.string().min(1,"form.name.error"),rate:x.string().min(1,"form.rate.error"),tags:x.array(x.string()).default([]),excludes:x.array(x.string()).default([]),ips:x.array(x.string()).default([]),group_ids:x.array(x.string()).default([]),host:x.string().min(1,"form.host.error"),port:x.string().min(1,"form.port.error"),server_port:x.string().min(1,"form.server_port.error"),parent_id:x.string().default("0").nullable(),route_ids:x.array(x.string()).default([]),protocol_settings:x.record(x.any()).default({}).nullable()}),wt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function jx(){const{t:s}=V("server"),{isOpen:n,setIsOpen:t,editingServer:r,setEditingServer:a,serverType:i,setServerType:l,refetch:d}=Xr(),[m,o]=u.useState([]),[c,h]=u.useState([]),[_,E]=u.useState([]),C=ge({resolver:Ne(gx),defaultValues:wt,mode:"onChange"});u.useEffect(()=>{S()},[n]),u.useEffect(()=>{r?.type&&r.type!==i&&l(r.type)},[r,i,l]),u.useEffect(()=>{r?r.type===i&&C.reset({...wt,...r}):C.reset({...wt,protocol_settings:Ie[i].schema.parse({})})},[r,C,i]);const S=async()=>{if(!n)return;const[v,M,H]=await Promise.all([bt(),Sr(),Cr()]);o(v.data?.map(se=>({label:se.name,value:se.id.toString()}))||[]),h(M.data?.map(se=>({label:se.remarks,value:se.id.toString()}))||[]),E(H.data||[])},w=u.useMemo(()=>_?.filter(v=>(v.parent_id===0||v.parent_id===null)&&v.type===i&&v.id!==C.watch("id")),[i,_,C]),b=()=>e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(fs,{align:"start",children:e.jsx(Od,{children:Xe.map(({type:v,label:M})=>e.jsx(je,{onClick:()=>{l(v),t(!0)},className:"cursor-pointer",children:e.jsx(q,{variant:"outline",className:"text-white",style:{background:qe[v]},children:M})},v))})})]}),k=()=>{t(!1),a(null),C.reset(wt)},p=async()=>{const v=C.getValues();(await kc({...v,type:i})).data&&(k(),A.success(s("form.success")),d())};return e.jsxs(be,{open:n,onOpenChange:k,children:[b(),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s(r?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(_e,{...C,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:C.control,name:"name",render:({field:v})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:s("form.name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.name.placeholder"),...v})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"rate",render:({field:v})=>e.jsxs(f,{className:"flex-[1]",children:[e.jsx(j,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(y,{children:e.jsx(T,{type:"number",min:"0",step:"0.1",...v})})}),e.jsx(D,{})]})})]}),e.jsx(g,{control:C.control,name:"code",render:({field:v})=>e.jsxs(f,{children:[e.jsxs(j,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.code.placeholder"),...v,value:v.value||""})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"tags",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.tags.label")}),e.jsx(y,{children:e.jsx(La,{value:v.value,onChange:v.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"group_ids",render:({field:v})=>e.jsxs(f,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(ta,{dialogTrigger:e.jsx(P,{variant:"link",children:s("form.groups.add")}),refetch:S})]}),e.jsx(y,{children:e.jsx(at,{options:m,onChange:M=>v.onChange(M.map(H=>H.value)),value:m?.filter(M=>v.value.includes(M.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"host",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.host.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.host.placeholder"),...v})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(g,{control:C.control,name:"port",render:({field:v})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(It,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{children:e.jsx(T,{placeholder:s("form.port.placeholder"),...v})}),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const M=v.value;M&&C.setValue("server_port",M)},children:e.jsx(Ve,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ce,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"server_port",render:({field:v})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(It,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.server_port.placeholder"),...v})}),e.jsx(D,{})]})})]})]}),n&&e.jsx(fx,{serverType:i,value:C.watch("protocol_settings"),onChange:v=>C.setValue("protocol_settings",v,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(g,{control:C.control,name:"parent_id",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.parent.label")}),e.jsxs(G,{onValueChange:v.onChange,value:v.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("form.parent.none")}),w?.map(M=>e.jsx(z,{value:M.id.toString(),className:"cursor-pointer",children:M.name},M.id))]})]}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"route_ids",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.route.label")}),e.jsx(y,{children:e.jsx(at,{options:c,onChange:M=>v.onChange(M.map(H=>H.value)),value:c?.filter(M=>v.value.includes(M.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(D,{})]})})]}),e.jsxs(ze,{className:"mt-6",children:[e.jsx(P,{type:"button",variant:"outline",onClick:k,children:s("form.cancel")}),e.jsx(P,{type:"submit",onClick:p,children:s("form.submit")})]})]})]})]})}function un({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const vx=[{value:ie.Shadowsocks,label:Xe.find(s=>s.type===ie.Shadowsocks)?.label,color:qe[ie.Shadowsocks]},{value:ie.Vmess,label:Xe.find(s=>s.type===ie.Vmess)?.label,color:qe[ie.Vmess]},{value:ie.Trojan,label:Xe.find(s=>s.type===ie.Trojan)?.label,color:qe[ie.Trojan]},{value:ie.Hysteria,label:Xe.find(s=>s.type===ie.Hysteria)?.label,color:qe[ie.Hysteria]},{value:ie.Vless,label:Xe.find(s=>s.type===ie.Vless)?.label,color:qe[ie.Vless]},{value:ie.Tuic,label:Xe.find(s=>s.type===ie.Tuic)?.label,color:qe[ie.Tuic]},{value:ie.Socks,label:Xe.find(s=>s.type===ie.Socks)?.label,color:qe[ie.Socks]},{value:ie.Naive,label:Xe.find(s=>s.type===ie.Naive)?.label,color:qe[ie.Naive]},{value:ie.Http,label:Xe.find(s=>s.type===ie.Http)?.label,color:qe[ie.Http]},{value:ie.Mieru,label:Xe.find(s=>s.type===ie.Mieru)?.label,color:qe[ie.Mieru]}];function bx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("server");return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(jx,{}),e.jsx(T,{placeholder:i("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(un,{column:s.getColumn("type"),title:i("toolbar.type"),options:vx}),s.getColumn("group_ids")&&e.jsx(un,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),t&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const gt=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),Ct={0:"bg-destructive/80 shadow-sm shadow-destructive/50",1:"bg-yellow-500/80 shadow-sm shadow-yellow-500/50",2:"bg-emerald-500/80 shadow-sm shadow-emerald-500/50"},yx=s=>{const{t:n}=V("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ht,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(q,{variant:"outline",className:N("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:qe[t.original.type]},children:[e.jsx(ur,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:a??r}),t.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:t.original.parent?.code||t.original.parent?.id})]}):""]})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:i=>{i.stopPropagation(),Ft(a||r.toString()).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(Xa,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Xe.find(i=>i.type===t.original.type)?.label,t.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=u.useState(!!t.getValue("show"));return e.jsx(Y,{checked:r,onCheckedChange:async i=>{a(i),Pc({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?qe[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:t,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[0])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.0")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[1])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.1")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",Ct[t.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:t.getValue("name")})]})}),e.jsx(ce,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.address")}),cell:({row:t})=>{const r=`${t.original.host}:${t.original.port}`,a=t.original.port!==t.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[t.original.host,":",t.original.port]})}),a&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",t.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(ve,{delayDuration:0,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:i=>{i.stopPropagation(),Ft(r).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(Xa,{className:"size-3"})})}),e.jsx(ce,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(gt,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(q,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:t})=>{const r=t.original.groups||[];return e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[r.map((a,i)=>e.jsx(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:a.name},i)),r.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})]})},enableSorting:!1,filterFn:(t,r,a)=>{const i=t.getValue(r);return i?a.some(l=>i.includes(l)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(q,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:qe[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:i}=Xr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Ss,{modal:!1,children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Vt,{className:"size-4"})})}),e.jsxs(fs,{align:"end",className:"w-40",children:[e.jsx(je,{className:"cursor-pointer",onClick:()=>{i(t.original.type),a(t.original),r(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(zo,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(je,{className:"cursor-pointer",onClick:async()=>{Dc({id:t.original.id}).then(({data:l})=>{l&&(A.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Ao,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(tt,{}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(Qe,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Tc({id:t.original.id}).then(({data:l})=>{l&&(A.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 Nx(){const[s,n]=u.useState({}),[t,r]=u.useState({"drag-handle":!1}),[a,i]=u.useState([]),[l,d]=u.useState({pageSize:500,pageIndex:0}),[m,o]=u.useState([]),[c,h]=u.useState(!1),[_,E]=u.useState({}),[C,S]=u.useState([]),{refetch:w}=re({queryKey:["nodeList"],queryFn:async()=>{const{data:H}=await Cr();return S(H),H}}),{data:b}=re({queryKey:["groups"],queryFn:async()=>{const{data:H}=await bt();return H}});u.useEffect(()=>{r({"drag-handle":c,show:!c,host:!c,online:!c,rate:!c,groups:!c,type:!1,actions:!c}),E({name:c?2e3:200}),d({pageSize:c?99999:500,pageIndex:0})},[c]);const k=(H,se)=>{c&&(H.dataTransfer.setData("text/plain",se.toString()),H.currentTarget.classList.add("opacity-50"))},p=(H,se)=>{if(!c)return;H.preventDefault(),H.currentTarget.classList.remove("bg-muted");const L=parseInt(H.dataTransfer.getData("text/plain"));if(L===se)return;const Z=[...C],[de]=Z.splice(L,1);Z.splice(se,0,de),S(Z)},v=async()=>{if(!c){h(!0);return}const H=C?.map((se,L)=>({id:se.id,order:L+1}));Ec(H).then(()=>{A.success("排序保存成功"),h(!1),w()}).finally(()=>{h(!1)})},M=ns({data:C||[],columns:yx(w),state:{sorting:m,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:_,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:E,onPaginationChange:d,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Zm,{refetch:w,children:e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:M,toolbar:H=>e.jsx(bx,{table:H,refetch:w,saveOrder:v,isSortMode:c,groups:b||[]}),draggable:c,onDragStart:k,onDragEnd:H=>H.currentTarget.classList.remove("opacity-50"),onDragOver:H=>{H.preventDefault(),H.currentTarget.classList.add("bg-muted")},onDragLeave:H=>H.currentTarget.classList.remove("bg-muted"),onDrop:p,showPagination:!c})})})}function _x(){const{t:s}=V("server");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Nx,{})})]})]})}const wx=Object.freeze(Object.defineProperty({__proto__:null,default:_x},Symbol.toStringTag,{value:"Module"}));function Cx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(ta,{refetch:n}),e.jsx(T,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:N("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})})}const Sx=s=>{const{t:n}=V("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:t.getValue("name")})})},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(ta,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ic({id:t.original.id}).then(({data:r})=>{r&&(A.success(n("messages.updateSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function kx(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),{data:m,refetch:o,isLoading:c}=re({queryKey:["serverGroupList"],queryFn:async()=>{const{data:_}=await bt();return _}}),h=ns({data:m||[],columns:Sx(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:h,toolbar:_=>e.jsx(Cx,{table:_,refetch:o}),isLoading:c})}function Tx(){const{t:s}=V("group");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(kx,{})})]})]})}const Dx=Object.freeze(Object.defineProperty({__proto__:null,default:Tx},Symbol.toStringTag,{value:"Module"})),Px=s=>x.object({remarks:x.string().min(1,s("form.validation.remarks")),match:x.array(x.string()),action:x.enum(["block","dns"]),action_value:x.string().optional()});function Zr({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="add"}){const{t:a}=V("route"),i=ge({resolver:Ne(Px(a)),defaultValues:t,mode:"onChange"}),[l,d]=u.useState(!1);return e.jsxs(be,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(_e,{...i,children:[e.jsx(g,{control:i.control,name:"remarks",render:({field:m})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:a("form.remarksPlaceholder"),...m})})}),e.jsx(D,{})]})}),e.jsx(g,{control:i.control,name:"match",render:({field:m})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(ys,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:m.value.join(` +`).filter(Boolean);o.onChange(h),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(F,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.key.description")}),e.jsx(D,{})]})})]}),e.jsx(g,{control:a.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(F,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"register_limit_count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(D,{})]})})]}),e.jsx(g,{control:a.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(F,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"password_limit_count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function Mu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ke,{}),e.jsx(Vu,{})]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Mu},Symbol.toStringTag,{value:"Module"})),Ou=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")}),Lu={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 zu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Ou),defaultValues:Lu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","subscribe"],queryFn:()=>gs("subscribe")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data?.subscribe){const o=i?.data?.subscribe;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(F,{children:s("subscribe.plan_change_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(z,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(z,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(z,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(z,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(F,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"surplus_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(F,{children:s("subscribe.surplus_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.new_order_event.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("renew_order_event.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(K,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(z,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.change_order_event.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"subscribe_path",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:"subscribe",...o,value:o.value||"",onChange:c=>{o.onChange(c),m(a.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:o.value||"s"})]}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(F,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(F,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Au(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ke,{}),e.jsx(zu,{})]})}const $u=Object.freeze(Object.defineProperty({__proto__:null,default:Au},Symbol.toStringTag,{value:"Module"})),Uu=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)}),Hu={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 qu(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Uu),defaultValues:Hu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","invite"],queryFn:()=>gs("invite")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(i?.data?.invite){const o=i?.data?.invite;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"invite_force",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(F,{children:s("invite.invite_force.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"invite_commission",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_commission.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_gen_limit.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(F,{children:s("invite.invite_never_expire.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(F,{children:s("invite.commission_first_time.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(F,{children:s("invite.commission_auto_check.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_method.placeholder"),...o,value:Array.isArray(o.value)?o.value.join(","):"",onChange:c=>{const h=c.target.value.split(",").filter(Boolean);o.onChange(h),m(a.getValues())}})}),e.jsx(F,{children:s("invite.commission_withdraw_method.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(F,{children:s("invite.withdraw_close.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(F,{children:s("invite.commission_distribution.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:c=>{o.onChange(c),m(a.getValues())}})})]})}),a.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(g,{control:a.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l1")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l2")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:s("invite.commission_distribution.l3")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),m(a.getValues())}})}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function Ku(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ke,{}),e.jsx(qu,{})]})}const Bu=Object.freeze(Object.defineProperty({__proto__:null,default:Ku},Symbol.toStringTag,{value:"Module"})),Gu=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()}),Wu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Yu(){const{data:s}=re({queryKey:["settings","frontend"],queryFn:()=>gs("frontend")}),n=ge({resolver:Ne(Gu),defaultValues:Wu,mode:"onChange"});u.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,i])=>{n.setValue(a,i)})}},[s]);function t(r){js(r).then(({data:a})=>{a&&A.success("更新成功")})}return e.jsx(_e,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(g,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Y,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(g,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Y,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(g,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(f,{children:[e.jsx(j,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(y,{children:e.jsxs("select",{className:N(nt({variant:"outline"}),"w-[200px] appearance-none font-normal"),...r,children:[e.jsx("option",{value:"default",children:"默认"}),e.jsx("option",{value:"black",children:"黑色"}),e.jsx("option",{value:"blackblue",children:"暗蓝色"}),e.jsx("option",{value:"green",children:"奶绿色"})]})}),e.jsx(Ta,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(D,{})]})}),e.jsx(g,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(f,{children:[e.jsx(j,{children:"背景"}),e.jsx(y,{children:e.jsx(T,{placeholder:"请输入图片地址",...r})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(D,{})]})}),e.jsx(P,{type:"submit",children:"保存设置"})]})})}function Qu(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"个性化设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自定义系统界面外观,包括主题风格、布局、颜色方案、背景图等个性化选项。"})]}),e.jsx(ke,{}),e.jsx(Yu,{})]})}const Ju=Object.freeze(Object.defineProperty({__proto__:null,default:Qu},Symbol.toStringTag,{value:"Module"})),Xu=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()}),Zu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function em(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(Xu),defaultValues:Zu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","server"],queryFn:()=>gs("server")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:c=>{c.data&&A.success(s("common.AutoSaved"))}});u.useEffect(()=>{if(i?.data.server){const c=i.data.server;Object.entries(c).forEach(([h,_])=>{a.setValue(h,_)}),r.current=c}},[i]);const d=u.useCallback(Se.debounce(async c=>{if(!Se.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),m=u.useCallback(c=>{d(c)},[d]);u.useEffect(()=>{const c=a.watch(h=>{m(h)});return()=>c.unsubscribe()},[a.watch,m]);const o=()=>{const c=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let _="";for(let E=0;Ee.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_token.title")}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{placeholder:s("server.server_token.placeholder"),...c,value:c.value||"",className:"pr-10"}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:h=>{h.preventDefault(),o()},children:e.jsx(yo,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ce,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(F,{children:s("server.server_token.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"server_pull_interval",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;c.onChange(_)}})}),e.jsx(F,{children:s("server.server_pull_interval.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"server_push_interval",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const _=h.target.value?Number(h.target.value):null;c.onChange(_)}})}),e.jsx(F,{children:s("server.server_push_interval.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"device_limit_mode",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(G,{onValueChange:c.onChange,value:c.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(z,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(F,{children:s("server.device_limit_mode.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function sm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ke,{}),e.jsx(em,{})]})}const tm=Object.freeze(Object.defineProperty({__proto__:null,default:sm},Symbol.toStringTag,{value:"Module"}));function am({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(be,{open:s,onOpenChange:n,children:e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(tr,{className:"h-5 w-5 text-green-500"}):e.jsx(ar,{className:"h-5 w-5 text-destructive"}),e.jsx(ye,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Te,{children:r?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(zs,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const nm=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function rm(){const{t:s}=V("settings"),[n,t]=u.useState(null),[r,a]=u.useState(!1),i=u.useRef(null),[l,d]=u.useState(!1),m=ge({resolver:Ne(nm),defaultValues:{},mode:"onBlur"}),{data:o}=re({queryKey:["settings","email"],queryFn:()=>gs("email")}),{data:c}=re({queryKey:["emailTemplate"],queryFn:()=>vd()}),{mutateAsync:h}=es({mutationFn:js,onSuccess:w=>{w.data&&A.success(s("common.autoSaved"))}}),{mutate:_,isPending:E}=es({mutationFn:bd,onMutate:()=>{t(null),a(!1)},onSuccess:w=>{t(w.data),a(!0),w.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});u.useEffect(()=>{if(o?.data.email){const w=o.data.email;Object.entries(w).forEach(([b,k])=>{m.setValue(b,k)}),i.current=w}},[o]);const C=u.useCallback(Se.debounce(async w=>{if(!Se.isEqual(w,i.current)){d(!0);try{await h(w),i.current=w}finally{d(!1)}}},1e3),[h]),S=u.useCallback(w=>{C(w)},[C]);return u.useEffect(()=>{const w=m.watch(b=>{S(b)});return()=>w.unsubscribe()},[m.watch,S]),e.jsxs(e.Fragment,{children:[e.jsx(_e,{...m,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:m.control,name:"email_host",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_host.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_host.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_port",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_port.title")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:s("common.placeholder"),...w,value:w.value||"",onChange:b=>{const k=b.target.value?Number(b.target.value):null;w.onChange(k)}})}),e.jsx(F,{children:s("email.email_port.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_encryption",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(G,{onValueChange:w.onChange,value:w.value||"none",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(z,{value:"none",children:s("email.email_encryption.none")}),e.jsx(z,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(z,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(F,{children:s("email.email_encryption.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_username",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_username.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_username.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_password",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_password.title")}),e.jsx(y,{children:e.jsx(T,{type:"password",placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_password.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_from_address",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_from.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...w,value:w.value||""})}),e.jsx(F,{children:s("email.email_from.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"email_template",render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(G,{onValueChange:b=>{w.onChange(b),S(m.getValues())},value:w.value||void 0,children:[e.jsx(y,{children:e.jsx(K,{className:"w-[200px]",children:e.jsx(W,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(B,{children:c?.data?.map(b=>e.jsx(z,{value:b,children:b},b))})]}),e.jsx(F,{children:s("email.email_template.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"remind_mail_enable",render:({field:w})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(F,{children:s("email.remind_mail.description")})]}),e.jsx(y,{children:e.jsx(Y,{checked:w.value||!1,onCheckedChange:b=>{w.onChange(b),S(m.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{onClick:()=>_(),loading:E,disabled:E,children:s(E?"test.sending":"test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(am,{open:r,onOpenChange:a,result:n})]})}function lm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ke,{}),e.jsx(rm,{})]})}const im=Object.freeze(Object.defineProperty({__proto__:null,default:lm},Symbol.toStringTag,{value:"Module"})),om=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),cm={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function dm(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(om),defaultValues:cm,mode:"onBlur"}),{data:i}=re({queryKey:["settings","telegram"],queryFn:()=>gs("telegram")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}}),{mutate:d,isPending:m}=es({mutationFn:yd,onSuccess:h=>{h.data&&A.success(s("telegram.webhook.success"))}});u.useEffect(()=>{if(i?.data.telegram){const h=i.data.telegram;Object.entries(h).forEach(([_,E])=>{a.setValue(_,E)}),r.current=h}},[i]);const o=u.useCallback(Se.debounce(async h=>{if(!Se.isEqual(h,r.current)){t(!0);try{await l(h),r.current=h}finally{t(!1)}}},1e3),[l]),c=u.useCallback(h=>{o(h)},[o]);return u.useEffect(()=>{const h=a.watch(_=>{c(_)});return()=>h.unsubscribe()},[a.watch,c]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.bot_token.description")}),e.jsx(D,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(P,{loading:m,disabled:m,onClick:()=>d(),children:s(m?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(F,{children:s("telegram.webhook.description")}),e.jsx(D,{})]}),e.jsx(g,{control:a.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(F,{children:s("telegram.bot_enable.description")}),e.jsx(y,{children:e.jsx(Y,{checked:h.value||!1,onCheckedChange:_=>{h.onChange(_),c(a.getValues())}})}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(F,{children:s("telegram.discuss_link.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function um(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ke,{}),e.jsx(dm,{})]})}const mm=Object.freeze(Object.defineProperty({__proto__:null,default:um},Symbol.toStringTag,{value:"Module"})),xm=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()}),hm={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function pm(){const{t:s}=V("settings"),[n,t]=u.useState(!1),r=u.useRef(null),a=ge({resolver:Ne(xm),defaultValues:hm,mode:"onBlur"}),{data:i}=re({queryKey:["settings","app"],queryFn:()=>gs("app")}),{mutateAsync:l}=es({mutationFn:js,onSuccess:o=>{o.data&&A.success(s("app.save_success"))}});u.useEffect(()=>{if(i?.data.app){const o=i.data.app;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=u.useCallback(Se.debounce(async o=>{if(!Se.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),m=u.useCallback(o=>{d(o)},[d]);return u.useEffect(()=>{const o=a.watch(c=>{m(c)});return()=>o.unsubscribe()},[a.watch,m]),e.jsx(_e,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:a.control,name:"windows_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.version.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"windows_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.download.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"macos_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.version.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"macos_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.download.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"android_version",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.version.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.version.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"android_download_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:s("app.android.download.title")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.download.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function fm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ke,{}),e.jsx(pm,{})]})}const gm=Object.freeze(Object.defineProperty({__proto__:null,default:fm},Symbol.toStringTag,{value:"Module"})),Ia=u.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:N("w-full caption-bottom text-sm",s),...n})}));Ia.displayName="Table";const Va=u.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:N("[&_tr]:border-b",s),...n}));Va.displayName="TableHeader";const Ma=u.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:N("[&_tr:last-child]:border-0",s),...n}));Ma.displayName="TableBody";const jm=u.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:N("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));jm.displayName="TableFooter";const Is=u.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:N("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Is.displayName="TableRow";const Fa=u.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:N("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Fa.displayName="TableHead";const Zs=u.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:N("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Zs.displayName="TableCell";const vm=u.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:N("mt-4 text-sm text-muted-foreground",s),...n}));vm.displayName="TableCaption";function bm({table:s}){const[n,t]=u.useState(""),{t:r}=V("common");u.useEffect(()=>{t((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const a=i=>{const l=parseInt(i);!isNaN(l)&&l>=1&&l<=s.getPageCount()?s.setPageIndex(l-1):t((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:r("table.pagination.selected",{selected:s.getFilteredSelectedRowModel().rows.length,total:s.getFilteredRowModel().rows.length})}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:r("table.pagination.itemsPerPage")}),e.jsxs(G,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx(z,{value:`${i}`,children:i},i))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(T,{type:"text",value:n,onChange:i=>t(i.target.value),onBlur:i=>a(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a(i.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:r("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.firstPage")}),e.jsx(No,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.previousPage")}),e.jsx(Zn,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.nextPage")}),e.jsx(Sa,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.lastPage")}),e.jsx(_o,{className:"h-4 w-4"})]})]})]})]})}function hs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:m=!0,isLoading:o=!1}){const{t:c}=V("common"),h=u.useRef(null),_=s.getAllColumns().filter(w=>w.getIsPinned()==="left"),E=s.getAllColumns().filter(w=>w.getIsPinned()==="right"),C=w=>_.slice(0,w).reduce((b,k)=>b+(k.getSize()??0),0),S=w=>E.slice(w+1).reduce((b,k)=>b+(k.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:h,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(Ia,{children:[e.jsx(Va,{children:s.getHeaderGroups().map(w=>e.jsx(Is,{className:"hover:bg-transparent",children:w.headers.map((b,k)=>{const p=b.column.getIsPinned()==="left",v=b.column.getIsPinned()==="right",M=p?C(_.indexOf(b.column)):void 0,H=v?S(E.indexOf(b.column)):void 0;return e.jsx(Fa,{colSpan:b.colSpan,style:{width:b.getSize(),...p&&{left:M},...v&&{right:H}},className:N("h-11 bg-card px-4 text-muted-foreground",(p||v)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",p&&"before:right-0",v&&"before:left-0"]),children:b.isPlaceholder?null:Rt(b.column.columnDef.header,b.getContext())},b.id)})},w.id))}),e.jsx(Ma,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((w,b)=>e.jsx(Is,{"data-state":w.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:k=>r?.(k,b),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:k=>d?.(k,b),children:w.getVisibleCells().map((k,p)=>{const v=k.column.getIsPinned()==="left",M=k.column.getIsPinned()==="right",H=v?C(_.indexOf(k.column)):void 0,se=M?S(E.indexOf(k.column)):void 0;return e.jsx(Zs,{style:{width:k.column.getSize(),...v&&{left:H},...M&&{right:se}},className:N("bg-card",(v||M)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",v&&"before:right-0",M&&"before:left-0"]),children:Rt(k.column.columnDef.cell,k.getContext())},k.id)})},w.id)):e.jsx(Is,{children:e.jsx(Zs,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:c("table.noData")})})})]})})}),m&&e.jsx(bm,{table:s})]})}const ym=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),on={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function qr({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=on}){const{t:a}=V("payment"),[i,l]=u.useState(!1),[d,m]=u.useState(!1),[o,c]=u.useState([]),[h,_]=u.useState([]),E=ym(a),C=ge({resolver:Ne(E),defaultValues:r,mode:"onChange"}),S=C.watch("payment");u.useEffect(()=>{i&&(async()=>{const{data:k}=await Lc();c(k)})()},[i]),u.useEffect(()=>{if(!S||!i)return;(async()=>{const k={payment:S,...t==="edit"&&{id:Number(C.getValues("id"))}};zc(k).then(({data:p})=>{_(p);const v=p.reduce((M,H)=>(H.field_name&&(M[H.field_name]=H.value??""),M),{});C.setValue("config",v)})})()},[S,i,C,t]);const w=async b=>{m(!0);try{(await Ac(b)).data&&(A.success(a("form.messages.success")),C.reset(on),s(),l(!1))}finally{m(!1)}};return e.jsxs(be,{open:i,onOpenChange:l,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(_e,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(w),className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"name",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:a("form.fields.name.placeholder"),...b})}),e.jsx(F,{children:a("form.fields.name.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"icon",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.icon.label")}),e.jsx(y,{children:e.jsx(T,{...b,value:b.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(F,{children:a("form.fields.icon.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"notify_domain",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.notify_domain.label")}),e.jsx(y,{children:e.jsx(T,{...b,value:b.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(F,{children:a("form.fields.notify_domain.description")}),e.jsx(D,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{control:C.control,name:"handling_fee_percent",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(y,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"handling_fee_fixed",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(y,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(D,{})]})})]}),e.jsx(g,{control:C.control,name:"payment",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.payment.label")}),e.jsxs(G,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(B,{children:o.map(k=>e.jsx(z,{value:k,children:k},k))})]}),e.jsx(F,{children:a("form.fields.payment.description")}),e.jsx(D,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(b=>e.jsx(g,{control:C.control,name:`config.${b.field_name}`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(j,{children:b.label}),e.jsx(y,{children:e.jsx(T,{...k,value:k.value||""})}),e.jsx(D,{})]})},b.field_name))}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:t,className:r}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(P,{variant:"ghost",size:"default",className:N("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",r),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),t&&e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Qa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(pa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(fa,{className:"h-4 w-4 text-foreground/70"}):e.jsx(wo,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:N("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",r),children:[e.jsx("span",{children:n}),t&&e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx(Qa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const Oa=Co,Kr=So,Nm=ko,Br=u.forwardRef(({className:s,...n},t)=>e.jsx(rr,{className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));Br.displayName=rr.displayName;const Yt=u.forwardRef(({className:s,...n},t)=>e.jsxs(Nm,{children:[e.jsx(Br,{}),e.jsx(lr,{ref:t,className:N("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));Yt.displayName=lr.displayName;const Qt=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Qt.displayName="AlertDialogHeader";const Jt=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Jt.displayName="AlertDialogFooter";const Xt=u.forwardRef(({className:s,...n},t)=>e.jsx(ir,{ref:t,className:N("text-lg font-semibold",s),...n}));Xt.displayName=ir.displayName;const Zt=u.forwardRef(({className:s,...n},t)=>e.jsx(or,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Zt.displayName=or.displayName;const ea=u.forwardRef(({className:s,...n},t)=>e.jsx(cr,{ref:t,className:N(st(),s),...n}));ea.displayName=cr.displayName;const sa=u.forwardRef(({className:s,...n},t)=>e.jsx(dr,{ref:t,className:N(st({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));sa.displayName=dr.displayName;function Qe({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Oa,{children:[e.jsx(Kr,{asChild:!0,children:n}),e.jsxs(Yt,{className:N("sm:max-w-[425px]",d),children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:t}),e.jsx(Zt,{children:r})]}),e.jsxs(Jt,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a})}),e.jsx(ea,{asChild:!0,children:e.jsx(P,{variant:l,onClick:s,children:i})})]})]})]})}const Gr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),_m=({refetch:s,isSortMode:n=!1})=>{const{t}=V("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ht,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(q,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(Y,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await Uc({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.name")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.payment")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:r})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:r,title:t("table.columns.notify_url")}),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{className:"ml-1",children:e.jsx(Gr,{className:"h-4 w-4"})}),e.jsx(ce,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:r.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("table.columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(qr,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(Qe,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await $c({id:r.original.id});a&&s()},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function wm({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("payment"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qr,{refetch:n}),e.jsx(T,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),i&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Cm(){const[s,n]=u.useState([]),[t,r]=u.useState([]),[a,i]=u.useState(!1),[l,d]=u.useState([]),[m,o]=u.useState({"drag-handle":!1}),[c,h]=u.useState({pageSize:20,pageIndex:0}),{refetch:_}=re({queryKey:["paymentList"],queryFn:async()=>{const{data:b}=await Oc();return d(b?.map(k=>({...k,enable:!!k.enable}))||[]),b}});u.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const E=(b,k)=>{a&&(b.dataTransfer.setData("text/plain",k.toString()),b.currentTarget.classList.add("opacity-50"))},C=(b,k)=>{if(!a)return;b.preventDefault(),b.currentTarget.classList.remove("bg-muted");const p=parseInt(b.dataTransfer.getData("text/plain"));if(p===k)return;const v=[...l],[M]=v.splice(p,1);v.splice(k,0,M),d(v)},S=async()=>{a?Hc({ids:l.map(b=>b.id)}).then(()=>{_(),i(!1),A.success("排序保存成功")}):i(!0)},w=ns({data:l,columns:_m({refetch:_,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:m,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(hs,{table:w,toolbar:b=>e.jsx(wm,{table:b,refetch:_,saveOrder:S,isSortMode:a}),draggable:a,onDragStart:E,onDragEnd:b=>b.currentTarget.classList.remove("opacity-50"),onDragOver:b=>{b.preventDefault(),b.currentTarget.classList.add("bg-muted")},onDragLeave:b=>b.currentTarget.classList.remove("bg-muted"),onDrop:C,showPagination:!a})}function Sm(){const{t:s}=V("payment");return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Cm,{})})]})]})}const km=Object.freeze(Object.defineProperty({__proto__:null,default:Sm},Symbol.toStringTag,{value:"Module"}));function Tm({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,i]=u.useState(!0),[l,d]=u.useState(!1),[m,o]=u.useState(null),c=To({config:Do(Po())}),h=ge({resolver:Ne(c),defaultValues:{config:{}}});u.useEffect(()=>{(async()=>{try{const{data:S}=await _s.getPluginConfig(s);o(S),h.reset({config:Object.fromEntries(Object.entries(S).map(([w,b])=>[w,b.value]))})}catch{A.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const _=async C=>{d(!0);try{await _s.updatePluginConfig(s,C.config),A.success(r("messages.configSaveSuccess")),t()}catch{A.error(r("messages.configSaveError"))}finally{d(!1)}},E=(C,S)=>{switch(S.type){case"string":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsx(T,{placeholder:S.placeholder,...w})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);case"number":case"percentage":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{type:"number",placeholder:S.placeholder,...w,onChange:b=>{const k=Number(b.target.value);S.type==="percentage"?w.onChange(Math.min(100,Math.max(0,k))):w.onChange(k)},className:S.type==="percentage"?"pr-8":"",min:S.type==="percentage"?0:void 0,max:S.type==="percentage"?100:void 0,step:S.type==="percentage"?1:void 0}),S.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(Eo,{className:"h-4 w-4 text-muted-foreground"})})]})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);case"select":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsxs(G,{onValueChange:w.onChange,defaultValue:w.value,children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:S.placeholder})})}),e.jsx(B,{children:S.options?.map(b=>e.jsx(z,{value:b.value,children:b.label},b.value))})]}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);case"boolean":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:S.label||S.description}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description})]}),e.jsx(y,{children:e.jsx(Y,{checked:w.value,onCheckedChange:w.onChange})})]})},C);case"text":return e.jsx(g,{control:h.control,name:`config.${C}`,render:({field:w})=>e.jsxs(f,{children:[e.jsx(j,{children:S.label||S.description}),e.jsx(y,{children:e.jsx(ys,{placeholder:S.placeholder,...w})}),S.description&&S.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.description}),e.jsx(D,{})]})},C);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(oe,{className:"h-4 w-[200px]"}),e.jsx(oe,{className:"h-10 w-full"}),e.jsx(oe,{className:"h-4 w-[200px]"}),e.jsx(oe,{className:"h-10 w-full"})]}):e.jsx(_e,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(_),className:"space-y-4",children:[m&&Object.entries(m).map(([C,S])=>E(C,S)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(P,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function Dm(){const{t:s}=V("plugin"),[n,t]=u.useState(null),[r,a]=u.useState(!1),[i,l]=u.useState(null),[d,m]=u.useState(""),[o,c]=u.useState("all"),[h,_]=u.useState(!1),[E,C]=u.useState(!1),[S,w]=u.useState(!1),b=u.useRef(null),{data:k,isLoading:p,refetch:v}=re({queryKey:["pluginList"],queryFn:async()=>{const{data:R}=await _s.getPluginList();return R}});k&&[...new Set(k.map(R=>R.category||"other"))];const M=k?.filter(R=>{const X=R.name.toLowerCase().includes(d.toLowerCase())||R.description.toLowerCase().includes(d.toLowerCase())||R.code.toLowerCase().includes(d.toLowerCase()),Ns=o==="all"||R.category===o;return X&&Ns}),H=async R=>{t(R),_s.installPlugin(R).then(()=>{A.success(s("messages.installSuccess")),v()}).catch(X=>{A.error(X.message||s("messages.installError"))}).finally(()=>{t(null)})},se=async R=>{t(R),_s.uninstallPlugin(R).then(()=>{A.success(s("messages.uninstallSuccess")),v()}).catch(X=>{A.error(X.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},L=async(R,X)=>{t(R),(X?_s.disablePlugin:_s.enablePlugin)(R).then(()=>{A.success(s(X?"messages.disableSuccess":"messages.enableSuccess")),v()}).catch(De=>{A.error(De.message||s(X?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},Z=R=>{k?.find(X=>X.code===R),l(R),a(!0)},de=async R=>{if(!R.name.endsWith(".zip")){A.error(s("upload.error.format"));return}_(!0),_s.uploadPlugin(R).then(()=>{A.success(s("messages.uploadSuccess")),C(!1),v()}).catch(X=>{A.error(X.message||s("messages.uploadError"))}).finally(()=>{_(!1),b.current&&(b.current.value="")})},Q=R=>{R.preventDefault(),R.stopPropagation(),R.type==="dragenter"||R.type==="dragover"?w(!0):R.type==="dragleave"&&w(!1)},te=R=>{R.preventDefault(),R.stopPropagation(),w(!1),R.dataTransfer.files&&R.dataTransfer.files[0]&&de(R.dataTransfer.files[0])},$=async R=>{t(R),_s.deletePlugin(R).then(()=>{A.success(s("messages.deleteSuccess")),v()}).catch(X=>{A.error(X.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ka,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(An,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(T,{placeholder:s("search.placeholder"),value:d,onChange:R=>m(R.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(P,{onClick:()=>C(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Gt,{defaultValue:"all",className:"w-full",children:[e.jsxs(vt,{children:[e.jsx(Ge,{value:"all",children:s("tabs.all")}),e.jsx(Ge,{value:"installed",children:s("tabs.installed")}),e.jsx(Ge,{value:"available",children:s("tabs.available")})]}),e.jsx(ws,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:p?e.jsxs(e.Fragment,{children:[e.jsx(oa,{}),e.jsx(oa,{}),e.jsx(oa,{})]}):M?.map(R=>e.jsx(ia,{plugin:R,onInstall:H,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:$,isLoading:n===R.name},R.name))})}),e.jsx(ws,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M?.filter(R=>R.is_installed).map(R=>e.jsx(ia,{plugin:R,onInstall:H,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:$,isLoading:n===R.name},R.name))})}),e.jsx(ws,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:M?.filter(R=>!R.is_installed).map(R=>e.jsx(ia,{plugin:R,onInstall:H,onUninstall:se,onToggleEnable:L,onOpenConfig:Z,onDelete:$,isLoading:n===R.name},R.code))})})]})]}),e.jsx(be,{open:r,onOpenChange:a,children:e.jsxs(fe,{className:"sm:max-w-lg",children:[e.jsxs(Ce,{children:[e.jsxs(ye,{children:[k?.find(R=>R.code===i)?.name," ",s("config.title")]}),e.jsx(Te,{children:s("config.description")})]}),i&&e.jsx(Tm,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),v()}})]})}),e.jsx(be,{open:E,onOpenChange:C,children:e.jsxs(fe,{className:"sm:max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:N("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",S&&"border-primary/50 bg-muted/50"),onDragEnter:Q,onDragLeave:Q,onDragOver:Q,onDrop:te,children:[e.jsx("input",{type:"file",ref:b,className:"hidden",accept:".zip",onChange:R=>{const X=R.target.files?.[0];X&&de(X)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(pt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>b.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function ia({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l}){const{t:d}=V("plugin");return e.jsxs(We,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(ts,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cs,{children:s.name}),s.is_installed&&e.jsx(q,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?d("status.enabled"):d("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ka,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[d("author"),": ",s.author]})})]})})]}),e.jsx(as,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(Ro,{className:"mr-2 h-4 w-4"}),d("button.config")]}),e.jsxs(P,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(Io,{className:"mr-2 h-4 w-4"}),s.is_enabled?d("button.disable"):d("button.enable")]}),e.jsx(Qe,{title:d("uninstall.title"),description:d("uninstall.description"),cancelText:d("common:cancel"),confirmText:d("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(P,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(cs,{className:"mr-2 h-4 w-4"}),d("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{onClick:()=>n(s.code),disabled:l,loading:l,children:d("button.install")}),e.jsx(Qe,{title:d("delete.title"),description:d("delete.description"),cancelText:d("common:cancel"),confirmText:d("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(P,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(cs,{className:"h-4 w-4"})})})]})})})]})}function oa(){return e.jsxs(We,{children:[e.jsxs(ts,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-6 w-[200px]"}),e.jsx(oe,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(oe,{className:"h-5 w-[120px]"}),e.jsx(oe,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(oe,{className:"h-4 w-[300px]"}),e.jsx(oe,{className:"h-4 w-[150px]"})]})]}),e.jsx(as,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(oe,{className:"h-9 w-[100px]"}),e.jsx(oe,{className:"h-9 w-[100px]"}),e.jsx(oe,{className:"h-8 w-8"})]})})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:Dm},Symbol.toStringTag,{value:"Module"})),Em=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(T,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(ys,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:N(st({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Rm({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=u.useState(!1),[i,l]=u.useState(!1),[d,m]=u.useState(!1),o=ge({defaultValues:n.configs.reduce((_,E)=>(_[E.field_name]="",_),{})}),c=async()=>{l(!0),_c(s).then(({data:_})=>{Object.entries(_).forEach(([E,C])=>{o.setValue(E,C)})}).finally(()=>{l(!1)})},h=async _=>{m(!0),wc(s,_).then(()=>{A.success(t("config.success")),a(!1)}).finally(()=>{m(!1)})};return e.jsxs(be,{open:r,onOpenChange:_=>{a(_),_?c():o.reset()},children:[e.jsx(Je,{asChild:!0,children:e.jsx(P,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(fe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:t("config.title",{name:n.name})}),e.jsx(Te,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Da,{className:"h-6 w-6 animate-spin"})}):e.jsx(_e,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(h),className:"space-y-4",children:[n.configs.map(_=>e.jsx(g,{control:o.control,name:_.field_name,render:({field:E})=>e.jsxs(f,{children:[e.jsx(j,{children:_.label}),e.jsx(y,{children:Em(_,E)}),e.jsx(D,{})]})},_.field_name)),e.jsxs(ze,{className:"mt-6 gap-2",children:[e.jsx(P,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(P,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function Im(){const{t:s}=V("theme"),[n,t]=u.useState(null),[r,a]=u.useState(!1),[i,l]=u.useState(!1),[d,m]=u.useState(!1),[o,c]=u.useState(null),h=u.useRef(null),[_,E]=u.useState(0),{data:C,isLoading:S,refetch:w}=re({queryKey:["themeList"],queryFn:async()=>{const{data:L}=await Nc();return L}}),b=async L=>{t(L),kc({frontend_theme:L}).then(()=>{A.success("主题切换成功"),w()}).finally(()=>{t(null)})},k=async L=>{if(!L.name.endsWith(".zip")){A.error(s("upload.error.format"));return}a(!0),Cc(L).then(()=>{A.success("主题上传成功"),l(!1),w()}).finally(()=>{a(!1),h.current&&(h.current.value="")})},p=L=>{L.preventDefault(),L.stopPropagation(),L.type==="dragenter"||L.type==="dragover"?m(!0):L.type==="dragleave"&&m(!1)},v=L=>{L.preventDefault(),L.stopPropagation(),m(!1),L.dataTransfer.files&&L.dataTransfer.files[0]&&k(L.dataTransfer.files[0])},M=()=>{o&&E(L=>L===0?o.images.length-1:L-1)},H=()=>{o&&E(L=>L===o.images.length-1?0:L+1)},se=(L,Z)=>{E(0),c({name:L,images:Z})};return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(P,{onClick:()=>l(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:S?e.jsxs(e.Fragment,{children:[e.jsx(cn,{}),e.jsx(cn,{})]}):C?.themes&&Object.entries(C.themes).map(([L,Z])=>e.jsx(We,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:Z.background_url?`url(${Z.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:N("relative z-10 h-full transition-colors",Z.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!Z.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Qe,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(L===C?.active){A.error(s("card.delete.error.active"));return}t(L),Sc(L).then(()=>{A.success("主题删除成功"),w()}).finally(()=>{t(null)})},children:e.jsx(P,{disabled:n===L,loading:n===L,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(ts,{children:[e.jsx(Cs,{children:Z.name}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:Z.description}),Z.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:Z.version})})]})})]}),e.jsxs(as,{className:"flex items-center justify-end space-x-3",children:[Z.images&&Array.isArray(Z.images)&&Z.images.length>0&&e.jsx(P,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>se(Z.name,Z.images),children:e.jsx(Vo,{className:"h-4 w-4"})}),e.jsx(Rm,{themeKey:L,themeInfo:Z}),e.jsx(P,{onClick:()=>b(L),disabled:n===L||L===C.active,loading:n===L,variant:L===C.active?"secondary":"default",children:L===C.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},L))}),e.jsx(be,{open:i,onOpenChange:l,children:e.jsxs(fe,{className:"sm:max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:N("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",d&&"border-primary/50 bg-muted/50"),onDragEnter:p,onDragLeave:p,onDragOver:p,onDrop:v,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:L=>{const Z=L.target.files?.[0];Z&&k(Z)}}),r?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(pt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(be,{open:!!o,onOpenChange:L=>{L||(c(null),E(0))},children:e.jsxs(fe,{className:"max-w-4xl",children:[e.jsxs(Ce,{children:[e.jsxs(ye,{children:[o?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:o&&s("preview.imageCount",{current:_+1,total:o.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:o?.images[_]&&e.jsx("img",{src:o.images[_],alt:`${o.name} 预览图 ${_+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:M,children:e.jsx(Mo,{className:"h-4 w-4"})}),e.jsx(P,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:H,children:e.jsx(Fo,{className:"h-4 w-4"})})]})]}),o&&o.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:o.images.map((L,Z)=>e.jsx("button",{onClick:()=>E(Z),className:N("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",_===Z?"border-primary":"border-transparent"),children:e.jsx("img",{src:L,alt:`缩略图 ${Z+1}`,className:"h-full w-full object-cover"})},Z))})]})})]})]})}function cn(){return e.jsxs(We,{children:[e.jsxs(ts,{children:[e.jsx(oe,{className:"h-6 w-[200px]"}),e.jsx(oe,{className:"h-4 w-[300px]"})]}),e.jsxs(as,{className:"flex items-center justify-end space-x-3",children:[e.jsx(oe,{className:"h-10 w-[100px]"}),e.jsx(oe,{className:"h-10 w-[100px]"})]})]})}const Vm=Object.freeze(Object.defineProperty({__proto__:null,default:Im},Symbol.toStringTag,{value:"Module"})),La=u.forwardRef(({className:s,value:n,onChange:t,...r},a)=>{const[i,l]=u.useState("");u.useEffect(()=>{if(i.includes(",")){const m=new Set([...n,...i.split(",").map(o=>o.trim())]);t(Array.from(m)),l("")}},[i,t,n]);const d=()=>{if(i){const m=new Set([...n,i]);t(Array.from(m)),l("")}};return e.jsxs("div",{className:N(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(m=>e.jsxs(q,{variant:"secondary",children:[m,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(o=>o!==m))},children:e.jsx(ga,{className:"w-3"})})]},m)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"||m.key===","?(m.preventDefault(),d()):m.key==="Backspace"&&i.length===0&&n.length>0&&(m.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});La.displayName="InputTags";const Mm=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()}),Fm={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Wr({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Fm}){const{t:a}=V("notice"),[i,l]=u.useState(!1),d=ge({resolver:Ne(Mm),defaultValues:r,mode:"onChange",shouldFocusError:!0}),m=new Pa({html:!0});return e.jsx(_e,{...d,children:e.jsxs(be,{onOpenChange:l,open:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(fe,{className:"sm:max-w-[1025px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(g,{control:d.control,name:"title",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(T,{placeholder:a("form.fields.title.placeholder"),...o})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"content",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.content.label")}),e.jsx(y,{children:e.jsx(Ea,{style:{height:"500px"},value:o.value,renderHTML:c=>m.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"img_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"tags",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.fields.tags.label")}),e.jsx(y,{children:e.jsx(La,{value:o.value,onChange:o.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",onClick:o=>{o.preventDefault(),d.handleSubmit(async c=>{qc(c).then(({data:h})=>{h&&(A.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function Om({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("notice"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!r&&e.jsx(Wr,{refetch:n}),!r&&e.jsx(T,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),i&&!r&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const Lm=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Oo,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(q,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Y,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await Bc({id:t.original.id});r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Wr,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:t.original}),e.jsx(Qe,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{Kc({id:t.original.id}).then(()=>{A.success(n("table.actions.delete.success")),s()})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function zm(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState(!1),[c,h]=u.useState({}),[_,E]=u.useState({pageSize:50,pageIndex:0}),[C,S]=u.useState([]),{refetch:w}=re({queryKey:["notices"],queryFn:async()=>{const{data:M}=await nn.getList();return S(M),M}});u.useEffect(()=>{r({"drag-handle":m,content:!m,created_at:!m,actions:!m}),E({pageSize:m?99999:50,pageIndex:0})},[m]);const b=(M,H)=>{m&&(M.dataTransfer.setData("text/plain",H.toString()),M.currentTarget.classList.add("opacity-50"))},k=(M,H)=>{if(!m)return;M.preventDefault(),M.currentTarget.classList.remove("bg-muted");const se=parseInt(M.dataTransfer.getData("text/plain"));if(se===H)return;const L=[...C],[Z]=L.splice(se,1);L.splice(H,0,Z),S(L)},p=async()=>{if(!m){o(!0);return}nn.sort(C.map(M=>M.id)).then(()=>{A.success("排序保存成功"),o(!1),w()}).finally(()=>{o(!1)})},v=ns({data:C??[],columns:Lm(w),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:c,pagination:_},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:h,onPaginationChange:E,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:v,toolbar:M=>e.jsx(Om,{table:M,refetch:w,saveOrder:p,isSortMode:m}),draggable:m,onDragStart:b,onDragEnd:M=>M.currentTarget.classList.remove("opacity-50"),onDragOver:M=>{M.preventDefault(),M.currentTarget.classList.add("bg-muted")},onDragLeave:M=>M.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!m})})}function Am(){const{t:s}=V("notice");return e.jsxs(Ee,{children:[e.jsxs(Re,{className:"flex items-center justify-between",children:[e.jsx(Ke,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(zm,{})})]})]})}const $m=Object.freeze(Object.defineProperty({__proto__:null,default:Am},Symbol.toStringTag,{value:"Module"})),Um=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()}),Hm={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Yr({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Hm}){const{t:a}=V("knowledge"),[i,l]=u.useState(!1),d=ge({resolver:Ne(Um),defaultValues:r,mode:"onChange",shouldFocusError:!0}),m=new Pa({html:!0});return u.useEffect(()=>{i&&r.id&&Wc(r.id).then(({data:o})=>{d.reset(o)})},[r.id,d,i]),e.jsxs(be,{onOpenChange:l,open:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(fe,{className:"sm:max-w-[1025px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(_e,{...d,children:[e.jsx(g,{control:d.control,name:"title",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(T,{placeholder:a("form.titlePlaceholder"),...o})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"category",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(T,{placeholder:a("form.categoryPlaceholder"),...o})})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"language",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.language")}),e.jsx(y,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(c=>e.jsx(z,{value:c.value,className:"cursor-pointer",children:a(`languages.${c.value}`)},c.value))})]})})]})}),e.jsx(g,{control:d.control,name:"body",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.content")}),e.jsx(y,{children:e.jsx(Ea,{style:{height:"500px"},value:o.value,renderHTML:c=>m.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"show",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(D,{})]})}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{d.handleSubmit(o=>{Yc(o).then(({data:c})=>{c&&(d.reset(),A.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function qm({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function Km({table:s,refetch:n,saveOrder:t,isSortMode:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yr,{refreshData:n}),e.jsx(T,{placeholder:i("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(qm,{column:s.getColumn("category"),title:i("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const Bm=({refetch:s,isSortMode:n=!1})=>{const{t}=V("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ht,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(q,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Y,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Jc({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.title")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:r.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(q,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Yr,{refreshData:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(Qe,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Qc({id:r.original.id}).then(({data:a})=>{a&&(A.success(t("messages.operationSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function Gm(){const[s,n]=u.useState([]),[t,r]=u.useState([]),[a,i]=u.useState(!1),[l,d]=u.useState([]),[m,o]=u.useState({"drag-handle":!1}),[c,h]=u.useState({pageSize:20,pageIndex:0}),{refetch:_,isLoading:E,data:C}=re({queryKey:["knowledge"],queryFn:async()=>{const{data:p}=await Gc();return d(p||[]),p}});u.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const S=(p,v)=>{a&&(p.dataTransfer.setData("text/plain",v.toString()),p.currentTarget.classList.add("opacity-50"))},w=(p,v)=>{if(!a)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const M=parseInt(p.dataTransfer.getData("text/plain"));if(M===v)return;const H=[...l],[se]=H.splice(M,1);H.splice(v,0,se),d(H)},b=async()=>{a?Xc({ids:l.map(p=>p.id)}).then(()=>{_(),i(!1),A.success("排序保存成功")}):i(!0)},k=ns({data:l,columns:Bm({refetch:_,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:m,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,onPaginationChange:h,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:k,toolbar:p=>e.jsx(Km,{table:p,refetch:_,saveOrder:b,isSortMode:a}),draggable:a,onDragStart:S,onDragEnd:p=>p.currentTarget.classList.remove("opacity-50"),onDragOver:p=>{p.preventDefault(),p.currentTarget.classList.add("bg-muted")},onDragLeave:p=>p.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!a})}function Wm(){const{t:s}=V("knowledge");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Gm,{})})]})]})}const Ym=Object.freeze(Object.defineProperty({__proto__:null,default:Wm},Symbol.toStringTag,{value:"Module"}));function Qm(s,n){const[t,r]=u.useState(s);return u.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function ca(s,n){if(s.length===0)return{};if(!n)return{"":s};const t={};return s.forEach(r=>{const a=r[n]||"";t[a]||(t[a]=[]),t[a].push(r)}),t}function Jm(s,n){const t=JSON.parse(JSON.stringify(s));for(const[r,a]of Object.entries(t))t[r]=a.filter(i=>!n.find(l=>l.value===i.value));return t}function Xm(s,n){for(const[,t]of Object.entries(s))if(t.some(r=>n.find(a=>a.value===r.value)))return!0;return!1}const Qr=u.forwardRef(({className:s,...n},t)=>Lo(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:N("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Qr.displayName="CommandEmpty";const at=u.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:m,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:c,hidePlaceholderWhenSelected:h,disabled:_,groupBy:E,className:C,badgeClassName:S,selectFirstItem:w=!0,creatable:b=!1,triggerSearchOnFocus:k=!1,commandProps:p,inputProps:v,hideClearAllButton:M=!1},H)=>{const se=u.useRef(null),[L,Z]=u.useState(!1),de=u.useRef(!1),[Q,te]=u.useState(!1),[$,R]=u.useState(s||[]),[X,Ns]=u.useState(ca(r,E)),[De,le]=u.useState(""),Os=Qm(De,i||500);u.useImperativeHandle(H,()=>({selectedValue:[...$],input:se.current,focus:()=>se.current?.focus()}),[$]);const Ws=u.useCallback(ee=>{const ue=$.filter(Ue=>Ue.value!==ee.value);R(ue),n?.(ue)},[n,$]),bl=u.useCallback(ee=>{const ue=se.current;ue&&((ee.key==="Delete"||ee.key==="Backspace")&&ue.value===""&&$.length>0&&($[$.length-1].fixed||Ws($[$.length-1])),ee.key==="Escape"&&ue.blur())},[Ws,$]);u.useEffect(()=>{s&&R(s)},[s]),u.useEffect(()=>{if(!a||l)return;const ee=ca(a||[],E);JSON.stringify(ee)!==JSON.stringify(X)&&Ns(ee)},[r,a,E,l,X]),u.useEffect(()=>{const ee=async()=>{te(!0);const Ue=await l?.(Os);Ns(ca(Ue||[],E)),te(!1)};(async()=>{!l||!L||(k&&await ee(),Os&&await ee())})()},[Os,E,L,k]);const yl=()=>{if(!b||Xm(X,[{value:De,label:De}])||$.find(ue=>ue.value===De))return;const ee=e.jsx(Me,{value:De,className:"cursor-pointer",onMouseDown:ue=>{ue.preventDefault(),ue.stopPropagation()},onSelect:ue=>{if($.length>=o){c?.($.length);return}le("");const Ue=[...$,{value:ue,label:ue}];R(Ue),n?.(Ue)},children:`Create "${De}"`});if(!l&&De.length>0||l&&Os.length>0&&!Q)return ee},Nl=u.useCallback(()=>{if(m)return l&&!b&&Object.keys(X).length===0?e.jsx(Me,{value:"-",disabled:!0,children:m}):e.jsx(Qr,{children:m})},[b,m,l,X]),_l=u.useMemo(()=>Jm(X,$),[X,$]),wl=u.useCallback(()=>{if(p?.filter)return p.filter;if(b)return(ee,ue)=>ee.toLowerCase().includes(ue.toLowerCase())?1:-1},[b,p?.filter]),Cl=u.useCallback(()=>{const ee=$.filter(ue=>ue.fixed);R(ee),n?.(ee)},[n,$]);return e.jsxs(Ms,{...p,onKeyDown:ee=>{bl(ee),p?.onKeyDown?.(ee)},className:N("h-auto overflow-visible bg-transparent",p?.className),shouldFilter:p?.shouldFilter!==void 0?p.shouldFilter:!l,filter:wl(),children:[e.jsx("div",{className:N("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":$.length!==0,"cursor-text":!_&&$.length!==0},C),onClick:()=>{_||se.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[$.map(ee=>e.jsxs(q,{className:N("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",S),"data-fixed":ee.fixed,"data-disabled":_||void 0,children:[ee.label,e.jsx("button",{className:N("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(_||ee.fixed)&&"hidden"),onKeyDown:ue=>{ue.key==="Enter"&&Ws(ee)},onMouseDown:ue=>{ue.preventDefault(),ue.stopPropagation()},onClick:()=>Ws(ee),children:e.jsx(ga,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},ee.value)),e.jsx(Le.Input,{...v,ref:se,value:De,disabled:_,onValueChange:ee=>{le(ee),v?.onValueChange?.(ee)},onBlur:ee=>{de.current===!1&&Z(!1),v?.onBlur?.(ee)},onFocus:ee=>{Z(!0),k&&l?.(Os),v?.onFocus?.(ee)},placeholder:h&&$.length!==0?"":t,className:N("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":$.length===0,"ml-1":$.length!==0},v?.className)}),e.jsx("button",{type:"button",onClick:Cl,className:N((M||_||$.length<1||$.filter(ee=>ee.fixed).length===$.length)&&"hidden"),children:e.jsx(ga,{})})]})}),e.jsx("div",{className:"relative",children:L&&e.jsx(Fs,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{de.current=!1},onMouseEnter:()=>{de.current=!0},onMouseUp:()=>{se.current?.focus()},children:Q?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Nl(),yl(),!w&&e.jsx(Me,{value:"-",className:"hidden"}),Object.entries(_l).map(([ee,ue])=>e.jsx(Ye,{heading:ee,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ue.map(Ue=>e.jsx(Me,{value:Ue.value,disabled:Ue.disable,onMouseDown:lt=>{lt.preventDefault(),lt.stopPropagation()},onSelect:()=>{if($.length>=o){c?.($.length);return}le("");const lt=[...$,Ue];R(lt),n?.(lt)},className:N("cursor-pointer",Ue.disable&&"cursor-default text-muted-foreground"),children:Ue.label},Ue.value))})},ee))]})})})]})});at.displayName="MultipleSelector";const Zm=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function ta({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),i=ge({resolver:Ne(Zm(a)),defaultValues:t,mode:"onChange"}),[l,d]=u.useState(!1),[m,o]=u.useState(!1),c=async h=>{o(!0),Ic(h).then(()=>{A.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{o(!1)})};return e.jsxs(be,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(_e,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(g,{control:i.control,name:"name",render:({field:h})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.name")}),e.jsx(y,{children:e.jsx(T,{placeholder:a("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(F,{children:a("form.nameDescription")}),e.jsx(D,{})]})}),e.jsxs(ze,{className:"gap-2",children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(P,{type:"submit",disabled:m||!i.formState.isValid,children:[m&&e.jsx(Da,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Jr=u.createContext(void 0);function ex({children:s,refetch:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null),[l,d]=u.useState(ie.Shadowsocks);return e.jsx(Jr.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function Xr(){const s=u.useContext(Jr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function da({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=V("server");u.useEffect(()=>{console.log(n)},[n]);const[i,l]=u.useState(!1),[d,m]=u.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,c]=u.useState(null),h=b=>{if(!b)return null;try{const k=JSON.parse(b);return typeof k!="object"||k===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},_={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},E=()=>{switch(r){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},C=()=>{const b=h(d||"");if(b){A.error(b);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{A.error(a("network_settings.errors.save_failed"))}},S=b=>{m(b),c(h(b))},w=b=>{const k=_[b];if(k){const p=JSON.stringify(k.content,null,2);m(p),c(null)}};return u.useEffect(()=>{i&&console.log(n)},[i,n]),u.useEffect(()=>{i&&n&&Object.keys(n).length>0&&m(JSON.stringify(n,null,2))},[i,n]),e.jsxs(be,{open:i,onOpenChange:b=>{!b&&i&&C(),l(b)},children:[e.jsx(Je,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[E().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:E().map(b=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>w(b),children:a("network_settings.use_template",{template:_[b].label})},b))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ys,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:E().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:b=>S(b.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(ze,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(J,{onClick:C,disabled:!!o,children:a("common.confirm")})]})]})]})}function pp(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 sx={},tx=Object.freeze(Object.defineProperty({__proto__:null,default:sx},Symbol.toStringTag,{value:"Module"})),fp=Xo(tx),dn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),ax=()=>{try{const s=zo.box.keyPair(),n=dn(Ja.encodeBase64(s.secretKey)),t=dn(Ja.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},nx=()=>{try{return ax()}catch(s){throw console.error("Error generating key pair:",s),s}},rx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},lx=()=>{const s=Math.floor(Math.random()*8)*2+2;return rx(s)},ix=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({})}),ox=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({})}),cx=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({})}),dx=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({})}),ux=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),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("")}),mx=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),xx=x.object({}),hx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),px=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),fx=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),Ie={shadowsocks:{schema:ix,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:ox,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:cx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:dx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:ux,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:mx,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:xx},naive:{schema:px},http:{schema:hx},mieru:{schema:fx,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]}},gx=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Ie[s]:null,i=a?.schema||x.record(x.any()),l=s?i.parse({}):{},d=ge({resolver:Ne(i),defaultValues:l,mode:"onChange"});if(u.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const p=i.parse({});d.reset(p)}}else d.reset(n)},[s,n,t,d,i]),u.useEffect(()=>{const p=d.watch(v=>{t(v)});return()=>p.unsubscribe()},[d,t]),!s||!a)return null;const k={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"cipher",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.shadowsocks.ciphers.map(v=>e.jsx(z,{value:v,children:v},v))})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.obfs.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(He,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.shadowsocks.obfs.none")}),e.jsx(z,{value:"http",children:r("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),d.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs_settings.path",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:r("dynamic_form.shadowsocks.obfs_settings.path"),...p})}),e.jsx(D,{})]})}),e.jsx(g,{control:d.control,name:"obfs_settings.host",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:r("dynamic_form.shadowsocks.obfs_settings.host"),...p})}),e.jsx(D,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.vmess.network.label"),e.jsx(da,{value:d.watch("network_settings"),setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.vmess.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(g,{control:d.control,name:"allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.trojan.network.label"),e.jsx(da,{value:d.watch("network_settings")||{},setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")||"tcp"})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value||"tcp",children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.trojan.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"version",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(y,{children:e.jsxs(G,{value:(p.value||2).toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.hysteria.versions.map(v=>e.jsxs(z,{value:v,className:"cursor-pointer",children:["V",v]},v))})})]})})]})}),d.watch("version")==1&&e.jsx(g,{control:d.control,name:"alpn",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value||"h2",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.hysteria.alpnOptions.map(v=>e.jsx(z,{value:v,children:v},v))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"obfs.open",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(g,{control:d.control,name:"obfs.type",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value||"salamander",onValueChange:p.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:e.jsx(z,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(g,{control:d.control,name:"obfs.password",render:({field:p})=>e.jsxs(f,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...p,value:p.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",M=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(H=>v[H%v.length]).join("");d.setValue("obfs.password",M),A.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...p,value:p.value||""})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value||!1,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"bandwidth.up",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:r("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(g,{control:d.control,name:"bandwidth.down",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...p,value:p.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:r("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(z,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(z,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"reality_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.server_port",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(g,{control:d.control,name:"reality_settings.private_key",render:({field:p})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(T,{...p,className:"pr-9"})}),e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const v=nx();d.setValue("reality_settings.private_key",v.privateKey),d.setValue("reality_settings.public_key",v.publicKey),A.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(It,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(g,{control:d.control,name:"reality_settings.public_key",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(y,{children:e.jsx(T,{...p})})]})}),e.jsx(g,{control:d.control,name:"reality_settings.short_id",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(T,{...p,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const v=lx();d.setValue("reality_settings.short_id",v),A.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ve,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(It,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(g,{control:d.control,name:"network",render:({field:p})=>e.jsxs(f,{children:[e.jsxs(j,{children:[r("dynamic_form.vless.network.label"),e.jsx(da,{value:d.watch("network_settings"),setValue:v=>d.setValue("network_settings",v),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.vless.networkOptions.map(v=>e.jsx(z,{value:v.value,className:"cursor-pointer",children:v.label},v.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"flow",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.vless.flow.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:v=>p.onChange(v==="none"?null:v),value:p.value||"none",children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:Ie.vless.flowOptions.map(v=>e.jsx(z,{value:v,children:v},v))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"version",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.version.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.versions.map(v=>e.jsxs(z,{value:v,children:["V",v]},v))})})]})})]})}),e.jsx(g,{control:d.control,name:"congestion_control",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.congestionControls.map(v=>e.jsx(z,{value:v,children:v.toUpperCase()},v))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]}),e.jsx(g,{control:d.control,name:"alpn",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(y,{children:e.jsx(at,{options:Ie.tuic.alpnOptions,onChange:v=>p.onChange(v.map(M=>M.value)),value:Ie.tuic.alpnOptions.filter(v=>p.value?.includes(v.value)),placeholder:r("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:r("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(g,{control:d.control,name:"udp_relay_mode",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.tuic.udpRelayModes.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"tls",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.http.tls.label")}),e.jsx(y,{children:e.jsxs(G,{value:p.value?.toString(),onValueChange:v=>p.onChange(Number(v)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(z,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:d.control,name:"tls_settings.server_name",render:({field:p})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...p})})]})}),e.jsx(g,{control:d.control,name:"tls_settings.allow_insecure",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Y,{checked:p.value,onCheckedChange:p.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{control:d.control,name:"transport",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.mieru.transportOptions.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})}),e.jsx(g,{control:d.control,name:"multiplexing",render:({field:p})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(y,{children:e.jsxs(G,{onValueChange:p.onChange,value:p.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(B,{children:e.jsx(He,{children:Ie.mieru.multiplexingOptions.map(v=>e.jsx(z,{value:v.value,children:v.label},v.value))})})]})})]})})]})};return e.jsx(ve,{children:k[s]?.()})},jx=x.object({id:x.number().optional().nullable(),code:x.string().optional(),name:x.string().min(1,"form.name.error"),rate:x.string().min(1,"form.rate.error"),tags:x.array(x.string()).default([]),excludes:x.array(x.string()).default([]),ips:x.array(x.string()).default([]),group_ids:x.array(x.string()).default([]),host:x.string().min(1,"form.host.error"),port:x.string().min(1,"form.port.error"),server_port:x.string().min(1,"form.server_port.error"),parent_id:x.string().default("0").nullable(),route_ids:x.array(x.string()).default([]),protocol_settings:x.record(x.any()).default({}).nullable()}),wt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function vx(){const{t:s}=V("server"),{isOpen:n,setIsOpen:t,editingServer:r,setEditingServer:a,serverType:i,setServerType:l,refetch:d}=Xr(),[m,o]=u.useState([]),[c,h]=u.useState([]),[_,E]=u.useState([]),C=ge({resolver:Ne(jx),defaultValues:wt,mode:"onChange"});u.useEffect(()=>{S()},[n]),u.useEffect(()=>{r?.type&&r.type!==i&&l(r.type)},[r,i,l]),u.useEffect(()=>{r?r.type===i&&C.reset({...wt,...r}):C.reset({...wt,protocol_settings:Ie[i].schema.parse({})})},[r,C,i]);const S=async()=>{if(!n)return;const[v,M,H]=await Promise.all([bt(),Sr(),Cr()]);o(v.data?.map(se=>({label:se.name,value:se.id.toString()}))||[]),h(M.data?.map(se=>({label:se.remarks,value:se.id.toString()}))||[]),E(H.data||[])},w=u.useMemo(()=>_?.filter(v=>(v.parent_id===0||v.parent_id===null)&&v.type===i&&v.id!==C.watch("id")),[i,_,C]),b=()=>e.jsxs(Ss,{children:[e.jsx(ks,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(fs,{align:"start",children:e.jsx(Ld,{children:Xe.map(({type:v,label:M})=>e.jsx(je,{onClick:()=>{l(v),t(!0)},className:"cursor-pointer",children:e.jsx(q,{variant:"outline",className:"text-white",style:{background:qe[v]},children:M})},v))})})]}),k=()=>{t(!1),a(null),C.reset(wt)},p=async()=>{const v=C.getValues();(await Tc({...v,type:i})).data&&(k(),A.success(s("form.success")),d())};return e.jsxs(be,{open:n,onOpenChange:k,children:[b(),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:s(r?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(_e,{...C,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(g,{control:C.control,name:"name",render:({field:v})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:s("form.name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.name.placeholder"),...v})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"rate",render:({field:v})=>e.jsxs(f,{className:"flex-[1]",children:[e.jsx(j,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(y,{children:e.jsx(T,{type:"number",min:"0",step:"0.1",...v})})}),e.jsx(D,{})]})})]}),e.jsx(g,{control:C.control,name:"code",render:({field:v})=>e.jsxs(f,{children:[e.jsxs(j,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.code.placeholder"),...v,value:v.value||""})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"tags",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.tags.label")}),e.jsx(y,{children:e.jsx(La,{value:v.value,onChange:v.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"group_ids",render:({field:v})=>e.jsxs(f,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(ta,{dialogTrigger:e.jsx(P,{variant:"link",children:s("form.groups.add")}),refetch:S})]}),e.jsx(y,{children:e.jsx(at,{options:m,onChange:M=>v.onChange(M.map(H=>H.value)),value:m?.filter(M=>v.value.includes(M.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:C.control,name:"host",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.host.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.host.placeholder"),...v})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(g,{control:C.control,name:"port",render:({field:v})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(It,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{children:e.jsx(T,{placeholder:s("form.port.placeholder"),...v})}),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const M=v.value;M&&C.setValue("server_port",M)},children:e.jsx(Ve,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ce,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"server_port",render:({field:v})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ve,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(It,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(y,{children:e.jsx(T,{placeholder:s("form.server_port.placeholder"),...v})}),e.jsx(D,{})]})})]})]}),n&&e.jsx(gx,{serverType:i,value:C.watch("protocol_settings"),onChange:v=>C.setValue("protocol_settings",v,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(g,{control:C.control,name:"parent_id",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.parent.label")}),e.jsxs(G,{onValueChange:v.onChange,value:v.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("form.parent.none")}),w?.map(M=>e.jsx(z,{value:M.id.toString(),className:"cursor-pointer",children:M.name},M.id))]})]}),e.jsx(D,{})]})}),e.jsx(g,{control:C.control,name:"route_ids",render:({field:v})=>e.jsxs(f,{children:[e.jsx(j,{children:s("form.route.label")}),e.jsx(y,{children:e.jsx(at,{options:c,onChange:M=>v.onChange(M.map(H=>H.value)),value:c?.filter(M=>v.value.includes(M.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(D,{})]})})]}),e.jsxs(ze,{className:"mt-6",children:[e.jsx(P,{type:"button",variant:"outline",onClick:k,children:s("form.cancel")}),e.jsx(P,{type:"submit",onClick:p,children:s("form.submit")})]})]})]})]})}function un({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const bx=[{value:ie.Shadowsocks,label:Xe.find(s=>s.type===ie.Shadowsocks)?.label,color:qe[ie.Shadowsocks]},{value:ie.Vmess,label:Xe.find(s=>s.type===ie.Vmess)?.label,color:qe[ie.Vmess]},{value:ie.Trojan,label:Xe.find(s=>s.type===ie.Trojan)?.label,color:qe[ie.Trojan]},{value:ie.Hysteria,label:Xe.find(s=>s.type===ie.Hysteria)?.label,color:qe[ie.Hysteria]},{value:ie.Vless,label:Xe.find(s=>s.type===ie.Vless)?.label,color:qe[ie.Vless]},{value:ie.Tuic,label:Xe.find(s=>s.type===ie.Tuic)?.label,color:qe[ie.Tuic]},{value:ie.Socks,label:Xe.find(s=>s.type===ie.Socks)?.label,color:qe[ie.Socks]},{value:ie.Naive,label:Xe.find(s=>s.type===ie.Naive)?.label,color:qe[ie.Naive]},{value:ie.Http,label:Xe.find(s=>s.type===ie.Http)?.label,color:qe[ie.Http]},{value:ie.Mieru,label:Xe.find(s=>s.type===ie.Mieru)?.label,color:qe[ie.Mieru]}];function yx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("server");return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(vx,{}),e.jsx(T,{placeholder:i("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(un,{column:s.getColumn("type"),title:i("toolbar.type"),options:bx}),s.getColumn("group_ids")&&e.jsx(un,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]}),t&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const gt=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),Ct={0:"bg-destructive/80 shadow-sm shadow-destructive/50",1:"bg-yellow-500/80 shadow-sm shadow-yellow-500/50",2:"bg-emerald-500/80 shadow-sm shadow-emerald-500/50"},Nx=s=>{const{t:n}=V("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ht,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(q,{variant:"outline",className:N("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:qe[t.original.type]},children:[e.jsx(ur,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:a??r}),t.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:t.original.parent?.code||t.original.parent?.id})]}):""]})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:i=>{i.stopPropagation(),Ft(a||r.toString()).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(Xa,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Xe.find(i=>i.type===t.original.type)?.label,t.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=u.useState(!!t.getValue("show"));return e.jsx(Y,{checked:r,onCheckedChange:async i=>{a(i),Ec({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?qe[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:t,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[0])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.0")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[1])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.1")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("h-2.5 w-2.5 rounded-full",Ct[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",Ct[t.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:t.getValue("name")})]})}),e.jsx(ce,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.address")}),cell:({row:t})=>{const r=`${t.original.host}:${t.original.port}`,a=t.original.port!==t.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[t.original.host,":",t.original.port]})}),a&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",t.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(ve,{delayDuration:0,children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:i=>{i.stopPropagation(),Ft(r).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(Xa,{className:"size-3"})})}),e.jsx(ce,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(gt,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(q,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:t})=>{const r=t.original.groups||[];return e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[r.map((a,i)=>e.jsx(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:a.name},i)),r.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})]})},enableSorting:!1,filterFn:(t,r,a)=>{const i=t.getValue(r);return i?a.some(l=>i.includes(l)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(q,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:qe[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:i}=Xr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Ss,{modal:!1,children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Vt,{className:"size-4"})})}),e.jsxs(fs,{align:"end",className:"w-40",children:[e.jsx(je,{className:"cursor-pointer",onClick:()=>{i(t.original.type),a(t.original),r(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(Ao,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(je,{className:"cursor-pointer",onClick:async()=>{Pc({id:t.original.id}).then(({data:l})=>{l&&(A.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx($o,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(tt,{}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(Qe,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Dc({id:t.original.id}).then(({data:l})=>{l&&(A.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 _x(){const[s,n]=u.useState({}),[t,r]=u.useState({"drag-handle":!1}),[a,i]=u.useState([]),[l,d]=u.useState({pageSize:500,pageIndex:0}),[m,o]=u.useState([]),[c,h]=u.useState(!1),[_,E]=u.useState({}),[C,S]=u.useState([]),{refetch:w}=re({queryKey:["nodeList"],queryFn:async()=>{const{data:H}=await Cr();return S(H),H}}),{data:b}=re({queryKey:["groups"],queryFn:async()=>{const{data:H}=await bt();return H}});u.useEffect(()=>{r({"drag-handle":c,show:!c,host:!c,online:!c,rate:!c,groups:!c,type:!1,actions:!c}),E({name:c?2e3:200}),d({pageSize:c?99999:500,pageIndex:0})},[c]);const k=(H,se)=>{c&&(H.dataTransfer.setData("text/plain",se.toString()),H.currentTarget.classList.add("opacity-50"))},p=(H,se)=>{if(!c)return;H.preventDefault(),H.currentTarget.classList.remove("bg-muted");const L=parseInt(H.dataTransfer.getData("text/plain"));if(L===se)return;const Z=[...C],[de]=Z.splice(L,1);Z.splice(se,0,de),S(Z)},v=async()=>{if(!c){h(!0);return}const H=C?.map((se,L)=>({id:se.id,order:L+1}));Rc(H).then(()=>{A.success("排序保存成功"),h(!1),w()}).finally(()=>{h(!1)})},M=ns({data:C||[],columns:Nx(w),state:{sorting:m,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:_,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:E,onPaginationChange:d,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ex,{refetch:w,children:e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:M,toolbar:H=>e.jsx(yx,{table:H,refetch:w,saveOrder:v,isSortMode:c,groups:b||[]}),draggable:c,onDragStart:k,onDragEnd:H=>H.currentTarget.classList.remove("opacity-50"),onDragOver:H=>{H.preventDefault(),H.currentTarget.classList.add("bg-muted")},onDragLeave:H=>H.currentTarget.classList.remove("bg-muted"),onDrop:p,showPagination:!c})})})}function wx(){const{t:s}=V("server");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(_x,{})})]})]})}const Cx=Object.freeze(Object.defineProperty({__proto__:null,default:wx},Symbol.toStringTag,{value:"Module"}));function Sx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(ta,{refetch:n}),e.jsx(T,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:N("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})})}const kx=s=>{const{t:n}=V("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:t.getValue("name")})})},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(ta,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Vc({id:t.original.id}).then(({data:r})=>{r&&(A.success(n("messages.updateSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Tx(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),{data:m,refetch:o,isLoading:c}=re({queryKey:["serverGroupList"],queryFn:async()=>{const{data:_}=await bt();return _}}),h=ns({data:m||[],columns:kx(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:h,toolbar:_=>e.jsx(Sx,{table:_,refetch:o}),isLoading:c})}function Dx(){const{t:s}=V("group");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Tx,{})})]})]})}const Px=Object.freeze(Object.defineProperty({__proto__:null,default:Dx},Symbol.toStringTag,{value:"Module"})),Ex=s=>x.object({remarks:x.string().min(1,s("form.validation.remarks")),match:x.array(x.string()),action:x.enum(["block","dns"]),action_value:x.string().optional()});function Zr({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="add"}){const{t:a}=V("route"),i=ge({resolver:Ne(Ex(a)),defaultValues:t,mode:"onChange"}),[l,d]=u.useState(!1);return e.jsxs(be,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ve,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(_e,{...i,children:[e.jsx(g,{control:i.control,name:"remarks",render:({field:m})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:a("form.remarksPlaceholder"),...m})})}),e.jsx(D,{})]})}),e.jsx(g,{control:i.control,name:"match",render:({field:m})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(ys,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:m.value.join(` `),onChange:o=>{m.onChange(o.target.value.split(` -`))}})})}),e.jsx(D,{})]})}),e.jsx(g,{control:i.control,name:"action",render:({field:m})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"block",children:a("actions.block")}),e.jsx(z,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(D,{})]})}),i.watch("action")==="dns"&&e.jsx(g,{control:i.control,name:"action_value",render:({field:m})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:a("form.dnsPlaceholder"),...m})})})]})}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{Vc(i.getValues()).then(({data:m})=>{m&&(d(!1),s&&s(),toast.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function Ex({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("route");return e.jsx("div",{className:"flex items-center justify-between ",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[e.jsx(Zr,{refetch:n}),e.jsx(T,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:a=>s.getColumn("remarks")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})})}function Rx({columns:s,data:n,refetch:t}){const[r,a]=u.useState({}),[i,l]=u.useState({}),[d,m]=u.useState([]),[o,c]=u.useState([]),h=ns({data:n,columns:s,state:{sorting:o,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:c,onColumnFiltersChange:m,onColumnVisibilityChange:l,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:h,toolbar:_=>e.jsx(Ex,{table:_,refetch:t})})}const Ix=s=>{const{t:n}=V("route"),t={block:{icon:$o,variant:"destructive",className:"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-800"},dns:{icon:Uo,variant:"secondary",className:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-400 hover:bg-blue-200 dark:hover:bg-blue-800"}};return[{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.id")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:r.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.remarks")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:r.original.remarks})}),enableHiding:!1,enableSorting:!1},{accessorKey:"action_value",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action_value.title")}),cell:({row:r})=>{const a=r.original.action,i=r.original.action_value,l=r.original.match?.length||0;return e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("span",{className:"text-sm font-medium",children:a==="dns"&&i?n("columns.action_value.dns",{value:i}):a==="block"?e.jsx("span",{className:"text-destructive",children:n("columns.action_value.block")}):n("columns.action_value.direct")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("columns.matchRules",{count:l})})]})},enableHiding:!1,enableSorting:!1,size:300},{accessorKey:"action",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action")}),cell:({row:r})=>{const a=r.getValue("action"),i=t[a]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(q,{variant:t[a]?.variant||"default",className:N("flex items-center gap-1.5 px-3 py-1 capitalize",t[a]?.className),children:[i&&e.jsx(i,{className:"h-3.5 w-3.5"}),n(`actions.${a}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Zr,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Mc({id:r.original.id}).then(({data:a})=>{a&&(A.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Vx(){const{t:s}=V("route"),[n,t]=u.useState([]);function r(){Sr().then(({data:a})=>{t(a)})}return u.useEffect(()=>{r()},[]),e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Rx,{data:n,columns:Ix(r),refetch:r})})]})]})}const Mx=Object.freeze(Object.defineProperty({__proto__:null,default:Vx},Symbol.toStringTag,{value:"Module"})),el=u.createContext(void 0);function Fx({children:s,refreshData:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null);return e.jsx(el.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function za(){const s=u.useContext(el);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function Ox({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=za(),{t:a}=V("subscribe");return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(P,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:a("plan.add")})]}),e.jsx(T,{placeholder:a("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:i=>s.getColumn("name")?.setFilterValue(i.target.value),className:"h-8 w-[150px] lg:w-[250px]"})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const mn={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Lx=s=>{const{t:n}=V("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ht,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.show")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{aa({id:t.original.id,show:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.sell")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{aa({id:t.original.id,sell:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{aa({id:t.original.id,renew:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.stats")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(gt,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.group")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.price")}),cell:({row:t})=>{const r=t.getValue("prices"),a=[{period:n("plan.columns.price_period.monthly"),key:"monthly",unit:n("plan.columns.price_period.unit.month")},{period:n("plan.columns.price_period.quarterly"),key:"quarterly",unit:n("plan.columns.price_period.unit.quarter")},{period:n("plan.columns.price_period.half_yearly"),key:"half_yearly",unit:n("plan.columns.price_period.unit.half_year")},{period:n("plan.columns.price_period.yearly"),key:"yearly",unit:n("plan.columns.price_period.unit.year")},{period:n("plan.columns.price_period.two_yearly"),key:"two_yearly",unit:n("plan.columns.price_period.unit.two_year")},{period:n("plan.columns.price_period.three_yearly"),key:"three_yearly",unit:n("plan.columns.price_period.unit.three_year")},{period:n("plan.columns.price_period.onetime"),key:"onetime",unit:""},{period:n("plan.columns.price_period.reset_traffic"),key:"reset_traffic",unit:n("plan.columns.price_period.unit.times")}];return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:a.map(({period:i,key:l,unit:d})=>r[l]!=null&&e.jsxs(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium transition-colors text-nowrap",mn[l].color,mn[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=za();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(Qe,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{Zc({id:t.original.id}).then(({data:i})=>{i&&(A.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.delete")})]})})]})}}]},zx=x.object({id:x.number().nullable(),group_id:x.union([x.number(),x.string()]).nullable().optional(),name:x.string().min(1).max(250),content:x.string().nullable().optional(),transfer_enable:x.union([x.number().min(0),x.string().min(1)]),prices:x.object({monthly:x.union([x.number(),x.string()]).nullable().optional(),quarterly:x.union([x.number(),x.string()]).nullable().optional(),half_yearly:x.union([x.number(),x.string()]).nullable().optional(),yearly:x.union([x.number(),x.string()]).nullable().optional(),two_yearly:x.union([x.number(),x.string()]).nullable().optional(),three_yearly:x.union([x.number(),x.string()]).nullable().optional(),onetime:x.union([x.number(),x.string()]).nullable().optional(),reset_traffic:x.union([x.number(),x.string()]).nullable().optional()}).default({}),speed_limit:x.union([x.number(),x.string()]).nullable().optional(),capacity_limit:x.union([x.number(),x.string()]).nullable().optional(),device_limit:x.union([x.number(),x.string()]).nullable().optional(),force_update:x.boolean().optional(),reset_traffic_method:x.number().nullable(),users_count:x.number().optional()}),sl=u.forwardRef(({className:s,...n},t)=>e.jsx(mr,{ref:t,className:N("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...n,children:e.jsx(Ho,{className:N("flex items-center justify-center text-current"),children:e.jsx($s,{className:"h-4 w-4"})})}));sl.displayName=mr.displayName;const St={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},kt={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},Ax=[{value:null,label:"follow_system"},{value:0,label:"monthly_first"},{value:1,label:"monthly_reset"},{value:2,label:"no_reset"},{value:3,label:"yearly_first"},{value:4,label:"yearly_reset"}];function $x(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=za(),[i,l]=u.useState(!1),{t:d}=V("subscribe"),m=ge({resolver:Ne(zx),defaultValues:{...St,...t||{}},mode:"onChange"});u.useEffect(()=>{t?m.reset({...St,...t}):m.reset(St)},[t,m]);const o=new Pa({html:!0}),[c,h]=u.useState();async function _(){bt().then(({data:S})=>{h(S)})}u.useEffect(()=>{s&&_()},[s]);const E=S=>{if(isNaN(S))return;const w=Object.entries(kt).reduce((b,[k,p])=>{const v=S*p.months*p.discount;return{...b,[k]:v.toFixed(2)}},{});m.setValue("prices",w,{shouldDirty:!0})},C=()=>{n(!1),r(null),m.reset(St)};return e.jsx(be,{open:s,onOpenChange:C,children:e.jsxs(fe,{children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Te,{})]}),e.jsxs(_e,{...m,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:m.control,name:"name",render:({field:S})=>e.jsxs(f,{children:[e.jsx(j,{children:d("plan.form.name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:d("plan.form.name.placeholder"),...S})}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"group_id",render:({field:S})=>e.jsxs(f,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(ta,{dialogTrigger:e.jsx(P,{variant:"link",children:d("plan.form.group.add")}),refetch:_})]}),e.jsxs(G,{value:S.value?.toString()??"",onValueChange:w=>S.onChange(w?Number(w):null),children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(B,{children:c?.map(w=>e.jsx(z,{value:w.id.toString(),children:w.name},w.id))})]}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"transfer_enable",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...S})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.transfer.unit")})]}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"speed_limit",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...S,value:S.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.speed.unit")})]}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:d("plan.form.price.title")}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(T,{type:"number",placeholder:d("plan.form.price.base_price"),className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:S=>{const w=parseFloat(S.target.value);E(w)}})]}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const S=Object.keys(kt).reduce((w,b)=>({...w,[b]:""}),{});m.setValue("prices",S,{shouldDirty:!0})},children:d("plan.form.price.clear.button")})}),e.jsx(ce,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:d("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(kt).filter(([S])=>!["onetime","reset_traffic"].includes(S)).map(([S,w])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(g,{control:m.control,name:`prices.${S}`,render:({field:b})=>e.jsxs(f,{children:[e.jsxs(j,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${S}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",w.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:w.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:"0.00",min:0,...b,value:b.value??"",onChange:k=>b.onChange(k.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},S))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(kt).filter(([S])=>["onetime","reset_traffic"].includes(S)).map(([S,w])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(g,{control:m.control,name:`prices.${S}`,render:({field:b})=>e.jsx(f,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(j,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${S}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(S==="onetime"?"plan.form.price.onetime_desc":"plan.form.price.reset_desc")})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:"0.00",min:0,...b,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},S))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(g,{control:m.control,name:"device_limit",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...S,value:S.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.device.unit")})]}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"capacity_limit",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...S,value:S.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.capacity.unit")})]}),e.jsx(D,{})]})})]}),e.jsx(g,{control:m.control,name:"reset_traffic_method",render:({field:S})=>e.jsxs(f,{children:[e.jsx(j,{children:d("plan.form.reset_method.label")}),e.jsxs(G,{value:S.value?.toString()??"null",onValueChange:w=>S.onChange(w=="null"?null:Number(w)),children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(B,{children:Ax.map(w=>e.jsx(z,{value:w.value?.toString()??"null",children:d(`plan.form.reset_method.options.${w.label}`)},w.value))})]}),e.jsx(F,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"content",render:({field:S})=>{const[w,b]=u.useState(!1);return e.jsxs(f,{className:"space-y-2",children:[e.jsxs(j,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d("plan.form.content.label"),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(!w),children:w?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(ce,{side:"top",children:e.jsx("p",{className:"text-xs",children:d(w?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{S.onChange(d("plan.form.content.template.content"))},children:d("plan.form.content.template.button")})}),e.jsx(ce,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:d("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${w?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(y,{children:e.jsx(Ea,{style:{height:"400px"},value:S.value||"",renderHTML:k=>o.render(k),onChange:({text:k})=>S.onChange(k),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:d("plan.form.content.placeholder"),className:"rounded-md border"})})}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:d("plan.form.content.preview")}),e.jsx("div",{className:"prose prose-sm dark:prose-invert h-[400px] max-w-none overflow-y-auto rounded-md border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:o.render(S.value||"")}})})]})]}),e.jsx(F,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(D,{})]})}})]}),e.jsx(ze,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:t&&e.jsx(g,{control:m.control,name:"force_update",render:({field:S})=>e.jsxs(f,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(y,{children:e.jsx(sl,{checked:S.value,onCheckedChange:S.onChange})}),e.jsx("div",{className:"",children:e.jsx(j,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(P,{type:"button",variant:"outline",onClick:C,children:d("plan.form.submit.cancel")}),e.jsx(P,{type:"submit",disabled:i,onClick:()=>{m.handleSubmit(async S=>{l(!0),(await Xc(S)).data&&(A.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),C(),a()),l(!1)})()},children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function Ux(){const[s,n]=u.useState({}),[t,r]=u.useState({"drag-handle":!1}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState(!1),[c,h]=u.useState({pageSize:20,pageIndex:0}),[_,E]=u.useState([]),{refetch:C}=re({queryKey:["planList"],queryFn:async()=>{const{data:p}=await qs();return E(p),p}});u.useEffect(()=>{r({"drag-handle":m}),h({pageSize:m?99999:10,pageIndex:0})},[m]);const S=(p,v)=>{m&&(p.dataTransfer.setData("text/plain",v.toString()),p.currentTarget.classList.add("opacity-50"))},w=(p,v)=>{if(!m)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const M=parseInt(p.dataTransfer.getData("text/plain"));if(M===v)return;const H=[..._],[se]=H.splice(M,1);H.splice(v,0,se),E(H)},b=async()=>{if(!m){o(!0);return}const p=_?.map(v=>v.id);ed(p).then(()=>{A.success("排序保存成功"),o(!1),C()}).finally(()=>{o(!1)})},k=ns({data:_||[],columns:Lx(C),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:c},enableRowSelection:!0,onPaginationChange:h,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}},pageCount:m?1:void 0});return e.jsx(Fx,{refreshData:C,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(hs,{table:k,toolbar:p=>e.jsx(Ox,{table:p,refetch:C,saveOrder:b,isSortMode:m}),draggable:m,onDragStart:S,onDragEnd:p=>p.currentTarget.classList.remove("opacity-50"),onDragOver:p=>{p.preventDefault(),p.currentTarget.classList.add("bg-muted")},onDragLeave:p=>p.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!m}),e.jsx($x,{})]})})}function Hx(){const{t:s}=V("subscribe");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("plan.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("plan.page.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(Ux,{})})]})]})}const qx=Object.freeze(Object.defineProperty({__proto__:null,default:Hx},Symbol.toStringTag,{value:"Module"})),Js=[{value:ae.PENDING,label:ot[ae.PENDING],icon:qo,color:ct[ae.PENDING]},{value:ae.PROCESSING,label:ot[ae.PROCESSING],icon:xr,color:ct[ae.PROCESSING]},{value:ae.COMPLETED,label:ot[ae.COMPLETED],icon:ja,color:ct[ae.COMPLETED]},{value:ae.CANCELLED,label:ot[ae.CANCELLED],icon:hr,color:ct[ae.CANCELLED]},{value:ae.DISCOUNTED,label:ot[ae.DISCOUNTED],icon:ja,color:ct[ae.DISCOUNTED]}],ut=[{value:xe.PENDING,label:Nt[xe.PENDING],icon:Ko,color:_t[xe.PENDING]},{value:xe.PROCESSING,label:Nt[xe.PROCESSING],icon:xr,color:_t[xe.PROCESSING]},{value:xe.VALID,label:Nt[xe.VALID],icon:ja,color:_t[xe.VALID]},{value:xe.INVALID,label:Nt[xe.INVALID],icon:hr,color:_t[xe.INVALID]}];function Tt({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=s?.getFilterValue(),i=Array.isArray(a)?new Set(a):a!==void 0?new Set([a]):new Set;return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:i.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:i.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[i.size," selected"]}):t.filter(l=>i.has(l.value)).map(l=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:l.label},l.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(Me,{onSelect:()=>{const m=new Set(i);d?m.delete(l.value):m.add(l.value);const o=Array.from(m);s?.setFilterValue(o.length?o:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),l.icon&&e.jsx(l.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${l.color}`}),e.jsx("span",{children:l.label}),r?.get(l.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(l.value)})]},l.value)})}),i.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Kx=x.object({email:x.string().min(1),plan_id:x.number(),period:x.string(),total_amount:x.number()}),Bx={email:"",plan_id:0,total_amount:0,period:""};function tl({refetch:s,trigger:n,defaultValues:t}){const{t:r}=V("order"),[a,i]=u.useState(!1),l=ge({resolver:Ne(Kx),defaultValues:{...Bx,...t},mode:"onChange"}),[d,m]=u.useState([]);return u.useEffect(()=>{a&&qs().then(({data:o})=>{m(o)})},[a]),e.jsxs(be,{open:a,onOpenChange:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:r("dialog.addOrder")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:r("dialog.assignOrder")}),e.jsx(Te,{})]}),e.jsxs(_e,{...l,children:[e.jsx(g,{control:l.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.userEmail")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dialog.placeholders.email"),...o})})]})}),e.jsx(g,{control:l.control,name:"plan_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(y,{children:e.jsxs(G,{value:o.value?o.value?.toString():void 0,onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(B,{children:d.map(c=>e.jsx(z,{value:c.id.toString(),children:c.name},c.id))})]})})]})}),e.jsx(g,{control:l.control,name:"period",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.orderPeriod")}),e.jsx(y,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dialog.placeholders.period")})}),e.jsx(B,{children:Object.keys(fu).map(c=>e.jsx(z,{value:c,children:r(`period.${c}`)},c))})]})})]})}),e.jsx(g,{control:l.control,name:"total_amount",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.paymentAmount")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:r("dialog.placeholders.amount"),value:o.value/100,onChange:c=>o.onChange(parseFloat(c.currentTarget.value)*100)})}),e.jsx(D,{})]})}),e.jsxs(ze,{children:[e.jsx(P,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(P,{type:"submit",onClick:()=>{l.handleSubmit(o=>{rd(o).then(({data:c})=>{c&&(s&&s(),l.reset(),i(!1),A.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function Gx({table:s,refetch:n}){const{t}=V("order"),r=s.getState().columnFilters.length>0,a=Object.values(os).filter(m=>typeof m=="number").map(m=>({label:t(`type.${os[m]}`),value:m,color:m===os.NEW?"green-500":m===os.RENEWAL?"blue-500":m===os.UPGRADE?"purple-500":"orange-500"})),i=Object.values(Pe).map(m=>({label:t(`period.${m}`),value:m,color:m===Pe.MONTH_PRICE?"slate-500":m===Pe.QUARTER_PRICE?"cyan-500":m===Pe.HALF_YEAR_PRICE?"indigo-500":m===Pe.YEAR_PRICE?"violet-500":m===Pe.TWO_YEAR_PRICE?"fuchsia-500":m===Pe.THREE_YEAR_PRICE?"pink-500":m===Pe.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(ae).filter(m=>typeof m=="number").map(m=>({label:t(`status.${ae[m]}`),value:m,icon:m===ae.PENDING?Js[0].icon:m===ae.PROCESSING?Js[1].icon:m===ae.COMPLETED?Js[2].icon:m===ae.CANCELLED?Js[3].icon:Js[4].icon,color:m===ae.PENDING?"yellow-500":m===ae.PROCESSING?"blue-500":m===ae.COMPLETED?"green-500":m===ae.CANCELLED?"red-500":"green-500"})),d=Object.values(xe).filter(m=>typeof m=="number").map(m=>({label:t(`commission.${xe[m]}`),value:m,icon:m===xe.PENDING?ut[0].icon:m===xe.PROCESSING?ut[1].icon:m===xe.VALID?ut[2].icon:ut[3].icon,color:m===xe.PENDING?"yellow-500":m===xe.PROCESSING?"blue-500":m===xe.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tl,{refetch:n}),e.jsx(T,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:m=>s.getColumn("trade_no")?.setFilterValue(m.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2",children:[s.getColumn("type")&&e.jsx(Tt,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(Tt,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(Tt,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(Tt,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})}function ls({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:N("flex items-center py-1.5",t),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:N("text-sm",r),children:n||"-"})]})}function Wx({status:s}){const{t:n}=V("order"),t={[ae.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[ae.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[ae.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[ae.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[ae.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(q,{variant:"secondary",className:N("font-medium",t[s]),children:n(`status.${ae[s]}`)})}function Yx({id:s,trigger:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(),{t:l}=V("order");return u.useEffect(()=>{(async()=>{if(t){const{data:m}=await td({id:s});i(m)}})()},[t,s]),e.jsxs(be,{onOpenChange:r,open:t,children:[e.jsx(Je,{asChild:!0,children:n}),e.jsxs(fe,{className:"max-w-xl",children:[e.jsxs(Ce,{className:"space-y-2",children:[e.jsx(ye,{className:"text-lg font-medium",children:l("dialog.title")}),e.jsx("div",{className:"flex items-center justify-between text-sm",children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-muted-foreground",children:[l("table.columns.tradeNo"),":",a?.trade_no]}),a?.status&&e.jsx(Wx,{status:a.status})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ls,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Us,{to:`/user/manage?email=${a.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.user.email,e.jsx(pr,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(ls,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(ls,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(ls,{label:l("dialog.fields.callbackNo"),value:a?.callback_no,valueClassName:"font-mono text-xs"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ls,{label:l("dialog.fields.paymentAmount"),value:Ls(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(ke,{className:"my-2"}),e.jsx(ls,{label:l("dialog.fields.balancePayment"),value:Ls(a?.balance_amount||0)}),e.jsx(ls,{label:l("dialog.fields.discountAmount"),value:Ls(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(ls,{label:l("dialog.fields.refundAmount"),value:Ls(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(ls,{label:l("dialog.fields.deductionAmount"),value:Ls(a?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ls,{label:l("dialog.fields.createdAt"),value:we(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(ls,{label:l("dialog.fields.updatedAt"),value:we(a?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const Qx={[os.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[os.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[os.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[os.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Jx={[Pe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Xx=s=>ae[s],Zx=s=>xe[s],eh=s=>os[s],sh=s=>{const{t:n}=V("order");return[{accessorKey:"trade_no",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.tradeNo")}),cell:({row:t})=>{const r=t.original.trade_no,a=r.length>6?`${r.slice(0,3)}...${r.slice(-3)}`:r;return e.jsx("div",{className:"flex items-center",children:e.jsx(Yx,{trigger:e.jsxs(J,{variant:"ghost",size:"sm",className:"flex h-8 items-center gap-1.5 px-2 font-medium text-primary transition-colors hover:bg-primary/10 hover:text-primary/80",children:[e.jsx("span",{className:"font-mono",children:a}),e.jsx(pr,{className:"h-3.5 w-3.5 opacity-70"})]}),id:t.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>{const r=t.getValue("type"),a=Qx[r];return e.jsx(q,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",a.color,a.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${eh(r)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.plan")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium text-foreground/90 sm:max-w-72 md:max-w-[31rem]",children:t.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.period")}),cell:({row:t})=>{const r=t.getValue("period"),a=Jx[r];return e.jsx(q,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",a.color,a.bgColor,"hover:bg-opacity-80"),children:n(`period.${r}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.amount")}),cell:({row:t})=>{const r=t.getValue("total_amount"),a=typeof r=="number"?(r/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",a]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:t})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:t,title:n("table.columns.status")}),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx(Gr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(ce,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:t})=>{const r=Js.find(a=>a.value===t.getValue("status"));return r?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.icon&&e.jsx(r.icon,{className:`h-4 w-4 text-${r.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${Xx(r.value)}`)})]}),r.value===ae.PENDING&&e.jsxs(Ss,{modal:!0,children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Vt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(fs,{align:"end",className:"w-[140px]",children:[e.jsx(je,{className:"cursor-pointer",onClick:async()=>{await ad({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await nd({trade_no:t.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commission")}),cell:({row:t})=>{const r=t.getValue("commission_balance"),a=r?(r/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:r?`¥${a}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commissionStatus")}),cell:({row:t})=>{const r=t.original.status,a=t.original.commission_balance,i=ut.find(l=>l.value===t.getValue("commission_status"));return a==0||!i?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i.icon&&e.jsx(i.icon,{className:`h-4 w-4 text-${i.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${Zx(i.value)}`)})]}),i.value===xe.PENDING&&r===ae.COMPLETED&&e.jsxs(Ss,{modal:!0,children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Vt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(fs,{align:"end",className:"w-[120px]",children:[e.jsx(je,{className:"cursor-pointer",onClick:async()=>{await an({trade_no:t.original.trade_no,commission_status:xe.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await an({trade_no:t.original.trade_no,commission_status:xe.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.createdAt")}),cell:({row:t})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:we(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function th(){const[s]=fr(),[n,t]=u.useState({}),[r,a]=u.useState({}),[i,l]=u.useState([]),[d,m]=u.useState([]),[o,c]=u.useState({pageIndex:0,pageSize:20});u.useEffect(()=>{const w=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([b,k])=>{const p=s.get(b);return p?{id:b,value:k==="number"?parseInt(p):p}:null}).filter(Boolean);w.length>0&&l(w)},[s]);const{refetch:h,data:_,isLoading:E}=re({queryKey:["orderList",o,i,d],queryFn:()=>sd({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),C=ns({data:_?.data??[],columns:sh(h),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:o},rowCount:_?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:m,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),onPaginationChange:c,getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:C,toolbar:e.jsx(Gx,{table:C,refetch:h}),showPagination:!0})}function ah(){const{t:s}=V("order");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",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(th,{})})]})]})}const nh=Object.freeze(Object.defineProperty({__proto__:null,default:ah},Symbol.toStringTag,{value:"Module"}));function rh({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const lh=x.object({id:x.coerce.number().nullable().optional(),name:x.string().min(1,"请输入优惠券名称"),code:x.string().nullable(),type:x.coerce.number(),value:x.coerce.number(),started_at:x.coerce.number(),ended_at:x.coerce.number(),limit_use:x.union([x.string(),x.number()]).nullable(),limit_use_with_user:x.union([x.string(),x.number()]).nullable(),generate_count:x.coerce.number().nullable().optional(),limit_plan_ids:x.array(x.coerce.number()).default([]).nullable(),limit_period:x.array(x.nativeEnum(xt)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),xn={name:"",code:null,type:Be.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:null,limit_use_with_user:null,limit_plan_ids:[],limit_period:[],generate_count:null};function al({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=V("coupon"),[d,m]=u.useState(!1),o=a??d,c=i??m,[h,_]=u.useState([]),E=ge({resolver:Ne(lh),defaultValues:s||xn});u.useEffect(()=>{s&&E.reset(s)},[s,E]),u.useEffect(()=>{qs().then(({data:b})=>_(b))},[]);const C=b=>{if(!b)return;const k=(p,v)=>{const M=new Date(v*1e3);return p.setHours(M.getHours(),M.getMinutes(),M.getSeconds()),Math.floor(p.getTime()/1e3)};b.from&&E.setValue("started_at",k(b.from,E.watch("started_at"))),b.to&&E.setValue("ended_at",k(b.to,E.watch("ended_at")))},S=async b=>{const k=await id(b);if(b.generate_count&&k){const p=new Blob([k],{type:"text/csv;charset=utf-8;"}),v=document.createElement("a");v.href=window.URL.createObjectURL(p),v.download=`coupons_${new Date().getTime()}.csv`,v.click(),window.URL.revokeObjectURL(v.href)}c(!1),t==="create"&&E.reset(xn),n()},w=(b,k)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:k}),e.jsx(T,{type:"datetime-local",step:"1",value:we(E.watch(b),"YYYY-MM-DDTHH:mm:ss"),onChange:p=>{const v=new Date(p.target.value);E.setValue(b,Math.floor(v.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(be,{open:o,onOpenChange:c,children:[r&&e.jsx(Je,{asChild:!0,children:r}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(_e,{...E,children:e.jsxs("form",{onSubmit:E.handleSubmit(S),className:"space-y-4",children:[e.jsx(g,{control:E.control,name:"name",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.name.label")}),e.jsx(T,{placeholder:l("form.name.placeholder"),...b}),e.jsx(D,{})]})}),t==="create"&&e.jsx(g,{control:E.control,name:"generate_count",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.generateCount.label")}),e.jsx(T,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...b,value:b.value===void 0?"":b.value,onChange:k=>b.onChange(k.target.value===""?"":parseInt(k.target.value)),className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(D,{})]})}),(!E.watch("generate_count")||E.watch("generate_count")==null)&&e.jsx(g,{control:E.control,name:"code",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.code.label")}),e.jsx(T,{placeholder:l("form.code.placeholder"),...b,className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.code.description")}),e.jsx(D,{})]})}),e.jsxs(f,{children:[e.jsx(j,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(g,{control:E.control,name:"type",render:({field:b})=>e.jsxs(G,{value:b.value.toString(),onValueChange:k=>{const p=b.value,v=parseInt(k);b.onChange(v);const M=E.getValues("value");M&&(p===Be.AMOUNT&&v===Be.PERCENTAGE?E.setValue("value",M/100):p===Be.PERCENTAGE&&v===Be.AMOUNT&&E.setValue("value",M*100))},children:[e.jsx(K,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(W,{placeholder:l("form.type.placeholder")})}),e.jsx(B,{children:Object.entries(gu).map(([k,p])=>e.jsx(z,{value:k,children:l(`table.toolbar.types.${k}`)},k))})]})}),e.jsx(g,{control:E.control,name:"value",render:({field:b})=>{const k=b.value==null?"":E.watch("type")===Be.AMOUNT&&typeof b.value=="number"?(b.value/100).toString():b.value.toString();return e.jsx(T,{type:"number",placeholder:l("form.value.placeholder"),...b,value:k,onChange:p=>{const v=p.target.value;if(v===""){b.onChange("");return}const M=parseFloat(v);isNaN(M)||b.onChange(E.watch("type")===Be.AMOUNT?Math.round(M*100):M)},step:"any",min:0,className:"flex-[2] rounded-none border-x-0 text-left"})}}),e.jsx("div",{className:"flex min-w-[40px] items-center justify-center rounded-md rounded-l-none border border-l-0 border-input bg-muted/50 px-3 font-medium text-muted-foreground",children:e.jsx("span",{children:E.watch("type")==Be.AMOUNT?"¥":"%"})})]})]}),e.jsxs(f,{children:[e.jsx(j,{children:l("form.validity.label")}),e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",className:N("w-full justify-start text-left font-normal",!E.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4"}),we(E.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",we(E.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(xs,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(Gs,{mode:"range",selected:{from:new Date(E.watch("started_at")*1e3),to:new Date(E.watch("ended_at")*1e3)},onSelect:C,numberOfMonths:2})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-4",children:[w("started_at",l("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:l("form.validity.to")}),w("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(D,{})]}),e.jsx(g,{control:E.control,name:"limit_use",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitUse.label")}),e.jsx(T,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...b,value:b.value===null?"":b.value,onChange:k=>b.onChange(k.target.value===""?null:parseInt(k.target.value)),className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:E.control,name:"limit_use_with_user",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitUseWithUser.label")}),e.jsx(T,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...b,value:b.value===null?"":b.value,onChange:k=>b.onChange(k.target.value===""?null:parseInt(k.target.value)),className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:E.control,name:"limit_period",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitPeriod.label")}),e.jsx(at,{options:Object.entries(xt).filter(([k])=>isNaN(Number(k))).map(([k,p])=>({label:l(`coupon:period.${p}`),value:k})),onChange:k=>{if(k.length===0){b.onChange([]);return}const p=k.map(v=>xt[v.value]);b.onChange(p)},value:(b.value||[]).map(k=>({label:l(`coupon:period.${k}`),value:Object.entries(xt).find(([p,v])=>v===k)?.[0]||""})),placeholder:l("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPeriod.empty")})}),e.jsx(F,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:E.control,name:"limit_plan_ids",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitPlan.label")}),e.jsx(at,{options:h?.map(k=>({label:k.name,value:k.id.toString()}))||[],onChange:k=>b.onChange(k.map(p=>Number(p.value))),value:(h||[]).filter(k=>(b.value||[]).includes(k.id)).map(k=>({label:k.name,value:k.id.toString()})),placeholder:l("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPlan.empty")})}),e.jsx(D,{})]})}),e.jsx(ze,{children:e.jsx(P,{type:"submit",disabled:E.formState.isSubmitting,children:E.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function ih({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(al,{refetch:n,dialogTrigger:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:r("form.add")})]})}),e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(rh,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:Be.AMOUNT,label:r(`table.toolbar.types.${Be.AMOUNT}`)},{value:Be.PERCENTAGE,label:r(`table.toolbar.types.${Be.PERCENTAGE}`)}]}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})}const nl=u.createContext(void 0);function oh({children:s,refetch:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null),l=m=>{i(m),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(nl.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(al,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function ch(){const s=u.useContext(nl);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const dh=s=>{const{t:n}=V("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(q,{children:t.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.original.show,onCheckedChange:r=>{cd({id:t.original.id,show:r}).then(({data:a})=>!a&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:n(`table.toolbar.types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.code")}),cell:({row:t})=>e.jsx(q,{variant:"secondary",children:t.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUse")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:t.original.limit_use===null?n("table.validity.unlimited"):t.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUseWithUser")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:t.original.limit_use_with_user===null?n("table.validity.noLimit"):t.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.validity")}),cell:({row:t})=>{const[r,a]=u.useState(!1),i=Date.now(),l=t.original.started_at*1e3,d=t.original.ended_at*1e3,m=i>d,o=ie.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=ch();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(Qe,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{od({id:t.original.id}).then(({data:a})=>{a&&(A.success("删除成功"),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete")})]})})]})}}]};function uh(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=re({queryKey:["couponList",m,a,l],queryFn:()=>ld({pageSize:m.pageSize,current:m.pageIndex+1,filter:a,sort:l})}),_=ns({data:h?.data??[],columns:dh(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:m},pageCount:Math.ceil((h?.total??0)/m.pageSize),rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:o,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(oh,{refetch:c,children:e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:_,toolbar:e.jsx(ih,{table:_,refetch:c})})})})}function mh(){const{t:s}=V("coupon");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",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(uh,{})})]})]})}const xh=Object.freeze(Object.defineProperty({__proto__:null,default:mh},Symbol.toStringTag,{value:"Module"})),hh=1,ph=1e6;let ua=0;function fh(){return ua=(ua+1)%Number.MAX_SAFE_INTEGER,ua.toString()}const ma=new Map,hn=s=>{if(ma.has(s))return;const n=setTimeout(()=>{ma.delete(s),ht({type:"REMOVE_TOAST",toastId:s})},ph);ma.set(s,n)},gh=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,hh)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(t=>t.id===n.toast.id?{...t,...n.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=n;return t?hn(t):s.toasts.forEach(r=>{hn(r.id)}),{...s,toasts:s.toasts.map(r=>r.id===t||t===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return n.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(t=>t.id!==n.toastId)}}},Pt=[];let Et={toasts:[]};function ht(s){Et=gh(Et,s),Pt.forEach(n=>{n(Et)})}function jh({...s}){const n=fh(),t=a=>ht({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>ht({type:"DISMISS_TOAST",toastId:n});return ht({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function rl(){const[s,n]=u.useState(Et);return u.useEffect(()=>(Pt.push(n),()=>{const t=Pt.indexOf(n);t>-1&&Pt.splice(t,1)}),[s]),{...s,toast:jh,dismiss:t=>ht({type:"DISMISS_TOAST",toastId:t})}}function vh({open:s,onOpenChange:n,table:t}){const{t:r}=V("user"),{toast:a}=rl(),[i,l]=u.useState(!1),[d,m]=u.useState(""),[o,c]=u.useState(""),h=async()=>{if(!d||!o){a({title:r("messages.error"),description:r("messages.send_mail.required_fields"),variant:"destructive"});return}try{l(!0),await Ot.sendMail({subject:d,content:o,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),a({title:r("messages.success"),description:r("messages.send_mail.success")}),n(!1),m(""),c("")}catch{a({title:r("messages.error"),description:r("messages.send_mail.failed"),variant:"destructive"})}finally{l(!1)}};return e.jsx(be,{open:s,onOpenChange:n,children:e.jsxs(fe,{className:"sm:max-w-[500px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:r("send_mail.title")}),e.jsx(Te,{children:r("send_mail.description")})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"subject",className:"text-right",children:r("send_mail.subject")}),e.jsx(T,{id:"subject",value:d,onChange:_=>m(_.target.value),className:"col-span-3"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"content",className:"text-right",children:r("send_mail.content")}),e.jsx(ys,{id:"content",value:o,onChange:_=>c(_.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(ze,{children:e.jsx(J,{type:"submit",onClick:h,disabled:i,children:r(i?"send_mail.sending":"send_mail.send")})})]})})}const bh=x.object({email_prefix:x.string().optional(),email_suffix:x.string().min(1),password:x.string().optional(),expired_at:x.number().optional().nullable(),plan_id:x.number().nullable(),generate_count:x.number().optional().nullable()}).refine(s=>s.generate_count===null?s.email_prefix!==void 0&&s.email_prefix!=="":!0,{message:"Email prefix is required when generate_count is null",path:["email_prefix"]}),yh={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function Nh({refetch:s}){const{t:n}=V("user"),[t,r]=u.useState(!1),a=ge({resolver:Ne(bh),defaultValues:yh,mode:"onChange"}),[i,l]=u.useState([]);return u.useEffect(()=>{t&&qs().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(be,{open:t,onOpenChange:r,children:[e.jsx(Je,{asChild:!0,children:e.jsxs(J,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:n("generate.title")}),e.jsx(Te,{})]}),e.jsxs(_e,{...a,children:[e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(g,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(T,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...d})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${a.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(g,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(T,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(g,{control:a.control,name:"password",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.password")}),e.jsx(T,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(j,{children:n("generate.form.expire_time")}),e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsx(y,{children:e.jsxs(J,{variant:"outline",className:N("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?we(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(jt,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(xs,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Go,{asChild:!0,children:e.jsx(J,{variant:"outline",className:"w-full",onClick:()=>{d.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Gs,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:m=>{m&&d.onChange(m?.getTime()/1e3)}})})]})]})]})}),e.jsx(g,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.subscription")}),e.jsx(y,{children:e.jsxs(G,{value:d.value?d.value.toString():"null",onValueChange:m=>d.onChange(m==="null"?null:parseInt(m)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(z,{value:"null",children:n("generate.form.subscription_none")}),i.map(m=>e.jsx(z,{value:m.id.toString(),children:m.name},m.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(g,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.generate_count")}),e.jsx(T,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:d.value||"",onChange:m=>d.onChange(m.target.value?parseInt(m.target.value):null)})]})})]}),e.jsxs(ze,{children:[e.jsx(J,{variant:"outline",onClick:()=>r(!1),children:n("generate.form.cancel")}),e.jsx(J,{onClick:()=>a.handleSubmit(d=>{xd(d).then(({data:m})=>{m&&(A.success(n("generate.form.success")),a.reset(),s(),r(!1))})})(),children:n("generate.form.submit")})]})]})]})}const ll=Nn,_h=_n,wh=wn,il=u.forwardRef(({className:s,...n},t)=>e.jsx(zt,{className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));il.displayName=zt.displayName;const Ch=As("fixed overflow-y-scroll z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-md",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-md"}},defaultVariants:{side:"right"}}),Aa=u.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(wh,{children:[e.jsx(il,{}),e.jsxs(At,{ref:a,className:N(Ch({side:s}),n),...r,children:[e.jsxs(Ca,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(ss,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));Aa.displayName=At.displayName;const $a=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});$a.displayName="SheetHeader";const ol=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});ol.displayName="SheetFooter";const Ua=u.forwardRef(({className:s,...n},t)=>e.jsx($t,{ref:t,className:N("text-lg font-semibold text-foreground",s),...n}));Ua.displayName=$t.displayName;const Ha=u.forwardRef(({className:s,...n},t)=>e.jsx(Ut,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Ha.displayName=Ut.displayName;function Sh({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=V("user"),{toast:i}=rl(),l=s.getState().columnFilters.length>0,[d,m]=u.useState([]),[o,c]=u.useState(!1),[h,_]=u.useState(!1),[E,C]=u.useState(!1),[S,w]=u.useState(!1),b=async()=>{try{const Q=await Ot.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),te=Q;console.log(Q);const $=new Blob([te],{type:"text/csv;charset=utf-8;"}),R=window.URL.createObjectURL($),X=document.createElement("a");X.href=R,X.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(X),X.click(),X.remove(),window.URL.revokeObjectURL(R),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},k=async()=>{try{w(!0),await Ot.batchBan({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),i({title:a("messages.success"),description:a("messages.batch_ban.success")}),n()}catch{i({title:a("messages.error"),description:a("messages.batch_ban.failed"),variant:"destructive"})}finally{w(!1),C(!1)}},p=[{label:a("filter.fields.email"),value:"email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.id"),value:"id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:a("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{label:a("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.token"),value:"token",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.banned"),value:"banned",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],options:[{label:a("filter.status.normal"),value:"0"},{label:a("filter.status.banned"),value:"1"}]},{label:a("filter.fields.remark"),value:"remarks",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.inviter_email"),value:"invite_user.email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]}],v=Q=>Q*1024*1024*1024,M=Q=>Q/(1024*1024*1024),H=()=>{m([...d,{field:"",operator:"",value:""}])},se=Q=>{m(d.filter((te,$)=>$!==Q))},L=(Q,te,$)=>{const R=[...d];if(R[Q]={...R[Q],[te]:$},te==="field"){const X=p.find(Ns=>Ns.value===$);X&&(R[Q].operator=X.operators[0].value,R[Q].value=X.type==="boolean"?!1:"")}m(R)},Z=(Q,te)=>{const $=p.find(R=>R.value===Q.field);if(!$)return null;switch($.type){case"text":return e.jsx(T,{placeholder:a("filter.sheet.value"),value:Q.value,onChange:R=>L(te,"value",R.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(T,{type:"number",placeholder:a("filter.sheet.value_number",{unit:$.unit}),value:$.unit==="GB"?M(Q.value||0):Q.value,onChange:R=>{const X=Number(R.target.value);L(te,"value",$.unit==="GB"?v(X):X)}}),$.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:$.unit})]});case"date":return e.jsx(Gs,{mode:"single",selected:Q.value,onSelect:R=>L(te,"value",R),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(G,{value:Q.value,onValueChange:R=>L(te,"value",R),children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("filter.sheet.value")})}),e.jsx(B,{children:$.useOptions?r.map(R=>e.jsx(z,{value:R.value.toString(),children:R.label},R.value)):$.options?.map(R=>e.jsx(z,{value:R.value.toString(),children:R.label},R.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Y,{checked:Q.value,onCheckedChange:R=>L(te,"value",R)}),e.jsx(Mt,{children:Q.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},de=()=>{const Q=d.filter(te=>te.field&&te.operator&&te.value!=="").map(te=>{const $=p.find(X=>X.value===te.field);let R=te.value;return te.operator==="contains"?{id:te.field,value:R}:($?.type==="date"&&R instanceof Date&&(R=Math.floor(R.getTime()/1e3)),$?.type==="boolean"&&(R=R?1:0),{id:te.field,value:`${te.operator}:${R}`})});s.setColumnFilters(Q),c(!1)};return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsx(Nh,{refetch:n}),e.jsx(T,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:Q=>s.getColumn("email")?.setFilterValue(Q.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(ll,{open:o,onOpenChange:c,children:[e.jsx(_h,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Wo,{className:"mr-2 h-4 w-4"}),a("filter.advanced"),d.length>0&&e.jsx(q,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:d.length})]})}),e.jsxs(Aa,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs($a,{children:[e.jsx(Ua,{children:a("filter.sheet.title")}),e.jsx(Ha,{children:a("filter.sheet.description")})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:a("filter.sheet.conditions")}),e.jsx(P,{variant:"outline",size:"sm",onClick:H,children:a("filter.sheet.add")})]}),e.jsx(zs,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((Q,te)=>e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Mt,{children:a("filter.sheet.condition",{number:te+1})}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>se(te),children:e.jsx(ss,{className:"h-4 w-4"})})]}),e.jsxs(G,{value:Q.field,onValueChange:$=>L(te,"field",$),children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("filter.sheet.field")})}),e.jsx(B,{children:e.jsx(He,{children:p.map($=>e.jsx(z,{value:$.value,className:"cursor-pointer",children:$.label},$.value))})})]}),Q.field&&e.jsxs(G,{value:Q.operator,onValueChange:$=>L(te,"operator",$),children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("filter.sheet.operator")})}),e.jsx(B,{children:p.find($=>$.value===Q.field)?.operators.map($=>e.jsx(z,{value:$.value,children:$.label},$.value))})]}),Q.field&&Q.operator&&Z(Q,te)]},te))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{variant:"outline",onClick:()=>{m([]),c(!1)},children:a("filter.sheet.reset")}),e.jsx(P,{onClick:de,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(P,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),m([])},className:"h-8 px-2 lg:px-3",children:[a("reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]}),e.jsxs(Ss,{modal:!1,children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(fs,{children:[e.jsx(je,{onClick:()=>_(!0),children:a("actions.send_email")}),e.jsx(je,{onClick:b,children:a("actions.export_csv")}),e.jsx(tt,{}),e.jsx(je,{onClick:()=>C(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(vh,{open:h,onOpenChange:_,table:s}),e.jsx(Oa,{open:E,onOpenChange:C,children:e.jsxs(Yt,{children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:a("actions.confirm_ban.title")}),e.jsx(Zt,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs(Jt,{children:[e.jsx(sa,{disabled:S,children:a("actions.confirm_ban.cancel")}),e.jsx(ea,{onClick:k,disabled:S,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(S?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const cl=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:"m17.71 11.29l-5-5a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21l-5 5a1 1 0 0 0 1.42 1.42L11 9.41V17a1 1 0 0 0 2 0V9.41l3.29 3.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42"})}),dl=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:"M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42"})}),kh=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:"M17 11H9.41l3.3-3.29a1 1 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l5 5a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L9.41 13H17a1 1 0 0 0 0-2"})}),Th=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:"M17.92 11.62a1 1 0 0 0-.21-.33l-5-5a1 1 0 0 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l5-5a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76"})}),xa=[{accessorKey:"record_at",header:"时间",cell:({row:s})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("time",{className:"text-sm text-muted-foreground",children:mc(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(cl,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:ps(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(dl,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:ps(s.original.d)})]})},{accessorKey:"server_rate",header:"倍率",cell:({row:s})=>{const n=s.original.server_rate;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(q,{variant:"outline",className:"font-mono",children:[n,"x"]})})}},{id:"total",header:"总计",cell:({row:s})=>{const n=s.original.u+s.original.d;return e.jsx("div",{className:"flex items-center justify-end font-mono text-sm",children:ps(n)})}}];function ul({user_id:s,dialogTrigger:n}){const{t}=V(["traffic"]),[r,a]=u.useState(!1),[i,l]=u.useState({pageIndex:0,pageSize:20}),{data:d,isLoading:m}=re({queryKey:["userStats",s,i,r],queryFn:()=>r?hd({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),o=ns({data:d?.data??[],columns:xa,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:rs(),onPaginationChange:l});return e.jsxs(be,{open:r,onOpenChange:a,children:[e.jsx(Je,{asChild:!0,children:n}),e.jsxs(fe,{className:"sm:max-w-[700px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ia,{children:[e.jsx(Va,{children:o.getHeaderGroups().map(c=>e.jsx(Is,{children:c.headers.map(h=>e.jsx(Fa,{className:N("h-10 px-2 text-xs",h.id==="total"&&"text-right"),children:h.isPlaceholder?null:Rt(h.column.columnDef.header,h.getContext())},h.id))},c.id))}),e.jsx(Ma,{children:m?Array.from({length:i.pageSize}).map((c,h)=>e.jsx(Is,{children:Array.from({length:xa.length}).map((_,E)=>e.jsx(Zs,{className:"p-2",children:e.jsx(oe,{className:"h-6 w-full"})},E))},h)):o.getRowModel().rows?.length?o.getRowModel().rows.map(c=>e.jsx(Is,{"data-state":c.getIsSelected()&&"selected",className:"h-10",children:c.getVisibleCells().map(h=>e.jsx(Zs,{className:"px-2",children:Rt(h.column.columnDef.cell,h.getContext())},h.id))},c.id)):e.jsx(Is,{children:e.jsx(Zs,{colSpan:xa.length,className:"h-24 text-center",children:t("trafficRecord.noRecords")})})})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:t("trafficRecord.perPage")}),e.jsxs(G,{value:`${o.getState().pagination.pageSize}`,onValueChange:c=>{o.setPageSize(Number(c))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:o.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50].map(c=>e.jsx(z,{value:`${c}`,children:c},c))})]}),e.jsx("p",{className:"text-sm font-medium",children:t("trafficRecord.records")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex w-[100px] items-center justify-center text-sm",children:t("trafficRecord.page",{current:o.getState().pagination.pageIndex+1,total:o.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||m,children:e.jsx(kh,{className:"h-4 w-4"})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||m,children:e.jsx(Th,{className:"h-4 w-4"})})]})]})]})]})]})]})}function Dh({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Oa,{children:[e.jsx(Kr,{asChild:!0,children:n}),e.jsxs(Yt,{className:N("sm:max-w-[425px]",d),children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:t}),e.jsx(Zt,{children:r})]}),e.jsxs(Jt,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a})}),e.jsx(ea,{asChild:!0,children:e.jsx(P,{variant:l,onClick:s,children:i})})]})]})]})}const Ph=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:"M5 18h4.24a1 1 0 0 0 .71-.29l6.92-6.93L19.71 8a1 1 0 0 0 0-1.42l-4.24-4.29a1 1 0 0 0-1.42 0l-2.82 2.83l-6.94 6.93a1 1 0 0 0-.29.71V17a1 1 0 0 0 1 1m9.76-13.59l2.83 2.83l-1.42 1.42l-2.83-2.83ZM6 13.17l5.93-5.93l2.83 2.83L8.83 16H6ZM21 20H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2"})}),Eh=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:"M19 11h-6V5a1 1 0 0 0-2 0v6H5a1 1 0 0 0 0 2h6v6a1 1 0 0 0 2 0v-6h6a1 1 0 0 0 0-2"})}),Rh=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:"M21 8.94a1.3 1.3 0 0 0-.06-.27v-.09a1 1 0 0 0-.19-.28l-6-6a1 1 0 0 0-.28-.19a.3.3 0 0 0-.09 0a.9.9 0 0 0-.33-.11H10a3 3 0 0 0-3 3v1H6a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-1h1a3 3 0 0 0 3-3zm-6-3.53L17.59 8H16a1 1 0 0 1-1-1ZM15 19a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h1v7a3 3 0 0 0 3 3h5Zm4-4a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3v3a3 3 0 0 0 3 3h3Z"})}),Ih=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:"M21 11a1 1 0 0 0-1 1a8.05 8.05 0 1 1-2.22-5.5h-2.4a1 1 0 0 0 0 2h4.53a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v1.77A10 10 0 1 0 22 12a1 1 0 0 0-1-1"})}),Vh=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:"M9.5 10.5H12a1 1 0 0 0 0-2h-1V8a1 1 0 0 0-2 0v.55a2.5 2.5 0 0 0 .5 4.95h1a.5.5 0 0 1 0 1H8a1 1 0 0 0 0 2h1v.5a1 1 0 0 0 2 0v-.55a2.5 2.5 0 0 0-.5-4.95h-1a.5.5 0 0 1 0-1M21 12h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Z"})}),Mh=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:"M12.3 12.22A4.92 4.92 0 0 0 14 8.5a5 5 0 0 0-10 0a4.92 4.92 0 0 0 1.7 3.72A8 8 0 0 0 1 19.5a1 1 0 0 0 2 0a6 6 0 0 1 12 0a1 1 0 0 0 2 0a8 8 0 0 0-4.7-7.28M9 11.5a3 3 0 1 1 3-3a3 3 0 0 1-3 3m9.74.32A5 5 0 0 0 15 3.5a1 1 0 0 0 0 2a3 3 0 0 1 3 3a3 3 0 0 1-1.5 2.59a1 1 0 0 0-.5.84a1 1 0 0 0 .45.86l.39.26l.13.07a7 7 0 0 1 4 6.38a1 1 0 0 0 2 0a9 9 0 0 0-4.23-7.68"})}),Fh=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:"M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2m0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1"})}),Oh=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:"M20 6h-4V5a3 3 0 0 0-3-3h-2a3 3 0 0 0-3 3v1H4a1 1 0 0 0 0 2h1v11a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8h1a1 1 0 0 0 0-2M10 5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1h-4Zm7 14a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V8h10Z"})}),Lh=(s,n,t,r)=>{const{t:a}=V("user");return[{accessorKey:"is_admin",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"is_staff",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.id")}),cell:({row:i})=>e.jsx(q,{variant:"outline",children:i.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.email")}),cell:({row:i})=>{const l=i.original.t||0,d=Date.now()/1e3-l<120,m=Math.floor(Date.now()/1e3-l);let o=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:we(l)});if(!d&&l!==0){const c=Math.floor(m/60),h=Math.floor(c/60),_=Math.floor(h/24);_>0?o+=` +`))}})})}),e.jsx(D,{})]})}),e.jsx(g,{control:i.control,name:"action",render:({field:m})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsxs(G,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(B,{children:[e.jsx(z,{value:"block",children:a("actions.block")}),e.jsx(z,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(D,{})]})}),i.watch("action")==="dns"&&e.jsx(g,{control:i.control,name:"action_value",render:({field:m})=>e.jsxs(f,{children:[e.jsx(j,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:a("form.dnsPlaceholder"),...m})})})]})}),e.jsxs(ze,{children:[e.jsx(yt,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{Mc(i.getValues()).then(({data:m})=>{m&&(d(!1),s&&s(),toast.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function Rx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("route");return e.jsx("div",{className:"flex items-center justify-between ",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[e.jsx(Zr,{refetch:n}),e.jsx(T,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:a=>s.getColumn("remarks")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})})}function Ix({columns:s,data:n,refetch:t}){const[r,a]=u.useState({}),[i,l]=u.useState({}),[d,m]=u.useState([]),[o,c]=u.useState([]),h=ns({data:n,columns:s,state:{sorting:o,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:c,onColumnFiltersChange:m,onColumnVisibilityChange:l,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:h,toolbar:_=>e.jsx(Rx,{table:_,refetch:t})})}const Vx=s=>{const{t:n}=V("route"),t={block:{icon:Uo,variant:"destructive",className:"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-800"},dns:{icon:Ho,variant:"secondary",className:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-400 hover:bg-blue-200 dark:hover:bg-blue-800"}};return[{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.id")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:r.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.remarks")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:r.original.remarks})}),enableHiding:!1,enableSorting:!1},{accessorKey:"action_value",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action_value.title")}),cell:({row:r})=>{const a=r.original.action,i=r.original.action_value,l=r.original.match?.length||0;return e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("span",{className:"text-sm font-medium",children:a==="dns"&&i?n("columns.action_value.dns",{value:i}):a==="block"?e.jsx("span",{className:"text-destructive",children:n("columns.action_value.block")}):n("columns.action_value.direct")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("columns.matchRules",{count:l})})]})},enableHiding:!1,enableSorting:!1,size:300},{accessorKey:"action",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action")}),cell:({row:r})=>{const a=r.getValue("action"),i=t[a]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(q,{variant:t[a]?.variant||"default",className:N("flex items-center gap-1.5 px-3 py-1 capitalize",t[a]?.className),children:[i&&e.jsx(i,{className:"h-3.5 w-3.5"}),n(`actions.${a}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Zr,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Fc({id:r.original.id}).then(({data:a})=>{a&&(A.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Mx(){const{t:s}=V("route"),[n,t]=u.useState([]);function r(){Sr().then(({data:a})=>{t(a)})}return u.useEffect(()=>{r()},[]),e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Ix,{data:n,columns:Vx(r),refetch:r})})]})]})}const Fx=Object.freeze(Object.defineProperty({__proto__:null,default:Mx},Symbol.toStringTag,{value:"Module"})),el=u.createContext(void 0);function Ox({children:s,refreshData:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null);return e.jsx(el.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function za(){const s=u.useContext(el);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function Lx({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=za(),{t:a}=V("subscribe");return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(P,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:a("plan.add")})]}),e.jsx(T,{placeholder:a("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:i=>s.getColumn("name")?.setFilterValue(i.target.value),className:"h-8 w-[150px] lg:w-[250px]"})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const mn={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},zx=s=>{const{t:n}=V("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ht,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(q,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.show")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{aa({id:t.original.id,show:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.sell")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{aa({id:t.original.id,sell:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{aa({id:t.original.id,renew:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.stats")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(gt,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.group")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.price")}),cell:({row:t})=>{const r=t.getValue("prices"),a=[{period:n("plan.columns.price_period.monthly"),key:"monthly",unit:n("plan.columns.price_period.unit.month")},{period:n("plan.columns.price_period.quarterly"),key:"quarterly",unit:n("plan.columns.price_period.unit.quarter")},{period:n("plan.columns.price_period.half_yearly"),key:"half_yearly",unit:n("plan.columns.price_period.unit.half_year")},{period:n("plan.columns.price_period.yearly"),key:"yearly",unit:n("plan.columns.price_period.unit.year")},{period:n("plan.columns.price_period.two_yearly"),key:"two_yearly",unit:n("plan.columns.price_period.unit.two_year")},{period:n("plan.columns.price_period.three_yearly"),key:"three_yearly",unit:n("plan.columns.price_period.unit.three_year")},{period:n("plan.columns.price_period.onetime"),key:"onetime",unit:""},{period:n("plan.columns.price_period.reset_traffic"),key:"reset_traffic",unit:n("plan.columns.price_period.unit.times")}];return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:a.map(({period:i,key:l,unit:d})=>r[l]!=null&&e.jsxs(q,{variant:"secondary",className:N("px-2 py-0.5 font-medium transition-colors text-nowrap",mn[l].color,mn[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=za();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(Qe,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{ed({id:t.original.id}).then(({data:i})=>{i&&(A.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.delete")})]})})]})}}]},Ax=x.object({id:x.number().nullable(),group_id:x.union([x.number(),x.string()]).nullable().optional(),name:x.string().min(1).max(250),content:x.string().nullable().optional(),transfer_enable:x.union([x.number().min(0),x.string().min(1)]),prices:x.object({monthly:x.union([x.number(),x.string()]).nullable().optional(),quarterly:x.union([x.number(),x.string()]).nullable().optional(),half_yearly:x.union([x.number(),x.string()]).nullable().optional(),yearly:x.union([x.number(),x.string()]).nullable().optional(),two_yearly:x.union([x.number(),x.string()]).nullable().optional(),three_yearly:x.union([x.number(),x.string()]).nullable().optional(),onetime:x.union([x.number(),x.string()]).nullable().optional(),reset_traffic:x.union([x.number(),x.string()]).nullable().optional()}).default({}),speed_limit:x.union([x.number(),x.string()]).nullable().optional(),capacity_limit:x.union([x.number(),x.string()]).nullable().optional(),device_limit:x.union([x.number(),x.string()]).nullable().optional(),force_update:x.boolean().optional(),reset_traffic_method:x.number().nullable(),users_count:x.number().optional()}),sl=u.forwardRef(({className:s,...n},t)=>e.jsx(mr,{ref:t,className:N("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...n,children:e.jsx(qo,{className:N("flex items-center justify-center text-current"),children:e.jsx($s,{className:"h-4 w-4"})})}));sl.displayName=mr.displayName;const St={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},kt={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},$x=[{value:null,label:"follow_system"},{value:0,label:"monthly_first"},{value:1,label:"monthly_reset"},{value:2,label:"no_reset"},{value:3,label:"yearly_first"},{value:4,label:"yearly_reset"}];function Ux(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=za(),[i,l]=u.useState(!1),{t:d}=V("subscribe"),m=ge({resolver:Ne(Ax),defaultValues:{...St,...t||{}},mode:"onChange"});u.useEffect(()=>{t?m.reset({...St,...t}):m.reset(St)},[t,m]);const o=new Pa({html:!0}),[c,h]=u.useState();async function _(){bt().then(({data:S})=>{h(S)})}u.useEffect(()=>{s&&_()},[s]);const E=S=>{if(isNaN(S))return;const w=Object.entries(kt).reduce((b,[k,p])=>{const v=S*p.months*p.discount;return{...b,[k]:v.toFixed(2)}},{});m.setValue("prices",w,{shouldDirty:!0})},C=()=>{n(!1),r(null),m.reset(St)};return e.jsx(be,{open:s,onOpenChange:C,children:e.jsxs(fe,{children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Te,{})]}),e.jsxs(_e,{...m,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:m.control,name:"name",render:({field:S})=>e.jsxs(f,{children:[e.jsx(j,{children:d("plan.form.name.label")}),e.jsx(y,{children:e.jsx(T,{placeholder:d("plan.form.name.placeholder"),...S})}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"group_id",render:({field:S})=>e.jsxs(f,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(ta,{dialogTrigger:e.jsx(P,{variant:"link",children:d("plan.form.group.add")}),refetch:_})]}),e.jsxs(G,{value:S.value?.toString()??"",onValueChange:w=>S.onChange(w?Number(w):null),children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(B,{children:c?.map(w=>e.jsx(z,{value:w.id.toString(),children:w.name},w.id))})]}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"transfer_enable",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...S})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.transfer.unit")})]}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"speed_limit",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...S,value:S.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.speed.unit")})]}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:d("plan.form.price.title")}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(T,{type:"number",placeholder:d("plan.form.price.base_price"),className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:S=>{const w=parseFloat(S.target.value);E(w)}})]}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const S=Object.keys(kt).reduce((w,b)=>({...w,[b]:""}),{});m.setValue("prices",S,{shouldDirty:!0})},children:d("plan.form.price.clear.button")})}),e.jsx(ce,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:d("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(kt).filter(([S])=>!["onetime","reset_traffic"].includes(S)).map(([S,w])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(g,{control:m.control,name:`prices.${S}`,render:({field:b})=>e.jsxs(f,{children:[e.jsxs(j,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${S}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",w.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:w.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:"0.00",min:0,...b,value:b.value??"",onChange:k=>b.onChange(k.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},S))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(kt).filter(([S])=>["onetime","reset_traffic"].includes(S)).map(([S,w])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(g,{control:m.control,name:`prices.${S}`,render:({field:b})=>e.jsx(f,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(j,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${S}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(S==="onetime"?"plan.form.price.onetime_desc":"plan.form.price.reset_desc")})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:"0.00",min:0,...b,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},S))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(g,{control:m.control,name:"device_limit",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...S,value:S.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.device.unit")})]}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"capacity_limit",render:({field:S})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(T,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...S,value:S.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.capacity.unit")})]}),e.jsx(D,{})]})})]}),e.jsx(g,{control:m.control,name:"reset_traffic_method",render:({field:S})=>e.jsxs(f,{children:[e.jsx(j,{children:d("plan.form.reset_method.label")}),e.jsxs(G,{value:S.value?.toString()??"null",onValueChange:w=>S.onChange(w=="null"?null:Number(w)),children:[e.jsx(y,{children:e.jsx(K,{children:e.jsx(W,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(B,{children:$x.map(w=>e.jsx(z,{value:w.value?.toString()??"null",children:d(`plan.form.reset_method.options.${w.label}`)},w.value))})]}),e.jsx(F,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:m.control,name:"content",render:({field:S})=>{const[w,b]=u.useState(!1);return e.jsxs(f,{className:"space-y-2",children:[e.jsxs(j,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d("plan.form.content.label"),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(!w),children:w?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(ce,{side:"top",children:e.jsx("p",{className:"text-xs",children:d(w?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(ve,{children:e.jsxs(he,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{S.onChange(d("plan.form.content.template.content"))},children:d("plan.form.content.template.button")})}),e.jsx(ce,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:d("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${w?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(y,{children:e.jsx(Ea,{style:{height:"400px"},value:S.value||"",renderHTML:k=>o.render(k),onChange:({text:k})=>S.onChange(k),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:d("plan.form.content.placeholder"),className:"rounded-md border"})})}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:d("plan.form.content.preview")}),e.jsx("div",{className:"prose prose-sm dark:prose-invert h-[400px] max-w-none overflow-y-auto rounded-md border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:o.render(S.value||"")}})})]})]}),e.jsx(F,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(D,{})]})}})]}),e.jsx(ze,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:t&&e.jsx(g,{control:m.control,name:"force_update",render:({field:S})=>e.jsxs(f,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(y,{children:e.jsx(sl,{checked:S.value,onCheckedChange:S.onChange})}),e.jsx("div",{className:"",children:e.jsx(j,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(P,{type:"button",variant:"outline",onClick:C,children:d("plan.form.submit.cancel")}),e.jsx(P,{type:"submit",disabled:i,onClick:()=>{m.handleSubmit(async S=>{l(!0),(await Zc(S)).data&&(A.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),C(),a()),l(!1)})()},children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function Hx(){const[s,n]=u.useState({}),[t,r]=u.useState({"drag-handle":!1}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState(!1),[c,h]=u.useState({pageSize:20,pageIndex:0}),[_,E]=u.useState([]),{refetch:C}=re({queryKey:["planList"],queryFn:async()=>{const{data:p}=await qs();return E(p),p}});u.useEffect(()=>{r({"drag-handle":m}),h({pageSize:m?99999:10,pageIndex:0})},[m]);const S=(p,v)=>{m&&(p.dataTransfer.setData("text/plain",v.toString()),p.currentTarget.classList.add("opacity-50"))},w=(p,v)=>{if(!m)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const M=parseInt(p.dataTransfer.getData("text/plain"));if(M===v)return;const H=[..._],[se]=H.splice(M,1);H.splice(v,0,se),E(H)},b=async()=>{if(!m){o(!0);return}const p=_?.map(v=>v.id);sd(p).then(()=>{A.success("排序保存成功"),o(!1),C()}).finally(()=>{o(!1)})},k=ns({data:_||[],columns:zx(C),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:c},enableRowSelection:!0,onPaginationChange:h,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}},pageCount:m?1:void 0});return e.jsx(Ox,{refreshData:C,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(hs,{table:k,toolbar:p=>e.jsx(Lx,{table:p,refetch:C,saveOrder:b,isSortMode:m}),draggable:m,onDragStart:S,onDragEnd:p=>p.currentTarget.classList.remove("opacity-50"),onDragOver:p=>{p.preventDefault(),p.currentTarget.classList.add("bg-muted")},onDragLeave:p=>p.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!m}),e.jsx(Ux,{})]})})}function qx(){const{t:s}=V("subscribe");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("plan.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("plan.page.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(Hx,{})})]})]})}const Kx=Object.freeze(Object.defineProperty({__proto__:null,default:qx},Symbol.toStringTag,{value:"Module"})),Js=[{value:ae.PENDING,label:ot[ae.PENDING],icon:Ko,color:ct[ae.PENDING]},{value:ae.PROCESSING,label:ot[ae.PROCESSING],icon:xr,color:ct[ae.PROCESSING]},{value:ae.COMPLETED,label:ot[ae.COMPLETED],icon:ja,color:ct[ae.COMPLETED]},{value:ae.CANCELLED,label:ot[ae.CANCELLED],icon:hr,color:ct[ae.CANCELLED]},{value:ae.DISCOUNTED,label:ot[ae.DISCOUNTED],icon:ja,color:ct[ae.DISCOUNTED]}],ut=[{value:xe.PENDING,label:Nt[xe.PENDING],icon:Bo,color:_t[xe.PENDING]},{value:xe.PROCESSING,label:Nt[xe.PROCESSING],icon:xr,color:_t[xe.PROCESSING]},{value:xe.VALID,label:Nt[xe.VALID],icon:ja,color:_t[xe.VALID]},{value:xe.INVALID,label:Nt[xe.INVALID],icon:hr,color:_t[xe.INVALID]}];function Tt({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=s?.getFilterValue(),i=Array.isArray(a)?new Set(a):a!==void 0?new Set([a]):new Set;return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:i.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:i.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[i.size," selected"]}):t.filter(l=>i.has(l.value)).map(l=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:l.label},l.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(Me,{onSelect:()=>{const m=new Set(i);d?m.delete(l.value):m.add(l.value);const o=Array.from(m);s?.setFilterValue(o.length?o:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),l.icon&&e.jsx(l.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${l.color}`}),e.jsx("span",{children:l.label}),r?.get(l.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(l.value)})]},l.value)})}),i.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Bx=x.object({email:x.string().min(1),plan_id:x.number(),period:x.string(),total_amount:x.number()}),Gx={email:"",plan_id:0,total_amount:0,period:""};function tl({refetch:s,trigger:n,defaultValues:t}){const{t:r}=V("order"),[a,i]=u.useState(!1),l=ge({resolver:Ne(Bx),defaultValues:{...Gx,...t},mode:"onChange"}),[d,m]=u.useState([]);return u.useEffect(()=>{a&&qs().then(({data:o})=>{m(o)})},[a]),e.jsxs(be,{open:a,onOpenChange:i,children:[e.jsx(Je,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:r("dialog.addOrder")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:r("dialog.assignOrder")}),e.jsx(Te,{})]}),e.jsxs(_e,{...l,children:[e.jsx(g,{control:l.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.userEmail")}),e.jsx(y,{children:e.jsx(T,{placeholder:r("dialog.placeholders.email"),...o})})]})}),e.jsx(g,{control:l.control,name:"plan_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(y,{children:e.jsxs(G,{value:o.value?o.value?.toString():void 0,onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(B,{children:d.map(c=>e.jsx(z,{value:c.id.toString(),children:c.name},c.id))})]})})]})}),e.jsx(g,{control:l.control,name:"period",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.orderPeriod")}),e.jsx(y,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(K,{children:e.jsx(W,{placeholder:r("dialog.placeholders.period")})}),e.jsx(B,{children:Object.keys(gu).map(c=>e.jsx(z,{value:c,children:r(`period.${c}`)},c))})]})})]})}),e.jsx(g,{control:l.control,name:"total_amount",render:({field:o})=>e.jsxs(f,{children:[e.jsx(j,{children:r("dialog.fields.paymentAmount")}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:r("dialog.placeholders.amount"),value:o.value/100,onChange:c=>o.onChange(parseFloat(c.currentTarget.value)*100)})}),e.jsx(D,{})]})}),e.jsxs(ze,{children:[e.jsx(P,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(P,{type:"submit",onClick:()=>{l.handleSubmit(o=>{ld(o).then(({data:c})=>{c&&(s&&s(),l.reset(),i(!1),A.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function Wx({table:s,refetch:n}){const{t}=V("order"),r=s.getState().columnFilters.length>0,a=Object.values(os).filter(m=>typeof m=="number").map(m=>({label:t(`type.${os[m]}`),value:m,color:m===os.NEW?"green-500":m===os.RENEWAL?"blue-500":m===os.UPGRADE?"purple-500":"orange-500"})),i=Object.values(Pe).map(m=>({label:t(`period.${m}`),value:m,color:m===Pe.MONTH_PRICE?"slate-500":m===Pe.QUARTER_PRICE?"cyan-500":m===Pe.HALF_YEAR_PRICE?"indigo-500":m===Pe.YEAR_PRICE?"violet-500":m===Pe.TWO_YEAR_PRICE?"fuchsia-500":m===Pe.THREE_YEAR_PRICE?"pink-500":m===Pe.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(ae).filter(m=>typeof m=="number").map(m=>({label:t(`status.${ae[m]}`),value:m,icon:m===ae.PENDING?Js[0].icon:m===ae.PROCESSING?Js[1].icon:m===ae.COMPLETED?Js[2].icon:m===ae.CANCELLED?Js[3].icon:Js[4].icon,color:m===ae.PENDING?"yellow-500":m===ae.PROCESSING?"blue-500":m===ae.COMPLETED?"green-500":m===ae.CANCELLED?"red-500":"green-500"})),d=Object.values(xe).filter(m=>typeof m=="number").map(m=>({label:t(`commission.${xe[m]}`),value:m,icon:m===xe.PENDING?ut[0].icon:m===xe.PROCESSING?ut[1].icon:m===xe.VALID?ut[2].icon:ut[3].icon,color:m===xe.PENDING?"yellow-500":m===xe.PROCESSING?"blue-500":m===xe.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tl,{refetch:n}),e.jsx(T,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:m=>s.getColumn("trade_no")?.setFilterValue(m.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2",children:[s.getColumn("type")&&e.jsx(Tt,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(Tt,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(Tt,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(Tt,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})}function ls({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:N("flex items-center py-1.5",t),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:N("text-sm",r),children:n||"-"})]})}function Yx({status:s}){const{t:n}=V("order"),t={[ae.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[ae.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[ae.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[ae.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[ae.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(q,{variant:"secondary",className:N("font-medium",t[s]),children:n(`status.${ae[s]}`)})}function Qx({id:s,trigger:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(),{t:l}=V("order");return u.useEffect(()=>{(async()=>{if(t){const{data:m}=await ad({id:s});i(m)}})()},[t,s]),e.jsxs(be,{onOpenChange:r,open:t,children:[e.jsx(Je,{asChild:!0,children:n}),e.jsxs(fe,{className:"max-w-xl",children:[e.jsxs(Ce,{className:"space-y-2",children:[e.jsx(ye,{className:"text-lg font-medium",children:l("dialog.title")}),e.jsx("div",{className:"flex items-center justify-between text-sm",children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-muted-foreground",children:[l("table.columns.tradeNo"),":",a?.trade_no]}),a?.status&&e.jsx(Yx,{status:a.status})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ls,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Us,{to:`/user/manage?email=${a.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.user.email,e.jsx(pr,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(ls,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(ls,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(ls,{label:l("dialog.fields.callbackNo"),value:a?.callback_no,valueClassName:"font-mono text-xs"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ls,{label:l("dialog.fields.paymentAmount"),value:Ls(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(ke,{className:"my-2"}),e.jsx(ls,{label:l("dialog.fields.balancePayment"),value:Ls(a?.balance_amount||0)}),e.jsx(ls,{label:l("dialog.fields.discountAmount"),value:Ls(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(ls,{label:l("dialog.fields.refundAmount"),value:Ls(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(ls,{label:l("dialog.fields.deductionAmount"),value:Ls(a?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ls,{label:l("dialog.fields.createdAt"),value:we(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(ls,{label:l("dialog.fields.updatedAt"),value:we(a?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const Jx={[os.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[os.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[os.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[os.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Xx={[Pe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Pe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Zx=s=>ae[s],eh=s=>xe[s],sh=s=>os[s],th=s=>{const{t:n}=V("order");return[{accessorKey:"trade_no",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.tradeNo")}),cell:({row:t})=>{const r=t.original.trade_no,a=r.length>6?`${r.slice(0,3)}...${r.slice(-3)}`:r;return e.jsx("div",{className:"flex items-center",children:e.jsx(Qx,{trigger:e.jsxs(J,{variant:"ghost",size:"sm",className:"flex h-8 items-center gap-1.5 px-2 font-medium text-primary transition-colors hover:bg-primary/10 hover:text-primary/80",children:[e.jsx("span",{className:"font-mono",children:a}),e.jsx(pr,{className:"h-3.5 w-3.5 opacity-70"})]}),id:t.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>{const r=t.getValue("type"),a=Jx[r];return e.jsx(q,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",a.color,a.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${sh(r)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.plan")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium text-foreground/90 sm:max-w-72 md:max-w-[31rem]",children:t.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.period")}),cell:({row:t})=>{const r=t.getValue("period"),a=Xx[r];return e.jsx(q,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",a?.color,a?.bgColor,"hover:bg-opacity-80"),children:n(`period.${r}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.amount")}),cell:({row:t})=>{const r=t.getValue("total_amount"),a=typeof r=="number"?(r/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",a]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:t})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:t,title:n("table.columns.status")}),e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx(Gr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(ce,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:t})=>{const r=Js.find(a=>a.value===t.getValue("status"));return r?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.icon&&e.jsx(r.icon,{className:`h-4 w-4 text-${r.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${Zx(r.value)}`)})]}),r.value===ae.PENDING&&e.jsxs(Ss,{modal:!0,children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Vt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(fs,{align:"end",className:"w-[140px]",children:[e.jsx(je,{className:"cursor-pointer",onClick:async()=>{await nd({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await rd({trade_no:t.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commission")}),cell:({row:t})=>{const r=t.getValue("commission_balance"),a=r?(r/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:r?`¥${a}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commissionStatus")}),cell:({row:t})=>{const r=t.original.status,a=t.original.commission_balance,i=ut.find(l=>l.value===t.getValue("commission_status"));return a==0||!i?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i.icon&&e.jsx(i.icon,{className:`h-4 w-4 text-${i.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${eh(i.value)}`)})]}),i.value===xe.PENDING&&r===ae.COMPLETED&&e.jsxs(Ss,{modal:!0,children:[e.jsx(ks,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Vt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(fs,{align:"end",className:"w-[120px]",children:[e.jsx(je,{className:"cursor-pointer",onClick:async()=>{await an({trade_no:t.original.trade_no,commission_status:xe.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await an({trade_no:t.original.trade_no,commission_status:xe.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.createdAt")}),cell:({row:t})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:we(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function ah(){const[s]=fr(),[n,t]=u.useState({}),[r,a]=u.useState({}),[i,l]=u.useState([]),[d,m]=u.useState([]),[o,c]=u.useState({pageIndex:0,pageSize:20});u.useEffect(()=>{const w=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([b,k])=>{const p=s.get(b);return p?{id:b,value:k==="number"?parseInt(p):p}:null}).filter(Boolean);w.length>0&&l(w)},[s]);const{refetch:h,data:_,isLoading:E}=re({queryKey:["orderList",o,i,d],queryFn:()=>td({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),C=ns({data:_?.data??[],columns:th(h),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:o},rowCount:_?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:m,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),onPaginationChange:c,getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(hs,{table:C,toolbar:e.jsx(Wx,{table:C,refetch:h}),showPagination:!0})}function nh(){const{t:s}=V("order");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",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({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(Me,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx($s,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const ih=x.object({id:x.coerce.number().nullable().optional(),name:x.string().min(1,"请输入优惠券名称"),code:x.string().nullable(),type:x.coerce.number(),value:x.coerce.number(),started_at:x.coerce.number(),ended_at:x.coerce.number(),limit_use:x.union([x.string(),x.number()]).nullable(),limit_use_with_user:x.union([x.string(),x.number()]).nullable(),generate_count:x.coerce.number().nullable().optional(),limit_plan_ids:x.array(x.coerce.number()).default([]).nullable(),limit_period:x.array(x.nativeEnum(xt)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),xn={name:"",code:null,type:Be.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:null,limit_use_with_user:null,limit_plan_ids:[],limit_period:[],generate_count:null};function al({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=V("coupon"),[d,m]=u.useState(!1),o=a??d,c=i??m,[h,_]=u.useState([]),E=ge({resolver:Ne(ih),defaultValues:s||xn});u.useEffect(()=>{s&&E.reset(s)},[s,E]),u.useEffect(()=>{qs().then(({data:b})=>_(b))},[]);const C=b=>{if(!b)return;const k=(p,v)=>{const M=new Date(v*1e3);return p.setHours(M.getHours(),M.getMinutes(),M.getSeconds()),Math.floor(p.getTime()/1e3)};b.from&&E.setValue("started_at",k(b.from,E.watch("started_at"))),b.to&&E.setValue("ended_at",k(b.to,E.watch("ended_at")))},S=async b=>{const k=await od(b);if(b.generate_count&&k){const p=new Blob([k],{type:"text/csv;charset=utf-8;"}),v=document.createElement("a");v.href=window.URL.createObjectURL(p),v.download=`coupons_${new Date().getTime()}.csv`,v.click(),window.URL.revokeObjectURL(v.href)}c(!1),t==="create"&&E.reset(xn),n()},w=(b,k)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:k}),e.jsx(T,{type:"datetime-local",step:"1",value:we(E.watch(b),"YYYY-MM-DDTHH:mm:ss"),onChange:p=>{const v=new Date(p.target.value);E.setValue(b,Math.floor(v.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(be,{open:o,onOpenChange:c,children:[r&&e.jsx(Je,{asChild:!0,children:r}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(_e,{...E,children:e.jsxs("form",{onSubmit:E.handleSubmit(S),className:"space-y-4",children:[e.jsx(g,{control:E.control,name:"name",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.name.label")}),e.jsx(T,{placeholder:l("form.name.placeholder"),...b}),e.jsx(D,{})]})}),t==="create"&&e.jsx(g,{control:E.control,name:"generate_count",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.generateCount.label")}),e.jsx(T,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...b,value:b.value===void 0?"":b.value,onChange:k=>b.onChange(k.target.value===""?"":parseInt(k.target.value)),className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(D,{})]})}),(!E.watch("generate_count")||E.watch("generate_count")==null)&&e.jsx(g,{control:E.control,name:"code",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.code.label")}),e.jsx(T,{placeholder:l("form.code.placeholder"),...b,className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.code.description")}),e.jsx(D,{})]})}),e.jsxs(f,{children:[e.jsx(j,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(g,{control:E.control,name:"type",render:({field:b})=>e.jsxs(G,{value:b.value.toString(),onValueChange:k=>{const p=b.value,v=parseInt(k);b.onChange(v);const M=E.getValues("value");M&&(p===Be.AMOUNT&&v===Be.PERCENTAGE?E.setValue("value",M/100):p===Be.PERCENTAGE&&v===Be.AMOUNT&&E.setValue("value",M*100))},children:[e.jsx(K,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(W,{placeholder:l("form.type.placeholder")})}),e.jsx(B,{children:Object.entries(ju).map(([k,p])=>e.jsx(z,{value:k,children:l(`table.toolbar.types.${k}`)},k))})]})}),e.jsx(g,{control:E.control,name:"value",render:({field:b})=>{const k=b.value==null?"":E.watch("type")===Be.AMOUNT&&typeof b.value=="number"?(b.value/100).toString():b.value.toString();return e.jsx(T,{type:"number",placeholder:l("form.value.placeholder"),...b,value:k,onChange:p=>{const v=p.target.value;if(v===""){b.onChange("");return}const M=parseFloat(v);isNaN(M)||b.onChange(E.watch("type")===Be.AMOUNT?Math.round(M*100):M)},step:"any",min:0,className:"flex-[2] rounded-none border-x-0 text-left"})}}),e.jsx("div",{className:"flex min-w-[40px] items-center justify-center rounded-md rounded-l-none border border-l-0 border-input bg-muted/50 px-3 font-medium text-muted-foreground",children:e.jsx("span",{children:E.watch("type")==Be.AMOUNT?"¥":"%"})})]})]}),e.jsxs(f,{children:[e.jsx(j,{children:l("form.validity.label")}),e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",className:N("w-full justify-start text-left font-normal",!E.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(jt,{className:"mr-2 h-4 w-4"}),we(E.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",we(E.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(xs,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(Gs,{mode:"range",selected:{from:new Date(E.watch("started_at")*1e3),to:new Date(E.watch("ended_at")*1e3)},onSelect:C,numberOfMonths:2})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-4",children:[w("started_at",l("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:l("form.validity.to")}),w("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(D,{})]}),e.jsx(g,{control:E.control,name:"limit_use",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitUse.label")}),e.jsx(T,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...b,value:b.value===null?"":b.value,onChange:k=>b.onChange(k.target.value===""?null:parseInt(k.target.value)),className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:E.control,name:"limit_use_with_user",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitUseWithUser.label")}),e.jsx(T,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...b,value:b.value===null?"":b.value,onChange:k=>b.onChange(k.target.value===""?null:parseInt(k.target.value)),className:"h-9"}),e.jsx(F,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:E.control,name:"limit_period",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitPeriod.label")}),e.jsx(at,{options:Object.entries(xt).filter(([k])=>isNaN(Number(k))).map(([k,p])=>({label:l(`coupon:period.${p}`),value:k})),onChange:k=>{if(k.length===0){b.onChange([]);return}const p=k.map(v=>xt[v.value]);b.onChange(p)},value:(b.value||[]).map(k=>({label:l(`coupon:period.${k}`),value:Object.entries(xt).find(([p,v])=>v===k)?.[0]||""})),placeholder:l("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPeriod.empty")})}),e.jsx(F,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(D,{})]})}),e.jsx(g,{control:E.control,name:"limit_plan_ids",render:({field:b})=>e.jsxs(f,{children:[e.jsx(j,{children:l("form.limitPlan.label")}),e.jsx(at,{options:h?.map(k=>({label:k.name,value:k.id.toString()}))||[],onChange:k=>b.onChange(k.map(p=>Number(p.value))),value:(h||[]).filter(k=>(b.value||[]).includes(k.id)).map(k=>({label:k.name,value:k.id.toString()})),placeholder:l("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPlan.empty")})}),e.jsx(D,{})]})}),e.jsx(ze,{children:e.jsx(P,{type:"submit",disabled:E.formState.isSubmitting,children:E.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function oh({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(al,{refetch:n,dialogTrigger:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:r("form.add")})]})}),e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(lh,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:Be.AMOUNT,label:r(`table.toolbar.types.${Be.AMOUNT}`)},{value:Be.PERCENTAGE,label:r(`table.toolbar.types.${Be.PERCENTAGE}`)}]}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]})]})}const nl=u.createContext(void 0);function ch({children:s,refetch:n}){const[t,r]=u.useState(!1),[a,i]=u.useState(null),l=m=>{i(m),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(nl.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(al,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function dh(){const s=u.useContext(nl);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const uh=s=>{const{t:n}=V("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(q,{children:t.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx(Y,{defaultChecked:t.original.show,onCheckedChange:r=>{dd({id:t.original.id,show:r}).then(({data:a})=>!a&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:n(`table.toolbar.types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.code")}),cell:({row:t})=>e.jsx(q,{variant:"secondary",children:t.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUse")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:t.original.limit_use===null?n("table.validity.unlimited"):t.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUseWithUser")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:t.original.limit_use_with_user===null?n("table.validity.noLimit"):t.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.validity")}),cell:({row:t})=>{const[r,a]=u.useState(!1),i=Date.now(),l=t.original.started_at*1e3,d=t.original.ended_at*1e3,m=i>d,o=ie.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=dh();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(Hs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(Qe,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{cd({id:t.original.id}).then(({data:a})=>{a&&(A.success("删除成功"),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete")})]})})]})}}]};function mh(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([]),[l,d]=u.useState([]),[m,o]=u.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=re({queryKey:["couponList",m,a,l],queryFn:()=>id({pageSize:m.pageSize,current:m.pageIndex+1,filter:a,sort:l})}),_=ns({data:h?.data??[],columns:uh(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:m},pageCount:Math.ceil((h?.total??0)/m.pageSize),rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:o,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ch,{refetch:c,children:e.jsx("div",{className:"space-y-4",children:e.jsx(hs,{table:_,toolbar:e.jsx(oh,{table:_,refetch:c})})})})}function xh(){const{t:s}=V("coupon");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",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(mh,{})})]})]})}const hh=Object.freeze(Object.defineProperty({__proto__:null,default:xh},Symbol.toStringTag,{value:"Module"})),ph=1,fh=1e6;let ua=0;function gh(){return ua=(ua+1)%Number.MAX_SAFE_INTEGER,ua.toString()}const ma=new Map,hn=s=>{if(ma.has(s))return;const n=setTimeout(()=>{ma.delete(s),ht({type:"REMOVE_TOAST",toastId:s})},fh);ma.set(s,n)},jh=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,ph)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(t=>t.id===n.toast.id?{...t,...n.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=n;return t?hn(t):s.toasts.forEach(r=>{hn(r.id)}),{...s,toasts:s.toasts.map(r=>r.id===t||t===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return n.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(t=>t.id!==n.toastId)}}},Pt=[];let Et={toasts:[]};function ht(s){Et=jh(Et,s),Pt.forEach(n=>{n(Et)})}function vh({...s}){const n=gh(),t=a=>ht({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>ht({type:"DISMISS_TOAST",toastId:n});return ht({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function rl(){const[s,n]=u.useState(Et);return u.useEffect(()=>(Pt.push(n),()=>{const t=Pt.indexOf(n);t>-1&&Pt.splice(t,1)}),[s]),{...s,toast:vh,dismiss:t=>ht({type:"DISMISS_TOAST",toastId:t})}}function bh({open:s,onOpenChange:n,table:t}){const{t:r}=V("user"),{toast:a}=rl(),[i,l]=u.useState(!1),[d,m]=u.useState(""),[o,c]=u.useState(""),h=async()=>{if(!d||!o){a({title:r("messages.error"),description:r("messages.send_mail.required_fields"),variant:"destructive"});return}try{l(!0),await Ot.sendMail({subject:d,content:o,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),a({title:r("messages.success"),description:r("messages.send_mail.success")}),n(!1),m(""),c("")}catch{a({title:r("messages.error"),description:r("messages.send_mail.failed"),variant:"destructive"})}finally{l(!1)}};return e.jsx(be,{open:s,onOpenChange:n,children:e.jsxs(fe,{className:"sm:max-w-[500px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:r("send_mail.title")}),e.jsx(Te,{children:r("send_mail.description")})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"subject",className:"text-right",children:r("send_mail.subject")}),e.jsx(T,{id:"subject",value:d,onChange:_=>m(_.target.value),className:"col-span-3"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"content",className:"text-right",children:r("send_mail.content")}),e.jsx(ys,{id:"content",value:o,onChange:_=>c(_.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(ze,{children:e.jsx(J,{type:"submit",onClick:h,disabled:i,children:r(i?"send_mail.sending":"send_mail.send")})})]})})}const yh=x.object({email_prefix:x.string().optional(),email_suffix:x.string().min(1),password:x.string().optional(),expired_at:x.number().optional().nullable(),plan_id:x.number().nullable(),generate_count:x.number().optional().nullable()}).refine(s=>s.generate_count===null?s.email_prefix!==void 0&&s.email_prefix!=="":!0,{message:"Email prefix is required when generate_count is null",path:["email_prefix"]}),Nh={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function _h({refetch:s}){const{t:n}=V("user"),[t,r]=u.useState(!1),a=ge({resolver:Ne(yh),defaultValues:Nh,mode:"onChange"}),[i,l]=u.useState([]);return u.useEffect(()=>{t&&qs().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(be,{open:t,onOpenChange:r,children:[e.jsx(Je,{asChild:!0,children:e.jsxs(J,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(Ve,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(fe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ce,{children:[e.jsx(ye,{children:n("generate.title")}),e.jsx(Te,{})]}),e.jsxs(_e,{...a,children:[e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(g,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(T,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...d})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${a.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(g,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(T,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(g,{control:a.control,name:"password",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.password")}),e.jsx(T,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(D,{})]})}),e.jsx(g,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(j,{children:n("generate.form.expire_time")}),e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsx(y,{children:e.jsxs(J,{variant:"outline",className:N("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?we(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(jt,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(xs,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Wo,{asChild:!0,children:e.jsx(J,{variant:"outline",className:"w-full",onClick:()=>{d.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Gs,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:m=>{m&&d.onChange(m?.getTime()/1e3)}})})]})]})]})}),e.jsx(g,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.subscription")}),e.jsx(y,{children:e.jsxs(G,{value:d.value?d.value.toString():"null",onValueChange:m=>d.onChange(m==="null"?null:parseInt(m)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(z,{value:"null",children:n("generate.form.subscription_none")}),i.map(m=>e.jsx(z,{value:m.id.toString(),children:m.name},m.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(g,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(f,{children:[e.jsx(j,{children:n("generate.form.generate_count")}),e.jsx(T,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:d.value||"",onChange:m=>d.onChange(m.target.value?parseInt(m.target.value):null)})]})})]}),e.jsxs(ze,{children:[e.jsx(J,{variant:"outline",onClick:()=>r(!1),children:n("generate.form.cancel")}),e.jsx(J,{onClick:()=>a.handleSubmit(d=>{hd(d).then(({data:m})=>{m&&(A.success(n("generate.form.success")),a.reset(),s(),r(!1))})})(),children:n("generate.form.submit")})]})]})]})}const ll=Nn,wh=_n,Ch=wn,il=u.forwardRef(({className:s,...n},t)=>e.jsx(zt,{className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));il.displayName=zt.displayName;const Sh=As("fixed overflow-y-scroll z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-md",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-md"}},defaultVariants:{side:"right"}}),Aa=u.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(Ch,{children:[e.jsx(il,{}),e.jsxs(At,{ref:a,className:N(Sh({side:s}),n),...r,children:[e.jsxs(Ca,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(ss,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));Aa.displayName=At.displayName;const $a=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});$a.displayName="SheetHeader";const ol=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});ol.displayName="SheetFooter";const Ua=u.forwardRef(({className:s,...n},t)=>e.jsx($t,{ref:t,className:N("text-lg font-semibold text-foreground",s),...n}));Ua.displayName=$t.displayName;const Ha=u.forwardRef(({className:s,...n},t)=>e.jsx(Ut,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Ha.displayName=Ut.displayName;function kh({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=V("user"),{toast:i}=rl(),l=s.getState().columnFilters.length>0,[d,m]=u.useState([]),[o,c]=u.useState(!1),[h,_]=u.useState(!1),[E,C]=u.useState(!1),[S,w]=u.useState(!1),b=async()=>{try{const Q=await Ot.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),te=Q;console.log(Q);const $=new Blob([te],{type:"text/csv;charset=utf-8;"}),R=window.URL.createObjectURL($),X=document.createElement("a");X.href=R,X.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(X),X.click(),X.remove(),window.URL.revokeObjectURL(R),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},k=async()=>{try{w(!0),await Ot.batchBan({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),i({title:a("messages.success"),description:a("messages.batch_ban.success")}),n()}catch{i({title:a("messages.error"),description:a("messages.batch_ban.failed"),variant:"destructive"})}finally{w(!1),C(!1)}},p=[{label:a("filter.fields.email"),value:"email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.id"),value:"id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:a("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{label:a("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.token"),value:"token",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.banned"),value:"banned",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],options:[{label:a("filter.status.normal"),value:"0"},{label:a("filter.status.banned"),value:"1"}]},{label:a("filter.fields.remark"),value:"remarks",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.inviter_email"),value:"invite_user.email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]}],v=Q=>Q*1024*1024*1024,M=Q=>Q/(1024*1024*1024),H=()=>{m([...d,{field:"",operator:"",value:""}])},se=Q=>{m(d.filter((te,$)=>$!==Q))},L=(Q,te,$)=>{const R=[...d];if(R[Q]={...R[Q],[te]:$},te==="field"){const X=p.find(Ns=>Ns.value===$);X&&(R[Q].operator=X.operators[0].value,R[Q].value=X.type==="boolean"?!1:"")}m(R)},Z=(Q,te)=>{const $=p.find(R=>R.value===Q.field);if(!$)return null;switch($.type){case"text":return e.jsx(T,{placeholder:a("filter.sheet.value"),value:Q.value,onChange:R=>L(te,"value",R.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(T,{type:"number",placeholder:a("filter.sheet.value_number",{unit:$.unit}),value:$.unit==="GB"?M(Q.value||0):Q.value,onChange:R=>{const X=Number(R.target.value);L(te,"value",$.unit==="GB"?v(X):X)}}),$.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:$.unit})]});case"date":return e.jsx(Gs,{mode:"single",selected:Q.value,onSelect:R=>L(te,"value",R),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(G,{value:Q.value,onValueChange:R=>L(te,"value",R),children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("filter.sheet.value")})}),e.jsx(B,{children:$.useOptions?r.map(R=>e.jsx(z,{value:R.value.toString(),children:R.label},R.value)):$.options?.map(R=>e.jsx(z,{value:R.value.toString(),children:R.label},R.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Y,{checked:Q.value,onCheckedChange:R=>L(te,"value",R)}),e.jsx(Mt,{children:Q.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},de=()=>{const Q=d.filter(te=>te.field&&te.operator&&te.value!=="").map(te=>{const $=p.find(X=>X.value===te.field);let R=te.value;return te.operator==="contains"?{id:te.field,value:R}:($?.type==="date"&&R instanceof Date&&(R=Math.floor(R.getTime()/1e3)),$?.type==="boolean"&&(R=R?1:0),{id:te.field,value:`${te.operator}:${R}`})});s.setColumnFilters(Q),c(!1)};return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsx(_h,{refetch:n}),e.jsx(T,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:Q=>s.getColumn("email")?.setFilterValue(Q.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(ll,{open:o,onOpenChange:c,children:[e.jsx(wh,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Yo,{className:"mr-2 h-4 w-4"}),a("filter.advanced"),d.length>0&&e.jsx(q,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:d.length})]})}),e.jsxs(Aa,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs($a,{children:[e.jsx(Ua,{children:a("filter.sheet.title")}),e.jsx(Ha,{children:a("filter.sheet.description")})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:a("filter.sheet.conditions")}),e.jsx(P,{variant:"outline",size:"sm",onClick:H,children:a("filter.sheet.add")})]}),e.jsx(zs,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((Q,te)=>e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Mt,{children:a("filter.sheet.condition",{number:te+1})}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>se(te),children:e.jsx(ss,{className:"h-4 w-4"})})]}),e.jsxs(G,{value:Q.field,onValueChange:$=>L(te,"field",$),children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("filter.sheet.field")})}),e.jsx(B,{children:e.jsx(He,{children:p.map($=>e.jsx(z,{value:$.value,className:"cursor-pointer",children:$.label},$.value))})})]}),Q.field&&e.jsxs(G,{value:Q.operator,onValueChange:$=>L(te,"operator",$),children:[e.jsx(K,{children:e.jsx(W,{placeholder:a("filter.sheet.operator")})}),e.jsx(B,{children:p.find($=>$.value===Q.field)?.operators.map($=>e.jsx(z,{value:$.value,children:$.label},$.value))})]}),Q.field&&Q.operator&&Z(Q,te)]},te))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{variant:"outline",onClick:()=>{m([]),c(!1)},children:a("filter.sheet.reset")}),e.jsx(P,{onClick:de,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(P,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),m([])},className:"h-8 px-2 lg:px-3",children:[a("reset"),e.jsx(ss,{className:"ml-2 h-4 w-4"})]}),e.jsxs(Ss,{modal:!1,children:[e.jsx(ks,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(fs,{children:[e.jsx(je,{onClick:()=>_(!0),children:a("actions.send_email")}),e.jsx(je,{onClick:b,children:a("actions.export_csv")}),e.jsx(tt,{}),e.jsx(je,{onClick:()=>C(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(bh,{open:h,onOpenChange:_,table:s}),e.jsx(Oa,{open:E,onOpenChange:C,children:e.jsxs(Yt,{children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:a("actions.confirm_ban.title")}),e.jsx(Zt,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs(Jt,{children:[e.jsx(sa,{disabled:S,children:a("actions.confirm_ban.cancel")}),e.jsx(ea,{onClick:k,disabled:S,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(S?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const cl=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:"m17.71 11.29l-5-5a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21l-5 5a1 1 0 0 0 1.42 1.42L11 9.41V17a1 1 0 0 0 2 0V9.41l3.29 3.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42"})}),dl=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:"M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42"})}),Th=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:"M17 11H9.41l3.3-3.29a1 1 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l5 5a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L9.41 13H17a1 1 0 0 0 0-2"})}),Dh=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:"M17.92 11.62a1 1 0 0 0-.21-.33l-5-5a1 1 0 0 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l5-5a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76"})}),xa=[{accessorKey:"record_at",header:"时间",cell:({row:s})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("time",{className:"text-sm text-muted-foreground",children:xc(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(cl,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:ps(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(dl,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:ps(s.original.d)})]})},{accessorKey:"server_rate",header:"倍率",cell:({row:s})=>{const n=s.original.server_rate;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(q,{variant:"outline",className:"font-mono",children:[n,"x"]})})}},{id:"total",header:"总计",cell:({row:s})=>{const n=s.original.u+s.original.d;return e.jsx("div",{className:"flex items-center justify-end font-mono text-sm",children:ps(n)})}}];function ul({user_id:s,dialogTrigger:n}){const{t}=V(["traffic"]),[r,a]=u.useState(!1),[i,l]=u.useState({pageIndex:0,pageSize:20}),{data:d,isLoading:m}=re({queryKey:["userStats",s,i,r],queryFn:()=>r?pd({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),o=ns({data:d?.data??[],columns:xa,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:rs(),onPaginationChange:l});return e.jsxs(be,{open:r,onOpenChange:a,children:[e.jsx(Je,{asChild:!0,children:n}),e.jsxs(fe,{className:"sm:max-w-[700px]",children:[e.jsx(Ce,{children:e.jsx(ye,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ia,{children:[e.jsx(Va,{children:o.getHeaderGroups().map(c=>e.jsx(Is,{children:c.headers.map(h=>e.jsx(Fa,{className:N("h-10 px-2 text-xs",h.id==="total"&&"text-right"),children:h.isPlaceholder?null:Rt(h.column.columnDef.header,h.getContext())},h.id))},c.id))}),e.jsx(Ma,{children:m?Array.from({length:i.pageSize}).map((c,h)=>e.jsx(Is,{children:Array.from({length:xa.length}).map((_,E)=>e.jsx(Zs,{className:"p-2",children:e.jsx(oe,{className:"h-6 w-full"})},E))},h)):o.getRowModel().rows?.length?o.getRowModel().rows.map(c=>e.jsx(Is,{"data-state":c.getIsSelected()&&"selected",className:"h-10",children:c.getVisibleCells().map(h=>e.jsx(Zs,{className:"px-2",children:Rt(h.column.columnDef.cell,h.getContext())},h.id))},c.id)):e.jsx(Is,{children:e.jsx(Zs,{colSpan:xa.length,className:"h-24 text-center",children:t("trafficRecord.noRecords")})})})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:t("trafficRecord.perPage")}),e.jsxs(G,{value:`${o.getState().pagination.pageSize}`,onValueChange:c=>{o.setPageSize(Number(c))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:o.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50].map(c=>e.jsx(z,{value:`${c}`,children:c},c))})]}),e.jsx("p",{className:"text-sm font-medium",children:t("trafficRecord.records")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex w-[100px] items-center justify-center text-sm",children:t("trafficRecord.page",{current:o.getState().pagination.pageIndex+1,total:o.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||m,children:e.jsx(Th,{className:"h-4 w-4"})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||m,children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]})]})]})]})}function Ph({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Oa,{children:[e.jsx(Kr,{asChild:!0,children:n}),e.jsxs(Yt,{className:N("sm:max-w-[425px]",d),children:[e.jsxs(Qt,{children:[e.jsx(Xt,{children:t}),e.jsx(Zt,{children:r})]}),e.jsxs(Jt,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a})}),e.jsx(ea,{asChild:!0,children:e.jsx(P,{variant:l,onClick:s,children:i})})]})]})]})}const Eh=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:"M5 18h4.24a1 1 0 0 0 .71-.29l6.92-6.93L19.71 8a1 1 0 0 0 0-1.42l-4.24-4.29a1 1 0 0 0-1.42 0l-2.82 2.83l-6.94 6.93a1 1 0 0 0-.29.71V17a1 1 0 0 0 1 1m9.76-13.59l2.83 2.83l-1.42 1.42l-2.83-2.83ZM6 13.17l5.93-5.93l2.83 2.83L8.83 16H6ZM21 20H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2"})}),Rh=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:"M19 11h-6V5a1 1 0 0 0-2 0v6H5a1 1 0 0 0 0 2h6v6a1 1 0 0 0 2 0v-6h6a1 1 0 0 0 0-2"})}),Ih=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:"M21 8.94a1.3 1.3 0 0 0-.06-.27v-.09a1 1 0 0 0-.19-.28l-6-6a1 1 0 0 0-.28-.19a.3.3 0 0 0-.09 0a.9.9 0 0 0-.33-.11H10a3 3 0 0 0-3 3v1H6a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-1h1a3 3 0 0 0 3-3zm-6-3.53L17.59 8H16a1 1 0 0 1-1-1ZM15 19a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h1v7a3 3 0 0 0 3 3h5Zm4-4a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3v3a3 3 0 0 0 3 3h3Z"})}),Vh=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:"M21 11a1 1 0 0 0-1 1a8.05 8.05 0 1 1-2.22-5.5h-2.4a1 1 0 0 0 0 2h4.53a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v1.77A10 10 0 1 0 22 12a1 1 0 0 0-1-1"})}),Mh=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:"M9.5 10.5H12a1 1 0 0 0 0-2h-1V8a1 1 0 0 0-2 0v.55a2.5 2.5 0 0 0 .5 4.95h1a.5.5 0 0 1 0 1H8a1 1 0 0 0 0 2h1v.5a1 1 0 0 0 2 0v-.55a2.5 2.5 0 0 0-.5-4.95h-1a.5.5 0 0 1 0-1M21 12h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Z"})}),Fh=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:"M12.3 12.22A4.92 4.92 0 0 0 14 8.5a5 5 0 0 0-10 0a4.92 4.92 0 0 0 1.7 3.72A8 8 0 0 0 1 19.5a1 1 0 0 0 2 0a6 6 0 0 1 12 0a1 1 0 0 0 2 0a8 8 0 0 0-4.7-7.28M9 11.5a3 3 0 1 1 3-3a3 3 0 0 1-3 3m9.74.32A5 5 0 0 0 15 3.5a1 1 0 0 0 0 2a3 3 0 0 1 3 3a3 3 0 0 1-1.5 2.59a1 1 0 0 0-.5.84a1 1 0 0 0 .45.86l.39.26l.13.07a7 7 0 0 1 4 6.38a1 1 0 0 0 2 0a9 9 0 0 0-4.23-7.68"})}),Oh=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:"M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2m0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1"})}),Lh=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:"M20 6h-4V5a3 3 0 0 0-3-3h-2a3 3 0 0 0-3 3v1H4a1 1 0 0 0 0 2h1v11a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8h1a1 1 0 0 0 0-2M10 5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1h-4Zm7 14a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V8h10Z"})}),zh=(s,n,t,r)=>{const{t:a}=V("user");return[{accessorKey:"is_admin",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"is_staff",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.id")}),cell:({row:i})=>e.jsx(q,{variant:"outline",children:i.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.email")}),cell:({row:i})=>{const l=i.original.t||0,d=Date.now()/1e3-l<120,m=Math.floor(Date.now()/1e3-l);let o=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:we(l)});if(!d&&l!==0){const c=Math.floor(m/60),h=Math.floor(c/60),_=Math.floor(h/24);_>0?o+=` `+a("columns.online_status.offline_duration.days",{count:_}):h>0?o+=` `+a("columns.online_status.offline_duration.hours",{count:h}):c>0?o+=` `+a("columns.online_status.offline_duration.minutes",{count:c}):o+=` -`+a("columns.online_status.offline_duration.seconds",{count:m})}return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:N("size-2.5 rounded-full ring-2 ring-offset-2",d?"bg-green-500 ring-green-500/20":"bg-gray-300 ring-gray-300/20","transition-all duration-300")}),e.jsx("span",{className:"font-medium text-foreground/90",children:i.original.email})]})}),e.jsx(ce,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:o})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.online_count")}),cell:({row:i})=>{const l=i.original.device_limit,d=i.original.online_count||0;return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(q,{variant:"outline",className:N("min-w-[4rem] justify-center",l!==null&&d>=l?"border-destructive/50 bg-destructive/10 text-destructive":"border-primary/40 bg-primary/5 text-primary/90"),children:[d," / ",l===null?"∞":l]})})}),e.jsx(ce,{side:"bottom",children:e.jsx("p",{className:"text-sm",children:l===null?a("columns.device_limit.unlimited"):a("columns.device_limit.limited",{count:l})})})]})})},enableSorting:!0,enableHiding:!1},{accessorKey:"banned",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.status")}),cell:({row:i})=>{const l=i.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(q,{className:N("min-w-20 justify-center transition-colors",l?"bg-destructive/15 text-destructive hover:bg-destructive/25":"bg-success/15 text-success hover:bg-success/25"),children:a(l?"columns.status_text.banned":"columns.status_text.normal")})})},enableSorting:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l))},{accessorKey:"plan_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.subscription")}),cell:({row:i})=>e.jsx("div",{className:"min-w-[10em] break-all",children:i.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.group")}),cell:({row:i})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(q,{variant:"outline",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5 whitespace-nowrap"),children:i.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.used_traffic")}),cell:({row:i})=>{const l=ps(i.original?.total_used),d=ps(i.original?.transfer_enable),m=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{className:"w-full",children:e.jsxs("div",{className:"w-full space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:l}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:N("h-full rounded-full transition-all",m>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(m,100)}%`}})})]})}),e.jsx(ce,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",d]})})]})})}},{accessorKey:"transfer_enable",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.total_traffic")}),cell:({row:i})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:ps(i.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.expire_time")}),cell:({row:i})=>{const l=i.original.expired_at,d=Date.now()/1e3,m=l!=null&&le.jsx(O,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=Xs(i.original?.balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:l})]})}},{accessorKey:"commission_balance",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.commission")}),cell:({row:i})=>{const l=Xs(i.original?.commission_balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:l})]})}},{accessorKey:"created_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.register_time")}),cell:({row:i})=>e.jsx("div",{className:"truncate",children:we(i.original?.created_at)}),size:1e3},{id:"actions",header:({column:i})=>e.jsx(O,{column:i,className:"justify-end",title:a("columns.actions")}),cell:({row:i,table:l})=>e.jsxs(Ss,{modal:!0,children:[e.jsx(ks,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(J,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Vt,{className:"size-4"})})})}),e.jsxs(fs,{align:"end",className:"min-w-[40px]",children:[e.jsx(je,{onSelect:d=>{d.preventDefault(),t(i.original),r(!0)},className:"p-0",children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Ph,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(je,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(tl,{defaultValues:{email:i.original.email},trigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Eh,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(je,{onSelect:()=>{Ft(i.original.subscribe_url).then(()=>{A.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Rh,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(je,{onSelect:()=>{md({id:i.original.id}).then(({data:d})=>{d&&A.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Ih,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(je,{onSelect:()=>{},className:"p-0",children:e.jsxs(Us,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=${i.original?.id}`,children:[e.jsx(Vh,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(je,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Mh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(je,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(ul,{user_id:i.original?.id,dialogTrigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Fh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(je,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Dh,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:i.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:d}=await Ot.destroy(i.original.id);d&&(A.success(a("common:delete.success")),s())}catch{A.error(a("common:delete.failed"))}},children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5 text-destructive hover:text-destructive",children:[e.jsx(Oh,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},ml=u.createContext(void 0),qa=()=>{const s=u.useContext(ml);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},xl=({children:s,refreshData:n})=>{const[t,r]=u.useState(!1),[a,i]=u.useState(null),l={isOpen:t,setIsOpen:r,editingUser:a,setEditingUser:i,refreshData:n};return e.jsx(ml.Provider,{value:l,children:s})},zh=x.object({id:x.number(),email:x.string().email(),invite_user_email:x.string().email().nullable().optional(),password:x.string().optional().nullable(),balance:x.coerce.number(),commission_balance:x.coerce.number(),u:x.number(),d:x.number(),transfer_enable:x.number(),expired_at:x.number().nullable(),plan_id:x.number().nullable(),banned:x.number(),commission_type:x.number(),commission_rate:x.number().nullable(),discount:x.number().nullable(),speed_limit:x.number().nullable(),device_limit:x.number().nullable(),is_admin:x.number(),is_staff:x.number(),remarks:x.string().nullable()});function hl(){const{t:s}=V("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=qa(),[i,l]=u.useState(!1),[d,m]=u.useState([]),o=ge({resolver:Ne(zh),defaultValues:{id:0,email:"",invite_user_email:null,password:null,balance:0,commission_balance:0,u:0,d:0,transfer_enable:0,expired_at:null,plan_id:null,banned:0,commission_type:0,commission_rate:null,discount:null,speed_limit:null,device_limit:null,is_admin:0,is_staff:0,remarks:null}});return u.useEffect(()=>{n&&qs().then(({data:c})=>{m(c)})},[n]),u.useEffect(()=>{if(r){const c=r.invite_user?.email,{invite_user:h,..._}=r;o.reset({..._,invite_user_email:c||null,password:null})}},[r,o]),e.jsx(ll,{open:n,onOpenChange:t,children:e.jsxs(Aa,{className:"max-w-[90%] space-y-4",children:[e.jsxs($a,{children:[e.jsx(Ua,{children:s("edit.title")}),e.jsx(Ha,{})]}),e.jsxs(_e,{...o,children:[e.jsx(g,{control:o.control,name:"email",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.email")}),e.jsx(y,{children:e.jsx(T,{...c,placeholder:s("edit.form.email_placeholder")})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"invite_user_email",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.inviter_email")}),e.jsx(y,{children:e.jsx(T,{value:c.value||"",onChange:h=>c.onChange(h.target.value?h.target.value:null),placeholder:s("edit.form.inviter_email_placeholder")})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"password",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.password")}),e.jsx(y,{children:e.jsx(T,{type:"password",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.password_placeholder")})}),e.jsx(D,{...c})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(g,{control:o.control,name:"balance",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.balance")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"commission_balance",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.commission_balance")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"u",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.upload")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"d",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.download")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{...c})]})})]}),e.jsx(g,{control:o.control,name:"transfer_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.total_traffic")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"expired_at",render:({field:c})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(j,{children:s("edit.form.expire_time")}),e.jsxs(vs,{open:i,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsx(y,{children:e.jsxs(P,{type:"button",variant:"outline",className:N("w-full pl-3 text-left font-normal",!c.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[c.value?we(c.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(jt,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(xs,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:h=>{h.preventDefault()},onEscapeKeyDown:h=>{h.preventDefault()},children:e.jsxs("div",{className:"flex flex-col space-y-3 p-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{c.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+1),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+3),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Gs,{mode:"single",selected:c.value?new Date(c.value*1e3):void 0,onSelect:h=>{if(h){const _=new Date(c.value?c.value*1e3:Date.now());h.setHours(_.getHours(),_.getMinutes(),_.getSeconds()),c.onChange(Math.floor(h.getTime()/1e3))}},disabled:h=>h{const h=new Date;h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3))},className:"h-6 px-2 text-xs",children:s("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"datetime-local",step:"1",value:we(c.value,"YYYY-MM-DDTHH:mm:ss"),onChange:h=>{const _=new Date(h.target.value);isNaN(_.getTime())||c.onChange(Math.floor(_.getTime()/1e3))},className:"flex-1"}),e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"plan_id",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.subscription")}),e.jsx(y,{children:e.jsxs(G,{value:c.value!==null?String(c.value):"null",onValueChange:h=>c.onChange(h==="null"?null:parseInt(h)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(z,{value:"null",children:s("edit.form.subscription_none")}),d.map(h=>e.jsx(z,{value:String(h.id),children:h.name},h.id))]})]})})]})}),e.jsx(g,{control:o.control,name:"banned",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.account_status")}),e.jsx(y,{children:e.jsxs(G,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(K,{children:e.jsx(W,{})}),e.jsxs(B,{children:[e.jsx(z,{value:"1",children:s("columns.status_text.banned")}),e.jsx(z,{value:"0",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(g,{control:o.control,name:"commission_type",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.commission_type")}),e.jsx(y,{children:e.jsxs(G,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx(z,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx(z,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(g,{control:o.control,name:"commission_rate",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.commission_rate")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(g,{control:o.control,name:"discount",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.discount")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"speed_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.speed_limit")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"device_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.device_limit")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"is_admin",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:c.value===1,onCheckedChange:h=>c.onChange(h?1:0)})})})]})}),e.jsx(g,{control:o.control,name:"is_staff",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:c.value===1,onCheckedChange:h=>c.onChange(h?1:0)})})})]})}),e.jsx(g,{control:o.control,name:"remarks",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.remarks")}),e.jsx(y,{children:e.jsx(ys,{className:"h-24",value:c.value||"",onChange:h=>c.onChange(h.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(D,{})]})}),e.jsxs(ol,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(P,{type:"submit",onClick:()=>{o.handleSubmit(c=>{ud(c).then(({data:h})=>{h&&(A.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function Ah(){const[s]=fr(),[n,t]=u.useState({}),[r,a]=u.useState({is_admin:!1,is_staff:!1}),[i,l]=u.useState([]),[d,m]=u.useState([]),[o,c]=u.useState({pageIndex:0,pageSize:20});u.useEffect(()=>{const v=s.get("email");v&&l(M=>M.some(se=>se.id==="email")?M:[...M,{id:"email",value:v}])},[s]);const{refetch:h,data:_,isLoading:E}=re({queryKey:["userList",o,i,d],queryFn:()=>dd({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),[C,S]=u.useState([]),[w,b]=u.useState([]);u.useEffect(()=>{bt().then(({data:v})=>{S(v)}),qs().then(({data:v})=>{b(v)})},[]);const k=C.map(v=>({label:v.name,value:v.id})),p=w.map(v=>({label:v.name,value:v.id}));return e.jsxs(xl,{refreshData:h,children:[e.jsx($h,{data:_?.data??[],rowCount:_?.total??0,sorting:d,setSorting:m,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:o,setPagination:c,refetch:h,serverGroupList:C,permissionGroups:k,subscriptionPlans:p}),e.jsx(hl,{})]})}function $h({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:m,setColumnFilters:o,pagination:c,setPagination:h,refetch:_,serverGroupList:E,permissionGroups:C,subscriptionPlans:S}){const{setIsOpen:w,setEditingUser:b}=qa(),k=ns({data:s,columns:Lh(_,E,b,w),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:m,pagination:c},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:o,onColumnVisibilityChange:i,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),onPaginationChange:h,getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnVisibility:{commission_balance:!1,created_at:!1,is_admin:!1,is_staff:!1,permission_group:!1,plan_id:!1},columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Sh,{table:k,refetch:_,serverGroupList:E,permissionGroups:C,subscriptionPlans:S}),e.jsx(hs,{table:k})]})}function Uh(){const{t:s}=V("user");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",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("div",{className:"w-full",children:e.jsx(Ah,{})})})]})]})}const Hh=Object.freeze(Object.defineProperty({__proto__:null,default:Uh},Symbol.toStringTag,{value:"Module"}));function qh({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(J,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Yo,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):t.filter(a=>r.has(a.value)).map(a=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:a.label},`selected-${a.value}`))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(Me,{onSelect:()=>{i?r.delete(a.value):r.add(a.value);const l=Array.from(r);s?.setFilterValue(l.length?l:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",i?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Qo,{className:N("h-4 w-4")})}),a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:a.label})]},`option-${a.value}`)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Kh=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:"M19 11H5a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})});function Bh({table:s}){const{t:n}=V("ticket");return e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-4",children:[e.jsx(Gt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(vt,{className:"grid w-full grid-cols-2",children:[e.jsx(Ge,{value:"0",children:n("status.pending")}),e.jsx(Ge,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(qh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:Oe.LOW,icon:Kh,color:"gray"},{label:n("level.medium"),value:Oe.MIDDLE,icon:cl,color:"yellow"},{label:n("level.high"),value:Oe.HIGH,icon:dl,color:"red"}]})]})})}function Gh(){return e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[e.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}const Wh=As("flex gap-2 max-w-[60%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),pl=u.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:N(Wh({variant:n,layout:t,className:s}),"relative group"),ref:i,...a,children:u.Children.map(r,l=>u.isValidElement(l)&&typeof l.type!="string"?u.cloneElement(l,{variant:n,layout:t}):l)}));pl.displayName="ChatBubble";const Yh=As("p-4",{variants:{variant:{received:"bg-secondary text-secondary-foreground rounded-r-lg rounded-tl-lg",sent:"bg-primary text-primary-foreground rounded-l-lg rounded-tr-lg"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),fl=u.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:N(Yh({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...i,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(Gh,{})}):a}));fl.displayName="ChatBubbleMessage";const Qh=u.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:N("absolute top-1/2 -translate-y-1/2 flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",s==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",n),...r,children:t}));Qh.displayName="ChatBubbleActionWrapper";const gl=u.forwardRef(({className:s,...n},t)=>e.jsx(ys,{autoComplete:"off",ref:t,name:"message",className:N("max-h-12 px-4 py-3 bg-background text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-md flex items-center h-16 resize-none",s),...n}));gl.displayName="ChatInput";const jl=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:"m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"})}),vl=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.098 12.634L13 11.423V7a1 1 0 0 0-2 0v5a1 1 0 0 0 .5.866l2.598 1.5a1 1 0 1 0 1-1.732M12 2a10 10 0 1 0 10 10A10.01 10.01 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8.01 8.01 0 0 1-8 8"})}),pn=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 12l3.54-3.54a1 1 0 0 0 0-1.41a1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29a1 1 0 0 0 .71-.29a1 1 0 0 0 0-1.41Z"})}),Jh=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:"M21.71 20.29L18 16.61A9 9 0 1 0 16.61 18l3.68 3.68a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.39M11 18a7 7 0 1 1 7-7a7 7 0 0 1-7 7"})}),Xh=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:"M3.71 16.29a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21a1 1 0 0 0-.21.33a1 1 0 0 0 .21 1.09a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1 1 0 0 0 .21-1.09a1 1 0 0 0-.21-.33M7 8h14a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m-3.29 3.29a1 1 0 0 0-1.09-.21a1.2 1.2 0 0 0-.33.21a1 1 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1 1 0 0 0-.21-.33M21 11H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2M3.71 6.29a1 1 0 0 0-.33-.21a1 1 0 0 0-1.09.21a1.2 1.2 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a1 1 0 0 0 1.09-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1.2 1.2 0 0 0-.21-.33M21 16H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})}),Zh=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:"M9 12H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m-1-2h4a1 1 0 0 0 0-2H8a1 1 0 0 0 0 2m1 6H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m12-4h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Zm-6.44-2.83a.8.8 0 0 0-.18-.09a.6.6 0 0 0-.19-.06a1 1 0 0 0-.9.27A1.05 1.05 0 0 0 12 17a1 1 0 0 0 .07.38a1.2 1.2 0 0 0 .22.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21A1 1 0 0 0 14 17a1.05 1.05 0 0 0-.29-.71a2 2 0 0 0-.15-.12m.14-3.88a1 1 0 0 0-1.62.33A1 1 0 0 0 13 14a1 1 0 0 0 1-1a1 1 0 0 0-.08-.38a.9.9 0 0 0-.22-.33"})});function ep(){return e.jsxs("div",{className:"flex h-full flex-col space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{className:"h-8 w-3/4"}),e.jsx(oe,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(oe,{className:"h-20 w-2/3"},s))})]})}function sp(){return e.jsx("div",{className:"space-y-4 p-4",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{className:"h-5 w-4/5"}),e.jsx(oe,{className:"h-4 w-2/3"}),e.jsx(oe,{className:"h-3 w-1/2"})]},s))})}function tp({ticket:s,isActive:n,onClick:t}){const{t:r}=V("ticket"),a=i=>{switch(i){case Oe.HIGH:return"bg-red-50 text-red-600 border-red-200";case Oe.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case Oe.LOW:return"bg-green-50 text-green-600 border-green-200";default:return"bg-gray-50 text-gray-600 border-gray-200"}};return e.jsxs("div",{className:N("flex cursor-pointer flex-col border-b p-4 hover:bg-accent/50",n&&"bg-accent"),onClick:t,children:[e.jsxs("div",{className:"flex max-w-[280px] items-center justify-between gap-2",children:[e.jsx("h4",{className:"flex-1 truncate font-medium",children:s.subject}),e.jsx(q,{variant:s.status===Vs.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Vs.CLOSED?r("status.closed"):r("status.processing")})]}),e.jsx("div",{className:"mt-1 max-w-[280px] truncate text-sm text-muted-foreground",children:s.user?.email}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[e.jsx("time",{className:"text-muted-foreground",children:we(s.updated_at)}),e.jsx("div",{className:N("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===Oe.LOW?"low":s.level===Oe.MIDDLE?"medium":"high"}`)})]})]})}function ap({ticketId:s,dialogTrigger:n}){const{t}=V("ticket"),r=Ts(),a=u.useRef(null),i=u.useRef(null),[l,d]=u.useState(!1),[m,o]=u.useState(""),[c,h]=u.useState(!1),[_,E]=u.useState(s),[C,S]=u.useState(""),[w,b]=u.useState(!1),{setIsOpen:k,setEditingUser:p}=qa(),{data:v,isLoading:M,refetch:H}=re({queryKey:["tickets",l],queryFn:()=>l?la.getList({filter:[{id:"status",value:[Vs.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:se,refetch:L,isLoading:Z}=re({queryKey:["ticket",_,l],queryFn:()=>l?fd(_):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),de=se?.data,te=(v?.data||[]).filter(le=>le.subject.toLowerCase().includes(C.toLowerCase())||le.user?.email.toLowerCase().includes(C.toLowerCase())),$=(le="smooth")=>{if(a.current){const{scrollHeight:Os,clientHeight:Ws}=a.current;a.current.scrollTo({top:Os-Ws,behavior:le})}};u.useEffect(()=>{if(!l)return;const le=requestAnimationFrame(()=>{$("instant"),setTimeout(()=>$(),1e3)});return()=>{cancelAnimationFrame(le)}},[l,de?.messages]);const R=async()=>{const le=m.trim();!le||c||(h(!0),la.reply({id:_,message:le}).then(()=>{o(""),L(),$(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{h(!1)}))},X=async()=>{la.close(_).then(()=>{A.success(t("actions.close_success")),L(),H()})},Ns=()=>{de?.user&&r("/finance/order?user_id="+de.user.id)},De=de?.status===Vs.CLOSED;return e.jsxs(be,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n??e.jsx(J,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(fe,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(ye,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(J,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 z-50 md:hidden",onClick:()=>b(!w),children:e.jsx(pn,{className:N("h-4 w-4 transition-transform",!w&&"rotate-180")})}),e.jsxs("div",{className:N("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",w?"-translate-x-full":"translate-x-0","w-80 md:w-80 md:translate-x-0"),children:[e.jsxs("div",{className:"space-y-4 border-b p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold",children:t("list.title")}),e.jsx(J,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 md:flex",onClick:()=>b(!w),children:e.jsx(pn,{className:N("h-4 w-4 transition-transform",!w&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Jh,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(T,{placeholder:t("list.search_placeholder"),value:C,onChange:le=>S(le.target.value),className:"pl-8"})]})]}),e.jsx(zs,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:M?e.jsx(sp,{}):te.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(C?"list.no_search_results":"list.no_tickets")}):te.map(le=>e.jsx(tp,{ticket:le,isActive:le.id===_,onClick:()=>{E(le.id),window.innerWidth<768&&b(!0)}},le.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!w&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>b(!0)}),Z?e.jsx(ep,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col space-y-4 border-b p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:de?.subject}),e.jsx(q,{variant:De?"secondary":"default",children:t(De?"status.closed":"status.processing")}),!De&&e.jsx(Qe,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:X,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(jl,{className:"h-4 w-4"}),t("actions.close_ticket")]})})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{children:de?.user?.email})]}),e.jsx(ke,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(vl,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",we(de?.created_at)]})]}),e.jsx(ke,{orientation:"vertical",className:"h-4"}),e.jsx(q,{variant:"outline",children:de?.level!=null&&t(`level.${de.level===Oe.LOW?"low":de.level===Oe.MIDDLE?"medium":"high"}`)})]})]}),de?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.user_info"),onClick:()=>{p(de.user),k(!0)},children:e.jsx(gt,{className:"h-4 w-4"})}),e.jsx(ul,{user_id:de.user.id,dialogTrigger:e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Xh,{className:"h-4 w-4"})})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:Ns,children:e.jsx(Zh,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{ref:a,className:"h-full space-y-4 overflow-y-auto p-6",children:de?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):de?.messages?.map(le=>e.jsx(pl,{variant:le.is_me?"sent":"received",className:le.is_me?"ml-auto":"mr-auto",children:e.jsx(fl,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:le.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:we(le.created_at)})})]})})},le.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(gl,{ref:i,disabled:De||c,placeholder:t(De?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:m,onChange:le=>o(le.target.value),onKeyDown:le=>{le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),R())}}),e.jsx(J,{disabled:De||c||!m.trim(),onClick:R,children:t(c?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const np=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:"M19 4H5a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3V7a3 3 0 0 0-3-3m-.41 2l-5.88 5.88a1 1 0 0 1-1.42 0L5.41 6ZM20 17a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7.41l5.88 5.88a3 3 0 0 0 4.24 0L20 7.41Z"})}),rp=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:"M21.92 11.6C19.9 6.91 16.1 4 12 4s-7.9 2.91-9.92 7.6a1 1 0 0 0 0 .8C4.1 17.09 7.9 20 12 20s7.9-2.91 9.92-7.6a1 1 0 0 0 0-.8M12 18c-3.17 0-6.17-2.29-7.9-6C5.83 8.29 8.83 6 12 6s6.17 2.29 7.9 6c-1.73 3.71-4.73 6-7.9 6m0-10a4 4 0 1 0 4 4a4 4 0 0 0-4-4m0 6a2 2 0 1 1 2-2a2 2 0 0 1-2 2"})}),lp=s=>{const{t:n}=V("ticket");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:t.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.subject")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(np,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[500px] truncate font-medium",children:t.getValue("subject")})]}),enableSorting:!1,enableHiding:!1,size:4e3},{accessorKey:"level",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.level")}),cell:({row:t})=>{const r=t.getValue("level"),a=r===Oe.LOW?"default":r===Oe.MIDDLE?"secondary":"destructive";return e.jsx(q,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===Oe.LOW?"low":r===Oe.MIDDLE?"medium":"high"}`)})},filterFn:(t,r,a)=>a.includes(t.getValue(r))},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.status")}),cell:({row:t})=>{const r=t.getValue("status"),a=t.original.reply_status,i=r===Vs.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===Vs.CLOSED?"default":a===0?"secondary":"destructive";return e.jsx(q,{variant:l,className:"whitespace-nowrap",children:i})}},{accessorKey:"updated_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.updated_at")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[e.jsx(vl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:we(t.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:we(t.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const r=t.original.status!==Vs.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(ap,{ticketId:t.original.id,dialogTrigger:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(rp,{className:"h-4 w-4"})})}),r&&e.jsx(Qe,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{gd(t.original.id).then(()=>{A.success(n("actions.close_success")),s()})},children:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(jl,{className:"h-4 w-4"})})})]})}}]};function ip(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([{id:"status",value:"0"}]),[l,d]=u.useState([]),[m,o]=u.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=re({queryKey:["orderList",m,a,l],queryFn:()=>pd({pageSize:m.pageSize,current:m.pageIndex+1,filter:a,sort:l})}),_=ns({data:h?.data??[],columns:lp(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:m},rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),onPaginationChange:o,getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Bh,{table:_,refetch:c}),e.jsx(hs,{table:_,showPagination:!0})]})}function op(){const{t:s}=V("ticket");return e.jsxs(xl,{refreshData:()=>{},children:[e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(ip,{})})]})]}),e.jsx(hl,{})]})}const cp=Object.freeze(Object.defineProperty({__proto__:null,default:op},Symbol.toStringTag,{value:"Module"}));export{hp as a,mp as c,xp as g,pp as r}; +`+a("columns.online_status.offline_duration.seconds",{count:m})}return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:N("size-2.5 rounded-full ring-2 ring-offset-2",d?"bg-green-500 ring-green-500/20":"bg-gray-300 ring-gray-300/20","transition-all duration-300")}),e.jsx("span",{className:"font-medium text-foreground/90",children:i.original.email})]})}),e.jsx(ce,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:o})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.online_count")}),cell:({row:i})=>{const l=i.original.device_limit,d=i.original.online_count||0;return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(q,{variant:"outline",className:N("min-w-[4rem] justify-center",l!==null&&d>=l?"border-destructive/50 bg-destructive/10 text-destructive":"border-primary/40 bg-primary/5 text-primary/90"),children:[d," / ",l===null?"∞":l]})})}),e.jsx(ce,{side:"bottom",children:e.jsx("p",{className:"text-sm",children:l===null?a("columns.device_limit.unlimited"):a("columns.device_limit.limited",{count:l})})})]})})},enableSorting:!0,enableHiding:!1},{accessorKey:"banned",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.status")}),cell:({row:i})=>{const l=i.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(q,{className:N("min-w-20 justify-center transition-colors",l?"bg-destructive/15 text-destructive hover:bg-destructive/25":"bg-success/15 text-success hover:bg-success/25"),children:a(l?"columns.status_text.banned":"columns.status_text.normal")})})},enableSorting:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l))},{accessorKey:"plan_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.subscription")}),cell:({row:i})=>e.jsx("div",{className:"min-w-[10em] break-all",children:i.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.group")}),cell:({row:i})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(q,{variant:"outline",className:N("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5 whitespace-nowrap"),children:i.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.used_traffic")}),cell:({row:i})=>{const l=ps(i.original?.total_used),d=ps(i.original?.transfer_enable),m=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(ve,{delayDuration:100,children:e.jsxs(he,{children:[e.jsx(pe,{className:"w-full",children:e.jsxs("div",{className:"w-full space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:l}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:N("h-full rounded-full transition-all",m>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(m,100)}%`}})})]})}),e.jsx(ce,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",d]})})]})})}},{accessorKey:"transfer_enable",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.total_traffic")}),cell:({row:i})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:ps(i.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.expire_time")}),cell:({row:i})=>{const l=i.original.expired_at,d=Date.now()/1e3,m=l!=null&&le.jsx(O,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=Xs(i.original?.balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:l})]})}},{accessorKey:"commission_balance",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.commission")}),cell:({row:i})=>{const l=Xs(i.original?.commission_balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:l})]})}},{accessorKey:"created_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.register_time")}),cell:({row:i})=>e.jsx("div",{className:"truncate",children:we(i.original?.created_at)}),size:1e3},{id:"actions",header:({column:i})=>e.jsx(O,{column:i,className:"justify-end",title:a("columns.actions")}),cell:({row:i,table:l})=>e.jsxs(Ss,{modal:!0,children:[e.jsx(ks,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(J,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Vt,{className:"size-4"})})})}),e.jsxs(fs,{align:"end",className:"min-w-[40px]",children:[e.jsx(je,{onSelect:d=>{d.preventDefault(),t(i.original),r(!0)},className:"p-0",children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Eh,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(je,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(tl,{defaultValues:{email:i.original.email},trigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Rh,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(je,{onSelect:()=>{Ft(i.original.subscribe_url).then(()=>{A.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Ih,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(je,{onSelect:()=>{xd({id:i.original.id}).then(({data:d})=>{d&&A.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Vh,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(je,{onSelect:()=>{},className:"p-0",children:e.jsxs(Us,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=${i.original?.id}`,children:[e.jsx(Mh,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(je,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Fh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(je,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(ul,{user_id:i.original?.id,dialogTrigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Oh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(je,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Ph,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:i.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:d}=await Ot.destroy(i.original.id);d&&(A.success(a("common:delete.success")),s())}catch{A.error(a("common:delete.failed"))}},children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5 text-destructive hover:text-destructive",children:[e.jsx(Lh,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},ml=u.createContext(void 0),qa=()=>{const s=u.useContext(ml);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},xl=({children:s,refreshData:n})=>{const[t,r]=u.useState(!1),[a,i]=u.useState(null),l={isOpen:t,setIsOpen:r,editingUser:a,setEditingUser:i,refreshData:n};return e.jsx(ml.Provider,{value:l,children:s})},Ah=x.object({id:x.number(),email:x.string().email(),invite_user_email:x.string().email().nullable().optional(),password:x.string().optional().nullable(),balance:x.coerce.number(),commission_balance:x.coerce.number(),u:x.number(),d:x.number(),transfer_enable:x.number(),expired_at:x.number().nullable(),plan_id:x.number().nullable(),banned:x.number(),commission_type:x.number(),commission_rate:x.number().nullable(),discount:x.number().nullable(),speed_limit:x.number().nullable(),device_limit:x.number().nullable(),is_admin:x.number(),is_staff:x.number(),remarks:x.string().nullable()});function hl(){const{t:s}=V("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=qa(),[i,l]=u.useState(!1),[d,m]=u.useState([]),o=ge({resolver:Ne(Ah),defaultValues:{id:0,email:"",invite_user_email:null,password:null,balance:0,commission_balance:0,u:0,d:0,transfer_enable:0,expired_at:null,plan_id:null,banned:0,commission_type:0,commission_rate:null,discount:null,speed_limit:null,device_limit:null,is_admin:0,is_staff:0,remarks:null}});return u.useEffect(()=>{n&&qs().then(({data:c})=>{m(c)})},[n]),u.useEffect(()=>{if(r){const c=r.invite_user?.email,{invite_user:h,..._}=r;o.reset({..._,invite_user_email:c||null,password:null})}},[r,o]),e.jsx(ll,{open:n,onOpenChange:t,children:e.jsxs(Aa,{className:"max-w-[90%] space-y-4",children:[e.jsxs($a,{children:[e.jsx(Ua,{children:s("edit.title")}),e.jsx(Ha,{})]}),e.jsxs(_e,{...o,children:[e.jsx(g,{control:o.control,name:"email",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.email")}),e.jsx(y,{children:e.jsx(T,{...c,placeholder:s("edit.form.email_placeholder")})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"invite_user_email",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.inviter_email")}),e.jsx(y,{children:e.jsx(T,{value:c.value||"",onChange:h=>c.onChange(h.target.value?h.target.value:null),placeholder:s("edit.form.inviter_email_placeholder")})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"password",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.password")}),e.jsx(y,{children:e.jsx(T,{type:"password",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.password_placeholder")})}),e.jsx(D,{...c})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(g,{control:o.control,name:"balance",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.balance")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"commission_balance",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.commission_balance")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"u",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.upload")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{...c})]})}),e.jsx(g,{control:o.control,name:"d",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.download")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{...c})]})})]}),e.jsx(g,{control:o.control,name:"transfer_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.total_traffic")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"expired_at",render:({field:c})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(j,{children:s("edit.form.expire_time")}),e.jsxs(vs,{open:i,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsx(y,{children:e.jsxs(P,{type:"button",variant:"outline",className:N("w-full pl-3 text-left font-normal",!c.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[c.value?we(c.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(jt,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(xs,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:h=>{h.preventDefault()},onEscapeKeyDown:h=>{h.preventDefault()},children:e.jsxs("div",{className:"flex flex-col space-y-3 p-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{c.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+1),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+3),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Gs,{mode:"single",selected:c.value?new Date(c.value*1e3):void 0,onSelect:h=>{if(h){const _=new Date(c.value?c.value*1e3:Date.now());h.setHours(_.getHours(),_.getMinutes(),_.getSeconds()),c.onChange(Math.floor(h.getTime()/1e3))}},disabled:h=>h{const h=new Date;h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3))},className:"h-6 px-2 text-xs",children:s("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"datetime-local",step:"1",value:we(c.value,"YYYY-MM-DDTHH:mm:ss"),onChange:h=>{const _=new Date(h.target.value);isNaN(_.getTime())||c.onChange(Math.floor(_.getTime()/1e3))},className:"flex-1"}),e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"plan_id",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.subscription")}),e.jsx(y,{children:e.jsxs(G,{value:c.value!==null?String(c.value):"null",onValueChange:h=>c.onChange(h==="null"?null:parseInt(h)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(z,{value:"null",children:s("edit.form.subscription_none")}),d.map(h=>e.jsx(z,{value:String(h.id),children:h.name},h.id))]})]})})]})}),e.jsx(g,{control:o.control,name:"banned",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.account_status")}),e.jsx(y,{children:e.jsxs(G,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(K,{children:e.jsx(W,{})}),e.jsxs(B,{children:[e.jsx(z,{value:"1",children:s("columns.status_text.banned")}),e.jsx(z,{value:"0",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(g,{control:o.control,name:"commission_type",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.commission_type")}),e.jsx(y,{children:e.jsxs(G,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(K,{children:e.jsx(W,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(z,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx(z,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx(z,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(g,{control:o.control,name:"commission_rate",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.commission_rate")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(g,{control:o.control,name:"discount",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.discount")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"speed_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.speed_limit")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"device_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.device_limit")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(D,{})]})}),e.jsx(g,{control:o.control,name:"is_admin",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:c.value===1,onCheckedChange:h=>c.onChange(h?1:0)})})})]})}),e.jsx(g,{control:o.control,name:"is_staff",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(y,{children:e.jsx(Y,{checked:c.value===1,onCheckedChange:h=>c.onChange(h?1:0)})})})]})}),e.jsx(g,{control:o.control,name:"remarks",render:({field:c})=>e.jsxs(f,{children:[e.jsx(j,{children:s("edit.form.remarks")}),e.jsx(y,{children:e.jsx(ys,{className:"h-24",value:c.value||"",onChange:h=>c.onChange(h.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(D,{})]})}),e.jsxs(ol,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(P,{type:"submit",onClick:()=>{o.handleSubmit(c=>{md(c).then(({data:h})=>{h&&(A.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function $h(){const[s]=fr(),[n,t]=u.useState({}),[r,a]=u.useState({is_admin:!1,is_staff:!1}),[i,l]=u.useState([]),[d,m]=u.useState([]),[o,c]=u.useState({pageIndex:0,pageSize:20});u.useEffect(()=>{const v=s.get("email");v&&l(M=>M.some(se=>se.id==="email")?M:[...M,{id:"email",value:v}])},[s]);const{refetch:h,data:_,isLoading:E}=re({queryKey:["userList",o,i,d],queryFn:()=>ud({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),[C,S]=u.useState([]),[w,b]=u.useState([]);u.useEffect(()=>{bt().then(({data:v})=>{S(v)}),qs().then(({data:v})=>{b(v)})},[]);const k=C.map(v=>({label:v.name,value:v.id})),p=w.map(v=>({label:v.name,value:v.id}));return e.jsxs(xl,{refreshData:h,children:[e.jsx(Uh,{data:_?.data??[],rowCount:_?.total??0,sorting:d,setSorting:m,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:o,setPagination:c,refetch:h,serverGroupList:C,permissionGroups:k,subscriptionPlans:p}),e.jsx(hl,{})]})}function Uh({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:m,setColumnFilters:o,pagination:c,setPagination:h,refetch:_,serverGroupList:E,permissionGroups:C,subscriptionPlans:S}){const{setIsOpen:w,setEditingUser:b}=qa(),k=ns({data:s,columns:zh(_,E,b,w),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:m,pagination:c},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:o,onColumnVisibilityChange:i,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),onPaginationChange:h,getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnVisibility:{commission_balance:!1,created_at:!1,is_admin:!1,is_staff:!1,permission_group:!1,plan_id:!1},columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(kh,{table:k,refetch:_,serverGroupList:E,permissionGroups:C,subscriptionPlans:S}),e.jsx(hs,{table:k})]})}function Hh(){const{t:s}=V("user");return e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",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("div",{className:"w-full",children:e.jsx($h,{})})})]})]})}const qh=Object.freeze(Object.defineProperty({__proto__:null,default:Hh},Symbol.toStringTag,{value:"Module"}));function Kh({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(vs,{children:[e.jsx(bs,{asChild:!0,children:e.jsxs(J,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Qo,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ke,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):t.filter(a=>r.has(a.value)).map(a=>e.jsx(q,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:a.label},`selected-${a.value}`))})]})]})}),e.jsx(xs,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ms,{children:[e.jsx(Ks,{placeholder:n}),e.jsxs(Fs,{children:[e.jsx(Bs,{children:"No results found."}),e.jsx(Ye,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(Me,{onSelect:()=>{i?r.delete(a.value):r.add(a.value);const l=Array.from(r);s?.setFilterValue(l.length?l:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",i?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Jo,{className:N("h-4 w-4")})}),a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:a.label})]},`option-${a.value}`)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(Ye,{children:e.jsx(Me,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Bh=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:"M19 11H5a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})});function Gh({table:s}){const{t:n}=V("ticket");return e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-4",children:[e.jsx(Gt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(vt,{className:"grid w-full grid-cols-2",children:[e.jsx(Ge,{value:"0",children:n("status.pending")}),e.jsx(Ge,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(Kh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:Oe.LOW,icon:Bh,color:"gray"},{label:n("level.medium"),value:Oe.MIDDLE,icon:cl,color:"yellow"},{label:n("level.high"),value:Oe.HIGH,icon:dl,color:"red"}]})]})})}function Wh(){return e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[e.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}const Yh=As("flex gap-2 max-w-[60%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),pl=u.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:N(Yh({variant:n,layout:t,className:s}),"relative group"),ref:i,...a,children:u.Children.map(r,l=>u.isValidElement(l)&&typeof l.type!="string"?u.cloneElement(l,{variant:n,layout:t}):l)}));pl.displayName="ChatBubble";const Qh=As("p-4",{variants:{variant:{received:"bg-secondary text-secondary-foreground rounded-r-lg rounded-tl-lg",sent:"bg-primary text-primary-foreground rounded-l-lg rounded-tr-lg"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),fl=u.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:N(Qh({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...i,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(Wh,{})}):a}));fl.displayName="ChatBubbleMessage";const Jh=u.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:N("absolute top-1/2 -translate-y-1/2 flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",s==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",n),...r,children:t}));Jh.displayName="ChatBubbleActionWrapper";const gl=u.forwardRef(({className:s,...n},t)=>e.jsx(ys,{autoComplete:"off",ref:t,name:"message",className:N("max-h-12 px-4 py-3 bg-background text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-md flex items-center h-16 resize-none",s),...n}));gl.displayName="ChatInput";const jl=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:"m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"})}),vl=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.098 12.634L13 11.423V7a1 1 0 0 0-2 0v5a1 1 0 0 0 .5.866l2.598 1.5a1 1 0 1 0 1-1.732M12 2a10 10 0 1 0 10 10A10.01 10.01 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8.01 8.01 0 0 1-8 8"})}),pn=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 12l3.54-3.54a1 1 0 0 0 0-1.41a1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29a1 1 0 0 0 .71-.29a1 1 0 0 0 0-1.41Z"})}),Xh=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:"M21.71 20.29L18 16.61A9 9 0 1 0 16.61 18l3.68 3.68a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.39M11 18a7 7 0 1 1 7-7a7 7 0 0 1-7 7"})}),Zh=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:"M3.71 16.29a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21a1 1 0 0 0-.21.33a1 1 0 0 0 .21 1.09a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1 1 0 0 0 .21-1.09a1 1 0 0 0-.21-.33M7 8h14a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m-3.29 3.29a1 1 0 0 0-1.09-.21a1.2 1.2 0 0 0-.33.21a1 1 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1 1 0 0 0-.21-.33M21 11H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2M3.71 6.29a1 1 0 0 0-.33-.21a1 1 0 0 0-1.09.21a1.2 1.2 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a1 1 0 0 0 1.09-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1.2 1.2 0 0 0-.21-.33M21 16H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})}),ep=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:"M9 12H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m-1-2h4a1 1 0 0 0 0-2H8a1 1 0 0 0 0 2m1 6H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m12-4h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Zm-6.44-2.83a.8.8 0 0 0-.18-.09a.6.6 0 0 0-.19-.06a1 1 0 0 0-.9.27A1.05 1.05 0 0 0 12 17a1 1 0 0 0 .07.38a1.2 1.2 0 0 0 .22.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21A1 1 0 0 0 14 17a1.05 1.05 0 0 0-.29-.71a2 2 0 0 0-.15-.12m.14-3.88a1 1 0 0 0-1.62.33A1 1 0 0 0 13 14a1 1 0 0 0 1-1a1 1 0 0 0-.08-.38a.9.9 0 0 0-.22-.33"})});function sp(){return e.jsxs("div",{className:"flex h-full flex-col space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{className:"h-8 w-3/4"}),e.jsx(oe,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(oe,{className:"h-20 w-2/3"},s))})]})}function tp(){return e.jsx("div",{className:"space-y-4 p-4",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(oe,{className:"h-5 w-4/5"}),e.jsx(oe,{className:"h-4 w-2/3"}),e.jsx(oe,{className:"h-3 w-1/2"})]},s))})}function ap({ticket:s,isActive:n,onClick:t}){const{t:r}=V("ticket"),a=i=>{switch(i){case Oe.HIGH:return"bg-red-50 text-red-600 border-red-200";case Oe.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case Oe.LOW:return"bg-green-50 text-green-600 border-green-200";default:return"bg-gray-50 text-gray-600 border-gray-200"}};return e.jsxs("div",{className:N("flex cursor-pointer flex-col border-b p-4 hover:bg-accent/50",n&&"bg-accent"),onClick:t,children:[e.jsxs("div",{className:"flex max-w-[280px] items-center justify-between gap-2",children:[e.jsx("h4",{className:"flex-1 truncate font-medium",children:s.subject}),e.jsx(q,{variant:s.status===Vs.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Vs.CLOSED?r("status.closed"):r("status.processing")})]}),e.jsx("div",{className:"mt-1 max-w-[280px] truncate text-sm text-muted-foreground",children:s.user?.email}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[e.jsx("time",{className:"text-muted-foreground",children:we(s.updated_at)}),e.jsx("div",{className:N("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===Oe.LOW?"low":s.level===Oe.MIDDLE?"medium":"high"}`)})]})]})}function np({ticketId:s,dialogTrigger:n}){const{t}=V("ticket"),r=Ts(),a=u.useRef(null),i=u.useRef(null),[l,d]=u.useState(!1),[m,o]=u.useState(""),[c,h]=u.useState(!1),[_,E]=u.useState(s),[C,S]=u.useState(""),[w,b]=u.useState(!1),{setIsOpen:k,setEditingUser:p}=qa(),{data:v,isLoading:M,refetch:H}=re({queryKey:["tickets",l],queryFn:()=>l?la.getList({filter:[{id:"status",value:[Vs.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:se,refetch:L,isLoading:Z}=re({queryKey:["ticket",_,l],queryFn:()=>l?gd(_):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),de=se?.data,te=(v?.data||[]).filter(le=>le.subject.toLowerCase().includes(C.toLowerCase())||le.user?.email.toLowerCase().includes(C.toLowerCase())),$=(le="smooth")=>{if(a.current){const{scrollHeight:Os,clientHeight:Ws}=a.current;a.current.scrollTo({top:Os-Ws,behavior:le})}};u.useEffect(()=>{if(!l)return;const le=requestAnimationFrame(()=>{$("instant"),setTimeout(()=>$(),1e3)});return()=>{cancelAnimationFrame(le)}},[l,de?.messages]);const R=async()=>{const le=m.trim();!le||c||(h(!0),la.reply({id:_,message:le}).then(()=>{o(""),L(),$(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{h(!1)}))},X=async()=>{la.close(_).then(()=>{A.success(t("actions.close_success")),L(),H()})},Ns=()=>{de?.user&&r("/finance/order?user_id="+de.user.id)},De=de?.status===Vs.CLOSED;return e.jsxs(be,{open:l,onOpenChange:d,children:[e.jsx(Je,{asChild:!0,children:n??e.jsx(J,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(fe,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(ye,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(J,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 z-50 md:hidden",onClick:()=>b(!w),children:e.jsx(pn,{className:N("h-4 w-4 transition-transform",!w&&"rotate-180")})}),e.jsxs("div",{className:N("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",w?"-translate-x-full":"translate-x-0","w-80 md:w-80 md:translate-x-0"),children:[e.jsxs("div",{className:"space-y-4 border-b p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold",children:t("list.title")}),e.jsx(J,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 md:flex",onClick:()=>b(!w),children:e.jsx(pn,{className:N("h-4 w-4 transition-transform",!w&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Xh,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(T,{placeholder:t("list.search_placeholder"),value:C,onChange:le=>S(le.target.value),className:"pl-8"})]})]}),e.jsx(zs,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:M?e.jsx(tp,{}):te.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(C?"list.no_search_results":"list.no_tickets")}):te.map(le=>e.jsx(ap,{ticket:le,isActive:le.id===_,onClick:()=>{E(le.id),window.innerWidth<768&&b(!0)}},le.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!w&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>b(!0)}),Z?e.jsx(sp,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col space-y-4 border-b p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:de?.subject}),e.jsx(q,{variant:De?"secondary":"default",children:t(De?"status.closed":"status.processing")}),!De&&e.jsx(Qe,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:X,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(jl,{className:"h-4 w-4"}),t("actions.close_ticket")]})})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsx("span",{children:de?.user?.email})]}),e.jsx(ke,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(vl,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",we(de?.created_at)]})]}),e.jsx(ke,{orientation:"vertical",className:"h-4"}),e.jsx(q,{variant:"outline",children:de?.level!=null&&t(`level.${de.level===Oe.LOW?"low":de.level===Oe.MIDDLE?"medium":"high"}`)})]})]}),de?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.user_info"),onClick:()=>{p(de.user),k(!0)},children:e.jsx(gt,{className:"h-4 w-4"})}),e.jsx(ul,{user_id:de.user.id,dialogTrigger:e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Zh,{className:"h-4 w-4"})})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:Ns,children:e.jsx(ep,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{ref:a,className:"h-full space-y-4 overflow-y-auto p-6",children:de?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):de?.messages?.map(le=>e.jsx(pl,{variant:le.is_me?"sent":"received",className:le.is_me?"ml-auto":"mr-auto",children:e.jsx(fl,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:le.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:we(le.created_at)})})]})})},le.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(gl,{ref:i,disabled:De||c,placeholder:t(De?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:m,onChange:le=>o(le.target.value),onKeyDown:le=>{le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),R())}}),e.jsx(J,{disabled:De||c||!m.trim(),onClick:R,children:t(c?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const rp=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:"M19 4H5a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3V7a3 3 0 0 0-3-3m-.41 2l-5.88 5.88a1 1 0 0 1-1.42 0L5.41 6ZM20 17a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7.41l5.88 5.88a3 3 0 0 0 4.24 0L20 7.41Z"})}),lp=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:"M21.92 11.6C19.9 6.91 16.1 4 12 4s-7.9 2.91-9.92 7.6a1 1 0 0 0 0 .8C4.1 17.09 7.9 20 12 20s7.9-2.91 9.92-7.6a1 1 0 0 0 0-.8M12 18c-3.17 0-6.17-2.29-7.9-6C5.83 8.29 8.83 6 12 6s6.17 2.29 7.9 6c-1.73 3.71-4.73 6-7.9 6m0-10a4 4 0 1 0 4 4a4 4 0 0 0-4-4m0 6a2 2 0 1 1 2-2a2 2 0 0 1-2 2"})}),ip=s=>{const{t:n}=V("ticket");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx(q,{variant:"outline",children:t.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.subject")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(rp,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[500px] truncate font-medium",children:t.getValue("subject")})]}),enableSorting:!1,enableHiding:!1,size:4e3},{accessorKey:"level",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.level")}),cell:({row:t})=>{const r=t.getValue("level"),a=r===Oe.LOW?"default":r===Oe.MIDDLE?"secondary":"destructive";return e.jsx(q,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===Oe.LOW?"low":r===Oe.MIDDLE?"medium":"high"}`)})},filterFn:(t,r,a)=>a.includes(t.getValue(r))},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.status")}),cell:({row:t})=>{const r=t.getValue("status"),a=t.original.reply_status,i=r===Vs.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===Vs.CLOSED?"default":a===0?"secondary":"destructive";return e.jsx(q,{variant:l,className:"whitespace-nowrap",children:i})}},{accessorKey:"updated_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.updated_at")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[e.jsx(vl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:we(t.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:we(t.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const r=t.original.status!==Vs.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(np,{ticketId:t.original.id,dialogTrigger:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(lp,{className:"h-4 w-4"})})}),r&&e.jsx(Qe,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{jd(t.original.id).then(()=>{A.success(n("actions.close_success")),s()})},children:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(jl,{className:"h-4 w-4"})})})]})}}]};function op(){const[s,n]=u.useState({}),[t,r]=u.useState({}),[a,i]=u.useState([{id:"status",value:"0"}]),[l,d]=u.useState([]),[m,o]=u.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=re({queryKey:["orderList",m,a,l],queryFn:()=>fd({pageSize:m.pageSize,current:m.pageIndex+1,filter:a,sort:l})}),_=ns({data:h?.data??[],columns:ip(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:m},rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:rs(),getFilteredRowModel:ds(),getPaginationRowModel:us(),onPaginationChange:o,getSortedRowModel:ms(),getFacetedRowModel:Ds(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Gh,{table:_,refetch:c}),e.jsx(hs,{table:_,showPagination:!0})]})}function cp(){const{t:s}=V("ticket");return e.jsxs(xl,{refreshData:()=>{},children:[e.jsxs(Ee,{children:[e.jsxs(Re,{children:[e.jsx(Ke,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ae,{}),e.jsx($e,{})]})]}),e.jsxs(Fe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(op,{})})]})]}),e.jsx(hl,{})]})}const dp=Object.freeze(Object.defineProperty({__proto__:null,default:cp},Symbol.toStringTag,{value:"Module"}));export{pp as a,xp as c,hp as g,fp as r}; diff --git a/public/assets/admin/assets/vendor.js b/public/assets/admin/assets/vendor.js index 8696dfe..0e4807a 100644 --- a/public/assets/admin/assets/vendor.js +++ b/public/assets/admin/assets/vendor.js @@ -585,4 +585,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho `:">",o};sp.prototype.renderInline=function(e,t,n){let r="";const i=this.rules;for(let o=0,a=e.length;o=0&&(r=this.attrs[n][1]),r};os.prototype.attrJoin=function(t,n){const r=this.attrIndex(t);r<0?this.attrPush([t,n]):this.attrs[r][1]=this.attrs[r][1]+" "+n};function yZ(e,t,n){this.src=e,this.env=n,this.tokens=[],this.inlineMode=!1,this.md=t}yZ.prototype.Token=os;const mGe=/\r\n?|\n/g,vGe=/\0/g;function yGe(e){let t;t=e.src.replace(mGe,` `),t=t.replace(vGe,"�"),e.src=t}function bGe(e){let t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function xGe(e){const t=e.tokens;for(let n=0,r=t.length;n\s]/i.test(e)}function _Ge(e){return/^<\/a\s*>/i.test(e)}function SGe(e){const t=e.tokens;if(e.md.options.linkify)for(let n=0,r=t.length;n=0;a--){const s=i[a];if(s.type==="link_close"){for(a--;i[a].level!==s.level&&i[a].type!=="link_open";)a--;continue}if(s.type==="html_inline"&&(wGe(s.content)&&o>0&&o--,_Ge(s.content)&&o++),!(o>0)&&s.type==="text"&&e.md.linkify.test(s.content)){const u=s.content;let l=e.md.linkify.match(u);const c=[];let f=s.level,h=0;l.length>0&&l[0].index===0&&a>0&&i[a-1].type==="text_special"&&(l=l.slice(1));for(let p=0;ph){const E=new e.Token("text","",0);E.content=u.slice(h,w),E.level=f,c.push(E)}const x=new e.Token("link_open","a",1);x.attrs=[["href",v]],x.level=f++,x.markup="linkify",x.info="auto",c.push(x);const S=new e.Token("text","",0);S.content=b,S.level=f,c.push(S);const O=new e.Token("link_close","a",-1);O.level=--f,O.markup="linkify",O.info="auto",c.push(O),h=l[p].lastIndex}if(h=0;n--){const r=e[n];r.type==="text"&&!t&&(r.content=r.content.replace(EGe,AGe)),r.type==="link_open"&&r.info==="auto"&&t--,r.type==="link_close"&&r.info==="auto"&&t++}}function kGe(e){let t=0;for(let n=e.length-1;n>=0;n--){const r=e[n];r.type==="text"&&!t&&bZ.test(r.content)&&(r.content=r.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/mg,"$1—").replace(/(^|\s)--(?=\s|$)/mg,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/mg,"$1–")),r.type==="link_open"&&r.info==="auto"&&t--,r.type==="link_close"&&r.info==="auto"&&t++}}function TGe(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type==="inline"&&(CGe.test(e.tokens[t].content)&&PGe(e.tokens[t].children),bZ.test(e.tokens[t].content)&&kGe(e.tokens[t].children))}const MGe=/['"]/,ON=/['"]/g,AN="’";function U1(e,t,n){return e.slice(0,t)+n+e.slice(t+1)}function RGe(e,t){let n;const r=[];for(let i=0;i=0&&!(r[n].level<=a);n--);if(r.length=n+1,o.type!=="text")continue;let s=o.content,u=0,l=s.length;e:for(;u=0)m=s.charCodeAt(c.index-1);else for(n=i-1;n>=0&&!(e[n].type==="softbreak"||e[n].type==="hardbreak");n--)if(e[n].content){m=e[n].content.charCodeAt(e[n].content.length-1);break}let v=32;if(u=48&&m<=57&&(h=f=!1),f&&h&&(f=b,h=w),!f&&!h){p&&(o.content=U1(o.content,c.index,AN));continue}if(h)for(n=r.length-1;n>=0;n--){let O=r[n];if(r[n].level=0;t--)e.tokens[t].type!=="inline"||!MGe.test(e.tokens[t].content)||RGe(e.tokens[t].children,e)}function $Ge(e){let t,n;const r=e.tokens,i=r.length;for(let o=0;o0&&this.level++,this.tokens.push(r),r};Ls.prototype.isEmpty=function(t){return this.bMarks[t]+this.tShift[t]>=this.eMarks[t]};Ls.prototype.skipEmptyLines=function(t){for(let n=this.lineMax;tn;)if(!Hn(this.src.charCodeAt(--t)))return t+1;return t};Ls.prototype.skipChars=function(t,n){for(let r=this.src.length;tr;)if(n!==this.src.charCodeAt(--t))return t+1;return t};Ls.prototype.getLines=function(t,n,r,i){if(t>=n)return"";const o=new Array(n-t);for(let a=0,s=t;sr?o[a]=new Array(u-r+1).join(" ")+this.src.slice(c,f):o[a]=this.src.slice(c,f)}return o.join("")};Ls.prototype.Token=os;const IGe=65536;function H3(e,t){const n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function PN(e){const t=[],n=e.length;let r=0,i=e.charCodeAt(r),o=!1,a=0,s="";for(;rn)return!1;let i=t+1;if(e.sCount[i]=4)return!1;let o=e.bMarks[i]+e.tShift[i];if(o>=e.eMarks[i])return!1;const a=e.src.charCodeAt(o++);if(a!==124&&a!==45&&a!==58||o>=e.eMarks[i])return!1;const s=e.src.charCodeAt(o++);if(s!==124&&s!==45&&s!==58&&!Hn(s)||a===45&&Hn(s))return!1;for(;o=4)return!1;l=PN(u),l.length&&l[0]===""&&l.shift(),l.length&&l[l.length-1]===""&&l.pop();const f=l.length;if(f===0||f!==c.length)return!1;if(r)return!0;const h=e.parentType;e.parentType="table";const p=e.md.block.ruler.getRules("blockquote"),m=e.push("table_open","table",1),v=[t,0];m.map=v;const b=e.push("thead_open","thead",1);b.map=[t,t+1];const w=e.push("tr_open","tr",1);w.map=[t,t+1];for(let O=0;O=4||(l=PN(u),l.length&&l[0]===""&&l.shift(),l.length&&l[l.length-1]===""&&l.pop(),S+=f-l.length,S>IGe))break;if(i===t+2){const C=e.push("tbody_open","tbody",1);C.map=x=[t+2,0]}const E=e.push("tr_open","tr",1);E.map=[i,i+1];for(let C=0;C=4){r++,i=r;continue}break}e.line=i;const o=e.push("code_block","code",0);return o.content=e.getLines(t,i,4+e.blkIndent,!1)+` -`,o.map=[t,e.line],!0}function FGe(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],o=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>o)return!1;const a=e.src.charCodeAt(i);if(a!==126&&a!==96)return!1;let s=i;i=e.skipChars(i,a);let u=i-s;if(u<3)return!1;const l=e.src.slice(s,i),c=e.src.slice(i,o);if(a===96&&c.indexOf(String.fromCharCode(a))>=0)return!1;if(r)return!0;let f=t,h=!1;for(;f++,!(f>=n||(i=s=e.bMarks[f]+e.tShift[f],o=e.eMarks[f],i=4)&&(i=e.skipChars(i,a),!(i-s=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;const s=[],u=[],l=[],c=[],f=e.md.block.ruler.getRules("blockquote"),h=e.parentType;e.parentType="blockquote";let p=!1,m;for(m=t;m=o)break;if(e.src.charCodeAt(i++)===62&&!S){let E=e.sCount[m]+1,C,P;e.src.charCodeAt(i)===32?(i++,E++,P=!1,C=!0):e.src.charCodeAt(i)===9?(C=!0,(e.bsCount[m]+E)%4===3?(i++,E++,P=!1):P=!0):C=!1;let M=E;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i=o,u.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+(C?1:0),l.push(e.sCount[m]),e.sCount[m]=M-E,c.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let O=!1;for(let E=0,C=f.length;E";const w=[t,0];b.map=w,e.md.block.tokenize(e,t,m);const x=e.push("blockquote_close","blockquote",-1);x.markup=">",e.lineMax=a,e.parentType=h,w[1]=e.line;for(let S=0;S=4)return!1;let o=e.bMarks[t]+e.tShift[t];const a=e.src.charCodeAt(o++);if(a!==42&&a!==45&&a!==95)return!1;let s=1;for(;o=r)return-1;let o=e.src.charCodeAt(i++);if(o<48||o>57)return-1;for(;;){if(i>=r)return-1;if(o=e.src.charCodeAt(i++),o>=48&&o<=57){if(i-n>=10)return-1;continue}if(o===41||o===46)break;return-1}return i=4||e.listIndent>=0&&e.sCount[u]-e.listIndent>=4&&e.sCount[u]=e.blkIndent&&(c=!0);let f,h,p;if((p=TN(e,u))>=0){if(f=!0,a=e.bMarks[u]+e.tShift[u],h=Number(e.src.slice(a,p-1)),c&&h!==1)return!1}else if((p=kN(e,u))>=0)f=!1;else return!1;if(c&&e.skipSpaces(p)>=e.eMarks[u])return!1;if(r)return!0;const m=e.src.charCodeAt(p-1),v=e.tokens.length;f?(s=e.push("ordered_list_open","ol",1),h!==1&&(s.attrs=[["start",h]])):s=e.push("bullet_list_open","ul",1);const b=[u,0];s.map=b,s.markup=String.fromCharCode(m);let w=!1;const x=e.md.block.ruler.getRules("list"),S=e.parentType;for(e.parentType="list";u=i?P=1:P=E-O,P>4&&(P=1);const M=O+P;s=e.push("list_item_open","li",1),s.markup=String.fromCharCode(m);const I=[u,0];s.map=I,f&&(s.info=e.src.slice(a,p-1));const B=e.tight,W=e.tShift[u],V=e.sCount[u],ee=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=M,e.tight=!0,e.tShift[u]=C-e.bMarks[u],e.sCount[u]=E,C>=i&&e.isEmpty(u+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,u,n,!0),(!e.tight||w)&&(l=!1),w=e.line-u>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=ee,e.tShift[u]=W,e.sCount[u]=V,e.tight=B,s=e.push("list_item_close","li",-1),s.markup=String.fromCharCode(m),u=e.line,I[1]=u,u>=n||e.sCount[u]=4)break;let Z=!1;for(let K=0,G=x.length;K=4||e.src.charCodeAt(i)!==91)return!1;function s(x){const S=e.lineMax;if(x>=S||e.isEmpty(x))return null;let O=!1;if(e.sCount[x]-e.blkIndent>3&&(O=!0),e.sCount[x]<0&&(O=!0),!O){const P=e.md.block.ruler.getRules("reference"),M=e.parentType;e.parentType="reference";let I=!1;for(let B=0,W=P.length;B"u"&&(e.env.references={}),typeof e.env.references[w]>"u"&&(e.env.references[w]={title:b,href:f}),e.line=a),!0):!1}const WGe=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],HGe="[a-zA-Z_:][a-zA-Z0-9:._-]*",KGe="[^\"'=<>`\\x00-\\x20]+",qGe="'[^']*'",GGe='"[^"]*"',YGe="(?:"+KGe+"|"+qGe+"|"+GGe+")",ZGe="(?:\\s+"+HGe+"(?:\\s*=\\s*"+YGe+")?)",xZ="<[A-Za-z][A-Za-z0-9\\-]*"+ZGe+"*\\s*\\/?>",wZ="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",XGe="",QGe="<[?][\\s\\S]*?[?]>",JGe="]*>",eYe="",tYe=new RegExp("^(?:"+xZ+"|"+wZ+"|"+XGe+"|"+QGe+"|"+JGe+"|"+eYe+")"),nYe=new RegExp("^(?:"+xZ+"|"+wZ+")"),td=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(nYe.source+"\\s*$"),/^$/,!1]];function rYe(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],o=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let a=e.src.slice(i,o),s=0;for(;s=4)return!1;let a=e.src.charCodeAt(i);if(a!==35||i>=o)return!1;let s=1;for(a=e.src.charCodeAt(++i);a===35&&i6||ii&&Hn(e.src.charCodeAt(u-1))&&(o=u),e.line=t+1;const l=e.push("heading_open","h"+String(s),1);l.markup="########".slice(0,s),l.map=[t,e.line];const c=e.push("inline","",0);c.content=e.src.slice(i,o).trim(),c.map=[t,e.line],c.children=[];const f=e.push("heading_close","h"+String(s),-1);return f.markup="########".slice(0,s),!0}function oYe(e,t,n){const r=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;const i=e.parentType;e.parentType="paragraph";let o=0,a,s=t+1;for(;s3)continue;if(e.sCount[s]>=e.blkIndent){let p=e.bMarks[s]+e.tShift[s];const m=e.eMarks[s];if(p=m))){o=a===61?1:2;break}}if(e.sCount[s]<0)continue;let h=!1;for(let p=0,m=r.length;p3||e.sCount[o]<0)continue;let l=!1;for(let c=0,f=r.length;c=n||e.sCount[a]=o){e.line=n;break}const u=e.line;let l=!1;for(let c=0;c=e.line)throw new Error("block rule didn't increment state.line");break}if(!l)throw new Error("none of the block rules matched");e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),a=e.line,a0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r};tv.prototype.scanDelims=function(e,t){const n=this.posMax,r=this.src.charCodeAt(e),i=e>0?this.src.charCodeAt(e-1):32;let o=e;for(;o0)return!1;const n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;const i=e.pending.match(lYe);if(!i)return!1;const o=i[1],a=e.md.linkify.matchAtStart(e.src.slice(n-o.length));if(!a)return!1;let s=a.url;if(s.length<=o.length)return!1;s=s.replace(/\*+$/,"");const u=e.md.normalizeLink(s);if(!e.md.validateLink(u))return!1;if(!t){e.pending=e.pending.slice(0,-o.length);const l=e.push("link_open","a",1);l.attrs=[["href",u]],l.markup="linkify",l.info="auto";const c=e.push("text","",0);c.content=e.md.normalizeLinkText(s);const f=e.push("link_close","a",-1);f.markup="linkify",f.info="auto"}return e.pos+=s.length-o.length,!0}function fYe(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;const r=e.pending.length-1,i=e.posMax;if(!t)if(r>=0&&e.pending.charCodeAt(r)===32)if(r>=1&&e.pending.charCodeAt(r-1)===32){let o=r-1;for(;o>=1&&e.pending.charCodeAt(o-1)===32;)o--;e.pending=e.pending.slice(0,o),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(n++;n?@[]^_`{|}~-".split("").forEach(function(e){UP[e.charCodeAt(0)]=1});function dYe(e,t){let n=e.pos;const r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push("hardbreak","br",0),n++;n=55296&&i<=56319&&n+1=56320&&s<=57343&&(o+=e.src[n+1],n++)}const a="\\"+o;if(!t){const s=e.push("text_special","",0);i<256&&UP[i]!==0?s.content=o:s.content=a,s.markup=a,s.info="escape"}return e.pos=n+1,!0}function hYe(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;const i=n;n++;const o=e.posMax;for(;n=0;r--){const i=t[r];if(i.marker!==95&&i.marker!==42||i.end===-1)continue;const o=t[i.end],a=r>0&&t[r-1].end===i.end+1&&t[r-1].marker===i.marker&&t[r-1].token===i.token-1&&t[i.end+1].token===o.token+1,s=String.fromCharCode(i.marker),u=e.tokens[i.token];u.type=a?"strong_open":"em_open",u.tag=a?"strong":"em",u.nesting=1,u.markup=a?s+s:s,u.content="";const l=e.tokens[o.token];l.type=a?"strong_close":"em_close",l.tag=a?"strong":"em",l.nesting=-1,l.markup=a?s+s:s,l.content="",a&&(e.tokens[t[r-1].token].content="",e.tokens[t[i.end+1].token].content="",r--)}}function vYe(e){const t=e.tokens_meta,n=e.tokens_meta.length;RN(e,e.delimiters);for(let r=0;r=f)return!1;if(u=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(a=e.md.normalizeLink(i.str),e.md.validateLink(a)?m=i.pos:a="",u=m;m=f||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(typeof e.env.references>"u")return!1;if(m=0?r=e.src.slice(u,m++):m=p+1):m=p+1,r||(r=e.src.slice(h,p)),o=e.env.references[T2(r)],!o)return e.pos=c,!1;a=o.href,s=o.title}if(!t){e.pos=h,e.posMax=p;const v=e.push("link_open","a",1),b=[["href",a]];v.attrs=b,s&&b.push(["title",s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push("link_close","a",-1)}return e.pos=m,e.posMax=f,!0}function bYe(e,t){let n,r,i,o,a,s,u,l,c="";const f=e.pos,h=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;const p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(o=m+1,o=h)return!1;for(l=o,s=e.md.helpers.parseLinkDestination(e.src,o,e.posMax),s.ok&&(c=e.md.normalizeLink(s.str),e.md.validateLink(c)?o=s.pos:c=""),l=o;o=h||e.src.charCodeAt(o)!==41)return e.pos=f,!1;o++}else{if(typeof e.env.references>"u")return!1;if(o=0?i=e.src.slice(l,o++):o=m+1):o=m+1,i||(i=e.src.slice(p,m)),a=e.env.references[T2(i)],!a)return e.pos=f,!1;c=a.href,u=a.title}if(!t){r=e.src.slice(p,m);const v=[];e.md.inline.parse(r,e.md,e.env,v);const b=e.push("image","img",0),w=[["src",c],["alt",""]];b.attrs=w,b.children=v,b.content=r,u&&w.push(["title",u])}return e.pos=o,e.posMax=h,!0}const xYe=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,wYe=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function _Ye(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;const r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;const a=e.src.charCodeAt(n);if(a===60)return!1;if(a===62)break}const o=e.src.slice(r+1,n);if(wYe.test(o)){const a=e.md.normalizeLink(o);if(!e.md.validateLink(a))return!1;if(!t){const s=e.push("link_open","a",1);s.attrs=[["href",a]],s.markup="autolink",s.info="auto";const u=e.push("text","",0);u.content=e.md.normalizeLinkText(o);const l=e.push("link_close","a",-1);l.markup="autolink",l.info="auto"}return e.pos+=o.length+2,!0}if(xYe.test(o)){const a=e.md.normalizeLink("mailto:"+o);if(!e.md.validateLink(a))return!1;if(!t){const s=e.push("link_open","a",1);s.attrs=[["href",a]],s.markup="autolink",s.info="auto";const u=e.push("text","",0);u.content=e.md.normalizeLinkText(o);const l=e.push("link_close","a",-1);l.markup="autolink",l.info="auto"}return e.pos+=o.length+2,!0}return!1}function SYe(e){return/^\s]/i.test(e)}function CYe(e){return/^<\/a\s*>/i.test(e)}function EYe(e){const t=e|32;return t>=97&&t<=122}function OYe(e,t){if(!e.md.options.html)return!1;const n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;const i=e.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!EYe(i))return!1;const o=e.src.slice(r).match(tYe);if(!o)return!1;if(!t){const a=e.push("html_inline","",0);a.content=o[0],SYe(a.content)&&e.linkLevel++,CYe(a.content)&&e.linkLevel--}return e.pos+=o[0].length,!0}const AYe=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,PYe=/^&([a-z][a-z0-9]{1,31});/i;function kYe(e,t){const n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){const o=e.src.slice(n).match(AYe);if(o){if(!t){const a=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0);s.content=BP(a)?Mx(a):Mx(65533),s.markup=o[0],s.info="entity"}return e.pos+=o[0].length,!0}}else{const o=e.src.slice(n).match(PYe);if(o){const a=gZ(o[0]);if(a!==o[0]){if(!t){const s=e.push("text_special","",0);s.content=a,s.markup=o[0],s.info="entity"}return e.pos+=o[0].length,!0}}}return!1}function DN(e){const t={},n=e.length;if(!n)return;let r=0,i=-2;const o=[];for(let a=0;au;l-=o[l]+1){const f=e[l];if(f.marker===s.marker&&f.open&&f.end<0){let h=!1;if((f.close||s.open)&&(f.length+s.length)%3===0&&(f.length%3!==0||s.length%3!==0)&&(h=!0),!h){const p=l>0&&!e[l-1].open?o[l-1]+1:0;o[a]=a-l+p,o[l]=p,s.open=!1,f.end=a,f.close=!1,c=-1,i=-2;break}}}c!==-1&&(t[s.marker][(s.open?3:0)+(s.length||0)%3]=c)}}function TYe(e){const t=e.tokens_meta,n=e.tokens_meta.length;DN(e.delimiters);for(let r=0;r0&&r++,i[t].type==="text"&&t+1=e.pos)throw new Error("inline rule didn't increment state.pos");break}}else e.pos=e.posMax;a||e.pos++,o[t]=e.pos};nv.prototype.tokenize=function(e){const t=this.ruler.getRules(""),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos=e.pos)throw new Error("inline rule didn't increment state.pos");break}}if(a){if(e.pos>=r)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()};nv.prototype.parse=function(e,t,n,r){const i=new this.State(e,t,n,r);this.tokenize(i);const o=this.ruler2.getRules(""),a=o.length;for(let s=0;s|$))",t.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}function N4(e){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){e[r]=n[r]})}),e}function R2(e){return Object.prototype.toString.call(e)}function DYe(e){return R2(e)==="[object String]"}function $Ye(e){return R2(e)==="[object Object]"}function IYe(e){return R2(e)==="[object RegExp]"}function $N(e){return R2(e)==="[object Function]"}function NYe(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const CZ={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function LYe(e){return Object.keys(e||{}).reduce(function(t,n){return t||CZ.hasOwnProperty(n)},!1)}const FYe={"http:":{validate:function(e,t,n){const r=e.slice(t);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const r=e.slice(t);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?t>=3&&e[t-3]===":"||t>=3&&e[t-3]==="/"?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const r=e.slice(t);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},jYe="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",BYe="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function zYe(e){e.__index__=-1,e.__text_cache__=""}function UYe(e){return function(t,n){const r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function IN(){return function(e,t){t.normalize(e)}}function Rx(e){const t=e.re=RYe(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(jYe),n.push(t.src_xn),t.src_tlds=n.join("|");function r(s){return s.replace("%TLDS%",t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),"i");const i=[];e.__compiled__={};function o(s,u){throw new Error('(LinkifyIt) Invalid schema "'+s+'": '+u)}Object.keys(e.__schemas__).forEach(function(s){const u=e.__schemas__[s];if(u===null)return;const l={validate:null,link:null};if(e.__compiled__[s]=l,$Ye(u)){IYe(u.validate)?l.validate=UYe(u.validate):$N(u.validate)?l.validate=u.validate:o(s,u),$N(u.normalize)?l.normalize=u.normalize:u.normalize?o(s,u):l.normalize=IN();return}if(DYe(u)){i.push(s);return}o(s,u)}),i.forEach(function(s){e.__compiled__[e.__schemas__[s]]&&(e.__compiled__[s].validate=e.__compiled__[e.__schemas__[s]].validate,e.__compiled__[s].normalize=e.__compiled__[e.__schemas__[s]].normalize)}),e.__compiled__[""]={validate:null,normalize:IN()};const a=Object.keys(e.__compiled__).filter(function(s){return s.length>0&&e.__compiled__[s]}).map(NYe).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+a+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+a+")","ig"),e.re.schema_at_start=RegExp("^"+e.re.schema_search.source,"i"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),zYe(e)}function VYe(e,t){const n=e.__index__,r=e.__last_index__,i=e.__text_cache__.slice(n,r);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=r+t,this.raw=i,this.text=i,this.url=i}function L4(e,t){const n=new VYe(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function Ho(e,t){if(!(this instanceof Ho))return new Ho(e,t);t||LYe(e)&&(t=e,e={}),this.__opts__=N4({},CZ,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=N4({},FYe,e),this.__compiled__={},this.__tlds__=BYe,this.__tlds_replaced__=!1,this.re={},Rx(this)}Ho.prototype.add=function(t,n){return this.__schemas__[t]=n,Rx(this),this};Ho.prototype.set=function(t){return this.__opts__=N4(this.__opts__,t),this};Ho.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;let n,r,i,o,a,s,u,l,c;if(this.re.schema_test.test(t)){for(u=this.re.schema_search,u.lastIndex=0;(n=u.exec(t))!==null;)if(o=this.testSchemaAt(t,n[2],u.lastIndex),o){this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(l=t.search(this.re.host_fuzzy_test),l>=0&&(this.__index__<0||l=0&&(i=t.match(this.re.email_fuzzy))!==null&&(a=i.index+i[1].length,s=i.index+i[0].length,(this.__index__<0||athis.__last_index__)&&(this.__schema__="mailto:",this.__index__=a,this.__last_index__=s))),this.__index__>=0};Ho.prototype.pretest=function(t){return this.re.pretest.test(t)};Ho.prototype.testSchemaAt=function(t,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(t,r,this):0};Ho.prototype.match=function(t){const n=[];let r=0;this.__index__>=0&&this.__text_cache__===t&&(n.push(L4(this,r)),r=this.__last_index__);let i=r?t.slice(r):t;for(;this.test(i);)n.push(L4(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return n.length?n:null};Ho.prototype.matchAtStart=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return null;const n=this.re.schema_at_start.exec(t);if(!n)return null;const r=this.testSchemaAt(t,n[2],n[0].length);return r?(this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+r,L4(this,0)):null};Ho.prototype.tlds=function(t,n){return t=Array.isArray(t)?t:[t],n?(this.__tlds__=this.__tlds__.concat(t).sort().filter(function(r,i,o){return r!==o[i-1]}).reverse(),Rx(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,Rx(this),this)};Ho.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),t.schema==="mailto:"&&!/^mailto:/i.test(t.url)&&(t.url="mailto:"+t.url)};Ho.prototype.onCompile=function(){};const zd=2147483647,_s=36,VP=1,gm=26,WYe=38,HYe=700,EZ=72,OZ=128,AZ="-",KYe=/^xn--/,qYe=/[^\0-\x7F]/,GYe=/[\x2E\u3002\uFF0E\uFF61]/g,YYe={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},G3=_s-VP,Ss=Math.floor,Y3=String.fromCharCode;function el(e){throw new RangeError(YYe[e])}function ZYe(e,t){const n=[];let r=e.length;for(;r--;)n[r]=t(e[r]);return n}function PZ(e,t){const n=e.split("@");let r="";n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(GYe,".");const i=e.split("."),o=ZYe(i,t).join(".");return r+o}function kZ(e){const t=[];let n=0;const r=e.length;for(;n=55296&&i<=56319&&nString.fromCodePoint(...e),QYe=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:_s},NN=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},TZ=function(e,t,n){let r=0;for(e=n?Ss(e/HYe):e>>1,e+=Ss(e/t);e>G3*gm>>1;r+=_s)e=Ss(e/G3);return Ss(r+(G3+1)*e/(e+WYe))},MZ=function(e){const t=[],n=e.length;let r=0,i=OZ,o=EZ,a=e.lastIndexOf(AZ);a<0&&(a=0);for(let s=0;s=128&&el("not-basic"),t.push(e.charCodeAt(s));for(let s=a>0?a+1:0;s=n&&el("invalid-input");const h=QYe(e.charCodeAt(s++));h>=_s&&el("invalid-input"),h>Ss((zd-r)/c)&&el("overflow"),r+=h*c;const p=f<=o?VP:f>=o+gm?gm:f-o;if(hSs(zd/m)&&el("overflow"),c*=m}const l=t.length+1;o=TZ(r-u,l,u==0),Ss(r/l)>zd-i&&el("overflow"),i+=Ss(r/l),r%=l,t.splice(r++,0,i)}return String.fromCodePoint(...t)},RZ=function(e){const t=[];e=kZ(e);const n=e.length;let r=OZ,i=0,o=EZ;for(const u of e)u<128&&t.push(Y3(u));const a=t.length;let s=a;for(a&&t.push(AZ);s=r&&cSs((zd-i)/l)&&el("overflow"),i+=(u-r)*l,r=u;for(const c of e)if(czd&&el("overflow"),c===r){let f=i;for(let h=_s;;h+=_s){const p=h<=o?VP:h>=o+gm?gm:h-o;if(f=0))try{t.hostname=DZ.toASCII(t.hostname)}catch{}return ev(NP(t))}function lZe(e){const t=LP(e,!0);if(t.hostname&&(!t.protocol||$Z.indexOf(t.protocol)>=0))try{t.hostname=DZ.toUnicode(t.hostname)}catch{}return kh(NP(t),kh.defaultChars+"%")}function ts(e,t){if(!(this instanceof ts))return new ts(e,t);t||jP(e)||(t=e||{},e="default"),this.inline=new nv,this.block=new M2,this.core=new zP,this.renderer=new sp,this.linkify=new Ho,this.validateLink=sZe,this.normalizeLink=uZe,this.normalizeLinkText=lZe,this.utils=fGe,this.helpers=k2({},gGe),this.options={},this.configure(e),t&&this.set(t)}ts.prototype.set=function(e){return k2(this.options,e),this};ts.prototype.configure=function(e){const t=this;if(jP(e)){const n=e;if(e=iZe[n],!e)throw new Error('Wrong `markdown-it` preset "'+n+'", check name')}if(!e)throw new Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach(function(n){e.components[n].rules&&t[n].ruler.enableOnly(e.components[n].rules),e.components[n].rules2&&t[n].ruler2.enableOnly(e.components[n].rules2)}),this};ts.prototype.enable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.enable(e,!0))},this),n=n.concat(this.inline.ruler2.enable(e,!0));const r=e.filter(function(i){return n.indexOf(i)<0});if(r.length&&!t)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this};ts.prototype.disable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.disable(e,!0))},this),n=n.concat(this.inline.ruler2.disable(e,!0));const r=e.filter(function(i){return n.indexOf(i)<0});if(r.length&&!t)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this};ts.prototype.use=function(e){const t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this};ts.prototype.parse=function(e,t){if(typeof e!="string")throw new Error("Input data should be a String");const n=new this.core.State(e,this,t);return this.core.process(n),n.tokens};ts.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)};ts.prototype.parseInline=function(e,t){const n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens};ts.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var IZ={exports:{}};(function(e){(function(t){var n=function(T){var D,$=new Float64Array(16);if(T)for(D=0;D>24&255,T[D+1]=$>>16&255,T[D+2]=$>>8&255,T[D+3]=$&255,T[D+4]=A>>24&255,T[D+5]=A>>16&255,T[D+6]=A>>8&255,T[D+7]=A&255}function v(T,D,$,A,L){var Q,te=0;for(Q=0;Q>>8)-1}function b(T,D,$,A){return v(T,D,$,A,16)}function w(T,D,$,A){return v(T,D,$,A,32)}function x(T,D,$,A){for(var L=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,Q=$[0]&255|($[1]&255)<<8|($[2]&255)<<16|($[3]&255)<<24,te=$[4]&255|($[5]&255)<<8|($[6]&255)<<16|($[7]&255)<<24,fe=$[8]&255|($[9]&255)<<8|($[10]&255)<<16|($[11]&255)<<24,_e=$[12]&255|($[13]&255)<<8|($[14]&255)<<16|($[15]&255)<<24,je=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,We=D[0]&255|(D[1]&255)<<8|(D[2]&255)<<16|(D[3]&255)<<24,ct=D[4]&255|(D[5]&255)<<8|(D[6]&255)<<16|(D[7]&255)<<24,Ie=D[8]&255|(D[9]&255)<<8|(D[10]&255)<<16|(D[11]&255)<<24,nt=D[12]&255|(D[13]&255)<<8|(D[14]&255)<<16|(D[15]&255)<<24,bt=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Ot=$[16]&255|($[17]&255)<<8|($[18]&255)<<16|($[19]&255)<<24,gt=$[20]&255|($[21]&255)<<8|($[22]&255)<<16|($[23]&255)<<24,ht=$[24]&255|($[25]&255)<<8|($[26]&255)<<16|($[27]&255)<<24,xt=$[28]&255|($[29]&255)<<8|($[30]&255)<<16|($[31]&255)<<24,wt=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Qe=L,ut=Q,Xe=te,Ne=fe,Ke=_e,Ge=je,pe=We,he=ct,Re=Ie,Oe=nt,Pe=bt,Be=Ot,vt=gt,Lt=ht,Ft=xt,$t=wt,J,Zt=0;Zt<20;Zt+=2)J=Qe+vt|0,Ke^=J<<7|J>>>25,J=Ke+Qe|0,Re^=J<<9|J>>>23,J=Re+Ke|0,vt^=J<<13|J>>>19,J=vt+Re|0,Qe^=J<<18|J>>>14,J=Ge+ut|0,Oe^=J<<7|J>>>25,J=Oe+Ge|0,Lt^=J<<9|J>>>23,J=Lt+Oe|0,ut^=J<<13|J>>>19,J=ut+Lt|0,Ge^=J<<18|J>>>14,J=Pe+pe|0,Ft^=J<<7|J>>>25,J=Ft+Pe|0,Xe^=J<<9|J>>>23,J=Xe+Ft|0,pe^=J<<13|J>>>19,J=pe+Xe|0,Pe^=J<<18|J>>>14,J=$t+Be|0,Ne^=J<<7|J>>>25,J=Ne+$t|0,he^=J<<9|J>>>23,J=he+Ne|0,Be^=J<<13|J>>>19,J=Be+he|0,$t^=J<<18|J>>>14,J=Qe+Ne|0,ut^=J<<7|J>>>25,J=ut+Qe|0,Xe^=J<<9|J>>>23,J=Xe+ut|0,Ne^=J<<13|J>>>19,J=Ne+Xe|0,Qe^=J<<18|J>>>14,J=Ge+Ke|0,pe^=J<<7|J>>>25,J=pe+Ge|0,he^=J<<9|J>>>23,J=he+pe|0,Ke^=J<<13|J>>>19,J=Ke+he|0,Ge^=J<<18|J>>>14,J=Pe+Oe|0,Be^=J<<7|J>>>25,J=Be+Pe|0,Re^=J<<9|J>>>23,J=Re+Be|0,Oe^=J<<13|J>>>19,J=Oe+Re|0,Pe^=J<<18|J>>>14,J=$t+Ft|0,vt^=J<<7|J>>>25,J=vt+$t|0,Lt^=J<<9|J>>>23,J=Lt+vt|0,Ft^=J<<13|J>>>19,J=Ft+Lt|0,$t^=J<<18|J>>>14;Qe=Qe+L|0,ut=ut+Q|0,Xe=Xe+te|0,Ne=Ne+fe|0,Ke=Ke+_e|0,Ge=Ge+je|0,pe=pe+We|0,he=he+ct|0,Re=Re+Ie|0,Oe=Oe+nt|0,Pe=Pe+bt|0,Be=Be+Ot|0,vt=vt+gt|0,Lt=Lt+ht|0,Ft=Ft+xt|0,$t=$t+wt|0,T[0]=Qe>>>0&255,T[1]=Qe>>>8&255,T[2]=Qe>>>16&255,T[3]=Qe>>>24&255,T[4]=ut>>>0&255,T[5]=ut>>>8&255,T[6]=ut>>>16&255,T[7]=ut>>>24&255,T[8]=Xe>>>0&255,T[9]=Xe>>>8&255,T[10]=Xe>>>16&255,T[11]=Xe>>>24&255,T[12]=Ne>>>0&255,T[13]=Ne>>>8&255,T[14]=Ne>>>16&255,T[15]=Ne>>>24&255,T[16]=Ke>>>0&255,T[17]=Ke>>>8&255,T[18]=Ke>>>16&255,T[19]=Ke>>>24&255,T[20]=Ge>>>0&255,T[21]=Ge>>>8&255,T[22]=Ge>>>16&255,T[23]=Ge>>>24&255,T[24]=pe>>>0&255,T[25]=pe>>>8&255,T[26]=pe>>>16&255,T[27]=pe>>>24&255,T[28]=he>>>0&255,T[29]=he>>>8&255,T[30]=he>>>16&255,T[31]=he>>>24&255,T[32]=Re>>>0&255,T[33]=Re>>>8&255,T[34]=Re>>>16&255,T[35]=Re>>>24&255,T[36]=Oe>>>0&255,T[37]=Oe>>>8&255,T[38]=Oe>>>16&255,T[39]=Oe>>>24&255,T[40]=Pe>>>0&255,T[41]=Pe>>>8&255,T[42]=Pe>>>16&255,T[43]=Pe>>>24&255,T[44]=Be>>>0&255,T[45]=Be>>>8&255,T[46]=Be>>>16&255,T[47]=Be>>>24&255,T[48]=vt>>>0&255,T[49]=vt>>>8&255,T[50]=vt>>>16&255,T[51]=vt>>>24&255,T[52]=Lt>>>0&255,T[53]=Lt>>>8&255,T[54]=Lt>>>16&255,T[55]=Lt>>>24&255,T[56]=Ft>>>0&255,T[57]=Ft>>>8&255,T[58]=Ft>>>16&255,T[59]=Ft>>>24&255,T[60]=$t>>>0&255,T[61]=$t>>>8&255,T[62]=$t>>>16&255,T[63]=$t>>>24&255}function S(T,D,$,A){for(var L=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,Q=$[0]&255|($[1]&255)<<8|($[2]&255)<<16|($[3]&255)<<24,te=$[4]&255|($[5]&255)<<8|($[6]&255)<<16|($[7]&255)<<24,fe=$[8]&255|($[9]&255)<<8|($[10]&255)<<16|($[11]&255)<<24,_e=$[12]&255|($[13]&255)<<8|($[14]&255)<<16|($[15]&255)<<24,je=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,We=D[0]&255|(D[1]&255)<<8|(D[2]&255)<<16|(D[3]&255)<<24,ct=D[4]&255|(D[5]&255)<<8|(D[6]&255)<<16|(D[7]&255)<<24,Ie=D[8]&255|(D[9]&255)<<8|(D[10]&255)<<16|(D[11]&255)<<24,nt=D[12]&255|(D[13]&255)<<8|(D[14]&255)<<16|(D[15]&255)<<24,bt=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Ot=$[16]&255|($[17]&255)<<8|($[18]&255)<<16|($[19]&255)<<24,gt=$[20]&255|($[21]&255)<<8|($[22]&255)<<16|($[23]&255)<<24,ht=$[24]&255|($[25]&255)<<8|($[26]&255)<<16|($[27]&255)<<24,xt=$[28]&255|($[29]&255)<<8|($[30]&255)<<16|($[31]&255)<<24,wt=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Qe=L,ut=Q,Xe=te,Ne=fe,Ke=_e,Ge=je,pe=We,he=ct,Re=Ie,Oe=nt,Pe=bt,Be=Ot,vt=gt,Lt=ht,Ft=xt,$t=wt,J,Zt=0;Zt<20;Zt+=2)J=Qe+vt|0,Ke^=J<<7|J>>>25,J=Ke+Qe|0,Re^=J<<9|J>>>23,J=Re+Ke|0,vt^=J<<13|J>>>19,J=vt+Re|0,Qe^=J<<18|J>>>14,J=Ge+ut|0,Oe^=J<<7|J>>>25,J=Oe+Ge|0,Lt^=J<<9|J>>>23,J=Lt+Oe|0,ut^=J<<13|J>>>19,J=ut+Lt|0,Ge^=J<<18|J>>>14,J=Pe+pe|0,Ft^=J<<7|J>>>25,J=Ft+Pe|0,Xe^=J<<9|J>>>23,J=Xe+Ft|0,pe^=J<<13|J>>>19,J=pe+Xe|0,Pe^=J<<18|J>>>14,J=$t+Be|0,Ne^=J<<7|J>>>25,J=Ne+$t|0,he^=J<<9|J>>>23,J=he+Ne|0,Be^=J<<13|J>>>19,J=Be+he|0,$t^=J<<18|J>>>14,J=Qe+Ne|0,ut^=J<<7|J>>>25,J=ut+Qe|0,Xe^=J<<9|J>>>23,J=Xe+ut|0,Ne^=J<<13|J>>>19,J=Ne+Xe|0,Qe^=J<<18|J>>>14,J=Ge+Ke|0,pe^=J<<7|J>>>25,J=pe+Ge|0,he^=J<<9|J>>>23,J=he+pe|0,Ke^=J<<13|J>>>19,J=Ke+he|0,Ge^=J<<18|J>>>14,J=Pe+Oe|0,Be^=J<<7|J>>>25,J=Be+Pe|0,Re^=J<<9|J>>>23,J=Re+Be|0,Oe^=J<<13|J>>>19,J=Oe+Re|0,Pe^=J<<18|J>>>14,J=$t+Ft|0,vt^=J<<7|J>>>25,J=vt+$t|0,Lt^=J<<9|J>>>23,J=Lt+vt|0,Ft^=J<<13|J>>>19,J=Ft+Lt|0,$t^=J<<18|J>>>14;T[0]=Qe>>>0&255,T[1]=Qe>>>8&255,T[2]=Qe>>>16&255,T[3]=Qe>>>24&255,T[4]=Ge>>>0&255,T[5]=Ge>>>8&255,T[6]=Ge>>>16&255,T[7]=Ge>>>24&255,T[8]=Pe>>>0&255,T[9]=Pe>>>8&255,T[10]=Pe>>>16&255,T[11]=Pe>>>24&255,T[12]=$t>>>0&255,T[13]=$t>>>8&255,T[14]=$t>>>16&255,T[15]=$t>>>24&255,T[16]=pe>>>0&255,T[17]=pe>>>8&255,T[18]=pe>>>16&255,T[19]=pe>>>24&255,T[20]=he>>>0&255,T[21]=he>>>8&255,T[22]=he>>>16&255,T[23]=he>>>24&255,T[24]=Re>>>0&255,T[25]=Re>>>8&255,T[26]=Re>>>16&255,T[27]=Re>>>24&255,T[28]=Oe>>>0&255,T[29]=Oe>>>8&255,T[30]=Oe>>>16&255,T[31]=Oe>>>24&255}function O(T,D,$,A){x(T,D,$,A)}function E(T,D,$,A){S(T,D,$,A)}var C=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function P(T,D,$,A,L,Q,te){var fe=new Uint8Array(16),_e=new Uint8Array(64),je,We;for(We=0;We<16;We++)fe[We]=0;for(We=0;We<8;We++)fe[We]=Q[We];for(;L>=64;){for(O(_e,fe,te,C),We=0;We<64;We++)T[D+We]=$[A+We]^_e[We];for(je=1,We=8;We<16;We++)je=je+(fe[We]&255)|0,fe[We]=je&255,je>>>=8;L-=64,D+=64,A+=64}if(L>0)for(O(_e,fe,te,C),We=0;We=64;){for(O(te,Q,L,C),_e=0;_e<64;_e++)T[D+_e]=te[_e];for(fe=1,_e=8;_e<16;_e++)fe=fe+(Q[_e]&255)|0,Q[_e]=fe&255,fe>>>=8;$-=64,D+=64}if($>0)for(O(te,Q,L,C),_e=0;_e<$;_e++)T[D+_e]=te[_e];return 0}function I(T,D,$,A,L){var Q=new Uint8Array(32);E(Q,A,L,C);for(var te=new Uint8Array(8),fe=0;fe<8;fe++)te[fe]=A[fe+16];return M(T,D,$,te,Q)}function B(T,D,$,A,L,Q,te){var fe=new Uint8Array(32);E(fe,Q,te,C);for(var _e=new Uint8Array(8),je=0;je<8;je++)_e[je]=Q[je+16];return P(T,D,$,A,L,_e,fe)}var W=function(T){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var D,$,A,L,Q,te,fe,_e;D=T[0]&255|(T[1]&255)<<8,this.r[0]=D&8191,$=T[2]&255|(T[3]&255)<<8,this.r[1]=(D>>>13|$<<3)&8191,A=T[4]&255|(T[5]&255)<<8,this.r[2]=($>>>10|A<<6)&7939,L=T[6]&255|(T[7]&255)<<8,this.r[3]=(A>>>7|L<<9)&8191,Q=T[8]&255|(T[9]&255)<<8,this.r[4]=(L>>>4|Q<<12)&255,this.r[5]=Q>>>1&8190,te=T[10]&255|(T[11]&255)<<8,this.r[6]=(Q>>>14|te<<2)&8191,fe=T[12]&255|(T[13]&255)<<8,this.r[7]=(te>>>11|fe<<5)&8065,_e=T[14]&255|(T[15]&255)<<8,this.r[8]=(fe>>>8|_e<<8)&8191,this.r[9]=_e>>>5&127,this.pad[0]=T[16]&255|(T[17]&255)<<8,this.pad[1]=T[18]&255|(T[19]&255)<<8,this.pad[2]=T[20]&255|(T[21]&255)<<8,this.pad[3]=T[22]&255|(T[23]&255)<<8,this.pad[4]=T[24]&255|(T[25]&255)<<8,this.pad[5]=T[26]&255|(T[27]&255)<<8,this.pad[6]=T[28]&255|(T[29]&255)<<8,this.pad[7]=T[30]&255|(T[31]&255)<<8};W.prototype.blocks=function(T,D,$){for(var A=this.fin?0:2048,L,Q,te,fe,_e,je,We,ct,Ie,nt,bt,Ot,gt,ht,xt,wt,Qe,ut,Xe,Ne=this.h[0],Ke=this.h[1],Ge=this.h[2],pe=this.h[3],he=this.h[4],Re=this.h[5],Oe=this.h[6],Pe=this.h[7],Be=this.h[8],vt=this.h[9],Lt=this.r[0],Ft=this.r[1],$t=this.r[2],J=this.r[3],Zt=this.r[4],sn=this.r[5],un=this.r[6],jt=this.r[7],ln=this.r[8],rn=this.r[9];$>=16;)L=T[D+0]&255|(T[D+1]&255)<<8,Ne+=L&8191,Q=T[D+2]&255|(T[D+3]&255)<<8,Ke+=(L>>>13|Q<<3)&8191,te=T[D+4]&255|(T[D+5]&255)<<8,Ge+=(Q>>>10|te<<6)&8191,fe=T[D+6]&255|(T[D+7]&255)<<8,pe+=(te>>>7|fe<<9)&8191,_e=T[D+8]&255|(T[D+9]&255)<<8,he+=(fe>>>4|_e<<12)&8191,Re+=_e>>>1&8191,je=T[D+10]&255|(T[D+11]&255)<<8,Oe+=(_e>>>14|je<<2)&8191,We=T[D+12]&255|(T[D+13]&255)<<8,Pe+=(je>>>11|We<<5)&8191,ct=T[D+14]&255|(T[D+15]&255)<<8,Be+=(We>>>8|ct<<8)&8191,vt+=ct>>>5|A,Ie=0,nt=Ie,nt+=Ne*Lt,nt+=Ke*(5*rn),nt+=Ge*(5*ln),nt+=pe*(5*jt),nt+=he*(5*un),Ie=nt>>>13,nt&=8191,nt+=Re*(5*sn),nt+=Oe*(5*Zt),nt+=Pe*(5*J),nt+=Be*(5*$t),nt+=vt*(5*Ft),Ie+=nt>>>13,nt&=8191,bt=Ie,bt+=Ne*Ft,bt+=Ke*Lt,bt+=Ge*(5*rn),bt+=pe*(5*ln),bt+=he*(5*jt),Ie=bt>>>13,bt&=8191,bt+=Re*(5*un),bt+=Oe*(5*sn),bt+=Pe*(5*Zt),bt+=Be*(5*J),bt+=vt*(5*$t),Ie+=bt>>>13,bt&=8191,Ot=Ie,Ot+=Ne*$t,Ot+=Ke*Ft,Ot+=Ge*Lt,Ot+=pe*(5*rn),Ot+=he*(5*ln),Ie=Ot>>>13,Ot&=8191,Ot+=Re*(5*jt),Ot+=Oe*(5*un),Ot+=Pe*(5*sn),Ot+=Be*(5*Zt),Ot+=vt*(5*J),Ie+=Ot>>>13,Ot&=8191,gt=Ie,gt+=Ne*J,gt+=Ke*$t,gt+=Ge*Ft,gt+=pe*Lt,gt+=he*(5*rn),Ie=gt>>>13,gt&=8191,gt+=Re*(5*ln),gt+=Oe*(5*jt),gt+=Pe*(5*un),gt+=Be*(5*sn),gt+=vt*(5*Zt),Ie+=gt>>>13,gt&=8191,ht=Ie,ht+=Ne*Zt,ht+=Ke*J,ht+=Ge*$t,ht+=pe*Ft,ht+=he*Lt,Ie=ht>>>13,ht&=8191,ht+=Re*(5*rn),ht+=Oe*(5*ln),ht+=Pe*(5*jt),ht+=Be*(5*un),ht+=vt*(5*sn),Ie+=ht>>>13,ht&=8191,xt=Ie,xt+=Ne*sn,xt+=Ke*Zt,xt+=Ge*J,xt+=pe*$t,xt+=he*Ft,Ie=xt>>>13,xt&=8191,xt+=Re*Lt,xt+=Oe*(5*rn),xt+=Pe*(5*ln),xt+=Be*(5*jt),xt+=vt*(5*un),Ie+=xt>>>13,xt&=8191,wt=Ie,wt+=Ne*un,wt+=Ke*sn,wt+=Ge*Zt,wt+=pe*J,wt+=he*$t,Ie=wt>>>13,wt&=8191,wt+=Re*Ft,wt+=Oe*Lt,wt+=Pe*(5*rn),wt+=Be*(5*ln),wt+=vt*(5*jt),Ie+=wt>>>13,wt&=8191,Qe=Ie,Qe+=Ne*jt,Qe+=Ke*un,Qe+=Ge*sn,Qe+=pe*Zt,Qe+=he*J,Ie=Qe>>>13,Qe&=8191,Qe+=Re*$t,Qe+=Oe*Ft,Qe+=Pe*Lt,Qe+=Be*(5*rn),Qe+=vt*(5*ln),Ie+=Qe>>>13,Qe&=8191,ut=Ie,ut+=Ne*ln,ut+=Ke*jt,ut+=Ge*un,ut+=pe*sn,ut+=he*Zt,Ie=ut>>>13,ut&=8191,ut+=Re*J,ut+=Oe*$t,ut+=Pe*Ft,ut+=Be*Lt,ut+=vt*(5*rn),Ie+=ut>>>13,ut&=8191,Xe=Ie,Xe+=Ne*rn,Xe+=Ke*ln,Xe+=Ge*jt,Xe+=pe*un,Xe+=he*sn,Ie=Xe>>>13,Xe&=8191,Xe+=Re*Zt,Xe+=Oe*J,Xe+=Pe*$t,Xe+=Be*Ft,Xe+=vt*Lt,Ie+=Xe>>>13,Xe&=8191,Ie=(Ie<<2)+Ie|0,Ie=Ie+nt|0,nt=Ie&8191,Ie=Ie>>>13,bt+=Ie,Ne=nt,Ke=bt,Ge=Ot,pe=gt,he=ht,Re=xt,Oe=wt,Pe=Qe,Be=ut,vt=Xe,D+=16,$-=16;this.h[0]=Ne,this.h[1]=Ke,this.h[2]=Ge,this.h[3]=pe,this.h[4]=he,this.h[5]=Re,this.h[6]=Oe,this.h[7]=Pe,this.h[8]=Be,this.h[9]=vt},W.prototype.finish=function(T,D){var $=new Uint16Array(10),A,L,Q,te;if(this.leftover){for(te=this.leftover,this.buffer[te++]=1;te<16;te++)this.buffer[te]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(A=this.h[1]>>>13,this.h[1]&=8191,te=2;te<10;te++)this.h[te]+=A,A=this.h[te]>>>13,this.h[te]&=8191;for(this.h[0]+=A*5,A=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=A,A=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=A,$[0]=this.h[0]+5,A=$[0]>>>13,$[0]&=8191,te=1;te<10;te++)$[te]=this.h[te]+A,A=$[te]>>>13,$[te]&=8191;for($[9]-=8192,L=(A^1)-1,te=0;te<10;te++)$[te]&=L;for(L=~L,te=0;te<10;te++)this.h[te]=this.h[te]&L|$[te];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,Q=this.h[0]+this.pad[0],this.h[0]=Q&65535,te=1;te<8;te++)Q=(this.h[te]+this.pad[te]|0)+(Q>>>16)|0,this.h[te]=Q&65535;T[D+0]=this.h[0]>>>0&255,T[D+1]=this.h[0]>>>8&255,T[D+2]=this.h[1]>>>0&255,T[D+3]=this.h[1]>>>8&255,T[D+4]=this.h[2]>>>0&255,T[D+5]=this.h[2]>>>8&255,T[D+6]=this.h[3]>>>0&255,T[D+7]=this.h[3]>>>8&255,T[D+8]=this.h[4]>>>0&255,T[D+9]=this.h[4]>>>8&255,T[D+10]=this.h[5]>>>0&255,T[D+11]=this.h[5]>>>8&255,T[D+12]=this.h[6]>>>0&255,T[D+13]=this.h[6]>>>8&255,T[D+14]=this.h[7]>>>0&255,T[D+15]=this.h[7]>>>8&255},W.prototype.update=function(T,D,$){var A,L;if(this.leftover){for(L=16-this.leftover,L>$&&(L=$),A=0;A=16&&(L=$-$%16,this.blocks(T,D,L),D+=L,$-=L),$){for(A=0;A<$;A++)this.buffer[this.leftover+A]=T[D+A];this.leftover+=$}};function V(T,D,$,A,L,Q){var te=new W(Q);return te.update($,A,L),te.finish(T,D),0}function ee(T,D,$,A,L,Q){var te=new Uint8Array(16);return V(te,0,$,A,L,Q),b(T,D,te,0)}function Z(T,D,$,A,L){var Q;if($<32)return-1;for(B(T,0,D,0,$,A,L),V(T,16,T,32,$-32,T),Q=0;Q<16;Q++)T[Q]=0;return 0}function K(T,D,$,A,L){var Q,te=new Uint8Array(32);if($<32||(I(te,0,32,A,L),ee(D,16,D,32,$-32,te)!==0))return-1;for(B(T,0,D,0,$,A,L),Q=0;Q<32;Q++)T[Q]=0;return 0}function G(T,D){var $;for($=0;$<16;$++)T[$]=D[$]|0}function H(T){var D,$,A=1;for(D=0;D<16;D++)$=T[D]+A+65535,A=Math.floor($/65536),T[D]=$-A*65536;T[0]+=A-1+37*(A-1)}function j(T,D,$){for(var A,L=~($-1),Q=0;Q<16;Q++)A=L&(T[Q]^D[Q]),T[Q]^=A,D[Q]^=A}function q(T,D){var $,A,L,Q=n(),te=n();for($=0;$<16;$++)te[$]=D[$];for(H(te),H(te),H(te),A=0;A<2;A++){for(Q[0]=te[0]-65517,$=1;$<15;$++)Q[$]=te[$]-65535-(Q[$-1]>>16&1),Q[$-1]&=65535;Q[15]=te[15]-32767-(Q[14]>>16&1),L=Q[15]>>16&1,Q[14]&=65535,j(te,Q,1-L)}for($=0;$<16;$++)T[2*$]=te[$]&255,T[2*$+1]=te[$]>>8}function Y(T,D){var $=new Uint8Array(32),A=new Uint8Array(32);return q($,T),q(A,D),w($,0,A,0)}function re(T){var D=new Uint8Array(32);return q(D,T),D[0]&1}function ie(T,D){var $;for($=0;$<16;$++)T[$]=D[2*$]+(D[2*$+1]<<8);T[15]&=32767}function se(T,D,$){for(var A=0;A<16;A++)T[A]=D[A]+$[A]}function ye(T,D,$){for(var A=0;A<16;A++)T[A]=D[A]-$[A]}function we(T,D,$){var A,L,Q=0,te=0,fe=0,_e=0,je=0,We=0,ct=0,Ie=0,nt=0,bt=0,Ot=0,gt=0,ht=0,xt=0,wt=0,Qe=0,ut=0,Xe=0,Ne=0,Ke=0,Ge=0,pe=0,he=0,Re=0,Oe=0,Pe=0,Be=0,vt=0,Lt=0,Ft=0,$t=0,J=$[0],Zt=$[1],sn=$[2],un=$[3],jt=$[4],ln=$[5],rn=$[6],Gn=$[7],mn=$[8],Pn=$[9],Yn=$[10],Zn=$[11],xr=$[12],$r=$[13],Ir=$[14],Nr=$[15];A=D[0],Q+=A*J,te+=A*Zt,fe+=A*sn,_e+=A*un,je+=A*jt,We+=A*ln,ct+=A*rn,Ie+=A*Gn,nt+=A*mn,bt+=A*Pn,Ot+=A*Yn,gt+=A*Zn,ht+=A*xr,xt+=A*$r,wt+=A*Ir,Qe+=A*Nr,A=D[1],te+=A*J,fe+=A*Zt,_e+=A*sn,je+=A*un,We+=A*jt,ct+=A*ln,Ie+=A*rn,nt+=A*Gn,bt+=A*mn,Ot+=A*Pn,gt+=A*Yn,ht+=A*Zn,xt+=A*xr,wt+=A*$r,Qe+=A*Ir,ut+=A*Nr,A=D[2],fe+=A*J,_e+=A*Zt,je+=A*sn,We+=A*un,ct+=A*jt,Ie+=A*ln,nt+=A*rn,bt+=A*Gn,Ot+=A*mn,gt+=A*Pn,ht+=A*Yn,xt+=A*Zn,wt+=A*xr,Qe+=A*$r,ut+=A*Ir,Xe+=A*Nr,A=D[3],_e+=A*J,je+=A*Zt,We+=A*sn,ct+=A*un,Ie+=A*jt,nt+=A*ln,bt+=A*rn,Ot+=A*Gn,gt+=A*mn,ht+=A*Pn,xt+=A*Yn,wt+=A*Zn,Qe+=A*xr,ut+=A*$r,Xe+=A*Ir,Ne+=A*Nr,A=D[4],je+=A*J,We+=A*Zt,ct+=A*sn,Ie+=A*un,nt+=A*jt,bt+=A*ln,Ot+=A*rn,gt+=A*Gn,ht+=A*mn,xt+=A*Pn,wt+=A*Yn,Qe+=A*Zn,ut+=A*xr,Xe+=A*$r,Ne+=A*Ir,Ke+=A*Nr,A=D[5],We+=A*J,ct+=A*Zt,Ie+=A*sn,nt+=A*un,bt+=A*jt,Ot+=A*ln,gt+=A*rn,ht+=A*Gn,xt+=A*mn,wt+=A*Pn,Qe+=A*Yn,ut+=A*Zn,Xe+=A*xr,Ne+=A*$r,Ke+=A*Ir,Ge+=A*Nr,A=D[6],ct+=A*J,Ie+=A*Zt,nt+=A*sn,bt+=A*un,Ot+=A*jt,gt+=A*ln,ht+=A*rn,xt+=A*Gn,wt+=A*mn,Qe+=A*Pn,ut+=A*Yn,Xe+=A*Zn,Ne+=A*xr,Ke+=A*$r,Ge+=A*Ir,pe+=A*Nr,A=D[7],Ie+=A*J,nt+=A*Zt,bt+=A*sn,Ot+=A*un,gt+=A*jt,ht+=A*ln,xt+=A*rn,wt+=A*Gn,Qe+=A*mn,ut+=A*Pn,Xe+=A*Yn,Ne+=A*Zn,Ke+=A*xr,Ge+=A*$r,pe+=A*Ir,he+=A*Nr,A=D[8],nt+=A*J,bt+=A*Zt,Ot+=A*sn,gt+=A*un,ht+=A*jt,xt+=A*ln,wt+=A*rn,Qe+=A*Gn,ut+=A*mn,Xe+=A*Pn,Ne+=A*Yn,Ke+=A*Zn,Ge+=A*xr,pe+=A*$r,he+=A*Ir,Re+=A*Nr,A=D[9],bt+=A*J,Ot+=A*Zt,gt+=A*sn,ht+=A*un,xt+=A*jt,wt+=A*ln,Qe+=A*rn,ut+=A*Gn,Xe+=A*mn,Ne+=A*Pn,Ke+=A*Yn,Ge+=A*Zn,pe+=A*xr,he+=A*$r,Re+=A*Ir,Oe+=A*Nr,A=D[10],Ot+=A*J,gt+=A*Zt,ht+=A*sn,xt+=A*un,wt+=A*jt,Qe+=A*ln,ut+=A*rn,Xe+=A*Gn,Ne+=A*mn,Ke+=A*Pn,Ge+=A*Yn,pe+=A*Zn,he+=A*xr,Re+=A*$r,Oe+=A*Ir,Pe+=A*Nr,A=D[11],gt+=A*J,ht+=A*Zt,xt+=A*sn,wt+=A*un,Qe+=A*jt,ut+=A*ln,Xe+=A*rn,Ne+=A*Gn,Ke+=A*mn,Ge+=A*Pn,pe+=A*Yn,he+=A*Zn,Re+=A*xr,Oe+=A*$r,Pe+=A*Ir,Be+=A*Nr,A=D[12],ht+=A*J,xt+=A*Zt,wt+=A*sn,Qe+=A*un,ut+=A*jt,Xe+=A*ln,Ne+=A*rn,Ke+=A*Gn,Ge+=A*mn,pe+=A*Pn,he+=A*Yn,Re+=A*Zn,Oe+=A*xr,Pe+=A*$r,Be+=A*Ir,vt+=A*Nr,A=D[13],xt+=A*J,wt+=A*Zt,Qe+=A*sn,ut+=A*un,Xe+=A*jt,Ne+=A*ln,Ke+=A*rn,Ge+=A*Gn,pe+=A*mn,he+=A*Pn,Re+=A*Yn,Oe+=A*Zn,Pe+=A*xr,Be+=A*$r,vt+=A*Ir,Lt+=A*Nr,A=D[14],wt+=A*J,Qe+=A*Zt,ut+=A*sn,Xe+=A*un,Ne+=A*jt,Ke+=A*ln,Ge+=A*rn,pe+=A*Gn,he+=A*mn,Re+=A*Pn,Oe+=A*Yn,Pe+=A*Zn,Be+=A*xr,vt+=A*$r,Lt+=A*Ir,Ft+=A*Nr,A=D[15],Qe+=A*J,ut+=A*Zt,Xe+=A*sn,Ne+=A*un,Ke+=A*jt,Ge+=A*ln,pe+=A*rn,he+=A*Gn,Re+=A*mn,Oe+=A*Pn,Pe+=A*Yn,Be+=A*Zn,vt+=A*xr,Lt+=A*$r,Ft+=A*Ir,$t+=A*Nr,Q+=38*ut,te+=38*Xe,fe+=38*Ne,_e+=38*Ke,je+=38*Ge,We+=38*pe,ct+=38*he,Ie+=38*Re,nt+=38*Oe,bt+=38*Pe,Ot+=38*Be,gt+=38*vt,ht+=38*Lt,xt+=38*Ft,wt+=38*$t,L=1,A=Q+L+65535,L=Math.floor(A/65536),Q=A-L*65536,A=te+L+65535,L=Math.floor(A/65536),te=A-L*65536,A=fe+L+65535,L=Math.floor(A/65536),fe=A-L*65536,A=_e+L+65535,L=Math.floor(A/65536),_e=A-L*65536,A=je+L+65535,L=Math.floor(A/65536),je=A-L*65536,A=We+L+65535,L=Math.floor(A/65536),We=A-L*65536,A=ct+L+65535,L=Math.floor(A/65536),ct=A-L*65536,A=Ie+L+65535,L=Math.floor(A/65536),Ie=A-L*65536,A=nt+L+65535,L=Math.floor(A/65536),nt=A-L*65536,A=bt+L+65535,L=Math.floor(A/65536),bt=A-L*65536,A=Ot+L+65535,L=Math.floor(A/65536),Ot=A-L*65536,A=gt+L+65535,L=Math.floor(A/65536),gt=A-L*65536,A=ht+L+65535,L=Math.floor(A/65536),ht=A-L*65536,A=xt+L+65535,L=Math.floor(A/65536),xt=A-L*65536,A=wt+L+65535,L=Math.floor(A/65536),wt=A-L*65536,A=Qe+L+65535,L=Math.floor(A/65536),Qe=A-L*65536,Q+=L-1+37*(L-1),L=1,A=Q+L+65535,L=Math.floor(A/65536),Q=A-L*65536,A=te+L+65535,L=Math.floor(A/65536),te=A-L*65536,A=fe+L+65535,L=Math.floor(A/65536),fe=A-L*65536,A=_e+L+65535,L=Math.floor(A/65536),_e=A-L*65536,A=je+L+65535,L=Math.floor(A/65536),je=A-L*65536,A=We+L+65535,L=Math.floor(A/65536),We=A-L*65536,A=ct+L+65535,L=Math.floor(A/65536),ct=A-L*65536,A=Ie+L+65535,L=Math.floor(A/65536),Ie=A-L*65536,A=nt+L+65535,L=Math.floor(A/65536),nt=A-L*65536,A=bt+L+65535,L=Math.floor(A/65536),bt=A-L*65536,A=Ot+L+65535,L=Math.floor(A/65536),Ot=A-L*65536,A=gt+L+65535,L=Math.floor(A/65536),gt=A-L*65536,A=ht+L+65535,L=Math.floor(A/65536),ht=A-L*65536,A=xt+L+65535,L=Math.floor(A/65536),xt=A-L*65536,A=wt+L+65535,L=Math.floor(A/65536),wt=A-L*65536,A=Qe+L+65535,L=Math.floor(A/65536),Qe=A-L*65536,Q+=L-1+37*(L-1),T[0]=Q,T[1]=te,T[2]=fe,T[3]=_e,T[4]=je,T[5]=We,T[6]=ct,T[7]=Ie,T[8]=nt,T[9]=bt,T[10]=Ot,T[11]=gt,T[12]=ht,T[13]=xt,T[14]=wt,T[15]=Qe}function He(T,D){we(T,D,D)}function Ee(T,D){var $=n(),A;for(A=0;A<16;A++)$[A]=D[A];for(A=253;A>=0;A--)He($,$),A!==2&&A!==4&&we($,$,D);for(A=0;A<16;A++)T[A]=$[A]}function it(T,D){var $=n(),A;for(A=0;A<16;A++)$[A]=D[A];for(A=250;A>=0;A--)He($,$),A!==1&&we($,$,D);for(A=0;A<16;A++)T[A]=$[A]}function ke(T,D,$){var A=new Uint8Array(32),L=new Float64Array(80),Q,te,fe=n(),_e=n(),je=n(),We=n(),ct=n(),Ie=n();for(te=0;te<31;te++)A[te]=D[te];for(A[31]=D[31]&127|64,A[0]&=248,ie(L,$),te=0;te<16;te++)_e[te]=L[te],We[te]=fe[te]=je[te]=0;for(fe[0]=We[0]=1,te=254;te>=0;--te)Q=A[te>>>3]>>>(te&7)&1,j(fe,_e,Q),j(je,We,Q),se(ct,fe,je),ye(fe,fe,je),se(je,_e,We),ye(_e,_e,We),He(We,ct),He(Ie,fe),we(fe,je,fe),we(je,_e,ct),se(ct,fe,je),ye(fe,fe,je),He(_e,fe),ye(je,We,Ie),we(fe,je,u),se(fe,fe,We),we(je,je,fe),we(fe,We,Ie),we(We,_e,L),He(_e,ct),j(fe,_e,Q),j(je,We,Q);for(te=0;te<16;te++)L[te+16]=fe[te],L[te+32]=je[te],L[te+48]=_e[te],L[te+64]=We[te];var nt=L.subarray(32),bt=L.subarray(16);return Ee(nt,nt),we(bt,bt,nt),q(T,bt),0}function Le(T,D){return ke(T,D,o)}function De(T,D){return r(D,32),Le(T,D)}function me(T,D,$){var A=new Uint8Array(32);return ke(A,$,D),E(T,i,A,C)}var yt=Z,lt=K;function Nt(T,D,$,A,L,Q){var te=new Uint8Array(32);return me(te,L,Q),yt(T,D,$,A,te)}function bn(T,D,$,A,L,Q){var te=new Uint8Array(32);return me(te,L,Q),lt(T,D,$,A,te)}var nn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ne(T,D,$,A){for(var L=new Int32Array(16),Q=new Int32Array(16),te,fe,_e,je,We,ct,Ie,nt,bt,Ot,gt,ht,xt,wt,Qe,ut,Xe,Ne,Ke,Ge,pe,he,Re,Oe,Pe,Be,vt=T[0],Lt=T[1],Ft=T[2],$t=T[3],J=T[4],Zt=T[5],sn=T[6],un=T[7],jt=D[0],ln=D[1],rn=D[2],Gn=D[3],mn=D[4],Pn=D[5],Yn=D[6],Zn=D[7],xr=0;A>=128;){for(Ke=0;Ke<16;Ke++)Ge=8*Ke+xr,L[Ke]=$[Ge+0]<<24|$[Ge+1]<<16|$[Ge+2]<<8|$[Ge+3],Q[Ke]=$[Ge+4]<<24|$[Ge+5]<<16|$[Ge+6]<<8|$[Ge+7];for(Ke=0;Ke<80;Ke++)if(te=vt,fe=Lt,_e=Ft,je=$t,We=J,ct=Zt,Ie=sn,nt=un,bt=jt,Ot=ln,gt=rn,ht=Gn,xt=mn,wt=Pn,Qe=Yn,ut=Zn,pe=un,he=Zn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=(J>>>14|mn<<18)^(J>>>18|mn<<14)^(mn>>>9|J<<23),he=(mn>>>14|J<<18)^(mn>>>18|J<<14)^(J>>>9|mn<<23),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=J&Zt^~J&sn,he=mn&Pn^~mn&Yn,Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=nn[Ke*2],he=nn[Ke*2+1],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=L[Ke%16],he=Q[Ke%16],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,Xe=Pe&65535|Be<<16,Ne=Re&65535|Oe<<16,pe=Xe,he=Ne,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=(vt>>>28|jt<<4)^(jt>>>2|vt<<30)^(jt>>>7|vt<<25),he=(jt>>>28|vt<<4)^(vt>>>2|jt<<30)^(vt>>>7|jt<<25),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=vt&Lt^vt&Ft^Lt&Ft,he=jt&ln^jt&rn^ln&rn,Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,nt=Pe&65535|Be<<16,ut=Re&65535|Oe<<16,pe=je,he=ht,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=Xe,he=Ne,Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,je=Pe&65535|Be<<16,ht=Re&65535|Oe<<16,Lt=te,Ft=fe,$t=_e,J=je,Zt=We,sn=ct,un=Ie,vt=nt,ln=bt,rn=Ot,Gn=gt,mn=ht,Pn=xt,Yn=wt,Zn=Qe,jt=ut,Ke%16===15)for(Ge=0;Ge<16;Ge++)pe=L[Ge],he=Q[Ge],Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=L[(Ge+9)%16],he=Q[(Ge+9)%16],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Xe=L[(Ge+1)%16],Ne=Q[(Ge+1)%16],pe=(Xe>>>1|Ne<<31)^(Xe>>>8|Ne<<24)^Xe>>>7,he=(Ne>>>1|Xe<<31)^(Ne>>>8|Xe<<24)^(Ne>>>7|Xe<<25),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Xe=L[(Ge+14)%16],Ne=Q[(Ge+14)%16],pe=(Xe>>>19|Ne<<13)^(Ne>>>29|Xe<<3)^Xe>>>6,he=(Ne>>>19|Xe<<13)^(Xe>>>29|Ne<<3)^(Ne>>>6|Xe<<26),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,L[Ge]=Pe&65535|Be<<16,Q[Ge]=Re&65535|Oe<<16;pe=vt,he=jt,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[0],he=D[0],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[0]=vt=Pe&65535|Be<<16,D[0]=jt=Re&65535|Oe<<16,pe=Lt,he=ln,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[1],he=D[1],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[1]=Lt=Pe&65535|Be<<16,D[1]=ln=Re&65535|Oe<<16,pe=Ft,he=rn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[2],he=D[2],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[2]=Ft=Pe&65535|Be<<16,D[2]=rn=Re&65535|Oe<<16,pe=$t,he=Gn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[3],he=D[3],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[3]=$t=Pe&65535|Be<<16,D[3]=Gn=Re&65535|Oe<<16,pe=J,he=mn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[4],he=D[4],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[4]=J=Pe&65535|Be<<16,D[4]=mn=Re&65535|Oe<<16,pe=Zt,he=Pn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[5],he=D[5],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[5]=Zt=Pe&65535|Be<<16,D[5]=Pn=Re&65535|Oe<<16,pe=sn,he=Yn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[6],he=D[6],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[6]=sn=Pe&65535|Be<<16,D[6]=Yn=Re&65535|Oe<<16,pe=un,he=Zn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[7],he=D[7],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[7]=un=Pe&65535|Be<<16,D[7]=Zn=Re&65535|Oe<<16,xr+=128,A-=128}return A}function de(T,D,$){var A=new Int32Array(8),L=new Int32Array(8),Q=new Uint8Array(256),te,fe=$;for(A[0]=1779033703,A[1]=3144134277,A[2]=1013904242,A[3]=2773480762,A[4]=1359893119,A[5]=2600822924,A[6]=528734635,A[7]=1541459225,L[0]=4089235720,L[1]=2227873595,L[2]=4271175723,L[3]=1595750129,L[4]=2917565137,L[5]=725511199,L[6]=4215389547,L[7]=327033209,ne(A,L,D,$),$%=128,te=0;te<$;te++)Q[te]=D[fe-$+te];for(Q[$]=128,$=256-128*($<112?1:0),Q[$-9]=0,m(Q,$-8,fe/536870912|0,fe<<3),ne(A,L,Q,$),te=0;te<8;te++)m(T,8*te,A[te],L[te]);return 0}function ge(T,D){var $=n(),A=n(),L=n(),Q=n(),te=n(),fe=n(),_e=n(),je=n(),We=n();ye($,T[1],T[0]),ye(We,D[1],D[0]),we($,$,We),se(A,T[0],T[1]),se(We,D[0],D[1]),we(A,A,We),we(L,T[3],D[3]),we(L,L,c),we(Q,T[2],D[2]),se(Q,Q,Q),ye(te,A,$),ye(fe,Q,L),se(_e,Q,L),se(je,A,$),we(T[0],te,fe),we(T[1],je,_e),we(T[2],_e,fe),we(T[3],te,je)}function ze(T,D,$){var A;for(A=0;A<4;A++)j(T[A],D[A],$)}function Fe(T,D){var $=n(),A=n(),L=n();Ee(L,D[2]),we($,D[0],L),we(A,D[1],L),q(T,A),T[31]^=re($)<<7}function Ae(T,D,$){var A,L;for(G(T[0],a),G(T[1],s),G(T[2],s),G(T[3],a),L=255;L>=0;--L)A=$[L/8|0]>>(L&7)&1,ze(T,D,A),ge(D,T),ge(T,T),ze(T,D,A)}function tt(T,D){var $=[n(),n(),n(),n()];G($[0],f),G($[1],h),G($[2],s),we($[3],f,h),Ae(T,$,D)}function mt(T,D,$){var A=new Uint8Array(64),L=[n(),n(),n(),n()],Q;for($||r(D,32),de(A,D,32),A[0]&=248,A[31]&=127,A[31]|=64,tt(L,A),Fe(T,L),Q=0;Q<32;Q++)D[Q+32]=T[Q];return 0}var wn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Kt(T,D){var $,A,L,Q;for(A=63;A>=32;--A){for($=0,L=A-32,Q=A-12;L>4)*wn[L],$=D[L]>>8,D[L]&=255;for(L=0;L<32;L++)D[L]-=$*wn[L];for(A=0;A<32;A++)D[A+1]+=D[A]>>8,T[A]=D[A]&255}function _n(T){var D=new Float64Array(64),$;for($=0;$<64;$++)D[$]=T[$];for($=0;$<64;$++)T[$]=0;Kt(T,D)}function Ii(T,D,$,A){var L=new Uint8Array(64),Q=new Uint8Array(64),te=new Uint8Array(64),fe,_e,je=new Float64Array(64),We=[n(),n(),n(),n()];de(L,A,32),L[0]&=248,L[31]&=127,L[31]|=64;var ct=$+64;for(fe=0;fe<$;fe++)T[64+fe]=D[fe];for(fe=0;fe<32;fe++)T[32+fe]=L[32+fe];for(de(te,T.subarray(32),$+32),_n(te),tt(We,te),Fe(T,We),fe=32;fe<64;fe++)T[fe]=A[fe];for(de(Q,T,$+64),_n(Q),fe=0;fe<64;fe++)je[fe]=0;for(fe=0;fe<32;fe++)je[fe]=te[fe];for(fe=0;fe<32;fe++)for(_e=0;_e<32;_e++)je[fe+_e]+=Q[fe]*L[_e];return Kt(T.subarray(32),je),ct}function br(T,D){var $=n(),A=n(),L=n(),Q=n(),te=n(),fe=n(),_e=n();return G(T[2],s),ie(T[1],D),He(L,T[1]),we(Q,L,l),ye(L,L,T[2]),se(Q,T[2],Q),He(te,Q),He(fe,te),we(_e,fe,te),we($,_e,L),we($,$,Q),it($,$),we($,$,L),we($,$,Q),we($,$,Q),we(T[0],$,Q),He(A,T[0]),we(A,A,Q),Y(A,L)&&we(T[0],T[0],p),He(A,T[0]),we(A,A,Q),Y(A,L)?-1:(re(T[0])===D[31]>>7&&ye(T[0],a,T[0]),we(T[3],T[0],T[1]),0)}function yi(T,D,$,A){var L,Q=new Uint8Array(32),te=new Uint8Array(64),fe=[n(),n(),n(),n()],_e=[n(),n(),n(),n()];if($<64||br(_e,A))return-1;for(L=0;L<$;L++)T[L]=D[L];for(L=0;L<32;L++)T[L+32]=A[L];if(de(te,T,$),_n(te),Ae(fe,_e,te),tt(_e,D.subarray(32)),ge(fe,_e),Fe(Q,fe),$-=64,w(D,0,Q,0)){for(L=0;L<$;L++)T[L]=0;return-1}for(L=0;L<$;L++)T[L]=D[L+64];return $}var sr=32,si=24,bi=32,Rr=16,Xi=32,yo=32,xi=32,Dr=32,Sa=32,_t=si,hn=bi,Sn=Rr,qn=64,ur=32,Xr=64,bo=32,Ql=64;t.lowlevel={crypto_core_hsalsa20:E,crypto_stream_xor:B,crypto_stream:I,crypto_stream_salsa20_xor:P,crypto_stream_salsa20:M,crypto_onetimeauth:V,crypto_onetimeauth_verify:ee,crypto_verify_16:b,crypto_verify_32:w,crypto_secretbox:Z,crypto_secretbox_open:K,crypto_scalarmult:ke,crypto_scalarmult_base:Le,crypto_box_beforenm:me,crypto_box_afternm:yt,crypto_box:Nt,crypto_box_open:bn,crypto_box_keypair:De,crypto_hash:de,crypto_sign:Ii,crypto_sign_keypair:mt,crypto_sign_open:yi,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:si,crypto_secretbox_ZEROBYTES:bi,crypto_secretbox_BOXZEROBYTES:Rr,crypto_scalarmult_BYTES:Xi,crypto_scalarmult_SCALARBYTES:yo,crypto_box_PUBLICKEYBYTES:xi,crypto_box_SECRETKEYBYTES:Dr,crypto_box_BEFORENMBYTES:Sa,crypto_box_NONCEBYTES:_t,crypto_box_ZEROBYTES:hn,crypto_box_BOXZEROBYTES:Sn,crypto_sign_BYTES:qn,crypto_sign_PUBLICKEYBYTES:ur,crypto_sign_SECRETKEYBYTES:Xr,crypto_sign_SEEDBYTES:bo,crypto_hash_BYTES:Ql,gf:n,D:l,L:wn,pack25519:q,unpack25519:ie,M:we,A:se,S:He,Z:ye,pow2523:it,add:ge,set25519:G,modL:Kt,scalarmult:Ae,scalarbase:tt};function Ef(T,D){if(T.length!==sr)throw new Error("bad key size");if(D.length!==si)throw new Error("bad nonce size")}function oe(T,D){if(T.length!==xi)throw new Error("bad public key size");if(D.length!==Dr)throw new Error("bad secret key size")}function ue(){for(var T=0;T=0},t.sign.keyPair=function(){var T=new Uint8Array(ur),D=new Uint8Array(Xr);return mt(T,D),{publicKey:T,secretKey:D}},t.sign.keyPair.fromSecretKey=function(T){if(ue(T),T.length!==Xr)throw new Error("bad secret key size");for(var D=new Uint8Array(ur),$=0;$"u"?typeof Buffer.from<"u"?(t.encodeBase64=function(r){return Buffer.from(r).toString("base64")},t.decodeBase64=function(r){return n(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(t.encodeBase64=function(r){return new Buffer(r).toString("base64")},t.decodeBase64=function(r){return n(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(t.encodeBase64=function(r){var i,o=[],a=r.length;for(i=0;i{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:a,disabled:s,value:u="on",onCheckedChange:l,form:c,...f}=e,[h,p]=y.useState(null),m=Yt(t,O=>p(O)),v=y.useRef(!1),b=h?c||!!h.closest("form"):!0,[w=!1,x]=Xa({prop:i,defaultProp:o,onChange:l}),S=y.useRef(w);return y.useEffect(()=>{const O=h?.form;if(O){const E=()=>x(S.current);return O.addEventListener("reset",E),()=>O.removeEventListener("reset",E)}},[h,x]),N.jsxs(fZe,{scope:n,state:w,disabled:s,children:[N.jsx(pt.button,{type:"button",role:"checkbox","aria-checked":El(w)?"mixed":w,"aria-required":a,"data-state":BZ(w),"data-disabled":s?"":void 0,disabled:s,value:u,...f,ref:m,onKeyDown:Ye(e.onKeyDown,O=>{O.key==="Enter"&&O.preventDefault()}),onClick:Ye(e.onClick,O=>{x(E=>El(E)?!0:!E),b&&(v.current=O.isPropagationStopped(),v.current||O.stopPropagation())})}),b&&N.jsx(hZe,{control:h,bubbles:!v.current,name:r,value:u,checked:w,required:a,disabled:s,form:c,style:{transform:"translateX(-100%)"},defaultChecked:El(o)?!1:o})]})});LZ.displayName=WP;var FZ="CheckboxIndicator",jZ=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=dZe(FZ,n);return N.jsx(Gr,{present:r||El(o.state)||o.state===!0,children:N.jsx(pt.span,{"data-state":BZ(o.state),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});jZ.displayName=FZ;var hZe=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:i,...o}=e,a=y.useRef(null),s=sP(n),u=_5(t);y.useEffect(()=>{const c=a.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(s!==n&&p){const m=new Event("click",{bubbles:r});c.indeterminate=El(n),p.call(c,El(n)?!1:n),c.dispatchEvent(m)}},[s,n,r]);const l=y.useRef(El(n)?!1:n);return N.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i??l.current,...o,tabIndex:-1,ref:a,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function El(e){return e==="indeterminate"}function BZ(e){return El(e)?"indeterminate":e?"checked":"unchecked"}var Eet=LZ,Oet=jZ;export{Jme as $,Yi as A,Dge as B,aXe as C,cXe as D,rT as E,oXe as F,F as G,xXe as H,zZe as I,vZe as J,EXe as K,gXe as L,jZe as M,FZe as N,gZe as O,xZe as P,yXe as Q,iXe as R,kl as S,mXe as T,wZe as U,qme as V,Zme as W,Xme as X,uU as Y,jXe as Z,Qme as _,SZe as a,XZe as a$,Gme as a0,Yme as a1,hQe as a2,NXe as a3,pQe as a4,iQe as a5,oQe as a6,uQe as a7,lQe as a8,fQe as a9,KZe as aA,DZe as aB,BZe as aC,YZe as aD,GZe as aE,UZe as aF,qZe as aG,kZe as aH,AZe as aI,NZe as aJ,nXe as aK,tXe as aL,JZe as aM,rXe as aN,WZe as aO,MZe as aP,pJe as aQ,HXe as aR,rJe as aS,vJe as aT,yJe as aU,bJe as aV,Vwe as aW,Ywe as aX,LZe as aY,bf as aZ,HZe as a_,RXe as aa,cQe as ab,zXe as ac,sQe as ad,dQe as ae,nQe as af,rQe as ag,aQe as ah,QXe as ai,XXe as aj,JXe as ak,RZe as al,mQe as am,Aye as an,Pye as ao,yQe as ap,_Qe as aq,bQe as ar,xQe as as,yZe as at,TZe as au,$Ze as av,ZZe as aw,EZe as ax,XQe as ay,IZe as az,_m as b,OZe as b$,wJe as b0,_Je as b1,SJe as b2,_Ze as b3,AJe as b4,kJe as b5,PJe as b6,TJe as b7,$Xe as b8,jJe as b9,ip as bA,UJe as bB,CQe as bC,PQe as bD,YQe as bE,kQe as bF,fJe as bG,cJe as bH,UQe as bI,lJe as bJ,ZQe as bK,SQe as bL,AQe as bM,EQe as bN,gJe as bO,Ui as bP,ZJe as bQ,XJe as bR,GQe as bS,sJe as bT,nJe as bU,zQe as bV,NQe as bW,IQe as bX,PZe as bY,eXe as bZ,VZe as b_,LXe as ba,BJe as bb,MJe as bc,RJe as bd,DJe as be,IJe as bf,NJe as bg,FJe as bh,LJe as bi,zJe as bj,$Je as bk,VJe as bl,IXe as bm,qJe as bn,GJe as bo,HJe as bp,KJe as bq,ZS as br,TQe as bs,CJe as bt,EJe as bu,oP as bv,aP as bw,nBe as bx,eu as by,Cf as bz,dn as c,RQe as c$,QZe as c0,JJe as c1,eet as c2,tJe as c3,UXe as c4,VXe as c5,set as c6,cet as c7,LQe as c8,OQe as c9,dJe as cA,ts as cB,yr as cC,KQe as cD,net as cE,ret as cF,GXe as cG,tf as cH,wQe as cI,wet as cJ,_et as cK,iJe as cL,jQe as cM,VQe as cN,QQe as cO,BQe as cP,aJe as cQ,HQe as cR,Eet as cS,Oet as cT,FXe as cU,ZXe as cV,DXe as cW,BXe as cX,YXe as cY,WQe as cZ,bZe as c_,get as ca,met as cb,bet as cc,xet as cd,vet as ce,yet as cf,det as cg,het as ch,pet as ci,WXe as cj,qXe as ck,uJe as cl,uet as cm,tet as cn,iet as co,oet as cp,aet as cq,pce as cr,xce as cs,lce as ct,JQe as cu,oJe as cv,eJe as cw,qQe as cx,DQe as cy,$Qe as cz,dXe as d,RWe as d0,KXe as d1,FQe as d2,MQe as d3,WO as e,vXe as f,pXe as g,SXe as h,qr as i,N as j,CXe as k,fXe as l,sXe as m,uXe as n,wXe as o,_Xe as p,OXe as q,y as r,AXe as s,CZe as t,uj as u,mZe as v,kXe as w,TXe as x,PXe as y,lXe as z}; +`,o.map=[t,e.line],!0}function FGe(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],o=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>o)return!1;const a=e.src.charCodeAt(i);if(a!==126&&a!==96)return!1;let s=i;i=e.skipChars(i,a);let u=i-s;if(u<3)return!1;const l=e.src.slice(s,i),c=e.src.slice(i,o);if(a===96&&c.indexOf(String.fromCharCode(a))>=0)return!1;if(r)return!0;let f=t,h=!1;for(;f++,!(f>=n||(i=s=e.bMarks[f]+e.tShift[f],o=e.eMarks[f],i=4)&&(i=e.skipChars(i,a),!(i-s=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;const s=[],u=[],l=[],c=[],f=e.md.block.ruler.getRules("blockquote"),h=e.parentType;e.parentType="blockquote";let p=!1,m;for(m=t;m=o)break;if(e.src.charCodeAt(i++)===62&&!S){let E=e.sCount[m]+1,C,P;e.src.charCodeAt(i)===32?(i++,E++,P=!1,C=!0):e.src.charCodeAt(i)===9?(C=!0,(e.bsCount[m]+E)%4===3?(i++,E++,P=!1):P=!0):C=!1;let M=E;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i=o,u.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+(C?1:0),l.push(e.sCount[m]),e.sCount[m]=M-E,c.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let O=!1;for(let E=0,C=f.length;E";const w=[t,0];b.map=w,e.md.block.tokenize(e,t,m);const x=e.push("blockquote_close","blockquote",-1);x.markup=">",e.lineMax=a,e.parentType=h,w[1]=e.line;for(let S=0;S=4)return!1;let o=e.bMarks[t]+e.tShift[t];const a=e.src.charCodeAt(o++);if(a!==42&&a!==45&&a!==95)return!1;let s=1;for(;o=r)return-1;let o=e.src.charCodeAt(i++);if(o<48||o>57)return-1;for(;;){if(i>=r)return-1;if(o=e.src.charCodeAt(i++),o>=48&&o<=57){if(i-n>=10)return-1;continue}if(o===41||o===46)break;return-1}return i=4||e.listIndent>=0&&e.sCount[u]-e.listIndent>=4&&e.sCount[u]=e.blkIndent&&(c=!0);let f,h,p;if((p=TN(e,u))>=0){if(f=!0,a=e.bMarks[u]+e.tShift[u],h=Number(e.src.slice(a,p-1)),c&&h!==1)return!1}else if((p=kN(e,u))>=0)f=!1;else return!1;if(c&&e.skipSpaces(p)>=e.eMarks[u])return!1;if(r)return!0;const m=e.src.charCodeAt(p-1),v=e.tokens.length;f?(s=e.push("ordered_list_open","ol",1),h!==1&&(s.attrs=[["start",h]])):s=e.push("bullet_list_open","ul",1);const b=[u,0];s.map=b,s.markup=String.fromCharCode(m);let w=!1;const x=e.md.block.ruler.getRules("list"),S=e.parentType;for(e.parentType="list";u=i?P=1:P=E-O,P>4&&(P=1);const M=O+P;s=e.push("list_item_open","li",1),s.markup=String.fromCharCode(m);const I=[u,0];s.map=I,f&&(s.info=e.src.slice(a,p-1));const B=e.tight,W=e.tShift[u],V=e.sCount[u],ee=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=M,e.tight=!0,e.tShift[u]=C-e.bMarks[u],e.sCount[u]=E,C>=i&&e.isEmpty(u+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,u,n,!0),(!e.tight||w)&&(l=!1),w=e.line-u>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=ee,e.tShift[u]=W,e.sCount[u]=V,e.tight=B,s=e.push("list_item_close","li",-1),s.markup=String.fromCharCode(m),u=e.line,I[1]=u,u>=n||e.sCount[u]=4)break;let Z=!1;for(let K=0,G=x.length;K=4||e.src.charCodeAt(i)!==91)return!1;function s(x){const S=e.lineMax;if(x>=S||e.isEmpty(x))return null;let O=!1;if(e.sCount[x]-e.blkIndent>3&&(O=!0),e.sCount[x]<0&&(O=!0),!O){const P=e.md.block.ruler.getRules("reference"),M=e.parentType;e.parentType="reference";let I=!1;for(let B=0,W=P.length;B"u"&&(e.env.references={}),typeof e.env.references[w]>"u"&&(e.env.references[w]={title:b,href:f}),e.line=a),!0):!1}const WGe=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],HGe="[a-zA-Z_:][a-zA-Z0-9:._-]*",KGe="[^\"'=<>`\\x00-\\x20]+",qGe="'[^']*'",GGe='"[^"]*"',YGe="(?:"+KGe+"|"+qGe+"|"+GGe+")",ZGe="(?:\\s+"+HGe+"(?:\\s*=\\s*"+YGe+")?)",xZ="<[A-Za-z][A-Za-z0-9\\-]*"+ZGe+"*\\s*\\/?>",wZ="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",XGe="",QGe="<[?][\\s\\S]*?[?]>",JGe="]*>",eYe="",tYe=new RegExp("^(?:"+xZ+"|"+wZ+"|"+XGe+"|"+QGe+"|"+JGe+"|"+eYe+")"),nYe=new RegExp("^(?:"+xZ+"|"+wZ+")"),td=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^/,!0],[/^<\?/,/\?>/,!0],[/^/,!0],[/^/,!0],[new RegExp("^|$))","i"),/^$/,!0],[new RegExp(nYe.source+"\\s*$"),/^$/,!1]];function rYe(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],o=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let a=e.src.slice(i,o),s=0;for(;s=4)return!1;let a=e.src.charCodeAt(i);if(a!==35||i>=o)return!1;let s=1;for(a=e.src.charCodeAt(++i);a===35&&i6||ii&&Hn(e.src.charCodeAt(u-1))&&(o=u),e.line=t+1;const l=e.push("heading_open","h"+String(s),1);l.markup="########".slice(0,s),l.map=[t,e.line];const c=e.push("inline","",0);c.content=e.src.slice(i,o).trim(),c.map=[t,e.line],c.children=[];const f=e.push("heading_close","h"+String(s),-1);return f.markup="########".slice(0,s),!0}function oYe(e,t,n){const r=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;const i=e.parentType;e.parentType="paragraph";let o=0,a,s=t+1;for(;s3)continue;if(e.sCount[s]>=e.blkIndent){let p=e.bMarks[s]+e.tShift[s];const m=e.eMarks[s];if(p=m))){o=a===61?1:2;break}}if(e.sCount[s]<0)continue;let h=!1;for(let p=0,m=r.length;p3||e.sCount[o]<0)continue;let l=!1;for(let c=0,f=r.length;c=n||e.sCount[a]=o){e.line=n;break}const u=e.line;let l=!1;for(let c=0;c=e.line)throw new Error("block rule didn't increment state.line");break}if(!l)throw new Error("none of the block rules matched");e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),a=e.line,a0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r};tv.prototype.scanDelims=function(e,t){const n=this.posMax,r=this.src.charCodeAt(e),i=e>0?this.src.charCodeAt(e-1):32;let o=e;for(;o0)return!1;const n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;const i=e.pending.match(lYe);if(!i)return!1;const o=i[1],a=e.md.linkify.matchAtStart(e.src.slice(n-o.length));if(!a)return!1;let s=a.url;if(s.length<=o.length)return!1;s=s.replace(/\*+$/,"");const u=e.md.normalizeLink(s);if(!e.md.validateLink(u))return!1;if(!t){e.pending=e.pending.slice(0,-o.length);const l=e.push("link_open","a",1);l.attrs=[["href",u]],l.markup="linkify",l.info="auto";const c=e.push("text","",0);c.content=e.md.normalizeLinkText(s);const f=e.push("link_close","a",-1);f.markup="linkify",f.info="auto"}return e.pos+=s.length-o.length,!0}function fYe(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;const r=e.pending.length-1,i=e.posMax;if(!t)if(r>=0&&e.pending.charCodeAt(r)===32)if(r>=1&&e.pending.charCodeAt(r-1)===32){let o=r-1;for(;o>=1&&e.pending.charCodeAt(o-1)===32;)o--;e.pending=e.pending.slice(0,o),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(n++;n?@[]^_`{|}~-".split("").forEach(function(e){UP[e.charCodeAt(0)]=1});function dYe(e,t){let n=e.pos;const r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push("hardbreak","br",0),n++;n=55296&&i<=56319&&n+1=56320&&s<=57343&&(o+=e.src[n+1],n++)}const a="\\"+o;if(!t){const s=e.push("text_special","",0);i<256&&UP[i]!==0?s.content=o:s.content=a,s.markup=a,s.info="escape"}return e.pos=n+1,!0}function hYe(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;const i=n;n++;const o=e.posMax;for(;n=0;r--){const i=t[r];if(i.marker!==95&&i.marker!==42||i.end===-1)continue;const o=t[i.end],a=r>0&&t[r-1].end===i.end+1&&t[r-1].marker===i.marker&&t[r-1].token===i.token-1&&t[i.end+1].token===o.token+1,s=String.fromCharCode(i.marker),u=e.tokens[i.token];u.type=a?"strong_open":"em_open",u.tag=a?"strong":"em",u.nesting=1,u.markup=a?s+s:s,u.content="";const l=e.tokens[o.token];l.type=a?"strong_close":"em_close",l.tag=a?"strong":"em",l.nesting=-1,l.markup=a?s+s:s,l.content="",a&&(e.tokens[t[r-1].token].content="",e.tokens[t[i.end+1].token].content="",r--)}}function vYe(e){const t=e.tokens_meta,n=e.tokens_meta.length;RN(e,e.delimiters);for(let r=0;r=f)return!1;if(u=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(a=e.md.normalizeLink(i.str),e.md.validateLink(a)?m=i.pos:a="",u=m;m=f||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(typeof e.env.references>"u")return!1;if(m=0?r=e.src.slice(u,m++):m=p+1):m=p+1,r||(r=e.src.slice(h,p)),o=e.env.references[T2(r)],!o)return e.pos=c,!1;a=o.href,s=o.title}if(!t){e.pos=h,e.posMax=p;const v=e.push("link_open","a",1),b=[["href",a]];v.attrs=b,s&&b.push(["title",s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push("link_close","a",-1)}return e.pos=m,e.posMax=f,!0}function bYe(e,t){let n,r,i,o,a,s,u,l,c="";const f=e.pos,h=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;const p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(o=m+1,o=h)return!1;for(l=o,s=e.md.helpers.parseLinkDestination(e.src,o,e.posMax),s.ok&&(c=e.md.normalizeLink(s.str),e.md.validateLink(c)?o=s.pos:c=""),l=o;o=h||e.src.charCodeAt(o)!==41)return e.pos=f,!1;o++}else{if(typeof e.env.references>"u")return!1;if(o=0?i=e.src.slice(l,o++):o=m+1):o=m+1,i||(i=e.src.slice(p,m)),a=e.env.references[T2(i)],!a)return e.pos=f,!1;c=a.href,u=a.title}if(!t){r=e.src.slice(p,m);const v=[];e.md.inline.parse(r,e.md,e.env,v);const b=e.push("image","img",0),w=[["src",c],["alt",""]];b.attrs=w,b.children=v,b.content=r,u&&w.push(["title",u])}return e.pos=o,e.posMax=h,!0}const xYe=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,wYe=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function _Ye(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;const r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;const a=e.src.charCodeAt(n);if(a===60)return!1;if(a===62)break}const o=e.src.slice(r+1,n);if(wYe.test(o)){const a=e.md.normalizeLink(o);if(!e.md.validateLink(a))return!1;if(!t){const s=e.push("link_open","a",1);s.attrs=[["href",a]],s.markup="autolink",s.info="auto";const u=e.push("text","",0);u.content=e.md.normalizeLinkText(o);const l=e.push("link_close","a",-1);l.markup="autolink",l.info="auto"}return e.pos+=o.length+2,!0}if(xYe.test(o)){const a=e.md.normalizeLink("mailto:"+o);if(!e.md.validateLink(a))return!1;if(!t){const s=e.push("link_open","a",1);s.attrs=[["href",a]],s.markup="autolink",s.info="auto";const u=e.push("text","",0);u.content=e.md.normalizeLinkText(o);const l=e.push("link_close","a",-1);l.markup="autolink",l.info="auto"}return e.pos+=o.length+2,!0}return!1}function SYe(e){return/^\s]/i.test(e)}function CYe(e){return/^<\/a\s*>/i.test(e)}function EYe(e){const t=e|32;return t>=97&&t<=122}function OYe(e,t){if(!e.md.options.html)return!1;const n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;const i=e.src.charCodeAt(r+1);if(i!==33&&i!==63&&i!==47&&!EYe(i))return!1;const o=e.src.slice(r).match(tYe);if(!o)return!1;if(!t){const a=e.push("html_inline","",0);a.content=o[0],SYe(a.content)&&e.linkLevel++,CYe(a.content)&&e.linkLevel--}return e.pos+=o[0].length,!0}const AYe=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,PYe=/^&([a-z][a-z0-9]{1,31});/i;function kYe(e,t){const n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){const o=e.src.slice(n).match(AYe);if(o){if(!t){const a=o[1][0].toLowerCase()==="x"?parseInt(o[1].slice(1),16):parseInt(o[1],10),s=e.push("text_special","",0);s.content=BP(a)?Mx(a):Mx(65533),s.markup=o[0],s.info="entity"}return e.pos+=o[0].length,!0}}else{const o=e.src.slice(n).match(PYe);if(o){const a=gZ(o[0]);if(a!==o[0]){if(!t){const s=e.push("text_special","",0);s.content=a,s.markup=o[0],s.info="entity"}return e.pos+=o[0].length,!0}}}return!1}function DN(e){const t={},n=e.length;if(!n)return;let r=0,i=-2;const o=[];for(let a=0;au;l-=o[l]+1){const f=e[l];if(f.marker===s.marker&&f.open&&f.end<0){let h=!1;if((f.close||s.open)&&(f.length+s.length)%3===0&&(f.length%3!==0||s.length%3!==0)&&(h=!0),!h){const p=l>0&&!e[l-1].open?o[l-1]+1:0;o[a]=a-l+p,o[l]=p,s.open=!1,f.end=a,f.close=!1,c=-1,i=-2;break}}}c!==-1&&(t[s.marker][(s.open?3:0)+(s.length||0)%3]=c)}}function TYe(e){const t=e.tokens_meta,n=e.tokens_meta.length;DN(e.delimiters);for(let r=0;r0&&r++,i[t].type==="text"&&t+1=e.pos)throw new Error("inline rule didn't increment state.pos");break}}else e.pos=e.posMax;a||e.pos++,o[t]=e.pos};nv.prototype.tokenize=function(e){const t=this.ruler.getRules(""),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos=e.pos)throw new Error("inline rule didn't increment state.pos");break}}if(a){if(e.pos>=r)break;continue}e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()};nv.prototype.parse=function(e,t,n,r){const i=new this.State(e,t,n,r);this.tokenize(i);const o=this.ruler2.getRules(""),a=o.length;for(let s=0;s|$))",t.tpl_email_fuzzy="(^|"+n+'|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}function N4(e){return Array.prototype.slice.call(arguments,1).forEach(function(n){n&&Object.keys(n).forEach(function(r){e[r]=n[r]})}),e}function R2(e){return Object.prototype.toString.call(e)}function DYe(e){return R2(e)==="[object String]"}function $Ye(e){return R2(e)==="[object Object]"}function IYe(e){return R2(e)==="[object RegExp]"}function $N(e){return R2(e)==="[object Function]"}function NYe(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const CZ={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};function LYe(e){return Object.keys(e||{}).reduce(function(t,n){return t||CZ.hasOwnProperty(n)},!1)}const FYe={"http:":{validate:function(e,t,n){const r=e.slice(t);return n.re.http||(n.re.http=new RegExp("^\\/\\/"+n.re.src_auth+n.re.src_host_port_strict+n.re.src_path,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const r=e.slice(t);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+"(?:localhost|(?:(?:"+n.re.src_domain+")\\.)+"+n.re.src_domain_root+")"+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?t>=3&&e[t-3]===":"||t>=3&&e[t-3]==="/"?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const r=e.slice(t);return n.re.mailto||(n.re.mailto=new RegExp("^"+n.re.src_email_name+"@"+n.re.src_host_strict,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},jYe="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",BYe="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function zYe(e){e.__index__=-1,e.__text_cache__=""}function UYe(e){return function(t,n){const r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}function IN(){return function(e,t){t.normalize(e)}}function Rx(e){const t=e.re=RYe(e.__opts__),n=e.__tlds__.slice();e.onCompile(),e.__tlds_replaced__||n.push(jYe),n.push(t.src_xn),t.src_tlds=n.join("|");function r(s){return s.replace("%TLDS%",t.src_tlds)}t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),"i");const i=[];e.__compiled__={};function o(s,u){throw new Error('(LinkifyIt) Invalid schema "'+s+'": '+u)}Object.keys(e.__schemas__).forEach(function(s){const u=e.__schemas__[s];if(u===null)return;const l={validate:null,link:null};if(e.__compiled__[s]=l,$Ye(u)){IYe(u.validate)?l.validate=UYe(u.validate):$N(u.validate)?l.validate=u.validate:o(s,u),$N(u.normalize)?l.normalize=u.normalize:u.normalize?o(s,u):l.normalize=IN();return}if(DYe(u)){i.push(s);return}o(s,u)}),i.forEach(function(s){e.__compiled__[e.__schemas__[s]]&&(e.__compiled__[s].validate=e.__compiled__[e.__schemas__[s]].validate,e.__compiled__[s].normalize=e.__compiled__[e.__schemas__[s]].normalize)}),e.__compiled__[""]={validate:null,normalize:IN()};const a=Object.keys(e.__compiled__).filter(function(s){return s.length>0&&e.__compiled__[s]}).map(NYe).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+a+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+a+")","ig"),e.re.schema_at_start=RegExp("^"+e.re.schema_search.source,"i"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),zYe(e)}function VYe(e,t){const n=e.__index__,r=e.__last_index__,i=e.__text_cache__.slice(n,r);this.schema=e.__schema__.toLowerCase(),this.index=n+t,this.lastIndex=r+t,this.raw=i,this.text=i,this.url=i}function L4(e,t){const n=new VYe(e,t);return e.__compiled__[n.schema].normalize(n,e),n}function Ho(e,t){if(!(this instanceof Ho))return new Ho(e,t);t||LYe(e)&&(t=e,e={}),this.__opts__=N4({},CZ,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=N4({},FYe,e),this.__compiled__={},this.__tlds__=BYe,this.__tlds_replaced__=!1,this.re={},Rx(this)}Ho.prototype.add=function(t,n){return this.__schemas__[t]=n,Rx(this),this};Ho.prototype.set=function(t){return this.__opts__=N4(this.__opts__,t),this};Ho.prototype.test=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return!1;let n,r,i,o,a,s,u,l,c;if(this.re.schema_test.test(t)){for(u=this.re.schema_search,u.lastIndex=0;(n=u.exec(t))!==null;)if(o=this.testSchemaAt(t,n[2],u.lastIndex),o){this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+o;break}}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(l=t.search(this.re.host_fuzzy_test),l>=0&&(this.__index__<0||l=0&&(i=t.match(this.re.email_fuzzy))!==null&&(a=i.index+i[1].length,s=i.index+i[0].length,(this.__index__<0||athis.__last_index__)&&(this.__schema__="mailto:",this.__index__=a,this.__last_index__=s))),this.__index__>=0};Ho.prototype.pretest=function(t){return this.re.pretest.test(t)};Ho.prototype.testSchemaAt=function(t,n,r){return this.__compiled__[n.toLowerCase()]?this.__compiled__[n.toLowerCase()].validate(t,r,this):0};Ho.prototype.match=function(t){const n=[];let r=0;this.__index__>=0&&this.__text_cache__===t&&(n.push(L4(this,r)),r=this.__last_index__);let i=r?t.slice(r):t;for(;this.test(i);)n.push(L4(this,r)),i=i.slice(this.__last_index__),r+=this.__last_index__;return n.length?n:null};Ho.prototype.matchAtStart=function(t){if(this.__text_cache__=t,this.__index__=-1,!t.length)return null;const n=this.re.schema_at_start.exec(t);if(!n)return null;const r=this.testSchemaAt(t,n[2],n[0].length);return r?(this.__schema__=n[2],this.__index__=n.index+n[1].length,this.__last_index__=n.index+n[0].length+r,L4(this,0)):null};Ho.prototype.tlds=function(t,n){return t=Array.isArray(t)?t:[t],n?(this.__tlds__=this.__tlds__.concat(t).sort().filter(function(r,i,o){return r!==o[i-1]}).reverse(),Rx(this),this):(this.__tlds__=t.slice(),this.__tlds_replaced__=!0,Rx(this),this)};Ho.prototype.normalize=function(t){t.schema||(t.url="http://"+t.url),t.schema==="mailto:"&&!/^mailto:/i.test(t.url)&&(t.url="mailto:"+t.url)};Ho.prototype.onCompile=function(){};const zd=2147483647,_s=36,VP=1,gm=26,WYe=38,HYe=700,EZ=72,OZ=128,AZ="-",KYe=/^xn--/,qYe=/[^\0-\x7F]/,GYe=/[\x2E\u3002\uFF0E\uFF61]/g,YYe={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},G3=_s-VP,Ss=Math.floor,Y3=String.fromCharCode;function el(e){throw new RangeError(YYe[e])}function ZYe(e,t){const n=[];let r=e.length;for(;r--;)n[r]=t(e[r]);return n}function PZ(e,t){const n=e.split("@");let r="";n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(GYe,".");const i=e.split("."),o=ZYe(i,t).join(".");return r+o}function kZ(e){const t=[];let n=0;const r=e.length;for(;n=55296&&i<=56319&&nString.fromCodePoint(...e),QYe=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:_s},NN=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},TZ=function(e,t,n){let r=0;for(e=n?Ss(e/HYe):e>>1,e+=Ss(e/t);e>G3*gm>>1;r+=_s)e=Ss(e/G3);return Ss(r+(G3+1)*e/(e+WYe))},MZ=function(e){const t=[],n=e.length;let r=0,i=OZ,o=EZ,a=e.lastIndexOf(AZ);a<0&&(a=0);for(let s=0;s=128&&el("not-basic"),t.push(e.charCodeAt(s));for(let s=a>0?a+1:0;s=n&&el("invalid-input");const h=QYe(e.charCodeAt(s++));h>=_s&&el("invalid-input"),h>Ss((zd-r)/c)&&el("overflow"),r+=h*c;const p=f<=o?VP:f>=o+gm?gm:f-o;if(hSs(zd/m)&&el("overflow"),c*=m}const l=t.length+1;o=TZ(r-u,l,u==0),Ss(r/l)>zd-i&&el("overflow"),i+=Ss(r/l),r%=l,t.splice(r++,0,i)}return String.fromCodePoint(...t)},RZ=function(e){const t=[];e=kZ(e);const n=e.length;let r=OZ,i=0,o=EZ;for(const u of e)u<128&&t.push(Y3(u));const a=t.length;let s=a;for(a&&t.push(AZ);s=r&&cSs((zd-i)/l)&&el("overflow"),i+=(u-r)*l,r=u;for(const c of e)if(czd&&el("overflow"),c===r){let f=i;for(let h=_s;;h+=_s){const p=h<=o?VP:h>=o+gm?gm:h-o;if(f=0))try{t.hostname=DZ.toASCII(t.hostname)}catch{}return ev(NP(t))}function lZe(e){const t=LP(e,!0);if(t.hostname&&(!t.protocol||$Z.indexOf(t.protocol)>=0))try{t.hostname=DZ.toUnicode(t.hostname)}catch{}return kh(NP(t),kh.defaultChars+"%")}function ts(e,t){if(!(this instanceof ts))return new ts(e,t);t||jP(e)||(t=e||{},e="default"),this.inline=new nv,this.block=new M2,this.core=new zP,this.renderer=new sp,this.linkify=new Ho,this.validateLink=sZe,this.normalizeLink=uZe,this.normalizeLinkText=lZe,this.utils=fGe,this.helpers=k2({},gGe),this.options={},this.configure(e),t&&this.set(t)}ts.prototype.set=function(e){return k2(this.options,e),this};ts.prototype.configure=function(e){const t=this;if(jP(e)){const n=e;if(e=iZe[n],!e)throw new Error('Wrong `markdown-it` preset "'+n+'", check name')}if(!e)throw new Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach(function(n){e.components[n].rules&&t[n].ruler.enableOnly(e.components[n].rules),e.components[n].rules2&&t[n].ruler2.enableOnly(e.components[n].rules2)}),this};ts.prototype.enable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.enable(e,!0))},this),n=n.concat(this.inline.ruler2.enable(e,!0));const r=e.filter(function(i){return n.indexOf(i)<0});if(r.length&&!t)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+r);return this};ts.prototype.disable=function(e,t){let n=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach(function(i){n=n.concat(this[i].ruler.disable(e,!0))},this),n=n.concat(this.inline.ruler2.disable(e,!0));const r=e.filter(function(i){return n.indexOf(i)<0});if(r.length&&!t)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+r);return this};ts.prototype.use=function(e){const t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this};ts.prototype.parse=function(e,t){if(typeof e!="string")throw new Error("Input data should be a String");const n=new this.core.State(e,this,t);return this.core.process(n),n.tokens};ts.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)};ts.prototype.parseInline=function(e,t){const n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens};ts.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var IZ={exports:{}};(function(e){(function(t){var n=function(T){var D,$=new Float64Array(16);if(T)for(D=0;D>24&255,T[D+1]=$>>16&255,T[D+2]=$>>8&255,T[D+3]=$&255,T[D+4]=A>>24&255,T[D+5]=A>>16&255,T[D+6]=A>>8&255,T[D+7]=A&255}function v(T,D,$,A,L){var Q,te=0;for(Q=0;Q>>8)-1}function b(T,D,$,A){return v(T,D,$,A,16)}function w(T,D,$,A){return v(T,D,$,A,32)}function x(T,D,$,A){for(var L=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,Q=$[0]&255|($[1]&255)<<8|($[2]&255)<<16|($[3]&255)<<24,te=$[4]&255|($[5]&255)<<8|($[6]&255)<<16|($[7]&255)<<24,fe=$[8]&255|($[9]&255)<<8|($[10]&255)<<16|($[11]&255)<<24,_e=$[12]&255|($[13]&255)<<8|($[14]&255)<<16|($[15]&255)<<24,je=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,We=D[0]&255|(D[1]&255)<<8|(D[2]&255)<<16|(D[3]&255)<<24,ct=D[4]&255|(D[5]&255)<<8|(D[6]&255)<<16|(D[7]&255)<<24,Ie=D[8]&255|(D[9]&255)<<8|(D[10]&255)<<16|(D[11]&255)<<24,nt=D[12]&255|(D[13]&255)<<8|(D[14]&255)<<16|(D[15]&255)<<24,bt=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Ot=$[16]&255|($[17]&255)<<8|($[18]&255)<<16|($[19]&255)<<24,gt=$[20]&255|($[21]&255)<<8|($[22]&255)<<16|($[23]&255)<<24,ht=$[24]&255|($[25]&255)<<8|($[26]&255)<<16|($[27]&255)<<24,xt=$[28]&255|($[29]&255)<<8|($[30]&255)<<16|($[31]&255)<<24,wt=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Qe=L,ut=Q,Xe=te,Ne=fe,Ke=_e,Ge=je,pe=We,he=ct,Re=Ie,Oe=nt,Pe=bt,Be=Ot,vt=gt,Lt=ht,Ft=xt,$t=wt,J,Zt=0;Zt<20;Zt+=2)J=Qe+vt|0,Ke^=J<<7|J>>>25,J=Ke+Qe|0,Re^=J<<9|J>>>23,J=Re+Ke|0,vt^=J<<13|J>>>19,J=vt+Re|0,Qe^=J<<18|J>>>14,J=Ge+ut|0,Oe^=J<<7|J>>>25,J=Oe+Ge|0,Lt^=J<<9|J>>>23,J=Lt+Oe|0,ut^=J<<13|J>>>19,J=ut+Lt|0,Ge^=J<<18|J>>>14,J=Pe+pe|0,Ft^=J<<7|J>>>25,J=Ft+Pe|0,Xe^=J<<9|J>>>23,J=Xe+Ft|0,pe^=J<<13|J>>>19,J=pe+Xe|0,Pe^=J<<18|J>>>14,J=$t+Be|0,Ne^=J<<7|J>>>25,J=Ne+$t|0,he^=J<<9|J>>>23,J=he+Ne|0,Be^=J<<13|J>>>19,J=Be+he|0,$t^=J<<18|J>>>14,J=Qe+Ne|0,ut^=J<<7|J>>>25,J=ut+Qe|0,Xe^=J<<9|J>>>23,J=Xe+ut|0,Ne^=J<<13|J>>>19,J=Ne+Xe|0,Qe^=J<<18|J>>>14,J=Ge+Ke|0,pe^=J<<7|J>>>25,J=pe+Ge|0,he^=J<<9|J>>>23,J=he+pe|0,Ke^=J<<13|J>>>19,J=Ke+he|0,Ge^=J<<18|J>>>14,J=Pe+Oe|0,Be^=J<<7|J>>>25,J=Be+Pe|0,Re^=J<<9|J>>>23,J=Re+Be|0,Oe^=J<<13|J>>>19,J=Oe+Re|0,Pe^=J<<18|J>>>14,J=$t+Ft|0,vt^=J<<7|J>>>25,J=vt+$t|0,Lt^=J<<9|J>>>23,J=Lt+vt|0,Ft^=J<<13|J>>>19,J=Ft+Lt|0,$t^=J<<18|J>>>14;Qe=Qe+L|0,ut=ut+Q|0,Xe=Xe+te|0,Ne=Ne+fe|0,Ke=Ke+_e|0,Ge=Ge+je|0,pe=pe+We|0,he=he+ct|0,Re=Re+Ie|0,Oe=Oe+nt|0,Pe=Pe+bt|0,Be=Be+Ot|0,vt=vt+gt|0,Lt=Lt+ht|0,Ft=Ft+xt|0,$t=$t+wt|0,T[0]=Qe>>>0&255,T[1]=Qe>>>8&255,T[2]=Qe>>>16&255,T[3]=Qe>>>24&255,T[4]=ut>>>0&255,T[5]=ut>>>8&255,T[6]=ut>>>16&255,T[7]=ut>>>24&255,T[8]=Xe>>>0&255,T[9]=Xe>>>8&255,T[10]=Xe>>>16&255,T[11]=Xe>>>24&255,T[12]=Ne>>>0&255,T[13]=Ne>>>8&255,T[14]=Ne>>>16&255,T[15]=Ne>>>24&255,T[16]=Ke>>>0&255,T[17]=Ke>>>8&255,T[18]=Ke>>>16&255,T[19]=Ke>>>24&255,T[20]=Ge>>>0&255,T[21]=Ge>>>8&255,T[22]=Ge>>>16&255,T[23]=Ge>>>24&255,T[24]=pe>>>0&255,T[25]=pe>>>8&255,T[26]=pe>>>16&255,T[27]=pe>>>24&255,T[28]=he>>>0&255,T[29]=he>>>8&255,T[30]=he>>>16&255,T[31]=he>>>24&255,T[32]=Re>>>0&255,T[33]=Re>>>8&255,T[34]=Re>>>16&255,T[35]=Re>>>24&255,T[36]=Oe>>>0&255,T[37]=Oe>>>8&255,T[38]=Oe>>>16&255,T[39]=Oe>>>24&255,T[40]=Pe>>>0&255,T[41]=Pe>>>8&255,T[42]=Pe>>>16&255,T[43]=Pe>>>24&255,T[44]=Be>>>0&255,T[45]=Be>>>8&255,T[46]=Be>>>16&255,T[47]=Be>>>24&255,T[48]=vt>>>0&255,T[49]=vt>>>8&255,T[50]=vt>>>16&255,T[51]=vt>>>24&255,T[52]=Lt>>>0&255,T[53]=Lt>>>8&255,T[54]=Lt>>>16&255,T[55]=Lt>>>24&255,T[56]=Ft>>>0&255,T[57]=Ft>>>8&255,T[58]=Ft>>>16&255,T[59]=Ft>>>24&255,T[60]=$t>>>0&255,T[61]=$t>>>8&255,T[62]=$t>>>16&255,T[63]=$t>>>24&255}function S(T,D,$,A){for(var L=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,Q=$[0]&255|($[1]&255)<<8|($[2]&255)<<16|($[3]&255)<<24,te=$[4]&255|($[5]&255)<<8|($[6]&255)<<16|($[7]&255)<<24,fe=$[8]&255|($[9]&255)<<8|($[10]&255)<<16|($[11]&255)<<24,_e=$[12]&255|($[13]&255)<<8|($[14]&255)<<16|($[15]&255)<<24,je=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,We=D[0]&255|(D[1]&255)<<8|(D[2]&255)<<16|(D[3]&255)<<24,ct=D[4]&255|(D[5]&255)<<8|(D[6]&255)<<16|(D[7]&255)<<24,Ie=D[8]&255|(D[9]&255)<<8|(D[10]&255)<<16|(D[11]&255)<<24,nt=D[12]&255|(D[13]&255)<<8|(D[14]&255)<<16|(D[15]&255)<<24,bt=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Ot=$[16]&255|($[17]&255)<<8|($[18]&255)<<16|($[19]&255)<<24,gt=$[20]&255|($[21]&255)<<8|($[22]&255)<<16|($[23]&255)<<24,ht=$[24]&255|($[25]&255)<<8|($[26]&255)<<16|($[27]&255)<<24,xt=$[28]&255|($[29]&255)<<8|($[30]&255)<<16|($[31]&255)<<24,wt=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Qe=L,ut=Q,Xe=te,Ne=fe,Ke=_e,Ge=je,pe=We,he=ct,Re=Ie,Oe=nt,Pe=bt,Be=Ot,vt=gt,Lt=ht,Ft=xt,$t=wt,J,Zt=0;Zt<20;Zt+=2)J=Qe+vt|0,Ke^=J<<7|J>>>25,J=Ke+Qe|0,Re^=J<<9|J>>>23,J=Re+Ke|0,vt^=J<<13|J>>>19,J=vt+Re|0,Qe^=J<<18|J>>>14,J=Ge+ut|0,Oe^=J<<7|J>>>25,J=Oe+Ge|0,Lt^=J<<9|J>>>23,J=Lt+Oe|0,ut^=J<<13|J>>>19,J=ut+Lt|0,Ge^=J<<18|J>>>14,J=Pe+pe|0,Ft^=J<<7|J>>>25,J=Ft+Pe|0,Xe^=J<<9|J>>>23,J=Xe+Ft|0,pe^=J<<13|J>>>19,J=pe+Xe|0,Pe^=J<<18|J>>>14,J=$t+Be|0,Ne^=J<<7|J>>>25,J=Ne+$t|0,he^=J<<9|J>>>23,J=he+Ne|0,Be^=J<<13|J>>>19,J=Be+he|0,$t^=J<<18|J>>>14,J=Qe+Ne|0,ut^=J<<7|J>>>25,J=ut+Qe|0,Xe^=J<<9|J>>>23,J=Xe+ut|0,Ne^=J<<13|J>>>19,J=Ne+Xe|0,Qe^=J<<18|J>>>14,J=Ge+Ke|0,pe^=J<<7|J>>>25,J=pe+Ge|0,he^=J<<9|J>>>23,J=he+pe|0,Ke^=J<<13|J>>>19,J=Ke+he|0,Ge^=J<<18|J>>>14,J=Pe+Oe|0,Be^=J<<7|J>>>25,J=Be+Pe|0,Re^=J<<9|J>>>23,J=Re+Be|0,Oe^=J<<13|J>>>19,J=Oe+Re|0,Pe^=J<<18|J>>>14,J=$t+Ft|0,vt^=J<<7|J>>>25,J=vt+$t|0,Lt^=J<<9|J>>>23,J=Lt+vt|0,Ft^=J<<13|J>>>19,J=Ft+Lt|0,$t^=J<<18|J>>>14;T[0]=Qe>>>0&255,T[1]=Qe>>>8&255,T[2]=Qe>>>16&255,T[3]=Qe>>>24&255,T[4]=Ge>>>0&255,T[5]=Ge>>>8&255,T[6]=Ge>>>16&255,T[7]=Ge>>>24&255,T[8]=Pe>>>0&255,T[9]=Pe>>>8&255,T[10]=Pe>>>16&255,T[11]=Pe>>>24&255,T[12]=$t>>>0&255,T[13]=$t>>>8&255,T[14]=$t>>>16&255,T[15]=$t>>>24&255,T[16]=pe>>>0&255,T[17]=pe>>>8&255,T[18]=pe>>>16&255,T[19]=pe>>>24&255,T[20]=he>>>0&255,T[21]=he>>>8&255,T[22]=he>>>16&255,T[23]=he>>>24&255,T[24]=Re>>>0&255,T[25]=Re>>>8&255,T[26]=Re>>>16&255,T[27]=Re>>>24&255,T[28]=Oe>>>0&255,T[29]=Oe>>>8&255,T[30]=Oe>>>16&255,T[31]=Oe>>>24&255}function O(T,D,$,A){x(T,D,$,A)}function E(T,D,$,A){S(T,D,$,A)}var C=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function P(T,D,$,A,L,Q,te){var fe=new Uint8Array(16),_e=new Uint8Array(64),je,We;for(We=0;We<16;We++)fe[We]=0;for(We=0;We<8;We++)fe[We]=Q[We];for(;L>=64;){for(O(_e,fe,te,C),We=0;We<64;We++)T[D+We]=$[A+We]^_e[We];for(je=1,We=8;We<16;We++)je=je+(fe[We]&255)|0,fe[We]=je&255,je>>>=8;L-=64,D+=64,A+=64}if(L>0)for(O(_e,fe,te,C),We=0;We=64;){for(O(te,Q,L,C),_e=0;_e<64;_e++)T[D+_e]=te[_e];for(fe=1,_e=8;_e<16;_e++)fe=fe+(Q[_e]&255)|0,Q[_e]=fe&255,fe>>>=8;$-=64,D+=64}if($>0)for(O(te,Q,L,C),_e=0;_e<$;_e++)T[D+_e]=te[_e];return 0}function I(T,D,$,A,L){var Q=new Uint8Array(32);E(Q,A,L,C);for(var te=new Uint8Array(8),fe=0;fe<8;fe++)te[fe]=A[fe+16];return M(T,D,$,te,Q)}function B(T,D,$,A,L,Q,te){var fe=new Uint8Array(32);E(fe,Q,te,C);for(var _e=new Uint8Array(8),je=0;je<8;je++)_e[je]=Q[je+16];return P(T,D,$,A,L,_e,fe)}var W=function(T){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var D,$,A,L,Q,te,fe,_e;D=T[0]&255|(T[1]&255)<<8,this.r[0]=D&8191,$=T[2]&255|(T[3]&255)<<8,this.r[1]=(D>>>13|$<<3)&8191,A=T[4]&255|(T[5]&255)<<8,this.r[2]=($>>>10|A<<6)&7939,L=T[6]&255|(T[7]&255)<<8,this.r[3]=(A>>>7|L<<9)&8191,Q=T[8]&255|(T[9]&255)<<8,this.r[4]=(L>>>4|Q<<12)&255,this.r[5]=Q>>>1&8190,te=T[10]&255|(T[11]&255)<<8,this.r[6]=(Q>>>14|te<<2)&8191,fe=T[12]&255|(T[13]&255)<<8,this.r[7]=(te>>>11|fe<<5)&8065,_e=T[14]&255|(T[15]&255)<<8,this.r[8]=(fe>>>8|_e<<8)&8191,this.r[9]=_e>>>5&127,this.pad[0]=T[16]&255|(T[17]&255)<<8,this.pad[1]=T[18]&255|(T[19]&255)<<8,this.pad[2]=T[20]&255|(T[21]&255)<<8,this.pad[3]=T[22]&255|(T[23]&255)<<8,this.pad[4]=T[24]&255|(T[25]&255)<<8,this.pad[5]=T[26]&255|(T[27]&255)<<8,this.pad[6]=T[28]&255|(T[29]&255)<<8,this.pad[7]=T[30]&255|(T[31]&255)<<8};W.prototype.blocks=function(T,D,$){for(var A=this.fin?0:2048,L,Q,te,fe,_e,je,We,ct,Ie,nt,bt,Ot,gt,ht,xt,wt,Qe,ut,Xe,Ne=this.h[0],Ke=this.h[1],Ge=this.h[2],pe=this.h[3],he=this.h[4],Re=this.h[5],Oe=this.h[6],Pe=this.h[7],Be=this.h[8],vt=this.h[9],Lt=this.r[0],Ft=this.r[1],$t=this.r[2],J=this.r[3],Zt=this.r[4],sn=this.r[5],un=this.r[6],jt=this.r[7],ln=this.r[8],rn=this.r[9];$>=16;)L=T[D+0]&255|(T[D+1]&255)<<8,Ne+=L&8191,Q=T[D+2]&255|(T[D+3]&255)<<8,Ke+=(L>>>13|Q<<3)&8191,te=T[D+4]&255|(T[D+5]&255)<<8,Ge+=(Q>>>10|te<<6)&8191,fe=T[D+6]&255|(T[D+7]&255)<<8,pe+=(te>>>7|fe<<9)&8191,_e=T[D+8]&255|(T[D+9]&255)<<8,he+=(fe>>>4|_e<<12)&8191,Re+=_e>>>1&8191,je=T[D+10]&255|(T[D+11]&255)<<8,Oe+=(_e>>>14|je<<2)&8191,We=T[D+12]&255|(T[D+13]&255)<<8,Pe+=(je>>>11|We<<5)&8191,ct=T[D+14]&255|(T[D+15]&255)<<8,Be+=(We>>>8|ct<<8)&8191,vt+=ct>>>5|A,Ie=0,nt=Ie,nt+=Ne*Lt,nt+=Ke*(5*rn),nt+=Ge*(5*ln),nt+=pe*(5*jt),nt+=he*(5*un),Ie=nt>>>13,nt&=8191,nt+=Re*(5*sn),nt+=Oe*(5*Zt),nt+=Pe*(5*J),nt+=Be*(5*$t),nt+=vt*(5*Ft),Ie+=nt>>>13,nt&=8191,bt=Ie,bt+=Ne*Ft,bt+=Ke*Lt,bt+=Ge*(5*rn),bt+=pe*(5*ln),bt+=he*(5*jt),Ie=bt>>>13,bt&=8191,bt+=Re*(5*un),bt+=Oe*(5*sn),bt+=Pe*(5*Zt),bt+=Be*(5*J),bt+=vt*(5*$t),Ie+=bt>>>13,bt&=8191,Ot=Ie,Ot+=Ne*$t,Ot+=Ke*Ft,Ot+=Ge*Lt,Ot+=pe*(5*rn),Ot+=he*(5*ln),Ie=Ot>>>13,Ot&=8191,Ot+=Re*(5*jt),Ot+=Oe*(5*un),Ot+=Pe*(5*sn),Ot+=Be*(5*Zt),Ot+=vt*(5*J),Ie+=Ot>>>13,Ot&=8191,gt=Ie,gt+=Ne*J,gt+=Ke*$t,gt+=Ge*Ft,gt+=pe*Lt,gt+=he*(5*rn),Ie=gt>>>13,gt&=8191,gt+=Re*(5*ln),gt+=Oe*(5*jt),gt+=Pe*(5*un),gt+=Be*(5*sn),gt+=vt*(5*Zt),Ie+=gt>>>13,gt&=8191,ht=Ie,ht+=Ne*Zt,ht+=Ke*J,ht+=Ge*$t,ht+=pe*Ft,ht+=he*Lt,Ie=ht>>>13,ht&=8191,ht+=Re*(5*rn),ht+=Oe*(5*ln),ht+=Pe*(5*jt),ht+=Be*(5*un),ht+=vt*(5*sn),Ie+=ht>>>13,ht&=8191,xt=Ie,xt+=Ne*sn,xt+=Ke*Zt,xt+=Ge*J,xt+=pe*$t,xt+=he*Ft,Ie=xt>>>13,xt&=8191,xt+=Re*Lt,xt+=Oe*(5*rn),xt+=Pe*(5*ln),xt+=Be*(5*jt),xt+=vt*(5*un),Ie+=xt>>>13,xt&=8191,wt=Ie,wt+=Ne*un,wt+=Ke*sn,wt+=Ge*Zt,wt+=pe*J,wt+=he*$t,Ie=wt>>>13,wt&=8191,wt+=Re*Ft,wt+=Oe*Lt,wt+=Pe*(5*rn),wt+=Be*(5*ln),wt+=vt*(5*jt),Ie+=wt>>>13,wt&=8191,Qe=Ie,Qe+=Ne*jt,Qe+=Ke*un,Qe+=Ge*sn,Qe+=pe*Zt,Qe+=he*J,Ie=Qe>>>13,Qe&=8191,Qe+=Re*$t,Qe+=Oe*Ft,Qe+=Pe*Lt,Qe+=Be*(5*rn),Qe+=vt*(5*ln),Ie+=Qe>>>13,Qe&=8191,ut=Ie,ut+=Ne*ln,ut+=Ke*jt,ut+=Ge*un,ut+=pe*sn,ut+=he*Zt,Ie=ut>>>13,ut&=8191,ut+=Re*J,ut+=Oe*$t,ut+=Pe*Ft,ut+=Be*Lt,ut+=vt*(5*rn),Ie+=ut>>>13,ut&=8191,Xe=Ie,Xe+=Ne*rn,Xe+=Ke*ln,Xe+=Ge*jt,Xe+=pe*un,Xe+=he*sn,Ie=Xe>>>13,Xe&=8191,Xe+=Re*Zt,Xe+=Oe*J,Xe+=Pe*$t,Xe+=Be*Ft,Xe+=vt*Lt,Ie+=Xe>>>13,Xe&=8191,Ie=(Ie<<2)+Ie|0,Ie=Ie+nt|0,nt=Ie&8191,Ie=Ie>>>13,bt+=Ie,Ne=nt,Ke=bt,Ge=Ot,pe=gt,he=ht,Re=xt,Oe=wt,Pe=Qe,Be=ut,vt=Xe,D+=16,$-=16;this.h[0]=Ne,this.h[1]=Ke,this.h[2]=Ge,this.h[3]=pe,this.h[4]=he,this.h[5]=Re,this.h[6]=Oe,this.h[7]=Pe,this.h[8]=Be,this.h[9]=vt},W.prototype.finish=function(T,D){var $=new Uint16Array(10),A,L,Q,te;if(this.leftover){for(te=this.leftover,this.buffer[te++]=1;te<16;te++)this.buffer[te]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(A=this.h[1]>>>13,this.h[1]&=8191,te=2;te<10;te++)this.h[te]+=A,A=this.h[te]>>>13,this.h[te]&=8191;for(this.h[0]+=A*5,A=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=A,A=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=A,$[0]=this.h[0]+5,A=$[0]>>>13,$[0]&=8191,te=1;te<10;te++)$[te]=this.h[te]+A,A=$[te]>>>13,$[te]&=8191;for($[9]-=8192,L=(A^1)-1,te=0;te<10;te++)$[te]&=L;for(L=~L,te=0;te<10;te++)this.h[te]=this.h[te]&L|$[te];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,Q=this.h[0]+this.pad[0],this.h[0]=Q&65535,te=1;te<8;te++)Q=(this.h[te]+this.pad[te]|0)+(Q>>>16)|0,this.h[te]=Q&65535;T[D+0]=this.h[0]>>>0&255,T[D+1]=this.h[0]>>>8&255,T[D+2]=this.h[1]>>>0&255,T[D+3]=this.h[1]>>>8&255,T[D+4]=this.h[2]>>>0&255,T[D+5]=this.h[2]>>>8&255,T[D+6]=this.h[3]>>>0&255,T[D+7]=this.h[3]>>>8&255,T[D+8]=this.h[4]>>>0&255,T[D+9]=this.h[4]>>>8&255,T[D+10]=this.h[5]>>>0&255,T[D+11]=this.h[5]>>>8&255,T[D+12]=this.h[6]>>>0&255,T[D+13]=this.h[6]>>>8&255,T[D+14]=this.h[7]>>>0&255,T[D+15]=this.h[7]>>>8&255},W.prototype.update=function(T,D,$){var A,L;if(this.leftover){for(L=16-this.leftover,L>$&&(L=$),A=0;A=16&&(L=$-$%16,this.blocks(T,D,L),D+=L,$-=L),$){for(A=0;A<$;A++)this.buffer[this.leftover+A]=T[D+A];this.leftover+=$}};function V(T,D,$,A,L,Q){var te=new W(Q);return te.update($,A,L),te.finish(T,D),0}function ee(T,D,$,A,L,Q){var te=new Uint8Array(16);return V(te,0,$,A,L,Q),b(T,D,te,0)}function Z(T,D,$,A,L){var Q;if($<32)return-1;for(B(T,0,D,0,$,A,L),V(T,16,T,32,$-32,T),Q=0;Q<16;Q++)T[Q]=0;return 0}function K(T,D,$,A,L){var Q,te=new Uint8Array(32);if($<32||(I(te,0,32,A,L),ee(D,16,D,32,$-32,te)!==0))return-1;for(B(T,0,D,0,$,A,L),Q=0;Q<32;Q++)T[Q]=0;return 0}function G(T,D){var $;for($=0;$<16;$++)T[$]=D[$]|0}function H(T){var D,$,A=1;for(D=0;D<16;D++)$=T[D]+A+65535,A=Math.floor($/65536),T[D]=$-A*65536;T[0]+=A-1+37*(A-1)}function j(T,D,$){for(var A,L=~($-1),Q=0;Q<16;Q++)A=L&(T[Q]^D[Q]),T[Q]^=A,D[Q]^=A}function q(T,D){var $,A,L,Q=n(),te=n();for($=0;$<16;$++)te[$]=D[$];for(H(te),H(te),H(te),A=0;A<2;A++){for(Q[0]=te[0]-65517,$=1;$<15;$++)Q[$]=te[$]-65535-(Q[$-1]>>16&1),Q[$-1]&=65535;Q[15]=te[15]-32767-(Q[14]>>16&1),L=Q[15]>>16&1,Q[14]&=65535,j(te,Q,1-L)}for($=0;$<16;$++)T[2*$]=te[$]&255,T[2*$+1]=te[$]>>8}function Y(T,D){var $=new Uint8Array(32),A=new Uint8Array(32);return q($,T),q(A,D),w($,0,A,0)}function re(T){var D=new Uint8Array(32);return q(D,T),D[0]&1}function ie(T,D){var $;for($=0;$<16;$++)T[$]=D[2*$]+(D[2*$+1]<<8);T[15]&=32767}function se(T,D,$){for(var A=0;A<16;A++)T[A]=D[A]+$[A]}function ye(T,D,$){for(var A=0;A<16;A++)T[A]=D[A]-$[A]}function we(T,D,$){var A,L,Q=0,te=0,fe=0,_e=0,je=0,We=0,ct=0,Ie=0,nt=0,bt=0,Ot=0,gt=0,ht=0,xt=0,wt=0,Qe=0,ut=0,Xe=0,Ne=0,Ke=0,Ge=0,pe=0,he=0,Re=0,Oe=0,Pe=0,Be=0,vt=0,Lt=0,Ft=0,$t=0,J=$[0],Zt=$[1],sn=$[2],un=$[3],jt=$[4],ln=$[5],rn=$[6],Gn=$[7],mn=$[8],Pn=$[9],Yn=$[10],Zn=$[11],xr=$[12],$r=$[13],Ir=$[14],Nr=$[15];A=D[0],Q+=A*J,te+=A*Zt,fe+=A*sn,_e+=A*un,je+=A*jt,We+=A*ln,ct+=A*rn,Ie+=A*Gn,nt+=A*mn,bt+=A*Pn,Ot+=A*Yn,gt+=A*Zn,ht+=A*xr,xt+=A*$r,wt+=A*Ir,Qe+=A*Nr,A=D[1],te+=A*J,fe+=A*Zt,_e+=A*sn,je+=A*un,We+=A*jt,ct+=A*ln,Ie+=A*rn,nt+=A*Gn,bt+=A*mn,Ot+=A*Pn,gt+=A*Yn,ht+=A*Zn,xt+=A*xr,wt+=A*$r,Qe+=A*Ir,ut+=A*Nr,A=D[2],fe+=A*J,_e+=A*Zt,je+=A*sn,We+=A*un,ct+=A*jt,Ie+=A*ln,nt+=A*rn,bt+=A*Gn,Ot+=A*mn,gt+=A*Pn,ht+=A*Yn,xt+=A*Zn,wt+=A*xr,Qe+=A*$r,ut+=A*Ir,Xe+=A*Nr,A=D[3],_e+=A*J,je+=A*Zt,We+=A*sn,ct+=A*un,Ie+=A*jt,nt+=A*ln,bt+=A*rn,Ot+=A*Gn,gt+=A*mn,ht+=A*Pn,xt+=A*Yn,wt+=A*Zn,Qe+=A*xr,ut+=A*$r,Xe+=A*Ir,Ne+=A*Nr,A=D[4],je+=A*J,We+=A*Zt,ct+=A*sn,Ie+=A*un,nt+=A*jt,bt+=A*ln,Ot+=A*rn,gt+=A*Gn,ht+=A*mn,xt+=A*Pn,wt+=A*Yn,Qe+=A*Zn,ut+=A*xr,Xe+=A*$r,Ne+=A*Ir,Ke+=A*Nr,A=D[5],We+=A*J,ct+=A*Zt,Ie+=A*sn,nt+=A*un,bt+=A*jt,Ot+=A*ln,gt+=A*rn,ht+=A*Gn,xt+=A*mn,wt+=A*Pn,Qe+=A*Yn,ut+=A*Zn,Xe+=A*xr,Ne+=A*$r,Ke+=A*Ir,Ge+=A*Nr,A=D[6],ct+=A*J,Ie+=A*Zt,nt+=A*sn,bt+=A*un,Ot+=A*jt,gt+=A*ln,ht+=A*rn,xt+=A*Gn,wt+=A*mn,Qe+=A*Pn,ut+=A*Yn,Xe+=A*Zn,Ne+=A*xr,Ke+=A*$r,Ge+=A*Ir,pe+=A*Nr,A=D[7],Ie+=A*J,nt+=A*Zt,bt+=A*sn,Ot+=A*un,gt+=A*jt,ht+=A*ln,xt+=A*rn,wt+=A*Gn,Qe+=A*mn,ut+=A*Pn,Xe+=A*Yn,Ne+=A*Zn,Ke+=A*xr,Ge+=A*$r,pe+=A*Ir,he+=A*Nr,A=D[8],nt+=A*J,bt+=A*Zt,Ot+=A*sn,gt+=A*un,ht+=A*jt,xt+=A*ln,wt+=A*rn,Qe+=A*Gn,ut+=A*mn,Xe+=A*Pn,Ne+=A*Yn,Ke+=A*Zn,Ge+=A*xr,pe+=A*$r,he+=A*Ir,Re+=A*Nr,A=D[9],bt+=A*J,Ot+=A*Zt,gt+=A*sn,ht+=A*un,xt+=A*jt,wt+=A*ln,Qe+=A*rn,ut+=A*Gn,Xe+=A*mn,Ne+=A*Pn,Ke+=A*Yn,Ge+=A*Zn,pe+=A*xr,he+=A*$r,Re+=A*Ir,Oe+=A*Nr,A=D[10],Ot+=A*J,gt+=A*Zt,ht+=A*sn,xt+=A*un,wt+=A*jt,Qe+=A*ln,ut+=A*rn,Xe+=A*Gn,Ne+=A*mn,Ke+=A*Pn,Ge+=A*Yn,pe+=A*Zn,he+=A*xr,Re+=A*$r,Oe+=A*Ir,Pe+=A*Nr,A=D[11],gt+=A*J,ht+=A*Zt,xt+=A*sn,wt+=A*un,Qe+=A*jt,ut+=A*ln,Xe+=A*rn,Ne+=A*Gn,Ke+=A*mn,Ge+=A*Pn,pe+=A*Yn,he+=A*Zn,Re+=A*xr,Oe+=A*$r,Pe+=A*Ir,Be+=A*Nr,A=D[12],ht+=A*J,xt+=A*Zt,wt+=A*sn,Qe+=A*un,ut+=A*jt,Xe+=A*ln,Ne+=A*rn,Ke+=A*Gn,Ge+=A*mn,pe+=A*Pn,he+=A*Yn,Re+=A*Zn,Oe+=A*xr,Pe+=A*$r,Be+=A*Ir,vt+=A*Nr,A=D[13],xt+=A*J,wt+=A*Zt,Qe+=A*sn,ut+=A*un,Xe+=A*jt,Ne+=A*ln,Ke+=A*rn,Ge+=A*Gn,pe+=A*mn,he+=A*Pn,Re+=A*Yn,Oe+=A*Zn,Pe+=A*xr,Be+=A*$r,vt+=A*Ir,Lt+=A*Nr,A=D[14],wt+=A*J,Qe+=A*Zt,ut+=A*sn,Xe+=A*un,Ne+=A*jt,Ke+=A*ln,Ge+=A*rn,pe+=A*Gn,he+=A*mn,Re+=A*Pn,Oe+=A*Yn,Pe+=A*Zn,Be+=A*xr,vt+=A*$r,Lt+=A*Ir,Ft+=A*Nr,A=D[15],Qe+=A*J,ut+=A*Zt,Xe+=A*sn,Ne+=A*un,Ke+=A*jt,Ge+=A*ln,pe+=A*rn,he+=A*Gn,Re+=A*mn,Oe+=A*Pn,Pe+=A*Yn,Be+=A*Zn,vt+=A*xr,Lt+=A*$r,Ft+=A*Ir,$t+=A*Nr,Q+=38*ut,te+=38*Xe,fe+=38*Ne,_e+=38*Ke,je+=38*Ge,We+=38*pe,ct+=38*he,Ie+=38*Re,nt+=38*Oe,bt+=38*Pe,Ot+=38*Be,gt+=38*vt,ht+=38*Lt,xt+=38*Ft,wt+=38*$t,L=1,A=Q+L+65535,L=Math.floor(A/65536),Q=A-L*65536,A=te+L+65535,L=Math.floor(A/65536),te=A-L*65536,A=fe+L+65535,L=Math.floor(A/65536),fe=A-L*65536,A=_e+L+65535,L=Math.floor(A/65536),_e=A-L*65536,A=je+L+65535,L=Math.floor(A/65536),je=A-L*65536,A=We+L+65535,L=Math.floor(A/65536),We=A-L*65536,A=ct+L+65535,L=Math.floor(A/65536),ct=A-L*65536,A=Ie+L+65535,L=Math.floor(A/65536),Ie=A-L*65536,A=nt+L+65535,L=Math.floor(A/65536),nt=A-L*65536,A=bt+L+65535,L=Math.floor(A/65536),bt=A-L*65536,A=Ot+L+65535,L=Math.floor(A/65536),Ot=A-L*65536,A=gt+L+65535,L=Math.floor(A/65536),gt=A-L*65536,A=ht+L+65535,L=Math.floor(A/65536),ht=A-L*65536,A=xt+L+65535,L=Math.floor(A/65536),xt=A-L*65536,A=wt+L+65535,L=Math.floor(A/65536),wt=A-L*65536,A=Qe+L+65535,L=Math.floor(A/65536),Qe=A-L*65536,Q+=L-1+37*(L-1),L=1,A=Q+L+65535,L=Math.floor(A/65536),Q=A-L*65536,A=te+L+65535,L=Math.floor(A/65536),te=A-L*65536,A=fe+L+65535,L=Math.floor(A/65536),fe=A-L*65536,A=_e+L+65535,L=Math.floor(A/65536),_e=A-L*65536,A=je+L+65535,L=Math.floor(A/65536),je=A-L*65536,A=We+L+65535,L=Math.floor(A/65536),We=A-L*65536,A=ct+L+65535,L=Math.floor(A/65536),ct=A-L*65536,A=Ie+L+65535,L=Math.floor(A/65536),Ie=A-L*65536,A=nt+L+65535,L=Math.floor(A/65536),nt=A-L*65536,A=bt+L+65535,L=Math.floor(A/65536),bt=A-L*65536,A=Ot+L+65535,L=Math.floor(A/65536),Ot=A-L*65536,A=gt+L+65535,L=Math.floor(A/65536),gt=A-L*65536,A=ht+L+65535,L=Math.floor(A/65536),ht=A-L*65536,A=xt+L+65535,L=Math.floor(A/65536),xt=A-L*65536,A=wt+L+65535,L=Math.floor(A/65536),wt=A-L*65536,A=Qe+L+65535,L=Math.floor(A/65536),Qe=A-L*65536,Q+=L-1+37*(L-1),T[0]=Q,T[1]=te,T[2]=fe,T[3]=_e,T[4]=je,T[5]=We,T[6]=ct,T[7]=Ie,T[8]=nt,T[9]=bt,T[10]=Ot,T[11]=gt,T[12]=ht,T[13]=xt,T[14]=wt,T[15]=Qe}function He(T,D){we(T,D,D)}function Ee(T,D){var $=n(),A;for(A=0;A<16;A++)$[A]=D[A];for(A=253;A>=0;A--)He($,$),A!==2&&A!==4&&we($,$,D);for(A=0;A<16;A++)T[A]=$[A]}function it(T,D){var $=n(),A;for(A=0;A<16;A++)$[A]=D[A];for(A=250;A>=0;A--)He($,$),A!==1&&we($,$,D);for(A=0;A<16;A++)T[A]=$[A]}function ke(T,D,$){var A=new Uint8Array(32),L=new Float64Array(80),Q,te,fe=n(),_e=n(),je=n(),We=n(),ct=n(),Ie=n();for(te=0;te<31;te++)A[te]=D[te];for(A[31]=D[31]&127|64,A[0]&=248,ie(L,$),te=0;te<16;te++)_e[te]=L[te],We[te]=fe[te]=je[te]=0;for(fe[0]=We[0]=1,te=254;te>=0;--te)Q=A[te>>>3]>>>(te&7)&1,j(fe,_e,Q),j(je,We,Q),se(ct,fe,je),ye(fe,fe,je),se(je,_e,We),ye(_e,_e,We),He(We,ct),He(Ie,fe),we(fe,je,fe),we(je,_e,ct),se(ct,fe,je),ye(fe,fe,je),He(_e,fe),ye(je,We,Ie),we(fe,je,u),se(fe,fe,We),we(je,je,fe),we(fe,We,Ie),we(We,_e,L),He(_e,ct),j(fe,_e,Q),j(je,We,Q);for(te=0;te<16;te++)L[te+16]=fe[te],L[te+32]=je[te],L[te+48]=_e[te],L[te+64]=We[te];var nt=L.subarray(32),bt=L.subarray(16);return Ee(nt,nt),we(bt,bt,nt),q(T,bt),0}function Le(T,D){return ke(T,D,o)}function De(T,D){return r(D,32),Le(T,D)}function me(T,D,$){var A=new Uint8Array(32);return ke(A,$,D),E(T,i,A,C)}var yt=Z,lt=K;function Nt(T,D,$,A,L,Q){var te=new Uint8Array(32);return me(te,L,Q),yt(T,D,$,A,te)}function bn(T,D,$,A,L,Q){var te=new Uint8Array(32);return me(te,L,Q),lt(T,D,$,A,te)}var nn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ne(T,D,$,A){for(var L=new Int32Array(16),Q=new Int32Array(16),te,fe,_e,je,We,ct,Ie,nt,bt,Ot,gt,ht,xt,wt,Qe,ut,Xe,Ne,Ke,Ge,pe,he,Re,Oe,Pe,Be,vt=T[0],Lt=T[1],Ft=T[2],$t=T[3],J=T[4],Zt=T[5],sn=T[6],un=T[7],jt=D[0],ln=D[1],rn=D[2],Gn=D[3],mn=D[4],Pn=D[5],Yn=D[6],Zn=D[7],xr=0;A>=128;){for(Ke=0;Ke<16;Ke++)Ge=8*Ke+xr,L[Ke]=$[Ge+0]<<24|$[Ge+1]<<16|$[Ge+2]<<8|$[Ge+3],Q[Ke]=$[Ge+4]<<24|$[Ge+5]<<16|$[Ge+6]<<8|$[Ge+7];for(Ke=0;Ke<80;Ke++)if(te=vt,fe=Lt,_e=Ft,je=$t,We=J,ct=Zt,Ie=sn,nt=un,bt=jt,Ot=ln,gt=rn,ht=Gn,xt=mn,wt=Pn,Qe=Yn,ut=Zn,pe=un,he=Zn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=(J>>>14|mn<<18)^(J>>>18|mn<<14)^(mn>>>9|J<<23),he=(mn>>>14|J<<18)^(mn>>>18|J<<14)^(J>>>9|mn<<23),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=J&Zt^~J&sn,he=mn&Pn^~mn&Yn,Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=nn[Ke*2],he=nn[Ke*2+1],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=L[Ke%16],he=Q[Ke%16],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,Xe=Pe&65535|Be<<16,Ne=Re&65535|Oe<<16,pe=Xe,he=Ne,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=(vt>>>28|jt<<4)^(jt>>>2|vt<<30)^(jt>>>7|vt<<25),he=(jt>>>28|vt<<4)^(vt>>>2|jt<<30)^(vt>>>7|jt<<25),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,pe=vt&Lt^vt&Ft^Lt&Ft,he=jt&ln^jt&rn^ln&rn,Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,nt=Pe&65535|Be<<16,ut=Re&65535|Oe<<16,pe=je,he=ht,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=Xe,he=Ne,Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,je=Pe&65535|Be<<16,ht=Re&65535|Oe<<16,Lt=te,Ft=fe,$t=_e,J=je,Zt=We,sn=ct,un=Ie,vt=nt,ln=bt,rn=Ot,Gn=gt,mn=ht,Pn=xt,Yn=wt,Zn=Qe,jt=ut,Ke%16===15)for(Ge=0;Ge<16;Ge++)pe=L[Ge],he=Q[Ge],Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=L[(Ge+9)%16],he=Q[(Ge+9)%16],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Xe=L[(Ge+1)%16],Ne=Q[(Ge+1)%16],pe=(Xe>>>1|Ne<<31)^(Xe>>>8|Ne<<24)^Xe>>>7,he=(Ne>>>1|Xe<<31)^(Ne>>>8|Xe<<24)^(Ne>>>7|Xe<<25),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Xe=L[(Ge+14)%16],Ne=Q[(Ge+14)%16],pe=(Xe>>>19|Ne<<13)^(Ne>>>29|Xe<<3)^Xe>>>6,he=(Ne>>>19|Xe<<13)^(Xe>>>29|Ne<<3)^(Ne>>>6|Xe<<26),Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,L[Ge]=Pe&65535|Be<<16,Q[Ge]=Re&65535|Oe<<16;pe=vt,he=jt,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[0],he=D[0],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[0]=vt=Pe&65535|Be<<16,D[0]=jt=Re&65535|Oe<<16,pe=Lt,he=ln,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[1],he=D[1],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[1]=Lt=Pe&65535|Be<<16,D[1]=ln=Re&65535|Oe<<16,pe=Ft,he=rn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[2],he=D[2],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[2]=Ft=Pe&65535|Be<<16,D[2]=rn=Re&65535|Oe<<16,pe=$t,he=Gn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[3],he=D[3],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[3]=$t=Pe&65535|Be<<16,D[3]=Gn=Re&65535|Oe<<16,pe=J,he=mn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[4],he=D[4],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[4]=J=Pe&65535|Be<<16,D[4]=mn=Re&65535|Oe<<16,pe=Zt,he=Pn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[5],he=D[5],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[5]=Zt=Pe&65535|Be<<16,D[5]=Pn=Re&65535|Oe<<16,pe=sn,he=Yn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[6],he=D[6],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[6]=sn=Pe&65535|Be<<16,D[6]=Yn=Re&65535|Oe<<16,pe=un,he=Zn,Re=he&65535,Oe=he>>>16,Pe=pe&65535,Be=pe>>>16,pe=T[7],he=D[7],Re+=he&65535,Oe+=he>>>16,Pe+=pe&65535,Be+=pe>>>16,Oe+=Re>>>16,Pe+=Oe>>>16,Be+=Pe>>>16,T[7]=un=Pe&65535|Be<<16,D[7]=Zn=Re&65535|Oe<<16,xr+=128,A-=128}return A}function de(T,D,$){var A=new Int32Array(8),L=new Int32Array(8),Q=new Uint8Array(256),te,fe=$;for(A[0]=1779033703,A[1]=3144134277,A[2]=1013904242,A[3]=2773480762,A[4]=1359893119,A[5]=2600822924,A[6]=528734635,A[7]=1541459225,L[0]=4089235720,L[1]=2227873595,L[2]=4271175723,L[3]=1595750129,L[4]=2917565137,L[5]=725511199,L[6]=4215389547,L[7]=327033209,ne(A,L,D,$),$%=128,te=0;te<$;te++)Q[te]=D[fe-$+te];for(Q[$]=128,$=256-128*($<112?1:0),Q[$-9]=0,m(Q,$-8,fe/536870912|0,fe<<3),ne(A,L,Q,$),te=0;te<8;te++)m(T,8*te,A[te],L[te]);return 0}function ge(T,D){var $=n(),A=n(),L=n(),Q=n(),te=n(),fe=n(),_e=n(),je=n(),We=n();ye($,T[1],T[0]),ye(We,D[1],D[0]),we($,$,We),se(A,T[0],T[1]),se(We,D[0],D[1]),we(A,A,We),we(L,T[3],D[3]),we(L,L,c),we(Q,T[2],D[2]),se(Q,Q,Q),ye(te,A,$),ye(fe,Q,L),se(_e,Q,L),se(je,A,$),we(T[0],te,fe),we(T[1],je,_e),we(T[2],_e,fe),we(T[3],te,je)}function ze(T,D,$){var A;for(A=0;A<4;A++)j(T[A],D[A],$)}function Fe(T,D){var $=n(),A=n(),L=n();Ee(L,D[2]),we($,D[0],L),we(A,D[1],L),q(T,A),T[31]^=re($)<<7}function Ae(T,D,$){var A,L;for(G(T[0],a),G(T[1],s),G(T[2],s),G(T[3],a),L=255;L>=0;--L)A=$[L/8|0]>>(L&7)&1,ze(T,D,A),ge(D,T),ge(T,T),ze(T,D,A)}function tt(T,D){var $=[n(),n(),n(),n()];G($[0],f),G($[1],h),G($[2],s),we($[3],f,h),Ae(T,$,D)}function mt(T,D,$){var A=new Uint8Array(64),L=[n(),n(),n(),n()],Q;for($||r(D,32),de(A,D,32),A[0]&=248,A[31]&=127,A[31]|=64,tt(L,A),Fe(T,L),Q=0;Q<32;Q++)D[Q+32]=T[Q];return 0}var wn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Kt(T,D){var $,A,L,Q;for(A=63;A>=32;--A){for($=0,L=A-32,Q=A-12;L>4)*wn[L],$=D[L]>>8,D[L]&=255;for(L=0;L<32;L++)D[L]-=$*wn[L];for(A=0;A<32;A++)D[A+1]+=D[A]>>8,T[A]=D[A]&255}function _n(T){var D=new Float64Array(64),$;for($=0;$<64;$++)D[$]=T[$];for($=0;$<64;$++)T[$]=0;Kt(T,D)}function Ii(T,D,$,A){var L=new Uint8Array(64),Q=new Uint8Array(64),te=new Uint8Array(64),fe,_e,je=new Float64Array(64),We=[n(),n(),n(),n()];de(L,A,32),L[0]&=248,L[31]&=127,L[31]|=64;var ct=$+64;for(fe=0;fe<$;fe++)T[64+fe]=D[fe];for(fe=0;fe<32;fe++)T[32+fe]=L[32+fe];for(de(te,T.subarray(32),$+32),_n(te),tt(We,te),Fe(T,We),fe=32;fe<64;fe++)T[fe]=A[fe];for(de(Q,T,$+64),_n(Q),fe=0;fe<64;fe++)je[fe]=0;for(fe=0;fe<32;fe++)je[fe]=te[fe];for(fe=0;fe<32;fe++)for(_e=0;_e<32;_e++)je[fe+_e]+=Q[fe]*L[_e];return Kt(T.subarray(32),je),ct}function br(T,D){var $=n(),A=n(),L=n(),Q=n(),te=n(),fe=n(),_e=n();return G(T[2],s),ie(T[1],D),He(L,T[1]),we(Q,L,l),ye(L,L,T[2]),se(Q,T[2],Q),He(te,Q),He(fe,te),we(_e,fe,te),we($,_e,L),we($,$,Q),it($,$),we($,$,L),we($,$,Q),we($,$,Q),we(T[0],$,Q),He(A,T[0]),we(A,A,Q),Y(A,L)&&we(T[0],T[0],p),He(A,T[0]),we(A,A,Q),Y(A,L)?-1:(re(T[0])===D[31]>>7&&ye(T[0],a,T[0]),we(T[3],T[0],T[1]),0)}function yi(T,D,$,A){var L,Q=new Uint8Array(32),te=new Uint8Array(64),fe=[n(),n(),n(),n()],_e=[n(),n(),n(),n()];if($<64||br(_e,A))return-1;for(L=0;L<$;L++)T[L]=D[L];for(L=0;L<32;L++)T[L+32]=A[L];if(de(te,T,$),_n(te),Ae(fe,_e,te),tt(_e,D.subarray(32)),ge(fe,_e),Fe(Q,fe),$-=64,w(D,0,Q,0)){for(L=0;L<$;L++)T[L]=0;return-1}for(L=0;L<$;L++)T[L]=D[L+64];return $}var sr=32,si=24,bi=32,Rr=16,Xi=32,yo=32,xi=32,Dr=32,Sa=32,_t=si,hn=bi,Sn=Rr,qn=64,ur=32,Xr=64,bo=32,Ql=64;t.lowlevel={crypto_core_hsalsa20:E,crypto_stream_xor:B,crypto_stream:I,crypto_stream_salsa20_xor:P,crypto_stream_salsa20:M,crypto_onetimeauth:V,crypto_onetimeauth_verify:ee,crypto_verify_16:b,crypto_verify_32:w,crypto_secretbox:Z,crypto_secretbox_open:K,crypto_scalarmult:ke,crypto_scalarmult_base:Le,crypto_box_beforenm:me,crypto_box_afternm:yt,crypto_box:Nt,crypto_box_open:bn,crypto_box_keypair:De,crypto_hash:de,crypto_sign:Ii,crypto_sign_keypair:mt,crypto_sign_open:yi,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:si,crypto_secretbox_ZEROBYTES:bi,crypto_secretbox_BOXZEROBYTES:Rr,crypto_scalarmult_BYTES:Xi,crypto_scalarmult_SCALARBYTES:yo,crypto_box_PUBLICKEYBYTES:xi,crypto_box_SECRETKEYBYTES:Dr,crypto_box_BEFORENMBYTES:Sa,crypto_box_NONCEBYTES:_t,crypto_box_ZEROBYTES:hn,crypto_box_BOXZEROBYTES:Sn,crypto_sign_BYTES:qn,crypto_sign_PUBLICKEYBYTES:ur,crypto_sign_SECRETKEYBYTES:Xr,crypto_sign_SEEDBYTES:bo,crypto_hash_BYTES:Ql,gf:n,D:l,L:wn,pack25519:q,unpack25519:ie,M:we,A:se,S:He,Z:ye,pow2523:it,add:ge,set25519:G,modL:Kt,scalarmult:Ae,scalarbase:tt};function Ef(T,D){if(T.length!==sr)throw new Error("bad key size");if(D.length!==si)throw new Error("bad nonce size")}function oe(T,D){if(T.length!==xi)throw new Error("bad public key size");if(D.length!==Dr)throw new Error("bad secret key size")}function ue(){for(var T=0;T=0},t.sign.keyPair=function(){var T=new Uint8Array(ur),D=new Uint8Array(Xr);return mt(T,D),{publicKey:T,secretKey:D}},t.sign.keyPair.fromSecretKey=function(T){if(ue(T),T.length!==Xr)throw new Error("bad secret key size");for(var D=new Uint8Array(ur),$=0;$"u"?typeof Buffer.from<"u"?(t.encodeBase64=function(r){return Buffer.from(r).toString("base64")},t.decodeBase64=function(r){return n(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(t.encodeBase64=function(r){return new Buffer(r).toString("base64")},t.decodeBase64=function(r){return n(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(t.encodeBase64=function(r){var i,o=[],a=r.length;for(i=0;i{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:a,disabled:s,value:u="on",onCheckedChange:l,form:c,...f}=e,[h,p]=y.useState(null),m=Yt(t,O=>p(O)),v=y.useRef(!1),b=h?c||!!h.closest("form"):!0,[w=!1,x]=Xa({prop:i,defaultProp:o,onChange:l}),S=y.useRef(w);return y.useEffect(()=>{const O=h?.form;if(O){const E=()=>x(S.current);return O.addEventListener("reset",E),()=>O.removeEventListener("reset",E)}},[h,x]),N.jsxs(fZe,{scope:n,state:w,disabled:s,children:[N.jsx(pt.button,{type:"button",role:"checkbox","aria-checked":El(w)?"mixed":w,"aria-required":a,"data-state":BZ(w),"data-disabled":s?"":void 0,disabled:s,value:u,...f,ref:m,onKeyDown:Ye(e.onKeyDown,O=>{O.key==="Enter"&&O.preventDefault()}),onClick:Ye(e.onClick,O=>{x(E=>El(E)?!0:!E),b&&(v.current=O.isPropagationStopped(),v.current||O.stopPropagation())})}),b&&N.jsx(hZe,{control:h,bubbles:!v.current,name:r,value:u,checked:w,required:a,disabled:s,form:c,style:{transform:"translateX(-100%)"},defaultChecked:El(o)?!1:o})]})});LZ.displayName=WP;var FZ="CheckboxIndicator",jZ=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=dZe(FZ,n);return N.jsx(Gr,{present:r||El(o.state)||o.state===!0,children:N.jsx(pt.span,{"data-state":BZ(o.state),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});jZ.displayName=FZ;var hZe=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:i,...o}=e,a=y.useRef(null),s=sP(n),u=_5(t);y.useEffect(()=>{const c=a.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(s!==n&&p){const m=new Event("click",{bubbles:r});c.indeterminate=El(n),p.call(c,El(n)?!1:n),c.dispatchEvent(m)}},[s,n,r]);const l=y.useRef(El(n)?!1:n);return N.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i??l.current,...o,tabIndex:-1,ref:a,style:{...e.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function El(e){return e==="indeterminate"}function BZ(e){return El(e)?"indeterminate":e?"checked":"unchecked"}var Eet=LZ,Oet=jZ;export{Qme as $,PXe as A,Yi as B,aXe as C,Dge as D,cXe as E,oXe as F,rT as G,F as H,zZe as I,xXe as J,vZe as K,gXe as L,EXe as M,jZe as N,gZe as O,xZe as P,yXe as Q,iXe as R,kl as S,mXe as T,FZe as U,wZe as V,qme as W,Zme as X,Xme as Y,uU as Z,jXe as _,SZe as a,HZe as a$,Jme as a0,Gme as a1,Yme as a2,hQe as a3,NXe as a4,pQe as a5,iQe as a6,oQe as a7,uQe as a8,lQe as a9,IZe as aA,KZe as aB,DZe as aC,BZe as aD,YZe as aE,GZe as aF,UZe as aG,qZe as aH,kZe as aI,AZe as aJ,NZe as aK,nXe as aL,tXe as aM,JZe as aN,rXe as aO,WZe as aP,MZe as aQ,pJe as aR,HXe as aS,rJe as aT,vJe as aU,yJe as aV,bJe as aW,Vwe as aX,Ywe as aY,LZe as aZ,bf as a_,fQe as aa,RXe as ab,cQe as ac,zXe as ad,sQe as ae,dQe as af,nQe as ag,rQe as ah,aQe as ai,QXe as aj,XXe as ak,JXe as al,RZe as am,mQe as an,Aye as ao,Pye as ap,yQe as aq,_Qe as ar,bQe as as,xQe as at,yZe as au,TZe as av,$Ze as aw,ZZe as ax,EZe as ay,XQe as az,bse as b,VZe as b$,XZe as b0,wJe as b1,_Je as b2,SJe as b3,_Ze as b4,AJe as b5,kJe as b6,PJe as b7,TJe as b8,$Xe as b9,Cf as bA,ip as bB,UJe as bC,CQe as bD,PQe as bE,YQe as bF,kQe as bG,fJe as bH,cJe as bI,UQe as bJ,lJe as bK,ZQe as bL,SQe as bM,AQe as bN,EQe as bO,gJe as bP,Ui as bQ,ZJe as bR,XJe as bS,GQe as bT,sJe as bU,nJe as bV,zQe as bW,NQe as bX,IQe as bY,PZe as bZ,eXe as b_,jJe as ba,LXe as bb,BJe as bc,MJe as bd,RJe as be,DJe as bf,IJe as bg,NJe as bh,FJe as bi,LJe as bj,zJe as bk,$Je as bl,VJe as bm,IXe as bn,qJe as bo,GJe as bp,HJe as bq,KJe as br,ZS as bs,TQe as bt,CJe as bu,EJe as bv,oP as bw,aP as bx,nBe as by,eu as bz,dn as c,bZe as c$,OZe as c0,QZe as c1,JJe as c2,eet as c3,tJe as c4,UXe as c5,VXe as c6,set as c7,cet as c8,LQe as c9,$Qe as cA,dJe as cB,ts as cC,yr as cD,KQe as cE,net as cF,ret as cG,GXe as cH,tf as cI,wQe as cJ,wet as cK,_et as cL,iJe as cM,jQe as cN,VQe as cO,QQe as cP,BQe as cQ,aJe as cR,HQe as cS,Eet as cT,Oet as cU,FXe as cV,ZXe as cW,DXe as cX,BXe as cY,YXe as cZ,WQe as c_,OQe as ca,get as cb,met as cc,bet as cd,xet as ce,vet as cf,yet as cg,det as ch,het as ci,pet as cj,WXe as ck,qXe as cl,uJe as cm,uet as cn,tet as co,iet as cp,oet as cq,aet as cr,pce as cs,xce as ct,lce as cu,JQe as cv,oJe as cw,eJe as cx,qQe as cy,DQe as cz,_m as d,RQe as d0,RWe as d1,KXe as d2,FQe as d3,MQe as d4,dXe as e,WO as f,vXe as g,pXe as h,SXe as i,N as j,qr as k,CXe as l,fXe as m,sXe as n,uXe as o,wXe as p,_Xe as q,y as r,OXe as s,CZe as t,uj as u,AXe as v,mZe as w,kXe as x,TXe as y,lXe as z};