From 213aff39934a590eed4f1d2f5152b2353649a697 Mon Sep 17 00:00:00 2001 From: xboard Date: Mon, 20 Oct 2025 21:46:26 +0800 Subject: [PATCH] feat(admin): add Custom ID/Original ID display with copy actions --- public/assets/admin/assets/index.css | 2 +- public/assets/admin/assets/index.js | 20 ++++++++++---------- public/assets/admin/index.html | 2 +- public/assets/admin/locales/en-US.js | 6 +++++- public/assets/admin/locales/zh-CN.js | 6 +++++- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/public/assets/admin/assets/index.css b/public/assets/admin/assets/index.css index 0b94759..88af0bb 100644 --- a/public/assets/admin/assets/index.css +++ b/public/assets/admin/assets/index.css @@ -1 +1 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--header-height: 4rem;--background: 0 0% 100%;--foreground: 222.2 84% 4.9%;--card: 0 0% 100%;--card-foreground: 222.2 84% 4.9%;--popover: 0 0% 100%;--popover-foreground: 222.2 84% 4.9%;--primary: 222.2 47.4% 11.2%;--primary-foreground: 210 40% 98%;--secondary: 210 40% 96.1%;--secondary-foreground: 222.2 47.4% 11.2%;--muted: 210 40% 96.1%;--muted-foreground: 215.4 16.3% 46.9%;--accent: 210 40% 96.1%;--accent-foreground: 222.2 47.4% 11.2%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;--border: 214.3 31.8% 91.4%;--input: 214.3 31.8% 91.4%;--ring: 222.2 84% 4.9%;--radius: .5rem}.dark{--background: 222.2 84% 4.9%;--foreground: 210 40% 98%;--card: 222.2 84% 4.9%;--card-foreground: 210 40% 98%;--popover: 222.2 84% 4.9%;--popover-foreground: 210 40% 98%;--primary: 210 40% 98%;--primary-foreground: 222.2 47.4% 11.2%;--secondary: 217.2 32.6% 17.5%;--secondary-foreground: 210 40% 98%;--muted: 217.2 32.6% 17.5%;--muted-foreground: 215 20.2% 65.1%;--accent: 217.2 32.6% 17.5%;--accent-foreground: 210 40% 98%;--destructive: 0 62.8% 30.6%;--destructive-foreground: 210 40% 98%;--border: 217.2 32.6% 17.5%;--input: 217.2 32.6% 17.5%;--ring: 212.7 26.8% 83.9%}.collapsibleDropdown{overflow:hidden}.collapsibleDropdown[data-state=open]{animation:slideDown .2s ease-out}.collapsibleDropdown[data-state=closed]{animation:slideUp .2s ease-out}@keyframes slideDown{0%{height:0}to{height:var(--radix-collapsible-content-height)}}@keyframes slideUp{0%{height:var(--radix-collapsible-content-height)}to{height:0}}*{border-color:hsl(var(--border))}body{min-height:100svh;width:100%;background-color:hsl(var(--background));color:hsl(var(--foreground))}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media (min-width: 1400px){.container{max-width:1400px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.invisible{visibility:hidden}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.-left-1{left:-.25rem}.-right-1{right:-.25rem}.-right-5{right:-1.25rem}.-top-1{top:-.25rem}.-top-1\/2{top:-50%}.bottom-0{bottom:0}.bottom-5{bottom:1.25rem}.bottom-full{bottom:100%}.left-0{left:0}.left-1\/2{left:50%}.left-2{left:.5rem}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[50\%\]{left:50%}.right-0{right:0}.right-1{right:.25rem}.right-1\.5{right:.375rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-5{right:1.25rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-2\.5{top:.625rem}.top-4{top:1rem}.top-\[1px\]{top:1px}.top-\[50\%\]{top:50%}.top-\[60\%\]{top:60%}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[-1\]{z-index:-1}.z-\[1\]{z-index:1}.col-span-2{grid-column:span 2 / span 2}.col-span-3{grid-column:span 3 / span 3}.-m-0\.5{margin:-.125rem}.m-1{margin:.25rem}.m-auto{margin:auto}.-mx-1{margin-left:-.25rem;margin-right:-.25rem}.-mx-4{margin-left:-1rem;margin-right:-1rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-4{margin-top:1rem;margin-bottom:1rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.-ml-3{margin-left:-.75rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-8{margin-left:2rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-4{margin-right:1rem}.mr-auto{margin-right:auto}.mt-0{margin-top:0}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-24{margin-top:6rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.\!table{display:table!important}.table{display:table}.grid{display:grid}.hidden{display:none}.aspect-\[16\/9\]{aspect-ratio:16/9}.aspect-square{aspect-ratio:1 / 1}.size-10{width:2.5rem;height:2.5rem}.size-2\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-\[--cell-size\]{width:var(--cell-size);height:var(--cell-size)}.h-0{height:0px}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-40{height:10rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-\[--cell-size\]{height:var(--cell-size)}.h-\[100vh\]{height:100vh}.h-\[180px\]{height:180px}.h-\[1px\]{height:1px}.h-\[200px\]{height:200px}.h-\[300px\]{height:300px}.h-\[400px\]{height:400px}.h-\[85vh\]{height:85vh}.h-\[90vh\]{height:90vh}.h-\[calc\(100\%-var\(--header-height\)\)\]{height:calc(100% - var(--header-height))}.h-\[calc\(100vh-280px\)\]{height:calc(100vh - 280px)}.h-\[var\(--header-height\)\]{height:var(--header-height)}.h-\[var\(--radix-navigation-menu-viewport-height\)\]{height:var(--radix-navigation-menu-viewport-height)}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.h-svh{height:100svh}.max-h-12{max-height:3rem}.max-h-96{max-height:24rem}.max-h-\[150px\]{max-height:150px}.max-h-\[200px\]{max-height:200px}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[95\%\]{max-height:95%}.max-h-\[calc\(85vh-120px\)\]{max-height:calc(85vh - 120px)}.min-h-10{min-height:2.5rem}.min-h-6{min-height:1.5rem}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[200px\]{min-height:200px}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.min-h-svh{min-height:100svh}.w-0{width:0px}.w-1\.5{width:.375rem}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-2\/3{width:66.666667%}.w-20{width:5rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-3\/4{width:75%}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-4\/5{width:80%}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-8{width:2rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-\[--cell-size\]{width:var(--cell-size)}.w-\[100px\]{width:100px}.w-\[120px\]{width:120px}.w-\[140px\]{width:140px}.w-\[150px\]{width:150px}.w-\[180px\]{width:180px}.w-\[1px\]{width:1px}.w-\[200px\]{width:200px}.w-\[250px\]{width:250px}.w-\[300px\]{width:300px}.w-\[400px\]{width:400px}.w-\[50px\]{width:50px}.w-\[60px\]{width:60px}.w-\[70px\]{width:70px}.w-\[80px\]{width:80px}.w-\[9\.5rem\]{width:9.5rem}.w-auto{width:auto}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-20{min-width:5rem}.min-w-\[--cell-size\]{min-width:var(--cell-size)}.min-w-\[10em\]{min-width:10em}.min-w-\[200px\]{min-width:200px}.min-w-\[3rem\]{min-width:3rem}.min-w-\[40px\]{min-width:40px}.min-w-\[4rem\]{min-width:4rem}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.max-w-2xl{max-width:42rem}.max-w-32{max-width:8rem}.max-w-4xl{max-width:56rem}.max-w-52{max-width:13rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[150px\]{max-width:150px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[300px\]{max-width:300px}.max-w-\[500px\]{max-width:500px}.max-w-\[60\%\]{max-width:60%}.max-w-\[600px\]{max-width:600px}.max-w-\[90\%\]{max-width:90%}.max-w-\[90vw\]{max-width:90vw}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-max{max-width:-moz-max-content;max-width:max-content}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-\[1\.2\]{flex:1.2}.flex-\[1\]{flex:1}.flex-\[2\]{flex:2}.flex-\[4\]{flex:4}.flex-\[5\]{flex:5}.flex-none{flex:none}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-x-full{--tw-translate-x: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\[-50\%\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-full{--tw-translate-x: 100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-0{--tw-translate-y: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\[-50\%\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-help{cursor:help}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-\[100px_1fr\]{grid-template-columns:100px 1fr}.flex-row{flex-direction:row}.flex-row-reverse{flex-direction:row-reverse}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-1{-moz-column-gap:.25rem;column-gap:.25rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-2{row-gap:.5rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2\.5>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.625rem * var(--tw-space-x-reverse));margin-left:calc(.625rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-scroll{overflow-y:scroll}.overscroll-contain{overscroll-behavior:contain}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-wrap{text-wrap:wrap}.text-nowrap{text-wrap:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-\[inherit\]{border-radius:inherit}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:.75rem}.rounded-l-lg{border-top-left-radius:var(--radius);border-bottom-left-radius:var(--radius)}.rounded-l-md{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.rounded-l-none{border-top-left-radius:0;border-bottom-left-radius:0}.rounded-r-lg{border-top-right-radius:var(--radius);border-bottom-right-radius:var(--radius)}.rounded-r-md{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.rounded-r-none{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-t-\[10px\]{border-top-left-radius:10px;border-top-right-radius:10px}.rounded-bl-none{border-bottom-left-radius:0}.rounded-br-none{border-bottom-right-radius:0}.rounded-tl-lg{border-top-left-radius:var(--radius)}.rounded-tl-none{border-top-left-radius:0}.rounded-tl-sm{border-top-left-radius:calc(var(--radius) - 4px)}.rounded-tr-lg{border-top-right-radius:var(--radius)}.rounded-tr-none{border-top-right-radius:0}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-x-0{border-left-width:0px;border-right-width:0px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l{border-left-width:1px}.border-l-0{border-left-width:0px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-r-0{border-right-width:0px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-300{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.border-blue-500\/50{border-color:#3b82f680}.border-border{border-color:hsl(var(--border))}.border-border\/30{border-color:hsl(var(--border) / .3)}.border-border\/50{border-color:hsl(var(--border) / .5)}.border-current{border-color:currentColor}.border-destructive\/50{border-color:hsl(var(--destructive) / .5)}.border-emerald-200{--tw-border-opacity: 1;border-color:rgb(167 243 208 / var(--tw-border-opacity, 1))}.border-foreground\/10{border-color:hsl(var(--foreground) / .1)}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-indigo-200{--tw-border-opacity: 1;border-color:rgb(199 210 254 / var(--tw-border-opacity, 1))}.border-input{border-color:hsl(var(--input))}.border-muted{border-color:hsl(var(--muted))}.border-muted-foreground\/25{border-color:hsl(var(--muted-foreground) / .25)}.border-muted-foreground\/30{border-color:hsl(var(--muted-foreground) / .3)}.border-orange-200{--tw-border-opacity: 1;border-color:rgb(254 215 170 / var(--tw-border-opacity, 1))}.border-orange-500\/50{border-color:#f9731680}.border-primary{border-color:hsl(var(--primary))}.border-primary\/20{border-color:hsl(var(--primary) / .2)}.border-primary\/40{border-color:hsl(var(--primary) / .4)}.border-primary\/50{border-color:hsl(var(--primary) / .5)}.border-purple-200{--tw-border-opacity: 1;border-color:rgb(233 213 255 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-l-slate-500{--tw-border-opacity: 1;border-left-color:rgb(100 116 139 / var(--tw-border-opacity, 1))}.border-l-transparent{border-left-color:transparent}.border-r-muted{border-right-color:hsl(var(--muted))}.border-t-transparent{border-top-color:transparent}.bg-accent{background-color:hsl(var(--accent))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-background{background-color:hsl(var(--background))}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/20{background-color:#0003}.bg-black\/80{background-color:#000c}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-destructive\/15{background-color:hsl(var(--destructive) / .15)}.bg-destructive\/80{background-color:hsl(var(--destructive) / .8)}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\/80{background-color:#10b981cc}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-indigo-100{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1))}.bg-inherit{background-color:inherit}.bg-muted{background-color:hsl(var(--muted))}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-popover{background-color:hsl(var(--popover))}.bg-primary{background-color:hsl(var(--primary))}.bg-primary-foreground{background-color:hsl(var(--primary-foreground))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-primary\/20{background-color:hsl(var(--primary) / .2)}.bg-primary\/5{background-color:hsl(var(--primary) / .05)}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-secondary{background-color:hsl(var(--secondary))}.bg-secondary\/50{background-color:hsl(var(--secondary) / .5)}.bg-slate-100\/80{background-color:#f1f5f9cc}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-yellow-500{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.bg-yellow-500\/80{background-color:#eab308cc}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-background\/95{--tw-gradient-from: hsl(var(--background) / .95) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-background\/80{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .8) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-background\/60{--tw-gradient-to: hsl(var(--background) / .6) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-primary{fill:hsl(var(--primary))}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-\[1px\]{padding:1px}.px-0{padding-left:0;padding-right:0}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.px-\[--cell-size\]{padding-left:var(--cell-size);padding-right:var(--cell-size)}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-0\.5{padding-bottom:.125rem}.pb-16{padding-bottom:4rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-2{padding-left:.5rem}.pl-2\.5{padding-left:.625rem}.pl-3{padding-left:.75rem}.pl-6{padding-left:1.5rem}.pl-8{padding-left:2rem}.pl-9{padding-left:2.25rem}.pr-1{padding-right:.25rem}.pr-10{padding-right:2.5rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-2\.5{padding-right:.625rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-7{padding-right:1.75rem}.pr-8{padding-right:2rem}.pr-9{padding-right:2.25rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\.5{padding-top:.375rem}.pt-16{padding-top:4rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[0\.625rem\]{font-size:.625rem}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.8rem\]{font-size:.8rem}.text-\[10px\]{font-size:10px}.text-\[7rem\]{font-size:7rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-10{line-height:2.5rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-widest{letter-spacing:.1em}.text-accent-foreground{color:hsl(var(--accent-foreground))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-current{color:currentColor}.text-destructive{color:hsl(var(--destructive))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-emerald-500{--tw-text-opacity: 1;color:rgb(16 185 129 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(6 95 70 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--foreground))}.text-foreground\/70{color:hsl(var(--foreground) / .7)}.text-foreground\/90{color:hsl(var(--foreground) / .9)}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-indigo-800{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-muted-foreground\/30{color:hsl(var(--muted-foreground) / .3)}.text-muted-foreground\/40{color:hsl(var(--muted-foreground) / .4)}.text-muted-foreground\/50{color:hsl(var(--muted-foreground) / .5)}.text-muted-foreground\/70{color:hsl(var(--muted-foreground) / .7)}.text-orange-500{--tw-text-opacity: 1;color:rgb(249 115 22 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-orange-800{--tw-text-opacity: 1;color:rgb(154 52 18 / var(--tw-text-opacity, 1))}.text-popover-foreground{color:hsl(var(--popover-foreground))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-primary\/90{color:hsl(var(--primary) / .9)}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--secondary-foreground))}.text-slate-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.underline-offset-4{text-underline-offset:4px}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-destructive\/50{--tw-shadow-color: hsl(var(--destructive) / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-500\/50{--tw-shadow-color: rgb(16 185 129 / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-yellow-500\/50{--tw-shadow-color: rgb(234 179 8 / .5);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-0{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(229 231 235 / var(--tw-ring-opacity, 1))}.ring-gray-300\/20{--tw-ring-color: rgb(209 213 219 / .2)}.ring-green-500\/20{--tw-ring-color: rgb(34 197 94 / .2)}.ring-primary\/20{--tw-ring-color: hsl(var(--primary) / .2)}.ring-offset-2{--tw-ring-offset-width: 2px}.ring-offset-background{--tw-ring-offset-color: hsl(var(--background))}.ring-offset-white{--tw-ring-offset-color: #fff}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[1px\]{--tw-backdrop-blur: blur(1px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[max-height\,padding\]{transition-property:max-height,padding;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[opacity\]{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.delay-100{transition-delay:.1s}.delay-150{transition-delay:.15s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.duration-700{transition-duration:.7s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.duration-500{animation-duration:.5s}.duration-700{animation-duration:.7s}.delay-100{animation-delay:.1s}.delay-150{animation-delay:.15s}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.\[--cell-size\:2rem\]{--cell-size: 2rem}html{overflow-y:scroll}.sticky{position:sticky!important;z-index:2;background-color:hsl(var(--card))}.sticky.before\:right-0:before,.sticky.before\:left-0:before{content:"";position:absolute;top:0;bottom:0;width:2px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent);opacity:1;transition:opacity .3s ease}.sticky.before\:right-0:before{right:-1px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent)}.sticky.before\:right-0:after{content:"";position:absolute;top:0;right:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to right,rgba(0,0,0,.05),transparent)}.sticky.before\:left-0:before{left:-1px;background:linear-gradient(to left,rgba(0,0,0,.08),transparent)}.sticky.before\:left-0:after{content:"";position:absolute;top:0;left:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to left,rgba(0,0,0,.05),transparent)}.sticky:hover:before{opacity:.8}.dark .sticky.before\:right-0:before,.dark .sticky.before\:left-0:before{background:linear-gradient(to right,rgba(255,255,255,.05),transparent)}.dark .sticky.before\:right-0:after,.dark .sticky.before\:left-0:after{background:linear-gradient(to right,rgba(255,255,255,.03),transparent)}.\*\:\!inline-block>*{display:inline-block!important}.file\:border-0::file-selector-button{border-width:0px}.file\:bg-transparent::file-selector-button{background-color:transparent}.file\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\:font-medium::file-selector-button{font-weight:500}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:bottom-0:before{content:var(--tw-content);bottom:0}.before\:left-0:before{content:var(--tw-content);left:0}.before\:right-0:before{content:var(--tw-content);right:0}.before\:top-0:before{content:var(--tw-content);top:0}.before\:w-\[1px\]:before{content:var(--tw-content);width:1px}.before\:bg-border:before{content:var(--tw-content);background-color:hsl(var(--border))}.after\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:inset-y-0:after{content:var(--tw-content);top:0;bottom:0}.after\:bottom-0:after{content:var(--tw-content);bottom:0}.after\:left-0:after{content:var(--tw-content);left:0}.after\:left-1\/2:after{content:var(--tw-content);left:50%}.after\:hidden:after{content:var(--tw-content);display:none}.after\:h-32:after{content:var(--tw-content);height:8rem}.after\:w-1:after{content:var(--tw-content);width:.25rem}.after\:w-full:after{content:var(--tw-content);width:100%}.after\:-translate-x-1\/2:after{content:var(--tw-content);--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.after\:bg-\[linear-gradient\(180deg\,_transparent_10\%\,_hsl\(var\(--background\)\)_70\%\)\]:after{content:var(--tw-content);background-image:linear-gradient(180deg,transparent 10%,hsl(var(--background)) 70%)}.focus-within\:ring-1:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-ring:focus-within{--tw-ring-color: hsl(var(--ring))}.hover\:-translate-y-1:hover{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:rotate-180:hover{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-accent\/50:hover{background-color:hsl(var(--accent) / .5)}.hover\:bg-background:hover{background-color:hsl(var(--background))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-200:hover{--tw-bg-opacity: 1;background-color:rgb(191 219 254 / var(--tw-bg-opacity, 1))}.hover\:bg-card\/80:hover{background-color:hsl(var(--card) / .8)}.hover\:bg-destructive\/10:hover{background-color:hsl(var(--destructive) / .1)}.hover\:bg-destructive\/25:hover{background-color:hsl(var(--destructive) / .25)}.hover\:bg-destructive\/80:hover{background-color:hsl(var(--destructive) / .8)}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-inherit:hover{background-color:inherit}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-muted\/40:hover{background-color:hsl(var(--muted) / .4)}.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted) / .5)}.hover\:bg-muted\/60:hover{background-color:hsl(var(--muted) / .6)}.hover\:bg-muted\/70:hover{background-color:hsl(var(--muted) / .7)}.hover\:bg-orange-100:hover{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.hover\:bg-primary\/10:hover{background-color:hsl(var(--primary) / .1)}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-secondary-foreground\/10:hover{background-color:hsl(var(--secondary-foreground) / .1)}.hover\:bg-secondary\/70:hover{background-color:hsl(var(--secondary) / .7)}.hover\:bg-secondary\/80:hover{background-color:hsl(var(--secondary) / .8)}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-200\/80:hover{background-color:#e2e8f0cc}.hover\:bg-transparent:hover{background-color:transparent}.hover\:bg-yellow-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.hover\:bg-opacity-80:hover{--tw-bg-opacity: .8}.hover\:text-accent-foreground:hover{color:hsl(var(--accent-foreground))}.hover\:text-destructive:hover{color:hsl(var(--destructive))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:text-foreground\/70:hover{color:hsl(var(--foreground) / .7)}.hover\:text-muted-foreground:hover{color:hsl(var(--muted-foreground))}.hover\:text-primary:hover{color:hsl(var(--primary))}.hover\:text-primary\/80:hover{color:hsl(var(--primary) / .8)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-black\/30:hover{--tw-shadow-color: rgb(0 0 0 / .3);--tw-shadow: var(--tw-shadow-colored)}.hover\:ring-primary:hover{--tw-ring-color: hsl(var(--primary))}.focus\:z-10:focus{z-index:10}.focus\:bg-accent:focus{background-color:hsl(var(--accent))}.focus\:text-accent-foreground:focus{color:hsl(var(--accent-foreground))}.focus\:text-destructive:focus{color:hsl(var(--destructive))}.focus\:text-red-600:focus{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-red-600:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(220 38 38 / var(--tw-ring-opacity, 1))}.focus\:ring-ring:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-primary:focus-visible{--tw-ring-color: hsl(var(--primary))}.focus-visible\:ring-red-500:focus-visible{--tw-ring-opacity: 1;--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity, 1))}.focus-visible\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--ring))}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width: 1px}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.focus-visible\:ring-offset-background:focus-visible{--tw-ring-offset-color: hsl(var(--background))}.active\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:pointer-events-auto{pointer-events:auto}.group:hover .group-hover\:via-background\/90{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .9) var(--tw-gradient-via-position), var(--tw-gradient-to)}.group:hover .group-hover\:to-background\/70{--tw-gradient-to: hsl(var(--background) / .7) var(--tw-gradient-to-position)}.group\/id:hover .group-hover\/id\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:justify-center{justify-content:center}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:px-2{padding-left:.5rem;padding-right:.5rem}.peer:disabled~.peer-disabled\:cursor-not-allowed{cursor:not-allowed}.peer:disabled~.peer-disabled\:opacity-70{opacity:.7}.has-\[\:focus-visible\]\:outline-none:has(:focus-visible){outline:2px solid transparent;outline-offset:2px}.has-\[\:focus-visible\]\:ring-1:has(:focus-visible){--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.has-\[\:focus-visible\]\:ring-neutral-950:has(:focus-visible){--tw-ring-opacity: 1;--tw-ring-color: rgb(10 10 10 / var(--tw-ring-opacity, 1))}.aria-disabled\:opacity-50[aria-disabled=true]{opacity:.5}.aria-selected\:bg-accent[aria-selected=true]{background-color:hsl(var(--accent))}.aria-selected\:text-accent-foreground[aria-selected=true]{color:hsl(var(--accent-foreground))}.aria-selected\:text-muted-foreground[aria-selected=true]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[panel-group-direction\=vertical\]\:h-px[data-panel-group-direction=vertical]{height:1px}.data-\[panel-group-direction\=vertical\]\:w-full[data-panel-group-direction=vertical]{width:100%}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=left\]\:-translate-x-1[data-side=left]{--tw-translate-x: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=right\]\:translate-x-1[data-side=right]{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=top\]\:-translate-y-1[data-side=top]{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x: 1rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes accordion-up{0%{height:var(--radix-accordion-content-height)}to{height:0}}.data-\[state\=closed\]\:animate-accordion-up[data-state=closed]{animation:accordion-up .2s ease-out}@keyframes accordion-down{0%{height:0}to{height:var(--radix-accordion-content-height)}}.data-\[state\=open\]\:animate-accordion-down[data-state=open]{animation:accordion-down .2s ease-out}.data-\[state\=dragging\]\:cursor-grabbing[data-state=dragging]{cursor:grabbing}.data-\[panel-group-direction\=vertical\]\:flex-col[data-panel-group-direction=vertical]{flex-direction:column}.data-\[range-end\=true\]\:rounded-md[data-range-end=true]{border-radius:calc(var(--radius) - 2px)}.data-\[range-middle\=true\]\:rounded-none[data-range-middle=true]{border-radius:0}.data-\[range-start\=true\]\:rounded-md[data-range-start=true]{border-radius:calc(var(--radius) - 2px)}.data-\[selected\=true\]\:rounded-none[data-selected=true]{border-radius:0}.data-\[active\]\:bg-accent\/50[data-active]{background-color:hsl(var(--accent) / .5)}.data-\[disabled\]\:bg-muted-foreground[data-disabled],.data-\[fixed\]\:bg-muted-foreground[data-fixed]{background-color:hsl(var(--muted-foreground))}.data-\[range-end\=true\]\:bg-primary[data-range-end=true]{background-color:hsl(var(--primary))}.data-\[range-middle\=true\]\:bg-accent[data-range-middle=true]{background-color:hsl(var(--accent))}.data-\[range-start\=true\]\:bg-primary[data-range-start=true],.data-\[selected-single\=true\]\:bg-primary[data-selected-single=true]{background-color:hsl(var(--primary))}.data-\[state\=active\]\:bg-background[data-state=active]{background-color:hsl(var(--background))}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:hsl(var(--primary))}.data-\[state\=open\]\:bg-accent[data-state=open]{background-color:hsl(var(--accent))}.data-\[state\=open\]\:bg-accent\/50[data-state=open]{background-color:hsl(var(--accent) / .5)}.data-\[state\=open\]\:bg-secondary[data-state=open]{background-color:hsl(var(--secondary))}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:hsl(var(--muted))}.data-\[state\=unchecked\]\:bg-input[data-state=unchecked]{background-color:hsl(var(--input))}.data-\[collapsed\=true\]\:py-2[data-collapsed=true]{padding-top:.5rem;padding-bottom:.5rem}.data-\[disabled\]\:text-muted[data-disabled],.data-\[fixed\]\:text-muted[data-fixed]{color:hsl(var(--muted))}.data-\[range-end\=true\]\:text-primary-foreground[data-range-end=true]{color:hsl(var(--primary-foreground))}.data-\[range-middle\=true\]\:text-accent-foreground[data-range-middle=true]{color:hsl(var(--accent-foreground))}.data-\[range-start\=true\]\:text-primary-foreground[data-range-start=true],.data-\[selected-single\=true\]\:text-primary-foreground[data-selected-single=true]{color:hsl(var(--primary-foreground))}.data-\[state\=active\]\:text-foreground[data-state=active]{color:hsl(var(--foreground))}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:hsl(var(--primary-foreground))}.data-\[state\=open\]\:text-muted-foreground[data-state=open]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{transition-duration:.3s}.data-\[motion\^\=from-\]\:animate-in[data-motion^=from-],.data-\[state\=open\]\:animate-in[data-state=open],.data-\[state\=visible\]\:animate-in[data-state=visible]{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.data-\[motion\^\=to-\]\:animate-out[data-motion^=to-],.data-\[state\=closed\]\:animate-out[data-state=closed],.data-\[state\=hidden\]\:animate-out[data-state=hidden]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\[motion\^\=from-\]\:fade-in[data-motion^=from-]{--tw-enter-opacity: 0}.data-\[motion\^\=to-\]\:fade-out[data-motion^=to-],.data-\[state\=closed\]\:fade-out-0[data-state=closed],.data-\[state\=hidden\]\:fade-out[data-state=hidden]{--tw-exit-opacity: 0}.data-\[state\=open\]\:fade-in-0[data-state=open],.data-\[state\=visible\]\:fade-in[data-state=visible]{--tw-enter-opacity: 0}.data-\[state\=closed\]\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\[state\=open\]\:zoom-in-90[data-state=open]{--tw-enter-scale: .9}.data-\[state\=open\]\:zoom-in-95[data-state=open]{--tw-enter-scale: .95}.data-\[motion\=from-end\]\:slide-in-from-right-52[data-motion=from-end]{--tw-enter-translate-x: 13rem}.data-\[motion\=from-start\]\:slide-in-from-left-52[data-motion=from-start]{--tw-enter-translate-x: -13rem}.data-\[motion\=to-end\]\:slide-out-to-right-52[data-motion=to-end]{--tw-exit-translate-x: 13rem}.data-\[motion\=to-start\]\:slide-out-to-left-52[data-motion=to-start]{--tw-exit-translate-x: -13rem}.data-\[side\=bottom\]\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.data-\[state\=closed\]\:slide-out-to-bottom[data-state=closed]{--tw-exit-translate-y: 100%}.data-\[state\=closed\]\:slide-out-to-left[data-state=closed]{--tw-exit-translate-x: -100%}.data-\[state\=closed\]\:slide-out-to-left-1\/2[data-state=closed]{--tw-exit-translate-x: -50%}.data-\[state\=closed\]\:slide-out-to-right[data-state=closed]{--tw-exit-translate-x: 100%}.data-\[state\=closed\]\:slide-out-to-top[data-state=closed]{--tw-exit-translate-y: -100%}.data-\[state\=closed\]\:slide-out-to-top-\[48\%\][data-state=closed]{--tw-exit-translate-y: -48%}.data-\[state\=open\]\:slide-in-from-bottom[data-state=open]{--tw-enter-translate-y: 100%}.data-\[state\=open\]\:slide-in-from-left[data-state=open]{--tw-enter-translate-x: -100%}.data-\[state\=open\]\:slide-in-from-left-1\/2[data-state=open]{--tw-enter-translate-x: -50%}.data-\[state\=open\]\:slide-in-from-right[data-state=open]{--tw-enter-translate-x: 100%}.data-\[state\=open\]\:slide-in-from-top[data-state=open]{--tw-enter-translate-y: -100%}.data-\[state\=open\]\:slide-in-from-top-\[48\%\][data-state=open]{--tw-enter-translate-y: -48%}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{animation-duration:.3s}.data-\[panel-group-direction\=vertical\]\:after\:left-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);left:0}.data-\[panel-group-direction\=vertical\]\:after\:h-1[data-panel-group-direction=vertical]:after{content:var(--tw-content);height:.25rem}.data-\[panel-group-direction\=vertical\]\:after\:w-full[data-panel-group-direction=vertical]:after{content:var(--tw-content);width:100%}.data-\[panel-group-direction\=vertical\]\:after\:-translate-y-1\/2[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[panel-group-direction\=vertical\]\:after\:translate-x-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[disabled\]\:hover\:bg-muted-foreground:hover[data-disabled],.data-\[fixed\]\:hover\:bg-muted-foreground:hover[data-fixed]{background-color:hsl(var(--muted-foreground))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:relative{position:relative}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:z-10{z-index:10}.group[data-state=open] .group-data-\[state\=\"open\"\]\:-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group[data-state=open] .group-data-\[state\=open\]\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:border-ring{border-color:hsl(var(--ring))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-\[3px\]{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-ring\/50{--tw-ring-color: hsl(var(--ring) / .5)}.dark\:border-amber-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(120 53 15 / var(--tw-border-opacity, 1))}.dark\:border-blue-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(29 78 216 / var(--tw-border-opacity, 1))}.dark\:border-blue-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(30 58 138 / var(--tw-border-opacity, 1))}.dark\:border-gray-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.dark\:border-red-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(127 29 29 / var(--tw-border-opacity, 1))}.dark\:border-yellow-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(113 63 18 / var(--tw-border-opacity, 1))}.dark\:bg-amber-900\/50:is(.dark *){background-color:#78350f80}.dark\:bg-amber-950\/30:is(.dark *){background-color:#451a034d}.dark\:bg-blue-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950\/30:is(.dark *){background-color:#1725544d}.dark\:bg-gray-800\/50:is(.dark *){background-color:#1f293780}.dark\:bg-green-500\/10:is(.dark *){background-color:#22c55e1a}.dark\:bg-red-500\/10:is(.dark *){background-color:#ef44441a}.dark\:bg-red-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-950\/30:is(.dark *){background-color:#450a0a4d}.dark\:bg-yellow-500\/10:is(.dark *){background-color:#eab3081a}.dark\:bg-yellow-950\/30:is(.dark *){background-color:#4220064d}.dark\:text-amber-200:is(.dark *){--tw-text-opacity: 1;color:rgb(253 230 138 / var(--tw-text-opacity, 1))}.dark\:text-amber-400:is(.dark *){--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.dark\:text-blue-300:is(.dark *){--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity, 1))}.dark\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.dark\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-300:is(.dark *){--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-yellow-300:is(.dark *){--tw-text-opacity: 1;color:rgb(253 224 71 / var(--tw-text-opacity, 1))}.dark\:text-yellow-400:is(.dark *){--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}.dark\:ring-gray-700:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity, 1))}.dark\:ring-gray-800:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(31 41 55 / var(--tw-ring-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::-moz-placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:hover\:bg-blue-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-blue-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:hover\:text-red-400:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:has-\[\:focus-visible\]\:ring-neutral-300:has(:focus-visible):is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(212 212 212 / var(--tw-ring-opacity, 1))}@media (min-width: 640px){.sm\:absolute{position:absolute}.sm\:inset-auto{inset:auto}.sm\:bottom-\[calc\(100\%\+10px\)\]{bottom:calc(100% + 10px)}.sm\:left-0{left:0}.sm\:right-0{right:0}.sm\:my-0{margin-top:0;margin-bottom:0}.sm\:my-4{margin-top:1rem;margin-bottom:1rem}.sm\:mt-0{margin-top:0}.sm\:mt-6{margin-top:1.5rem}.sm\:block{display:block}.sm\:hidden{display:none}.sm\:h-\[80vh\]{height:80vh}.sm\:h-full{height:100%}.sm\:max-h-\[500px\]{max-height:500px}.sm\:max-h-\[600px\]{max-height:600px}.sm\:max-h-\[700px\]{max-height:700px}.sm\:max-h-\[800px\]{max-height:800px}.sm\:w-48{width:12rem}.sm\:w-\[350px\]{width:350px}.sm\:w-\[540px\]{width:540px}.sm\:w-\[90vw\]{width:90vw}.sm\:w-auto{width:auto}.sm\:w-full{width:100%}.sm\:max-w-72{max-width:18rem}.sm\:max-w-\[1025px\]{max-width:1025px}.sm\:max-w-\[425px\]{max-width:425px}.sm\:max-w-\[500px\]{max-width:500px}.sm\:max-w-\[700px\]{max-width:700px}.sm\:max-w-lg{max-width:32rem}.sm\:max-w-md{max-width:28rem}.sm\:max-w-sm{max-width:24rem}.sm\:max-w-xl{max-width:36rem}.sm\:translate-y-5{--tw-translate-y: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-end{justify-content:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:gap-0{gap:0px}.sm\:gap-6{gap:1.5rem}.sm\:space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:rounded-lg{border-radius:var(--radius)}.sm\:p-6{padding:1.5rem}.sm\:text-left{text-align:left}.sm\:text-2xl{font-size:1.5rem;line-height:2rem}.sm\:text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width: 768px){.md\:absolute{position:absolute}.md\:relative{position:relative}.md\:bottom-0{bottom:0}.md\:right-8{right:2rem}.md\:right-auto{right:auto}.md\:top-8{top:2rem}.md\:col-span-1{grid-column:span 1 / span 1}.md\:mb-2{margin-bottom:.5rem}.md\:ml-14{margin-left:3.5rem}.md\:ml-64{margin-left:16rem}.md\:mt-2{margin-top:.5rem}.md\:block{display:block}.md\:flex{display:flex}.md\:inline-flex{display:inline-flex}.md\:hidden{display:none}.md\:h-full{height:100%}.md\:h-svh{height:100svh}.md\:w-14{width:3.5rem}.md\:w-32{width:8rem}.md\:w-64{width:16rem}.md\:w-80{width:20rem}.md\:w-\[420px\]{width:420px}.md\:w-\[var\(--radix-navigation-menu-viewport-width\)\]{width:var(--radix-navigation-menu-viewport-width)}.md\:w-auto{width:auto}.md\:max-w-\[31rem\]{max-width:31rem}.md\:translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.md\:overflow-y-hidden{overflow-y:hidden}.md\:border-none{border-style:none}.md\:px-4{padding-left:1rem;padding-right:1rem}.md\:px-8{padding-left:2rem;padding-right:2rem}.md\:py-2{padding-top:.5rem;padding-bottom:.5rem}.md\:pt-0{padding-top:0}.md\:text-2xl{font-size:1.5rem;line-height:2rem}.md\:text-3xl{font-size:1.875rem;line-height:2.25rem}.md\:opacity-0{opacity:0}.after\:md\:block:after{content:var(--tw-content);display:block}}@media (min-width: 1024px){.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:w-1\/5{width:20%}.lg\:w-\[250px\]{width:250px}.lg\:max-w-none{max-width:none}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:flex-col{flex-direction:column}.lg\:gap-8{gap:2rem}.lg\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(0px * var(--tw-space-x-reverse));margin-left:calc(0px * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-x-12>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(3rem * var(--tw-space-x-reverse));margin-left:calc(3rem * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.lg\:space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.lg\:p-8{padding:2rem}.lg\:px-0{padding-left:0;padding-right:0}.lg\:px-3{padding-left:.75rem;padding-right:.75rem}}@media (min-width: 1280px){.xl\:mr-2{margin-right:.5rem}.xl\:flex{display:flex}.xl\:inline-flex{display:inline-flex}.xl\:h-10{height:2.5rem}.xl\:w-60{width:15rem}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:justify-start{justify-content:flex-start}.xl\:px-3{padding-left:.75rem;padding-right:.75rem}.xl\:py-2{padding-top:.5rem;padding-bottom:.5rem}}.\[\&\:\:-webkit-calendar-picker-indicator\]\:hidden::-webkit-calendar-picker-indicator{display:none}.\[\&\:first-child\[data-selected\=true\]_button\]\:rounded-l-md:first-child[data-selected=true] button{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\&\:last-child\[data-selected\=true\]_button\]\:rounded-r-md:last-child[data-selected=true] button{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y: 2px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\>span\]\:line-clamp-1>span{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\[\&\>span\]\:text-xs>span{font-size:.75rem;line-height:1rem}.\[\&\>span\]\:opacity-70>span{opacity:.7}.\[\&\>svg\]\:size-3\.5>svg{width:.875rem;height:.875rem}.\[\&\>svg\]\:text-muted-foreground>svg{color:hsl(var(--muted-foreground))}.\[\&\>tr\]\:last\:border-b-0:last-child>tr{border-bottom-width:0px}.\[\&\[data-panel-group-direction\=vertical\]\>div\]\:rotate-90[data-panel-group-direction=vertical]>div{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\[data-state\=open\]\>svg\]\:rotate-180[data-state=open]>svg{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&_\[cmdk-group-heading\]\]\:px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-group-heading\]\]\:py-1\.5 [cmdk-group-heading]{padding-top:.375rem;padding-bottom:.375rem}.\[\&_\[cmdk-group-heading\]\]\:text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\[\&_\[cmdk-group-heading\]\]\:font-medium [cmdk-group-heading]{font-weight:500}.\[\&_\[cmdk-group-heading\]\]\:text-muted-foreground [cmdk-group-heading]{color:hsl(var(--muted-foreground))}.\[\&_\[cmdk-group\]\:not\(\[hidden\]\)_\~\[cmdk-group\]\]\:pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\[\&_\[cmdk-group\]\]\:px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\[\&_\[cmdk-input\]\]\:h-12 [cmdk-input]{height:3rem}.\[\&_\[cmdk-item\]\]\:px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-item\]\]\:py-3 [cmdk-item]{padding-top:.75rem;padding-bottom:.75rem}.\[\&_\[cmdk-item\]_svg\]\:h-5 [cmdk-item] svg{height:1.25rem}.\[\&_\[cmdk-item\]_svg\]\:w-5 [cmdk-item] svg{width:1.25rem}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:invisible svg{visibility:hidden}.\[\&_svg\]\:size-4 svg{width:1rem;height:1rem}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-width:0px}.\[\&_tr\]\:border-b tr{border-bottom-width:1px}[data-slot=card-content] .\[\[data-slot\=card-content\]_\&\]\:bg-transparent,[data-slot=popover-content] .\[\[data-slot\=popover-content\]_\&\]\:bg-transparent{background-color:transparent}html.dark .markdown-body{color-scheme:dark;--color-prettylights-syntax-comment: #8b949e;--color-prettylights-syntax-constant: #79c0ff;--color-prettylights-syntax-entity: #d2a8ff;--color-prettylights-syntax-storage-modifier-import: #c9d1d9;--color-prettylights-syntax-entity-tag: #7ee787;--color-prettylights-syntax-keyword: #ff7b72;--color-prettylights-syntax-string: #a5d6ff;--color-prettylights-syntax-variable: #ffa657;--color-prettylights-syntax-brackethighlighter-unmatched: #f85149;--color-prettylights-syntax-invalid-illegal-text: #f0f6fc;--color-prettylights-syntax-invalid-illegal-bg: #8e1519;--color-prettylights-syntax-carriage-return-text: #f0f6fc;--color-prettylights-syntax-carriage-return-bg: #b62324;--color-prettylights-syntax-string-regexp: #7ee787;--color-prettylights-syntax-markup-list: #f2cc60;--color-prettylights-syntax-markup-heading: #1f6feb;--color-prettylights-syntax-markup-italic: #c9d1d9;--color-prettylights-syntax-markup-bold: #c9d1d9;--color-prettylights-syntax-markup-deleted-text: #ffdcd7;--color-prettylights-syntax-markup-deleted-bg: #67060c;--color-prettylights-syntax-markup-inserted-text: #aff5b4;--color-prettylights-syntax-markup-inserted-bg: #033a16;--color-prettylights-syntax-markup-changed-text: #ffdfb6;--color-prettylights-syntax-markup-changed-bg: #5a1e02;--color-prettylights-syntax-markup-ignored-text: #c9d1d9;--color-prettylights-syntax-markup-ignored-bg: #1158c7;--color-prettylights-syntax-meta-diff-range: #d2a8ff;--color-prettylights-syntax-brackethighlighter-angle: #8b949e;--color-prettylights-syntax-sublimelinter-gutter-mark: #484f58;--color-prettylights-syntax-constant-other-reference-link: #a5d6ff;--color-fg-default: #e6edf3;--color-fg-muted: #7d8590;--color-fg-subtle: #6e7681;--color-canvas-default: #0d1117;--color-canvas-subtle: #161b22;--color-border-default: #30363d;--color-border-muted: #21262d;--color-neutral-muted: rgba(110,118,129,.4);--color-accent-fg: #2f81f7;--color-accent-emphasis: #1f6feb;--color-attention-fg: #d29922;--color-attention-subtle: rgba(187,128,9,.15);--color-danger-fg: #f85149;--color-done-fg: #a371f7}html:not(.dark) .markdown-body{color-scheme:light;--color-prettylights-syntax-comment: #6e7781;--color-prettylights-syntax-constant: #0550ae;--color-prettylights-syntax-entity: #6639ba;--color-prettylights-syntax-storage-modifier-import: #24292f;--color-prettylights-syntax-entity-tag: #116329;--color-prettylights-syntax-keyword: #cf222e;--color-prettylights-syntax-string: #0a3069;--color-prettylights-syntax-variable: #953800;--color-prettylights-syntax-brackethighlighter-unmatched: #82071e;--color-prettylights-syntax-invalid-illegal-text: #f6f8fa;--color-prettylights-syntax-invalid-illegal-bg: #82071e;--color-prettylights-syntax-carriage-return-text: #f6f8fa;--color-prettylights-syntax-carriage-return-bg: #cf222e;--color-prettylights-syntax-string-regexp: #116329;--color-prettylights-syntax-markup-list: #3b2300;--color-prettylights-syntax-markup-heading: #0550ae;--color-prettylights-syntax-markup-italic: #24292f;--color-prettylights-syntax-markup-bold: #24292f;--color-prettylights-syntax-markup-deleted-text: #82071e;--color-prettylights-syntax-markup-deleted-bg: #ffebe9;--color-prettylights-syntax-markup-inserted-text: #116329;--color-prettylights-syntax-markup-inserted-bg: #dafbe1;--color-prettylights-syntax-markup-changed-text: #953800;--color-prettylights-syntax-markup-changed-bg: #ffd8b5;--color-prettylights-syntax-markup-ignored-text: #eaeef2;--color-prettylights-syntax-markup-ignored-bg: #0550ae;--color-prettylights-syntax-meta-diff-range: #8250df;--color-prettylights-syntax-brackethighlighter-angle: #57606a;--color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f;--color-prettylights-syntax-constant-other-reference-link: #0a3069;--color-fg-default: #1F2328;--color-fg-muted: #656d76;--color-fg-subtle: #6e7781;--color-canvas-default: #ffffff;--color-canvas-subtle: #f6f8fa;--color-border-default: #d0d7de;--color-border-muted: hsla(210,18%,87%,1);--color-neutral-muted: rgba(175,184,193,.2);--color-accent-fg: #0969da;--color-accent-emphasis: #0969da;--color-attention-fg: #9a6700;--color-attention-subtle: #fff8c5;--color-danger-fg: #d1242f;--color-done-fg: #8250df}.markdown-body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;margin:0;color:var(--color-fg-default);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body .octicon{display:inline-block;fill:currentColor;vertical-align:text-bottom}.markdown-body h1:hover .anchor .octicon-link:before,.markdown-body h2:hover .anchor .octicon-link:before,.markdown-body h3:hover .anchor .octicon-link:before,.markdown-body h4:hover .anchor .octicon-link:before,.markdown-body h5:hover .anchor .octicon-link:before,.markdown-body h6:hover .anchor .octicon-link:before{width:16px;height:16px;content:" ";display:inline-block;background-color:currentColor;-webkit-mask-image:url("data:image/svg+xml,");mask-image:url("data:image/svg+xml,")}.markdown-body details,.markdown-body figcaption,.markdown-body figure{display:block}.markdown-body summary{display:list-item}.markdown-body [hidden]{display:none!important}.markdown-body a{background-color:transparent;color:var(--color-accent-fg);text-decoration:none}.markdown-body abbr[title]{border-bottom:none;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.markdown-body b,.markdown-body strong{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dfn{font-style:italic}.markdown-body h1{margin:.67em 0;font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:2em;border-bottom:1px solid var(--color-border-muted)}.markdown-body mark{background-color:var(--color-attention-subtle);color:var(--color-fg-default)}.markdown-body small{font-size:90%}.markdown-body sub,.markdown-body sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.markdown-body sub{bottom:-.25em}.markdown-body sup{top:-.5em}.markdown-body img{border-style:none;max-width:100%;box-sizing:content-box;background-color:var(--color-canvas-default)}.markdown-body code,.markdown-body kbd,.markdown-body pre,.markdown-body samp{font-family:monospace;font-size:1em}.markdown-body figure{margin:1em 40px}.markdown-body hr{box-sizing:content-box;overflow:hidden;background:transparent;border-bottom:1px solid var(--color-border-muted);height:.25em;padding:0;margin:24px 0;background-color:var(--color-border-default);border:0}.markdown-body input{font:inherit;margin:0;overflow:visible;font-family:inherit;font-size:inherit;line-height:inherit}.markdown-body [type=button],.markdown-body [type=reset],.markdown-body [type=submit]{-webkit-appearance:button}.markdown-body [type=checkbox],.markdown-body [type=radio]{box-sizing:border-box;padding:0}.markdown-body [type=number]::-webkit-inner-spin-button,.markdown-body [type=number]::-webkit-outer-spin-button{height:auto}.markdown-body [type=search]::-webkit-search-cancel-button,.markdown-body [type=search]::-webkit-search-decoration{-webkit-appearance:none}.markdown-body ::-webkit-input-placeholder{color:inherit;opacity:.54}.markdown-body ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.markdown-body a:hover{text-decoration:underline}.markdown-body ::-moz-placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body ::placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body hr:before{display:table;content:""}.markdown-body hr:after{display:table;clear:both;content:""}.markdown-body table{border-spacing:0;border-collapse:collapse;display:block;width:-moz-max-content;width:max-content;max-width:100%;overflow:auto}.markdown-body td,.markdown-body th{padding:0}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>*:not(summary){display:none!important}.markdown-body a:focus,.markdown-body [role=button]:focus,.markdown-body input[type=radio]:focus,.markdown-body input[type=checkbox]:focus{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:focus:not(:focus-visible),.markdown-body [role=button]:focus:not(:focus-visible),.markdown-body input[type=radio]:focus:not(:focus-visible),.markdown-body input[type=checkbox]:focus:not(:focus-visible){outline:solid 1px transparent}.markdown-body a:focus-visible,.markdown-body [role=button]:focus-visible,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus-visible{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:not([class]):focus,.markdown-body a:not([class]):focus-visible,.markdown-body input[type=radio]:focus,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus,.markdown-body input[type=checkbox]:focus-visible{outline-offset:0}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;line-height:10px;color:var(--color-fg-default);vertical-align:middle;background-color:var(--color-canvas-subtle);border:solid 1px var(--color-neutral-muted);border-bottom-color:var(--color-neutral-muted);border-radius:6px;box-shadow:inset 0 -1px 0 var(--color-neutral-muted)}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:var(--base-text-weight-semibold, 600);line-height:1.25}.markdown-body h2{font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:1.5em;border-bottom:1px solid var(--color-border-muted)}.markdown-body h3{font-weight:var(--base-text-weight-semibold, 600);font-size:1.25em}.markdown-body h4{font-weight:var(--base-text-weight-semibold, 600);font-size:1em}.markdown-body h5{font-weight:var(--base-text-weight-semibold, 600);font-size:.875em}.markdown-body h6{font-weight:var(--base-text-weight-semibold, 600);font-size:.85em;color:var(--color-fg-muted)}.markdown-body p{margin-top:0;margin-bottom:10px}.markdown-body blockquote{margin:0;padding:0 1em;color:var(--color-fg-muted);border-left:.25em solid var(--color-border-default)}.markdown-body ul,.markdown-body ol{margin-top:0;margin-bottom:0;padding-left:2em}.markdown-body ol ol,.markdown-body ul ol{list-style-type:lower-roman}.markdown-body ul ul ol,.markdown-body ul ol ol,.markdown-body ol ul ol,.markdown-body ol ol ol{list-style-type:lower-alpha}.markdown-body dd{margin-left:0}.markdown-body tt,.markdown-body code,.markdown-body samp{font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px}.markdown-body pre{margin-top:0;margin-bottom:0;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px;word-wrap:normal}.markdown-body .octicon{display:inline-block;overflow:visible!important;vertical-align:text-bottom;fill:currentColor}.markdown-body input::-webkit-outer-spin-button,.markdown-body input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none;appearance:none}.markdown-body .color-fg-accent{color:var(--color-accent-fg)!important}.markdown-body .color-fg-attention{color:var(--color-attention-fg)!important}.markdown-body .color-fg-done{color:var(--color-done-fg)!important}.markdown-body .flex-items-center{align-items:center!important}.markdown-body .mb-1{margin-bottom:var(--base-size-4, 4px)!important}.markdown-body .text-semibold{font-weight:var(--base-text-weight-medium, 500)!important}.markdown-body .d-inline-flex{display:inline-flex!important}.markdown-body:before{display:table;content:""}.markdown-body:after{display:table;clear:both;content:""}.markdown-body>*:first-child{margin-top:0!important}.markdown-body>*:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:var(--color-danger-fg)}.markdown-body .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.markdown-body .anchor:focus{outline:none}.markdown-body p,.markdown-body blockquote,.markdown-body ul,.markdown-body ol,.markdown-body dl,.markdown-body table,.markdown-body pre,.markdown-body details{margin-top:0;margin-bottom:16px}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:var(--color-fg-default);vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 tt,.markdown-body h1 code,.markdown-body h2 tt,.markdown-body h2 code,.markdown-body h3 tt,.markdown-body h3 code,.markdown-body h4 tt,.markdown-body h4 code,.markdown-body h5 tt,.markdown-body h5 code,.markdown-body h6 tt,.markdown-body h6 code{padding:0 .2em;font-size:inherit}.markdown-body summary h1,.markdown-body summary h2,.markdown-body summary h3,.markdown-body summary h4,.markdown-body summary h5,.markdown-body summary h6{display:inline-block}.markdown-body summary h1 .anchor,.markdown-body summary h2 .anchor,.markdown-body summary h3 .anchor,.markdown-body summary h4 .anchor,.markdown-body summary h5 .anchor,.markdown-body summary h6 .anchor{margin-left:-40px}.markdown-body summary h1,.markdown-body summary h2{padding-bottom:0;border-bottom:0}.markdown-body ul.no-list,.markdown-body ol.no-list{padding:0;list-style-type:none}.markdown-body ol[type="a s"]{list-style-type:lower-alpha}.markdown-body ol[type="A s"]{list-style-type:upper-alpha}.markdown-body ol[type="i s"]{list-style-type:lower-roman}.markdown-body ol[type="I s"]{list-style-type:upper-roman}.markdown-body ol[type="1"]{list-style-type:decimal}.markdown-body div>ol:not([type]){list-style-type:decimal}.markdown-body ul ul,.markdown-body ul ol,.markdown-body ol ol,.markdown-body ol ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{margin-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table th{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body table th,.markdown-body table td{padding:6px 13px;border:1px solid var(--color-border-default)}.markdown-body table td>:last-child{margin-bottom:0}.markdown-body table tr{background-color:var(--color-canvas-default);border-top:1px solid var(--color-border-muted)}.markdown-body table tr:nth-child(2n){background-color:var(--color-canvas-subtle)}.markdown-body table img{background-color:transparent}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{max-width:none;vertical-align:text-top;background-color:transparent}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid var(--color-border-default)}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:var(--color-fg-default)}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:.2em .4em;margin:0;font-size:85%;white-space:break-spaces;background-color:var(--color-neutral-muted);border-radius:6px}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body samp{font-size:85%}.markdown-body pre code{font-size:100%}.markdown-body pre>code{padding:0;margin:0;word-break:normal;white-space:pre;background:transparent;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;color:var(--color-fg-default);background-color:var(--color-canvas-subtle);border-radius:6px}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:12px;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-num{padding:10px 8px 9px;text-align:right;background:var(--color-canvas-default);border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:var(--base-text-weight-semibold, 600);background:var(--color-canvas-subtle);border-top:0}.markdown-body [data-footnote-ref]:before{content:"["}.markdown-body [data-footnote-ref]:after{content:"]"}.markdown-body .footnotes{font-size:12px;color:var(--color-fg-muted);border-top:1px solid var(--color-border-default)}.markdown-body .footnotes ol{padding-left:16px}.markdown-body .footnotes ol ul{display:inline-block;padding-left:16px;margin-top:16px}.markdown-body .footnotes li{position:relative}.markdown-body .footnotes li:target:before{position:absolute;inset:-8px -8px -8px -24px;pointer-events:none;content:"";border:2px solid var(--color-accent-emphasis);border-radius:6px}.markdown-body .footnotes li:target{color:var(--color-fg-default)}.markdown-body .footnotes .data-footnote-backref g-emoji{font-family:monospace}.markdown-body .pl-c{color:var(--color-prettylights-syntax-comment)}.markdown-body .pl-c1,.markdown-body .pl-s .pl-v{color:var(--color-prettylights-syntax-constant)}.markdown-body .pl-e,.markdown-body .pl-en{color:var(--color-prettylights-syntax-entity)}.markdown-body .pl-smi,.markdown-body .pl-s .pl-s1{color:var(--color-prettylights-syntax-storage-modifier-import)}.markdown-body .pl-ent{color:var(--color-prettylights-syntax-entity-tag)}.markdown-body .pl-k{color:var(--color-prettylights-syntax-keyword)}.markdown-body .pl-s,.markdown-body .pl-pds,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sre,.markdown-body .pl-sr .pl-sra{color:var(--color-prettylights-syntax-string)}.markdown-body .pl-v,.markdown-body .pl-smw{color:var(--color-prettylights-syntax-variable)}.markdown-body .pl-bu{color:var(--color-prettylights-syntax-brackethighlighter-unmatched)}.markdown-body .pl-ii{color:var(--color-prettylights-syntax-invalid-illegal-text);background-color:var(--color-prettylights-syntax-invalid-illegal-bg)}.markdown-body .pl-c2{color:var(--color-prettylights-syntax-carriage-return-text);background-color:var(--color-prettylights-syntax-carriage-return-bg)}.markdown-body .pl-sr .pl-cce{font-weight:700;color:var(--color-prettylights-syntax-string-regexp)}.markdown-body .pl-ml{color:var(--color-prettylights-syntax-markup-list)}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{font-weight:700;color:var(--color-prettylights-syntax-markup-heading)}.markdown-body .pl-mi{font-style:italic;color:var(--color-prettylights-syntax-markup-italic)}.markdown-body .pl-mb{font-weight:700;color:var(--color-prettylights-syntax-markup-bold)}.markdown-body .pl-md{color:var(--color-prettylights-syntax-markup-deleted-text);background-color:var(--color-prettylights-syntax-markup-deleted-bg)}.markdown-body .pl-mi1{color:var(--color-prettylights-syntax-markup-inserted-text);background-color:var(--color-prettylights-syntax-markup-inserted-bg)}.markdown-body .pl-mc{color:var(--color-prettylights-syntax-markup-changed-text);background-color:var(--color-prettylights-syntax-markup-changed-bg)}.markdown-body .pl-mi2{color:var(--color-prettylights-syntax-markup-ignored-text);background-color:var(--color-prettylights-syntax-markup-ignored-bg)}.markdown-body .pl-mdr{font-weight:700;color:var(--color-prettylights-syntax-meta-diff-range)}.markdown-body .pl-ba{color:var(--color-prettylights-syntax-brackethighlighter-angle)}.markdown-body .pl-sg{color:var(--color-prettylights-syntax-sublimelinter-gutter-mark)}.markdown-body .pl-corl{text-decoration:underline;color:var(--color-prettylights-syntax-constant-other-reference-link)}.markdown-body g-emoji{display:inline-block;min-width:1ch;font-family:"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol;font-size:1em;font-style:normal!important;font-weight:var(--base-text-weight-normal, 400);line-height:1;vertical-align:-.075em}.markdown-body g-emoji img{width:1em;height:1em}.markdown-body .task-list-item{list-style-type:none}.markdown-body .task-list-item label{font-weight:var(--base-text-weight-normal, 400)}.markdown-body .task-list-item.enabled label{cursor:pointer}.markdown-body .task-list-item+.task-list-item{margin-top:4px}.markdown-body .task-list-item .handle{display:none}.markdown-body .task-list-item-checkbox{margin:0 .2em .25em -1.4em;vertical-align:middle}.markdown-body .contains-task-list:dir(rtl) .task-list-item-checkbox{margin:0 -1.6em .25em .2em}.markdown-body .contains-task-list{position:relative}.markdown-body .contains-task-list:hover .task-list-item-convert-container,.markdown-body .contains-task-list:focus-within .task-list-item-convert-container{display:block;width:auto;height:24px;overflow:visible;clip:auto}.markdown-body .QueryBuilder .qb-entity{color:var(--color-prettylights-syntax-entity)}.markdown-body .QueryBuilder .qb-constant{color:var(--color-prettylights-syntax-constant)}.markdown-body ::-webkit-calendar-picker-indicator{filter:invert(50%)}.markdown-body .markdown-alert{padding:0 1em;margin-bottom:16px;color:inherit;border-left:.25em solid var(--color-border-default)}.markdown-body .markdown-alert>:first-child{margin-top:0}.markdown-body .markdown-alert>:last-child{margin-bottom:0}.markdown-body .markdown-alert.markdown-alert-note{border-left-color:var(--color-accent-fg)}.markdown-body .markdown-alert.markdown-alert-important{border-left-color:var(--color-done-fg)}.markdown-body .markdown-alert.markdown-alert-warning{border-left-color:var(--color-attention-fg)} +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--header-height: 4rem;--background: 0 0% 100%;--foreground: 222.2 84% 4.9%;--card: 0 0% 100%;--card-foreground: 222.2 84% 4.9%;--popover: 0 0% 100%;--popover-foreground: 222.2 84% 4.9%;--primary: 222.2 47.4% 11.2%;--primary-foreground: 210 40% 98%;--secondary: 210 40% 96.1%;--secondary-foreground: 222.2 47.4% 11.2%;--muted: 210 40% 96.1%;--muted-foreground: 215.4 16.3% 46.9%;--accent: 210 40% 96.1%;--accent-foreground: 222.2 47.4% 11.2%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;--border: 214.3 31.8% 91.4%;--input: 214.3 31.8% 91.4%;--ring: 222.2 84% 4.9%;--radius: .5rem}.dark{--background: 222.2 84% 4.9%;--foreground: 210 40% 98%;--card: 222.2 84% 4.9%;--card-foreground: 210 40% 98%;--popover: 222.2 84% 4.9%;--popover-foreground: 210 40% 98%;--primary: 210 40% 98%;--primary-foreground: 222.2 47.4% 11.2%;--secondary: 217.2 32.6% 17.5%;--secondary-foreground: 210 40% 98%;--muted: 217.2 32.6% 17.5%;--muted-foreground: 215 20.2% 65.1%;--accent: 217.2 32.6% 17.5%;--accent-foreground: 210 40% 98%;--destructive: 0 62.8% 30.6%;--destructive-foreground: 210 40% 98%;--border: 217.2 32.6% 17.5%;--input: 217.2 32.6% 17.5%;--ring: 212.7 26.8% 83.9%}.collapsibleDropdown{overflow:hidden}.collapsibleDropdown[data-state=open]{animation:slideDown .2s ease-out}.collapsibleDropdown[data-state=closed]{animation:slideUp .2s ease-out}@keyframes slideDown{0%{height:0}to{height:var(--radix-collapsible-content-height)}}@keyframes slideUp{0%{height:var(--radix-collapsible-content-height)}to{height:0}}*{border-color:hsl(var(--border))}body{min-height:100svh;width:100%;background-color:hsl(var(--background));color:hsl(var(--foreground))}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media (min-width: 1400px){.container{max-width:1400px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.invisible{visibility:hidden}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.-left-1{left:-.25rem}.-right-1{right:-.25rem}.-right-5{right:-1.25rem}.-top-1{top:-.25rem}.-top-1\/2{top:-50%}.bottom-0{bottom:0}.bottom-5{bottom:1.25rem}.bottom-full{bottom:100%}.left-0{left:0}.left-1\/2{left:50%}.left-2{left:.5rem}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[50\%\]{left:50%}.right-0{right:0}.right-1{right:.25rem}.right-1\.5{right:.375rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-5{right:1.25rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-2\.5{top:.625rem}.top-4{top:1rem}.top-\[1px\]{top:1px}.top-\[50\%\]{top:50%}.top-\[60\%\]{top:60%}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[-1\]{z-index:-1}.z-\[1\]{z-index:1}.col-span-2{grid-column:span 2 / span 2}.col-span-3{grid-column:span 3 / span 3}.-m-0\.5{margin:-.125rem}.m-1{margin:.25rem}.m-auto{margin:auto}.-mx-1{margin-left:-.25rem;margin-right:-.25rem}.-mx-4{margin-left:-1rem;margin-right:-1rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-4{margin-top:1rem;margin-bottom:1rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.-ml-3{margin-left:-.75rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-8{margin-left:2rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-4{margin-right:1rem}.mr-auto{margin-right:auto}.mt-0{margin-top:0}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-24{margin-top:6rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.\!table{display:table!important}.table{display:table}.grid{display:grid}.hidden{display:none}.aspect-\[16\/9\]{aspect-ratio:16/9}.aspect-square{aspect-ratio:1 / 1}.size-10{width:2.5rem;height:2.5rem}.size-2\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-\[--cell-size\]{width:var(--cell-size);height:var(--cell-size)}.h-0{height:0px}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-40{height:10rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-\[--cell-size\]{height:var(--cell-size)}.h-\[100vh\]{height:100vh}.h-\[180px\]{height:180px}.h-\[1px\]{height:1px}.h-\[200px\]{height:200px}.h-\[300px\]{height:300px}.h-\[400px\]{height:400px}.h-\[85vh\]{height:85vh}.h-\[90vh\]{height:90vh}.h-\[calc\(100\%-var\(--header-height\)\)\]{height:calc(100% - var(--header-height))}.h-\[calc\(100vh-280px\)\]{height:calc(100vh - 280px)}.h-\[var\(--header-height\)\]{height:var(--header-height)}.h-\[var\(--radix-navigation-menu-viewport-height\)\]{height:var(--radix-navigation-menu-viewport-height)}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.h-svh{height:100svh}.max-h-12{max-height:3rem}.max-h-96{max-height:24rem}.max-h-\[150px\]{max-height:150px}.max-h-\[200px\]{max-height:200px}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[95\%\]{max-height:95%}.max-h-\[calc\(85vh-120px\)\]{max-height:calc(85vh - 120px)}.min-h-10{min-height:2.5rem}.min-h-6{min-height:1.5rem}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[200px\]{min-height:200px}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.min-h-svh{min-height:100svh}.w-0{width:0px}.w-1\.5{width:.375rem}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-2\/3{width:66.666667%}.w-20{width:5rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-3\/4{width:75%}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-4\/5{width:80%}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-72{width:18rem}.w-8{width:2rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-\[--cell-size\]{width:var(--cell-size)}.w-\[100px\]{width:100px}.w-\[120px\]{width:120px}.w-\[140px\]{width:140px}.w-\[150px\]{width:150px}.w-\[180px\]{width:180px}.w-\[1px\]{width:1px}.w-\[200px\]{width:200px}.w-\[250px\]{width:250px}.w-\[300px\]{width:300px}.w-\[400px\]{width:400px}.w-\[50px\]{width:50px}.w-\[60px\]{width:60px}.w-\[70px\]{width:70px}.w-\[80px\]{width:80px}.w-\[9\.5rem\]{width:9.5rem}.w-auto{width:auto}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-20{min-width:5rem}.min-w-\[--cell-size\]{min-width:var(--cell-size)}.min-w-\[10em\]{min-width:10em}.min-w-\[200px\]{min-width:200px}.min-w-\[3rem\]{min-width:3rem}.min-w-\[40px\]{min-width:40px}.min-w-\[4rem\]{min-width:4rem}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.max-w-2xl{max-width:42rem}.max-w-32{max-width:8rem}.max-w-4xl{max-width:56rem}.max-w-52{max-width:13rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[300px\]{max-width:300px}.max-w-\[500px\]{max-width:500px}.max-w-\[60\%\]{max-width:60%}.max-w-\[600px\]{max-width:600px}.max-w-\[90\%\]{max-width:90%}.max-w-\[90vw\]{max-width:90vw}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-max{max-width:-moz-max-content;max-width:max-content}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-\[1\.2\]{flex:1.2}.flex-\[1\]{flex:1}.flex-\[2\]{flex:2}.flex-\[4\]{flex:4}.flex-\[5\]{flex:5}.flex-none{flex:none}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-x-full{--tw-translate-x: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\[-50\%\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-full{--tw-translate-x: 100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-0{--tw-translate-y: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\[-50\%\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-help{cursor:help}.cursor-move{cursor:move}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-\[100px_1fr\]{grid-template-columns:100px 1fr}.flex-row{flex-direction:row}.flex-row-reverse{flex-direction:row-reverse}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-1{-moz-column-gap:.25rem;column-gap:.25rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-2{row-gap:.5rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2\.5>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.625rem * var(--tw-space-x-reverse));margin-left:calc(.625rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-scroll{overflow-y:scroll}.overscroll-contain{overscroll-behavior:contain}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-wrap{text-wrap:wrap}.text-nowrap{text-wrap:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-\[inherit\]{border-radius:inherit}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:.75rem}.rounded-l-lg{border-top-left-radius:var(--radius);border-bottom-left-radius:var(--radius)}.rounded-l-md{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.rounded-l-none{border-top-left-radius:0;border-bottom-left-radius:0}.rounded-r-lg{border-top-right-radius:var(--radius);border-bottom-right-radius:var(--radius)}.rounded-r-md{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.rounded-r-none{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-t-\[10px\]{border-top-left-radius:10px;border-top-right-radius:10px}.rounded-bl-none{border-bottom-left-radius:0}.rounded-br-none{border-bottom-right-radius:0}.rounded-tl-lg{border-top-left-radius:var(--radius)}.rounded-tl-none{border-top-left-radius:0}.rounded-tl-sm{border-top-left-radius:calc(var(--radius) - 4px)}.rounded-tr-lg{border-top-right-radius:var(--radius)}.rounded-tr-none{border-top-right-radius:0}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-x-0{border-left-width:0px;border-right-width:0px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l{border-left-width:1px}.border-l-0{border-left-width:0px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-r-0{border-right-width:0px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-300{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.border-blue-500\/50{border-color:#3b82f680}.border-border{border-color:hsl(var(--border))}.border-border\/30{border-color:hsl(var(--border) / .3)}.border-border\/50{border-color:hsl(var(--border) / .5)}.border-current{border-color:currentColor}.border-destructive\/50{border-color:hsl(var(--destructive) / .5)}.border-emerald-200{--tw-border-opacity: 1;border-color:rgb(167 243 208 / var(--tw-border-opacity, 1))}.border-foreground\/10{border-color:hsl(var(--foreground) / .1)}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-indigo-200{--tw-border-opacity: 1;border-color:rgb(199 210 254 / var(--tw-border-opacity, 1))}.border-input{border-color:hsl(var(--input))}.border-muted{border-color:hsl(var(--muted))}.border-muted-foreground\/25{border-color:hsl(var(--muted-foreground) / .25)}.border-muted-foreground\/30{border-color:hsl(var(--muted-foreground) / .3)}.border-orange-200{--tw-border-opacity: 1;border-color:rgb(254 215 170 / var(--tw-border-opacity, 1))}.border-orange-500\/50{border-color:#f9731680}.border-primary{border-color:hsl(var(--primary))}.border-primary\/20{border-color:hsl(var(--primary) / .2)}.border-primary\/40{border-color:hsl(var(--primary) / .4)}.border-primary\/50{border-color:hsl(var(--primary) / .5)}.border-purple-200{--tw-border-opacity: 1;border-color:rgb(233 213 255 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-l-slate-500{--tw-border-opacity: 1;border-left-color:rgb(100 116 139 / var(--tw-border-opacity, 1))}.border-l-transparent{border-left-color:transparent}.border-r-muted{border-right-color:hsl(var(--muted))}.border-t-transparent{border-top-color:transparent}.bg-accent{background-color:hsl(var(--accent))}.bg-amber-100{--tw-bg-opacity: 1;background-color:rgb(254 243 199 / var(--tw-bg-opacity, 1))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-background{background-color:hsl(var(--background))}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/20{background-color:#0003}.bg-black\/80{background-color:#000c}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-destructive\/15{background-color:hsl(var(--destructive) / .15)}.bg-destructive\/80{background-color:hsl(var(--destructive) / .8)}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\/80{background-color:#10b981cc}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-indigo-100{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1))}.bg-inherit{background-color:inherit}.bg-muted{background-color:hsl(var(--muted))}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-popover{background-color:hsl(var(--popover))}.bg-primary{background-color:hsl(var(--primary))}.bg-primary-foreground{background-color:hsl(var(--primary-foreground))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-primary\/20{background-color:hsl(var(--primary) / .2)}.bg-primary\/5{background-color:hsl(var(--primary) / .05)}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-secondary{background-color:hsl(var(--secondary))}.bg-secondary\/50{background-color:hsl(var(--secondary) / .5)}.bg-slate-100\/80{background-color:#f1f5f9cc}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-yellow-500{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.bg-yellow-500\/80{background-color:#eab308cc}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-background\/95{--tw-gradient-from: hsl(var(--background) / .95) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-background\/80{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .8) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-background\/60{--tw-gradient-to: hsl(var(--background) / .6) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-primary{fill:hsl(var(--primary))}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-\[1px\]{padding:1px}.px-0{padding-left:0;padding-right:0}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.px-\[--cell-size\]{padding-left:var(--cell-size);padding-right:var(--cell-size)}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-0\.5{padding-bottom:.125rem}.pb-16{padding-bottom:4rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-2{padding-left:.5rem}.pl-2\.5{padding-left:.625rem}.pl-3{padding-left:.75rem}.pl-6{padding-left:1.5rem}.pl-8{padding-left:2rem}.pl-9{padding-left:2.25rem}.pr-1{padding-right:.25rem}.pr-10{padding-right:2.5rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-2\.5{padding-right:.625rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-7{padding-right:1.75rem}.pr-8{padding-right:2rem}.pr-9{padding-right:2.25rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\.5{padding-top:.375rem}.pt-16{padding-top:4rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[0\.625rem\]{font-size:.625rem}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.8rem\]{font-size:.8rem}.text-\[10px\]{font-size:10px}.text-\[7rem\]{font-size:7rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-10{line-height:2.5rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-widest{letter-spacing:.1em}.text-accent-foreground{color:hsl(var(--accent-foreground))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-current{color:currentColor}.text-destructive{color:hsl(var(--destructive))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-emerald-500{--tw-text-opacity: 1;color:rgb(16 185 129 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(6 95 70 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--foreground))}.text-foreground\/70{color:hsl(var(--foreground) / .7)}.text-foreground\/90{color:hsl(var(--foreground) / .9)}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-indigo-800{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-muted-foreground\/30{color:hsl(var(--muted-foreground) / .3)}.text-muted-foreground\/40{color:hsl(var(--muted-foreground) / .4)}.text-muted-foreground\/50{color:hsl(var(--muted-foreground) / .5)}.text-muted-foreground\/60{color:hsl(var(--muted-foreground) / .6)}.text-muted-foreground\/70{color:hsl(var(--muted-foreground) / .7)}.text-orange-500{--tw-text-opacity: 1;color:rgb(249 115 22 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-orange-800{--tw-text-opacity: 1;color:rgb(154 52 18 / var(--tw-text-opacity, 1))}.text-popover-foreground{color:hsl(var(--popover-foreground))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-primary\/90{color:hsl(var(--primary) / .9)}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--secondary-foreground))}.text-slate-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.underline-offset-4{text-underline-offset:4px}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-destructive\/50{--tw-shadow-color: hsl(var(--destructive) / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-500\/50{--tw-shadow-color: rgb(16 185 129 / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-yellow-500\/50{--tw-shadow-color: rgb(234 179 8 / .5);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-0{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(229 231 235 / var(--tw-ring-opacity, 1))}.ring-gray-300\/20{--tw-ring-color: rgb(209 213 219 / .2)}.ring-green-500\/20{--tw-ring-color: rgb(34 197 94 / .2)}.ring-primary\/20{--tw-ring-color: hsl(var(--primary) / .2)}.ring-offset-2{--tw-ring-offset-width: 2px}.ring-offset-background{--tw-ring-offset-color: hsl(var(--background))}.ring-offset-white{--tw-ring-offset-color: #fff}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[1px\]{--tw-backdrop-blur: blur(1px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[max-height\,padding\]{transition-property:max-height,padding;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[opacity\]{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.delay-100{transition-delay:.1s}.delay-150{transition-delay:.15s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.duration-700{transition-duration:.7s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.duration-500{animation-duration:.5s}.duration-700{animation-duration:.7s}.delay-100{animation-delay:.1s}.delay-150{animation-delay:.15s}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.\[--cell-size\:2rem\]{--cell-size: 2rem}html{overflow-y:scroll}.sticky{position:sticky!important;z-index:2;background-color:hsl(var(--card))}.sticky.before\:right-0:before,.sticky.before\:left-0:before{content:"";position:absolute;top:0;bottom:0;width:2px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent);opacity:1;transition:opacity .3s ease}.sticky.before\:right-0:before{right:-1px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent)}.sticky.before\:right-0:after{content:"";position:absolute;top:0;right:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to right,rgba(0,0,0,.05),transparent)}.sticky.before\:left-0:before{left:-1px;background:linear-gradient(to left,rgba(0,0,0,.08),transparent)}.sticky.before\:left-0:after{content:"";position:absolute;top:0;left:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to left,rgba(0,0,0,.05),transparent)}.sticky:hover:before{opacity:.8}.dark .sticky.before\:right-0:before,.dark .sticky.before\:left-0:before{background:linear-gradient(to right,rgba(255,255,255,.05),transparent)}.dark .sticky.before\:right-0:after,.dark .sticky.before\:left-0:after{background:linear-gradient(to right,rgba(255,255,255,.03),transparent)}.\*\:\!inline-block>*{display:inline-block!important}.file\:border-0::file-selector-button{border-width:0px}.file\:bg-transparent::file-selector-button{background-color:transparent}.file\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\:font-medium::file-selector-button{font-weight:500}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:bottom-0:before{content:var(--tw-content);bottom:0}.before\:left-0:before{content:var(--tw-content);left:0}.before\:right-0:before{content:var(--tw-content);right:0}.before\:top-0:before{content:var(--tw-content);top:0}.before\:w-\[1px\]:before{content:var(--tw-content);width:1px}.before\:bg-border:before{content:var(--tw-content);background-color:hsl(var(--border))}.after\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:inset-y-0:after{content:var(--tw-content);top:0;bottom:0}.after\:bottom-0:after{content:var(--tw-content);bottom:0}.after\:left-0:after{content:var(--tw-content);left:0}.after\:left-1\/2:after{content:var(--tw-content);left:50%}.after\:hidden:after{content:var(--tw-content);display:none}.after\:h-32:after{content:var(--tw-content);height:8rem}.after\:w-1:after{content:var(--tw-content);width:.25rem}.after\:w-full:after{content:var(--tw-content);width:100%}.after\:-translate-x-1\/2:after{content:var(--tw-content);--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.after\:bg-\[linear-gradient\(180deg\,_transparent_10\%\,_hsl\(var\(--background\)\)_70\%\)\]:after{content:var(--tw-content);background-image:linear-gradient(180deg,transparent 10%,hsl(var(--background)) 70%)}.focus-within\:ring-1:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-ring:focus-within{--tw-ring-color: hsl(var(--ring))}.hover\:-translate-y-1:hover{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:rotate-180:hover{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-accent\/50:hover{background-color:hsl(var(--accent) / .5)}.hover\:bg-background:hover{background-color:hsl(var(--background))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-200:hover{--tw-bg-opacity: 1;background-color:rgb(191 219 254 / var(--tw-bg-opacity, 1))}.hover\:bg-card\/80:hover{background-color:hsl(var(--card) / .8)}.hover\:bg-destructive\/10:hover{background-color:hsl(var(--destructive) / .1)}.hover\:bg-destructive\/25:hover{background-color:hsl(var(--destructive) / .25)}.hover\:bg-destructive\/80:hover{background-color:hsl(var(--destructive) / .8)}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-inherit:hover{background-color:inherit}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-muted\/40:hover{background-color:hsl(var(--muted) / .4)}.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted) / .5)}.hover\:bg-muted\/60:hover{background-color:hsl(var(--muted) / .6)}.hover\:bg-muted\/70:hover{background-color:hsl(var(--muted) / .7)}.hover\:bg-orange-100:hover{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.hover\:bg-primary\/10:hover{background-color:hsl(var(--primary) / .1)}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-secondary-foreground\/10:hover{background-color:hsl(var(--secondary-foreground) / .1)}.hover\:bg-secondary\/70:hover{background-color:hsl(var(--secondary) / .7)}.hover\:bg-secondary\/80:hover{background-color:hsl(var(--secondary) / .8)}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-200\/80:hover{background-color:#e2e8f0cc}.hover\:bg-transparent:hover{background-color:transparent}.hover\:bg-yellow-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.hover\:bg-opacity-80:hover{--tw-bg-opacity: .8}.hover\:text-accent-foreground:hover{color:hsl(var(--accent-foreground))}.hover\:text-destructive:hover{color:hsl(var(--destructive))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:text-foreground\/70:hover{color:hsl(var(--foreground) / .7)}.hover\:text-muted-foreground:hover{color:hsl(var(--muted-foreground))}.hover\:text-primary:hover{color:hsl(var(--primary))}.hover\:text-primary\/80:hover{color:hsl(var(--primary) / .8)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-black\/30:hover{--tw-shadow-color: rgb(0 0 0 / .3);--tw-shadow: var(--tw-shadow-colored)}.hover\:ring-primary:hover{--tw-ring-color: hsl(var(--primary))}.focus\:z-10:focus{z-index:10}.focus\:bg-accent:focus{background-color:hsl(var(--accent))}.focus\:text-accent-foreground:focus{color:hsl(var(--accent-foreground))}.focus\:text-destructive:focus{color:hsl(var(--destructive))}.focus\:text-red-600:focus{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-red-600:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(220 38 38 / var(--tw-ring-opacity, 1))}.focus\:ring-ring:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-primary:focus-visible{--tw-ring-color: hsl(var(--primary))}.focus-visible\:ring-red-500:focus-visible{--tw-ring-opacity: 1;--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity, 1))}.focus-visible\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--ring))}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width: 1px}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.focus-visible\:ring-offset-background:focus-visible{--tw-ring-offset-color: hsl(var(--background))}.active\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:pointer-events-auto{pointer-events:auto}.group:hover .group-hover\:via-background\/90{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .9) var(--tw-gradient-via-position), var(--tw-gradient-to)}.group:hover .group-hover\:to-background\/70{--tw-gradient-to: hsl(var(--background) / .7) var(--tw-gradient-to-position)}.group\/id:hover .group-hover\/id\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:justify-center{justify-content:center}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:px-2{padding-left:.5rem;padding-right:.5rem}.peer:disabled~.peer-disabled\:cursor-not-allowed{cursor:not-allowed}.peer:disabled~.peer-disabled\:opacity-70{opacity:.7}.has-\[\:focus-visible\]\:outline-none:has(:focus-visible){outline:2px solid transparent;outline-offset:2px}.has-\[\:focus-visible\]\:ring-1:has(:focus-visible){--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.has-\[\:focus-visible\]\:ring-neutral-950:has(:focus-visible){--tw-ring-opacity: 1;--tw-ring-color: rgb(10 10 10 / var(--tw-ring-opacity, 1))}.aria-disabled\:opacity-50[aria-disabled=true]{opacity:.5}.aria-selected\:bg-accent[aria-selected=true]{background-color:hsl(var(--accent))}.aria-selected\:text-accent-foreground[aria-selected=true]{color:hsl(var(--accent-foreground))}.aria-selected\:text-muted-foreground[aria-selected=true]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[panel-group-direction\=vertical\]\:h-px[data-panel-group-direction=vertical]{height:1px}.data-\[panel-group-direction\=vertical\]\:w-full[data-panel-group-direction=vertical]{width:100%}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=left\]\:-translate-x-1[data-side=left]{--tw-translate-x: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=right\]\:translate-x-1[data-side=right]{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=top\]\:-translate-y-1[data-side=top]{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x: 1rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes accordion-up{0%{height:var(--radix-accordion-content-height)}to{height:0}}.data-\[state\=closed\]\:animate-accordion-up[data-state=closed]{animation:accordion-up .2s ease-out}@keyframes accordion-down{0%{height:0}to{height:var(--radix-accordion-content-height)}}.data-\[state\=open\]\:animate-accordion-down[data-state=open]{animation:accordion-down .2s ease-out}.data-\[state\=dragging\]\:cursor-grabbing[data-state=dragging]{cursor:grabbing}.data-\[panel-group-direction\=vertical\]\:flex-col[data-panel-group-direction=vertical]{flex-direction:column}.data-\[range-end\=true\]\:rounded-md[data-range-end=true]{border-radius:calc(var(--radius) - 2px)}.data-\[range-middle\=true\]\:rounded-none[data-range-middle=true]{border-radius:0}.data-\[range-start\=true\]\:rounded-md[data-range-start=true]{border-radius:calc(var(--radius) - 2px)}.data-\[selected\=true\]\:rounded-none[data-selected=true]{border-radius:0}.data-\[active\]\:bg-accent\/50[data-active]{background-color:hsl(var(--accent) / .5)}.data-\[disabled\]\:bg-muted-foreground[data-disabled],.data-\[fixed\]\:bg-muted-foreground[data-fixed]{background-color:hsl(var(--muted-foreground))}.data-\[range-end\=true\]\:bg-primary[data-range-end=true]{background-color:hsl(var(--primary))}.data-\[range-middle\=true\]\:bg-accent[data-range-middle=true]{background-color:hsl(var(--accent))}.data-\[range-start\=true\]\:bg-primary[data-range-start=true],.data-\[selected-single\=true\]\:bg-primary[data-selected-single=true]{background-color:hsl(var(--primary))}.data-\[state\=active\]\:bg-background[data-state=active]{background-color:hsl(var(--background))}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:hsl(var(--primary))}.data-\[state\=open\]\:bg-accent[data-state=open]{background-color:hsl(var(--accent))}.data-\[state\=open\]\:bg-accent\/50[data-state=open]{background-color:hsl(var(--accent) / .5)}.data-\[state\=open\]\:bg-secondary[data-state=open]{background-color:hsl(var(--secondary))}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:hsl(var(--muted))}.data-\[state\=unchecked\]\:bg-input[data-state=unchecked]{background-color:hsl(var(--input))}.data-\[collapsed\=true\]\:py-2[data-collapsed=true]{padding-top:.5rem;padding-bottom:.5rem}.data-\[disabled\]\:text-muted[data-disabled],.data-\[fixed\]\:text-muted[data-fixed]{color:hsl(var(--muted))}.data-\[range-end\=true\]\:text-primary-foreground[data-range-end=true]{color:hsl(var(--primary-foreground))}.data-\[range-middle\=true\]\:text-accent-foreground[data-range-middle=true]{color:hsl(var(--accent-foreground))}.data-\[range-start\=true\]\:text-primary-foreground[data-range-start=true],.data-\[selected-single\=true\]\:text-primary-foreground[data-selected-single=true]{color:hsl(var(--primary-foreground))}.data-\[state\=active\]\:text-foreground[data-state=active]{color:hsl(var(--foreground))}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:hsl(var(--primary-foreground))}.data-\[state\=open\]\:text-muted-foreground[data-state=open]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{transition-duration:.3s}.data-\[motion\^\=from-\]\:animate-in[data-motion^=from-],.data-\[state\=open\]\:animate-in[data-state=open],.data-\[state\=visible\]\:animate-in[data-state=visible]{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.data-\[motion\^\=to-\]\:animate-out[data-motion^=to-],.data-\[state\=closed\]\:animate-out[data-state=closed],.data-\[state\=hidden\]\:animate-out[data-state=hidden]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\[motion\^\=from-\]\:fade-in[data-motion^=from-]{--tw-enter-opacity: 0}.data-\[motion\^\=to-\]\:fade-out[data-motion^=to-],.data-\[state\=closed\]\:fade-out-0[data-state=closed],.data-\[state\=hidden\]\:fade-out[data-state=hidden]{--tw-exit-opacity: 0}.data-\[state\=open\]\:fade-in-0[data-state=open],.data-\[state\=visible\]\:fade-in[data-state=visible]{--tw-enter-opacity: 0}.data-\[state\=closed\]\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\[state\=open\]\:zoom-in-90[data-state=open]{--tw-enter-scale: .9}.data-\[state\=open\]\:zoom-in-95[data-state=open]{--tw-enter-scale: .95}.data-\[motion\=from-end\]\:slide-in-from-right-52[data-motion=from-end]{--tw-enter-translate-x: 13rem}.data-\[motion\=from-start\]\:slide-in-from-left-52[data-motion=from-start]{--tw-enter-translate-x: -13rem}.data-\[motion\=to-end\]\:slide-out-to-right-52[data-motion=to-end]{--tw-exit-translate-x: 13rem}.data-\[motion\=to-start\]\:slide-out-to-left-52[data-motion=to-start]{--tw-exit-translate-x: -13rem}.data-\[side\=bottom\]\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.data-\[state\=closed\]\:slide-out-to-bottom[data-state=closed]{--tw-exit-translate-y: 100%}.data-\[state\=closed\]\:slide-out-to-left[data-state=closed]{--tw-exit-translate-x: -100%}.data-\[state\=closed\]\:slide-out-to-left-1\/2[data-state=closed]{--tw-exit-translate-x: -50%}.data-\[state\=closed\]\:slide-out-to-right[data-state=closed]{--tw-exit-translate-x: 100%}.data-\[state\=closed\]\:slide-out-to-top[data-state=closed]{--tw-exit-translate-y: -100%}.data-\[state\=closed\]\:slide-out-to-top-\[48\%\][data-state=closed]{--tw-exit-translate-y: -48%}.data-\[state\=open\]\:slide-in-from-bottom[data-state=open]{--tw-enter-translate-y: 100%}.data-\[state\=open\]\:slide-in-from-left[data-state=open]{--tw-enter-translate-x: -100%}.data-\[state\=open\]\:slide-in-from-left-1\/2[data-state=open]{--tw-enter-translate-x: -50%}.data-\[state\=open\]\:slide-in-from-right[data-state=open]{--tw-enter-translate-x: 100%}.data-\[state\=open\]\:slide-in-from-top[data-state=open]{--tw-enter-translate-y: -100%}.data-\[state\=open\]\:slide-in-from-top-\[48\%\][data-state=open]{--tw-enter-translate-y: -48%}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{animation-duration:.3s}.data-\[panel-group-direction\=vertical\]\:after\:left-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);left:0}.data-\[panel-group-direction\=vertical\]\:after\:h-1[data-panel-group-direction=vertical]:after{content:var(--tw-content);height:.25rem}.data-\[panel-group-direction\=vertical\]\:after\:w-full[data-panel-group-direction=vertical]:after{content:var(--tw-content);width:100%}.data-\[panel-group-direction\=vertical\]\:after\:-translate-y-1\/2[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[panel-group-direction\=vertical\]\:after\:translate-x-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[disabled\]\:hover\:bg-muted-foreground:hover[data-disabled],.data-\[fixed\]\:hover\:bg-muted-foreground:hover[data-fixed]{background-color:hsl(var(--muted-foreground))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:relative{position:relative}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:z-10{z-index:10}.group[data-state=open] .group-data-\[state\=\"open\"\]\:-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group[data-state=open] .group-data-\[state\=open\]\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:border-ring{border-color:hsl(var(--ring))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-\[3px\]{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-ring\/50{--tw-ring-color: hsl(var(--ring) / .5)}.dark\:border-amber-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(120 53 15 / var(--tw-border-opacity, 1))}.dark\:border-blue-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(29 78 216 / var(--tw-border-opacity, 1))}.dark\:border-blue-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(30 58 138 / var(--tw-border-opacity, 1))}.dark\:border-gray-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.dark\:border-red-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(127 29 29 / var(--tw-border-opacity, 1))}.dark\:border-yellow-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(113 63 18 / var(--tw-border-opacity, 1))}.dark\:bg-amber-900\/50:is(.dark *){background-color:#78350f80}.dark\:bg-amber-950\/30:is(.dark *){background-color:#451a034d}.dark\:bg-blue-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950\/30:is(.dark *){background-color:#1725544d}.dark\:bg-gray-800\/50:is(.dark *){background-color:#1f293780}.dark\:bg-green-500\/10:is(.dark *){background-color:#22c55e1a}.dark\:bg-red-500\/10:is(.dark *){background-color:#ef44441a}.dark\:bg-red-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-950\/30:is(.dark *){background-color:#450a0a4d}.dark\:bg-yellow-500\/10:is(.dark *){background-color:#eab3081a}.dark\:bg-yellow-950\/30:is(.dark *){background-color:#4220064d}.dark\:text-amber-200:is(.dark *){--tw-text-opacity: 1;color:rgb(253 230 138 / var(--tw-text-opacity, 1))}.dark\:text-amber-400:is(.dark *){--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.dark\:text-blue-300:is(.dark *){--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity, 1))}.dark\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.dark\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-300:is(.dark *){--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-yellow-300:is(.dark *){--tw-text-opacity: 1;color:rgb(253 224 71 / var(--tw-text-opacity, 1))}.dark\:text-yellow-400:is(.dark *){--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}.dark\:ring-gray-700:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity, 1))}.dark\:ring-gray-800:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(31 41 55 / var(--tw-ring-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::-moz-placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:hover\:bg-blue-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-blue-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:hover\:text-red-400:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:has-\[\:focus-visible\]\:ring-neutral-300:has(:focus-visible):is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(212 212 212 / var(--tw-ring-opacity, 1))}@media (min-width: 640px){.sm\:absolute{position:absolute}.sm\:inset-auto{inset:auto}.sm\:bottom-\[calc\(100\%\+10px\)\]{bottom:calc(100% + 10px)}.sm\:left-0{left:0}.sm\:right-0{right:0}.sm\:my-0{margin-top:0;margin-bottom:0}.sm\:my-4{margin-top:1rem;margin-bottom:1rem}.sm\:mt-0{margin-top:0}.sm\:mt-6{margin-top:1.5rem}.sm\:block{display:block}.sm\:hidden{display:none}.sm\:h-\[80vh\]{height:80vh}.sm\:h-full{height:100%}.sm\:max-h-\[500px\]{max-height:500px}.sm\:max-h-\[600px\]{max-height:600px}.sm\:max-h-\[700px\]{max-height:700px}.sm\:max-h-\[800px\]{max-height:800px}.sm\:w-48{width:12rem}.sm\:w-\[350px\]{width:350px}.sm\:w-\[540px\]{width:540px}.sm\:w-\[90vw\]{width:90vw}.sm\:w-auto{width:auto}.sm\:w-full{width:100%}.sm\:max-w-72{max-width:18rem}.sm\:max-w-\[1025px\]{max-width:1025px}.sm\:max-w-\[425px\]{max-width:425px}.sm\:max-w-\[500px\]{max-width:500px}.sm\:max-w-\[700px\]{max-width:700px}.sm\:max-w-lg{max-width:32rem}.sm\:max-w-md{max-width:28rem}.sm\:max-w-sm{max-width:24rem}.sm\:max-w-xl{max-width:36rem}.sm\:translate-y-5{--tw-translate-y: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-end{justify-content:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:gap-0{gap:0px}.sm\:gap-6{gap:1.5rem}.sm\:space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:rounded-lg{border-radius:var(--radius)}.sm\:p-6{padding:1.5rem}.sm\:text-left{text-align:left}.sm\:text-2xl{font-size:1.5rem;line-height:2rem}.sm\:text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width: 768px){.md\:absolute{position:absolute}.md\:relative{position:relative}.md\:bottom-0{bottom:0}.md\:right-8{right:2rem}.md\:right-auto{right:auto}.md\:top-8{top:2rem}.md\:col-span-1{grid-column:span 1 / span 1}.md\:mb-2{margin-bottom:.5rem}.md\:ml-14{margin-left:3.5rem}.md\:ml-64{margin-left:16rem}.md\:mt-2{margin-top:.5rem}.md\:block{display:block}.md\:flex{display:flex}.md\:inline-flex{display:inline-flex}.md\:hidden{display:none}.md\:h-full{height:100%}.md\:h-svh{height:100svh}.md\:w-14{width:3.5rem}.md\:w-32{width:8rem}.md\:w-64{width:16rem}.md\:w-80{width:20rem}.md\:w-\[420px\]{width:420px}.md\:w-\[var\(--radix-navigation-menu-viewport-width\)\]{width:var(--radix-navigation-menu-viewport-width)}.md\:w-auto{width:auto}.md\:max-w-\[31rem\]{max-width:31rem}.md\:translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.md\:overflow-y-hidden{overflow-y:hidden}.md\:border-none{border-style:none}.md\:px-4{padding-left:1rem;padding-right:1rem}.md\:px-8{padding-left:2rem;padding-right:2rem}.md\:py-2{padding-top:.5rem;padding-bottom:.5rem}.md\:pt-0{padding-top:0}.md\:text-2xl{font-size:1.5rem;line-height:2rem}.md\:text-3xl{font-size:1.875rem;line-height:2.25rem}.md\:opacity-0{opacity:0}.after\:md\:block:after{content:var(--tw-content);display:block}}@media (min-width: 1024px){.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:w-1\/5{width:20%}.lg\:w-\[250px\]{width:250px}.lg\:max-w-none{max-width:none}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:flex-col{flex-direction:column}.lg\:gap-8{gap:2rem}.lg\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(0px * var(--tw-space-x-reverse));margin-left:calc(0px * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-x-12>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(3rem * var(--tw-space-x-reverse));margin-left:calc(3rem * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.lg\:space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.lg\:p-8{padding:2rem}.lg\:px-0{padding-left:0;padding-right:0}.lg\:px-3{padding-left:.75rem;padding-right:.75rem}}@media (min-width: 1280px){.xl\:mr-2{margin-right:.5rem}.xl\:flex{display:flex}.xl\:inline-flex{display:inline-flex}.xl\:h-10{height:2.5rem}.xl\:w-60{width:15rem}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:justify-start{justify-content:flex-start}.xl\:px-3{padding-left:.75rem;padding-right:.75rem}.xl\:py-2{padding-top:.5rem;padding-bottom:.5rem}}.\[\&\:\:-webkit-calendar-picker-indicator\]\:hidden::-webkit-calendar-picker-indicator{display:none}.\[\&\:first-child\[data-selected\=true\]_button\]\:rounded-l-md:first-child[data-selected=true] button{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\&\:last-child\[data-selected\=true\]_button\]\:rounded-r-md:last-child[data-selected=true] button{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y: 2px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\>span\]\:line-clamp-1>span{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\[\&\>span\]\:text-xs>span{font-size:.75rem;line-height:1rem}.\[\&\>span\]\:opacity-70>span{opacity:.7}.\[\&\>svg\]\:size-3\.5>svg{width:.875rem;height:.875rem}.\[\&\>svg\]\:text-muted-foreground>svg{color:hsl(var(--muted-foreground))}.\[\&\>tr\]\:last\:border-b-0:last-child>tr{border-bottom-width:0px}.\[\&\[data-panel-group-direction\=vertical\]\>div\]\:rotate-90[data-panel-group-direction=vertical]>div{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\[data-state\=open\]\>svg\]\:rotate-180[data-state=open]>svg{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&_\[cmdk-group-heading\]\]\:px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-group-heading\]\]\:py-1\.5 [cmdk-group-heading]{padding-top:.375rem;padding-bottom:.375rem}.\[\&_\[cmdk-group-heading\]\]\:text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\[\&_\[cmdk-group-heading\]\]\:font-medium [cmdk-group-heading]{font-weight:500}.\[\&_\[cmdk-group-heading\]\]\:text-muted-foreground [cmdk-group-heading]{color:hsl(var(--muted-foreground))}.\[\&_\[cmdk-group\]\:not\(\[hidden\]\)_\~\[cmdk-group\]\]\:pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\[\&_\[cmdk-group\]\]\:px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\[\&_\[cmdk-input\]\]\:h-12 [cmdk-input]{height:3rem}.\[\&_\[cmdk-item\]\]\:px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-item\]\]\:py-3 [cmdk-item]{padding-top:.75rem;padding-bottom:.75rem}.\[\&_\[cmdk-item\]_svg\]\:h-5 [cmdk-item] svg{height:1.25rem}.\[\&_\[cmdk-item\]_svg\]\:w-5 [cmdk-item] svg{width:1.25rem}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:invisible svg{visibility:hidden}.\[\&_svg\]\:size-4 svg{width:1rem;height:1rem}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-width:0px}.\[\&_tr\]\:border-b tr{border-bottom-width:1px}[data-slot=card-content] .\[\[data-slot\=card-content\]_\&\]\:bg-transparent,[data-slot=popover-content] .\[\[data-slot\=popover-content\]_\&\]\:bg-transparent{background-color:transparent}html.dark .markdown-body{color-scheme:dark;--color-prettylights-syntax-comment: #8b949e;--color-prettylights-syntax-constant: #79c0ff;--color-prettylights-syntax-entity: #d2a8ff;--color-prettylights-syntax-storage-modifier-import: #c9d1d9;--color-prettylights-syntax-entity-tag: #7ee787;--color-prettylights-syntax-keyword: #ff7b72;--color-prettylights-syntax-string: #a5d6ff;--color-prettylights-syntax-variable: #ffa657;--color-prettylights-syntax-brackethighlighter-unmatched: #f85149;--color-prettylights-syntax-invalid-illegal-text: #f0f6fc;--color-prettylights-syntax-invalid-illegal-bg: #8e1519;--color-prettylights-syntax-carriage-return-text: #f0f6fc;--color-prettylights-syntax-carriage-return-bg: #b62324;--color-prettylights-syntax-string-regexp: #7ee787;--color-prettylights-syntax-markup-list: #f2cc60;--color-prettylights-syntax-markup-heading: #1f6feb;--color-prettylights-syntax-markup-italic: #c9d1d9;--color-prettylights-syntax-markup-bold: #c9d1d9;--color-prettylights-syntax-markup-deleted-text: #ffdcd7;--color-prettylights-syntax-markup-deleted-bg: #67060c;--color-prettylights-syntax-markup-inserted-text: #aff5b4;--color-prettylights-syntax-markup-inserted-bg: #033a16;--color-prettylights-syntax-markup-changed-text: #ffdfb6;--color-prettylights-syntax-markup-changed-bg: #5a1e02;--color-prettylights-syntax-markup-ignored-text: #c9d1d9;--color-prettylights-syntax-markup-ignored-bg: #1158c7;--color-prettylights-syntax-meta-diff-range: #d2a8ff;--color-prettylights-syntax-brackethighlighter-angle: #8b949e;--color-prettylights-syntax-sublimelinter-gutter-mark: #484f58;--color-prettylights-syntax-constant-other-reference-link: #a5d6ff;--color-fg-default: #e6edf3;--color-fg-muted: #7d8590;--color-fg-subtle: #6e7681;--color-canvas-default: #0d1117;--color-canvas-subtle: #161b22;--color-border-default: #30363d;--color-border-muted: #21262d;--color-neutral-muted: rgba(110,118,129,.4);--color-accent-fg: #2f81f7;--color-accent-emphasis: #1f6feb;--color-attention-fg: #d29922;--color-attention-subtle: rgba(187,128,9,.15);--color-danger-fg: #f85149;--color-done-fg: #a371f7}html:not(.dark) .markdown-body{color-scheme:light;--color-prettylights-syntax-comment: #6e7781;--color-prettylights-syntax-constant: #0550ae;--color-prettylights-syntax-entity: #6639ba;--color-prettylights-syntax-storage-modifier-import: #24292f;--color-prettylights-syntax-entity-tag: #116329;--color-prettylights-syntax-keyword: #cf222e;--color-prettylights-syntax-string: #0a3069;--color-prettylights-syntax-variable: #953800;--color-prettylights-syntax-brackethighlighter-unmatched: #82071e;--color-prettylights-syntax-invalid-illegal-text: #f6f8fa;--color-prettylights-syntax-invalid-illegal-bg: #82071e;--color-prettylights-syntax-carriage-return-text: #f6f8fa;--color-prettylights-syntax-carriage-return-bg: #cf222e;--color-prettylights-syntax-string-regexp: #116329;--color-prettylights-syntax-markup-list: #3b2300;--color-prettylights-syntax-markup-heading: #0550ae;--color-prettylights-syntax-markup-italic: #24292f;--color-prettylights-syntax-markup-bold: #24292f;--color-prettylights-syntax-markup-deleted-text: #82071e;--color-prettylights-syntax-markup-deleted-bg: #ffebe9;--color-prettylights-syntax-markup-inserted-text: #116329;--color-prettylights-syntax-markup-inserted-bg: #dafbe1;--color-prettylights-syntax-markup-changed-text: #953800;--color-prettylights-syntax-markup-changed-bg: #ffd8b5;--color-prettylights-syntax-markup-ignored-text: #eaeef2;--color-prettylights-syntax-markup-ignored-bg: #0550ae;--color-prettylights-syntax-meta-diff-range: #8250df;--color-prettylights-syntax-brackethighlighter-angle: #57606a;--color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f;--color-prettylights-syntax-constant-other-reference-link: #0a3069;--color-fg-default: #1F2328;--color-fg-muted: #656d76;--color-fg-subtle: #6e7781;--color-canvas-default: #ffffff;--color-canvas-subtle: #f6f8fa;--color-border-default: #d0d7de;--color-border-muted: hsla(210,18%,87%,1);--color-neutral-muted: rgba(175,184,193,.2);--color-accent-fg: #0969da;--color-accent-emphasis: #0969da;--color-attention-fg: #9a6700;--color-attention-subtle: #fff8c5;--color-danger-fg: #d1242f;--color-done-fg: #8250df}.markdown-body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;margin:0;color:var(--color-fg-default);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body .octicon{display:inline-block;fill:currentColor;vertical-align:text-bottom}.markdown-body h1:hover .anchor .octicon-link:before,.markdown-body h2:hover .anchor .octicon-link:before,.markdown-body h3:hover .anchor .octicon-link:before,.markdown-body h4:hover .anchor .octicon-link:before,.markdown-body h5:hover .anchor .octicon-link:before,.markdown-body h6:hover .anchor .octicon-link:before{width:16px;height:16px;content:" ";display:inline-block;background-color:currentColor;-webkit-mask-image:url("data:image/svg+xml,");mask-image:url("data:image/svg+xml,")}.markdown-body details,.markdown-body figcaption,.markdown-body figure{display:block}.markdown-body summary{display:list-item}.markdown-body [hidden]{display:none!important}.markdown-body a{background-color:transparent;color:var(--color-accent-fg);text-decoration:none}.markdown-body abbr[title]{border-bottom:none;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.markdown-body b,.markdown-body strong{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dfn{font-style:italic}.markdown-body h1{margin:.67em 0;font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:2em;border-bottom:1px solid var(--color-border-muted)}.markdown-body mark{background-color:var(--color-attention-subtle);color:var(--color-fg-default)}.markdown-body small{font-size:90%}.markdown-body sub,.markdown-body sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.markdown-body sub{bottom:-.25em}.markdown-body sup{top:-.5em}.markdown-body img{border-style:none;max-width:100%;box-sizing:content-box;background-color:var(--color-canvas-default)}.markdown-body code,.markdown-body kbd,.markdown-body pre,.markdown-body samp{font-family:monospace;font-size:1em}.markdown-body figure{margin:1em 40px}.markdown-body hr{box-sizing:content-box;overflow:hidden;background:transparent;border-bottom:1px solid var(--color-border-muted);height:.25em;padding:0;margin:24px 0;background-color:var(--color-border-default);border:0}.markdown-body input{font:inherit;margin:0;overflow:visible;font-family:inherit;font-size:inherit;line-height:inherit}.markdown-body [type=button],.markdown-body [type=reset],.markdown-body [type=submit]{-webkit-appearance:button}.markdown-body [type=checkbox],.markdown-body [type=radio]{box-sizing:border-box;padding:0}.markdown-body [type=number]::-webkit-inner-spin-button,.markdown-body [type=number]::-webkit-outer-spin-button{height:auto}.markdown-body [type=search]::-webkit-search-cancel-button,.markdown-body [type=search]::-webkit-search-decoration{-webkit-appearance:none}.markdown-body ::-webkit-input-placeholder{color:inherit;opacity:.54}.markdown-body ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.markdown-body a:hover{text-decoration:underline}.markdown-body ::-moz-placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body ::placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body hr:before{display:table;content:""}.markdown-body hr:after{display:table;clear:both;content:""}.markdown-body table{border-spacing:0;border-collapse:collapse;display:block;width:-moz-max-content;width:max-content;max-width:100%;overflow:auto}.markdown-body td,.markdown-body th{padding:0}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>*:not(summary){display:none!important}.markdown-body a:focus,.markdown-body [role=button]:focus,.markdown-body input[type=radio]:focus,.markdown-body input[type=checkbox]:focus{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:focus:not(:focus-visible),.markdown-body [role=button]:focus:not(:focus-visible),.markdown-body input[type=radio]:focus:not(:focus-visible),.markdown-body input[type=checkbox]:focus:not(:focus-visible){outline:solid 1px transparent}.markdown-body a:focus-visible,.markdown-body [role=button]:focus-visible,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus-visible{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:not([class]):focus,.markdown-body a:not([class]):focus-visible,.markdown-body input[type=radio]:focus,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus,.markdown-body input[type=checkbox]:focus-visible{outline-offset:0}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;line-height:10px;color:var(--color-fg-default);vertical-align:middle;background-color:var(--color-canvas-subtle);border:solid 1px var(--color-neutral-muted);border-bottom-color:var(--color-neutral-muted);border-radius:6px;box-shadow:inset 0 -1px 0 var(--color-neutral-muted)}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:var(--base-text-weight-semibold, 600);line-height:1.25}.markdown-body h2{font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:1.5em;border-bottom:1px solid var(--color-border-muted)}.markdown-body h3{font-weight:var(--base-text-weight-semibold, 600);font-size:1.25em}.markdown-body h4{font-weight:var(--base-text-weight-semibold, 600);font-size:1em}.markdown-body h5{font-weight:var(--base-text-weight-semibold, 600);font-size:.875em}.markdown-body h6{font-weight:var(--base-text-weight-semibold, 600);font-size:.85em;color:var(--color-fg-muted)}.markdown-body p{margin-top:0;margin-bottom:10px}.markdown-body blockquote{margin:0;padding:0 1em;color:var(--color-fg-muted);border-left:.25em solid var(--color-border-default)}.markdown-body ul,.markdown-body ol{margin-top:0;margin-bottom:0;padding-left:2em}.markdown-body ol ol,.markdown-body ul ol{list-style-type:lower-roman}.markdown-body ul ul ol,.markdown-body ul ol ol,.markdown-body ol ul ol,.markdown-body ol ol ol{list-style-type:lower-alpha}.markdown-body dd{margin-left:0}.markdown-body tt,.markdown-body code,.markdown-body samp{font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px}.markdown-body pre{margin-top:0;margin-bottom:0;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px;word-wrap:normal}.markdown-body .octicon{display:inline-block;overflow:visible!important;vertical-align:text-bottom;fill:currentColor}.markdown-body input::-webkit-outer-spin-button,.markdown-body input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none;appearance:none}.markdown-body .color-fg-accent{color:var(--color-accent-fg)!important}.markdown-body .color-fg-attention{color:var(--color-attention-fg)!important}.markdown-body .color-fg-done{color:var(--color-done-fg)!important}.markdown-body .flex-items-center{align-items:center!important}.markdown-body .mb-1{margin-bottom:var(--base-size-4, 4px)!important}.markdown-body .text-semibold{font-weight:var(--base-text-weight-medium, 500)!important}.markdown-body .d-inline-flex{display:inline-flex!important}.markdown-body:before{display:table;content:""}.markdown-body:after{display:table;clear:both;content:""}.markdown-body>*:first-child{margin-top:0!important}.markdown-body>*:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:var(--color-danger-fg)}.markdown-body .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.markdown-body .anchor:focus{outline:none}.markdown-body p,.markdown-body blockquote,.markdown-body ul,.markdown-body ol,.markdown-body dl,.markdown-body table,.markdown-body pre,.markdown-body details{margin-top:0;margin-bottom:16px}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:var(--color-fg-default);vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 tt,.markdown-body h1 code,.markdown-body h2 tt,.markdown-body h2 code,.markdown-body h3 tt,.markdown-body h3 code,.markdown-body h4 tt,.markdown-body h4 code,.markdown-body h5 tt,.markdown-body h5 code,.markdown-body h6 tt,.markdown-body h6 code{padding:0 .2em;font-size:inherit}.markdown-body summary h1,.markdown-body summary h2,.markdown-body summary h3,.markdown-body summary h4,.markdown-body summary h5,.markdown-body summary h6{display:inline-block}.markdown-body summary h1 .anchor,.markdown-body summary h2 .anchor,.markdown-body summary h3 .anchor,.markdown-body summary h4 .anchor,.markdown-body summary h5 .anchor,.markdown-body summary h6 .anchor{margin-left:-40px}.markdown-body summary h1,.markdown-body summary h2{padding-bottom:0;border-bottom:0}.markdown-body ul.no-list,.markdown-body ol.no-list{padding:0;list-style-type:none}.markdown-body ol[type="a s"]{list-style-type:lower-alpha}.markdown-body ol[type="A s"]{list-style-type:upper-alpha}.markdown-body ol[type="i s"]{list-style-type:lower-roman}.markdown-body ol[type="I s"]{list-style-type:upper-roman}.markdown-body ol[type="1"]{list-style-type:decimal}.markdown-body div>ol:not([type]){list-style-type:decimal}.markdown-body ul ul,.markdown-body ul ol,.markdown-body ol ol,.markdown-body ol ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{margin-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table th{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body table th,.markdown-body table td{padding:6px 13px;border:1px solid var(--color-border-default)}.markdown-body table td>:last-child{margin-bottom:0}.markdown-body table tr{background-color:var(--color-canvas-default);border-top:1px solid var(--color-border-muted)}.markdown-body table tr:nth-child(2n){background-color:var(--color-canvas-subtle)}.markdown-body table img{background-color:transparent}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{max-width:none;vertical-align:text-top;background-color:transparent}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid var(--color-border-default)}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:var(--color-fg-default)}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:.2em .4em;margin:0;font-size:85%;white-space:break-spaces;background-color:var(--color-neutral-muted);border-radius:6px}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body samp{font-size:85%}.markdown-body pre code{font-size:100%}.markdown-body pre>code{padding:0;margin:0;word-break:normal;white-space:pre;background:transparent;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;color:var(--color-fg-default);background-color:var(--color-canvas-subtle);border-radius:6px}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:12px;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-num{padding:10px 8px 9px;text-align:right;background:var(--color-canvas-default);border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:var(--base-text-weight-semibold, 600);background:var(--color-canvas-subtle);border-top:0}.markdown-body [data-footnote-ref]:before{content:"["}.markdown-body [data-footnote-ref]:after{content:"]"}.markdown-body .footnotes{font-size:12px;color:var(--color-fg-muted);border-top:1px solid var(--color-border-default)}.markdown-body .footnotes ol{padding-left:16px}.markdown-body .footnotes ol ul{display:inline-block;padding-left:16px;margin-top:16px}.markdown-body .footnotes li{position:relative}.markdown-body .footnotes li:target:before{position:absolute;inset:-8px -8px -8px -24px;pointer-events:none;content:"";border:2px solid var(--color-accent-emphasis);border-radius:6px}.markdown-body .footnotes li:target{color:var(--color-fg-default)}.markdown-body .footnotes .data-footnote-backref g-emoji{font-family:monospace}.markdown-body .pl-c{color:var(--color-prettylights-syntax-comment)}.markdown-body .pl-c1,.markdown-body .pl-s .pl-v{color:var(--color-prettylights-syntax-constant)}.markdown-body .pl-e,.markdown-body .pl-en{color:var(--color-prettylights-syntax-entity)}.markdown-body .pl-smi,.markdown-body .pl-s .pl-s1{color:var(--color-prettylights-syntax-storage-modifier-import)}.markdown-body .pl-ent{color:var(--color-prettylights-syntax-entity-tag)}.markdown-body .pl-k{color:var(--color-prettylights-syntax-keyword)}.markdown-body .pl-s,.markdown-body .pl-pds,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sre,.markdown-body .pl-sr .pl-sra{color:var(--color-prettylights-syntax-string)}.markdown-body .pl-v,.markdown-body .pl-smw{color:var(--color-prettylights-syntax-variable)}.markdown-body .pl-bu{color:var(--color-prettylights-syntax-brackethighlighter-unmatched)}.markdown-body .pl-ii{color:var(--color-prettylights-syntax-invalid-illegal-text);background-color:var(--color-prettylights-syntax-invalid-illegal-bg)}.markdown-body .pl-c2{color:var(--color-prettylights-syntax-carriage-return-text);background-color:var(--color-prettylights-syntax-carriage-return-bg)}.markdown-body .pl-sr .pl-cce{font-weight:700;color:var(--color-prettylights-syntax-string-regexp)}.markdown-body .pl-ml{color:var(--color-prettylights-syntax-markup-list)}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{font-weight:700;color:var(--color-prettylights-syntax-markup-heading)}.markdown-body .pl-mi{font-style:italic;color:var(--color-prettylights-syntax-markup-italic)}.markdown-body .pl-mb{font-weight:700;color:var(--color-prettylights-syntax-markup-bold)}.markdown-body .pl-md{color:var(--color-prettylights-syntax-markup-deleted-text);background-color:var(--color-prettylights-syntax-markup-deleted-bg)}.markdown-body .pl-mi1{color:var(--color-prettylights-syntax-markup-inserted-text);background-color:var(--color-prettylights-syntax-markup-inserted-bg)}.markdown-body .pl-mc{color:var(--color-prettylights-syntax-markup-changed-text);background-color:var(--color-prettylights-syntax-markup-changed-bg)}.markdown-body .pl-mi2{color:var(--color-prettylights-syntax-markup-ignored-text);background-color:var(--color-prettylights-syntax-markup-ignored-bg)}.markdown-body .pl-mdr{font-weight:700;color:var(--color-prettylights-syntax-meta-diff-range)}.markdown-body .pl-ba{color:var(--color-prettylights-syntax-brackethighlighter-angle)}.markdown-body .pl-sg{color:var(--color-prettylights-syntax-sublimelinter-gutter-mark)}.markdown-body .pl-corl{text-decoration:underline;color:var(--color-prettylights-syntax-constant-other-reference-link)}.markdown-body g-emoji{display:inline-block;min-width:1ch;font-family:"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol;font-size:1em;font-style:normal!important;font-weight:var(--base-text-weight-normal, 400);line-height:1;vertical-align:-.075em}.markdown-body g-emoji img{width:1em;height:1em}.markdown-body .task-list-item{list-style-type:none}.markdown-body .task-list-item label{font-weight:var(--base-text-weight-normal, 400)}.markdown-body .task-list-item.enabled label{cursor:pointer}.markdown-body .task-list-item+.task-list-item{margin-top:4px}.markdown-body .task-list-item .handle{display:none}.markdown-body .task-list-item-checkbox{margin:0 .2em .25em -1.4em;vertical-align:middle}.markdown-body .contains-task-list:dir(rtl) .task-list-item-checkbox{margin:0 -1.6em .25em .2em}.markdown-body .contains-task-list{position:relative}.markdown-body .contains-task-list:hover .task-list-item-convert-container,.markdown-body .contains-task-list:focus-within .task-list-item-convert-container{display:block;width:auto;height:24px;overflow:visible;clip:auto}.markdown-body .QueryBuilder .qb-entity{color:var(--color-prettylights-syntax-entity)}.markdown-body .QueryBuilder .qb-constant{color:var(--color-prettylights-syntax-constant)}.markdown-body ::-webkit-calendar-picker-indicator{filter:invert(50%)}.markdown-body .markdown-alert{padding:0 1em;margin-bottom:16px;color:inherit;border-left:.25em solid var(--color-border-default)}.markdown-body .markdown-alert>:first-child{margin-top:0}.markdown-body .markdown-alert>:last-child{margin-bottom:0}.markdown-body .markdown-alert.markdown-alert-note{border-left-color:var(--color-accent-fg)}.markdown-body .markdown-alert.markdown-alert-important{border-left-color:var(--color-done-fg)}.markdown-body .markdown-alert.markdown-alert-warning{border-left-color:var(--color-attention-fg)} diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 21c428a..f5e6ed3 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,21 +1,21 @@ -import{r as m,j as e,t as io,c as oo,I as sa,a as vt,S as Fn,u as Ws,b as co,d as Pn,R as Pr,e as Lr,f as mo,F as uo,C as xo,L as Rr,T as Er,g as Ir,h as ho,i as go,k as po,l as fo,m as $,n as Vr,o as Mr,z as h,p as V,q as Ce,s as Te,v as re,w as As,x as Ie,y as Or,A as jo,O as Ln,B as vo,D as bo,E as yo,G as _o,H as No,J as wo,Q as Co,K as So,M as ka,N as ko,P as To,U as Do,V as Fo,W as Po,X as Lo,Y as zr,Z as $r,_ as za,$ as $a,a0 as Rn,a1 as os,a2 as Aa,a3 as qa,a4 as Ar,a5 as qr,a6 as Ur,a7 as Hr,a8 as Kr,a9 as Ro,aa as Br,ab as Gr,ac as Wr,ad as Yr,ae as bt,af as Jr,ag as Eo,ah as Qr,ai as Xr,aj as Io,ak as Vo,al as Mo,am as Oo,an as zo,ao as $o,ap as Ao,aq as qo,ar as Uo,as as Ho,at as Zr,au as Ko,av as Bo,aw as Bs,ax as el,ay as Go,az as Wo,aA as sl,aB as En,aC as Yo,aD as Jo,aE as nr,aF as Qo,aG as tl,aH as Xo,aI as al,aJ as Zo,aK as ec,aL as sc,aM as tc,aN as ac,aO as nc,aP as rc,aQ as nl,aR as lc,aS as ic,aT as oc,aU as ps,aV as cc,aW as In,aX as dc,aY as mc,aZ as rl,a_ as ll,a$ as il,b0 as uc,b1 as xc,b2 as hc,b3 as ol,b4 as gc,b5 as Vn,b6 as cl,b7 as pc,b8 as dl,b9 as fc,ba as ml,bb as jc,bc as ul,bd as xl,be as vc,bf as bc,bg as hl,bh as yc,bi as gl,bj as _c,bk as pl,bl as fl,bm as jl,bn as Nc,bo as vl,bp as wc,bq as Cc,br as zs,bs as Ee,bt as Ss,bu as Sc,bv as kc,bw as Tc,bx as Dc,by as Fc,bz as Pc,bA as rr,bB as lr,bC as Lc,bD as Rc,bE as Mn,bF as Ec,bG as Ic,bH as Ta,bI as Rt,bJ as ta,bK as Vc,bL as bl,bM as Mc,bN as Oc,bO as yl,bP as zc,bQ as $c,bR as ir,bS as yn,bT as _n,bU as Ac,bV as qc,bW as _l,bX as Uc,bY as Hc,bZ as Kc,b_ as Bc,b$ as Da,c0 as Nn,c1 as Ye,c2 as Fa,c3 as Gc,c4 as cn,c5 as Wc,c6 as wn,c7 as xs,c8 as Wt,c9 as Yt,ca as Cn,cb as Nl,cc as Je,cd as ts,ce as wl,cf as Cl,cg as Yc,ch as Jc,ci as Qc,cj as Xc,ck as Zc,cl as Sl,cm as ed,cn as sd,co as td,cp as Be,cq as or,cr as ad,cs as kl,ct as Tl,cu as Dl,cv as Fl,cw as Pl,cx as Ll,cy as nd,cz as rd,cA as ld,cB as Ua,cC as rt,cD as fs,cE as js,cF as id,cG as od,cH as cd,cI as dd,cJ as md,cK as ud,cL as Pa,cM as xd,cN as hd,cO as Sn,cP as On,cQ as zn,cR as gd,cS as Ls,cT as Rs,cU as Ha,cV as pd,cW as fd,cX as _a,cY as La,cZ as jd,c_ as cr,c$ as Rl,d0 as dr,d1 as Ra,d2 as vd,d3 as $n,d4 as bd,d5 as yd,d6 as _d,d7 as El,d8 as Nd,d9 as wd,da as Il,db as kn,dc as Vl,dd as Cd,de as aa,df as Ml,dg as Sd,dh as kd,di as Td,dj as Ol,dk as Dd,dl as zl,dm as Jt,dn as An,dp as Fd,dq as mr,dr as $l,ds as Pd,dt as ur,du as Ld,dv as Rd}from"./vendor.js";import"./index.js";var hp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ed(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 Id={theme:"system",setTheme:()=>null},Al=m.createContext(Id);function Vd({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,o]=m.useState(()=>localStorage.getItem(t)||n);m.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(x);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),o(d)}};return e.jsx(Al.Provider,{...r,value:l,children:s})}const Md=()=>{const s=m.useContext(Al);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Od=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),zd=function(s,n){return new URL(s,n).href},xr={},we=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]"),x=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(u=>{if(u=zd(u,r),u in xr)return;xr[u]=!0;const i=u.endsWith(".css"),c=i?'[rel="stylesheet"]':"";if(!!r)for(let T=l.length-1;T>=0;T--){const C=l[T];if(C.href===u&&(!i||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${c}`))return;const F=document.createElement("link");if(F.rel=i?"stylesheet":Od,i||(F.as="script"),F.crossOrigin="",F.href=u,x&&F.setAttribute("nonce",x),document.head.appendChild(F),i)return new Promise((T,C)=>{F.addEventListener("load",T),F.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(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"&&o(d.reason);return n().catch(o)})};function _(...s){return io(oo(s))}const Mt=vt("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"}}),L=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:o,loading:l=!1,leftSection:d,rightSection:x,...u},i)=>{const c=r?Fn:"button";return e.jsxs(c,{className:_(Mt({variant:n,size:t,className:s})),disabled:l||o,ref:i,...u,children:[(d&&l||!d&&!x&&l)&&e.jsx(sa,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&x&&e.jsx("div",{className:"ml-2",children:x}),x&&l&&e.jsx(sa,{className:"ml-2 h-4 w-4 animate-spin"})]})});L.displayName="Button";function wt({className:s,minimal:n=!1}){const t=Ws(),r=co(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:_("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(L,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(L,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function hr(){const s=Ws();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(L,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(L,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function $d(){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(L,{variant:"outline",children:"Learn more"})})]})})}function Ad(s){return typeof s>"u"}function qd(s){return s===null}function Ud(s){return qd(s)||Ad(s)}class Hd{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:o,time:l,expire:d}=a;return Ud(d)||d>new Date().getTime()?{value:o,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 ql({prefixKey:s="",storage:n=sessionStorage}){return new Hd({prefixKey:s,storage:n})}const Ul="Xboard_",Kd=function(s={}){return ql({prefixKey:s.prefixKey||"",storage:localStorage})},Bd=function(s={}){return ql({prefixKey:s.prefixKey||"",storage:sessionStorage})},qn=Kd({prefixKey:Ul});Bd({prefixKey:Ul});const Hl="access_token";function na(){return qn.get(Hl)}function Kl(){qn.remove(Hl)}const gr=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Gd({children:s}){const n=Ws(),t=Pn(),r=na();return m.useEffect(()=>{if(!r.value&&!gr.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),gr.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const Re=m.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(Pr,{ref:a,decorative:t,orientation:n,className:_("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));Re.displayName=Pr.displayName;const Wd=vt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Xe=m.forwardRef(({className:s,...n},t)=>e.jsx(Lr,{ref:t,className:_(Wd(),s),...n}));Xe.displayName=Lr.displayName;const De=uo,Bl=m.createContext({}),j=({...s})=>e.jsx(Bl.Provider,{value:{name:s.name},children:e.jsx(xo,{...s})}),Ka=()=>{const s=m.useContext(Bl),n=m.useContext(Gl),{getFieldState:t,formState:r}=mo(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:o}=n;return{id:o,name:s.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},Gl=m.createContext({}),f=m.forwardRef(({className:s,...n},t)=>{const r=m.useId();return e.jsx(Gl.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:_("space-y-2",s),...n})})});f.displayName="FormItem";const v=m.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Ka();return e.jsx(Xe,{ref:t,className:_(r&&"text-destructive",s),htmlFor:a,...n})});v.displayName="FormLabel";const b=m.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:o}=Ka();return e.jsx(Fn,{ref:n,id:r,"aria-describedby":t?`${a} ${o}`:`${a}`,"aria-invalid":!!t,...s})});b.displayName="FormControl";const A=m.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Ka();return e.jsx("p",{ref:t,id:r,className:_("text-[0.8rem] text-muted-foreground",s),...n})});A.displayName="FormDescription";const R=m.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:o}=Ka(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:o,className:_("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});R.displayName="FormMessage";const yt=ho,lt=m.forwardRef(({className:s,...n},t)=>e.jsx(Rr,{ref:t,className:_("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));lt.displayName=Rr.displayName;const Ge=m.forwardRef(({className:s,...n},t)=>e.jsx(Er,{ref:t,className:_("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=Er.displayName;const ys=m.forwardRef(({className:s,...n},t)=>e.jsx(Ir,{ref:t,className:_("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ys.displayName=Ir.displayName;function ne(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),go(s).format(n))}function Yd(s=void 0,n="YYYY-MM-DD"){return ne(s,n)}function pr(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,o=>o.includes(".")?".00":o);return n?`¥${a}`:a}function Et(s){return new Promise(n=>{try{const t=document.createElement("button");t.style.position="fixed",t.style.left="-9999px",t.style.opacity="0",t.setAttribute("data-clipboard-text",s),document.body.appendChild(t);const r=new po(t);r.on("success",()=>{r.destroy(),document.body.removeChild(t),n(!0)}),r.on("error",a=>{console.error("Clipboard.js failed:",a),r.destroy(),document.body.removeChild(t),n(!1)}),t.click()}catch(t){console.error("copyToClipboard failed:",t),n(!1)}})}function Le(s){if(s==null||s<=0)return"0 B";const n=1024,t=["B","KB","MB","GB","TB"];let r=Math.floor(Math.log(s)/Math.log(n));return r<0?r=0:r>=t.length&&(r=t.length-1),`${parseFloat((s/Math.pow(n,r)).toFixed(2))} ${t[r]}`}const fr="i18nextLng";function Jd(){return console.log(localStorage.getItem(fr)),localStorage.getItem(fr)}function Wl(){Kl();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 Qd=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Xd(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const Ft=fo.create({baseURL:Xd(),timeout:12e3,headers:{"Content-Type":"application/json"}});Ft.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=na();if(!Qd.includes(s.url?.split("?")[0]||"")){if(!n.value)return Wl(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Jd()||"zh-CN",s},s=>Promise.reject(s));Ft.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)&&Wl(),$.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const M={get:(s,n)=>Ft.get(s,n),post:(s,n,t)=>Ft.post(s,n,t),put:(s,n,t)=>Ft.put(s,n,t),delete:(s,n)=>Ft.delete(s,n)},Zd="access_token";function em(s){qn.set(Zd,s)}const xt=window?.settings?.secure_path,Ea={getStats:()=>M.get(xt+"/monitor/api/stats"),getOverride:()=>M.get(xt+"/stat/getOverride"),getOrderStat:s=>M.get(xt+"/stat/getOrder",{params:s}),getStatsData:()=>M.get(xt+"/stat/getStats"),getNodeTrafficData:s=>M.get(xt+"/stat/getTrafficRank",{params:s}),getServerLastRank:()=>M.get(xt+"/stat/getServerLastRank"),getServerYesterdayRank:()=>M.get(xt+"/stat/getServerYesterdayRank")},zt=window?.settings?.secure_path,Qt={getList:()=>M.get(zt+"/theme/getThemes"),getConfig:s=>M.post(zt+"/theme/getThemeConfig",{name:s}),updateConfig:(s,n)=>M.post(zt+"/theme/saveThemeConfig",{name:s,config:n}),upload:s=>{const n=new FormData;return n.append("file",s),M.post(zt+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},drop:s=>M.post(zt+"/theme/delete",{name:s})},Ct=window?.settings?.secure_path,pt={getList:()=>M.get(Ct+"/server/manage/getNodes"),save:s=>M.post(Ct+"/server/manage/save",s),drop:s=>M.post(Ct+"/server/manage/drop",s),copy:s=>M.post(Ct+"/server/manage/copy",s),update:s=>M.post(Ct+"/server/manage/update",s),sort:s=>M.post(Ct+"/server/manage/sort",s)},dn=window?.settings?.secure_path,_t={getList:()=>M.get(dn+"/server/group/fetch"),save:s=>M.post(dn+"/server/group/save",s),drop:s=>M.post(dn+"/server/group/drop",s)},mn=window?.settings?.secure_path,Ba={getList:()=>M.get(mn+"/server/route/fetch"),save:s=>M.post(mn+"/server/route/save",s),drop:s=>M.post(mn+"/server/route/drop",s)},ht=window?.settings?.secure_path,ft={getList:()=>M.get(ht+"/payment/fetch"),getMethodList:()=>M.get(ht+"/payment/getPaymentMethods"),getMethodForm:s=>M.post(ht+"/payment/getPaymentForm",s),save:s=>M.post(ht+"/payment/save",s),drop:s=>M.post(ht+"/payment/drop",s),updateStatus:s=>M.post(ht+"/payment/show",s),sort:s=>M.post(ht+"/payment/sort",s)},$t=window?.settings?.secure_path,ra={getList:()=>M.get(`${$t}/notice/fetch`),save:s=>M.post(`${$t}/notice/save`,s),drop:s=>M.post(`${$t}/notice/drop`,{id:s}),updateStatus:s=>M.post(`${$t}/notice/show`,{id:s}),sort:s=>M.post(`${$t}/notice/sort`,{ids:s})},St=window?.settings?.secure_path,It={getList:()=>M.get(St+"/knowledge/fetch"),getInfo:s=>M.get(St+"/knowledge/fetch?id="+s),save:s=>M.post(St+"/knowledge/save",s),drop:s=>M.post(St+"/knowledge/drop",s),updateStatus:s=>M.post(St+"/knowledge/show",s),sort:s=>M.post(St+"/knowledge/sort",s)},At=window?.settings?.secure_path,_s={getList:()=>M.get(At+"/plan/fetch"),save:s=>M.post(At+"/plan/save",s),update:s=>M.post(At+"/plan/update",s),drop:s=>M.post(At+"/plan/drop",s),sort:s=>M.post(At+"/plan/sort",{ids:s})},kt=window?.settings?.secure_path,gt={getList:s=>M.post(kt+"/order/fetch",s),getInfo:s=>M.post(kt+"/order/detail",s),markPaid:s=>M.post(kt+"/order/paid",s),makeCancel:s=>M.post(kt+"/order/cancel",s),update:s=>M.post(kt+"/order/update",s),assign:s=>M.post(kt+"/order/assign",s)},Ds=window?.settings?.secure_path,Ps={getTemplates:s=>M.post(Ds+"/gift-card/templates",s),createTemplate:s=>M.post(Ds+"/gift-card/create-template",s),updateTemplate:s=>M.post(Ds+"/gift-card/update-template",s),deleteTemplate:s=>M.post(Ds+"/gift-card/delete-template",s),getCodes:s=>M.post(Ds+"/gift-card/codes",s),generateCodes:s=>s.download_csv?M.post(Ds+"/gift-card/generate-codes",s,{responseType:"blob"}):M.post(Ds+"/gift-card/generate-codes",s),toggleCode:s=>M.post(Ds+"/gift-card/toggle-code",s),exportCodes:s=>M.get(Ds+`/gift-card/export-codes?batch_id=${s}`,{responseType:"blob"}),getUsages:s=>M.post(Ds+"/gift-card/usages",s),getStatistics:s=>M.post(Ds+"/gift-card/statistics",s),getTypes:()=>M.get(Ds+"/gift-card/types")},xa=window?.settings?.secure_path,Ia={getList:s=>M.post(xa+"/coupon/fetch",s),save:s=>M.post(xa+"/coupon/generate",s),drop:s=>M.post(xa+"/coupon/drop",s),update:s=>M.post(xa+"/coupon/update",s)},vs=window?.settings?.secure_path,Us={getList:s=>M.post(`${vs}/user/fetch`,s),update:s=>M.post(`${vs}/user/update`,s),resetSecret:s=>M.post(`${vs}/user/resetSecret`,{id:s}),generate:s=>s.download_csv?M.post(`${vs}/user/generate`,s,{responseType:"blob"}):M.post(`${vs}/user/generate`,s),getStats:s=>M.post(`${vs}/stat/getStatUser`,s),destroy:s=>M.post(`${vs}/user/destroy`,{id:s}),sendMail:s=>M.post(`${vs}/user/sendMail`,s),dumpCSV:s=>M.post(`${vs}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>M.post(`${vs}/user/ban`,s)},la={getLogs:s=>M.get(`${vs}/traffic-reset/logs`,{params:s}),getStats:s=>M.get(`${vs}/traffic-reset/stats`,{params:s}),resetUser:s=>M.post(`${vs}/traffic-reset/reset-user`,s),getUserHistory:(s,n)=>M.get(`${vs}/traffic-reset/user/${s}/history`,{params:n})},ha=window?.settings?.secure_path,Pt={getList:s=>M.post(ha+"/ticket/fetch",s),getInfo:s=>M.get(ha+"/ticket/fetch?id= "+s),reply:s=>M.post(ha+"/ticket/reply",s),close:s=>M.post(ha+"/ticket/close",{id:s})},ls=window?.settings?.secure_path,ye={getSettings:(s="")=>M.get(ls+"/config/fetch?key="+s),saveSettings:s=>M.post(ls+"/config/save",s),getEmailTemplate:()=>M.get(ls+"/config/getEmailTemplate"),sendTestMail:()=>M.post(ls+"/config/testSendMail"),setTelegramWebhook:()=>M.post(ls+"/config/setTelegramWebhook"),updateSystemConfig:s=>M.post(ls+"/config/save",s),getSystemStatus:()=>M.get(`${ls}/system/getSystemStatus`),getQueueStats:()=>M.get(`${ls}/system/getQueueStats`),getQueueWorkload:()=>M.get(`${ls}/system/getQueueWorkload`),getQueueMasters:()=>M.get(`${ls}/system/getQueueMasters`),getHorizonFailedJobs:s=>M.get(`${ls}/system/getHorizonFailedJobs`,{params:s}),getSystemLog:s=>M.get(`${ls}/system/getSystemLog`,{params:s}),getLogFiles:()=>M.get(`${ls}/log/files`),getLogContent:s=>M.get(`${ls}/log/fetch`,{params:s}),getLogClearStats:s=>M.get(`${ls}/system/getLogClearStats`,{params:s}),clearSystemLog:s=>M.post(`${ls}/system/clearSystemLog`,s)},Ms=window?.settings?.secure_path,Os={getPluginTypes:()=>M.get(`${Ms}/plugin/types`),getPluginList:s=>{const n=s?{type:s}:{};return M.get(`${Ms}/plugin/getPlugins`,{params:n})},uploadPlugin:s=>{const n=new FormData;return n.append("file",s),M.post(`${Ms}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>M.post(`${Ms}/plugin/delete`,{code:s}),installPlugin:s=>M.post(`${Ms}/plugin/install`,{code:s}),uninstallPlugin:s=>M.post(`${Ms}/plugin/uninstall`,{code:s}),enablePlugin:s=>M.post(`${Ms}/plugin/enable`,{code:s}),disablePlugin:s=>M.post(`${Ms}/plugin/disable`,{code:s}),getPluginConfig:s=>M.get(`${Ms}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>M.post(`${Ms}/plugin/config`,{code:s,config:n}),upgradePlugin:s=>M.post(`${Ms}/plugin/upgrade`,{code:s})};window?.settings?.secure_path;Vr.config({monaco:Mr});const sm=h.object({subscribe_template_singbox:h.string().optional().default(""),subscribe_template_clash:h.string().optional().default(""),subscribe_template_clashmeta:h.string().optional().default(""),subscribe_template_stash:h.string().optional().default(""),subscribe_template_surge:h.string().optional().default(""),subscribe_template_surfboard:h.string().optional().default("")}),jr=[{key:"singbox",label:"Sing-box",language:"json"},{key:"clash",label:"Clash",language:"yaml"},{key:"clashmeta",label:"Clash Meta",language:"yaml"},{key:"stash",label:"Stash",language:"yaml"},{key:"surge",label:"Surge",language:"ini"},{key:"surfboard",label:"Surfboard",language:"ini"}],vr={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function tm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),[a,o]=m.useState("singbox"),l=Ce({resolver:Te(sm),defaultValues:vr,mode:"onChange"}),{data:d,isLoading:x}=re({queryKey:["settings","client"],queryFn:()=>ye.getSettings("subscribe_template")}),{mutateAsync:u}=As({mutationFn:ye.saveSettings,onSuccess:()=>{$.success(s("common.autoSaved"))},onError:F=>{console.error("保存失败:",F),$.error(s("common.saveFailed"))}});m.useEffect(()=>{if(d?.data?.subscribe_template){const F=d.data.subscribe_template;Object.entries(F).forEach(([T,C])=>{if(T in vr){const P=typeof C=="string"?C:"";l.setValue(T,P)}}),r.current=l.getValues()}},[d,l]);const i=m.useCallback(Ie.debounce(async F=>{if(!r.current||!Ie.isEqual(F,r.current)){t(!0);try{await u(F),r.current=F}catch(T){console.error("保存设置失败:",T)}finally{t(!1)}}},1500),[u]),c=m.useCallback(()=>{const F=l.getValues();i(F)},[l,i]),p=m.useCallback((F,T)=>e.jsx(j,{control:l.control,name:F,render:({field:C})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s(`subscribe_template.${F.replace("subscribe_template_","")}.title`)}),e.jsx(b,{children:e.jsx(Or,{height:"500px",defaultLanguage:T,value:C.value||"",onChange:P=>{C.onChange(P||""),c()},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})}),e.jsx(A,{children:s(`subscribe_template.${F.replace("subscribe_template_","")}.description`)}),e.jsx(R,{})]})}),[l.control,s,c]);return x?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")})}):e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(yt,{value:a,onValueChange:o,className:"w-full",children:[e.jsx(lt,{className:"",children:jr.map(({key:F,label:T})=>e.jsx(Ge,{value:F,className:"text-xs",children:T},F))}),jr.map(({key:F,language:T})=>e.jsx(ys,{value:F,className:"mt-4",children:p(`subscribe_template_${F}`,T)},F))]}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500"}),s("common.saving")]})]})})}function am(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(Re,{}),e.jsx(tm,{})]})}const nm=()=>e.jsx(Gd,{children:e.jsx(Ln,{})}),rm=jo([{path:"/sign-in",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ym);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(nm,{}),children:[{path:"/",lazy:async()=>({Component:(await we(()=>Promise.resolve().then(()=>Fm),void 0,import.meta.url)).default}),errorElement:e.jsx(wt,{}),children:[{index:!0,lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Qm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(wt,{}),children:[{path:"system",lazy:async()=>({Component:(await we(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 we(async()=>{const{default:s}=await Promise.resolve().then(()=>ru);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>du);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>gu);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>bu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Cu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Fu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Iu);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>$u);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Ku);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(am,{})}]},{path:"payment",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>sx);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>rx);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ux);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>bx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(wt,{}),children:[{path:"manage",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Jx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>sh);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ih);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(wt,{}),children:[{path:"plan",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ph);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Fh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>$h);return{default:s}},void 0,import.meta.url)).default})},{path:"gift-card",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>lg);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(wt,{}),children:[{path:"manage",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>zg);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>np);return{default:s}},void 0,import.meta.url)).default})},{path:"traffic-reset-logs",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>dp);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:wt},{path:"/404",Component:hr},{path:"/503",Component:$d},{path:"*",Component:hr}]);function lm(){return M.get("/user/info")}const un={token:na()?.value||"",userInfo:null,isLoggedIn:!!na()?.value,loading:!1,error:null},Xt=vo("user/fetchUserInfo",async()=>(await lm()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),Yl=bo({name:"user",initialState:un,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>un},extraReducers:s=>{s.addCase(Xt.pending,n=>{n.loading=!0,n.error=null}).addCase(Xt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(Xt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return un})}}),{setToken:im,resetUserState:om}=Yl.actions,cm=s=>s.user.userInfo,dm=Yl.reducer,Jl=yo({reducer:{user:dm}});na()?.value&&Jl.dispatch(Xt());_o.use(No).use(wo).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 mm=new Co;So.createRoot(document.getElementById("root")).render(e.jsx(ka.StrictMode,{children:e.jsx(ko,{client:mm,children:e.jsx(To,{store:Jl,children:e.jsxs(Vd,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Do,{router:rm}),e.jsx(Fo,{richColors:!0,position:"top-right"})]})})})}));const ke=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("rounded-xl border bg-card text-card-foreground shadow",s),...n}));ke.displayName="Card";const Fe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("flex flex-col space-y-1.5 p-6",s),...n}));Fe.displayName="CardHeader";const Me=m.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:_("font-semibold leading-none tracking-tight",s),...n}));Me.displayName="CardTitle";const et=m.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:_("text-sm text-muted-foreground",s),...n}));et.displayName="CardDescription";const Pe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("p-6 pt-0",s),...n}));Pe.displayName="CardContent";const um=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("flex items-center p-6 pt-0",s),...n}));um.displayName="CardFooter";const D=m.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:_("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));D.displayName="Input";const Ql=m.forwardRef(({className:s,...n},t)=>{const[r,a]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:_("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(L,{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(o=>!o),children:r?e.jsx(Po,{size:18}):e.jsx(Lo,{size:18})})]})});Ql.displayName="PasswordInput";const xm=s=>M.post("/passport/auth/login",s);function hm({className:s,onForgotPassword:n,...t}){const r=Ws(),a=zr(),{t:o}=V("auth"),l=h.object({email:h.string().min(1,{message:o("signIn.validation.emailRequired")}),password:h.string().min(1,{message:o("signIn.validation.passwordRequired")}).min(7,{message:o("signIn.validation.passwordLength")})}),d=Ce({resolver:Te(l),defaultValues:{email:"",password:""}});async function x(u){try{const{data:i}=await xm(u);em(i.auth_data),a(im(i.auth_data)),await a(Xt()).unwrap(),r("/")}catch(i){console.error("Login failed:",i),i.response?.data?.message&&d.setError("root",{message:i.response.data.message})}}return e.jsx("div",{className:_("grid gap-6",s),...t,children:e.jsx(De,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(x),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(j,{control:d.control,name:"email",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:o("signIn.email")}),e.jsx(b,{children:e.jsx(D,{placeholder:o("signIn.emailPlaceholder"),autoComplete:"email",...u})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"password",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:o("signIn.password")}),e.jsx(b,{children:e.jsx(Ql,{placeholder:o("signIn.passwordPlaceholder"),autoComplete:"current-password",...u})}),e.jsx(R,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(L,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:o("signIn.forgotPassword")})}),e.jsx(L,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:o("signIn.submit")})]})})})})}const de=$r,cs=Ar,gm=qr,st=Rn,Xl=m.forwardRef(({className:s,...n},t)=>e.jsx(za,{ref:t,className:_("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}));Xl.displayName=za.displayName;const oe=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(gm,{children:[e.jsx(Xl,{}),e.jsxs($a,{ref:r,className:_("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(Rn,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));oe.displayName=$a.displayName;const he=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});he.displayName="DialogHeader";const Oe=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Oe.displayName="DialogFooter";const me=m.forwardRef(({className:s,...n},t)=>e.jsx(Aa,{ref:t,className:_("text-lg font-semibold leading-none tracking-tight",s),...n}));me.displayName=Aa.displayName;const qe=m.forwardRef(({className:s,...n},t)=>e.jsx(qa,{ref:t,className:_("text-sm text-muted-foreground",s),...n}));qe.displayName=qa.displayName;const Vt=vt("inline-flex items-center justify-center gap-2 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"}}),G=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},o)=>{const l=r?Fn:"button";return e.jsx(l,{className:_(Vt({variant:n,size:t,className:s})),ref:o,...a})});G.displayName="Button";const Hs=Io,Gs=Vo,pm=Mo,fm=m.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Ur,{ref:a,className:_("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(Hr,{className:"ml-auto h-4 w-4"})]}));fm.displayName=Ur.displayName;const jm=m.forwardRef(({className:s,...n},t)=>e.jsx(Kr,{ref:t,className:_("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}));jm.displayName=Kr.displayName;const qs=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Ro,{children:e.jsx(Br,{ref:r,sideOffset:n,className:_("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})}));qs.displayName=Br.displayName;const Se=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Gr,{ref:r,className:_("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}));Se.displayName=Gr.displayName;const Zl=m.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Wr,{ref:a,className:_("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(Yr,{children:e.jsx(bt,{className:"h-4 w-4"})})}),n]}));Zl.displayName=Wr.displayName;const vm=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Jr,{ref:r,className:_("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(Yr,{children:e.jsx(Eo,{className:"h-4 w-4 fill-current"})})}),n]}));vm.displayName=Jr.displayName;const Ga=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Qr,{ref:r,className:_("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ga.displayName=Qr.displayName;const at=m.forwardRef(({className:s,...n},t)=>e.jsx(Xr,{ref:t,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));at.displayName=Xr.displayName;const Tn=({className:s,...n})=>e.jsx("span",{className:_("ml-auto text-xs tracking-widest opacity-60",s),...n});Tn.displayName="DropdownMenuShortcut";const xn=[{code:"en-US",name:"English",flag:Oo,shortName:"EN"},{code:"zh-CN",name:"中文",flag:zo,shortName:"CN"}];function ei(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=xn.find(a=>a.code===s.language)||xn[1],r=t.flag;return e.jsxs(Hs,{children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(G,{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(qs,{align:"end",className:"w-[120px]",children:xn.map(a=>{const o=a.flag,l=a.code===s.language;return e.jsxs(Se,{onClick:()=>n(a.code),className:_("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(o,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:_("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function bm(){const[s,n]=m.useState(!1),{t}=V("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative flex min-h-svh flex-col items-center justify-center bg-primary-foreground px-4 py-8 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(ei,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px] md:w-[420px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold sm:text-3xl",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(ke,{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-tight sm:text-2xl",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(hm,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(de,{open:s,onOpenChange:n,children:e.jsx(oe,{className:"max-w-[90vw] sm:max-w-lg",children:e.jsxs(he,{children:[e.jsx(me,{children:t("signIn.resetPassword.title")}),e.jsx(qe,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"max-w-full overflow-x-auto rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(G,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Et(r).then(()=>{$.success(t("common:copy.success"))}),children:e.jsx($o,{className:"h-4 w-4"})})]})})]})})})]})}const ym=Object.freeze(Object.defineProperty({__proto__:null,default:bm},Symbol.toStringTag,{value:"Module"})),Ue=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:_("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}));Ue.displayName="Layout";const He=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));He.displayName="LayoutHeader";const Qe=m.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:_("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Qe.displayName="LayoutBody";const si=Ao,ti=qo,ai=Uo,pe=Ho,ue=Ko,xe=Bo,ce=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Zr,{ref:r,sideOffset:n,className:_("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=Zr.displayName;function Wa(){const{pathname:s}=Pn();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function ni({key:s,defaultValue:n}){const[t,r]=m.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function _m(){const[s,n]=ni({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(o=>o!==a))}}}function Nm({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),o=({sub:l,...d})=>{const x=`${a(d.title)}-${d.href}`;return n&&l?m.createElement(Sm,{...d,sub:l,key:x,closeNav:r}):n?m.createElement(Cm,{...d,key:x,closeNav:r}):l?m.createElement(wm,{...d,sub:l,key:x,closeNav:r}):m.createElement(ri,{...d,key:x,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:_("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(pe,{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(o)})})})}function ri({title:s,icon:n,label:t,href:r,closeNav:a,subLink:o=!1}){const{checkActiveNav:l}=Wa(),{t:d}=V();return e.jsxs(Bs,{to:r,onClick:a,className:_(Mt({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",o&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":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 wm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:o}=Wa(),{isExpanded:l,toggleItem:d}=_m(),{t:x}=V(),u=!!r?.find(p=>o(p.href)),i=x(s),c=l(i)||u;return e.jsxs(si,{open:c,onOpenChange:()=>d(i),children:[e.jsxs(ti,{className:_(Mt({variant:u?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),x(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:x(t)}),e.jsx("span",{className:_('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(el,{stroke:1})})]}),e.jsx(ai,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(p=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(ri,{...p,subLink:!0,closeNav:a})},x(p.title)))})})]})}function Cm({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:o}=Wa(),{t:l}=V();return e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(Bs,{to:r,onClick:a,className:_(Mt({variant:o(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 Sm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:o}=Wa(),{t:l}=V(),d=!!r?.find(x=>o(x.href));return e.jsxs(Hs,{children:[e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsx(Gs,{asChild:!0,children:e.jsx(L,{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(el,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(qs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ga,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(at,{}),r.map(({title:x,icon:u,label:i,href:c})=>e.jsx(Se,{asChild:!0,children:e.jsxs(Bs,{to:c,onClick:a,className:`${o(c)?"bg-secondary":""}`,children:[u," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(x)}),i&&e.jsx("span",{className:"ml-auto text-xs",children:l(i)})]})},`${l(x)}-${c}`))]})]})}const li=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Go,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Wo,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(sl,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(En,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Yo,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Jo,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(nr,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Qo,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(tl,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Xo,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(al,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Zo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(ec,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(sc,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(nr,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(tc,{size:18})},{title:"nav:giftCardManagement",label:"",href:"/finance/gift-card",icon:e.jsx(ac,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(nc,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(rc,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(nl,{size:18})}]}];function km({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=m.useState(!1),{t:o}=V();return m.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:_(`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(Ue,{className:`flex h-full flex-col ${r?"h-[100vh] md:h-full":""}`,children:[e.jsxs(He,{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(L,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":o("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(lc,{}):e.jsx(ic,{})})]}),e.jsx(Nm,{id:"sidebar-menu",className:_("flex-1 overflow-auto overscroll-contain",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:li}),e.jsx("div",{className:_("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:_("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:_("whitespace-nowrap tracking-wide","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(L,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":o("common:toggleSidebar"),children:e.jsx(oc,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Tm(){const[s,n]=ni({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function Dm(){const[s,n]=Tm();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(km,{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(Ln,{})})]})}const Fm=Object.freeze(Object.defineProperty({__proto__:null,default:Dm},Symbol.toStringTag,{value:"Module"})),Ys=m.forwardRef(({className:s,...n},t)=>e.jsx(ps,{ref:t,className:_("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ys.displayName=ps.displayName;const Pm=({children:s,...n})=>e.jsx(de,{...n,children:e.jsx(oe,{className:"overflow-hidden p-0",children:e.jsx(Ys,{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})})}),it=m.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(cc,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(ps.Input,{ref:t,className:_("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})]}));it.displayName=ps.Input.displayName;const Js=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.List,{ref:t,className:_("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Js.displayName=ps.List.displayName;const ot=m.forwardRef((s,n)=>e.jsx(ps.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));ot.displayName=ps.Empty.displayName;const gs=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.Group,{ref:t,className:_("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}));gs.displayName=ps.Group.displayName;const Ot=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.Separator,{ref:t,className:_("-mx-1 h-px bg-border",s),...n}));Ot.displayName=ps.Separator.displayName;const Ae=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.Item,{ref:t,className:_("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}));Ae.displayName=ps.Item.displayName;function Lm(){const s=[];for(const n of li)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function ds(){const[s,n]=m.useState(!1),t=Ws(),r=Lm(),{t:a}=V("search"),{t:o}=V("nav");m.useEffect(()=>{const d=x=>{x.key==="k"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),n(u=>!u))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=m.useCallback(d=>{n(!1),t(d)},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(G,{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(In,{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(Pm,{open:s,onOpenChange:n,children:[e.jsx(it,{placeholder:a("placeholder")}),e.jsxs(Js,{children:[e.jsx(ot,{children:a("noResults")}),e.jsx(gs,{heading:a("title"),children:r.map(d=>e.jsxs(Ae,{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:o(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:o(d.parent)})]},d.href))})]})]})]})}function as(){const{theme:s,setTheme:n}=Md();return m.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(L,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(dc,{size:20}):e.jsx(mc,{size:20})}),e.jsx(ei,{})]})}const ii=m.forwardRef(({className:s,...n},t)=>e.jsx(rl,{ref:t,className:_("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));ii.displayName=rl.displayName;const oi=m.forwardRef(({className:s,...n},t)=>e.jsx(ll,{ref:t,className:_("aspect-square h-full w-full",s),...n}));oi.displayName=ll.displayName;const ci=m.forwardRef(({className:s,...n},t)=>e.jsx(il,{ref:t,className:_("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ci.displayName=il.displayName;function ns(){const s=Ws(),n=zr(),t=uc(cm),{t:r}=V(["common"]),a=()=>{Kl(),n(om()),s("/sign-in")},o=t?.email?.split("@")[0]||r("common:user"),l=o.substring(0,2).toUpperCase();return e.jsxs(Hs,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(ii,{className:"h-8 w-8",children:[e.jsx(oi,{src:t?.avatar_url,alt:o}),e.jsx(ci,{children:l})]})})}),e.jsxs(qs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ga,{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:o}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(at,{}),e.jsx(Se,{asChild:!0,children:e.jsxs(Bs,{to:"/config/system",children:[r("common:settings"),e.jsx(Tn,{children:"⌘S"})]})}),e.jsx(at,{}),e.jsxs(Se,{onClick:a,children:[r("common:logout"),e.jsx(Tn,{children:"⇧⌘Q"})]})]})]})}const X=xc,ws=yc,Z=hc,J=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(ol,{ref:r,className:_("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(gc,{asChild:!0,children:e.jsx(Vn,{className:"h-4 w-4 opacity-50"})})]}));J.displayName=ol.displayName;const di=m.forwardRef(({className:s,...n},t)=>e.jsx(cl,{ref:t,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(pc,{className:"h-4 w-4"})}));di.displayName=cl.displayName;const mi=m.forwardRef(({className:s,...n},t)=>e.jsx(dl,{ref:t,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Vn,{className:"h-4 w-4"})}));mi.displayName=dl.displayName;const Q=m.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(fc,{children:e.jsxs(ml,{ref:a,className:_("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(di,{}),e.jsx(jc,{className:_("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(mi,{})]})}));Q.displayName=ml.displayName;const Rm=m.forwardRef(({className:s,...n},t)=>e.jsx(ul,{ref:t,className:_("px-2 py-1.5 text-sm font-semibold",s),...n}));Rm.displayName=ul.displayName;const q=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(xl,{ref:r,className:_("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(vc,{children:e.jsx(bt,{className:"h-4 w-4"})})}),e.jsx(bc,{children:n})]}));q.displayName=xl.displayName;const Em=m.forwardRef(({className:s,...n},t)=>e.jsx(hl,{ref:t,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));Em.displayName=hl.displayName;function ks({className:s,classNames:n,showOutsideDays:t=!0,captionLayout:r="label",buttonVariant:a="ghost",formatters:o,components:l,...d}){const x=gl();return e.jsx(_c,{showOutsideDays:t,className:_("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,s),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...o},classNames:{root:_("w-fit",x.root),months:_("relative flex flex-col gap-4 md:flex-row",x.months),month:_("flex w-full flex-col gap-4",x.month),nav:_("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",x.nav),button_previous:_(Vt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",x.button_previous),button_next:_(Vt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",x.button_next),month_caption:_("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",x.month_caption),dropdowns:_("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",x.dropdowns),dropdown_root:_("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",x.dropdown_root),dropdown:_("absolute inset-0 opacity-0",x.dropdown),caption_label:_("select-none font-medium",r==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",x.caption_label),table:"w-full border-collapse",weekdays:_("flex",x.weekdays),weekday:_("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",x.weekday),week:_("mt-2 flex w-full",x.week),week_number_header:_("w-[--cell-size] select-none",x.week_number_header),week_number:_("text-muted-foreground select-none text-[0.8rem]",x.week_number),day:_("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",x.day),range_start:_("bg-accent rounded-l-md",x.range_start),range_middle:_("rounded-none",x.range_middle),range_end:_("bg-accent rounded-r-md",x.range_end),today:_("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",x.today),outside:_("text-muted-foreground aria-selected:text-muted-foreground",x.outside),disabled:_("text-muted-foreground opacity-50",x.disabled),hidden:_("invisible",x.hidden),...n},components:{Root:({className:u,rootRef:i,...c})=>e.jsx("div",{"data-slot":"calendar",ref:i,className:_(u),...c}),Chevron:({className:u,orientation:i,...c})=>i==="left"?e.jsx(pl,{className:_("size-4",u),...c}):i==="right"?e.jsx(fl,{className:_("size-4",u),...c}):e.jsx(jl,{className:_("size-4",u),...c}),DayButton:Im,WeekNumber:({children:u,...i})=>e.jsx("td",{...i,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:u})}),...l},...d})}function Im({className:s,day:n,modifiers:t,...r}){const a=gl(),o=m.useRef(null);return m.useEffect(()=>{t.focused&&o.current?.focus()},[t.focused]),e.jsx(G,{ref:o,variant:"ghost",size:"icon","data-day":n.date.toLocaleDateString(),"data-selected-single":t.selected&&!t.range_start&&!t.range_end&&!t.range_middle,"data-range-start":t.range_start,"data-range-end":t.range_end,"data-range-middle":t.range_middle,className:_("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",a.day,s),...r})}const es=wc,ss=Cc,We=m.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(Nc,{children:e.jsx(vl,{ref:a,align:n,sideOffset:t,className:_("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})}));We.displayName=vl.displayName;const Qs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Bt=s=>(s/100).toFixed(2),Vm=({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,o)=>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"))?`¥${Bt(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},o))]}):null},Mm=[{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"}],Om=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=zs(t,7);break;case"30d":r=zs(t,30);break;case"90d":r=zs(t,90);break;case"180d":r=zs(t,180);break;case"365d":r=zs(t,365);break;default:r=zs(t,30)}return{startDate:r,endDate:t}};function zm(){const[s,n]=m.useState("amount"),[t,r]=m.useState("30d"),[a,o]=m.useState({from:zs(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:x}=Om(t,a),{data:u}=re({queryKey:["orderStat",{start_date:Ee(d,"yyyy-MM-dd"),end_date:Ee(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:i}=await Ea.getOrderStat({start_date:Ee(d,"yyyy-MM-dd"),end_date:Ee(x,"yyyy-MM-dd")});return i},refetchInterval:3e4});return e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Me,{children:l("dashboard:overview.title")}),e.jsxs(et,{children:[u?.summary.start_date," ",l("dashboard:overview.to")," ",u?.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(X,{value:t,onValueChange:i=>r(i),children:[e.jsx(J,{className:"w-[120px]",children:e.jsx(Z,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(Q,{children:Mm.map(i=>e.jsx(q,{value:i.value,children:l(i.label)},i.value))})]}),t==="custom"&&e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Ss,{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:[Ee(a.from,"yyyy-MM-dd")," -"," ",Ee(a.to,"yyyy-MM-dd")]}):Ee(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(ks,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:i=>{i?.from&&i?.to&&o({from:i.from,to:i.to})},captionLayout:"dropdown",numberOfMonths:2})})]})]}),e.jsx(yt,{value:s,onValueChange:i=>n(i),children:e.jsxs(lt,{children:[e.jsx(Ge,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(Ge,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(Pe,{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:["¥",Bt(u?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:u?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",Bt(u?.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:["¥",Bt(u?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:u?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",u?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Sc,{width:"100%",height:"100%",children:e.jsxs(kc,{data:u?.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:Qs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Qs.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:Qs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Qs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Tc,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:i=>Ee(new Date(i),"MM-dd",{locale:Lc})}),e.jsx(Dc,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:i=>s==="amount"?`¥${Bt(i)}`:l("dashboard:overview.transactions",{count:i})}),e.jsx(Fc,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Pc,{content:e.jsx(Vm,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(rr,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Qs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(rr,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Qs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(lr,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Qs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(lr,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Qs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function be({className:s,...n}){return e.jsx("div",{className:_("animate-pulse rounded-md bg-primary/10",s),...n})}function $m(){return e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"h-4 w-[120px]"}),e.jsx(be,{className:"h-4 w-4"})]}),e.jsxs(Pe,{children:[e.jsx(be,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx(be,{className:"h-4 w-[100px]"})]})]})]})}function Am(){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($m,{},n))})}var ie=(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))(ie||{});const qt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Ut={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var $s=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))($s||{}),fe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(fe||{});const ga={0:"待确认",1:"发放中",2:"有效",3:"无效"},pa={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Ze=(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))(Ze||{});const qm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ge=(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.AnyTLS="anytls",s))(ge||{});const Fs=[{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"},{type:"anytls",label:"AnyTLS"}],bs={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50",anytls:"#7E57C2"};var Cs=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Cs||{});const Um={1:"按金额优惠",2:"按比例优惠"};var tt=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(tt||{}),us=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(us||{}),Zt=(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))(Zt||{});function Xs({title:s,value:n,icon:t,trend:r,description:a,onClick:o,highlight:l,className:d}){return e.jsxs(ke,{className:_("transition-colors",o&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:o,children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(Pe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Vc,{className:_("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:_("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 Hm({className:s}){const n=Ws(),{t}=V(),{data:r,isLoading:a}=re({queryKey:["dashboardStats"],queryFn:async()=>(await Ea.getStatsData()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(Am,{});const o=()=>{const l=new URLSearchParams;l.set("commission_status",fe.PENDING.toString()),l.set("status",ie.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Xs,{title:t("dashboard:stats.todayIncome"),value:Ks(r.todayIncome),icon:e.jsx(Rc,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Xs,{title:t("dashboard:stats.monthlyIncome"),value:Ks(r.currentMonthIncome),icon:e.jsx(Mn,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Xs,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(Ec,{className:_("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(Xs,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(Ic,{className:_("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:o,highlight:r.commissionPendingTotal>0}),e.jsx(Xs,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(Ta,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Xs,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(Ta,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Xs,{title:t("dashboard:stats.monthlyUpload"),value:Le(r.monthTraffic.upload),icon:e.jsx(Rt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:Le(r.todayTraffic.upload)})}),e.jsx(Xs,{title:t("dashboard:stats.monthlyDownload"),value:Le(r.monthTraffic.download),icon:e.jsx(ta,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:Le(r.todayTraffic.download)})})]})}const jt=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(bl,{ref:r,className:_("relative overflow-hidden",s),...t,children:[e.jsx(Mc,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Va,{}),e.jsx(Oc,{})]}));jt.displayName=bl.displayName;const Va=m.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(yl,{ref:r,orientation:n,className:_("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(zc,{className:"relative flex-1 rounded-full bg-border"})}));Va.displayName=yl.displayName;const Dn={today:{getValue:()=>{const s=Ac();return{start:s,end:qc(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:zs(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:zs(s,30),end:s}}},custom:{getValue:()=>null}};function br({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=V(),o={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(X,{value:s,onValueChange:t,children:[e.jsx(J,{className:"w-[120px]",children:e.jsx(Z,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(Q,{position:"popper",className:"z-50",children:Object.entries(Dn).map(([l])=>e.jsx(q,{value:l,children:o[l]},l))})]}),s==="custom"&&e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(Ss,{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:[Ee(n.from,"yyyy-MM-dd")," -"," ",Ee(n.to,"yyyy-MM-dd")]}):Ee(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(ks,{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 Tt=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Km({className:s}){const{t:n}=V(),[t,r]=m.useState("today"),[a,o]=m.useState({from:zs(new Date,7),to:new Date}),[l,d]=m.useState("today"),[x,u]=m.useState({from:zs(new Date,7),to:new Date}),i=m.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:Dn[t].getValue(),[t,a]),c=m.useMemo(()=>l==="custom"?{start:x.from,end:x.to}:Dn[l].getValue(),[l,x]),{data:p}=re({queryKey:["nodeTrafficRank",i.start,i.end],queryFn:()=>Ea.getNodeTrafficData({type:"node",start_time:Ie.round(i.start.getTime()/1e3),end_time:Ie.round(i.end.getTime()/1e3)}),refetchInterval:3e4}),{data:F}=re({queryKey:["userTrafficRank",c.start,c.end],queryFn:()=>Ea.getNodeTrafficData({type:"user",start_time:Ie.round(c.start.getTime()/1e3),end_time:Ie.round(c.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(ke,{children:[e.jsx(Fe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Me,{className:"flex items-center text-base font-medium",children:[e.jsx($c,{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(br,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:o}),e.jsx(ir,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Pe,{className:"flex-1",children:p?.data?e.jsxs(jt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:p.data.map(T=>e.jsx(pe,{delayDuration:200,children:e.jsxs(ue,{children:[e.jsx(xe,{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:T.name}),e.jsxs("span",{className:_("ml-2 flex items-center text-xs font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?e.jsx(yn,{className:"mr-1 h-3 w-3"}):e.jsx(_n,{className:"mr-1 h-3 w-3"}),Math.abs(T.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:`${T.value/p.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Tt(T.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:Tt(T.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Tt(T.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?"+":"",T.change,"%"]})]})})]})},T.id))}),e.jsx(Va,{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(ke,{children:[e.jsx(Fe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Me,{className:"flex items-center text-base font-medium",children:[e.jsx(Ta,{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(br,{selectedRange:l,customDateRange:x,onRangeChange:d,onCustomRangeChange:u}),e.jsx(ir,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Pe,{className:"flex-1",children:F?.data?e.jsxs(jt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:F.data.map(T=>e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{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:T.name}),e.jsxs("span",{className:_("ml-2 flex items-center text-xs font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?e.jsx(yn,{className:"mr-1 h-3 w-3"}):e.jsx(_n,{className:"mr-1 h-3 w-3"}),Math.abs(T.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:`${T.value/F.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Tt(T.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:Tt(T.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Tt(T.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?"+":"",T.change,"%"]})]})})]})},T.id))}),e.jsx(Va,{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 Bm=vt("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 U({className:s,variant:n,...t}){return e.jsx("div",{className:_(Bm({variant:n}),s),...t})}const Na=m.forwardRef(({className:s,value:n,...t},r)=>e.jsx(_l,{ref:r,className:_("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(Uc,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Na.displayName=_l.displayName;const Un=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:_("w-full caption-bottom text-sm",s),...n})}));Un.displayName="Table";const Hn=m.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:_("[&_tr]:border-b",s),...n}));Hn.displayName="TableHeader";const Kn=m.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:_("[&_tr:last-child]:border-0",s),...n}));Kn.displayName="TableBody";const Gm=m.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:_("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Gm.displayName="TableFooter";const Zs=m.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:_("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Zs.displayName="TableRow";const Bn=m.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:_("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}));Bn.displayName="TableHead";const Lt=m.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:_("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Lt.displayName="TableCell";const Wm=m.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:_("mt-4 text-sm text-muted-foreground",s),...n}));Wm.displayName="TableCaption";function ui({table:s}){const[n,t]=m.useState(""),{t:r}=V("common");m.useEffect(()=>{t((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const a=o=>{const l=parseInt(o);!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(X,{value:`${s.getState().pagination.pageSize}`,onValueChange:o=>{s.setPageSize(Number(o))},children:[e.jsx(J,{className:"h-8 w-[70px]",children:e.jsx(Z,{placeholder:s.getState().pagination.pageSize})}),e.jsx(Q,{side:"top",children:[10,20,30,40,50,100,500].map(o=>e.jsx(q,{value:`${o}`,children:o},o))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(D,{type:"text",value:n,onChange:o=>t(o.target.value),onBlur:o=>a(o.target.value),onKeyDown:o=>{o.key==="Enter"&&a(o.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(L,{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(Hc,{className:"h-4 w-4"})]}),e.jsxs(L,{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(Kc,{className:"h-4 w-4"})]}),e.jsxs(L,{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(Hr,{className:"h-4 w-4"})]}),e.jsxs(L,{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(Bc,{className:"h-4 w-4"})]})]})]})]})}function rs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:o,onDragLeave:l,onDrop:d,showPagination:x=!0,isLoading:u=!1}){const{t:i}=V("common"),c=m.useRef(null),p=s.getAllColumns().filter(P=>P.getIsPinned()==="left"),F=s.getAllColumns().filter(P=>P.getIsPinned()==="right"),T=P=>p.slice(0,P).reduce((w,I)=>w+(I.getSize()??0),0),C=P=>F.slice(P+1).reduce((w,I)=>w+(I.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:c,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(Un,{children:[e.jsx(Hn,{children:s.getHeaderGroups().map(P=>e.jsx(Zs,{className:"hover:bg-transparent",children:P.headers.map((w,I)=>{const y=w.column.getIsPinned()==="left",N=w.column.getIsPinned()==="right",S=y?T(p.indexOf(w.column)):void 0,O=N?C(F.indexOf(w.column)):void 0;return e.jsx(Bn,{colSpan:w.colSpan,style:{width:w.getSize(),...y&&{left:S},...N&&{right:O}},className:_("h-11 bg-card px-4 text-muted-foreground",(y||N)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",y&&"before:right-0",N&&"before:left-0"]),children:w.isPlaceholder?null:Da(w.column.columnDef.header,w.getContext())},w.id)})},P.id))}),e.jsx(Kn,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((P,w)=>e.jsx(Zs,{"data-state":P.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:I=>r?.(I,w),onDragEnd:a,onDragOver:o,onDragLeave:l,onDrop:I=>d?.(I,w),children:P.getVisibleCells().map((I,y)=>{const N=I.column.getIsPinned()==="left",S=I.column.getIsPinned()==="right",O=N?T(p.indexOf(I.column)):void 0,E=S?C(F.indexOf(I.column)):void 0;return e.jsx(Lt,{style:{width:I.column.getSize(),...N&&{left:O},...S&&{right:E}},className:_("bg-card",(N||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",N&&"before:right-0",S&&"before:left-0"]),children:Da(I.column.columnDef.cell,I.getContext())},I.id)})},P.id)):e.jsx(Zs,{children:e.jsx(Lt,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:i("table.noData")})})})]})})}),x&&e.jsx(ui,{table:s})]})}const wa=s=>{if(!s)return"";let n;if(typeof s=="string"){if(n=parseInt(s),isNaN(n))return s}else n=s;return(n.toString().length===10?new Date(n*1e3):new Date(n)).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})},Ht=Nl(),Kt=Nl();function fa({data:s,isLoading:n,searchKeyword:t,selectedLevel:r,total:a,currentPage:o,pageSize:l,onViewDetail:d,onPageChange:x,onPageSizeChange:u}){const{t:i}=V(),c=T=>{switch(T.toLowerCase()){case"info":return e.jsx(Wt,{className:"h-4 w-4 text-blue-500"});case"warning":return e.jsx(Yt,{className:"h-4 w-4 text-yellow-500"});case"error":return e.jsx(Cn,{className:"h-4 w-4 text-red-500"});default:return e.jsx(Wt,{className:"h-4 w-4 text-slate-500"})}},p=m.useMemo(()=>[Ht.accessor("level",{id:"level",header:()=>i("dashboard:systemLog.level"),size:80,cell:({getValue:T,row:C})=>{const P=T();return e.jsxs("div",{className:"flex items-center gap-1",children:[c(P),e.jsx("span",{className:_(P.toLowerCase()==="error"&&"text-red-600",P.toLowerCase()==="warning"&&"text-yellow-600",P.toLowerCase()==="info"&&"text-blue-600"),children:P})]})}}),Ht.accessor("created_at",{id:"created_at",header:()=>i("dashboard:systemLog.time"),size:160,cell:({getValue:T})=>wa(T())}),Ht.accessor(T=>T.title||T.message||"",{id:"title",header:()=>i("dashboard:systemLog.logTitle"),cell:({getValue:T})=>e.jsx("span",{className:"inline-block max-w-[300px] truncate",children:T()})}),Ht.accessor("method",{id:"method",header:()=>i("dashboard:systemLog.method"),size:100,cell:({getValue:T})=>{const C=T();return C?e.jsx(U,{variant:"outline",className:_(C==="GET"&&"border-blue-200 bg-blue-50 text-blue-700",C==="POST"&&"border-green-200 bg-green-50 text-green-700",C==="PUT"&&"border-amber-200 bg-amber-50 text-amber-700",C==="DELETE"&&"border-red-200 bg-red-50 text-red-700"),children:C}):null}}),Ht.display({id:"actions",header:()=>i("dashboard:systemLog.action"),size:80,cell:({row:T})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>d(T.original),"aria-label":i("dashboard:systemLog.viewDetail"),children:e.jsx(Nn,{className:"h-4 w-4"})})})],[i,d]),F=Ye({data:s,columns:p,getCoreRowModel:Je(),getPaginationRowModel:ts(),pageCount:Math.ceil(a/l),manualPagination:!0,state:{pagination:m.useMemo(()=>({pageIndex:o-1,pageSize:l}),[o,l])},onPaginationChange:T=>{let C,P;if(typeof T=="function"){const w=T({pageIndex:o-1,pageSize:l});C=w.pageIndex,P=w.pageSize}else C=T.pageIndex,P=T.pageSize;P!==l?u(P):x(C+1)}});return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(rs,{table:F,showPagination:!0,isLoading:n}),(t||r&&r!=="all")&&e.jsx("div",{className:"text-center text-sm text-muted-foreground",children:t&&r&&r!=="all"?i("dashboard:systemLog.filter.searchAndLevel",{keyword:t,level:r,count:a}):t?i("dashboard:systemLog.filter.searchOnly",{keyword:t,count:a}):i("dashboard:systemLog.filter.levelOnly",{level:r,count:a})})]})}function Ym(){const{t:s}=V(),[n,t]=m.useState(0),[r,a]=m.useState(!1),[o,l]=m.useState(1),[d]=m.useState(10),[x,u]=m.useState(null),[i,c]=m.useState(!1),[p,F]=m.useState(!1),[T,C]=m.useState(1),[P,w]=m.useState(10),[I,y]=m.useState(null),[N,S]=m.useState(!1),[O,E]=m.useState(""),[g,k]=m.useState(""),[W,te]=m.useState("all"),[ae,B]=m.useState(!1),[se,je]=m.useState(0),[ms,ze]=m.useState("all"),[le,Ts]=m.useState(1e3),[Ns,ct]=m.useState(!1),[Is,dt]=m.useState(null),[mt,ut]=m.useState(!1);m.useEffect(()=>{const Y=setTimeout(()=>{k(O),O!==g&&C(1)},500);return()=>clearTimeout(Y)},[O]);const{data:K,isLoading:H,refetch:_e,isRefetching:$e}=re({queryKey:["systemStatus",n],queryFn:async()=>(await ye.getSystemStatus()).data,refetchInterval:3e4}),{data:Ne,isLoading:Bi,refetch:mp,isRefetching:Xn}=re({queryKey:["queueStats",n],queryFn:async()=>(await ye.getQueueStats()).data,refetchInterval:3e4}),{data:Zn,isLoading:Gi,refetch:Wi}=re({queryKey:["failedJobs",o,d],queryFn:async()=>{const Y=await ye.getHorizonFailedJobs({current:o,page_size:d});return{data:Y.data,total:Y.total||0}},enabled:r}),{data:er,isLoading:ia,refetch:Yi}=re({queryKey:["systemLogs",T,P,W,g],queryFn:async()=>{const Y={current:T,page_size:P};W&&W!=="all"&&(Y.level=W),g.trim()&&(Y.keyword=g.trim());const Vs=await ye.getSystemLog(Y);return{data:Vs.data,total:Vs.total||0}},enabled:p}),sr=Zn?.data||[],Ji=Zn?.total||0,oa=er?.data||[],ca=er?.total||0,Qi=m.useMemo(()=>[Kt.display({id:"failed_at",header:()=>s("dashboard:queue.details.time"),cell:({row:Y})=>wa(Y.original.failed_at)}),Kt.display({id:"queue",header:()=>s("dashboard:queue.details.queue"),cell:({row:Y})=>Y.original.queue}),Kt.display({id:"name",header:()=>s("dashboard:queue.details.name"),cell:({row:Y})=>e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[150px] truncate",children:Y.original.name})}),e.jsx(ce,{children:e.jsx("span",{children:Y.original.name})})]})})}),Kt.display({id:"exception",header:()=>s("dashboard:queue.details.exception"),cell:({row:Y})=>e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[200px] truncate",children:Y.original.exception.split(` -`)[0]})}),e.jsx(ce,{className:"max-w-[300px] whitespace-pre-wrap",children:e.jsx("span",{children:Y.original.exception})})]})})}),Kt.display({id:"actions",header:()=>s("dashboard:queue.details.action"),size:80,cell:({row:Y})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>so(Y.original),"aria-label":s("dashboard:queue.details.viewDetail"),children:e.jsx(Nn,{className:"h-4 w-4"})})})],[s]),tr=Ye({data:sr,columns:Qi,getCoreRowModel:Je(),getPaginationRowModel:ts(),pageCount:Math.ceil(Ji/d),manualPagination:!0,state:{pagination:{pageIndex:o-1,pageSize:d}},onPaginationChange:Y=>{if(typeof Y=="function"){const Vs=Y({pageIndex:o-1,pageSize:d});ar(Vs.pageIndex+1)}else ar(Y.pageIndex+1)}}),Xi=()=>{t(Y=>Y+1)},ar=Y=>{l(Y)},da=Y=>{C(Y)},ma=Y=>{w(Y),C(1)},Zi=Y=>{te(Y),C(1)},eo=()=>{E(""),k(""),te("all"),C(1)},ua=Y=>{y(Y),S(!0)},so=Y=>{u(Y),c(!0)},to=async()=>{try{const Y=await ye.getLogClearStats({days:se,level:ms==="all"?void 0:ms});dt(Y.data),ut(!0)}catch(Y){console.error("Failed to get clear stats:",Y),$.error(s("dashboard:systemLog.getStatsFailed"))}},ao=async()=>{ct(!0);try{const{data:Y}=await ye.clearSystemLog({days:se,level:ms==="all"?void 0:ms,limit:le});Y&&($.success(s("dashboard:systemLog.clearSuccess",{count:Y.cleared_count}),{duration:3e3}),B(!1),ut(!1),dt(null),_e())}catch(Y){console.error("Failed to clear logs:",Y),$.error(s("dashboard:systemLog.clearLogsFailed"))}finally{ct(!1)}};if(H||Bi)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Fa,{className:"h-6 w-6 animate-spin"})});const no=Y=>Y?e.jsx(wl,{className:"h-5 w-5 text-green-500"}):e.jsx(Cl,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(Gc,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(et,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:Xi,disabled:$e||Xn,children:e.jsx(cn,{className:_("h-4 w-4",($e||Xn)&&"animate-spin")})})]}),e.jsx(Pe,{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:[no(Ne?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(U,{variant:Ne?.status?"secondary":"destructive",children:Ne?.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:Ne?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{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:Ne?.recentJobs||0}),e.jsx(Na,{value:(Ne?.recentJobs||0)/(Ne?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:Ne?.periods?.recentJobs||0})})})]})}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{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:Ne?.jobsPerMinute||0}),e.jsx(Na,{value:(Ne?.jobsPerMinute||0)/(Ne?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:Ne?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(Wc,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(et,{children:s("dashboard:queue.details.description")})]}),e.jsx(Pe,{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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"cursor-pointer text-2xl font-bold text-destructive hover:underline",title:s("dashboard:queue.details.viewFailedJobs"),onClick:()=>a(!0),style:{userSelect:"none"},children:Ne?.failedJobs||0}),e.jsx(Nn,{className:"h-4 w-4 cursor-pointer text-muted-foreground hover:text-destructive",onClick:()=>a(!0),"aria-label":s("dashboard:queue.details.viewFailedJobs")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:Ne?.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:[Ne?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:Ne?.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:[Ne?.processes||0," /"," ",(Ne?.processes||0)+(Ne?.pausedMasters||0)]})]}),e.jsx(Na,{value:(Ne?.processes||0)/((Ne?.processes||0)+(Ne?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-5 w-5"}),s("dashboard:systemLog.title")]}),e.jsx(et,{children:s("dashboard:systemLog.description")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>F(!0),children:s("dashboard:systemLog.viewAll")}),e.jsxs(G,{variant:"outline",onClick:()=>B(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(xs,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.clearLogs")]})]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-900 dark:bg-blue-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"h-5 w-5 text-blue-500"}),e.jsx("p",{className:"font-medium text-blue-700 dark:text-blue-300",children:s("dashboard:systemLog.tabs.info")})]}),e.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:K?.logs?.info||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-900 dark:bg-yellow-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-5 w-5 text-yellow-500"}),e.jsx("p",{className:"font-medium text-yellow-700 dark:text-yellow-300",children:s("dashboard:systemLog.tabs.warning")})]}),e.jsx("p",{className:"text-2xl font-bold text-yellow-700 dark:text-yellow-300",children:K?.logs?.warning||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-900 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-5 w-5 text-red-500"}),e.jsx("p",{className:"font-medium text-red-700 dark:text-red-300",children:s("dashboard:systemLog.tabs.error")})]}),e.jsx("p",{className:"text-2xl font-bold text-red-700 dark:text-red-300",children:K?.logs?.error||0})]})]}),K?.logs&&K.logs.total>0&&e.jsxs("div",{className:"mt-3 text-center text-sm text-muted-foreground",children:[s("dashboard:systemLog.totalLogs"),": ",K.logs.total]})]})})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.failedJobsDetailTitle")})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(rs,{table:tr,showPagination:!1,isLoading:Gi}),e.jsx(ui,{table:tr}),sr.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:s("dashboard:queue.details.noFailedJobs")})]}),e.jsxs(Oe,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Wi(),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(st,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:i,onOpenChange:c,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.jobDetailTitle")})}),x&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.id")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:x.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.time")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:x.failed_at})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.queue")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:x.queue})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.connection")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:x.connection})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.name")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:x.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.exception")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-red-700 dark:text-red-300",children:x.exception})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.payload")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(x.payload),null,2)}catch{return x.payload}})()})})]})]}),e.jsx(Oe,{children:e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:s("common:close")})})]})}),e.jsx(de,{open:p,onOpenChange:F,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.title")})}),e.jsxs(yt,{value:W,onValueChange:Zi,className:"w-full overflow-x-auto",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 p-1 md:flex-row md:items-center md:justify-between",children:[e.jsxs(lt,{className:"grid w-auto grid-cols-4",children:[e.jsxs(Ge,{value:"all",className:"flex items-center gap-2",children:[e.jsx(wn,{className:"h-4 w-4"}),s("dashboard:systemLog.tabs.all")]}),e.jsxs(Ge,{value:"info",className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"h-4 w-4 text-blue-500"}),s("dashboard:systemLog.tabs.info")]}),e.jsxs(Ge,{value:"warning",className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-yellow-500"}),s("dashboard:systemLog.tabs.warning")]}),e.jsxs(Ge,{value:"error",className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4 text-red-500"}),s("dashboard:systemLog.tabs.error")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(D,{placeholder:s("dashboard:systemLog.search"),value:O,onChange:Y=>E(Y.target.value),className:"w-full md:w-64"})]})]}),e.jsx(ys,{value:"all",className:"mt-0",children:e.jsx(fa,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})}),e.jsx(ys,{value:"info",className:"mt-0 overflow-x-auto",children:e.jsx(fa,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})}),e.jsx(ys,{value:"warning",className:"mt-0",children:e.jsx(fa,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})}),e.jsx(ys,{value:"error",className:"mt-0",children:e.jsx(fa,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})})]}),e.jsxs(Oe,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Yi(),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(G,{variant:"outline",onClick:eo,children:s("dashboard:systemLog.filter.reset")}),e.jsx(st,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:N,onOpenChange:S,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.detailTitle")})}),I&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.level")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Wt,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:I.level})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.time")}),e.jsx("p",{children:wa(I.created_at)||wa(I.updated_at)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.logTitle")}),e.jsx("div",{className:"whitespace-pre-wrap rounded-md bg-muted/50 p-3",children:I.title||I.message||""})]}),(I.host||I.ip)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[I.host&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.host")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:I.host})]}),I.ip&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.ip")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:I.ip})]})]}),I.uri&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.uri")}),e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 p-3",children:e.jsx("code",{className:"text-sm",children:I.uri})})]}),I.method&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.method")}),e.jsx("div",{children:e.jsx(U,{variant:"outline",className:"text-base font-medium",children:I.method})})]}),I.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.requestData")}),e.jsx("div",{className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(I.data),null,2)}catch{return I.data}})()})})]}),I.context&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.exception")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs text-red-700 dark:text-red-300",children:(()=>{try{const Y=JSON.parse(I.context);if(Y.exception){const Vs=Y.exception,Nt=Vs["\0*\0message"]||"",ro=Vs["\0*\0file"]||"",lo=Vs["\0*\0line"]||"";return`${Nt} +import{r as m,j as e,t as io,c as oo,I as sa,a as bt,S as Pn,u as Ws,b as co,d as Ln,R as Pr,e as Lr,f as mo,F as uo,C as xo,L as Rr,T as Er,g as Ir,h as ho,i as go,k as po,l as fo,m as $,n as Vr,o as Mr,z as h,p as V,q as Ce,s as Te,v as re,w as As,x as Ie,y as Or,A as jo,O as Rn,B as vo,D as bo,E as yo,G as _o,H as No,J as wo,Q as Co,K as So,M as Ta,N as ko,P as To,U as Do,V as Fo,W as Po,X as Lo,Y as zr,Z as $r,_ as $a,$ as Aa,a0 as En,a1 as os,a2 as qa,a3 as Ua,a4 as Ar,a5 as qr,a6 as Ur,a7 as Hr,a8 as Kr,a9 as Ro,aa as Br,ab as Gr,ac as Wr,ad as Yr,ae as yt,af as Jr,ag as Eo,ah as Qr,ai as Xr,aj as Io,ak as Vo,al as Mo,am as Oo,an as zo,ao as $o,ap as Ao,aq as qo,ar as Uo,as as Ho,at as Zr,au as Ko,av as Bo,aw as Bs,ax as el,ay as Go,az as Wo,aA as sl,aB as In,aC as Yo,aD as Jo,aE as rr,aF as Qo,aG as tl,aH as Xo,aI as al,aJ as Zo,aK as ec,aL as sc,aM as tc,aN as ac,aO as nc,aP as rc,aQ as nl,aR as lc,aS as ic,aT as oc,aU as ps,aV as cc,aW as Vn,aX as dc,aY as mc,aZ as rl,a_ as ll,a$ as il,b0 as uc,b1 as xc,b2 as hc,b3 as ol,b4 as gc,b5 as Mn,b6 as cl,b7 as pc,b8 as dl,b9 as fc,ba as ml,bb as jc,bc as ul,bd as xl,be as vc,bf as bc,bg as hl,bh as yc,bi as gl,bj as _c,bk as pl,bl as fl,bm as jl,bn as Nc,bo as vl,bp as wc,bq as Cc,br as zs,bs as Ee,bt as Ss,bu as Sc,bv as kc,bw as Tc,bx as Dc,by as Fc,bz as Pc,bA as lr,bB as ir,bC as Lc,bD as Rc,bE as On,bF as Ec,bG as Ic,bH as Da,bI as Et,bJ as ta,bK as Vc,bL as bl,bM as Mc,bN as Oc,bO as yl,bP as zc,bQ as $c,bR as or,bS as _n,bT as Nn,bU as Ac,bV as qc,bW as _l,bX as Uc,bY as Hc,bZ as Kc,b_ as Bc,b$ as Fa,c0 as wn,c1 as Ye,c2 as Pa,c3 as Gc,c4 as dn,c5 as Wc,c6 as Cn,c7 as xs,c8 as Wt,c9 as Yt,ca as Sn,cb as Nl,cc as Je,cd as ts,ce as wl,cf as Cl,cg as Yc,ch as Jc,ci as Qc,cj as Xc,ck as Zc,cl as Sl,cm as ed,cn as sd,co as td,cp as $e,cq as cr,cr as ad,cs as kl,ct as Tl,cu as Dl,cv as Fl,cw as Pl,cx as Ll,cy as nd,cz as rd,cA as ld,cB as Ha,cC as lt,cD as fs,cE as js,cF as id,cG as od,cH as cd,cI as dd,cJ as md,cK as ud,cL as La,cM as xd,cN as hd,cO as kn,cP as zn,cQ as $n,cR as gd,cS as Ls,cT as Rs,cU as Ka,cV as pd,cW as fd,cX as Na,cY as Ra,cZ as jd,c_ as dr,c$ as Rl,d0 as xa,d1 as Ea,d2 as vd,d3 as An,d4 as bd,d5 as yd,d6 as _d,d7 as El,d8 as Nd,d9 as wd,da as Il,db as Tn,dc as Vl,dd as Cd,de as aa,df as Ml,dg as Sd,dh as kd,di as Td,dj as Ol,dk as Dd,dl as zl,dm as Jt,dn as qn,dp as Fd,dq as mr,dr as $l,ds as Pd,dt as ur,du as Ld,dv as Rd}from"./vendor.js";import"./index.js";var hp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ed(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 Id={theme:"system",setTheme:()=>null},Al=m.createContext(Id);function Vd({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=m.useState(()=>localStorage.getItem(t)||n);m.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(x);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(Al.Provider,{...r,value:l,children:s})}const Md=()=>{const s=m.useContext(Al);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Od=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),zd=function(s,n){return new URL(s,n).href},xr={},we=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]"),x=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(u=>{if(u=zd(u,r),u in xr)return;xr[u]=!0;const o=u.endsWith(".css"),c=o?'[rel="stylesheet"]':"";if(!!r)for(let T=l.length-1;T>=0;T--){const C=l[T];if(C.href===u&&(!o||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${u}"]${c}`))return;const F=document.createElement("link");if(F.rel=o?"stylesheet":Od,o||(F.as="script"),F.crossOrigin="",F.href=u,x&&F.setAttribute("nonce",x),document.head.appendChild(F),o)return new Promise((T,C)=>{F.addEventListener("load",T),F.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${u}`)))})}))}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 _(...s){return io(oo(s))}const Mt=bt("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"}}),L=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:x,...u},o)=>{const c=r?Pn:"button";return e.jsxs(c,{className:_(Mt({variant:n,size:t,className:s})),disabled:l||i,ref:o,...u,children:[(d&&l||!d&&!x&&l)&&e.jsx(sa,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&x&&e.jsx("div",{className:"ml-2",children:x}),x&&l&&e.jsx(sa,{className:"ml-2 h-4 w-4 animate-spin"})]})});L.displayName="Button";function Ct({className:s,minimal:n=!1}){const t=Ws(),r=co(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:_("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(L,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(L,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function hr(){const s=Ws();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(L,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(L,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function $d(){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(L,{variant:"outline",children:"Learn more"})})]})})}function Ad(s){return typeof s>"u"}function qd(s){return s===null}function Ud(s){return qd(s)||Ad(s)}class Hd{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 Ud(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 ql({prefixKey:s="",storage:n=sessionStorage}){return new Hd({prefixKey:s,storage:n})}const Ul="Xboard_",Kd=function(s={}){return ql({prefixKey:s.prefixKey||"",storage:localStorage})},Bd=function(s={}){return ql({prefixKey:s.prefixKey||"",storage:sessionStorage})},Un=Kd({prefixKey:Ul});Bd({prefixKey:Ul});const Hl="access_token";function na(){return Un.get(Hl)}function Kl(){Un.remove(Hl)}const gr=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Gd({children:s}){const n=Ws(),t=Ln(),r=na();return m.useEffect(()=>{if(!r.value&&!gr.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),gr.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const Re=m.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(Pr,{ref:a,decorative:t,orientation:n,className:_("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));Re.displayName=Pr.displayName;const Wd=bt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Xe=m.forwardRef(({className:s,...n},t)=>e.jsx(Lr,{ref:t,className:_(Wd(),s),...n}));Xe.displayName=Lr.displayName;const De=uo,Bl=m.createContext({}),j=({...s})=>e.jsx(Bl.Provider,{value:{name:s.name},children:e.jsx(xo,{...s})}),Ba=()=>{const s=m.useContext(Bl),n=m.useContext(Gl),{getFieldState:t,formState:r}=mo(),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}},Gl=m.createContext({}),f=m.forwardRef(({className:s,...n},t)=>{const r=m.useId();return e.jsx(Gl.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:_("space-y-2",s),...n})})});f.displayName="FormItem";const v=m.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Ba();return e.jsx(Xe,{ref:t,className:_(r&&"text-destructive",s),htmlFor:a,...n})});v.displayName="FormLabel";const b=m.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Ba();return e.jsx(Pn,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});b.displayName="FormControl";const A=m.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Ba();return e.jsx("p",{ref:t,id:r,className:_("text-[0.8rem] text-muted-foreground",s),...n})});A.displayName="FormDescription";const R=m.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Ba(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:_("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});R.displayName="FormMessage";const _t=ho,it=m.forwardRef(({className:s,...n},t)=>e.jsx(Rr,{ref:t,className:_("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));it.displayName=Rr.displayName;const Ge=m.forwardRef(({className:s,...n},t)=>e.jsx(Er,{ref:t,className:_("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=Er.displayName;const ys=m.forwardRef(({className:s,...n},t)=>e.jsx(Ir,{ref:t,className:_("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ys.displayName=Ir.displayName;function ne(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),go(s).format(n))}function Yd(s=void 0,n="YYYY-MM-DD"){return ne(s,n)}function pr(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const 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 Zs(s){return new Promise(n=>{try{const t=document.createElement("button");t.style.position="fixed",t.style.left="-9999px",t.style.opacity="0",t.setAttribute("data-clipboard-text",s),document.body.appendChild(t);const r=new po(t);r.on("success",()=>{r.destroy(),document.body.removeChild(t),n(!0)}),r.on("error",a=>{console.error("Clipboard.js failed:",a),r.destroy(),document.body.removeChild(t),n(!1)}),t.click()}catch(t){console.error("copyToClipboard failed:",t),n(!1)}})}function Le(s){if(s==null||s<=0)return"0 B";const n=1024,t=["B","KB","MB","GB","TB"];let r=Math.floor(Math.log(s)/Math.log(n));return r<0?r=0:r>=t.length&&(r=t.length-1),`${parseFloat((s/Math.pow(n,r)).toFixed(2))} ${t[r]}`}const fr="i18nextLng";function Jd(){return console.log(localStorage.getItem(fr)),localStorage.getItem(fr)}function Wl(){Kl();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 Qd=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Xd(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const Pt=fo.create({baseURL:Xd(),timeout:12e3,headers:{"Content-Type":"application/json"}});Pt.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=na();if(!Qd.includes(s.url?.split("?")[0]||"")){if(!n.value)return Wl(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Jd()||"zh-CN",s},s=>Promise.reject(s));Pt.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)&&Wl(),$.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const M={get:(s,n)=>Pt.get(s,n),post:(s,n,t)=>Pt.post(s,n,t),put:(s,n,t)=>Pt.put(s,n,t),delete:(s,n)=>Pt.delete(s,n)},Zd="access_token";function em(s){Un.set(Zd,s)}const ht=window?.settings?.secure_path,Ia={getStats:()=>M.get(ht+"/monitor/api/stats"),getOverride:()=>M.get(ht+"/stat/getOverride"),getOrderStat:s=>M.get(ht+"/stat/getOrder",{params:s}),getStatsData:()=>M.get(ht+"/stat/getStats"),getNodeTrafficData:s=>M.get(ht+"/stat/getTrafficRank",{params:s}),getServerLastRank:()=>M.get(ht+"/stat/getServerLastRank"),getServerYesterdayRank:()=>M.get(ht+"/stat/getServerYesterdayRank")},zt=window?.settings?.secure_path,Qt={getList:()=>M.get(zt+"/theme/getThemes"),getConfig:s=>M.post(zt+"/theme/getThemeConfig",{name:s}),updateConfig:(s,n)=>M.post(zt+"/theme/saveThemeConfig",{name:s,config:n}),upload:s=>{const n=new FormData;return n.append("file",s),M.post(zt+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},drop:s=>M.post(zt+"/theme/delete",{name:s})},St=window?.settings?.secure_path,ft={getList:()=>M.get(St+"/server/manage/getNodes"),save:s=>M.post(St+"/server/manage/save",s),drop:s=>M.post(St+"/server/manage/drop",s),copy:s=>M.post(St+"/server/manage/copy",s),update:s=>M.post(St+"/server/manage/update",s),sort:s=>M.post(St+"/server/manage/sort",s)},mn=window?.settings?.secure_path,Nt={getList:()=>M.get(mn+"/server/group/fetch"),save:s=>M.post(mn+"/server/group/save",s),drop:s=>M.post(mn+"/server/group/drop",s)},un=window?.settings?.secure_path,Ga={getList:()=>M.get(un+"/server/route/fetch"),save:s=>M.post(un+"/server/route/save",s),drop:s=>M.post(un+"/server/route/drop",s)},gt=window?.settings?.secure_path,jt={getList:()=>M.get(gt+"/payment/fetch"),getMethodList:()=>M.get(gt+"/payment/getPaymentMethods"),getMethodForm:s=>M.post(gt+"/payment/getPaymentForm",s),save:s=>M.post(gt+"/payment/save",s),drop:s=>M.post(gt+"/payment/drop",s),updateStatus:s=>M.post(gt+"/payment/show",s),sort:s=>M.post(gt+"/payment/sort",s)},$t=window?.settings?.secure_path,ra={getList:()=>M.get(`${$t}/notice/fetch`),save:s=>M.post(`${$t}/notice/save`,s),drop:s=>M.post(`${$t}/notice/drop`,{id:s}),updateStatus:s=>M.post(`${$t}/notice/show`,{id:s}),sort:s=>M.post(`${$t}/notice/sort`,{ids:s})},kt=window?.settings?.secure_path,It={getList:()=>M.get(kt+"/knowledge/fetch"),getInfo:s=>M.get(kt+"/knowledge/fetch?id="+s),save:s=>M.post(kt+"/knowledge/save",s),drop:s=>M.post(kt+"/knowledge/drop",s),updateStatus:s=>M.post(kt+"/knowledge/show",s),sort:s=>M.post(kt+"/knowledge/sort",s)},At=window?.settings?.secure_path,_s={getList:()=>M.get(At+"/plan/fetch"),save:s=>M.post(At+"/plan/save",s),update:s=>M.post(At+"/plan/update",s),drop:s=>M.post(At+"/plan/drop",s),sort:s=>M.post(At+"/plan/sort",{ids:s})},Tt=window?.settings?.secure_path,pt={getList:s=>M.post(Tt+"/order/fetch",s),getInfo:s=>M.post(Tt+"/order/detail",s),markPaid:s=>M.post(Tt+"/order/paid",s),makeCancel:s=>M.post(Tt+"/order/cancel",s),update:s=>M.post(Tt+"/order/update",s),assign:s=>M.post(Tt+"/order/assign",s)},Ds=window?.settings?.secure_path,Ps={getTemplates:s=>M.post(Ds+"/gift-card/templates",s),createTemplate:s=>M.post(Ds+"/gift-card/create-template",s),updateTemplate:s=>M.post(Ds+"/gift-card/update-template",s),deleteTemplate:s=>M.post(Ds+"/gift-card/delete-template",s),getCodes:s=>M.post(Ds+"/gift-card/codes",s),generateCodes:s=>s.download_csv?M.post(Ds+"/gift-card/generate-codes",s,{responseType:"blob"}):M.post(Ds+"/gift-card/generate-codes",s),toggleCode:s=>M.post(Ds+"/gift-card/toggle-code",s),exportCodes:s=>M.get(Ds+`/gift-card/export-codes?batch_id=${s}`,{responseType:"blob"}),getUsages:s=>M.post(Ds+"/gift-card/usages",s),getStatistics:s=>M.post(Ds+"/gift-card/statistics",s),getTypes:()=>M.get(Ds+"/gift-card/types")},ha=window?.settings?.secure_path,Va={getList:s=>M.post(ha+"/coupon/fetch",s),save:s=>M.post(ha+"/coupon/generate",s),drop:s=>M.post(ha+"/coupon/drop",s),update:s=>M.post(ha+"/coupon/update",s)},vs=window?.settings?.secure_path,Us={getList:s=>M.post(`${vs}/user/fetch`,s),update:s=>M.post(`${vs}/user/update`,s),resetSecret:s=>M.post(`${vs}/user/resetSecret`,{id:s}),generate:s=>s.download_csv?M.post(`${vs}/user/generate`,s,{responseType:"blob"}):M.post(`${vs}/user/generate`,s),getStats:s=>M.post(`${vs}/stat/getStatUser`,s),destroy:s=>M.post(`${vs}/user/destroy`,{id:s}),sendMail:s=>M.post(`${vs}/user/sendMail`,s),dumpCSV:s=>M.post(`${vs}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>M.post(`${vs}/user/ban`,s)},la={getLogs:s=>M.get(`${vs}/traffic-reset/logs`,{params:s}),getStats:s=>M.get(`${vs}/traffic-reset/stats`,{params:s}),resetUser:s=>M.post(`${vs}/traffic-reset/reset-user`,s),getUserHistory:(s,n)=>M.get(`${vs}/traffic-reset/user/${s}/history`,{params:n})},ga=window?.settings?.secure_path,Lt={getList:s=>M.post(ga+"/ticket/fetch",s),getInfo:s=>M.get(ga+"/ticket/fetch?id= "+s),reply:s=>M.post(ga+"/ticket/reply",s),close:s=>M.post(ga+"/ticket/close",{id:s})},ls=window?.settings?.secure_path,ye={getSettings:(s="")=>M.get(ls+"/config/fetch?key="+s),saveSettings:s=>M.post(ls+"/config/save",s),getEmailTemplate:()=>M.get(ls+"/config/getEmailTemplate"),sendTestMail:()=>M.post(ls+"/config/testSendMail"),setTelegramWebhook:()=>M.post(ls+"/config/setTelegramWebhook"),updateSystemConfig:s=>M.post(ls+"/config/save",s),getSystemStatus:()=>M.get(`${ls}/system/getSystemStatus`),getQueueStats:()=>M.get(`${ls}/system/getQueueStats`),getQueueWorkload:()=>M.get(`${ls}/system/getQueueWorkload`),getQueueMasters:()=>M.get(`${ls}/system/getQueueMasters`),getHorizonFailedJobs:s=>M.get(`${ls}/system/getHorizonFailedJobs`,{params:s}),getSystemLog:s=>M.get(`${ls}/system/getSystemLog`,{params:s}),getLogFiles:()=>M.get(`${ls}/log/files`),getLogContent:s=>M.get(`${ls}/log/fetch`,{params:s}),getLogClearStats:s=>M.get(`${ls}/system/getLogClearStats`,{params:s}),clearSystemLog:s=>M.post(`${ls}/system/clearSystemLog`,s)},Ms=window?.settings?.secure_path,Os={getPluginTypes:()=>M.get(`${Ms}/plugin/types`),getPluginList:s=>{const n=s?{type:s}:{};return M.get(`${Ms}/plugin/getPlugins`,{params:n})},uploadPlugin:s=>{const n=new FormData;return n.append("file",s),M.post(`${Ms}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>M.post(`${Ms}/plugin/delete`,{code:s}),installPlugin:s=>M.post(`${Ms}/plugin/install`,{code:s}),uninstallPlugin:s=>M.post(`${Ms}/plugin/uninstall`,{code:s}),enablePlugin:s=>M.post(`${Ms}/plugin/enable`,{code:s}),disablePlugin:s=>M.post(`${Ms}/plugin/disable`,{code:s}),getPluginConfig:s=>M.get(`${Ms}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>M.post(`${Ms}/plugin/config`,{code:s,config:n}),upgradePlugin:s=>M.post(`${Ms}/plugin/upgrade`,{code:s})};window?.settings?.secure_path;Vr.config({monaco:Mr});const sm=h.object({subscribe_template_singbox:h.string().optional().default(""),subscribe_template_clash:h.string().optional().default(""),subscribe_template_clashmeta:h.string().optional().default(""),subscribe_template_stash:h.string().optional().default(""),subscribe_template_surge:h.string().optional().default(""),subscribe_template_surfboard:h.string().optional().default("")}),jr=[{key:"singbox",label:"Sing-box",language:"json"},{key:"clash",label:"Clash",language:"yaml"},{key:"clashmeta",label:"Clash Meta",language:"yaml"},{key:"stash",label:"Stash",language:"yaml"},{key:"surge",label:"Surge",language:"ini"},{key:"surfboard",label:"Surfboard",language:"ini"}],vr={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function tm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),[a,i]=m.useState("singbox"),l=Ce({resolver:Te(sm),defaultValues:vr,mode:"onChange"}),{data:d,isLoading:x}=re({queryKey:["settings","client"],queryFn:()=>ye.getSettings("subscribe_template")}),{mutateAsync:u}=As({mutationFn:ye.saveSettings,onSuccess:()=>{$.success(s("common.autoSaved"))},onError:F=>{console.error("保存失败:",F),$.error(s("common.saveFailed"))}});m.useEffect(()=>{if(d?.data?.subscribe_template){const F=d.data.subscribe_template;Object.entries(F).forEach(([T,C])=>{if(T in vr){const P=typeof C=="string"?C:"";l.setValue(T,P)}}),r.current=l.getValues()}},[d,l]);const o=m.useCallback(Ie.debounce(async F=>{if(!r.current||!Ie.isEqual(F,r.current)){t(!0);try{await u(F),r.current=F}catch(T){console.error("保存设置失败:",T)}finally{t(!1)}}},1500),[u]),c=m.useCallback(()=>{const F=l.getValues();o(F)},[l,o]),p=m.useCallback((F,T)=>e.jsx(j,{control:l.control,name:F,render:({field:C})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s(`subscribe_template.${F.replace("subscribe_template_","")}.title`)}),e.jsx(b,{children:e.jsx(Or,{height:"500px",defaultLanguage:T,value:C.value||"",onChange:P=>{C.onChange(P||""),c()},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})}),e.jsx(A,{children:s(`subscribe_template.${F.replace("subscribe_template_","")}.description`)}),e.jsx(R,{})]})}),[l.control,s,c]);return x?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")})}):e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(_t,{value:a,onValueChange:i,className:"w-full",children:[e.jsx(it,{className:"",children:jr.map(({key:F,label:T})=>e.jsx(Ge,{value:F,className:"text-xs",children:T},F))}),jr.map(({key:F,language:T})=>e.jsx(ys,{value:F,className:"mt-4",children:p(`subscribe_template_${F}`,T)},F))]}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500"}),s("common.saving")]})]})})}function am(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(Re,{}),e.jsx(tm,{})]})}const nm=()=>e.jsx(Gd,{children:e.jsx(Rn,{})}),rm=jo([{path:"/sign-in",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ym);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(nm,{}),children:[{path:"/",lazy:async()=>({Component:(await we(()=>Promise.resolve().then(()=>Fm),void 0,import.meta.url)).default}),errorElement:e.jsx(Ct,{}),children:[{index:!0,lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Qm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ct,{}),children:[{path:"system",lazy:async()=>({Component:(await we(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 we(async()=>{const{default:s}=await Promise.resolve().then(()=>ru);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>du);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>gu);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>bu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Cu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Fu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Iu);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>$u);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Ku);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(am,{})}]},{path:"payment",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>sx);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>rx);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ux);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>bx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ct,{}),children:[{path:"manage",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Jx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>sh);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ih);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ct,{}),children:[{path:"plan",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>ph);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>Fh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>$h);return{default:s}},void 0,import.meta.url)).default})},{path:"gift-card",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>lg);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ct,{}),children:[{path:"manage",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>zg);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>np);return{default:s}},void 0,import.meta.url)).default})},{path:"traffic-reset-logs",lazy:async()=>({Component:(await we(async()=>{const{default:s}=await Promise.resolve().then(()=>dp);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ct},{path:"/404",Component:hr},{path:"/503",Component:$d},{path:"*",Component:hr}]);function lm(){return M.get("/user/info")}const xn={token:na()?.value||"",userInfo:null,isLoggedIn:!!na()?.value,loading:!1,error:null},Xt=vo("user/fetchUserInfo",async()=>(await lm()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),Yl=bo({name:"user",initialState:xn,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>xn},extraReducers:s=>{s.addCase(Xt.pending,n=>{n.loading=!0,n.error=null}).addCase(Xt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(Xt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return xn})}}),{setToken:im,resetUserState:om}=Yl.actions,cm=s=>s.user.userInfo,dm=Yl.reducer,Jl=yo({reducer:{user:dm}});na()?.value&&Jl.dispatch(Xt());_o.use(No).use(wo).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 mm=new Co;So.createRoot(document.getElementById("root")).render(e.jsx(Ta.StrictMode,{children:e.jsx(ko,{client:mm,children:e.jsx(To,{store:Jl,children:e.jsxs(Vd,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Do,{router:rm}),e.jsx(Fo,{richColors:!0,position:"top-right"})]})})})}));const ke=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("rounded-xl border bg-card text-card-foreground shadow",s),...n}));ke.displayName="Card";const Fe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("flex flex-col space-y-1.5 p-6",s),...n}));Fe.displayName="CardHeader";const Me=m.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:_("font-semibold leading-none tracking-tight",s),...n}));Me.displayName="CardTitle";const st=m.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:_("text-sm text-muted-foreground",s),...n}));st.displayName="CardDescription";const Pe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("p-6 pt-0",s),...n}));Pe.displayName="CardContent";const um=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("flex items-center p-6 pt-0",s),...n}));um.displayName="CardFooter";const D=m.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:_("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));D.displayName="Input";const Ql=m.forwardRef(({className:s,...n},t)=>{const[r,a]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:_("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(L,{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(Po,{size:18}):e.jsx(Lo,{size:18})})]})});Ql.displayName="PasswordInput";const xm=s=>M.post("/passport/auth/login",s);function hm({className:s,onForgotPassword:n,...t}){const r=Ws(),a=zr(),{t:i}=V("auth"),l=h.object({email:h.string().min(1,{message:i("signIn.validation.emailRequired")}),password:h.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=Ce({resolver:Te(l),defaultValues:{email:"",password:""}});async function x(u){try{const{data:o}=await xm(u);em(o.auth_data),a(im(o.auth_data)),await a(Xt()).unwrap(),r("/")}catch(o){console.error("Login failed:",o),o.response?.data?.message&&d.setError("root",{message:o.response.data.message})}}return e.jsx("div",{className:_("grid gap-6",s),...t,children:e.jsx(De,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(x),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(j,{control:d.control,name:"email",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:i("signIn.email")}),e.jsx(b,{children:e.jsx(D,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...u})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"password",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:i("signIn.password")}),e.jsx(b,{children:e.jsx(Ql,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...u})}),e.jsx(R,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(L,{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(L,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const de=$r,cs=Ar,gm=qr,tt=En,Xl=m.forwardRef(({className:s,...n},t)=>e.jsx($a,{ref:t,className:_("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}));Xl.displayName=$a.displayName;const oe=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(gm,{children:[e.jsx(Xl,{}),e.jsxs(Aa,{ref:r,className:_("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(En,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));oe.displayName=Aa.displayName;const he=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});he.displayName="DialogHeader";const Oe=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Oe.displayName="DialogFooter";const me=m.forwardRef(({className:s,...n},t)=>e.jsx(qa,{ref:t,className:_("text-lg font-semibold leading-none tracking-tight",s),...n}));me.displayName=qa.displayName;const Ue=m.forwardRef(({className:s,...n},t)=>e.jsx(Ua,{ref:t,className:_("text-sm text-muted-foreground",s),...n}));Ue.displayName=Ua.displayName;const Vt=bt("inline-flex items-center justify-center gap-2 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"}}),G=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?Pn:"button";return e.jsx(l,{className:_(Vt({variant:n,size:t,className:s})),ref:i,...a})});G.displayName="Button";const Hs=Io,Gs=Vo,pm=Mo,fm=m.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Ur,{ref:a,className:_("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(Hr,{className:"ml-auto h-4 w-4"})]}));fm.displayName=Ur.displayName;const jm=m.forwardRef(({className:s,...n},t)=>e.jsx(Kr,{ref:t,className:_("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}));jm.displayName=Kr.displayName;const qs=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Ro,{children:e.jsx(Br,{ref:r,sideOffset:n,className:_("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})}));qs.displayName=Br.displayName;const Se=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Gr,{ref:r,className:_("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}));Se.displayName=Gr.displayName;const Zl=m.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Wr,{ref:a,className:_("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(Yr,{children:e.jsx(yt,{className:"h-4 w-4"})})}),n]}));Zl.displayName=Wr.displayName;const vm=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Jr,{ref:r,className:_("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(Yr,{children:e.jsx(Eo,{className:"h-4 w-4 fill-current"})})}),n]}));vm.displayName=Jr.displayName;const Wa=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Qr,{ref:r,className:_("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Wa.displayName=Qr.displayName;const nt=m.forwardRef(({className:s,...n},t)=>e.jsx(Xr,{ref:t,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));nt.displayName=Xr.displayName;const Dn=({className:s,...n})=>e.jsx("span",{className:_("ml-auto text-xs tracking-widest opacity-60",s),...n});Dn.displayName="DropdownMenuShortcut";const hn=[{code:"en-US",name:"English",flag:Oo,shortName:"EN"},{code:"zh-CN",name:"中文",flag:zo,shortName:"CN"}];function ei(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=hn.find(a=>a.code===s.language)||hn[1],r=t.flag;return e.jsxs(Hs,{children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(G,{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(qs,{align:"end",className:"w-[120px]",children:hn.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(Se,{onClick:()=>n(a.code),className:_("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:_("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function bm(){const[s,n]=m.useState(!1),{t}=V("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative flex min-h-svh flex-col items-center justify-center bg-primary-foreground px-4 py-8 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(ei,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px] md:w-[420px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold sm:text-3xl",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(ke,{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-tight sm:text-2xl",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(hm,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(de,{open:s,onOpenChange:n,children:e.jsx(oe,{className:"max-w-[90vw] sm:max-w-lg",children:e.jsxs(he,{children:[e.jsx(me,{children:t("signIn.resetPassword.title")}),e.jsx(Ue,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"max-w-full overflow-x-auto rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(G,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Zs(r).then(()=>{$.success(t("common:copy.success"))}),children:e.jsx($o,{className:"h-4 w-4"})})]})})]})})})]})}const ym=Object.freeze(Object.defineProperty({__proto__:null,default:bm},Symbol.toStringTag,{value:"Module"})),He=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:_("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}));He.displayName="Layout";const Ke=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:_("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ke.displayName="LayoutHeader";const Qe=m.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:_("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Qe.displayName="LayoutBody";const si=Ao,ti=qo,ai=Uo,pe=Ho,ue=Ko,xe=Bo,ce=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Zr,{ref:r,sideOffset:n,className:_("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=Zr.displayName;function Ya(){const{pathname:s}=Ln();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function ni({key:s,defaultValue:n}){const[t,r]=m.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function _m(){const[s,n]=ni({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 Nm({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const x=`${a(d.title)}-${d.href}`;return n&&l?m.createElement(Sm,{...d,sub:l,key:x,closeNav:r}):n?m.createElement(Cm,{...d,key:x,closeNav:r}):l?m.createElement(wm,{...d,sub:l,key:x,closeNav:r}):m.createElement(ri,{...d,key:x,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:_("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(pe,{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 ri({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Ya(),{t:d}=V();return e.jsxs(Bs,{to:r,onClick:a,className:_(Mt({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 wm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ya(),{isExpanded:l,toggleItem:d}=_m(),{t:x}=V(),u=!!r?.find(p=>i(p.href)),o=x(s),c=l(o)||u;return e.jsxs(si,{open:c,onOpenChange:()=>d(o),children:[e.jsxs(ti,{className:_(Mt({variant:u?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),x(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:x(t)}),e.jsx("span",{className:_('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(el,{stroke:1})})]}),e.jsx(ai,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(p=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(ri,{...p,subLink:!0,closeNav:a})},x(p.title)))})})]})}function Cm({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Ya(),{t:l}=V();return e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(Bs,{to:r,onClick:a,className:_(Mt({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 Sm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ya(),{t:l}=V(),d=!!r?.find(x=>i(x.href));return e.jsxs(Hs,{children:[e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsx(Gs,{asChild:!0,children:e.jsx(L,{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(el,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(qs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Wa,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(nt,{}),r.map(({title:x,icon:u,label:o,href:c})=>e.jsx(Se,{asChild:!0,children:e.jsxs(Bs,{to:c,onClick:a,className:`${i(c)?"bg-secondary":""}`,children:[u," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(x)}),o&&e.jsx("span",{className:"ml-auto text-xs",children:l(o)})]})},`${l(x)}-${c}`))]})]})}const li=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Go,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Wo,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(sl,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(In,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Yo,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Jo,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(rr,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Qo,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(tl,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Xo,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(al,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Zo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(ec,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(sc,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(rr,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(tc,{size:18})},{title:"nav:giftCardManagement",label:"",href:"/finance/gift-card",icon:e.jsx(ac,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(nc,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(rc,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(nl,{size:18})}]}];function km({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=m.useState(!1),{t:i}=V();return m.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:_(`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(He,{className:`flex h-full flex-col ${r?"h-[100vh] md:h-full":""}`,children:[e.jsxs(Ke,{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(L,{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(lc,{}):e.jsx(ic,{})})]}),e.jsx(Nm,{id:"sidebar-menu",className:_("flex-1 overflow-auto overscroll-contain",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:li}),e.jsx("div",{className:_("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:_("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:_("whitespace-nowrap tracking-wide","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(L,{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(oc,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Tm(){const[s,n]=ni({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function Dm(){const[s,n]=Tm();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(km,{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(Rn,{})})]})}const Fm=Object.freeze(Object.defineProperty({__proto__:null,default:Dm},Symbol.toStringTag,{value:"Module"})),Ys=m.forwardRef(({className:s,...n},t)=>e.jsx(ps,{ref:t,className:_("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ys.displayName=ps.displayName;const Pm=({children:s,...n})=>e.jsx(de,{...n,children:e.jsx(oe,{className:"overflow-hidden p-0",children:e.jsx(Ys,{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})})}),ot=m.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(cc,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(ps.Input,{ref:t,className:_("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})]}));ot.displayName=ps.Input.displayName;const Js=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.List,{ref:t,className:_("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Js.displayName=ps.List.displayName;const ct=m.forwardRef((s,n)=>e.jsx(ps.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));ct.displayName=ps.Empty.displayName;const gs=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.Group,{ref:t,className:_("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}));gs.displayName=ps.Group.displayName;const Ot=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.Separator,{ref:t,className:_("-mx-1 h-px bg-border",s),...n}));Ot.displayName=ps.Separator.displayName;const qe=m.forwardRef(({className:s,...n},t)=>e.jsx(ps.Item,{ref:t,className:_("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}));qe.displayName=ps.Item.displayName;function Lm(){const s=[];for(const n of li)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function ds(){const[s,n]=m.useState(!1),t=Ws(),r=Lm(),{t:a}=V("search"),{t:i}=V("nav");m.useEffect(()=>{const d=x=>{x.key==="k"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),n(u=>!u))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=m.useCallback(d=>{n(!1),t(d)},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs(G,{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(Vn,{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(Pm,{open:s,onOpenChange:n,children:[e.jsx(ot,{placeholder:a("placeholder")}),e.jsxs(Js,{children:[e.jsx(ct,{children:a("noResults")}),e.jsx(gs,{heading:a("title"),children:r.map(d=>e.jsxs(qe,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}function as(){const{theme:s,setTheme:n}=Md();return m.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(L,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(dc,{size:20}):e.jsx(mc,{size:20})}),e.jsx(ei,{})]})}const ii=m.forwardRef(({className:s,...n},t)=>e.jsx(rl,{ref:t,className:_("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));ii.displayName=rl.displayName;const oi=m.forwardRef(({className:s,...n},t)=>e.jsx(ll,{ref:t,className:_("aspect-square h-full w-full",s),...n}));oi.displayName=ll.displayName;const ci=m.forwardRef(({className:s,...n},t)=>e.jsx(il,{ref:t,className:_("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ci.displayName=il.displayName;function ns(){const s=Ws(),n=zr(),t=uc(cm),{t:r}=V(["common"]),a=()=>{Kl(),n(om()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(Hs,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(ii,{className:"h-8 w-8",children:[e.jsx(oi,{src:t?.avatar_url,alt:i}),e.jsx(ci,{children:l})]})})}),e.jsxs(qs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Wa,{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(nt,{}),e.jsx(Se,{asChild:!0,children:e.jsxs(Bs,{to:"/config/system",children:[r("common:settings"),e.jsx(Dn,{children:"⌘S"})]})}),e.jsx(nt,{}),e.jsxs(Se,{onClick:a,children:[r("common:logout"),e.jsx(Dn,{children:"⇧⌘Q"})]})]})]})}const X=xc,ws=yc,Z=hc,J=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(ol,{ref:r,className:_("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(gc,{asChild:!0,children:e.jsx(Mn,{className:"h-4 w-4 opacity-50"})})]}));J.displayName=ol.displayName;const di=m.forwardRef(({className:s,...n},t)=>e.jsx(cl,{ref:t,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(pc,{className:"h-4 w-4"})}));di.displayName=cl.displayName;const mi=m.forwardRef(({className:s,...n},t)=>e.jsx(dl,{ref:t,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Mn,{className:"h-4 w-4"})}));mi.displayName=dl.displayName;const Q=m.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(fc,{children:e.jsxs(ml,{ref:a,className:_("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(di,{}),e.jsx(jc,{className:_("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(mi,{})]})}));Q.displayName=ml.displayName;const Rm=m.forwardRef(({className:s,...n},t)=>e.jsx(ul,{ref:t,className:_("px-2 py-1.5 text-sm font-semibold",s),...n}));Rm.displayName=ul.displayName;const q=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(xl,{ref:r,className:_("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(vc,{children:e.jsx(yt,{className:"h-4 w-4"})})}),e.jsx(bc,{children:n})]}));q.displayName=xl.displayName;const Em=m.forwardRef(({className:s,...n},t)=>e.jsx(hl,{ref:t,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));Em.displayName=hl.displayName;function ks({className:s,classNames:n,showOutsideDays:t=!0,captionLayout:r="label",buttonVariant:a="ghost",formatters:i,components:l,...d}){const x=gl();return e.jsx(_c,{showOutsideDays:t,className:_("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,s),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...i},classNames:{root:_("w-fit",x.root),months:_("relative flex flex-col gap-4 md:flex-row",x.months),month:_("flex w-full flex-col gap-4",x.month),nav:_("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",x.nav),button_previous:_(Vt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",x.button_previous),button_next:_(Vt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",x.button_next),month_caption:_("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",x.month_caption),dropdowns:_("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",x.dropdowns),dropdown_root:_("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",x.dropdown_root),dropdown:_("absolute inset-0 opacity-0",x.dropdown),caption_label:_("select-none font-medium",r==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",x.caption_label),table:"w-full border-collapse",weekdays:_("flex",x.weekdays),weekday:_("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",x.weekday),week:_("mt-2 flex w-full",x.week),week_number_header:_("w-[--cell-size] select-none",x.week_number_header),week_number:_("text-muted-foreground select-none text-[0.8rem]",x.week_number),day:_("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",x.day),range_start:_("bg-accent rounded-l-md",x.range_start),range_middle:_("rounded-none",x.range_middle),range_end:_("bg-accent rounded-r-md",x.range_end),today:_("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",x.today),outside:_("text-muted-foreground aria-selected:text-muted-foreground",x.outside),disabled:_("text-muted-foreground opacity-50",x.disabled),hidden:_("invisible",x.hidden),...n},components:{Root:({className:u,rootRef:o,...c})=>e.jsx("div",{"data-slot":"calendar",ref:o,className:_(u),...c}),Chevron:({className:u,orientation:o,...c})=>o==="left"?e.jsx(pl,{className:_("size-4",u),...c}):o==="right"?e.jsx(fl,{className:_("size-4",u),...c}):e.jsx(jl,{className:_("size-4",u),...c}),DayButton:Im,WeekNumber:({children:u,...o})=>e.jsx("td",{...o,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:u})}),...l},...d})}function Im({className:s,day:n,modifiers:t,...r}){const a=gl(),i=m.useRef(null);return m.useEffect(()=>{t.focused&&i.current?.focus()},[t.focused]),e.jsx(G,{ref:i,variant:"ghost",size:"icon","data-day":n.date.toLocaleDateString(),"data-selected-single":t.selected&&!t.range_start&&!t.range_end&&!t.range_middle,"data-range-start":t.range_start,"data-range-end":t.range_end,"data-range-middle":t.range_middle,className:_("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",a.day,s),...r})}const es=wc,ss=Cc,We=m.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(Nc,{children:e.jsx(vl,{ref:a,align:n,sideOffset:t,className:_("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})}));We.displayName=vl.displayName;const Qs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Bt=s=>(s/100).toFixed(2),Vm=({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"))?`¥${Bt(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},Mm=[{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"}],Om=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=zs(t,7);break;case"30d":r=zs(t,30);break;case"90d":r=zs(t,90);break;case"180d":r=zs(t,180);break;case"365d":r=zs(t,365);break;default:r=zs(t,30)}return{startDate:r,endDate:t}};function zm(){const[s,n]=m.useState("amount"),[t,r]=m.useState("30d"),[a,i]=m.useState({from:zs(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:x}=Om(t,a),{data:u}=re({queryKey:["orderStat",{start_date:Ee(d,"yyyy-MM-dd"),end_date:Ee(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:o}=await Ia.getOrderStat({start_date:Ee(d,"yyyy-MM-dd"),end_date:Ee(x,"yyyy-MM-dd")});return o},refetchInterval:3e4});return e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Me,{children:l("dashboard:overview.title")}),e.jsxs(st,{children:[u?.summary.start_date," ",l("dashboard:overview.to")," ",u?.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(X,{value:t,onValueChange:o=>r(o),children:[e.jsx(J,{className:"w-[120px]",children:e.jsx(Z,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(Q,{children:Mm.map(o=>e.jsx(q,{value:o.value,children:l(o.label)},o.value))})]}),t==="custom"&&e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Ss,{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:[Ee(a.from,"yyyy-MM-dd")," -"," ",Ee(a.to,"yyyy-MM-dd")]}):Ee(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(ks,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:o=>{o?.from&&o?.to&&i({from:o.from,to:o.to})},captionLayout:"dropdown",numberOfMonths:2})})]})]}),e.jsx(_t,{value:s,onValueChange:o=>n(o),children:e.jsxs(it,{children:[e.jsx(Ge,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(Ge,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(Pe,{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:["¥",Bt(u?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:u?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",Bt(u?.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:["¥",Bt(u?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:u?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",u?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Sc,{width:"100%",height:"100%",children:e.jsxs(kc,{data:u?.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:Qs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Qs.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:Qs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Qs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Tc,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:o=>Ee(new Date(o),"MM-dd",{locale:Lc})}),e.jsx(Dc,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:o=>s==="amount"?`¥${Bt(o)}`:l("dashboard:overview.transactions",{count:o})}),e.jsx(Fc,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Pc,{content:e.jsx(Vm,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(lr,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Qs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(lr,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Qs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(ir,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Qs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(ir,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Qs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function be({className:s,...n}){return e.jsx("div",{className:_("animate-pulse rounded-md bg-primary/10",s),...n})}function $m(){return e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(be,{className:"h-4 w-[120px]"}),e.jsx(be,{className:"h-4 w-4"})]}),e.jsxs(Pe,{children:[e.jsx(be,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx(be,{className:"h-4 w-[100px]"})]})]})]})}function Am(){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($m,{},n))})}var ie=(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))(ie||{});const qt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Ut={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var $s=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))($s||{}),fe=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(fe||{});const pa={0:"待确认",1:"发放中",2:"有效",3:"无效"},fa={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Ze=(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))(Ze||{});const qm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ge=(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.AnyTLS="anytls",s))(ge||{});const Fs=[{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"},{type:"anytls",label:"AnyTLS"}],bs={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50",anytls:"#7E57C2"};var Cs=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Cs||{});const Um={1:"按金额优惠",2:"按比例优惠"};var at=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(at||{}),us=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(us||{}),Zt=(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))(Zt||{});function Xs({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(ke,{className:_("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Me,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(Pe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Vc,{className:_("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:_("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 Hm({className:s}){const n=Ws(),{t}=V(),{data:r,isLoading:a}=re({queryKey:["dashboardStats"],queryFn:async()=>(await Ia.getStatsData()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(Am,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",fe.PENDING.toString()),l.set("status",ie.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Xs,{title:t("dashboard:stats.todayIncome"),value:Ks(r.todayIncome),icon:e.jsx(Rc,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Xs,{title:t("dashboard:stats.monthlyIncome"),value:Ks(r.currentMonthIncome),icon:e.jsx(On,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Xs,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(Ec,{className:_("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(Xs,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(Ic,{className:_("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(Xs,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(Da,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Xs,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(Da,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Xs,{title:t("dashboard:stats.monthlyUpload"),value:Le(r.monthTraffic.upload),icon:e.jsx(Et,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:Le(r.todayTraffic.upload)})}),e.jsx(Xs,{title:t("dashboard:stats.monthlyDownload"),value:Le(r.monthTraffic.download),icon:e.jsx(ta,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:Le(r.todayTraffic.download)})})]})}const vt=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(bl,{ref:r,className:_("relative overflow-hidden",s),...t,children:[e.jsx(Mc,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ma,{}),e.jsx(Oc,{})]}));vt.displayName=bl.displayName;const Ma=m.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(yl,{ref:r,orientation:n,className:_("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(zc,{className:"relative flex-1 rounded-full bg-border"})}));Ma.displayName=yl.displayName;const Fn={today:{getValue:()=>{const s=Ac();return{start:s,end:qc(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:zs(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:zs(s,30),end:s}}},custom:{getValue:()=>null}};function br({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(X,{value:s,onValueChange:t,children:[e.jsx(J,{className:"w-[120px]",children:e.jsx(Z,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(Q,{position:"popper",className:"z-50",children:Object.entries(Fn).map(([l])=>e.jsx(q,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(Ss,{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:[Ee(n.from,"yyyy-MM-dd")," -"," ",Ee(n.to,"yyyy-MM-dd")]}):Ee(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(ks,{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 Dt=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Km({className:s}){const{t:n}=V(),[t,r]=m.useState("today"),[a,i]=m.useState({from:zs(new Date,7),to:new Date}),[l,d]=m.useState("today"),[x,u]=m.useState({from:zs(new Date,7),to:new Date}),o=m.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:Fn[t].getValue(),[t,a]),c=m.useMemo(()=>l==="custom"?{start:x.from,end:x.to}:Fn[l].getValue(),[l,x]),{data:p}=re({queryKey:["nodeTrafficRank",o.start,o.end],queryFn:()=>Ia.getNodeTrafficData({type:"node",start_time:Ie.round(o.start.getTime()/1e3),end_time:Ie.round(o.end.getTime()/1e3)}),refetchInterval:3e4}),{data:F}=re({queryKey:["userTrafficRank",c.start,c.end],queryFn:()=>Ia.getNodeTrafficData({type:"user",start_time:Ie.round(c.start.getTime()/1e3),end_time:Ie.round(c.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(ke,{children:[e.jsx(Fe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Me,{className:"flex items-center text-base font-medium",children:[e.jsx($c,{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(br,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(or,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Pe,{className:"flex-1",children:p?.data?e.jsxs(vt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:p.data.map(T=>e.jsx(pe,{delayDuration:200,children:e.jsxs(ue,{children:[e.jsx(xe,{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:T.name}),e.jsxs("span",{className:_("ml-2 flex items-center text-xs font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?e.jsx(_n,{className:"mr-1 h-3 w-3"}):e.jsx(Nn,{className:"mr-1 h-3 w-3"}),Math.abs(T.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:`${T.value/p.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Dt(T.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:Dt(T.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Dt(T.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?"+":"",T.change,"%"]})]})})]})},T.id))}),e.jsx(Ma,{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(ke,{children:[e.jsx(Fe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Me,{className:"flex items-center text-base font-medium",children:[e.jsx(Da,{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(br,{selectedRange:l,customDateRange:x,onRangeChange:d,onCustomRangeChange:u}),e.jsx(or,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Pe,{className:"flex-1",children:F?.data?e.jsxs(vt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:F.data.map(T=>e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{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:T.name}),e.jsxs("span",{className:_("ml-2 flex items-center text-xs font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?e.jsx(_n,{className:"mr-1 h-3 w-3"}):e.jsx(Nn,{className:"mr-1 h-3 w-3"}),Math.abs(T.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:`${T.value/F.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Dt(T.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:Dt(T.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Dt(T.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",T.change>=0?"text-green-600":"text-red-600"),children:[T.change>=0?"+":"",T.change,"%"]})]})})]})},T.id))}),e.jsx(Ma,{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 Bm=bt("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 U({className:s,variant:n,...t}){return e.jsx("div",{className:_(Bm({variant:n}),s),...t})}const wa=m.forwardRef(({className:s,value:n,...t},r)=>e.jsx(_l,{ref:r,className:_("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(Uc,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));wa.displayName=_l.displayName;const Hn=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:_("w-full caption-bottom text-sm",s),...n})}));Hn.displayName="Table";const Kn=m.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:_("[&_tr]:border-b",s),...n}));Kn.displayName="TableHeader";const Bn=m.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:_("[&_tr:last-child]:border-0",s),...n}));Bn.displayName="TableBody";const Gm=m.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:_("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Gm.displayName="TableFooter";const et=m.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:_("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));et.displayName="TableRow";const Gn=m.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:_("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}));Gn.displayName="TableHead";const Rt=m.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:_("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Rt.displayName="TableCell";const Wm=m.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:_("mt-4 text-sm text-muted-foreground",s),...n}));Wm.displayName="TableCaption";function ui({table:s}){const[n,t]=m.useState(""),{t:r}=V("common");m.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(X,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(J,{className:"h-8 w-[70px]",children:e.jsx(Z,{placeholder:s.getState().pagination.pageSize})}),e.jsx(Q,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx(q,{value:`${i}`,children:i},i))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(D,{type:"text",value:n,onChange:i=>t(i.target.value),onBlur:i=>a(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a(i.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:r("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(L,{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(Hc,{className:"h-4 w-4"})]}),e.jsxs(L,{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(Kc,{className:"h-4 w-4"})]}),e.jsxs(L,{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(Hr,{className:"h-4 w-4"})]}),e.jsxs(L,{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(Bc,{className:"h-4 w-4"})]})]})]})]})}function rs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:x=!0,isLoading:u=!1}){const{t:o}=V("common"),c=m.useRef(null),p=s.getAllColumns().filter(P=>P.getIsPinned()==="left"),F=s.getAllColumns().filter(P=>P.getIsPinned()==="right"),T=P=>p.slice(0,P).reduce((N,I)=>N+(I.getSize()??0),0),C=P=>F.slice(P+1).reduce((N,I)=>N+(I.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:c,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(Hn,{children:[e.jsx(Kn,{children:s.getHeaderGroups().map(P=>e.jsx(et,{className:"hover:bg-transparent",children:P.headers.map((N,I)=>{const y=N.column.getIsPinned()==="left",w=N.column.getIsPinned()==="right",S=y?T(p.indexOf(N.column)):void 0,O=w?C(F.indexOf(N.column)):void 0;return e.jsx(Gn,{colSpan:N.colSpan,style:{width:N.getSize(),...y&&{left:S},...w&&{right:O}},className:_("h-11 bg-card px-4 text-muted-foreground",(y||w)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",y&&"before:right-0",w&&"before:left-0"]),children:N.isPlaceholder?null:Fa(N.column.columnDef.header,N.getContext())},N.id)})},P.id))}),e.jsx(Bn,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((P,N)=>e.jsx(et,{"data-state":P.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:I=>r?.(I,N),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:I=>d?.(I,N),children:P.getVisibleCells().map((I,y)=>{const w=I.column.getIsPinned()==="left",S=I.column.getIsPinned()==="right",O=w?T(p.indexOf(I.column)):void 0,E=S?C(F.indexOf(I.column)):void 0;return e.jsx(Rt,{style:{width:I.column.getSize(),...w&&{left:O},...S&&{right:E}},className:_("bg-card",(w||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",w&&"before:right-0",S&&"before:left-0"]),children:Fa(I.column.columnDef.cell,I.getContext())},I.id)})},P.id)):e.jsx(et,{children:e.jsx(Rt,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:o("table.noData")})})})]})})}),x&&e.jsx(ui,{table:s})]})}const Ca=s=>{if(!s)return"";let n;if(typeof s=="string"){if(n=parseInt(s),isNaN(n))return s}else n=s;return(n.toString().length===10?new Date(n*1e3):new Date(n)).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})},Ht=Nl(),Kt=Nl();function ja({data:s,isLoading:n,searchKeyword:t,selectedLevel:r,total:a,currentPage:i,pageSize:l,onViewDetail:d,onPageChange:x,onPageSizeChange:u}){const{t:o}=V(),c=T=>{switch(T.toLowerCase()){case"info":return e.jsx(Wt,{className:"h-4 w-4 text-blue-500"});case"warning":return e.jsx(Yt,{className:"h-4 w-4 text-yellow-500"});case"error":return e.jsx(Sn,{className:"h-4 w-4 text-red-500"});default:return e.jsx(Wt,{className:"h-4 w-4 text-slate-500"})}},p=m.useMemo(()=>[Ht.accessor("level",{id:"level",header:()=>o("dashboard:systemLog.level"),size:80,cell:({getValue:T,row:C})=>{const P=T();return e.jsxs("div",{className:"flex items-center gap-1",children:[c(P),e.jsx("span",{className:_(P.toLowerCase()==="error"&&"text-red-600",P.toLowerCase()==="warning"&&"text-yellow-600",P.toLowerCase()==="info"&&"text-blue-600"),children:P})]})}}),Ht.accessor("created_at",{id:"created_at",header:()=>o("dashboard:systemLog.time"),size:160,cell:({getValue:T})=>Ca(T())}),Ht.accessor(T=>T.title||T.message||"",{id:"title",header:()=>o("dashboard:systemLog.logTitle"),cell:({getValue:T})=>e.jsx("span",{className:"inline-block max-w-[300px] truncate",children:T()})}),Ht.accessor("method",{id:"method",header:()=>o("dashboard:systemLog.method"),size:100,cell:({getValue:T})=>{const C=T();return C?e.jsx(U,{variant:"outline",className:_(C==="GET"&&"border-blue-200 bg-blue-50 text-blue-700",C==="POST"&&"border-green-200 bg-green-50 text-green-700",C==="PUT"&&"border-amber-200 bg-amber-50 text-amber-700",C==="DELETE"&&"border-red-200 bg-red-50 text-red-700"),children:C}):null}}),Ht.display({id:"actions",header:()=>o("dashboard:systemLog.action"),size:80,cell:({row:T})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>d(T.original),"aria-label":o("dashboard:systemLog.viewDetail"),children:e.jsx(wn,{className:"h-4 w-4"})})})],[o,d]),F=Ye({data:s,columns:p,getCoreRowModel:Je(),getPaginationRowModel:ts(),pageCount:Math.ceil(a/l),manualPagination:!0,state:{pagination:m.useMemo(()=>({pageIndex:i-1,pageSize:l}),[i,l])},onPaginationChange:T=>{let C,P;if(typeof T=="function"){const N=T({pageIndex:i-1,pageSize:l});C=N.pageIndex,P=N.pageSize}else C=T.pageIndex,P=T.pageSize;P!==l?u(P):x(C+1)}});return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(rs,{table:F,showPagination:!0,isLoading:n}),(t||r&&r!=="all")&&e.jsx("div",{className:"text-center text-sm text-muted-foreground",children:t&&r&&r!=="all"?o("dashboard:systemLog.filter.searchAndLevel",{keyword:t,level:r,count:a}):t?o("dashboard:systemLog.filter.searchOnly",{keyword:t,count:a}):o("dashboard:systemLog.filter.levelOnly",{level:r,count:a})})]})}function Ym(){const{t:s}=V(),[n,t]=m.useState(0),[r,a]=m.useState(!1),[i,l]=m.useState(1),[d]=m.useState(10),[x,u]=m.useState(null),[o,c]=m.useState(!1),[p,F]=m.useState(!1),[T,C]=m.useState(1),[P,N]=m.useState(10),[I,y]=m.useState(null),[w,S]=m.useState(!1),[O,E]=m.useState(""),[g,k]=m.useState(""),[W,te]=m.useState("all"),[ae,B]=m.useState(!1),[se,je]=m.useState(0),[ms,ze]=m.useState("all"),[le,Ts]=m.useState(1e3),[Ns,dt]=m.useState(!1),[Is,mt]=m.useState(null),[ut,xt]=m.useState(!1);m.useEffect(()=>{const Y=setTimeout(()=>{k(O),O!==g&&C(1)},500);return()=>clearTimeout(Y)},[O]);const{data:K,isLoading:H,refetch:_e,isRefetching:Ae}=re({queryKey:["systemStatus",n],queryFn:async()=>(await ye.getSystemStatus()).data,refetchInterval:3e4}),{data:Ne,isLoading:Bi,refetch:mp,isRefetching:Zn}=re({queryKey:["queueStats",n],queryFn:async()=>(await ye.getQueueStats()).data,refetchInterval:3e4}),{data:er,isLoading:Gi,refetch:Wi}=re({queryKey:["failedJobs",i,d],queryFn:async()=>{const Y=await ye.getHorizonFailedJobs({current:i,page_size:d});return{data:Y.data,total:Y.total||0}},enabled:r}),{data:sr,isLoading:ia,refetch:Yi}=re({queryKey:["systemLogs",T,P,W,g],queryFn:async()=>{const Y={current:T,page_size:P};W&&W!=="all"&&(Y.level=W),g.trim()&&(Y.keyword=g.trim());const Vs=await ye.getSystemLog(Y);return{data:Vs.data,total:Vs.total||0}},enabled:p}),tr=er?.data||[],Ji=er?.total||0,oa=sr?.data||[],ca=sr?.total||0,Qi=m.useMemo(()=>[Kt.display({id:"failed_at",header:()=>s("dashboard:queue.details.time"),cell:({row:Y})=>Ca(Y.original.failed_at)}),Kt.display({id:"queue",header:()=>s("dashboard:queue.details.queue"),cell:({row:Y})=>Y.original.queue}),Kt.display({id:"name",header:()=>s("dashboard:queue.details.name"),cell:({row:Y})=>e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[150px] truncate",children:Y.original.name})}),e.jsx(ce,{children:e.jsx("span",{children:Y.original.name})})]})})}),Kt.display({id:"exception",header:()=>s("dashboard:queue.details.exception"),cell:({row:Y})=>e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[200px] truncate",children:Y.original.exception.split(` +`)[0]})}),e.jsx(ce,{className:"max-w-[300px] whitespace-pre-wrap",children:e.jsx("span",{children:Y.original.exception})})]})})}),Kt.display({id:"actions",header:()=>s("dashboard:queue.details.action"),size:80,cell:({row:Y})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>so(Y.original),"aria-label":s("dashboard:queue.details.viewDetail"),children:e.jsx(wn,{className:"h-4 w-4"})})})],[s]),ar=Ye({data:tr,columns:Qi,getCoreRowModel:Je(),getPaginationRowModel:ts(),pageCount:Math.ceil(Ji/d),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:d}},onPaginationChange:Y=>{if(typeof Y=="function"){const Vs=Y({pageIndex:i-1,pageSize:d});nr(Vs.pageIndex+1)}else nr(Y.pageIndex+1)}}),Xi=()=>{t(Y=>Y+1)},nr=Y=>{l(Y)},da=Y=>{C(Y)},ma=Y=>{N(Y),C(1)},Zi=Y=>{te(Y),C(1)},eo=()=>{E(""),k(""),te("all"),C(1)},ua=Y=>{y(Y),S(!0)},so=Y=>{u(Y),c(!0)},to=async()=>{try{const Y=await ye.getLogClearStats({days:se,level:ms==="all"?void 0:ms});mt(Y.data),xt(!0)}catch(Y){console.error("Failed to get clear stats:",Y),$.error(s("dashboard:systemLog.getStatsFailed"))}},ao=async()=>{dt(!0);try{const{data:Y}=await ye.clearSystemLog({days:se,level:ms==="all"?void 0:ms,limit:le});Y&&($.success(s("dashboard:systemLog.clearSuccess",{count:Y.cleared_count}),{duration:3e3}),B(!1),xt(!1),mt(null),_e())}catch(Y){console.error("Failed to clear logs:",Y),$.error(s("dashboard:systemLog.clearLogsFailed"))}finally{dt(!1)}};if(H||Bi)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Pa,{className:"h-6 w-6 animate-spin"})});const no=Y=>Y?e.jsx(wl,{className:"h-5 w-5 text-green-500"}):e.jsx(Cl,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(Gc,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(st,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:Xi,disabled:Ae||Zn,children:e.jsx(dn,{className:_("h-4 w-4",(Ae||Zn)&&"animate-spin")})})]}),e.jsx(Pe,{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:[no(Ne?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(U,{variant:Ne?.status?"secondary":"destructive",children:Ne?.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:Ne?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{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:Ne?.recentJobs||0}),e.jsx(wa,{value:(Ne?.recentJobs||0)/(Ne?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:Ne?.periods?.recentJobs||0})})})]})}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{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:Ne?.jobsPerMinute||0}),e.jsx(wa,{value:(Ne?.jobsPerMinute||0)/(Ne?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:Ne?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(Wc,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(st,{children:s("dashboard:queue.details.description")})]}),e.jsx(Pe,{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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"cursor-pointer text-2xl font-bold text-destructive hover:underline",title:s("dashboard:queue.details.viewFailedJobs"),onClick:()=>a(!0),style:{userSelect:"none"},children:Ne?.failedJobs||0}),e.jsx(wn,{className:"h-4 w-4 cursor-pointer text-muted-foreground hover:text-destructive",onClick:()=>a(!0),"aria-label":s("dashboard:queue.details.viewFailedJobs")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:Ne?.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:[Ne?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:Ne?.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:[Ne?.processes||0," /"," ",(Ne?.processes||0)+(Ne?.pausedMasters||0)]})]}),e.jsx(wa,{value:(Ne?.processes||0)/((Ne?.processes||0)+(Ne?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Me,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-5 w-5"}),s("dashboard:systemLog.title")]}),e.jsx(st,{children:s("dashboard:systemLog.description")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>F(!0),children:s("dashboard:systemLog.viewAll")}),e.jsxs(G,{variant:"outline",onClick:()=>B(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(xs,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.clearLogs")]})]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-900 dark:bg-blue-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"h-5 w-5 text-blue-500"}),e.jsx("p",{className:"font-medium text-blue-700 dark:text-blue-300",children:s("dashboard:systemLog.tabs.info")})]}),e.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:K?.logs?.info||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-900 dark:bg-yellow-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-5 w-5 text-yellow-500"}),e.jsx("p",{className:"font-medium text-yellow-700 dark:text-yellow-300",children:s("dashboard:systemLog.tabs.warning")})]}),e.jsx("p",{className:"text-2xl font-bold text-yellow-700 dark:text-yellow-300",children:K?.logs?.warning||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-900 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5 text-red-500"}),e.jsx("p",{className:"font-medium text-red-700 dark:text-red-300",children:s("dashboard:systemLog.tabs.error")})]}),e.jsx("p",{className:"text-2xl font-bold text-red-700 dark:text-red-300",children:K?.logs?.error||0})]})]}),K?.logs&&K.logs.total>0&&e.jsxs("div",{className:"mt-3 text-center text-sm text-muted-foreground",children:[s("dashboard:systemLog.totalLogs"),": ",K.logs.total]})]})})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.failedJobsDetailTitle")})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(rs,{table:ar,showPagination:!1,isLoading:Gi}),e.jsx(ui,{table:ar}),tr.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:s("dashboard:queue.details.noFailedJobs")})]}),e.jsxs(Oe,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Wi(),children:[e.jsx(dn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(tt,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:o,onOpenChange:c,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.jobDetailTitle")})}),x&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.id")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:x.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.time")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:x.failed_at})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.queue")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:x.queue})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.connection")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:x.connection})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.name")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:x.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.exception")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-red-700 dark:text-red-300",children:x.exception})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.payload")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(x.payload),null,2)}catch{return x.payload}})()})})]})]}),e.jsx(Oe,{children:e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:s("common:close")})})]})}),e.jsx(de,{open:p,onOpenChange:F,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.title")})}),e.jsxs(_t,{value:W,onValueChange:Zi,className:"w-full overflow-x-auto",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 p-1 md:flex-row md:items-center md:justify-between",children:[e.jsxs(it,{className:"grid w-auto grid-cols-4",children:[e.jsxs(Ge,{value:"all",className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4"}),s("dashboard:systemLog.tabs.all")]}),e.jsxs(Ge,{value:"info",className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"h-4 w-4 text-blue-500"}),s("dashboard:systemLog.tabs.info")]}),e.jsxs(Ge,{value:"warning",className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-yellow-500"}),s("dashboard:systemLog.tabs.warning")]}),e.jsxs(Ge,{value:"error",className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-red-500"}),s("dashboard:systemLog.tabs.error")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(D,{placeholder:s("dashboard:systemLog.search"),value:O,onChange:Y=>E(Y.target.value),className:"w-full md:w-64"})]})]}),e.jsx(ys,{value:"all",className:"mt-0",children:e.jsx(ja,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})}),e.jsx(ys,{value:"info",className:"mt-0 overflow-x-auto",children:e.jsx(ja,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})}),e.jsx(ys,{value:"warning",className:"mt-0",children:e.jsx(ja,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})}),e.jsx(ys,{value:"error",className:"mt-0",children:e.jsx(ja,{data:oa,isLoading:ia,searchKeyword:g,selectedLevel:W,total:ca,currentPage:T,pageSize:P,onViewDetail:ua,onPageChange:da,onPageSizeChange:ma})})]}),e.jsxs(Oe,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Yi(),children:[e.jsx(dn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(G,{variant:"outline",onClick:eo,children:s("dashboard:systemLog.filter.reset")}),e.jsx(tt,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:w,onOpenChange:S,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.detailTitle")})}),I&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.level")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Wt,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:I.level})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.time")}),e.jsx("p",{children:Ca(I.created_at)||Ca(I.updated_at)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.logTitle")}),e.jsx("div",{className:"whitespace-pre-wrap rounded-md bg-muted/50 p-3",children:I.title||I.message||""})]}),(I.host||I.ip)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[I.host&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.host")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:I.host})]}),I.ip&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.ip")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:I.ip})]})]}),I.uri&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.uri")}),e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 p-3",children:e.jsx("code",{className:"text-sm",children:I.uri})})]}),I.method&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.method")}),e.jsx("div",{children:e.jsx(U,{variant:"outline",className:"text-base font-medium",children:I.method})})]}),I.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.requestData")}),e.jsx("div",{className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(I.data),null,2)}catch{return I.data}})()})})]}),I.context&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.exception")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs text-red-700 dark:text-red-300",children:(()=>{try{const Y=JSON.parse(I.context);if(Y.exception){const Vs=Y.exception,wt=Vs["\0*\0message"]||"",ro=Vs["\0*\0file"]||"",lo=Vs["\0*\0line"]||"";return`${wt} File: ${ro} -Line: ${lo}`}return JSON.stringify(Y,null,2)}catch{return I.context}})()})})]})]}),e.jsx(Oe,{children:e.jsx(st,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})})]})}),e.jsx(de,{open:ae,onOpenChange:B,children:e.jsxs(oe,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(xs,{className:"h-5 w-5 text-destructive"}),s("dashboard:systemLog.clearLogs")]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"clearDays",children:s("dashboard:systemLog.clearDays")}),e.jsx(D,{id:"clearDays",type:"number",min:"0",max:"365",value:se,onChange:Y=>{const Vs=Y.target.value;if(Vs==="")je(0);else{const Nt=parseInt(Vs);!isNaN(Nt)&&Nt>=0&&Nt<=365&&je(Nt)}},placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearDaysDesc")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"clearLevel",children:s("dashboard:systemLog.clearLevel")}),e.jsxs(X,{value:ms,onValueChange:ze,children:[e.jsx(J,{children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:s("dashboard:systemLog.tabs.all")}),e.jsx(q,{value:"info",children:s("dashboard:systemLog.tabs.info")}),e.jsx(q,{value:"warning",children:s("dashboard:systemLog.tabs.warning")}),e.jsx(q,{value:"error",children:s("dashboard:systemLog.tabs.error")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"clearLimit",children:s("dashboard:systemLog.clearLimit")}),e.jsx(D,{id:"clearLimit",type:"number",min:"100",max:"10000",value:le,onChange:Y=>Ts(parseInt(Y.target.value)||1e3),placeholder:"1000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearLimitDesc")})]})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5 text-amber-600"}),e.jsx("span",{className:"font-medium text-amber-800 dark:text-amber-200",children:s("dashboard:systemLog.clearPreview")})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:to,disabled:Ns,children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.getStats")]})]}),mt&&Is&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.cutoffDate")}),e.jsx("p",{className:"font-mono text-sm",children:Is.cutoff_date})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.totalLogs")}),e.jsx("p",{className:"font-mono text-sm font-medium",children:Is.total_logs.toLocaleString()})]})]}),e.jsxs("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-red-600"}),e.jsxs("span",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:[s("dashboard:systemLog.willClear"),":",e.jsx("span",{className:"ml-1 font-bold",children:Is.logs_to_clear.toLocaleString()}),s("dashboard:systemLog.logsUnit")]})]}),e.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-300",children:s("dashboard:systemLog.clearWarning")})]})]})]})]}),e.jsxs(Oe,{children:[e.jsx(G,{variant:"outline",onClick:()=>{B(!1),ut(!1),dt(null)},children:s("common:cancel")}),e.jsx(G,{variant:"destructive",onClick:ao,disabled:Ns||!mt||!Is,children:Ns?e.jsxs(e.Fragment,{children:[e.jsx(Fa,{className:"mr-2 h-4 w-4 animate-spin"}),s("dashboard:systemLog.clearing")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.confirmClear")]})})]})]})})]})}function Jm(){const{t:s}=V();return e.jsxs(Ue,{children:[e.jsxs(He,{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(ds,{}),e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsx(Qe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Hm,{}),e.jsx(zm,{}),e.jsx(Km,{}),e.jsx(Ym,{})]})})})]})}const Qm=Object.freeze(Object.defineProperty({__proto__:null,default:Jm},Symbol.toStringTag,{value:"Module"}));function Xm({className:s,items:n,...t}){const{pathname:r}=Pn(),a=Ws(),[o,l]=m.useState(r??"/settings"),d=u=>{l(u),a(u)},{t:x}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(X,{value:o,onValueChange:d,children:[e.jsx(J,{className:"h-12 sm:w-48",children:e.jsx(Z,{placeholder:"Theme"})}),e.jsx(Q,{children:n.map(u=>e.jsx(q,{value:u.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:u.icon}),e.jsx("span",{className:"text-md",children:x(u.title)})]})},u.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:_("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(u=>e.jsxs(Bs,{to:u.href,className:_(Mt({variant:"ghost"}),r===u.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:u.icon}),x(u.title)]},u.href))})})]})}const Zm=[{title:"site.title",key:"site",icon:e.jsx(Yc,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(al,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(nl,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Jc,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(tl,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Qc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Xc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(sl,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(Zc,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function eu(){const{t:s}=V("settings");return e.jsxs(Ue,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Re,{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(Xm,{items:Zm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(Ln,{})})})]})]})]})}const su=Object.freeze(Object.defineProperty({__proto__:null,default:eu},Symbol.toStringTag,{value:"Module"})),ee=m.forwardRef(({className:s,...n},t)=>e.jsx(Sl,{className:_("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(ed,{className:_("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));ee.displayName=Sl.displayName;const Es=m.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:_("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}));Es.displayName="Textarea";const tu=h.object({logo:h.string().nullable().default(""),force_https:h.number().nullable().default(0),stop_register:h.number().nullable().default(0),app_name:h.string().nullable().default(""),app_description:h.string().nullable().default(""),app_url:h.string().nullable().default(""),subscribe_url:h.string().nullable().default(""),try_out_plan_id:h.number().nullable().default(0),try_out_hour:h.coerce.number().nullable().default(0),tos_url:h.string().nullable().default(""),currency:h.string().nullable().default(""),currency_symbol:h.string().nullable().default("")});function au(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),{data:a}=re({queryKey:["settings","site"],queryFn:()=>ye.getSettings("site")}),{data:o}=re({queryKey:["plans"],queryFn:()=>_s.getList()}),l=Ce({resolver:Te(tu),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=As({mutationFn:ye.saveSettings,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(a?.data?.site){const i=a?.data?.site;Object.entries(i).forEach(([c,p])=>{l.setValue(c,p)}),r.current=i}},[a]);const x=m.useCallback(Ie.debounce(async i=>{if(!Ie.isEqual(i,r.current)){t(!0);try{const c=Object.entries(i).reduce((p,[F,T])=>(p[F]=T===null?"":T,p),{});await d(c),r.current=i}finally{t(!1)}}},1e3),[d]),u=m.useCallback(i=>{x(i)},[x]);return m.useEffect(()=>{const i=l.watch(c=>{u(c)});return()=>i.unsubscribe()},[l.watch,u]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:l.control,name:"app_name",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.siteName.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"app_description",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.siteDescription.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"app_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.siteUrl.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"force_https",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(A,{children:s("site.form.forceHttps.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:!!i.value,onCheckedChange:c=>{i.onChange(Number(c)),u(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"logo",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.logo.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"subscribe_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(b,{children:e.jsx(Es,{placeholder:s("site.form.subscribeUrl.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.subscribeUrl.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"tos_url",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.tosUrl.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"stop_register",render:({field:i})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(A,{children:s("site.form.stopRegister.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:!!i.value,onCheckedChange:c=>{i.onChange(Number(c)),u(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"try_out_plan_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(b,{children:e.jsxs(X,{value:i.value?.toString(),onValueChange:c=>{i.onChange(Number(c)),u(l.getValues())},children:[e.jsx(J,{children:e.jsx(Z,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("site.form.tryOut.placeholder")}),o?.data?.map(c=>e.jsx(q,{value:c.id.toString(),children:c.name},c.id.toString()))]})]})}),e.jsx(A,{children:s("site.form.tryOut.description")}),e.jsx(R,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(j,{control:l.control,name:"try_out_hour",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.tryOut.duration.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"currency",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.currency.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"currency_symbol",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...i,value:i.value||"",onChange:c=>{i.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.currencySymbol.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function nu(){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(Re,{}),e.jsx(au,{})]})}const ru=Object.freeze(Object.defineProperty({__proto__:null,default:nu},Symbol.toStringTag,{value:"Module"})),lu=h.object({email_verify:h.boolean().nullable(),safe_mode_enable:h.boolean().nullable(),secure_path:h.string().nullable(),email_whitelist_enable:h.boolean().nullable(),email_whitelist_suffix:h.array(h.string().nullable()).nullable(),email_gmail_limit_enable:h.boolean().nullable(),captcha_enable:h.boolean().nullable(),captcha_type:h.string().nullable(),recaptcha_key:h.string().nullable(),recaptcha_site_key:h.string().nullable(),recaptcha_v3_secret_key:h.string().nullable(),recaptcha_v3_site_key:h.string().nullable(),recaptcha_v3_score_threshold:h.coerce.string().transform(s=>s===""?null:s).nullable(),turnstile_secret_key:h.string().nullable(),turnstile_site_key:h.string().nullable(),register_limit_by_ip_enable:h.boolean().nullable(),register_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:h.boolean().nullable(),password_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:h.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,captcha_enable:!1,captcha_type:"recaptcha",recaptcha_key:"",recaptcha_site_key:"",recaptcha_v3_secret_key:"",recaptcha_v3_site_key:"",recaptcha_v3_score_threshold:"0.5",turnstile_secret_key:"",turnstile_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 ou(){const{t:s}=V("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),o=m.useRef(null),l=Ce({resolver:Te(lu),defaultValues:iu,mode:"onBlur"}),{data:d}=re({queryKey:["settings","safe"],queryFn:()=>ye.getSettings("safe")}),{mutateAsync:x}=As({mutationFn:ye.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data.safe){const c=d.data.safe,p={};Object.entries(c).forEach(([F,T])=>{if(typeof T=="number"){const C=String(T);l.setValue(F,C),p[F]=C}else l.setValue(F,T),p[F]=T}),o.current=p,a(!0)}},[d]);const u=m.useCallback(Ie.debounce(async c=>{if(!Ie.isEqual(c,o.current)){t(!0);try{const p={...c,email_whitelist_suffix:c.email_whitelist_suffix?.filter(Boolean)||[]};await x(p),o.current=c}finally{t(!1)}}},1e3),[x]),i=m.useCallback(c=>{r&&u(c)},[u,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(p=>{i(p)});return()=>c.unsubscribe()},[l.watch,i,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:l.control,name:"email_verify",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(A,{children:s("safe.form.emailVerify.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"email_gmail_limit_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(A,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"safe_mode_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(A,{children:s("safe.form.safeMode.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"secure_path",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.securePath.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"email_whitelist_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(A,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),l.watch("email_whitelist_enable")&&e.jsx(j,{control:l.control,name:"email_whitelist_suffix",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(b,{children:e.jsx(Es,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...c,value:(c.value||[]).join(` +Line: ${lo}`}return JSON.stringify(Y,null,2)}catch{return I.context}})()})})]})]}),e.jsx(Oe,{children:e.jsx(tt,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})})]})}),e.jsx(de,{open:ae,onOpenChange:B,children:e.jsxs(oe,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(xs,{className:"h-5 w-5 text-destructive"}),s("dashboard:systemLog.clearLogs")]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"clearDays",children:s("dashboard:systemLog.clearDays")}),e.jsx(D,{id:"clearDays",type:"number",min:"0",max:"365",value:se,onChange:Y=>{const Vs=Y.target.value;if(Vs==="")je(0);else{const wt=parseInt(Vs);!isNaN(wt)&&wt>=0&&wt<=365&&je(wt)}},placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearDaysDesc")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"clearLevel",children:s("dashboard:systemLog.clearLevel")}),e.jsxs(X,{value:ms,onValueChange:ze,children:[e.jsx(J,{children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:s("dashboard:systemLog.tabs.all")}),e.jsx(q,{value:"info",children:s("dashboard:systemLog.tabs.info")}),e.jsx(q,{value:"warning",children:s("dashboard:systemLog.tabs.warning")}),e.jsx(q,{value:"error",children:s("dashboard:systemLog.tabs.error")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"clearLimit",children:s("dashboard:systemLog.clearLimit")}),e.jsx(D,{id:"clearLimit",type:"number",min:"100",max:"10000",value:le,onChange:Y=>Ts(parseInt(Y.target.value)||1e3),placeholder:"1000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearLimitDesc")})]})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-5 w-5 text-amber-600"}),e.jsx("span",{className:"font-medium text-amber-800 dark:text-amber-200",children:s("dashboard:systemLog.clearPreview")})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:to,disabled:Ns,children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.getStats")]})]}),ut&&Is&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.cutoffDate")}),e.jsx("p",{className:"font-mono text-sm",children:Is.cutoff_date})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.totalLogs")}),e.jsx("p",{className:"font-mono text-sm font-medium",children:Is.total_logs.toLocaleString()})]})]}),e.jsxs("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-red-600"}),e.jsxs("span",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:[s("dashboard:systemLog.willClear"),":",e.jsx("span",{className:"ml-1 font-bold",children:Is.logs_to_clear.toLocaleString()}),s("dashboard:systemLog.logsUnit")]})]}),e.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-300",children:s("dashboard:systemLog.clearWarning")})]})]})]})]}),e.jsxs(Oe,{children:[e.jsx(G,{variant:"outline",onClick:()=>{B(!1),xt(!1),mt(null)},children:s("common:cancel")}),e.jsx(G,{variant:"destructive",onClick:ao,disabled:Ns||!ut||!Is,children:Ns?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"mr-2 h-4 w-4 animate-spin"}),s("dashboard:systemLog.clearing")]}):e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.confirmClear")]})})]})]})})]})}function Jm(){const{t:s}=V();return e.jsxs(He,{children:[e.jsxs(Ke,{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(ds,{}),e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsx(Qe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Hm,{}),e.jsx(zm,{}),e.jsx(Km,{}),e.jsx(Ym,{})]})})})]})}const Qm=Object.freeze(Object.defineProperty({__proto__:null,default:Jm},Symbol.toStringTag,{value:"Module"}));function Xm({className:s,items:n,...t}){const{pathname:r}=Ln(),a=Ws(),[i,l]=m.useState(r??"/settings"),d=u=>{l(u),a(u)},{t:x}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(X,{value:i,onValueChange:d,children:[e.jsx(J,{className:"h-12 sm:w-48",children:e.jsx(Z,{placeholder:"Theme"})}),e.jsx(Q,{children:n.map(u=>e.jsx(q,{value:u.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:u.icon}),e.jsx("span",{className:"text-md",children:x(u.title)})]})},u.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:_("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(u=>e.jsxs(Bs,{to:u.href,className:_(Mt({variant:"ghost"}),r===u.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:u.icon}),x(u.title)]},u.href))})})]})}const Zm=[{title:"site.title",key:"site",icon:e.jsx(Yc,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(al,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(nl,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Jc,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(tl,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Qc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Xc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(sl,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(Zc,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function eu(){const{t:s}=V("settings");return e.jsxs(He,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Re,{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(Xm,{items:Zm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(Rn,{})})})]})]})]})}const su=Object.freeze(Object.defineProperty({__proto__:null,default:eu},Symbol.toStringTag,{value:"Module"})),ee=m.forwardRef(({className:s,...n},t)=>e.jsx(Sl,{className:_("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(ed,{className:_("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));ee.displayName=Sl.displayName;const Es=m.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:_("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}));Es.displayName="Textarea";const tu=h.object({logo:h.string().nullable().default(""),force_https:h.number().nullable().default(0),stop_register:h.number().nullable().default(0),app_name:h.string().nullable().default(""),app_description:h.string().nullable().default(""),app_url:h.string().nullable().default(""),subscribe_url:h.string().nullable().default(""),try_out_plan_id:h.number().nullable().default(0),try_out_hour:h.coerce.number().nullable().default(0),tos_url:h.string().nullable().default(""),currency:h.string().nullable().default(""),currency_symbol:h.string().nullable().default("")});function au(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),{data:a}=re({queryKey:["settings","site"],queryFn:()=>ye.getSettings("site")}),{data:i}=re({queryKey:["plans"],queryFn:()=>_s.getList()}),l=Ce({resolver:Te(tu),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=As({mutationFn:ye.saveSettings,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(a?.data?.site){const o=a?.data?.site;Object.entries(o).forEach(([c,p])=>{l.setValue(c,p)}),r.current=o}},[a]);const x=m.useCallback(Ie.debounce(async o=>{if(!Ie.isEqual(o,r.current)){t(!0);try{const c=Object.entries(o).reduce((p,[F,T])=>(p[F]=T===null?"":T,p),{});await d(c),r.current=o}finally{t(!1)}}},1e3),[d]),u=m.useCallback(o=>{x(o)},[x]);return m.useEffect(()=>{const o=l.watch(c=>{u(c)});return()=>o.unsubscribe()},[l.watch,u]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:l.control,name:"app_name",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.siteName.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"app_description",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.siteDescription.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"app_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.siteUrl.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"force_https",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(A,{children:s("site.form.forceHttps.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:!!o.value,onCheckedChange:c=>{o.onChange(Number(c)),u(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"logo",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.logo.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"subscribe_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(b,{children:e.jsx(Es,{placeholder:s("site.form.subscribeUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.subscribeUrl.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"tos_url",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.tosUrl.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"stop_register",render:({field:o})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(A,{children:s("site.form.stopRegister.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:!!o.value,onCheckedChange:c=>{o.onChange(Number(c)),u(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"try_out_plan_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(b,{children:e.jsxs(X,{value:o.value?.toString(),onValueChange:c=>{o.onChange(Number(c)),u(l.getValues())},children:[e.jsx(J,{children:e.jsx(Z,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(c=>e.jsx(q,{value:c.id.toString(),children:c.name},c.id.toString()))]})]})}),e.jsx(A,{children:s("site.form.tryOut.description")}),e.jsx(R,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(j,{control:l.control,name:"try_out_hour",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.tryOut.duration.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"currency",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.currency.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"currency_symbol",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(l.getValues())}})}),e.jsx(A,{children:s("site.form.currencySymbol.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function nu(){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(Re,{}),e.jsx(au,{})]})}const ru=Object.freeze(Object.defineProperty({__proto__:null,default:nu},Symbol.toStringTag,{value:"Module"})),lu=h.object({email_verify:h.boolean().nullable(),safe_mode_enable:h.boolean().nullable(),secure_path:h.string().nullable(),email_whitelist_enable:h.boolean().nullable(),email_whitelist_suffix:h.array(h.string().nullable()).nullable(),email_gmail_limit_enable:h.boolean().nullable(),captcha_enable:h.boolean().nullable(),captcha_type:h.string().nullable(),recaptcha_key:h.string().nullable(),recaptcha_site_key:h.string().nullable(),recaptcha_v3_secret_key:h.string().nullable(),recaptcha_v3_site_key:h.string().nullable(),recaptcha_v3_score_threshold:h.coerce.string().transform(s=>s===""?null:s).nullable(),turnstile_secret_key:h.string().nullable(),turnstile_site_key:h.string().nullable(),register_limit_by_ip_enable:h.boolean().nullable(),register_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:h.boolean().nullable(),password_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:h.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,captcha_enable:!1,captcha_type:"recaptcha",recaptcha_key:"",recaptcha_site_key:"",recaptcha_v3_secret_key:"",recaptcha_v3_site_key:"",recaptcha_v3_score_threshold:"0.5",turnstile_secret_key:"",turnstile_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 ou(){const{t:s}=V("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),i=m.useRef(null),l=Ce({resolver:Te(lu),defaultValues:iu,mode:"onBlur"}),{data:d}=re({queryKey:["settings","safe"],queryFn:()=>ye.getSettings("safe")}),{mutateAsync:x}=As({mutationFn:ye.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data.safe){const c=d.data.safe,p={};Object.entries(c).forEach(([F,T])=>{if(typeof T=="number"){const C=String(T);l.setValue(F,C),p[F]=C}else l.setValue(F,T),p[F]=T}),i.current=p,a(!0)}},[d]);const u=m.useCallback(Ie.debounce(async c=>{if(!Ie.isEqual(c,i.current)){t(!0);try{const p={...c,email_whitelist_suffix:c.email_whitelist_suffix?.filter(Boolean)||[]};await x(p),i.current=c}finally{t(!1)}}},1e3),[x]),o=m.useCallback(c=>{r&&u(c)},[u,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(p=>{o(p)});return()=>c.unsubscribe()},[l.watch,o,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:l.control,name:"email_verify",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(A,{children:s("safe.form.emailVerify.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"email_gmail_limit_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(A,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"safe_mode_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(A,{children:s("safe.form.safeMode.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"secure_path",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.securePath.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"email_whitelist_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(A,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),l.watch("email_whitelist_enable")&&e.jsx(j,{control:l.control,name:"email_whitelist_suffix",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(b,{children:e.jsx(Es,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...c,value:(c.value||[]).join(` `),onChange:p=>{const F=p.target.value.split(` -`).filter(Boolean);c.onChange(F),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"captcha_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.enable.label")}),e.jsx(A,{children:s("safe.form.captcha.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),l.watch("captcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"captcha_type",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.type.label")}),e.jsxs(X,{onValueChange:p=>{c.onChange(p),i(l.getValues())},value:c.value||"recaptcha",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:s("safe.form.captcha.type.description")})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"recaptcha",children:s("safe.form.captcha.type.options.recaptcha")}),e.jsx(q,{value:"recaptcha-v3",children:s("safe.form.captcha.type.options.recaptcha-v3")}),e.jsx(q,{value:"turnstile",children:s("safe.form.captcha.type.options.turnstile")})]})]}),e.jsx(A,{children:s("safe.form.captcha.type.description")}),e.jsx(R,{})]})}),l.watch("captcha_type")==="recaptcha"&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"recaptcha_site_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha.siteKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"recaptcha_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha.key.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha.key.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha.key.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="recaptcha-v3"&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"recaptcha_v3_site_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha_v3.siteKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha_v3.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"recaptcha_v3_secret_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.secretKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha_v3.secretKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha_v3.secretKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"recaptcha_v3_score_threshold",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",step:"0.1",min:"0",max:"1",placeholder:s("safe.form.captcha.recaptcha_v3.scoreThreshold.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="turnstile"&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"turnstile_site_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.turnstile.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.turnstile.siteKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.turnstile.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"turnstile_secret_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.turnstile.secretKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.turnstile.secretKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.turnstile.secretKey.description")}),e.jsx(R,{})]})})]})]}),e.jsx(j,{control:l.control,name:"register_limit_by_ip_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(A,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),l.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"register_limit_count",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.registerLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"register_limit_expire",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(R,{})]})})]}),e.jsx(j,{control:l.control,name:"password_limit_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(A,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),l.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"password_limit_count",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"password_limit_expire",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),i(l.getValues())}})}),e.jsx(A,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function cu(){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(Re,{}),e.jsx(ou,{})]})}const du=Object.freeze(Object.defineProperty({__proto__:null,default:cu},Symbol.toStringTag,{value:"Module"})),mu=h.object({plan_change_enable:h.boolean().nullable().default(!1),reset_traffic_method:h.coerce.number().nullable().default(0),surplus_enable:h.boolean().nullable().default(!1),new_order_event_id:h.coerce.number().nullable().default(0),renew_order_event_id:h.coerce.number().nullable().default(0),change_order_event_id:h.coerce.number().nullable().default(0),show_info_to_server_enable:h.boolean().nullable().default(!1),show_protocol_to_server_enable:h.boolean().nullable().default(!1),default_remind_expire:h.boolean().nullable().default(!1),default_remind_traffic:h.boolean().nullable().default(!1),subscribe_path:h.string().nullable().default("s")}),uu={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 xu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(mu),defaultValues:uu,mode:"onBlur"}),{data:o}=re({queryKey:["settings","subscribe"],queryFn:()=>ye.getSettings("subscribe")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:u=>{u.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(o?.data?.subscribe){const u=o?.data?.subscribe;Object.entries(u).forEach(([i,c])=>{a.setValue(i,c)}),r.current=u}},[o]);const d=m.useCallback(Ie.debounce(async u=>{if(!Ie.isEqual(u,r.current)){t(!0);try{await l(u),r.current=u}finally{t(!1)}}},1e3),[l]),x=m.useCallback(u=>{d(u)},[d]);return m.useEffect(()=>{const u=a.watch(i=>{x(i)});return()=>u.unsubscribe()},[a.watch,x]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:a.control,name:"plan_change_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(A,{children:s("subscribe.plan_change_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:i=>{u.onChange(i),x(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"reset_traffic_method",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择重置方式"})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(q,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(q,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(q,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(q,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(A,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"surplus_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(A,{children:s("subscribe.surplus_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:i=>{u.onChange(i),x(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"new_order_event_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString(),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(q,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(A,{children:s("subscribe.new_order_event.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"renew_order_event_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString(),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(q,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(A,{children:s("subscribe.renew_order_event.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"change_order_event_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString(),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(q,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(A,{children:s("subscribe.change_order_event.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"subscribe_path",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:"subscribe",...u,value:u.value||"",onChange:i=>{u.onChange(i),x(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:u.value||"s"}),e.jsx("br",{}),s("subscribe.subscribe_path.restart_tip")]}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"show_info_to_server_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(A,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:i=>{u.onChange(i),x(a.getValues())}})})]})}),e.jsx(j,{control:a.control,name:"show_protocol_to_server_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(A,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:i=>{u.onChange(i),x(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function hu(){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(Re,{}),e.jsx(xu,{})]})}const gu=Object.freeze(Object.defineProperty({__proto__:null,default:hu},Symbol.toStringTag,{value:"Module"})),pu=h.object({invite_force:h.boolean().default(!1),invite_commission:h.coerce.string().default("0"),invite_gen_limit:h.coerce.string().default("0"),invite_never_expire:h.boolean().default(!1),commission_first_time_enable:h.boolean().default(!1),commission_auto_check_enable:h.boolean().default(!1),commission_withdraw_limit:h.coerce.string().default("0"),commission_withdraw_method:h.array(h.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:h.boolean().default(!1),commission_distribution_enable:h.boolean().default(!1),commission_distribution_l1:h.coerce.number().default(0),commission_distribution_l2:h.coerce.number().default(0),commission_distribution_l3:h.coerce.number().default(0)}),fu={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 ju(){const{t:s}=V("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),o=m.useRef(null),l=Ce({resolver:Te(pu),defaultValues:fu,mode:"onBlur"}),{data:d}=re({queryKey:["settings","invite"],queryFn:()=>ye.getSettings("invite")}),{mutateAsync:x}=As({mutationFn:ye.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data?.invite){const c=d?.data?.invite,p={};Object.entries(c).forEach(([F,T])=>{if(typeof T=="number"){const C=String(T);l.setValue(F,C),p[F]=C}else l.setValue(F,T),p[F]=T}),o.current=p,a(!0)}},[d]);const u=m.useCallback(Ie.debounce(async c=>{if(!Ie.isEqual(c,o.current)){t(!0);try{await x(c),o.current=c}finally{t(!1)}}},1e3),[x]),i=m.useCallback(c=>{r&&u(c)},[u,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(p=>{i(p)});return()=>c.unsubscribe()},[l.watch,i,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:l.control,name:"invite_force",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(A,{children:s("invite.invite_force.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"invite_commission",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("invite.invite_commission.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"invite_gen_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("invite.invite_gen_limit.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"invite_never_expire",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(A,{children:s("invite.invite_never_expire.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_first_time_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(A,{children:s("invite.commission_first_time.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_auto_check_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(A,{children:s("invite.commission_auto_check.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_withdraw_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"commission_withdraw_method",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_method.placeholder"),...c,value:Array.isArray(c.value)?c.value.join(","):"",onChange:p=>{const F=p.target.value.split(",").filter(Boolean);c.onChange(F),i(l.getValues())}})}),e.jsx(A,{children:s("invite.commission_withdraw_method.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"withdraw_close_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(A,{children:s("invite.withdraw_close.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_distribution_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(A,{children:s("invite.commission_distribution.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),i(l.getValues())}})})]})}),l.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"commission_distribution_l1",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:s("invite.commission_distribution.l1")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:p=>{const F=p.target.value?Number(p.target.value):0;c.onChange(F),i(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"commission_distribution_l2",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:s("invite.commission_distribution.l2")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:p=>{const F=p.target.value?Number(p.target.value):0;c.onChange(F),i(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"commission_distribution_l3",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:s("invite.commission_distribution.l3")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:p=>{const F=p.target.value?Number(p.target.value):0;c.onChange(F),i(l.getValues())}})}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.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("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(Re,{}),e.jsx(ju,{})]})}const bu=Object.freeze(Object.defineProperty({__proto__:null,default:vu},Symbol.toStringTag,{value:"Module"})),yu=h.object({frontend_theme:h.string().nullable(),frontend_theme_sidebar:h.string().nullable(),frontend_theme_header:h.string().nullable(),frontend_theme_color:h.string().nullable(),frontend_background_url:h.string().url().nullable()}),_u={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Nu(){const{data:s}=re({queryKey:["settings","frontend"],queryFn:()=>ye.getSettings("frontend")}),n=Ce({resolver:Te(yu),defaultValues:_u,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,o])=>{n.setValue(a,o)})}},[s]);function t(r){ye.saveSettings(r).then(({data:a})=>{a&&$.success("更新成功")})}return e.jsx(De,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(j,{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(v,{className:"text-base",children:"边栏风格"}),e.jsx(A,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(j,{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(v,{className:"text-base",children:"头部风格"}),e.jsx(A,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(f,{children:[e.jsx(v,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(b,{children:e.jsxs("select",{className:_(Mt({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(Vn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(A,{children:"主题色"}),e.jsx(R,{})]})}),e.jsx(j,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(f,{children:[e.jsx(v,{children:"背景"}),e.jsx(b,{children:e.jsx(D,{placeholder:"请输入图片地址",...r})}),e.jsx(A,{children:"将会在后台登录页面进行展示。"}),e.jsx(R,{})]})}),e.jsx(L,{type:"submit",children:"保存设置"})]})})}function wu(){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(Re,{}),e.jsx(Nu,{})]})}const Cu=Object.freeze(Object.defineProperty({__proto__:null,default:wu},Symbol.toStringTag,{value:"Module"})),Su=h.object({server_pull_interval:h.coerce.number().nullable(),server_push_interval:h.coerce.number().nullable(),server_token:h.string().nullable(),device_limit_mode:h.coerce.number().nullable()}),ku={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Tu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(Su),defaultValues:ku,mode:"onBlur"}),{data:o}=re({queryKey:["settings","server"],queryFn:()=>ye.getSettings("server")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:i=>{i.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(o?.data.server){const i=o.data.server;Object.entries(i).forEach(([c,p])=>{a.setValue(c,p)}),r.current=i}},[o]);const d=m.useCallback(Ie.debounce(async i=>{if(!Ie.isEqual(i,r.current)){t(!0);try{await l(i),r.current=i}finally{t(!1)}}},1e3),[l]),x=m.useCallback(i=>{d(i)},[d]);m.useEffect(()=>{const i=a.watch(c=>{x(c)});return()=>i.unsubscribe()},[a.watch,x]);const u=()=>{const i=Math.floor(Math.random()*17)+16,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let p="";for(let F=0;Fe.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.server_token.title")}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...i,value:i.value||"",className:"pr-10"}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:c=>{c.preventDefault(),u()},children:e.jsx(sd,{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(A,{children:s("server.server_token.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"server_pull_interval",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...i,value:i.value||"",onChange:c=>{const p=c.target.value?Number(c.target.value):null;i.onChange(p)}})}),e.jsx(A,{children:s("server.server_pull_interval.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"server_push_interval",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...i,value:i.value||"",onChange:c=>{const p=c.target.value?Number(c.target.value):null;i.onChange(p)}})}),e.jsx(A,{children:s("server.server_push_interval.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"device_limit_mode",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(X,{onValueChange:i.onChange,value:i.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(q,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(A,{children:s("server.device_limit_mode.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.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("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(Re,{}),e.jsx(Tu,{})]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"}));function Pu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(wl,{className:"h-5 w-5 text-green-500"}):e.jsx(Cl,{className:"h-5 w-5 text-destructive"}),e.jsx(me,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(qe,{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(jt,{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 Lu=h.object({email_template:h.string().nullable().default("classic"),email_host:h.string().nullable().default(""),email_port:h.coerce.number().nullable().default(465),email_username:h.string().nullable().default(""),email_password:h.string().nullable().default(""),email_encryption:h.string().nullable().default(""),email_from_address:h.string().email().nullable().default(""),remind_mail_enable:h.boolean().nullable().default(!1)});function Ru(){const{t:s}=V("settings"),[n,t]=m.useState(null),[r,a]=m.useState(!1),o=m.useRef(null),[l,d]=m.useState(!1),x=Ce({resolver:Te(Lu),defaultValues:{},mode:"onBlur"}),{data:u}=re({queryKey:["settings","email"],queryFn:()=>ye.getSettings("email")}),{data:i}=re({queryKey:["emailTemplate"],queryFn:()=>ye.getEmailTemplate()}),{mutateAsync:c}=As({mutationFn:ye.saveSettings,onSuccess:P=>{P.data&&$.success(s("common.autoSaved"))}}),{mutate:p,isPending:F}=As({mutationFn:ye.sendTestMail,onMutate:()=>{t(null),a(!1)},onSuccess:P=>{t(P.data),a(!0),P.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(u?.data.email){const P=u.data.email;Object.entries(P).forEach(([w,I])=>{x.setValue(w,I)}),o.current=P}},[u]);const T=m.useCallback(Ie.debounce(async P=>{if(!Ie.isEqual(P,o.current)){d(!0);try{await c(P),o.current=P}finally{d(!1)}}},1e3),[c]),C=m.useCallback(P=>{T(P)},[T]);return m.useEffect(()=>{const P=x.watch(w=>{C(w)});return()=>P.unsubscribe()},[x.watch,C]),e.jsxs(e.Fragment,{children:[e.jsx(De,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"email_host",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_host.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_host.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_port",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_port.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...P,value:P.value||"",onChange:w=>{const I=w.target.value?Number(w.target.value):null;P.onChange(I)}})}),e.jsx(A,{children:s("email.email_port.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_encryption",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(X,{onValueChange:w=>{const I=w==="none"?"":w;P.onChange(I)},value:P.value===""||P.value===null||P.value===void 0?"none":P.value,children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择加密方式"})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"none",children:s("email.email_encryption.none")}),e.jsx(q,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(q,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(A,{children:s("email.email_encryption.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_username",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_username.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),autoComplete:"off",...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_username.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_password",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_password.title")}),e.jsx(b,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),autoComplete:"off",...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_password.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_from_address",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_from.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_from.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_template",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(X,{onValueChange:w=>{P.onChange(w),C(x.getValues())},value:P.value||void 0,children:[e.jsx(b,{children:e.jsx(J,{className:"w-[200px]",children:e.jsx(Z,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(Q,{children:i?.data?.map(w=>e.jsx(q,{value:w,children:w},w))})]}),e.jsx(A,{children:s("email.email_template.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"remind_mail_enable",render:({field:P})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(A,{children:s("email.remind_mail.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:P.value||!1,onCheckedChange:w=>{P.onChange(w),C(x.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(L,{onClick:()=>p(),loading:F,disabled:F,children:s(F?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Pu,{open:r,onOpenChange:a,result:n})]})}function Eu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(Re,{}),e.jsx(Ru,{})]})}const Iu=Object.freeze(Object.defineProperty({__proto__:null,default:Eu},Symbol.toStringTag,{value:"Module"})),Vu=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Mu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Ou(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(Vu),defaultValues:Mu,mode:"onBlur"}),{data:o}=re({queryKey:["settings","telegram"],queryFn:()=>ye.getSettings("telegram")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}}),{mutate:d,isPending:x}=As({mutationFn:ye.setTelegramWebhook,onSuccess:c=>{c.data&&$.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(o?.data.telegram){const c=o.data.telegram;Object.entries(c).forEach(([p,F])=>{a.setValue(p,F)}),r.current=c}},[o]);const u=m.useCallback(Ie.debounce(async c=>{if(!Ie.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),i=m.useCallback(c=>{u(c)},[u]);return m.useEffect(()=>{const c=a.watch(p=>{i(p)});return()=>c.unsubscribe()},[a.watch,i]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:a.control,name:"telegram_bot_token",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("telegram.bot_token.description")}),e.jsx(R,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(L,{loading:x,disabled:x,onClick:()=>d(),children:s(x?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(A,{children:s("telegram.webhook.description")}),e.jsx(R,{})]}),e.jsx(j,{control:a.control,name:"telegram_bot_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(A,{children:s("telegram.bot_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),i(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"telegram_discuss_link",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("telegram.discuss_link.description")}),e.jsx(R,{})]})}),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("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(Re,{}),e.jsx(Ou,{})]})}const $u=Object.freeze(Object.defineProperty({__proto__:null,default:zu},Symbol.toStringTag,{value:"Module"})),Au=h.object({windows_version:h.string().nullable(),windows_download_url:h.string().nullable(),macos_version:h.string().nullable(),macos_download_url:h.string().nullable(),android_version:h.string().nullable(),android_download_url:h.string().nullable()}),qu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Uu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(Au),defaultValues:qu,mode:"onBlur"}),{data:o}=re({queryKey:["settings","app"],queryFn:()=>ye.getSettings("app")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:u=>{u.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(o?.data.app){const u=o.data.app;Object.entries(u).forEach(([i,c])=>{a.setValue(i,c)}),r.current=u}},[o]);const d=m.useCallback(Ie.debounce(async u=>{if(!Ie.isEqual(u,r.current)){t(!0);try{await l(u),r.current=u}finally{t(!1)}}},1e3),[l]),x=m.useCallback(u=>{d(u)},[d]);return m.useEffect(()=>{const u=a.watch(i=>{x(i)});return()=>u.unsubscribe()},[a.watch,x]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:a.control,name:"windows_version",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.windows.version.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"windows_download_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.windows.download.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"macos_version",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.macos.version.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"macos_download_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.macos.download.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"android_version",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.android.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.android.version.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"android_download_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.android.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.android.download.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Hu(){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(Re,{}),e.jsx(Uu,{})]})}const Ku=Object.freeze(Object.defineProperty({__proto__:null,default:Hu},Symbol.toStringTag,{value:"Module"}));Vr.config({monaco:Mr});function xi({form:s,config:n,namePrefix:t="",className:r="space-y-4"}){const[a,o]=m.useState({}),l=x=>t?`${t}.${x}`:x,d=(x,u)=>{const i=l(x);switch(u.type){case"string":return e.jsx(j,{control:s.control,name:i,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsx(D,{placeholder:u.placeholder,...c})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"number":case"percentage":return e.jsx(j,{control:s.control,name:i,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:u.placeholder,min:u.min??(u.type==="percentage"?0:void 0),max:u.max??(u.type==="percentage"?100:void 0),step:u.step??(u.type==="percentage"?1:void 0),...c,onChange:p=>{const F=Number(p.target.value);u.type==="percentage"?c.onChange(Math.min(100,Math.max(0,F))):c.onChange(F)},className:u.type==="percentage"?"pr-8":""}),u.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(td,{className:"h-4 w-4 text-muted-foreground"})})]})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"select":return e.jsx(j,{control:s.control,name:i,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsxs(X,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:u.placeholder})})}),e.jsx(Q,{children:u.options?.map(p=>e.jsx(q,{value:p.value,children:p.label},p.value))})]}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"boolean":return e.jsx(j,{control:s.control,name:i,render:({field:c})=>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(v,{className:"text-base",children:u.label||u.description}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:c.onChange})})]})},x);case"text":return e.jsx(j,{control:s.control,name:i,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsx(Es,{placeholder:u.placeholder,...c})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"yaml":case"json":return e.jsx(j,{control:s.control,name:i,render:({field:c})=>{const p=(()=>{if(c.value===null||c.value===void 0)return"";if(typeof c.value=="string")return c.value;try{return JSON.stringify(c.value,null,2)}catch{return String(c.value)}})(),F=`${t}_${x}`,T=a[F]||150;return e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsx("div",{className:"resize-y overflow-hidden rounded-md border",style:{height:`${T}px`},children:e.jsx(Or,{height:"100%",defaultLanguage:u.type,value:p,onChange:C=>{c.onChange(C||"")},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,formatOnPaste:u.type==="json",formatOnType:u.type==="json"}})})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})}},x);default:return null}};return e.jsx("div",{className:r,children:Object.entries(n).map(([x,u])=>d(x,u))})}function hi(s){return Object.fromEntries(Object.entries(s).map(([n,t])=>{let r=t.value;if(t.type==="yaml"||t.type==="json"){if(r==null)r="";else if(typeof r!="string")try{r=JSON.stringify(r,null,2)}catch{r=String(r)}}return[n,r]}))}const Bu=s=>h.object({id:h.number().nullable(),name:h.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:h.string().optional().nullable(),notify_domain:h.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:h.coerce.number().min(0).optional().nullable(),handling_fee_percent:h.coerce.number().min(0).max(100).optional().nullable(),payment:h.string().min(1,s("form.validation.payment.required")),config:h.record(h.string(),h.string())}),yr={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function gi({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=yr}){const{t:a}=V("payment"),[o,l]=m.useState(!1),[d,x]=m.useState(!1),[u,i]=m.useState([]),[c,p]=m.useState([]),[F,T]=m.useState({}),C=Bu(a),P=Ce({resolver:Te(C),defaultValues:r,mode:"onChange"}),w=P.watch("payment");m.useEffect(()=>{o&&(async()=>{const{data:N}=await ft.getMethodList();i(N)})()},[o]),m.useEffect(()=>{if(!w||!o)return;(async()=>{const N={payment:w,...t==="edit"&&{id:Number(P.getValues("id"))}};try{const{data:S}=await ft.getMethodForm(N),O=Object.values(S);p(O);const E=Object.entries(S).reduce((k,[W,te])=>(k[W]=te,k),{});T(E);const g=hi(E);P.setValue("config",g)}catch(S){console.error("Failed to fetch payment method form:",S),p([]),T({})}})()},[w,o,P,t]);const I=async y=>{x(!0);try{(await ft.save(y)).data&&($.success(a("form.messages.success")),P.reset(yr),s(),l(!1))}finally{x(!1)}};return e.jsxs(de,{open:o,onOpenChange:l,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(oe,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[500px]",children:[e.jsx(he,{children:e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(De,{...P,children:e.jsxs("form",{onSubmit:P.handleSubmit(I),className:"space-y-4",children:[e.jsx(j,{control:P.control,name:"name",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("form.fields.name.placeholder"),...y})}),e.jsx(A,{children:a("form.fields.name.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:P.control,name:"icon",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.icon.label")}),e.jsx(b,{children:e.jsx(D,{...y,value:y.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(A,{children:a("form.fields.icon.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:P.control,name:"notify_domain",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.notify_domain.label")}),e.jsx(b,{children:e.jsx(D,{...y,value:y.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(A,{children:a("form.fields.notify_domain.description")}),e.jsx(R,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:P.control,name:"handling_fee_percent",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...y,value:y.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(R,{})]})}),e.jsx(j,{control:P.control,name:"handling_fee_fixed",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...y,value:y.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(R,{})]})})]}),e.jsx(j,{control:P.control,name:"payment",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.payment.label")}),e.jsxs(X,{onValueChange:y.onChange,defaultValue:y.value,children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(Q,{children:u.map(N=>e.jsx(q,{value:N,children:N},N))})]}),e.jsx(A,{children:a("form.fields.payment.description")}),e.jsx(R,{})]})}),Object.keys(F).length>0&&e.jsxs("div",{className:"space-y-4 ",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:a("form.sections.payment_config")}),e.jsx(xi,{form:P,config:F,namePrefix:"config",className:"space-y-4"})]}),e.jsxs(Oe,{className:"pt-4",children:[e.jsx(st,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(L,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function z({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(L,{variant:"ghost",size:"default",className:_("-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(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(or,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(yn,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(_n,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ad,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:_("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(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(or,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const Gn=nd,pi=rd,Gu=ld,fi=m.forwardRef(({className:s,...n},t)=>e.jsx(kl,{className:_("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}));fi.displayName=kl.displayName;const Ya=m.forwardRef(({className:s,...n},t)=>e.jsxs(Gu,{children:[e.jsx(fi,{}),e.jsx(Tl,{ref:t,className:_("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})]}));Ya.displayName=Tl.displayName;const Ja=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ja.displayName="AlertDialogHeader";const Qa=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Qa.displayName="AlertDialogFooter";const Xa=m.forwardRef(({className:s,...n},t)=>e.jsx(Dl,{ref:t,className:_("text-lg font-semibold",s),...n}));Xa.displayName=Dl.displayName;const Za=m.forwardRef(({className:s,...n},t)=>e.jsx(Fl,{ref:t,className:_("text-sm text-muted-foreground",s),...n}));Za.displayName=Fl.displayName;const en=m.forwardRef(({className:s,...n},t)=>e.jsx(Pl,{ref:t,className:_(Vt(),s),...n}));en.displayName=Pl.displayName;const sn=m.forwardRef(({className:s,...n},t)=>e.jsx(Ll,{ref:t,className:_(Vt({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));sn.displayName=Ll.displayName;function hs({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:o="确认",variant:l="default",className:d}){return e.jsxs(Gn,{children:[e.jsx(pi,{asChild:!0,children:n}),e.jsxs(Ya,{className:_("sm:max-w-[425px]",d),children:[e.jsxs(Ja,{children:[e.jsx(Xa,{children:t}),e.jsx(Za,{children:r})]}),e.jsxs(Qa,{children:[e.jsx(sn,{asChild:!0,children:e.jsx(L,{variant:"outline",children:a})}),e.jsx(en,{asChild:!0,children:e.jsx(L,{variant:l,onClick:s,children:o})})]})]})]})}const ji=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"})}),Wu=({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(Ua,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(z,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(z,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(ee,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await ft.updateStatus({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(z,{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(z,{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(z,{column:r,title:t("table.columns.notify_url")}),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{className:"ml-1",children:e.jsx(ji,{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(z,{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(gi,{refetch:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(rt,{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(hs,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await ft.drop({id:r.original.id});a&&s()},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(xs,{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 Yu({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("payment"),o=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(gi,{refetch:n}),e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),o&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(L,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Ju(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,o]=m.useState(!1),[l,d]=m.useState([]),[x,u]=m.useState({"drag-handle":!1}),[i,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:p}=re({queryKey:["paymentList"],queryFn:async()=>{const{data:w}=await ft.getList();return d(w?.map(I=>({...I,enable:!!I.enable}))||[]),w}});m.useEffect(()=>{u({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const F=(w,I)=>{a&&(w.dataTransfer.setData("text/plain",I.toString()),w.currentTarget.classList.add("opacity-50"))},T=(w,I)=>{if(!a)return;w.preventDefault(),w.currentTarget.classList.remove("bg-muted");const y=parseInt(w.dataTransfer.getData("text/plain"));if(y===I)return;const N=[...l],[S]=N.splice(y,1);N.splice(I,0,S),d(N)},C=async()=>{a?ft.sort({ids:l.map(w=>w.id)}).then(()=>{p(),o(!1),$.success("排序保存成功")}):o(!0)},P=Ye({data:l,columns:Wu({refetch:p,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:x,pagination:i},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(rs,{table:P,toolbar:w=>e.jsx(Yu,{table:w,refetch:p,saveOrder:C,isSortMode:a}),draggable:a,onDragStart:F,onDragEnd:w=>w.currentTarget.classList.remove("opacity-50"),onDragOver:w=>{w.preventDefault(),w.currentTarget.classList.add("bg-muted")},onDragLeave:w=>w.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!a})}function Qu(){const{t:s}=V("payment");return e.jsxs(Ue,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsx(ds,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Ju,{})})]})]})}const Xu=Object.freeze(Object.defineProperty({__proto__:null,default:Qu},Symbol.toStringTag,{value:"Module"}));function Zu({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,o]=m.useState(!0),[l,d]=m.useState(!1),[x,u]=m.useState(null),i=id({config:od(cd())}),c=Ce({resolver:Te(i),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:T}=await Os.getPluginConfig(s);u(T);const C=hi(T);c.reset({config:C})}catch{$.error(r("messages.configLoadError"))}finally{o(!1)}})()},[s,c,r]);const p=async F=>{d(!0);try{await Os.updatePluginConfig(s,F.config),$.success(r("messages.configSaveSuccess")),t()}catch{$.error(r("messages.configSaveError"))}finally{d(!1)}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-4 w-[200px]"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-4 w-[200px]"}),e.jsx(be,{className:"h-10 w-full"})]}):e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(p),className:"space-y-4",children:[x&&e.jsx(xi,{form:c,config:x,namePrefix:"config"}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(L,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function ex(){const{t:s}=V("plugin"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[o,l]=m.useState(null),[d,x]=m.useState(""),[u,i]=m.useState("feature"),[c,p]=m.useState("all"),[F,T]=m.useState(!1),[C,P]=m.useState(!1),[w,I]=m.useState(!1),y=m.useRef(null),[N,S]=m.useState(!1),[O,E]=m.useState(""),{data:g,isLoading:k}=re({queryKey:["pluginTypes"],queryFn:async()=>{const{data:K}=await Os.getPluginTypes();return K}}),{data:W,isLoading:te,refetch:ae}=re({queryKey:["pluginList"],queryFn:async()=>{const{data:K}=await Os.getPluginList();return K}}),B=W?.filter(K=>K.name.toLowerCase().includes(d.toLowerCase())||K.description.toLowerCase().includes(d.toLowerCase())||K.code.toLowerCase().includes(d.toLowerCase())),se=()=>{if(!B)return[];let K=B;return u!=="all"&&(K=K.filter(H=>H.type===u)),c==="installed"?K=K.filter(H=>H.is_installed):c==="available"&&(K=K.filter(H=>!H.is_installed)),K},je=K=>g?.find(H=>H.value===K),ms=async K=>{t(K),Os.installPlugin(K).then(()=>{$.success(s("messages.installSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.installError"))}).finally(()=>{t(null)})},ze=async K=>{t(K),Os.upgradePlugin(K).then(()=>{$.success(s("messages.upgradeSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.upgradeError"))}).finally(()=>{t(null)})},le=async K=>{t(K),Os.uninstallPlugin(K).then(()=>{$.success(s("messages.uninstallSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},Ts=async(K,H)=>{t(K),(H?Os.disablePlugin:Os.enablePlugin)(K).then(()=>{$.success(s(H?"messages.disableSuccess":"messages.enableSuccess")),ae()}).catch($e=>{$.error($e.message||s(H?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},Ns=K=>{W?.find(H=>H.code===K),l(K),a(!0)},ct=async K=>{if(!K.name.endsWith(".zip")){$.error(s("upload.error.format"));return}T(!0),Os.uploadPlugin(K).then(()=>{$.success(s("messages.uploadSuccess")),P(!1),ae()}).catch(H=>{$.error(H.message||s("messages.uploadError"))}).finally(()=>{T(!1),y.current&&(y.current.value="")})},Is=K=>{K.preventDefault(),K.stopPropagation(),K.type==="dragenter"||K.type==="dragover"?I(!0):K.type==="dragleave"&&I(!1)},dt=K=>{K.preventDefault(),K.stopPropagation(),I(!1),K.dataTransfer.files&&K.dataTransfer.files[0]&&ct(K.dataTransfer.files[0])},mt=async K=>{t(K),Os.deletePlugin(K).then(()=>{$.success(s("messages.deleteSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.deleteError"))}).finally(()=>{t(null)})},ut=K=>dd(K||"",{walkTokens(H){(H.type==="image"||H.type==="link")&&(H.type="text",H.raw="",H.text="")}});return e.jsxs(Ue,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(En,{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(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(In,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:d,onChange:K=>x(K.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(X,{value:c,onValueChange:p,children:[e.jsx(J,{className:"w-[140px]",children:e.jsx(Z,{placeholder:s("status.filter_placeholder",{defaultValue:"安装状态"})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:s("status.all",{defaultValue:"全部状态"})}),e.jsx(q,{value:"installed",children:s("status.installed",{defaultValue:"已安装"})}),e.jsx(q,{value:"available",children:s("status.available",{defaultValue:"可安装"})})]})]}),e.jsxs(L,{onClick:()=>P(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(Rt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsxs(yt,{value:u,onValueChange:i,className:"w-full",children:[e.jsxs(lt,{children:[g?.map(K=>e.jsx(Ge,{value:K.value,children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:K.label})})},K.value)),e.jsx(Ge,{value:"all",children:s("tabs.all")})]}),e.jsx(ys,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:te||k?e.jsxs(e.Fragment,{children:[e.jsx(hn,{}),e.jsx(hn,{}),e.jsx(hn,{})]}):se().map(K=>e.jsx(_r,{plugin:K,typeInfo:je(K.type),onInstall:ms,onUpgrade:ze,onUninstall:le,onToggleEnable:Ts,onOpenConfig:Ns,onDelete:mt,isLoading:n===K.code,onShowReadme:K.readme?()=>{E(K.readme),S(!0)}:void 0},K.code))})}),g?.map(K=>e.jsx(ys,{value:K.value,className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:se().map(H=>e.jsx(_r,{plugin:H,typeInfo:je(H.type),onInstall:ms,onUpgrade:ze,onUninstall:le,onToggleEnable:Ts,onOpenConfig:Ns,onDelete:mt,isLoading:n===H.code,onShowReadme:H.readme?()=>{E(H.readme),S(!0)}:void 0},H.code))})},K.value))]})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(oe,{className:"sm:max-w-lg",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[W?.find(K=>K.code===o)?.name," ",s("config.title")]}),e.jsx(qe,{children:s("config.description")})]}),o&&e.jsx(Zu,{pluginName:o,onClose:()=>a(!1),onSuccess:()=>{a(!1),ae()}})]})}),e.jsx(de,{open:C,onOpenChange:P,children:e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(qe,{children:s("upload.description")})]}),e.jsxs("div",{className:_("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",w&&"border-primary/50 bg-muted/50"),onDragEnter:Is,onDragLeave:Is,onDragOver:Is,onDrop:dt,children:[e.jsx("input",{type:"file",ref:y,className:"hidden",accept:".zip",onChange:K=>{const H=K.target.files?.[0];H&&ct(H)}}),F?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(Rt,{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:()=>y.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(de,{open:N,onOpenChange:S,children:e.jsxs(oe,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsx(me,{children:s("readme.title",{defaultValue:"插件文档"})})}),e.jsx("div",{className:"markdown-body max-h-[60vh] overflow-y-auto",dangerouslySetInnerHTML:{__html:ut(O)}})]})})]})]})}function _r({plugin:s,onInstall:n,onUpgrade:t,onUninstall:r,onToggleEnable:a,onOpenConfig:o,onDelete:l,isLoading:d,onShowReadme:x,typeInfo:u}){const{t:i}=V("plugin");return e.jsx(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-semibold",children:s.name}),u&&e.jsx(U,{variant:"outline",className:"border-primary/20 bg-primary/5 px-1.5 py-0.5 text-xs text-primary",children:u.label}),s.is_installed?e.jsx(U,{variant:s.is_enabled?"default":"outline",className:"px-1.5 py-0.5 text-xs",children:s.is_enabled?i("status.enabled"):i("status.disabled")}):e.jsx(U,{variant:"outline",className:"border-muted-foreground/30 bg-muted/30 px-1.5 py-0.5 text-xs text-muted-foreground",children:i("status.not_installed")})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[s.is_protected&&e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",children:e.jsx(md,{className:"h-3 w-3"})})}),e.jsx(ce,{children:e.jsx("p",{children:i("status.protected")})})]})}),s.readme&&e.jsx("button",{type:"button",onClick:x,className:"flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-primary",title:i("button.readme"),children:e.jsx(wn,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mb-2 flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(En,{className:"h-3 w-3"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:s.code})]}),e.jsxs("span",{children:["v",s.version]}),e.jsxs("span",{children:[i("author"),": ",s.author]})]}),e.jsx("p",{className:"mb-3 overflow-hidden text-ellipsis text-sm text-muted-foreground",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:s.description}),e.jsx("div",{className:"flex items-center justify-end gap-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[s.need_upgrade&&e.jsx(hs,{title:i("upgrade.title"),description:i("upgrade.description"),cancelText:i("common:cancel"),confirmText:i("upgrade.button"),variant:"default",onConfirm:async()=>t(s.code),children:e.jsxs(L,{variant:"destructive",size:"sm",disabled:d,className:"h-7 px-2 text-xs bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ud,{className:"mr-1 h-3 w-3"}),i("button.upgrade")]})}),s.config&&Object.keys(s.config).length>0&&e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>o(s.code),disabled:!s.is_enabled||d,className:"h-7 px-2 text-xs",children:[e.jsx(Pa,{className:"mr-1 h-3 w-3"}),i("button.config")]}),e.jsxs(L,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>a(s.code,s.is_enabled),disabled:d,className:"h-7 px-2 text-xs",children:[e.jsx(xd,{className:"mr-1 h-3 w-3"}),s.is_enabled?i("button.disable"):i("button.enable")]}),e.jsx(hs,{title:i("uninstall.title"),description:i("uninstall.description"),cancelText:i("common:cancel"),confirmText:i("uninstall.button"),variant:"destructive",onConfirm:async()=>r(s.code),children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-destructive",disabled:d||s.is_enabled,children:[e.jsx(xs,{className:"mr-1 h-3 w-3"}),i("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{onClick:()=>n(s.code),disabled:d,size:"sm",className:"h-7 px-3 text-xs",children:[d?e.jsx("div",{className:"mr-1 h-3 w-3 animate-spin rounded-full border border-current border-t-transparent"}):null,i("button.install")]}),s.can_be_deleted!==!1&&e.jsx(hs,{title:i("delete.title"),description:i("delete.description"),cancelText:i("common:cancel"),confirmText:i("delete.button"),variant:"destructive",onConfirm:async()=>l(s.code),children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",disabled:d,children:e.jsx(xs,{className:"h-3 w-3"})})})]})})]})})}function hn(){return e.jsxs(ke,{children:[e.jsxs(Fe,{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(be,{className:"h-6 w-[200px]"}),e.jsx(be,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(be,{className:"h-5 w-[120px]"}),e.jsx(be,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(be,{className:"h-4 w-[300px]"}),e.jsx(be,{className:"h-4 w-[150px]"})]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(be,{className:"h-9 w-[100px]"}),e.jsx(be,{className:"h-9 w-[100px]"}),e.jsx(be,{className:"h-8 w-8"})]})})]})}const sx=Object.freeze(Object.defineProperty({__proto__:null,default:ex},Symbol.toStringTag,{value:"Module"})),tx=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(D,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(Es,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:_(Vt({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 ax({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=m.useState(!1),[o,l]=m.useState(!1),[d,x]=m.useState(!1),u=Ce({defaultValues:n.configs.reduce((p,F)=>(p[F.field_name]="",p),{})}),i=async()=>{l(!0),Qt.getConfig(s).then(({data:p})=>{Object.entries(p).forEach(([F,T])=>{u.setValue(F,T)})}).finally(()=>{l(!1)})},c=async p=>{x(!0),Qt.updateConfig(s,p).then(()=>{$.success(t("config.success")),a(!1)}).finally(()=>{x(!1)})};return e.jsxs(de,{open:r,onOpenChange:p=>{a(p),p?i():u.reset()},children:[e.jsx(cs,{asChild:!0,children:e.jsx(L,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(oe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:t("config.title",{name:n.name})}),e.jsx(qe,{children:t("config.description")})]}),o?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Fa,{className:"h-6 w-6 animate-spin"})}):e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(c),className:"space-y-4",children:[n.configs.map(p=>e.jsx(j,{control:u.control,name:p.field_name,render:({field:F})=>e.jsxs(f,{children:[e.jsx(v,{children:p.label}),e.jsx(b,{children:tx(p,F)}),e.jsx(R,{})]})},p.field_name)),e.jsxs(Oe,{className:"mt-6 gap-2",children:[e.jsx(L,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(L,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function nx(){const{t:s}=V("theme"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[o,l]=m.useState(!1),[d,x]=m.useState(!1),[u,i]=m.useState(null),c=m.useRef(null),[p,F]=m.useState(0),{data:T,isLoading:C,refetch:P}=re({queryKey:["themeList"],queryFn:async()=>{const{data:g}=await Qt.getList();return g}}),w=async g=>{t(g),ye.updateSystemConfig({frontend_theme:g}).then(()=>{$.success("主题切换成功"),P()}).finally(()=>{t(null)})},I=async g=>{if(!g.name.endsWith(".zip")){$.error(s("upload.error.format"));return}a(!0),Qt.upload(g).then(()=>{$.success("主题上传成功"),l(!1),P()}).finally(()=>{a(!1),c.current&&(c.current.value="")})},y=g=>{g.preventDefault(),g.stopPropagation(),g.type==="dragenter"||g.type==="dragover"?x(!0):g.type==="dragleave"&&x(!1)},N=g=>{g.preventDefault(),g.stopPropagation(),x(!1),g.dataTransfer.files&&g.dataTransfer.files[0]&&I(g.dataTransfer.files[0])},S=()=>{u&&F(g=>g===0?u.images.length-1:g-1)},O=()=>{u&&F(g=>g===u.images.length-1?0:g+1)},E=(g,k)=>{F(0),i({name:g,images:k})};return e.jsxs(Ue,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsx(ds,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(L,{onClick:()=>l(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Rt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Nr,{}),e.jsx(Nr,{})]}):T?.themes&&Object.entries(T.themes).map(([g,k])=>e.jsx(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:k.background_url?`url(${k.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:_("relative z-10 h-full transition-colors",k.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!k.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(hs,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(g===T?.active){$.error(s("card.delete.error.active"));return}t(g),Qt.drop(g).then(()=>{$.success("主题删除成功"),P()}).finally(()=>{t(null)})},children:e.jsx(L,{disabled:n===g,loading:n===g,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(xs,{className:"h-4 w-4"})})})}),e.jsxs(Fe,{children:[e.jsx(Me,{children:k.name}),e.jsx(et,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:k.description}),k.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:k.version})})]})})]}),e.jsxs(Pe,{className:"flex items-center justify-end space-x-3",children:[k.images&&Array.isArray(k.images)&&k.images.length>0&&e.jsx(L,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>E(k.name,k.images),children:e.jsx(hd,{className:"h-4 w-4"})}),e.jsx(ax,{themeKey:g,themeInfo:k}),e.jsx(L,{onClick:()=>w(g),disabled:n===g||g===T.active,loading:n===g,variant:g===T.active?"secondary":"default",children:g===T.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},g))}),e.jsx(de,{open:o,onOpenChange:l,children:e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(qe,{children:s("upload.description")})]}),e.jsxs("div",{className:_("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:y,onDragLeave:y,onDragOver:y,onDrop:N,children:[e.jsx("input",{type:"file",ref:c,className:"hidden",accept:".zip",onChange:g=>{const k=g.target.files?.[0];k&&I(k)}}),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(Rt,{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:()=>c.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(de,{open:!!u,onOpenChange:g=>{g||(i(null),F(0))},children:e.jsxs(oe,{className:"max-w-4xl",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[u?.name," ",s("preview.title")]}),e.jsx(qe,{className:"text-center",children:u&&s("preview.imageCount",{current:p+1,total:u.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:u?.images[p]&&e.jsx("img",{src:u.images[p],alt:`${u.name} 预览图 ${p+1}`,className:"h-full w-full object-contain"})}),u&&u.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(L,{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:S,children:e.jsx(pl,{className:"h-4 w-4"})}),e.jsx(L,{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:O,children:e.jsx(fl,{className:"h-4 w-4"})})]})]}),u&&u.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:u.images.map((g,k)=>e.jsx("button",{onClick:()=>F(k),className:_("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",p===k?"border-primary":"border-transparent"),children:e.jsx("img",{src:g,alt:`缩略图 ${k+1}`,className:"h-full w-full object-cover"})},k))})]})})]})]})}function Nr(){return e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsx(be,{className:"h-6 w-[200px]"}),e.jsx(be,{className:"h-4 w-[300px]"})]}),e.jsxs(Pe,{className:"flex items-center justify-end space-x-3",children:[e.jsx(be,{className:"h-10 w-[100px]"}),e.jsx(be,{className:"h-10 w-[100px]"})]})]})}const rx=Object.freeze(Object.defineProperty({__proto__:null,default:nx},Symbol.toStringTag,{value:"Module"})),tn=m.forwardRef(({className:s,value:n=[],onChange:t,...r},a)=>{const[o,l]=m.useState("");m.useEffect(()=>{if(o.includes(",")){const x=new Set([...n,...o.split(",").map(u=>u.trim())]);t(Array.from(x)),l("")}},[o,t,n]);const d=()=>{if(o){const x=new Set([...n,o]);t(Array.from(x)),l("")}};return e.jsxs("div",{className:_(" 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(x=>e.jsxs(U,{variant:"secondary",children:[x,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(u=>u!==x))},children:e.jsx(Sn,{className:"w-3"})})]},x)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:o,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"||x.key===","?(x.preventDefault(),d()):x.key==="Backspace"&&o.length===0&&n.length>0&&(x.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});tn.displayName="InputTags";const lx=h.object({id:h.number().nullable(),title:h.string().min(1).max(250),content:h.string().min(1),show:h.boolean(),tags:h.array(h.string()),img_url:h.string().nullable()}),ix={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function vi({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=ix}){const{t:a}=V("notice"),[o,l]=m.useState(!1),d=Ce({resolver:Te(lx),defaultValues:r,mode:"onChange",shouldFocusError:!0}),x=new On({html:!0});return e.jsx(De,{...d,children:e.jsxs(de,{onOpenChange:l,open:o,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(oe,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(qe,{})]}),e.jsx(j,{control:d.control,name:"title",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:a("form.fields.title.placeholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"content",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.content.label")}),e.jsx(b,{children:e.jsx(zn,{style:{height:"500px"},value:u.value,renderHTML:i=>x.render(i),onChange:({text:i})=>{u.onChange(i)}})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"img_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...u,value:u.value||""})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"show",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:u.value,onCheckedChange:u.onChange})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"tags",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.tags.label")}),e.jsx(b,{children:e.jsx(tn,{value:u.value,onChange:u.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsxs(Oe,{children:[e.jsx(st,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(L,{type:"submit",onClick:u=>{u.preventDefault(),d.handleSubmit(async i=>{ra.save(i).then(({data:c})=>{c&&($.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function ox({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=V("notice"),o=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!r&&e.jsx(vi,{refetch:n}),!r&&e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),o&&!r&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const cx=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(gd,{className:"h-4 w-4 cursor-move text-muted-foreground"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await ra.updateStatus(t.original.id);r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(z,{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(z,{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(vi,{refetch:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(rt,{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(hs,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{ra.drop(t.original.id).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 dx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,o]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState(!1),[i,c]=m.useState({}),[p,F]=m.useState({pageSize:50,pageIndex:0}),[T,C]=m.useState([]),{refetch:P}=re({queryKey:["notices"],queryFn:async()=>{const{data:S}=await ra.getList();return C(S),S}});m.useEffect(()=>{r({"drag-handle":x,content:!x,created_at:!x,actions:!x}),F({pageSize:x?99999:50,pageIndex:0})},[x]);const w=(S,O)=>{x&&(S.dataTransfer.setData("text/plain",O.toString()),S.currentTarget.classList.add("opacity-50"))},I=(S,O)=>{if(!x)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const E=parseInt(S.dataTransfer.getData("text/plain"));if(E===O)return;const g=[...T],[k]=g.splice(E,1);g.splice(O,0,k),C(g)},y=async()=>{if(!x){u(!0);return}ra.sort(T.map(S=>S.id)).then(()=>{$.success("排序保存成功"),u(!1),P()}).finally(()=>{u(!1)})},N=Ye({data:T??[],columns:cx(P),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:i,pagination:p},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,onColumnSizingChange:c,onPaginationChange:F,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:N,toolbar:S=>e.jsx(ox,{table:S,refetch:P,saveOrder:y,isSortMode:x}),draggable:x,onDragStart:w,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:I,showPagination:!x})})}function mx(){const{t:s}=V("notice");return e.jsxs(Ue,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsx(ds,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(dx,{})})]})]})}const ux=Object.freeze(Object.defineProperty({__proto__:null,default:mx},Symbol.toStringTag,{value:"Module"})),xx=h.object({id:h.number().nullable(),language:h.string().max(250),category:h.string().max(250),title:h.string().min(1).max(250),body:h.string().min(1),show:h.boolean()}),hx={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function bi({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=hx}){const{t:a}=V("knowledge"),[o,l]=m.useState(!1),d=Ce({resolver:Te(xx),defaultValues:r,mode:"onChange",shouldFocusError:!0}),x=new On({html:!0});return m.useEffect(()=>{o&&r.id&&It.getInfo(r.id).then(({data:u})=>{d.reset(u)})},[r.id,d,o]),e.jsxs(de,{onOpenChange:l,open:o,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(oe,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(qe,{})]}),e.jsxs(De,{...d,children:[e.jsx(j,{control:d.control,name:"title",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:a("form.titlePlaceholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"category",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:a("form.categoryPlaceholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"language",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.language")}),e.jsx(b,{children:e.jsxs(X,{value:u.value,onValueChange:u.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("form.languagePlaceholder")})}),e.jsx(Q,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(i=>e.jsx(q,{value:i.value,className:"cursor-pointer",children:a(`languages.${i.value}`)},i.value))})]})})]})}),e.jsx(j,{control:d.control,name:"body",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.content")}),e.jsx(b,{children:e.jsx(zn,{style:{height:"500px"},value:u.value,renderHTML:i=>x.render(i),onChange:({text:i})=>{u.onChange(i)}})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"show",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:u.value,onCheckedChange:u.onChange})})}),e.jsx(R,{})]})}),e.jsxs(Oe,{children:[e.jsx(st,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(L,{type:"submit",onClick:()=>{d.handleSubmit(u=>{It.save(u).then(({data:i})=>{i&&(d.reset(),$.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function gx({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ha,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(o=>a.has(o.value)).map(o=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(it,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ot,{children:"No results found."}),e.jsx(gs,{children:t.map(o=>{const l=a.has(o.value);return e.jsxs(Ae,{onSelect:()=>{l?a.delete(o.value):a.add(o.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:_("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(bt,{className:_("h-4 w-4")})}),o.icon&&e.jsx(o.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:o.label}),r?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(o.value)})]},o.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ot,{}),e.jsx(gs,{children:e.jsx(Ae,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function px({table:s,refetch:n,saveOrder:t,isSortMode:r}){const a=s.getState().columnFilters.length>0,{t:o}=V("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:o("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bi,{refreshData:n}),e.jsx(D,{placeholder:o("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(gx,{column:s.getColumn("category"),title:o("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[o("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(L,{variant:r?"default":"outline",onClick:t,size:"sm",children:o(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const fx=({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(Ua,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(z,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(z,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{It.updateStatus({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(z,{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(z,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(U,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(z,{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(bi,{refreshData:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(rt,{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(hs,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{It.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(t("messages.operationSuccess")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 jx(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,o]=m.useState(!1),[l,d]=m.useState([]),[x,u]=m.useState({"drag-handle":!1}),[i,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:p,isLoading:F,data:T}=re({queryKey:["knowledge"],queryFn:async()=>{const{data:y}=await It.getList();return d(y||[]),y}});m.useEffect(()=>{u({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const C=(y,N)=>{a&&(y.dataTransfer.setData("text/plain",N.toString()),y.currentTarget.classList.add("opacity-50"))},P=(y,N)=>{if(!a)return;y.preventDefault(),y.currentTarget.classList.remove("bg-muted");const S=parseInt(y.dataTransfer.getData("text/plain"));if(S===N)return;const O=[...l],[E]=O.splice(S,1);O.splice(N,0,E),d(O)},w=async()=>{a?It.sort({ids:l.map(y=>y.id)}).then(()=>{p(),o(!1),$.success("排序保存成功")}):o(!0)},I=Ye({data:l,columns:fx({refetch:p,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:x,pagination:i},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:u,onPaginationChange:c,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:I,toolbar:y=>e.jsx(px,{table:y,refetch:p,saveOrder:w,isSortMode:a}),draggable:a,onDragStart:C,onDragEnd:y=>y.currentTarget.classList.remove("opacity-50"),onDragOver:y=>{y.preventDefault(),y.currentTarget.classList.add("bg-muted")},onDragLeave:y=>y.currentTarget.classList.remove("bg-muted"),onDrop:P,showPagination:!a})}function vx(){const{t:s}=V("knowledge");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(jx,{})})]})]})}const bx=Object.freeze(Object.defineProperty({__proto__:null,default:vx},Symbol.toStringTag,{value:"Module"}));function yx(s,n){const[t,r]=m.useState(s);return m.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function gn(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 _x(s,n){const t=JSON.parse(JSON.stringify(s));for(const[r,a]of Object.entries(t))t[r]=a.filter(o=>!n.find(l=>l.value===o.value));return t}function Nx(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 yi=m.forwardRef(({className:s,...n},t)=>pd(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:_("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);yi.displayName="CommandEmpty";const nt=m.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:o,onSearch:l,loadingIndicator:d,emptyIndicator:x,maxSelected:u=Number.MAX_SAFE_INTEGER,onMaxSelected:i,hidePlaceholderWhenSelected:c,disabled:p,groupBy:F,className:T,badgeClassName:C,selectFirstItem:P=!0,creatable:w=!1,triggerSearchOnFocus:I=!1,commandProps:y,inputProps:N,hideClearAllButton:S=!1},O)=>{const E=m.useRef(null),[g,k]=m.useState(!1),W=m.useRef(!1),[te,ae]=m.useState(!1),[B,se]=m.useState(s||[]),[je,ms]=m.useState(gn(r,F)),[ze,le]=m.useState(""),Ts=yx(ze,o||500);m.useImperativeHandle(O,()=>({selectedValue:[...B],input:E.current,focus:()=>E.current?.focus()}),[B]);const Ns=m.useCallback(H=>{const _e=B.filter($e=>$e.value!==H.value);se(_e),n?.(_e)},[n,B]),ct=m.useCallback(H=>{const _e=E.current;_e&&((H.key==="Delete"||H.key==="Backspace")&&_e.value===""&&B.length>0&&(B[B.length-1].fixed||Ns(B[B.length-1])),H.key==="Escape"&&_e.blur())},[Ns,B]);m.useEffect(()=>{s&&se(s)},[s]),m.useEffect(()=>{if(!a||l)return;const H=gn(a||[],F);JSON.stringify(H)!==JSON.stringify(je)&&ms(H)},[r,a,F,l,je]),m.useEffect(()=>{const H=async()=>{ae(!0);const $e=await l?.(Ts);ms(gn($e||[],F)),ae(!1)};(async()=>{!l||!g||(I&&await H(),Ts&&await H())})()},[Ts,F,g,I]);const Is=()=>{if(!w||Nx(je,[{value:ze,label:ze}])||B.find(_e=>_e.value===ze))return;const H=e.jsx(Ae,{value:ze,className:"cursor-pointer",onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation()},onSelect:_e=>{if(B.length>=u){i?.(B.length);return}le("");const $e=[...B,{value:_e,label:_e}];se($e),n?.($e)},children:`Create "${ze}"`});if(!l&&ze.length>0||l&&Ts.length>0&&!te)return H},dt=m.useCallback(()=>{if(x)return l&&!w&&Object.keys(je).length===0?e.jsx(Ae,{value:"-",disabled:!0,children:x}):e.jsx(yi,{children:x})},[w,x,l,je]),mt=m.useMemo(()=>_x(je,B),[je,B]),ut=m.useCallback(()=>{if(y?.filter)return y.filter;if(w)return(H,_e)=>H.toLowerCase().includes(_e.toLowerCase())?1:-1},[w,y?.filter]),K=m.useCallback(()=>{const H=B.filter(_e=>_e.fixed);se(H),n?.(H)},[n,B]);return e.jsxs(Ys,{...y,onKeyDown:H=>{ct(H),y?.onKeyDown?.(H)},className:_("h-auto overflow-visible bg-transparent",y?.className),shouldFilter:y?.shouldFilter!==void 0?y.shouldFilter:!l,filter:ut(),children:[e.jsx("div",{className:_("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":B.length!==0,"cursor-text":!p&&B.length!==0},T),onClick:()=>{p||E.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[B.map(H=>e.jsxs(U,{className:_("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",C),"data-fixed":H.fixed,"data-disabled":p||void 0,children:[H.label,e.jsx("button",{className:_("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(p||H.fixed)&&"hidden"),onKeyDown:_e=>{_e.key==="Enter"&&Ns(H)},onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation()},onClick:()=>Ns(H),children:e.jsx(Sn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},H.value)),e.jsx(ps.Input,{...N,ref:E,value:ze,disabled:p,onValueChange:H=>{le(H),N?.onValueChange?.(H)},onBlur:H=>{W.current===!1&&k(!1),N?.onBlur?.(H)},onFocus:H=>{k(!0),I&&l?.(Ts),N?.onFocus?.(H)},placeholder:c&&B.length!==0?"":t,className:_("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":c,"px-3 py-2":B.length===0,"ml-1":B.length!==0},N?.className)}),e.jsx("button",{type:"button",onClick:K,className:_((S||p||B.length<1||B.filter(H=>H.fixed).length===B.length)&&"hidden"),children:e.jsx(Sn,{})})]})}),e.jsx("div",{className:"relative",children:g&&e.jsx(Js,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{W.current=!1},onMouseEnter:()=>{W.current=!0},onMouseUp:()=>{E.current?.focus()},children:te?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[dt(),Is(),!P&&e.jsx(Ae,{value:"-",className:"hidden"}),Object.entries(mt).map(([H,_e])=>e.jsx(gs,{heading:H,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:_e.map($e=>e.jsx(Ae,{value:$e.value,disabled:$e.disable,onMouseDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation()},onSelect:()=>{if(B.length>=u){i?.(B.length);return}le("");const Ne=[...B,$e];se(Ne),n?.(Ne)},className:_("cursor-pointer",$e.disable&&"cursor-default text-muted-foreground"),children:$e.label},$e.value))})},H))]})})})]})});nt.displayName="MultipleSelector";const wx=s=>h.object({id:h.number().optional(),name:h.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 an({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),o=Ce({resolver:Te(wx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1),[x,u]=m.useState(!1),i=async c=>{u(!0),_t.save(c).then(()=>{$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),o.reset(),d(!1)}).finally(()=>{u(!1)})};return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(qe,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(De,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(i),className:"space-y-4",children:[e.jsx(j,{control:o.control,name:"name",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.name")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("form.namePlaceholder"),...c,className:"w-full"})}),e.jsx(A,{children:a("form.nameDescription")}),e.jsx(R,{})]})}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(st,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(L,{type:"submit",disabled:x||!o.formState.isValid,children:[x&&e.jsx(Fa,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const _i=m.createContext(void 0);function Cx({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,o]=m.useState(null),[l,d]=m.useState(ge.Shadowsocks);return e.jsx(_i.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:o,serverType:l,setServerType:d,refetch:n},children:s})}function Ni(){const s=m.useContext(_i);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function pn({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=V("server");m.useEffect(()=>{console.log(n)},[n]);const[o,l]=m.useState(!1),[d,x]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[u,i]=m.useState(null),c=w=>{if(!w)return null;try{const I=JSON.parse(w);return typeof I!="object"||I===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},p={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},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:{}}}}}},F=()=>{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[]}},T=()=>{const w=c(d||"");if(w){$.error(w);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{$.error(a("network_settings.errors.save_failed"))}},C=w=>{x(w),i(c(w))},P=w=>{const I=p[w];if(I){const y=JSON.stringify(I.content,null,2);x(y),i(null)}};return m.useEffect(()=>{o&&console.log(n)},[o,n]),m.useEffect(()=>{o&&n&&Object.keys(n).length>0&&x(JSON.stringify(n,null,2))},[o,n]),e.jsxs(de,{open:o,onOpenChange:w=>{!w&&o&&T(),l(w)},children:[e.jsx(cs,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[F().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:F().map(w=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>P(w),children:a("network_settings.use_template",{template:p[w].label})},w))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Es,{className:`min-h-[200px] font-mono text-sm ${u?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:F().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:w=>C(w.target.value)}),u&&e.jsx("p",{className:"text-sm text-red-500",children:u})]})]}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(G,{onClick:T,disabled:!!u,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={},kx=Object.freeze(Object.defineProperty({__proto__:null,default:Sx},Symbol.toStringTag,{value:"Module"})),fp=Ed(kx),wr=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Tx=()=>{try{const s=jd.box.keyPair(),n=wr(cr.encodeBase64(s.secretKey)),t=wr(cr.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Dx=()=>{try{return Tx()}catch(s){throw console.error("Error generating key pair:",s),s}},Fx=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)},Px=()=>{const s=Math.floor(Math.random()*8)*2+2;return Fx(s)},Lx=h.object({cipher:h.string().default("aes-128-gcm"),plugin:h.string().optional().default(""),plugin_opts:h.string().optional().default(""),client_fingerprint:h.string().optional().default("chrome")}),Rx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({})}),Ex=h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({})}),Ix=h.object({version:h.coerce.number().default(2),alpn:h.string().default("h2"),obfs:h.object({open:h.coerce.boolean().default(!1),type:h.string().default("salamander"),password:h.string().default("")}).default({}),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),bandwidth:h.object({up:h.string().default(""),down:h.string().default("")}).default({}),hop_interval:h.number().optional(),port_range:h.string().optional()}),Vx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),reality_settings:h.object({server_port:h.coerce.number().default(443),server_name:h.string().default(""),allow_insecure:h.boolean().default(!1),public_key:h.string().default(""),private_key:h.string().default(""),short_id:h.string().default("")}).default({}),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({}),flow:h.string().default("")}),Mx=h.object({version:h.coerce.number().default(5),congestion_control:h.string().default("bbr"),alpn:h.array(h.string()).default(["h3"]),udp_relay_mode:h.string().default("native"),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ox=h.object({}),zx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),$x=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ax=h.object({transport:h.string().default("tcp"),multiplexing:h.string().default("MULTIPLEXING_LOW")}),qx=h.object({padding_scheme:h.array(h.string()).optional().default([]),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ve={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"],plugins:[{value:"none",label:"None"},{value:"obfs",label:"Simple Obfs"},{value:"v2ray-plugin",label:"V2Ray Plugin"}],clientFingerprints:[{value:"chrome",label:"Chrome"},{value:"firefox",label:"Firefox"},{value:"safari",label:"Safari"},{value:"ios",label:"iOS"}]},vmess:{schema:Rx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Ex,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Ix,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Vx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},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:Ox},naive:{schema:$x},http:{schema:zx},mieru:{schema:Ax,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:qx,defaultPaddingScheme:["stop=8","0=30-30","1=100-400","2=400-500,c,500-1000,c,500-1000,c,500-1000,c,500-1000","3=9-9,500-1000","4=500-1000","5=500-1000","6=500-1000","7=500-1000"]}},Ux=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Ve[s]:null,o=a?.schema||h.record(h.any()),l=s?o.parse({}):{},d=Ce({resolver:Te(o),defaultValues:l,mode:"onChange"}),[x,u]=m.useState(!1),[i,c]=m.useState("");if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const g=o.parse({});d.reset(g)}}else d.reset(n)},[s,n,t,d,o]),m.useEffect(()=>{const g=d.watch(k=>{t(k)});return()=>g.unsubscribe()},[d,t]),!s||!a)return null;const E={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"cipher",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(b,{children:e.jsxs(es,{open:x,onOpenChange:u,children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":x,className:_("w-full justify-between",!g.value&&"text-muted-foreground"),disabled:!1,children:[g.value||r("dynamic_form.shadowsocks.cipher.placeholder"),e.jsx(fd,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(We,{className:"w-[400px] p-0",align:"start",children:e.jsxs(Ys,{shouldFilter:!1,children:[e.jsx(it,{placeholder:r("dynamic_form.shadowsocks.cipher.search_placeholder"),value:i,onValueChange:k=>{c(k),k&&!Ve.shadowsocks.ciphers.includes(k)&&g.onChange(k)}}),e.jsxs(Js,{children:[e.jsxs(ot,{children:[i&&e.jsxs(Ae,{value:i,onSelect:k=>{g.onChange(k),c(""),u(!1)},children:[e.jsx(_a,{className:"mr-2 h-4 w-4 opacity-100"}),e.jsxs("span",{className:"font-medium text-blue-600",children:[r("dynamic_form.shadowsocks.cipher.use_custom"),' "',i,'"']}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",r("dynamic_form.shadowsocks.cipher.custom_label"),")"]})]}),!i&&e.jsxs("div",{className:"p-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:r("dynamic_form.shadowsocks.cipher.no_results")}),e.jsx("p",{className:"mt-1 text-xs",children:r("dynamic_form.shadowsocks.cipher.custom_hint")})]})]}),e.jsx(gs,{heading:r("dynamic_form.shadowsocks.cipher.preset_group"),children:Ve.shadowsocks.ciphers.filter(k=>k.toLowerCase().includes(i.toLowerCase())).map(k=>e.jsxs(Ae,{value:k,onSelect:W=>{g.onChange(W),c(""),u(!1)},children:[e.jsx(_a,{className:_("mr-2 h-4 w-4",g.value===k?"opacity-100":"opacity-0")}),k]},k))}),g.value&&!Ve.shadowsocks.ciphers.includes(g.value)&&e.jsx(gs,{heading:r("dynamic_form.shadowsocks.cipher.custom_group"),children:e.jsxs(Ae,{value:g.value,onSelect:()=>{},children:[e.jsx(_a,{className:"mr-2 h-4 w-4 opacity-100"}),e.jsx("span",{className:"font-medium text-blue-600",children:g.value}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",r("dynamic_form.shadowsocks.cipher.current_value"),")"]})]})})]})]})})]})}),e.jsx(A,{children:r("dynamic_form.shadowsocks.cipher.description")})]})}),e.jsx(j,{control:d.control,name:"plugin",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.plugin.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:k=>g.onChange(k==="none"?"":k),value:g.value===""?"none":g.value||"none",children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.shadowsocks.plugin.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.shadowsocks.plugins.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})}),e.jsx(A,{children:g.value&&g.value!=="none"&&g.value!==""&&e.jsxs(e.Fragment,{children:[g.value==="obfs"&&r("dynamic_form.shadowsocks.plugin.obfs_hint"),g.value==="v2ray-plugin"&&r("dynamic_form.shadowsocks.plugin.v2ray_hint")]})})]})}),d.watch("plugin")&&d.watch("plugin")!=="none"&&d.watch("plugin")!==""&&e.jsx(j,{control:d.control,name:"plugin_opts",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.plugin_opts.label")}),e.jsx(A,{children:r("dynamic_form.shadowsocks.plugin_opts.description")}),e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:r("dynamic_form.shadowsocks.plugin_opts.placeholder"),...g})})]})}),(d.watch("plugin")==="shadow-tls"||d.watch("plugin")==="restls")&&e.jsx(j,{control:d.control,name:"client_fingerprint",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.client_fingerprint")}),e.jsx(b,{children:e.jsxs(X,{value:g.value||"chrome",onValueChange:g.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.shadowsocks.client_fingerprint_placeholder")})}),e.jsx(Q,{children:Ve.shadowsocks.clientFingerprints.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})]})}),e.jsx(A,{children:r("dynamic_form.shadowsocks.client_fingerprint_description")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(q,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"network",render:({field:g})=>e.jsxs(f,{children:[e.jsxs(v,{children:[r("dynamic_form.vmess.network.label"),e.jsx(pn,{value:d.watch("network_settings"),setValue:k=>d.setValue("network_settings",k),templateType:d.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.vmess.networkOptions.map(k=>e.jsx(q,{value:k.value,className:"cursor-pointer",children:k.label},k.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(j,{control:d.control,name:"allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"network",render:({field:g})=>e.jsxs(f,{children:[e.jsxs(v,{children:[r("dynamic_form.trojan.network.label"),e.jsx(pn,{value:d.watch("network_settings")||{},setValue:k=>d.setValue("network_settings",k),templateType:d.watch("network")||"tcp"})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value||"tcp",children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.trojan.networkOptions.map(k=>e.jsx(q,{value:k.value,className:"cursor-pointer",children:k.label},k.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"version",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:(g.value||2).toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.hysteria.versions.map(k=>e.jsxs(q,{value:k,className:"cursor-pointer",children:["V",k]},k))})})]})})]})}),d.watch("version")==1&&e.jsx(j,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value||"h2",onValueChange:g.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.hysteria.alpnOptions.map(k=>e.jsx(q,{value:k,children:k},k))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"obfs.open",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(j,{control:d.control,name:"obfs.type",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value||"salamander",onValueChange:g.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:e.jsx(q,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(j,{control:d.control,name:"obfs.password",render:({field:g})=>e.jsxs(f,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...g,value:g.value||"",className:"pr-9"})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(te=>k[te%k.length]).join("");d.setValue("obfs.password",W),$.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 transition-transform duration-150 active:scale-90",children:e.jsx(Be,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform duration-300 hover:rotate-180"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(j,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"bandwidth.up",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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(j,{control:d.control,name:"bandwidth.down",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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")})})]})]})}),e.jsx(e.Fragment,{children:e.jsx(j,{control:d.control,name:"hop_interval",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...g,value:g.value||"",onChange:k=>{const W=k.target.value?parseInt(k.target.value):void 0;g.onChange(W)}})}),e.jsx(A,{children:r("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(q,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(q,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"reality_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"reality_settings.server_port",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"reality_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(j,{control:d.control,name:"reality_settings.private_key",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...g,className:"pr-9"})}),e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const k=Dx();d.setValue("reality_settings.private_key",k.privateKey),d.setValue("reality_settings.public_key",k.publicKey),$.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 transition-transform duration-150 active:scale-90",children:e.jsx(Be,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform duration-300 hover:rotate-180"})})}),e.jsx(La,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(j,{control:d.control,name:"reality_settings.public_key",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(b,{children:e.jsx(D,{...g})})]})}),e.jsx(j,{control:d.control,name:"reality_settings.short_id",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...g,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const k=Px();d.setValue("reality_settings.short_id",k),$.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 transition-transform duration-150 active:scale-90",children:e.jsx(Be,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform duration-300 hover:rotate-180"})})}),e.jsx(La,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(A,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(j,{control:d.control,name:"network",render:({field:g})=>e.jsxs(f,{children:[e.jsxs(v,{children:[r("dynamic_form.vless.network.label"),e.jsx(pn,{value:d.watch("network_settings"),setValue:k=>d.setValue("network_settings",k),templateType:d.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.vless.networkOptions.map(k=>e.jsx(q,{value:k.value,className:"cursor-pointer",children:k.label},k.value))})})]})})]})}),e.jsx(j,{control:d.control,name:"flow",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.flow.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:k=>g.onChange(k==="none"?null:k),value:g.value||"none",children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(Q,{children:Ve.vless.flowOptions.map(k=>e.jsx(q,{value:k,children:k},k))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"version",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.tuic.versions.map(k=>e.jsxs(q,{value:k,children:["V",k]},k))})})]})})]})}),e.jsx(j,{control:d.control,name:"congestion_control",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.tuic.congestionControls.map(k=>e.jsx(q,{value:k,children:k.toUpperCase()},k))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(b,{children:e.jsx(nt,{options:Ve.tuic.alpnOptions,onChange:k=>g.onChange(k.map(W=>W.value)),value:Ve.tuic.alpnOptions.filter(k=>g.value?.includes(k.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(j,{control:d.control,name:"udp_relay_mode",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.tuic.udpRelayModes.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.naive.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(q,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.http.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(q,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"transport",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.mieru.transportOptions.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})})]})}),e.jsx(j,{control:d.control,name:"multiplexing",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.mieru.multiplexingOptions.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:d.control,name:"padding_scheme",render:({field:g})=>e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(v,{children:r("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{d.setValue("padding_scheme",Ve.anytls.defaultPaddingScheme),$.success(r("dynamic_form.anytls.padding_scheme.default_success","已设置默认填充方案"))},className:"h-7 px-2",children:r("dynamic_form.anytls.padding_scheme.use_default","使用默认方案")})]}),e.jsx(A,{children:r("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(b,{children:e.jsx("textarea",{className:"flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:r("dynamic_form.anytls.padding_scheme.placeholder",`例如: +`).filter(Boolean);c.onChange(F),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"captcha_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.enable.label")}),e.jsx(A,{children:s("safe.form.captcha.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),l.watch("captcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"captcha_type",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.type.label")}),e.jsxs(X,{onValueChange:p=>{c.onChange(p),o(l.getValues())},value:c.value||"recaptcha",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:s("safe.form.captcha.type.description")})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"recaptcha",children:s("safe.form.captcha.type.options.recaptcha")}),e.jsx(q,{value:"recaptcha-v3",children:s("safe.form.captcha.type.options.recaptcha-v3")}),e.jsx(q,{value:"turnstile",children:s("safe.form.captcha.type.options.turnstile")})]})]}),e.jsx(A,{children:s("safe.form.captcha.type.description")}),e.jsx(R,{})]})}),l.watch("captcha_type")==="recaptcha"&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"recaptcha_site_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha.siteKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"recaptcha_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha.key.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha.key.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha.key.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="recaptcha-v3"&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"recaptcha_v3_site_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha_v3.siteKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha_v3.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"recaptcha_v3_secret_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.secretKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha_v3.secretKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha_v3.secretKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"recaptcha_v3_score_threshold",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",step:"0.1",min:"0",max:"1",placeholder:s("safe.form.captcha.recaptcha_v3.scoreThreshold.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="turnstile"&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"turnstile_site_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.turnstile.siteKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.turnstile.siteKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.turnstile.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"turnstile_secret_key",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.captcha.turnstile.secretKey.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.captcha.turnstile.secretKey.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.captcha.turnstile.secretKey.description")}),e.jsx(R,{})]})})]})]}),e.jsx(j,{control:l.control,name:"register_limit_by_ip_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(A,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),l.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"register_limit_count",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.registerLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"register_limit_expire",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(R,{})]})})]}),e.jsx(j,{control:l.control,name:"password_limit_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(A,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),l.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"password_limit_count",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"password_limit_expire",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...c,value:c.value||"",onChange:p=>{c.onChange(p),o(l.getValues())}})}),e.jsx(A,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function cu(){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(Re,{}),e.jsx(ou,{})]})}const du=Object.freeze(Object.defineProperty({__proto__:null,default:cu},Symbol.toStringTag,{value:"Module"})),mu=h.object({plan_change_enable:h.boolean().nullable().default(!1),reset_traffic_method:h.coerce.number().nullable().default(0),surplus_enable:h.boolean().nullable().default(!1),new_order_event_id:h.coerce.number().nullable().default(0),renew_order_event_id:h.coerce.number().nullable().default(0),change_order_event_id:h.coerce.number().nullable().default(0),show_info_to_server_enable:h.boolean().nullable().default(!1),show_protocol_to_server_enable:h.boolean().nullable().default(!1),default_remind_expire:h.boolean().nullable().default(!1),default_remind_traffic:h.boolean().nullable().default(!1),subscribe_path:h.string().nullable().default("s")}),uu={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 xu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(mu),defaultValues:uu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","subscribe"],queryFn:()=>ye.getSettings("subscribe")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:u=>{u.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.subscribe){const u=i?.data?.subscribe;Object.entries(u).forEach(([o,c])=>{a.setValue(o,c)}),r.current=u}},[i]);const d=m.useCallback(Ie.debounce(async u=>{if(!Ie.isEqual(u,r.current)){t(!0);try{await l(u),r.current=u}finally{t(!1)}}},1e3),[l]),x=m.useCallback(u=>{d(u)},[d]);return m.useEffect(()=>{const u=a.watch(o=>{x(o)});return()=>u.unsubscribe()},[a.watch,x]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:a.control,name:"plan_change_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(A,{children:s("subscribe.plan_change_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:o=>{u.onChange(o),x(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"reset_traffic_method",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择重置方式"})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(q,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(q,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(q,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(q,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(A,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"surplus_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(A,{children:s("subscribe.surplus_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:o=>{u.onChange(o),x(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"new_order_event_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString(),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(q,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(A,{children:s("subscribe.new_order_event.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"renew_order_event_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString(),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(q,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(A,{children:s("subscribe.renew_order_event.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"change_order_event_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:u.onChange,value:u.value?.toString(),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(q,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(A,{children:s("subscribe.change_order_event.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"subscribe_path",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:"subscribe",...u,value:u.value||"",onChange:o=>{u.onChange(o),x(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:u.value||"s"}),e.jsx("br",{}),s("subscribe.subscribe_path.restart_tip")]}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"show_info_to_server_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(A,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:o=>{u.onChange(o),x(a.getValues())}})})]})}),e.jsx(j,{control:a.control,name:"show_protocol_to_server_enable",render:({field:u})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(A,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:u.value||!1,onCheckedChange:o=>{u.onChange(o),x(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function hu(){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(Re,{}),e.jsx(xu,{})]})}const gu=Object.freeze(Object.defineProperty({__proto__:null,default:hu},Symbol.toStringTag,{value:"Module"})),pu=h.object({invite_force:h.boolean().default(!1),invite_commission:h.coerce.string().default("0"),invite_gen_limit:h.coerce.string().default("0"),invite_never_expire:h.boolean().default(!1),commission_first_time_enable:h.boolean().default(!1),commission_auto_check_enable:h.boolean().default(!1),commission_withdraw_limit:h.coerce.string().default("0"),commission_withdraw_method:h.array(h.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:h.boolean().default(!1),commission_distribution_enable:h.boolean().default(!1),commission_distribution_l1:h.coerce.number().default(0),commission_distribution_l2:h.coerce.number().default(0),commission_distribution_l3:h.coerce.number().default(0)}),fu={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 ju(){const{t:s}=V("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),i=m.useRef(null),l=Ce({resolver:Te(pu),defaultValues:fu,mode:"onBlur"}),{data:d}=re({queryKey:["settings","invite"],queryFn:()=>ye.getSettings("invite")}),{mutateAsync:x}=As({mutationFn:ye.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data?.invite){const c=d?.data?.invite,p={};Object.entries(c).forEach(([F,T])=>{if(typeof T=="number"){const C=String(T);l.setValue(F,C),p[F]=C}else l.setValue(F,T),p[F]=T}),i.current=p,a(!0)}},[d]);const u=m.useCallback(Ie.debounce(async c=>{if(!Ie.isEqual(c,i.current)){t(!0);try{await x(c),i.current=c}finally{t(!1)}}},1e3),[x]),o=m.useCallback(c=>{r&&u(c)},[u,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(p=>{o(p)});return()=>c.unsubscribe()},[l.watch,o,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:l.control,name:"invite_force",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(A,{children:s("invite.invite_force.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"invite_commission",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("invite.invite_commission.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"invite_gen_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("invite.invite_gen_limit.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"invite_never_expire",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(A,{children:s("invite.invite_never_expire.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_first_time_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(A,{children:s("invite.commission_first_time.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_auto_check_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(A,{children:s("invite.commission_auto_check.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_withdraw_limit",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"commission_withdraw_method",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_method.placeholder"),...c,value:Array.isArray(c.value)?c.value.join(","):"",onChange:p=>{const F=p.target.value.split(",").filter(Boolean);c.onChange(F),o(l.getValues())}})}),e.jsx(A,{children:s("invite.commission_withdraw_method.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"withdraw_close_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(A,{children:s("invite.withdraw_close.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),e.jsx(j,{control:l.control,name:"commission_distribution_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(A,{children:s("invite.commission_distribution.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:p=>{c.onChange(p),o(l.getValues())}})})]})}),l.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:l.control,name:"commission_distribution_l1",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:s("invite.commission_distribution.l1")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:p=>{const F=p.target.value?Number(p.target.value):0;c.onChange(F),o(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"commission_distribution_l2",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:s("invite.commission_distribution.l2")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:p=>{const F=p.target.value?Number(p.target.value):0;c.onChange(F),o(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:l.control,name:"commission_distribution_l3",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:s("invite.commission_distribution.l3")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:p=>{const F=p.target.value?Number(p.target.value):0;c.onChange(F),o(l.getValues())}})}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.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("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(Re,{}),e.jsx(ju,{})]})}const bu=Object.freeze(Object.defineProperty({__proto__:null,default:vu},Symbol.toStringTag,{value:"Module"})),yu=h.object({frontend_theme:h.string().nullable(),frontend_theme_sidebar:h.string().nullable(),frontend_theme_header:h.string().nullable(),frontend_theme_color:h.string().nullable(),frontend_background_url:h.string().url().nullable()}),_u={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Nu(){const{data:s}=re({queryKey:["settings","frontend"],queryFn:()=>ye.getSettings("frontend")}),n=Ce({resolver:Te(yu),defaultValues:_u,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,i])=>{n.setValue(a,i)})}},[s]);function t(r){ye.saveSettings(r).then(({data:a})=>{a&&$.success("更新成功")})}return e.jsx(De,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(j,{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(v,{className:"text-base",children:"边栏风格"}),e.jsx(A,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(j,{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(v,{className:"text-base",children:"头部风格"}),e.jsx(A,{children:"边栏风格"})]}),e.jsx(b,{children:e.jsx(ee,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(f,{children:[e.jsx(v,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(b,{children:e.jsxs("select",{className:_(Mt({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(Mn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(A,{children:"主题色"}),e.jsx(R,{})]})}),e.jsx(j,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(f,{children:[e.jsx(v,{children:"背景"}),e.jsx(b,{children:e.jsx(D,{placeholder:"请输入图片地址",...r})}),e.jsx(A,{children:"将会在后台登录页面进行展示。"}),e.jsx(R,{})]})}),e.jsx(L,{type:"submit",children:"保存设置"})]})})}function wu(){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(Re,{}),e.jsx(Nu,{})]})}const Cu=Object.freeze(Object.defineProperty({__proto__:null,default:wu},Symbol.toStringTag,{value:"Module"})),Su=h.object({server_pull_interval:h.coerce.number().nullable(),server_push_interval:h.coerce.number().nullable(),server_token:h.string().nullable(),device_limit_mode:h.coerce.number().nullable()}),ku={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Tu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(Su),defaultValues:ku,mode:"onBlur"}),{data:i}=re({queryKey:["settings","server"],queryFn:()=>ye.getSettings("server")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:o=>{o.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(i?.data.server){const o=i.data.server;Object.entries(o).forEach(([c,p])=>{a.setValue(c,p)}),r.current=o}},[i]);const d=m.useCallback(Ie.debounce(async o=>{if(!Ie.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),x=m.useCallback(o=>{d(o)},[d]);m.useEffect(()=>{const o=a.watch(c=>{x(c)});return()=>o.unsubscribe()},[a.watch,x]);const u=()=>{const o=Math.floor(Math.random()*17)+16,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let p="";for(let F=0;Fe.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.server_token.title")}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...o,value:o.value||"",className:"pr-10"}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:c=>{c.preventDefault(),u()},children:e.jsx(sd,{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(A,{children:s("server.server_token.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"server_pull_interval",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...o,value:o.value||"",onChange:c=>{const p=c.target.value?Number(c.target.value):null;o.onChange(p)}})}),e.jsx(A,{children:s("server.server_pull_interval.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"server_push_interval",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...o,value:o.value||"",onChange:c=>{const p=c.target.value?Number(c.target.value):null;o.onChange(p)}})}),e.jsx(A,{children:s("server.server_push_interval.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"device_limit_mode",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(X,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(q,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(A,{children:s("server.device_limit_mode.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.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("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(Re,{}),e.jsx(Tu,{})]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"}));function Pu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(wl,{className:"h-5 w-5 text-green-500"}):e.jsx(Cl,{className:"h-5 w-5 text-destructive"}),e.jsx(me,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ue,{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(vt,{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 Lu=h.object({email_template:h.string().nullable().default("classic"),email_host:h.string().nullable().default(""),email_port:h.coerce.number().nullable().default(465),email_username:h.string().nullable().default(""),email_password:h.string().nullable().default(""),email_encryption:h.string().nullable().default(""),email_from_address:h.string().email().nullable().default(""),remind_mail_enable:h.boolean().nullable().default(!1)});function Ru(){const{t:s}=V("settings"),[n,t]=m.useState(null),[r,a]=m.useState(!1),i=m.useRef(null),[l,d]=m.useState(!1),x=Ce({resolver:Te(Lu),defaultValues:{},mode:"onBlur"}),{data:u}=re({queryKey:["settings","email"],queryFn:()=>ye.getSettings("email")}),{data:o}=re({queryKey:["emailTemplate"],queryFn:()=>ye.getEmailTemplate()}),{mutateAsync:c}=As({mutationFn:ye.saveSettings,onSuccess:P=>{P.data&&$.success(s("common.autoSaved"))}}),{mutate:p,isPending:F}=As({mutationFn:ye.sendTestMail,onMutate:()=>{t(null),a(!1)},onSuccess:P=>{t(P.data),a(!0),P.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(u?.data.email){const P=u.data.email;Object.entries(P).forEach(([N,I])=>{x.setValue(N,I)}),i.current=P}},[u]);const T=m.useCallback(Ie.debounce(async P=>{if(!Ie.isEqual(P,i.current)){d(!0);try{await c(P),i.current=P}finally{d(!1)}}},1e3),[c]),C=m.useCallback(P=>{T(P)},[T]);return m.useEffect(()=>{const P=x.watch(N=>{C(N)});return()=>P.unsubscribe()},[x.watch,C]),e.jsxs(e.Fragment,{children:[e.jsx(De,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"email_host",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_host.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_host.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_port",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_port.title")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...P,value:P.value||"",onChange:N=>{const I=N.target.value?Number(N.target.value):null;P.onChange(I)}})}),e.jsx(A,{children:s("email.email_port.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_encryption",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(X,{onValueChange:N=>{const I=N==="none"?"":N;P.onChange(I)},value:P.value===""||P.value===null||P.value===void 0?"none":P.value,children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:"请选择加密方式"})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"none",children:s("email.email_encryption.none")}),e.jsx(q,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(q,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(A,{children:s("email.email_encryption.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_username",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_username.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),autoComplete:"off",...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_username.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_password",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_password.title")}),e.jsx(b,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),autoComplete:"off",...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_password.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_from_address",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_from.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...P,value:P.value||""})}),e.jsx(A,{children:s("email.email_from.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"email_template",render:({field:P})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(X,{onValueChange:N=>{P.onChange(N),C(x.getValues())},value:P.value||void 0,children:[e.jsx(b,{children:e.jsx(J,{className:"w-[200px]",children:e.jsx(Z,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(Q,{children:o?.data?.map(N=>e.jsx(q,{value:N,children:N},N))})]}),e.jsx(A,{children:s("email.email_template.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"remind_mail_enable",render:({field:P})=>e.jsxs(f,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(A,{children:s("email.remind_mail.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:P.value||!1,onCheckedChange:N=>{P.onChange(N),C(x.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(L,{onClick:()=>p(),loading:F,disabled:F,children:s(F?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Pu,{open:r,onOpenChange:a,result:n})]})}function Eu(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(Re,{}),e.jsx(Ru,{})]})}const Iu=Object.freeze(Object.defineProperty({__proto__:null,default:Eu},Symbol.toStringTag,{value:"Module"})),Vu=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Mu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Ou(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(Vu),defaultValues:Mu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","telegram"],queryFn:()=>ye.getSettings("telegram")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}}),{mutate:d,isPending:x}=As({mutationFn:ye.setTelegramWebhook,onSuccess:c=>{c.data&&$.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(i?.data.telegram){const c=i.data.telegram;Object.entries(c).forEach(([p,F])=>{a.setValue(p,F)}),r.current=c}},[i]);const u=m.useCallback(Ie.debounce(async c=>{if(!Ie.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),o=m.useCallback(c=>{u(c)},[u]);return m.useEffect(()=>{const c=a.watch(p=>{o(p)});return()=>c.unsubscribe()},[a.watch,o]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:a.control,name:"telegram_bot_token",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("telegram.bot_token.description")}),e.jsx(R,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(L,{loading:x,disabled:x,onClick:()=>d(),children:s(x?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(A,{children:s("telegram.webhook.description")}),e.jsx(R,{})]}),e.jsx(j,{control:a.control,name:"telegram_bot_enable",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(A,{children:s("telegram.bot_enable.description")}),e.jsx(b,{children:e.jsx(ee,{checked:c.value||!1,onCheckedChange:p=>{c.onChange(p),o(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"telegram_discuss_link",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...c,value:c.value||""})}),e.jsx(A,{children:s("telegram.discuss_link.description")}),e.jsx(R,{})]})}),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("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(Re,{}),e.jsx(Ou,{})]})}const $u=Object.freeze(Object.defineProperty({__proto__:null,default:zu},Symbol.toStringTag,{value:"Module"})),Au=h.object({windows_version:h.string().nullable(),windows_download_url:h.string().nullable(),macos_version:h.string().nullable(),macos_download_url:h.string().nullable(),android_version:h.string().nullable(),android_download_url:h.string().nullable()}),qu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Uu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=Ce({resolver:Te(Au),defaultValues:qu,mode:"onBlur"}),{data:i}=re({queryKey:["settings","app"],queryFn:()=>ye.getSettings("app")}),{mutateAsync:l}=As({mutationFn:ye.saveSettings,onSuccess:u=>{u.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(i?.data.app){const u=i.data.app;Object.entries(u).forEach(([o,c])=>{a.setValue(o,c)}),r.current=u}},[i]);const d=m.useCallback(Ie.debounce(async u=>{if(!Ie.isEqual(u,r.current)){t(!0);try{await l(u),r.current=u}finally{t(!1)}}},1e3),[l]),x=m.useCallback(u=>{d(u)},[d]);return m.useEffect(()=>{const u=a.watch(o=>{x(o)});return()=>u.unsubscribe()},[a.watch,x]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:a.control,name:"windows_version",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.windows.version.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"windows_download_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.windows.download.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"macos_version",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.macos.version.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"macos_download_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.macos.download.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"android_version",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.android.version.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.android.version.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"android_download_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-base",children:s("app.android.download.title")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("common.placeholder"),...u,value:u.value||""})}),e.jsx(A,{children:s("app.android.download.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Hu(){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(Re,{}),e.jsx(Uu,{})]})}const Ku=Object.freeze(Object.defineProperty({__proto__:null,default:Hu},Symbol.toStringTag,{value:"Module"}));Vr.config({monaco:Mr});function xi({form:s,config:n,namePrefix:t="",className:r="space-y-4"}){const[a,i]=m.useState({}),l=x=>t?`${t}.${x}`:x,d=(x,u)=>{const o=l(x);switch(u.type){case"string":return e.jsx(j,{control:s.control,name:o,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsx(D,{placeholder:u.placeholder,...c})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"number":case"percentage":return e.jsx(j,{control:s.control,name:o,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:u.placeholder,min:u.min??(u.type==="percentage"?0:void 0),max:u.max??(u.type==="percentage"?100:void 0),step:u.step??(u.type==="percentage"?1:void 0),...c,onChange:p=>{const F=Number(p.target.value);u.type==="percentage"?c.onChange(Math.min(100,Math.max(0,F))):c.onChange(F)},className:u.type==="percentage"?"pr-8":""}),u.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(td,{className:"h-4 w-4 text-muted-foreground"})})]})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"select":return e.jsx(j,{control:s.control,name:o,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsxs(X,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:u.placeholder})})}),e.jsx(Q,{children:u.options?.map(p=>e.jsx(q,{value:p.value,children:p.label},p.value))})]}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"boolean":return e.jsx(j,{control:s.control,name:o,render:({field:c})=>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(v,{className:"text-base",children:u.label||u.description}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description})]}),e.jsx(b,{children:e.jsx(ee,{checked:c.value,onCheckedChange:c.onChange})})]})},x);case"text":return e.jsx(j,{control:s.control,name:o,render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsx(Es,{placeholder:u.placeholder,...c})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})},x);case"yaml":case"json":return e.jsx(j,{control:s.control,name:o,render:({field:c})=>{const p=(()=>{if(c.value===null||c.value===void 0)return"";if(typeof c.value=="string")return c.value;try{return JSON.stringify(c.value,null,2)}catch{return String(c.value)}})(),F=`${t}_${x}`,T=a[F]||150;return e.jsxs(f,{children:[e.jsx(v,{children:u.label||u.description}),e.jsx(b,{children:e.jsx("div",{className:"resize-y overflow-hidden rounded-md border",style:{height:`${T}px`},children:e.jsx(Or,{height:"100%",defaultLanguage:u.type,value:p,onChange:C=>{c.onChange(C||"")},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,formatOnPaste:u.type==="json",formatOnType:u.type==="json"}})})}),u.description&&u.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description}),e.jsx(R,{})]})}},x);default:return null}};return e.jsx("div",{className:r,children:Object.entries(n).map(([x,u])=>d(x,u))})}function hi(s){return Object.fromEntries(Object.entries(s).map(([n,t])=>{let r=t.value;if(t.type==="yaml"||t.type==="json"){if(r==null)r="";else if(typeof r!="string")try{r=JSON.stringify(r,null,2)}catch{r=String(r)}}return[n,r]}))}const Bu=s=>h.object({id:h.number().nullable(),name:h.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:h.string().optional().nullable(),notify_domain:h.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:h.coerce.number().min(0).optional().nullable(),handling_fee_percent:h.coerce.number().min(0).max(100).optional().nullable(),payment:h.string().min(1,s("form.validation.payment.required")),config:h.record(h.string(),h.string())}),yr={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function gi({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=yr}){const{t:a}=V("payment"),[i,l]=m.useState(!1),[d,x]=m.useState(!1),[u,o]=m.useState([]),[c,p]=m.useState([]),[F,T]=m.useState({}),C=Bu(a),P=Ce({resolver:Te(C),defaultValues:r,mode:"onChange"}),N=P.watch("payment");m.useEffect(()=>{i&&(async()=>{const{data:w}=await jt.getMethodList();o(w)})()},[i]),m.useEffect(()=>{if(!N||!i)return;(async()=>{const w={payment:N,...t==="edit"&&{id:Number(P.getValues("id"))}};try{const{data:S}=await jt.getMethodForm(w),O=Object.values(S);p(O);const E=Object.entries(S).reduce((k,[W,te])=>(k[W]=te,k),{});T(E);const g=hi(E);P.setValue("config",g)}catch(S){console.error("Failed to fetch payment method form:",S),p([]),T({})}})()},[N,i,P,t]);const I=async y=>{x(!0);try{(await jt.save(y)).data&&($.success(a("form.messages.success")),P.reset(yr),s(),l(!1))}finally{x(!1)}};return e.jsxs(de,{open:i,onOpenChange:l,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx($e,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(oe,{className:"max-h-[90vh] overflow-y-auto sm:max-w-[500px]",children:[e.jsx(he,{children:e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(De,{...P,children:e.jsxs("form",{onSubmit:P.handleSubmit(I),className:"space-y-4",children:[e.jsx(j,{control:P.control,name:"name",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("form.fields.name.placeholder"),...y})}),e.jsx(A,{children:a("form.fields.name.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:P.control,name:"icon",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.icon.label")}),e.jsx(b,{children:e.jsx(D,{...y,value:y.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(A,{children:a("form.fields.icon.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:P.control,name:"notify_domain",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.notify_domain.label")}),e.jsx(b,{children:e.jsx(D,{...y,value:y.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(A,{children:a("form.fields.notify_domain.description")}),e.jsx(R,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:P.control,name:"handling_fee_percent",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...y,value:y.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(R,{})]})}),e.jsx(j,{control:P.control,name:"handling_fee_fixed",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...y,value:y.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(R,{})]})})]}),e.jsx(j,{control:P.control,name:"payment",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.payment.label")}),e.jsxs(X,{onValueChange:y.onChange,defaultValue:y.value,children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(Q,{children:u.map(w=>e.jsx(q,{value:w,children:w},w))})]}),e.jsx(A,{children:a("form.fields.payment.description")}),e.jsx(R,{})]})}),Object.keys(F).length>0&&e.jsxs("div",{className:"space-y-4 ",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:a("form.sections.payment_config")}),e.jsx(xi,{form:P,config:F,namePrefix:"config",className:"space-y-4"})]}),e.jsxs(Oe,{className:"pt-4",children:[e.jsx(tt,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(L,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function z({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(L,{variant:"ghost",size:"default",className:_("-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(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(cr,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(_n,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Nn,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ad,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:_("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(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(cr,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const Wn=nd,pi=rd,Gu=ld,fi=m.forwardRef(({className:s,...n},t)=>e.jsx(kl,{className:_("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}));fi.displayName=kl.displayName;const Ja=m.forwardRef(({className:s,...n},t)=>e.jsxs(Gu,{children:[e.jsx(fi,{}),e.jsx(Tl,{ref:t,className:_("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})]}));Ja.displayName=Tl.displayName;const Qa=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});Qa.displayName="AlertDialogHeader";const Xa=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Xa.displayName="AlertDialogFooter";const Za=m.forwardRef(({className:s,...n},t)=>e.jsx(Dl,{ref:t,className:_("text-lg font-semibold",s),...n}));Za.displayName=Dl.displayName;const en=m.forwardRef(({className:s,...n},t)=>e.jsx(Fl,{ref:t,className:_("text-sm text-muted-foreground",s),...n}));en.displayName=Fl.displayName;const sn=m.forwardRef(({className:s,...n},t)=>e.jsx(Pl,{ref:t,className:_(Vt(),s),...n}));sn.displayName=Pl.displayName;const tn=m.forwardRef(({className:s,...n},t)=>e.jsx(Ll,{ref:t,className:_(Vt({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));tn.displayName=Ll.displayName;function hs({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Wn,{children:[e.jsx(pi,{asChild:!0,children:n}),e.jsxs(Ja,{className:_("sm:max-w-[425px]",d),children:[e.jsxs(Qa,{children:[e.jsx(Za,{children:t}),e.jsx(en,{children:r})]}),e.jsxs(Xa,{children:[e.jsx(tn,{asChild:!0,children:e.jsx(L,{variant:"outline",children:a})}),e.jsx(sn,{asChild:!0,children:e.jsx(L,{variant:l,onClick:s,children:i})})]})]})]})}const ji=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"})}),Wu=({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(Ha,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(z,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(z,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(ee,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await jt.updateStatus({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(z,{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(z,{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(z,{column:r,title:t("table.columns.notify_url")}),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{className:"ml-1",children:e.jsx(ji,{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(z,{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(gi,{refetch:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(lt,{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(hs,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await jt.drop({id:r.original.id});a&&s()},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(xs,{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 Yu({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(gi,{refetch:n}),e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),i&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(L,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Ju(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[x,u]=m.useState({"drag-handle":!1}),[o,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:p}=re({queryKey:["paymentList"],queryFn:async()=>{const{data:N}=await jt.getList();return d(N?.map(I=>({...I,enable:!!I.enable}))||[]),N}});m.useEffect(()=>{u({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const F=(N,I)=>{a&&(N.dataTransfer.setData("text/plain",I.toString()),N.currentTarget.classList.add("opacity-50"))},T=(N,I)=>{if(!a)return;N.preventDefault(),N.currentTarget.classList.remove("bg-muted");const y=parseInt(N.dataTransfer.getData("text/plain"));if(y===I)return;const w=[...l],[S]=w.splice(y,1);w.splice(I,0,S),d(w)},C=async()=>{a?jt.sort({ids:l.map(N=>N.id)}).then(()=>{p(),i(!1),$.success("排序保存成功")}):i(!0)},P=Ye({data:l,columns:Wu({refetch:p,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:x,pagination:o},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(rs,{table:P,toolbar:N=>e.jsx(Yu,{table:N,refetch:p,saveOrder:C,isSortMode:a}),draggable:a,onDragStart:F,onDragEnd:N=>N.currentTarget.classList.remove("opacity-50"),onDragOver:N=>{N.preventDefault(),N.currentTarget.classList.add("bg-muted")},onDragLeave:N=>N.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!a})}function Qu(){const{t:s}=V("payment");return e.jsxs(He,{children:[e.jsxs(Ke,{className:"flex items-center justify-between",children:[e.jsx(ds,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Ju,{})})]})]})}const Xu=Object.freeze(Object.defineProperty({__proto__:null,default:Qu},Symbol.toStringTag,{value:"Module"}));function Zu({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,i]=m.useState(!0),[l,d]=m.useState(!1),[x,u]=m.useState(null),o=id({config:od(cd())}),c=Ce({resolver:Te(o),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:T}=await Os.getPluginConfig(s);u(T);const C=hi(T);c.reset({config:C})}catch{$.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s,c,r]);const p=async F=>{d(!0);try{await Os.updatePluginConfig(s,F.config),$.success(r("messages.configSaveSuccess")),t()}catch{$.error(r("messages.configSaveError"))}finally{d(!1)}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{className:"h-4 w-[200px]"}),e.jsx(be,{className:"h-10 w-full"}),e.jsx(be,{className:"h-4 w-[200px]"}),e.jsx(be,{className:"h-10 w-full"})]}):e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(p),className:"space-y-4",children:[x&&e.jsx(xi,{form:c,config:x,namePrefix:"config"}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(L,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function ex(){const{t:s}=V("plugin"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(null),[d,x]=m.useState(""),[u,o]=m.useState("feature"),[c,p]=m.useState("all"),[F,T]=m.useState(!1),[C,P]=m.useState(!1),[N,I]=m.useState(!1),y=m.useRef(null),[w,S]=m.useState(!1),[O,E]=m.useState(""),{data:g,isLoading:k}=re({queryKey:["pluginTypes"],queryFn:async()=>{const{data:K}=await Os.getPluginTypes();return K}}),{data:W,isLoading:te,refetch:ae}=re({queryKey:["pluginList"],queryFn:async()=>{const{data:K}=await Os.getPluginList();return K}}),B=W?.filter(K=>K.name.toLowerCase().includes(d.toLowerCase())||K.description.toLowerCase().includes(d.toLowerCase())||K.code.toLowerCase().includes(d.toLowerCase())),se=()=>{if(!B)return[];let K=B;return u!=="all"&&(K=K.filter(H=>H.type===u)),c==="installed"?K=K.filter(H=>H.is_installed):c==="available"&&(K=K.filter(H=>!H.is_installed)),K},je=K=>g?.find(H=>H.value===K),ms=async K=>{t(K),Os.installPlugin(K).then(()=>{$.success(s("messages.installSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.installError"))}).finally(()=>{t(null)})},ze=async K=>{t(K),Os.upgradePlugin(K).then(()=>{$.success(s("messages.upgradeSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.upgradeError"))}).finally(()=>{t(null)})},le=async K=>{t(K),Os.uninstallPlugin(K).then(()=>{$.success(s("messages.uninstallSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},Ts=async(K,H)=>{t(K),(H?Os.disablePlugin:Os.enablePlugin)(K).then(()=>{$.success(s(H?"messages.disableSuccess":"messages.enableSuccess")),ae()}).catch(Ae=>{$.error(Ae.message||s(H?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},Ns=K=>{W?.find(H=>H.code===K),l(K),a(!0)},dt=async K=>{if(!K.name.endsWith(".zip")){$.error(s("upload.error.format"));return}T(!0),Os.uploadPlugin(K).then(()=>{$.success(s("messages.uploadSuccess")),P(!1),ae()}).catch(H=>{$.error(H.message||s("messages.uploadError"))}).finally(()=>{T(!1),y.current&&(y.current.value="")})},Is=K=>{K.preventDefault(),K.stopPropagation(),K.type==="dragenter"||K.type==="dragover"?I(!0):K.type==="dragleave"&&I(!1)},mt=K=>{K.preventDefault(),K.stopPropagation(),I(!1),K.dataTransfer.files&&K.dataTransfer.files[0]&&dt(K.dataTransfer.files[0])},ut=async K=>{t(K),Os.deletePlugin(K).then(()=>{$.success(s("messages.deleteSuccess")),ae()}).catch(H=>{$.error(H.message||s("messages.deleteError"))}).finally(()=>{t(null)})},xt=K=>dd(K||"",{walkTokens(H){(H.type==="image"||H.type==="link")&&(H.type="text",H.raw="",H.text="")}});return e.jsxs(He,{children:[e.jsxs(Ke,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(In,{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(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Vn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:d,onChange:K=>x(K.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(X,{value:c,onValueChange:p,children:[e.jsx(J,{className:"w-[140px]",children:e.jsx(Z,{placeholder:s("status.filter_placeholder",{defaultValue:"安装状态"})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:s("status.all",{defaultValue:"全部状态"})}),e.jsx(q,{value:"installed",children:s("status.installed",{defaultValue:"已安装"})}),e.jsx(q,{value:"available",children:s("status.available",{defaultValue:"可安装"})})]})]}),e.jsxs(L,{onClick:()=>P(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(Et,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsxs(_t,{value:u,onValueChange:o,className:"w-full",children:[e.jsxs(it,{children:[g?.map(K=>e.jsx(Ge,{value:K.value,children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:K.label})})},K.value)),e.jsx(Ge,{value:"all",children:s("tabs.all")})]}),e.jsx(ys,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:te||k?e.jsxs(e.Fragment,{children:[e.jsx(gn,{}),e.jsx(gn,{}),e.jsx(gn,{})]}):se().map(K=>e.jsx(_r,{plugin:K,typeInfo:je(K.type),onInstall:ms,onUpgrade:ze,onUninstall:le,onToggleEnable:Ts,onOpenConfig:Ns,onDelete:ut,isLoading:n===K.code,onShowReadme:K.readme?()=>{E(K.readme),S(!0)}:void 0},K.code))})}),g?.map(K=>e.jsx(ys,{value:K.value,className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:se().map(H=>e.jsx(_r,{plugin:H,typeInfo:je(H.type),onInstall:ms,onUpgrade:ze,onUninstall:le,onToggleEnable:Ts,onOpenConfig:Ns,onDelete:ut,isLoading:n===H.code,onShowReadme:H.readme?()=>{E(H.readme),S(!0)}:void 0},H.code))})},K.value))]})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(oe,{className:"sm:max-w-lg",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[W?.find(K=>K.code===i)?.name," ",s("config.title")]}),e.jsx(Ue,{children:s("config.description")})]}),i&&e.jsx(Zu,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),ae()}})]})}),e.jsx(de,{open:C,onOpenChange:P,children:e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(Ue,{children:s("upload.description")})]}),e.jsxs("div",{className:_("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",N&&"border-primary/50 bg-muted/50"),onDragEnter:Is,onDragLeave:Is,onDragOver:Is,onDrop:mt,children:[e.jsx("input",{type:"file",ref:y,className:"hidden",accept:".zip",onChange:K=>{const H=K.target.files?.[0];H&&dt(H)}}),F?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(Et,{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:()=>y.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(de,{open:w,onOpenChange:S,children:e.jsxs(oe,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsx(me,{children:s("readme.title",{defaultValue:"插件文档"})})}),e.jsx("div",{className:"markdown-body max-h-[60vh] overflow-y-auto",dangerouslySetInnerHTML:{__html:xt(O)}})]})})]})]})}function _r({plugin:s,onInstall:n,onUpgrade:t,onUninstall:r,onToggleEnable:a,onOpenConfig:i,onDelete:l,isLoading:d,onShowReadme:x,typeInfo:u}){const{t:o}=V("plugin");return e.jsx(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("h3",{className:"truncate text-base font-semibold",children:s.name}),u&&e.jsx(U,{variant:"outline",className:"border-primary/20 bg-primary/5 px-1.5 py-0.5 text-xs text-primary",children:u.label}),s.is_installed?e.jsx(U,{variant:s.is_enabled?"default":"outline",className:"px-1.5 py-0.5 text-xs",children:s.is_enabled?o("status.enabled"):o("status.disabled")}):e.jsx(U,{variant:"outline",className:"border-muted-foreground/30 bg-muted/30 px-1.5 py-0.5 text-xs text-muted-foreground",children:o("status.not_installed")})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1.5",children:[s.is_protected&&e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("div",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",children:e.jsx(md,{className:"h-3 w-3"})})}),e.jsx(ce,{children:e.jsx("p",{children:o("status.protected")})})]})}),s.readme&&e.jsx("button",{type:"button",onClick:x,className:"flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-primary",title:o("button.readme"),children:e.jsx(Cn,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"mb-2 flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:s.code})]}),e.jsxs("span",{children:["v",s.version]}),e.jsxs("span",{children:[o("author"),": ",s.author]})]}),e.jsx("p",{className:"mb-3 overflow-hidden text-ellipsis text-sm text-muted-foreground",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:s.description}),e.jsx("div",{className:"flex items-center justify-end gap-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[s.need_upgrade&&e.jsx(hs,{title:o("upgrade.title"),description:o("upgrade.description"),cancelText:o("common:cancel"),confirmText:o("upgrade.button"),variant:"default",onConfirm:async()=>t(s.code),children:e.jsxs(L,{variant:"destructive",size:"sm",disabled:d,className:"h-7 px-2 text-xs bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ud,{className:"mr-1 h-3 w-3"}),o("button.upgrade")]})}),s.config&&Object.keys(s.config).length>0&&e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>i(s.code),disabled:!s.is_enabled||d,className:"h-7 px-2 text-xs",children:[e.jsx(La,{className:"mr-1 h-3 w-3"}),o("button.config")]}),e.jsxs(L,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>a(s.code,s.is_enabled),disabled:d,className:"h-7 px-2 text-xs",children:[e.jsx(xd,{className:"mr-1 h-3 w-3"}),s.is_enabled?o("button.disable"):o("button.enable")]}),e.jsx(hs,{title:o("uninstall.title"),description:o("uninstall.description"),cancelText:o("common:cancel"),confirmText:o("uninstall.button"),variant:"destructive",onConfirm:async()=>r(s.code),children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-destructive",disabled:d||s.is_enabled,children:[e.jsx(xs,{className:"mr-1 h-3 w-3"}),o("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{onClick:()=>n(s.code),disabled:d,size:"sm",className:"h-7 px-3 text-xs",children:[d?e.jsx("div",{className:"mr-1 h-3 w-3 animate-spin rounded-full border border-current border-t-transparent"}):null,o("button.install")]}),s.can_be_deleted!==!1&&e.jsx(hs,{title:o("delete.title"),description:o("delete.description"),cancelText:o("common:cancel"),confirmText:o("delete.button"),variant:"destructive",onConfirm:async()=>l(s.code),children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",disabled:d,children:e.jsx(xs,{className:"h-3 w-3"})})})]})})]})})}function gn(){return e.jsxs(ke,{children:[e.jsxs(Fe,{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(be,{className:"h-6 w-[200px]"}),e.jsx(be,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(be,{className:"h-5 w-[120px]"}),e.jsx(be,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(be,{className:"h-4 w-[300px]"}),e.jsx(be,{className:"h-4 w-[150px]"})]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(be,{className:"h-9 w-[100px]"}),e.jsx(be,{className:"h-9 w-[100px]"}),e.jsx(be,{className:"h-8 w-8"})]})})]})}const sx=Object.freeze(Object.defineProperty({__proto__:null,default:ex},Symbol.toStringTag,{value:"Module"})),tx=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(D,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(Es,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:_(Vt({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 ax({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,x]=m.useState(!1),u=Ce({defaultValues:n.configs.reduce((p,F)=>(p[F.field_name]="",p),{})}),o=async()=>{l(!0),Qt.getConfig(s).then(({data:p})=>{Object.entries(p).forEach(([F,T])=>{u.setValue(F,T)})}).finally(()=>{l(!1)})},c=async p=>{x(!0),Qt.updateConfig(s,p).then(()=>{$.success(t("config.success")),a(!1)}).finally(()=>{x(!1)})};return e.jsxs(de,{open:r,onOpenChange:p=>{a(p),p?o():u.reset()},children:[e.jsx(cs,{asChild:!0,children:e.jsx(L,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(oe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:t("config.title",{name:n.name})}),e.jsx(Ue,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Pa,{className:"h-6 w-6 animate-spin"})}):e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(c),className:"space-y-4",children:[n.configs.map(p=>e.jsx(j,{control:u.control,name:p.field_name,render:({field:F})=>e.jsxs(f,{children:[e.jsx(v,{children:p.label}),e.jsx(b,{children:tx(p,F)}),e.jsx(R,{})]})},p.field_name)),e.jsxs(Oe,{className:"mt-6 gap-2",children:[e.jsx(L,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(L,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function nx(){const{t:s}=V("theme"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,x]=m.useState(!1),[u,o]=m.useState(null),c=m.useRef(null),[p,F]=m.useState(0),{data:T,isLoading:C,refetch:P}=re({queryKey:["themeList"],queryFn:async()=>{const{data:g}=await Qt.getList();return g}}),N=async g=>{t(g),ye.updateSystemConfig({frontend_theme:g}).then(()=>{$.success("主题切换成功"),P()}).finally(()=>{t(null)})},I=async g=>{if(!g.name.endsWith(".zip")){$.error(s("upload.error.format"));return}a(!0),Qt.upload(g).then(()=>{$.success("主题上传成功"),l(!1),P()}).finally(()=>{a(!1),c.current&&(c.current.value="")})},y=g=>{g.preventDefault(),g.stopPropagation(),g.type==="dragenter"||g.type==="dragover"?x(!0):g.type==="dragleave"&&x(!1)},w=g=>{g.preventDefault(),g.stopPropagation(),x(!1),g.dataTransfer.files&&g.dataTransfer.files[0]&&I(g.dataTransfer.files[0])},S=()=>{u&&F(g=>g===0?u.images.length-1:g-1)},O=()=>{u&&F(g=>g===u.images.length-1?0:g+1)},E=(g,k)=>{F(0),o({name:g,images:k})};return e.jsxs(He,{children:[e.jsxs(Ke,{className:"flex items-center justify-between",children:[e.jsx(ds,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(L,{onClick:()=>l(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Et,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Nr,{}),e.jsx(Nr,{})]}):T?.themes&&Object.entries(T.themes).map(([g,k])=>e.jsx(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:k.background_url?`url(${k.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:_("relative z-10 h-full transition-colors",k.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!k.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(hs,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(g===T?.active){$.error(s("card.delete.error.active"));return}t(g),Qt.drop(g).then(()=>{$.success("主题删除成功"),P()}).finally(()=>{t(null)})},children:e.jsx(L,{disabled:n===g,loading:n===g,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(xs,{className:"h-4 w-4"})})})}),e.jsxs(Fe,{children:[e.jsx(Me,{children:k.name}),e.jsx(st,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:k.description}),k.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:k.version})})]})})]}),e.jsxs(Pe,{className:"flex items-center justify-end space-x-3",children:[k.images&&Array.isArray(k.images)&&k.images.length>0&&e.jsx(L,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>E(k.name,k.images),children:e.jsx(hd,{className:"h-4 w-4"})}),e.jsx(ax,{themeKey:g,themeInfo:k}),e.jsx(L,{onClick:()=>N(g),disabled:n===g||g===T.active,loading:n===g,variant:g===T.active?"secondary":"default",children:g===T.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},g))}),e.jsx(de,{open:i,onOpenChange:l,children:e.jsxs(oe,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(Ue,{children:s("upload.description")})]}),e.jsxs("div",{className:_("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:y,onDragLeave:y,onDragOver:y,onDrop:w,children:[e.jsx("input",{type:"file",ref:c,className:"hidden",accept:".zip",onChange:g=>{const k=g.target.files?.[0];k&&I(k)}}),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(Et,{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:()=>c.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(de,{open:!!u,onOpenChange:g=>{g||(o(null),F(0))},children:e.jsxs(oe,{className:"max-w-4xl",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[u?.name," ",s("preview.title")]}),e.jsx(Ue,{className:"text-center",children:u&&s("preview.imageCount",{current:p+1,total:u.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:u?.images[p]&&e.jsx("img",{src:u.images[p],alt:`${u.name} 预览图 ${p+1}`,className:"h-full w-full object-contain"})}),u&&u.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(L,{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:S,children:e.jsx(pl,{className:"h-4 w-4"})}),e.jsx(L,{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:O,children:e.jsx(fl,{className:"h-4 w-4"})})]})]}),u&&u.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:u.images.map((g,k)=>e.jsx("button",{onClick:()=>F(k),className:_("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",p===k?"border-primary":"border-transparent"),children:e.jsx("img",{src:g,alt:`缩略图 ${k+1}`,className:"h-full w-full object-cover"})},k))})]})})]})]})}function Nr(){return e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsx(be,{className:"h-6 w-[200px]"}),e.jsx(be,{className:"h-4 w-[300px]"})]}),e.jsxs(Pe,{className:"flex items-center justify-end space-x-3",children:[e.jsx(be,{className:"h-10 w-[100px]"}),e.jsx(be,{className:"h-10 w-[100px]"})]})]})}const rx=Object.freeze(Object.defineProperty({__proto__:null,default:nx},Symbol.toStringTag,{value:"Module"})),an=m.forwardRef(({className:s,value:n=[],onChange:t,...r},a)=>{const[i,l]=m.useState("");m.useEffect(()=>{if(i.includes(",")){const x=new Set([...n,...i.split(",").map(u=>u.trim())]);t(Array.from(x)),l("")}},[i,t,n]);const d=()=>{if(i){const x=new Set([...n,i]);t(Array.from(x)),l("")}};return e.jsxs("div",{className:_(" 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(x=>e.jsxs(U,{variant:"secondary",children:[x,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(u=>u!==x))},children:e.jsx(kn,{className:"w-3"})})]},x)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"||x.key===","?(x.preventDefault(),d()):x.key==="Backspace"&&i.length===0&&n.length>0&&(x.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});an.displayName="InputTags";const lx=h.object({id:h.number().nullable(),title:h.string().min(1).max(250),content:h.string().min(1),show:h.boolean(),tags:h.array(h.string()),img_url:h.string().nullable()}),ix={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function vi({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=ix}){const{t:a}=V("notice"),[i,l]=m.useState(!1),d=Ce({resolver:Te(lx),defaultValues:r,mode:"onChange",shouldFocusError:!0}),x=new zn({html:!0});return e.jsx(De,{...d,children:e.jsxs(de,{onOpenChange:l,open:i,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx($e,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(oe,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ue,{})]}),e.jsx(j,{control:d.control,name:"title",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:a("form.fields.title.placeholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"content",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.content.label")}),e.jsx(b,{children:e.jsx($n,{style:{height:"500px"},value:u.value,renderHTML:o=>x.render(o),onChange:({text:o})=>{u.onChange(o)}})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"img_url",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...u,value:u.value||""})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"show",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:u.value,onCheckedChange:u.onChange})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"tags",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.fields.tags.label")}),e.jsx(b,{children:e.jsx(an,{value:u.value,onChange:u.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsxs(Oe,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(L,{type:"submit",onClick:u=>{u.preventDefault(),d.handleSubmit(async o=>{ra.save(o).then(({data:c})=>{c&&($.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function ox({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(vi,{refetch:n}),!r&&e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),i&&!r&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(L,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const cx=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(gd,{className:"h-4 w-4 cursor-move text-muted-foreground"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await ra.updateStatus(t.original.id);r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(z,{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(z,{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(vi,{refetch:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(lt,{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(hs,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{ra.drop(t.original.id).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 dx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState(!1),[o,c]=m.useState({}),[p,F]=m.useState({pageSize:50,pageIndex:0}),[T,C]=m.useState([]),{refetch:P}=re({queryKey:["notices"],queryFn:async()=>{const{data:S}=await ra.getList();return C(S),S}});m.useEffect(()=>{r({"drag-handle":x,content:!x,created_at:!x,actions:!x}),F({pageSize:x?99999:50,pageIndex:0})},[x]);const N=(S,O)=>{x&&(S.dataTransfer.setData("text/plain",O.toString()),S.currentTarget.classList.add("opacity-50"))},I=(S,O)=>{if(!x)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const E=parseInt(S.dataTransfer.getData("text/plain"));if(E===O)return;const g=[...T],[k]=g.splice(E,1);g.splice(O,0,k),C(g)},y=async()=>{if(!x){u(!0);return}ra.sort(T.map(S=>S.id)).then(()=>{$.success("排序保存成功"),u(!1),P()}).finally(()=>{u(!1)})},w=Ye({data:T??[],columns:cx(P),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:o,pagination:p},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:c,onPaginationChange:F,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:w,toolbar:S=>e.jsx(ox,{table:S,refetch:P,saveOrder:y,isSortMode:x}),draggable:x,onDragStart:N,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:I,showPagination:!x})})}function mx(){const{t:s}=V("notice");return e.jsxs(He,{children:[e.jsxs(Ke,{className:"flex items-center justify-between",children:[e.jsx(ds,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(dx,{})})]})]})}const ux=Object.freeze(Object.defineProperty({__proto__:null,default:mx},Symbol.toStringTag,{value:"Module"})),xx=h.object({id:h.number().nullable(),language:h.string().max(250),category:h.string().max(250),title:h.string().min(1).max(250),body:h.string().min(1),show:h.boolean()}),hx={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function bi({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=hx}){const{t:a}=V("knowledge"),[i,l]=m.useState(!1),d=Ce({resolver:Te(xx),defaultValues:r,mode:"onChange",shouldFocusError:!0}),x=new zn({html:!0});return m.useEffect(()=>{i&&r.id&&It.getInfo(r.id).then(({data:u})=>{d.reset(u)})},[r.id,d,i]),e.jsxs(de,{onOpenChange:l,open:i,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx($e,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(oe,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Ue,{})]}),e.jsxs(De,{...d,children:[e.jsx(j,{control:d.control,name:"title",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:a("form.titlePlaceholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"category",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(b,{children:e.jsx(D,{placeholder:a("form.categoryPlaceholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"language",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.language")}),e.jsx(b,{children:e.jsxs(X,{value:u.value,onValueChange:u.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("form.languagePlaceholder")})}),e.jsx(Q,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(o=>e.jsx(q,{value:o.value,className:"cursor-pointer",children:a(`languages.${o.value}`)},o.value))})]})})]})}),e.jsx(j,{control:d.control,name:"body",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.content")}),e.jsx(b,{children:e.jsx($n,{style:{height:"500px"},value:u.value,renderHTML:o=>x.render(o),onChange:({text:o})=>{u.onChange(o)}})}),e.jsx(R,{})]})}),e.jsx(j,{control:d.control,name:"show",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:u.value,onCheckedChange:u.onChange})})}),e.jsx(R,{})]})}),e.jsxs(Oe,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(L,{type:"submit",onClick:()=>{d.handleSubmit(u=>{It.save(u).then(({data:o})=>{o&&(d.reset(),$.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function gx({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ka,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(ot,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ct,{children:"No results found."}),e.jsx(gs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(qe,{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:_("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(yt,{className:_("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(Ot,{}),e.jsx(gs,{children:e.jsx(qe,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function px({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(bi,{refreshData:n}),e.jsx(D,{placeholder:i("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(gx,{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(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(L,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const fx=({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(Ha,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(z,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(z,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(ee,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{It.updateStatus({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(z,{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(z,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(U,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(z,{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(bi,{refreshData:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(lt,{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(hs,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{It.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(t("messages.operationSuccess")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 jx(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[x,u]=m.useState({"drag-handle":!1}),[o,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:p,isLoading:F,data:T}=re({queryKey:["knowledge"],queryFn:async()=>{const{data:y}=await It.getList();return d(y||[]),y}});m.useEffect(()=>{u({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const C=(y,w)=>{a&&(y.dataTransfer.setData("text/plain",w.toString()),y.currentTarget.classList.add("opacity-50"))},P=(y,w)=>{if(!a)return;y.preventDefault(),y.currentTarget.classList.remove("bg-muted");const S=parseInt(y.dataTransfer.getData("text/plain"));if(S===w)return;const O=[...l],[E]=O.splice(S,1);O.splice(w,0,E),d(O)},N=async()=>{a?It.sort({ids:l.map(y=>y.id)}).then(()=>{p(),i(!1),$.success("排序保存成功")}):i(!0)},I=Ye({data:l,columns:fx({refetch:p,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:x,pagination:o},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:u,onPaginationChange:c,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:I,toolbar:y=>e.jsx(px,{table:y,refetch:p,saveOrder:N,isSortMode:a}),draggable:a,onDragStart:C,onDragEnd:y=>y.currentTarget.classList.remove("opacity-50"),onDragOver:y=>{y.preventDefault(),y.currentTarget.classList.add("bg-muted")},onDragLeave:y=>y.currentTarget.classList.remove("bg-muted"),onDrop:P,showPagination:!a})}function vx(){const{t:s}=V("knowledge");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(jx,{})})]})]})}const bx=Object.freeze(Object.defineProperty({__proto__:null,default:vx},Symbol.toStringTag,{value:"Module"}));function yx(s,n){const[t,r]=m.useState(s);return m.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function pn(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 _x(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 Nx(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 yi=m.forwardRef(({className:s,...n},t)=>pd(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:_("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);yi.displayName="CommandEmpty";const rt=m.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:x,maxSelected:u=Number.MAX_SAFE_INTEGER,onMaxSelected:o,hidePlaceholderWhenSelected:c,disabled:p,groupBy:F,className:T,badgeClassName:C,selectFirstItem:P=!0,creatable:N=!1,triggerSearchOnFocus:I=!1,commandProps:y,inputProps:w,hideClearAllButton:S=!1},O)=>{const E=m.useRef(null),[g,k]=m.useState(!1),W=m.useRef(!1),[te,ae]=m.useState(!1),[B,se]=m.useState(s||[]),[je,ms]=m.useState(pn(r,F)),[ze,le]=m.useState(""),Ts=yx(ze,i||500);m.useImperativeHandle(O,()=>({selectedValue:[...B],input:E.current,focus:()=>E.current?.focus()}),[B]);const Ns=m.useCallback(H=>{const _e=B.filter(Ae=>Ae.value!==H.value);se(_e),n?.(_e)},[n,B]),dt=m.useCallback(H=>{const _e=E.current;_e&&((H.key==="Delete"||H.key==="Backspace")&&_e.value===""&&B.length>0&&(B[B.length-1].fixed||Ns(B[B.length-1])),H.key==="Escape"&&_e.blur())},[Ns,B]);m.useEffect(()=>{s&&se(s)},[s]),m.useEffect(()=>{if(!a||l)return;const H=pn(a||[],F);JSON.stringify(H)!==JSON.stringify(je)&&ms(H)},[r,a,F,l,je]),m.useEffect(()=>{const H=async()=>{ae(!0);const Ae=await l?.(Ts);ms(pn(Ae||[],F)),ae(!1)};(async()=>{!l||!g||(I&&await H(),Ts&&await H())})()},[Ts,F,g,I]);const Is=()=>{if(!N||Nx(je,[{value:ze,label:ze}])||B.find(_e=>_e.value===ze))return;const H=e.jsx(qe,{value:ze,className:"cursor-pointer",onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation()},onSelect:_e=>{if(B.length>=u){o?.(B.length);return}le("");const Ae=[...B,{value:_e,label:_e}];se(Ae),n?.(Ae)},children:`Create "${ze}"`});if(!l&&ze.length>0||l&&Ts.length>0&&!te)return H},mt=m.useCallback(()=>{if(x)return l&&!N&&Object.keys(je).length===0?e.jsx(qe,{value:"-",disabled:!0,children:x}):e.jsx(yi,{children:x})},[N,x,l,je]),ut=m.useMemo(()=>_x(je,B),[je,B]),xt=m.useCallback(()=>{if(y?.filter)return y.filter;if(N)return(H,_e)=>H.toLowerCase().includes(_e.toLowerCase())?1:-1},[N,y?.filter]),K=m.useCallback(()=>{const H=B.filter(_e=>_e.fixed);se(H),n?.(H)},[n,B]);return e.jsxs(Ys,{...y,onKeyDown:H=>{dt(H),y?.onKeyDown?.(H)},className:_("h-auto overflow-visible bg-transparent",y?.className),shouldFilter:y?.shouldFilter!==void 0?y.shouldFilter:!l,filter:xt(),children:[e.jsx("div",{className:_("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":B.length!==0,"cursor-text":!p&&B.length!==0},T),onClick:()=>{p||E.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[B.map(H=>e.jsxs(U,{className:_("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",C),"data-fixed":H.fixed,"data-disabled":p||void 0,children:[H.label,e.jsx("button",{className:_("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(p||H.fixed)&&"hidden"),onKeyDown:_e=>{_e.key==="Enter"&&Ns(H)},onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation()},onClick:()=>Ns(H),children:e.jsx(kn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},H.value)),e.jsx(ps.Input,{...w,ref:E,value:ze,disabled:p,onValueChange:H=>{le(H),w?.onValueChange?.(H)},onBlur:H=>{W.current===!1&&k(!1),w?.onBlur?.(H)},onFocus:H=>{k(!0),I&&l?.(Ts),w?.onFocus?.(H)},placeholder:c&&B.length!==0?"":t,className:_("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":c,"px-3 py-2":B.length===0,"ml-1":B.length!==0},w?.className)}),e.jsx("button",{type:"button",onClick:K,className:_((S||p||B.length<1||B.filter(H=>H.fixed).length===B.length)&&"hidden"),children:e.jsx(kn,{})})]})}),e.jsx("div",{className:"relative",children:g&&e.jsx(Js,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{W.current=!1},onMouseEnter:()=>{W.current=!0},onMouseUp:()=>{E.current?.focus()},children:te?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[mt(),Is(),!P&&e.jsx(qe,{value:"-",className:"hidden"}),Object.entries(ut).map(([H,_e])=>e.jsx(gs,{heading:H,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:_e.map(Ae=>e.jsx(qe,{value:Ae.value,disabled:Ae.disable,onMouseDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation()},onSelect:()=>{if(B.length>=u){o?.(B.length);return}le("");const Ne=[...B,Ae];se(Ne),n?.(Ne)},className:_("cursor-pointer",Ae.disable&&"cursor-default text-muted-foreground"),children:Ae.label},Ae.value))})},H))]})})})]})});rt.displayName="MultipleSelector";const wx=s=>h.object({id:h.number().optional(),name:h.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 nn({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),i=Ce({resolver:Te(wx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1),[x,u]=m.useState(!1),o=async c=>{u(!0),Nt.save(c).then(()=>{$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{u(!1)})};return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx($e,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ue,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(De,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(o),className:"space-y-4",children:[e.jsx(j,{control:i.control,name:"name",render:({field:c})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.name")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("form.namePlaceholder"),...c,className:"w-full"})}),e.jsx(A,{children:a("form.nameDescription")}),e.jsx(R,{})]})}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(tt,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(L,{type:"submit",disabled:x||!i.formState.isValid,children:[x&&e.jsx(Pa,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const _i=m.createContext(void 0);function Cx({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),[l,d]=m.useState(ge.Shadowsocks);return e.jsx(_i.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function Ni(){const s=m.useContext(_i);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function fn({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=V("server");m.useEffect(()=>{console.log(n)},[n]);const[i,l]=m.useState(!1),[d,x]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[u,o]=m.useState(null),c=N=>{if(!N)return null;try{const I=JSON.parse(N);return typeof I!="object"||I===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},p={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}},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:{}}}}}},F=()=>{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[]}},T=()=>{const N=c(d||"");if(N){$.error(N);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{$.error(a("network_settings.errors.save_failed"))}},C=N=>{x(N),o(c(N))},P=N=>{const I=p[N];if(I){const y=JSON.stringify(I.content,null,2);x(y),o(null)}};return m.useEffect(()=>{i&&console.log(n)},[i,n]),m.useEffect(()=>{i&&n&&Object.keys(n).length>0&&x(JSON.stringify(n,null,2))},[i,n]),e.jsxs(de,{open:i,onOpenChange:N=>{!N&&i&&T(),l(N)},children:[e.jsx(cs,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[F().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:F().map(N=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>P(N),children:a("network_settings.use_template",{template:p[N].label})},N))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Es,{className:`min-h-[200px] font-mono text-sm ${u?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:F().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:N=>C(N.target.value)}),u&&e.jsx("p",{className:"text-sm text-red-500",children:u})]})]}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(G,{onClick:T,disabled:!!u,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={},kx=Object.freeze(Object.defineProperty({__proto__:null,default:Sx},Symbol.toStringTag,{value:"Module"})),fp=Ed(kx),wr=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Tx=()=>{try{const s=jd.box.keyPair(),n=wr(dr.encodeBase64(s.secretKey)),t=wr(dr.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Dx=()=>{try{return Tx()}catch(s){throw console.error("Error generating key pair:",s),s}},Fx=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)},Px=()=>{const s=Math.floor(Math.random()*8)*2+2;return Fx(s)},Lx=h.object({cipher:h.string().default("aes-128-gcm"),plugin:h.string().optional().default(""),plugin_opts:h.string().optional().default(""),client_fingerprint:h.string().optional().default("chrome")}),Rx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({})}),Ex=h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({})}),Ix=h.object({version:h.coerce.number().default(2),alpn:h.string().default("h2"),obfs:h.object({open:h.coerce.boolean().default(!1),type:h.string().default("salamander"),password:h.string().default("")}).default({}),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),bandwidth:h.object({up:h.string().default(""),down:h.string().default("")}).default({}),hop_interval:h.number().optional(),port_range:h.string().optional()}),Vx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),reality_settings:h.object({server_port:h.coerce.number().default(443),server_name:h.string().default(""),allow_insecure:h.boolean().default(!1),public_key:h.string().default(""),private_key:h.string().default(""),short_id:h.string().default("")}).default({}),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({}),flow:h.string().default("")}),Mx=h.object({version:h.coerce.number().default(5),congestion_control:h.string().default("bbr"),alpn:h.array(h.string()).default(["h3"]),udp_relay_mode:h.string().default("native"),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ox=h.object({}),zx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),$x=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ax=h.object({transport:h.string().default("tcp"),multiplexing:h.string().default("MULTIPLEXING_LOW")}),qx=h.object({padding_scheme:h.array(h.string()).optional().default([]),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ve={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"],plugins:[{value:"none",label:"None"},{value:"obfs",label:"Simple Obfs"},{value:"v2ray-plugin",label:"V2Ray Plugin"}],clientFingerprints:[{value:"chrome",label:"Chrome"},{value:"firefox",label:"Firefox"},{value:"safari",label:"Safari"},{value:"ios",label:"iOS"}]},vmess:{schema:Rx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Ex,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Ix,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Vx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},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:Ox},naive:{schema:$x},http:{schema:zx},mieru:{schema:Ax,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:qx,defaultPaddingScheme:["stop=8","0=30-30","1=100-400","2=400-500,c,500-1000,c,500-1000,c,500-1000,c,500-1000","3=9-9,500-1000","4=500-1000","5=500-1000","6=500-1000","7=500-1000"]}},Ux=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Ve[s]:null,i=a?.schema||h.record(h.any()),l=s?i.parse({}):{},d=Ce({resolver:Te(i),defaultValues:l,mode:"onChange"}),[x,u]=m.useState(!1),[o,c]=m.useState("");if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const g=i.parse({});d.reset(g)}}else d.reset(n)},[s,n,t,d,i]),m.useEffect(()=>{const g=d.watch(k=>{t(k)});return()=>g.unsubscribe()},[d,t]),!s||!a)return null;const E={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"cipher",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(b,{children:e.jsxs(es,{open:x,onOpenChange:u,children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":x,className:_("w-full justify-between",!g.value&&"text-muted-foreground"),disabled:!1,children:[g.value||r("dynamic_form.shadowsocks.cipher.placeholder"),e.jsx(fd,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(We,{className:"w-[400px] p-0",align:"start",children:e.jsxs(Ys,{shouldFilter:!1,children:[e.jsx(ot,{placeholder:r("dynamic_form.shadowsocks.cipher.search_placeholder"),value:o,onValueChange:k=>{c(k),k&&!Ve.shadowsocks.ciphers.includes(k)&&g.onChange(k)}}),e.jsxs(Js,{children:[e.jsxs(ct,{children:[o&&e.jsxs(qe,{value:o,onSelect:k=>{g.onChange(k),c(""),u(!1)},children:[e.jsx(Na,{className:"mr-2 h-4 w-4 opacity-100"}),e.jsxs("span",{className:"font-medium text-blue-600",children:[r("dynamic_form.shadowsocks.cipher.use_custom"),' "',o,'"']}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",r("dynamic_form.shadowsocks.cipher.custom_label"),")"]})]}),!o&&e.jsxs("div",{className:"p-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:r("dynamic_form.shadowsocks.cipher.no_results")}),e.jsx("p",{className:"mt-1 text-xs",children:r("dynamic_form.shadowsocks.cipher.custom_hint")})]})]}),e.jsx(gs,{heading:r("dynamic_form.shadowsocks.cipher.preset_group"),children:Ve.shadowsocks.ciphers.filter(k=>k.toLowerCase().includes(o.toLowerCase())).map(k=>e.jsxs(qe,{value:k,onSelect:W=>{g.onChange(W),c(""),u(!1)},children:[e.jsx(Na,{className:_("mr-2 h-4 w-4",g.value===k?"opacity-100":"opacity-0")}),k]},k))}),g.value&&!Ve.shadowsocks.ciphers.includes(g.value)&&e.jsx(gs,{heading:r("dynamic_form.shadowsocks.cipher.custom_group"),children:e.jsxs(qe,{value:g.value,onSelect:()=>{},children:[e.jsx(Na,{className:"mr-2 h-4 w-4 opacity-100"}),e.jsx("span",{className:"font-medium text-blue-600",children:g.value}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",r("dynamic_form.shadowsocks.cipher.current_value"),")"]})]})})]})]})})]})}),e.jsx(A,{children:r("dynamic_form.shadowsocks.cipher.description")})]})}),e.jsx(j,{control:d.control,name:"plugin",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.plugin.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:k=>g.onChange(k==="none"?"":k),value:g.value===""?"none":g.value||"none",children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.shadowsocks.plugin.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.shadowsocks.plugins.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})}),e.jsx(A,{children:g.value&&g.value!=="none"&&g.value!==""&&e.jsxs(e.Fragment,{children:[g.value==="obfs"&&r("dynamic_form.shadowsocks.plugin.obfs_hint"),g.value==="v2ray-plugin"&&r("dynamic_form.shadowsocks.plugin.v2ray_hint")]})})]})}),d.watch("plugin")&&d.watch("plugin")!=="none"&&d.watch("plugin")!==""&&e.jsx(j,{control:d.control,name:"plugin_opts",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.plugin_opts.label")}),e.jsx(A,{children:r("dynamic_form.shadowsocks.plugin_opts.description")}),e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:r("dynamic_form.shadowsocks.plugin_opts.placeholder"),...g})})]})}),(d.watch("plugin")==="shadow-tls"||d.watch("plugin")==="restls")&&e.jsx(j,{control:d.control,name:"client_fingerprint",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.client_fingerprint")}),e.jsx(b,{children:e.jsxs(X,{value:g.value||"chrome",onValueChange:g.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.shadowsocks.client_fingerprint_placeholder")})}),e.jsx(Q,{children:Ve.shadowsocks.clientFingerprints.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})]})}),e.jsx(A,{children:r("dynamic_form.shadowsocks.client_fingerprint_description")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(q,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"network",render:({field:g})=>e.jsxs(f,{children:[e.jsxs(v,{children:[r("dynamic_form.vmess.network.label"),e.jsx(fn,{value:d.watch("network_settings"),setValue:k=>d.setValue("network_settings",k),templateType:d.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.vmess.networkOptions.map(k=>e.jsx(q,{value:k.value,className:"cursor-pointer",children:k.label},k.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(j,{control:d.control,name:"allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"network",render:({field:g})=>e.jsxs(f,{children:[e.jsxs(v,{children:[r("dynamic_form.trojan.network.label"),e.jsx(fn,{value:d.watch("network_settings")||{},setValue:k=>d.setValue("network_settings",k),templateType:d.watch("network")||"tcp"})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value||"tcp",children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.trojan.networkOptions.map(k=>e.jsx(q,{value:k.value,className:"cursor-pointer",children:k.label},k.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"version",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:(g.value||2).toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.hysteria.versions.map(k=>e.jsxs(q,{value:k,className:"cursor-pointer",children:["V",k]},k))})})]})})]})}),d.watch("version")==1&&e.jsx(j,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value||"h2",onValueChange:g.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.hysteria.alpnOptions.map(k=>e.jsx(q,{value:k,children:k},k))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"obfs.open",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(j,{control:d.control,name:"obfs.type",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value||"salamander",onValueChange:g.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:e.jsx(q,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(j,{control:d.control,name:"obfs.password",render:({field:g})=>e.jsxs(f,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...g,value:g.value||"",className:"pr-9"})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",W=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(te=>k[te%k.length]).join("");d.setValue("obfs.password",W),$.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 transition-transform duration-150 active:scale-90",children:e.jsx($e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform duration-300 hover:rotate-180"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(j,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"bandwidth.up",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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(j,{control:d.control,name:"bandwidth.down",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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")})})]})]})}),e.jsx(e.Fragment,{children:e.jsx(j,{control:d.control,name:"hop_interval",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...g,value:g.value||"",onChange:k=>{const W=k.target.value?parseInt(k.target.value):void 0;g.onChange(W)}})}),e.jsx(A,{children:r("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(q,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(q,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"reality_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"reality_settings.server_port",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"reality_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(j,{control:d.control,name:"reality_settings.private_key",render:({field:g})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...g,className:"pr-9"})}),e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const k=Dx();d.setValue("reality_settings.private_key",k.privateKey),d.setValue("reality_settings.public_key",k.publicKey),$.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 transition-transform duration-150 active:scale-90",children:e.jsx($e,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform duration-300 hover:rotate-180"})})}),e.jsx(Ra,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(j,{control:d.control,name:"reality_settings.public_key",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(b,{children:e.jsx(D,{...g})})]})}),e.jsx(j,{control:d.control,name:"reality_settings.short_id",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{children:e.jsx(D,{...g,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const k=Px();d.setValue("reality_settings.short_id",k),$.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 transition-transform duration-150 active:scale-90",children:e.jsx($e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform duration-300 hover:rotate-180"})})}),e.jsx(Ra,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(A,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(j,{control:d.control,name:"network",render:({field:g})=>e.jsxs(f,{children:[e.jsxs(v,{children:[r("dynamic_form.vless.network.label"),e.jsx(fn,{value:d.watch("network_settings"),setValue:k=>d.setValue("network_settings",k),templateType:d.watch("network")})]}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.vless.networkOptions.map(k=>e.jsx(q,{value:k.value,className:"cursor-pointer",children:k.label},k.value))})})]})})]})}),e.jsx(j,{control:d.control,name:"flow",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.vless.flow.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:k=>g.onChange(k==="none"?null:k),value:g.value||"none",children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(Q,{children:Ve.vless.flowOptions.map(k=>e.jsx(q,{value:k,children:k},k))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"version",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.version.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.tuic.versions.map(k=>e.jsxs(q,{value:k,children:["V",k]},k))})})]})})]})}),e.jsx(j,{control:d.control,name:"congestion_control",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.tuic.congestionControls.map(k=>e.jsx(q,{value:k,children:k.toUpperCase()},k))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(j,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(b,{children:e.jsx(rt,{options:Ve.tuic.alpnOptions,onChange:k=>g.onChange(k.map(W=>W.value)),value:Ve.tuic.alpnOptions.filter(k=>g.value?.includes(k.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(j,{control:d.control,name:"udp_relay_mode",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.tuic.udpRelayModes.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.naive.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(q,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.http.tls.label")}),e.jsx(b,{children:e.jsxs(X,{value:g.value?.toString(),onValueChange:k=>g.onChange(Number(k)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(q,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:d.control,name:"transport",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.mieru.transportOptions.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})})]})}),e.jsx(j,{control:d.control,name:"multiplexing",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(b,{children:e.jsxs(X,{onValueChange:g.onChange,value:g.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(Q,{children:e.jsx(ws,{children:Ve.mieru.multiplexingOptions.map(k=>e.jsx(q,{value:k.value,children:k.label},k.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:d.control,name:"padding_scheme",render:({field:g})=>e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(v,{children:r("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{d.setValue("padding_scheme",Ve.anytls.defaultPaddingScheme),$.success(r("dynamic_form.anytls.padding_scheme.default_success","已设置默认填充方案"))},className:"h-7 px-2",children:r("dynamic_form.anytls.padding_scheme.use_default","使用默认方案")})]}),e.jsx(A,{children:r("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(b,{children:e.jsx("textarea",{className:"flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:r("dynamic_form.anytls.padding_scheme.placeholder",`例如: stop=8 0=30-30 1=100-400 2=400-500,c,500-1000`),...g,value:Array.isArray(g.value)?g.value.join(` `):"",onChange:k=>{const te=k.target.value.split(` -`).filter(ae=>ae.trim()!=="");g.onChange(te)}})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.anytls.tls.server_name.label","SNI")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.anytls.tls.server_name.placeholder","服务器名称"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.anytls.tls.allow_insecure","允许不安全连接")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]})})};return e.jsx(pe,{children:E[s]?.()})};function Hx(){const{t:s}=V("server"),n=h.object({start:h.string().min(1,s("form.dynamic_rate.start_time_error")),end:h.string().min(1,s("form.dynamic_rate.end_time_error")),rate:h.string().min(1,s("form.dynamic_rate.multiplier_error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.dynamic_rate.multiplier_error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.dynamic_rate.multiplier_error_gte_zero")})}),t=h.object({id:h.number().optional().nullable(),specific_key:h.string().optional().nullable(),code:h.string().optional(),show:h.boolean().optional().nullable(),name:h.string().min(1,s("form.name.error")),rate:h.string().min(1,s("form.rate.error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.rate.error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.rate.error_gte_zero")}),rate_time_enable:h.boolean().default(!1),rate_time_ranges:h.array(n).default([]),tags:h.array(h.string()).default([]),excludes:h.array(h.string()).default([]),ips:h.array(h.string()).default([]),group_ids:h.array(h.string()).default([]),host:h.string().min(1,s("form.host.error")),port:h.string().min(1,s("form.port.error")),server_port:h.string().min(1,s("form.server_port.error")),parent_id:h.string().default("0").nullable(),route_ids:h.array(h.string()).default([]),protocol_settings:h.record(h.any()).default({}).nullable()}),r={id:null,specific_key:null,code:"",show:!1,name:"",rate:"1",rate_time_enable:!1,rate_time_ranges:[],tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null},{isOpen:a,setIsOpen:o,editingServer:l,setEditingServer:d,serverType:x,setServerType:u,refetch:i}=Ni(),[c,p]=m.useState([]),[F,T]=m.useState([]),[C,P]=m.useState([]),w=Ce({resolver:Te(t),defaultValues:r,mode:"onChange"});m.useEffect(()=>{I()},[a]),m.useEffect(()=>{l?.type&&l.type!==x&&u(l.type)},[l,x,u]),m.useEffect(()=>{l?l.type===x&&w.reset({...r,...l}):w.reset({...r,protocol_settings:Ve[x].schema.parse({})})},[l,w,x]);const I=async()=>{if(!a)return;const[E,g,k]=await Promise.all([_t.getList(),Ba.getList(),pt.getList()]);p(E.data?.map(W=>({label:W.name,value:W.id.toString()}))||[]),T(g.data?.map(W=>({label:W.remarks,value:W.id.toString()}))||[]),P(k.data||[])},y=m.useMemo(()=>C?.filter(E=>(E.parent_id===0||E.parent_id===null)&&E.type===x&&E.id!==w.watch("id")),[x,C,w]),N=()=>e.jsxs(Hs,{children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(qs,{align:"start",children:e.jsx(pm,{children:Fs.map(({type:E,label:g})=>e.jsx(Se,{onClick:()=>{u(E),o(!0)},className:"cursor-pointer",children:e.jsx(U,{variant:"outline",className:"text-white",style:{background:bs[E]},children:g})},E))})})]}),S=()=>{o(!1),d(null),w.reset(r)},O=async()=>{const E=w.getValues();(await pt.save({...E,type:x})).data&&(S(),$.success(s("form.success")),i())};return e.jsxs(de,{open:a,onOpenChange:S,children:[N(),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(qe,{})]}),e.jsxs(De,{...w,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:w.control,name:"name",render:({field:E})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:s("form.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:"rate",render:({field:E})=>e.jsxs(f,{className:"flex-[1]",children:[e.jsx(v,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...E})})}),e.jsx(R,{})]})})]}),e.jsx(j,{control:w.control,name:"rate_time_enable",render:({field:E})=>e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(v,{children:s("form.dynamic_rate.enable_label")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("form.dynamic_rate.enable_description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:E.value,onCheckedChange:E.onChange})})]}),e.jsx(R,{})]})}),w.watch("rate_time_enable")&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(v,{className:"",children:s("form.dynamic_rate.rules_label")}),e.jsxs(L,{type:"button",variant:"outline",size:"sm",onClick:()=>{const E=w.getValues("rate_time_ranges")||[];w.setValue("rate_time_ranges",[...E,{start:"00:00",end:"23:59",rate:"1"}])},children:[e.jsx(Be,{icon:"ion:add",className:"mr-1 size-4"}),s("form.dynamic_rate.add_rule")]})]}),(w.watch("rate_time_ranges")||[]).map((E,g)=>e.jsxs("div",{className:"space-y-2 rounded border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:s("form.dynamic_rate.rule_title",{index:g+1})}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",onClick:()=>{const k=w.getValues("rate_time_ranges")||[];k.splice(g,1),w.setValue("rate_time_ranges",[...k])},children:e.jsx(Be,{icon:"ion:trash-outline",className:"size-4"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(j,{control:w.control,name:`rate_time_ranges.${g}.start`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-xs",children:s("form.dynamic_rate.start_time")}),e.jsx(b,{children:e.jsx(D,{type:"time",...k,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:`rate_time_ranges.${g}.end`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-xs",children:s("form.dynamic_rate.end_time")}),e.jsx(b,{children:e.jsx(D,{type:"time",...k,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:`rate_time_ranges.${g}.rate`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-xs",children:s("form.dynamic_rate.multiplier")}),e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...k,className:"text-sm",placeholder:"1.0"})}),e.jsx(R,{})]})})]})]},g)),(w.watch("rate_time_ranges")||[]).length===0&&e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:s("form.dynamic_rate.no_rules")})]}),e.jsx(j,{control:w.control,name:"code",render:({field:E})=>e.jsxs(f,{children:[e.jsxs(v,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(b,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...E,value:E.value||""})}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:"tags",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.tags.label")}),e.jsx(b,{children:e.jsx(tn,{value:E.value,onChange:E.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:"group_ids",render:({field:E})=>e.jsxs(f,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(an,{dialogTrigger:e.jsx(L,{variant:"link",children:s("form.groups.add")}),refetch:I})]}),e.jsx(b,{children:e.jsx(nt,{options:c,onChange:g=>E.onChange(g.map(k=>k.value)),value:c?.filter(g=>E.value.includes(g.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(R,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:w.control,name:"host",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.host.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{control:w.control,name:"port",render:({field:E})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(Be,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(La,{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(b,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...E})}),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const g=E.value;g&&w.setValue("server_port",g)},children:e.jsx(Be,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ce,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:"server_port",render:({field:E})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(Be,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(La,{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(b,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...E})}),e.jsx(R,{})]})})]})]}),a&&e.jsx(Ux,{serverType:x,value:w.watch("protocol_settings"),onChange:E=>w.setValue("protocol_settings",E,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(j,{control:w.control,name:"parent_id",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.parent.label")}),e.jsxs(X,{onValueChange:E.onChange,value:E.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("form.parent.none")}),y?.map(g=>e.jsx(q,{value:g.id.toString(),className:"cursor-pointer",children:g.name},g.id))]})]}),e.jsx(R,{})]})}),e.jsx(j,{control:w.control,name:"route_ids",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.route.label")}),e.jsx(b,{children:e.jsx(nt,{options:F,onChange:g=>E.onChange(g.map(k=>k.value)),value:F?.filter(g=>E.value.includes(g.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(R,{})]})})]}),e.jsxs(Oe,{className:"mt-6 flex flex-col gap-2 sm:flex-row sm:gap-0",children:[e.jsx(L,{type:"button",variant:"outline",onClick:S,className:"w-full sm:w-auto",children:s("form.cancel")}),e.jsx(L,{type:"submit",onClick:O,className:"w-full sm:w-auto",children:s("form.submit")})]})]})]})]})}function Cr({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ha,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(o=>a.has(o.value)).map(o=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(it,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ot,{children:"No results found."}),e.jsx(gs,{children:t.map(o=>{const l=a.has(o.value);return e.jsxs(Ae,{onSelect:()=>{l?a.delete(o.value):a.add(o.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:_("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(bt,{className:_("h-4 w-4")})}),o.icon&&e.jsx(o.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${o.color}`}),e.jsx("span",{children:o.label}),r?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(o.value)})]},o.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ot,{}),e.jsx(gs,{children:e.jsx(Ae,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Kx=[{value:ge.Shadowsocks,label:Fs.find(s=>s.type===ge.Shadowsocks)?.label,color:bs[ge.Shadowsocks]},{value:ge.Vmess,label:Fs.find(s=>s.type===ge.Vmess)?.label,color:bs[ge.Vmess]},{value:ge.Trojan,label:Fs.find(s=>s.type===ge.Trojan)?.label,color:bs[ge.Trojan]},{value:ge.Hysteria,label:Fs.find(s=>s.type===ge.Hysteria)?.label,color:bs[ge.Hysteria]},{value:ge.Vless,label:Fs.find(s=>s.type===ge.Vless)?.label,color:bs[ge.Vless]},{value:ge.Tuic,label:Fs.find(s=>s.type===ge.Tuic)?.label,color:bs[ge.Tuic]},{value:ge.Socks,label:Fs.find(s=>s.type===ge.Socks)?.label,color:bs[ge.Socks]},{value:ge.Naive,label:Fs.find(s=>s.type===ge.Naive)?.label,color:bs[ge.Naive]},{value:ge.Http,label:Fs.find(s=>s.type===ge.Http)?.label,color:bs[ge.Http]},{value:ge.Mieru,label:Fs.find(s=>s.type===ge.Mieru)?.label,color:bs[ge.Mieru]}];function Bx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:o}=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(Hx,{}),e.jsx(D,{placeholder:o("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(Cr,{column:s.getColumn("type"),title:o("toolbar.type"),options:Kx}),s.getColumn("group_ids")&&e.jsx(Cr,{column:s.getColumn("group_ids"),title:o("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[o("toolbar.reset"),e.jsx(os,{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:o("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(L,{variant:t?"default":"outline",onClick:n,size:"sm",children:o(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const Ma=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"})}),ja={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"},Ke=(s,n)=>n>0?Math.round(s/n*100):0,Gx=s=>{const{t:n}=V("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ua,{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(z,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(U,{variant:"outline",className:_("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:bs[t.original.type]},children:[e.jsx(Rl,{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(L,{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:o=>{o.stopPropagation(),Et(a||r.toString()).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(dr,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Fs.find(o=>o.type===t.original.type)?.label,t.original.parent?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=m.useState(!!t.getValue("show"));return e.jsx(ee,{checked:r,onCheckedChange:async o=>{a(o),pt.update({id:t.original.id,type:t.original.type,show:o?1:0}).catch(()=>{a(!o),s()})},style:{backgroundColor:r?bs[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(z,{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:_("h-2.5 w-2.5 rounded-full",ja[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:_("h-2.5 w-2.5 rounded-full",ja[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:_("h-2.5 w-2.5 rounded-full",ja[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:_("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",ja[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.jsxs("div",{className:" space-y-3",children:[e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)}),t.original.load_status&&e.jsxs("div",{className:"border-t border-border/50 pt-3",children:[e.jsx("p",{className:"mb-3 text-sm font-medium",children:n("columns.loadStatus.details")}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsx("div",{children:e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.cpu"),":"]}),e.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",t.original.load_status.cpu>=90?"bg-destructive":t.original.load_status.cpu>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Math.min(100,t.original.load_status.cpu)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",t.original.load_status.cpu>=90?"text-destructive":t.original.load_status.cpu>=70?"text-yellow-600":"text-emerald-600"),children:[Math.round(t.original.load_status.cpu),"%"]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.memory"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",Ke(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"bg-destructive":Ke(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Ke(t.original.load_status.mem.used,t.original.load_status.mem.total)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",Ke(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"text-destructive":Ke(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Ke(t.original.load_status.mem.used,t.original.load_status.mem.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[Le(t.original.load_status.mem.used)," ","/"," ",Le(t.original.load_status.mem.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.swap"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",Ke(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"bg-destructive":Ke(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Ke(t.original.load_status.swap.used,t.original.load_status.swap.total)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",Ke(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"text-destructive":Ke(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"text-yellow-600":"text-emerald-600"),children:[Ke(t.original.load_status.swap.used,t.original.load_status.swap.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[Le(t.original.load_status.swap.used)," ","/"," ",Le(t.original.load_status.swap.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.disk"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",Ke(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"bg-destructive":Ke(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Ke(t.original.load_status.disk.used,t.original.load_status.disk.total)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",Ke(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"text-destructive":Ke(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Ke(t.original.load_status.disk.used,t.original.load_status.disk.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[Le(t.original.load_status.disk.used)," ","/"," ",Le(t.original.load_status.disk.total)]})]})]})]})]})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(z,{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(pe,{delayDuration:0,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{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:o=>{o.stopPropagation(),Et(r).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(dr,{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(z,{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(Ma,{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(z,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(U,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(z,{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,o)=>e.jsx(U,{variant:"secondary",className:_("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},o)),r.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})]})},enableSorting:!1,filterFn:(t,r,a)=>{const o=t.getValue(r);return o?a.some(l=>o.includes(l)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(U,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:bs[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:o}=Ni();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Hs,{modal:!1,children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Ra,{className:"size-4"})})}),e.jsxs(qs,{align:"end",className:"w-40",children:[e.jsx(Se,{className:"cursor-pointer",onClick:()=>{o(t.original.type),a(t.original),r(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(vd,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(Se,{className:"cursor-pointer",onClick:async()=>{pt.copy({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx($n,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(at,{}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(hs,{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()=>{pt.drop({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(xs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Wx(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,o]=m.useState([]),[l,d]=m.useState({pageSize:500,pageIndex:0}),[x,u]=m.useState([]),[i,c]=m.useState(!1),[p,F]=m.useState({}),[T,C]=m.useState([]),{refetch:P}=re({queryKey:["nodeList"],queryFn:async()=>{const{data:O}=await pt.getList();return C(O),O}}),{data:w}=re({queryKey:["groups"],queryFn:async()=>{const{data:O}=await _t.getList();return O}});m.useEffect(()=>{r({"drag-handle":i,show:!i,host:!i,online:!i,rate:!i,groups:!i,type:!1,actions:!i}),F({name:i?2e3:200}),d({pageSize:i?99999:500,pageIndex:0})},[i]);const I=(O,E)=>{i&&(O.dataTransfer.setData("text/plain",E.toString()),O.currentTarget.classList.add("opacity-50"))},y=(O,E)=>{if(!i)return;O.preventDefault(),O.currentTarget.classList.remove("bg-muted");const g=parseInt(O.dataTransfer.getData("text/plain"));if(g===E)return;const k=[...T],[W]=k.splice(g,1);k.splice(E,0,W),C(k)},N=async()=>{if(!i){c(!0);return}const O=T?.map((E,g)=>({id:E.id,order:g+1}));pt.sort(O).then(()=>{$.success("排序保存成功"),c(!1),P()}).finally(()=>{c(!1)})},S=Ye({data:T||[],columns:Gx(P),state:{sorting:x,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:p,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:o,onColumnVisibilityChange:r,onColumnSizingChange:F,onPaginationChange:d,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Cx,{refetch:P,children:e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:S,toolbar:O=>e.jsx(Bx,{table:O,refetch:P,saveOrder:N,isSortMode:i,groups:w||[]}),draggable:i,onDragStart:I,onDragEnd:O=>O.currentTarget.classList.remove("opacity-50"),onDragOver:O=>{O.preventDefault(),O.currentTarget.classList.add("bg-muted")},onDragLeave:O=>O.currentTarget.classList.remove("bg-muted"),onDrop:y,showPagination:!i})})})}function Yx(){const{t:s}=V("server");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Wx,{})})]})]})}const Jx=Object.freeze(Object.defineProperty({__proto__:null,default:Yx},Symbol.toStringTag,{value:"Module"}));function Qx({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(an,{refetch:n}),e.jsx(D,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:_("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}const Xx=s=>{const{t:n}=V("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Ma,{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(z,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Rl,{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(z,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(an,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(rt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(hs,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{_t.drop({id:t.original.id}).then(({data:r})=>{r&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 Zx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,o]=m.useState([]),[l,d]=m.useState([]),{data:x,refetch:u,isLoading:i}=re({queryKey:["serverGroupList"],queryFn:async()=>{const{data:p}=await _t.getList();return p}}),c=Ye({data:x||[],columns:Xx(u),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:c,toolbar:p=>e.jsx(Qx,{table:p,refetch:u}),isLoading:i})}function eh(){const{t:s}=V("group");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Zx,{})})]})]})}const sh=Object.freeze(Object.defineProperty({__proto__:null,default:eh},Symbol.toStringTag,{value:"Module"})),th=s=>h.object({remarks:h.string().min(1,s("form.validation.remarks")),match:h.array(h.string()),action:h.enum(["block","dns"]),action_value:h.string().optional()});function wi({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="create"}){const{t:a}=V("route"),o=Ce({resolver:Te(th(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1);return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(qe,{})]}),e.jsxs(De,{...o,children:[e.jsx(j,{control:o.control,name:"remarks",render:({field:x})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:a("form.remarksPlaceholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(j,{control:o.control,name:"match",render:({field:x})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(Es,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:Array.isArray(x.value)?x.value.join(` -`):"",onChange:u=>{const i=u.target.value.split(` -`);x.onChange(i)}})})}),e.jsx(R,{})]})}),e.jsx(j,{control:o.control,name:"action",render:({field:x})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"block",children:a("actions.block")}),e.jsx(q,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(R,{})]})}),o.watch("action")==="dns"&&e.jsx(j,{control:o.control,name:"action_value",render:({field:x})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:a("form.dnsPlaceholder"),...x})})})]})}),e.jsxs(Oe,{children:[e.jsx(st,{asChild:!0,children:e.jsx(L,{variant:"outline",children:a("form.cancel")})}),e.jsx(L,{type:"submit",onClick:()=>{const x=o.getValues(),u={...x,match:Array.isArray(x.match)?x.match.filter(i=>i.trim()!==""):[]};Ba.save(u).then(({data:i})=>{i&&(d(!1),s&&s(),$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),o.reset())})},children:a("form.submit")})]})]})]})]})}function ah({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(wi,{refetch:n}),e.jsx(D,{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(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}function nh({columns:s,data:n,refetch:t}){const[r,a]=m.useState({}),[o,l]=m.useState({}),[d,x]=m.useState([]),[u,i]=m.useState([]),c=Ye({data:n,columns:s,state:{sorting:u,columnVisibility:o,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:i,onColumnFiltersChange:x,onColumnVisibilityChange:l,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:c,toolbar:p=>e.jsx(ah,{table:p,refetch:t})})}const rh=s=>{const{t:n}=V("route"),t={block:{icon:bd,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:yd,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(z,{column:r,title:n("columns.id")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:r.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:r})=>e.jsx(z,{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(z,{column:r,title:n("columns.action_value.title")}),cell:({row:r})=>{const a=r.original.action,o=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"&&o?n("columns.action_value.dns",{value:o}):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(z,{column:r,title:n("columns.action")}),cell:({row:r})=>{const a=r.getValue("action"),o=t[a]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(U,{variant:t[a]?.variant||"default",className:_("flex items-center gap-1.5 px-3 py-1 capitalize",t[a]?.className),children:[o&&e.jsx(o,{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(wi,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(rt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(hs,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ba.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 lh(){const{t:s}=V("route"),[n,t]=m.useState([]);function r(){Ba.getList().then(({data:a})=>{t(a)})}return m.useEffect(()=>{r()},[]),e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(nh,{data:n,columns:rh(r),refetch:r})})]})]})}const ih=Object.freeze(Object.defineProperty({__proto__:null,default:lh},Symbol.toStringTag,{value:"Module"})),Ci=m.createContext(void 0);function oh({children:s,refreshData:n}){const[t,r]=m.useState(!1),[a,o]=m.useState(null);return e.jsx(Ci.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:o,refreshData:n},children:s})}function Wn(){const s=m.useContext(Ci);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function ch({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=Wn(),{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(L,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("div",{children:a("plan.add")})]}),e.jsx(D,{placeholder:a("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:o=>s.getColumn("name")?.setFilterValue(o.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(L,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const Sr={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"}},dh=s=>{const{t:n}=V("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ua,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.show")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{_s.update({id:t.original.id,show:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.sell")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{_s.update({id:t.original.id,sell:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{_s.update({id:t.original.id,renew:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("plan.columns.stats")}),cell:({row:t})=>{const r=t.getValue("users_count")||0,a=t.original.active_users_count||0,o=r>0?Math.round(a/r*100):0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-slate-50 px-2 py-1 hover:bg-slate-100 transition-colors cursor-help",children:[e.jsx(Ta,{className:"h-3.5 w-3.5 text-slate-500"}),e.jsx("span",{className:"text-sm font-medium text-slate-700",children:r})]})}),e.jsx(ce,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"总用户数"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"所有使用该套餐的用户(包括已过期)"})]})})]})}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-green-50 px-2 py-1 hover:bg-green-100 transition-colors cursor-help",children:[e.jsx(_d,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:a})]})}),e.jsx(ce,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"有效期内用户"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"当前仍在有效期内的活跃用户"}),r>0&&e.jsxs("p",{className:"text-xs font-medium text-green-600",children:["活跃率:",o,"%"]})]})})]})})]})},enableSorting:!0,size:120},{accessorKey:"group",header:({column:t})=>e.jsx(z,{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(U,{variant:"secondary",className:_("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(z,{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 r?e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:a.map(({period:o,key:l,unit:d})=>r[l]!=null&&e.jsxs(U,{variant:"secondary",className:_("px-2 py-0.5 font-medium transition-colors text-nowrap",Sr[l].color,Sr[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[o," ¥",r[l],d]},l))}):e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"outline",className:"px-2 py-0.5 text-xs text-muted-foreground border-dashed",children:n("plan.columns.price_period.no_price")})})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=Wn();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(rt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(hs,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{_s.drop({id:t.original.id}).then(({data:o})=>{o&&($.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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")})]})})]})}}]},mh=h.object({id:h.number().nullable(),group_id:h.union([h.number(),h.string()]).nullable().optional(),name:h.string().min(1).max(250),tags:h.array(h.string()).nullable().optional(),content:h.string().nullable().optional(),transfer_enable:h.union([h.number().min(0),h.string().min(1)]),prices:h.object({monthly:h.union([h.number(),h.string()]).nullable().optional(),quarterly:h.union([h.number(),h.string()]).nullable().optional(),half_yearly:h.union([h.number(),h.string()]).nullable().optional(),yearly:h.union([h.number(),h.string()]).nullable().optional(),two_yearly:h.union([h.number(),h.string()]).nullable().optional(),three_yearly:h.union([h.number(),h.string()]).nullable().optional(),onetime:h.union([h.number(),h.string()]).nullable().optional(),reset_traffic:h.union([h.number(),h.string()]).nullable().optional()}).default({}),speed_limit:h.union([h.number(),h.string()]).nullable().optional(),capacity_limit:h.union([h.number(),h.string()]).nullable().optional(),device_limit:h.union([h.number(),h.string()]).nullable().optional(),force_update:h.boolean().optional(),reset_traffic_method:h.number().nullable(),users_count:h.number().optional(),active_users_count:h.number().optional()}),Yn=m.forwardRef(({className:s,...n},t)=>e.jsx(El,{ref:t,className:_("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(Nd,{className:_("flex items-center justify-center text-current"),children:e.jsx(bt,{className:"h-4 w-4"})})}));Yn.displayName=El.displayName;const va={id:null,group_id:null,name:"",tags:[],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},ba={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}},uh=[{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 xh(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=Wn(),[o,l]=m.useState(!1),{t:d}=V("subscribe"),x=Ce({resolver:Te(mh),defaultValues:{...va,...t||{}},mode:"onChange"});m.useEffect(()=>{t?x.reset({...va,...t}):x.reset(va)},[t,x]);const u=new On({html:!0}),[i,c]=m.useState();async function p(){_t.getList().then(({data:w})=>{c(w)})}m.useEffect(()=>{s&&p()},[s]);const F=async w=>{l(!0),_s.save(w).then(({data:I})=>{I&&($.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),P(),a())}).finally(()=>{l(!1)})},T=w=>{const I=Object.values(w).map(y=>y?.message).filter(Boolean);$.error(I.join(` -`)||d("plan.form.submit.error.validation","表单校验失败"))},C=w=>{if(isNaN(w))return;const I=Object.entries(ba).reduce((y,[N,S])=>{const O=w*S.months*S.discount;return{...y,[N]:O.toFixed(2)}},{});x.setValue("prices",I,{shouldDirty:!0})},P=()=>{n(!1),r(null),x.reset(va)};return e.jsx(de,{open:s,onOpenChange:P,children:e.jsxs(oe,{children:[e.jsxs(he,{children:[e.jsx(me,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(qe,{})]}),e.jsx(De,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(F,T),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"name",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:d("plan.form.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:d("plan.form.name.placeholder"),...w})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"tags",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:d("plan.form.tags.label","标签")}),e.jsx(b,{children:e.jsx(tn,{value:w.value||[],onChange:w.onChange,placeholder:d("plan.form.tags.placeholder","输入标签后按回车确认"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"group_id",render:({field:w})=>e.jsxs(f,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(an,{dialogTrigger:e.jsx(L,{variant:"link",children:d("plan.form.group.add")}),refetch:p})]}),e.jsxs(X,{value:w.value?.toString()??"",onValueChange:I=>w.onChange(I?Number(I):null),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(Q,{children:i?.map(I=>e.jsx(q,{value:I.id.toString(),children:I.name},I.id))})]}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"transfer_enable",render:({field:w})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...w})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.transfer.unit")})]}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"speed_limit",render:({field:w})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.speed.unit")})]}),e.jsx(R,{})]})}),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(D,{type:"number",step:"0.01",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:w=>{const I=parseFloat(w.target.value);C(I)}})]}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const w=Object.keys(ba).reduce((I,y)=>({...I,[y]:""}),{});x.setValue("prices",w,{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(ba).filter(([w])=>!["onetime","reset_traffic"].includes(w)).map(([w,I])=>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(j,{control:x.control,name:`prices.${w}`,render:({field:y})=>e.jsxs(f,{children:[e.jsxs(v,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${w}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",I.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:I.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,step:"0.01",...y,value:y.value??"",onChange:N=>y.onChange(N.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},w))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(ba).filter(([w])=>["onetime","reset_traffic"].includes(w)).map(([w,I])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(j,{control:x.control,name:`prices.${w}`,render:({field:y})=>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(v,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${w}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(w==="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(b,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,step:"0.01",...y,value:y.value??"",className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},w))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(j,{control:x.control,name:"device_limit",render:({field:w})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.device.unit")})]}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"capacity_limit",render:({field:w})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...w,value:w.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:d("plan.form.capacity.unit")})]}),e.jsx(R,{})]})})]}),e.jsx(j,{control:x.control,name:"reset_traffic_method",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:d("plan.form.reset_method.label")}),e.jsxs(X,{value:w.value?.toString()??"null",onValueChange:I=>w.onChange(I=="null"?null:Number(I)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(Q,{children:uh.map(I=>e.jsx(q,{value:I.value?.toString()??"null",children:d(`plan.form.reset_method.options.${I.label}`)},I.value))})]}),e.jsx(A,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"content",render:({field:w})=>{const[I,y]=m.useState(!1);return e.jsxs(f,{className:"space-y-2",children:[e.jsxs(v,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d("plan.form.content.label"),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",type:"button",onClick:()=>y(!I),children:I?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(I?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",type:"button",onClick:()=>{w.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 ${I?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(b,{children:e.jsx(zn,{style:{height:"400px"},value:w.value||"",renderHTML:N=>u.render(N),onChange:({text:N})=>w.onChange(N),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"})})}),I&&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:u.render(w.value||"")}})})]})]}),e.jsx(A,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(R,{})]})}})]}),e.jsx(Oe,{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(j,{control:x.control,name:"force_update",render:({field:w})=>e.jsxs(f,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(b,{children:e.jsx(Yn,{checked:w.value,onCheckedChange:w.onChange})}),e.jsx("div",{className:"",children:e.jsx(v,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:P,children:d("plan.form.submit.cancel")}),e.jsx(L,{type:"submit",disabled:o,children:d(o?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})})]})})}function hh(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,o]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState(!1),[i,c]=m.useState({pageSize:20,pageIndex:0}),[p,F]=m.useState([]),{refetch:T}=re({queryKey:["planList"],queryFn:async()=>{const{data:y}=await _s.getList();return F(y),y}});m.useEffect(()=>{r({"drag-handle":x}),c({pageSize:x?99999:10,pageIndex:0})},[x]);const C=(y,N)=>{x&&(y.dataTransfer.setData("text/plain",N.toString()),y.currentTarget.classList.add("opacity-50"))},P=(y,N)=>{if(!x)return;y.preventDefault(),y.currentTarget.classList.remove("bg-muted");const S=parseInt(y.dataTransfer.getData("text/plain"));if(S===N)return;const O=[...p],[E]=O.splice(S,1);O.splice(N,0,E),F(O)},w=async()=>{if(!x){u(!0);return}const y=p?.map(N=>N.id);_s.sort(y).then(()=>{$.success("排序保存成功"),u(!1),T()}).finally(()=>{u(!1)})},I=Ye({data:p||[],columns:dh(T),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:i},enableRowSelection:!0,onPaginationChange:c,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}},pageCount:x?1:void 0});return e.jsx(oh,{refreshData:T,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(rs,{table:I,toolbar:y=>e.jsx(ch,{table:y,refetch:T,saveOrder:w,isSortMode:x}),draggable:x,onDragStart:C,onDragEnd:y=>y.currentTarget.classList.remove("opacity-50"),onDragOver:y=>{y.preventDefault(),y.currentTarget.classList.add("bg-muted")},onDragLeave:y=>y.currentTarget.classList.remove("bg-muted"),onDrop:P,showPagination:!x}),e.jsx(xh,{})]})})}function gh(){const{t:s}=V("subscribe");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(hh,{})})]})]})}const ph=Object.freeze(Object.defineProperty({__proto__:null,default:gh},Symbol.toStringTag,{value:"Module"})),Dt=[{value:ie.PENDING,label:qt[ie.PENDING],icon:wd,color:Ut[ie.PENDING]},{value:ie.PROCESSING,label:qt[ie.PROCESSING],icon:Il,color:Ut[ie.PROCESSING]},{value:ie.COMPLETED,label:qt[ie.COMPLETED],icon:kn,color:Ut[ie.COMPLETED]},{value:ie.CANCELLED,label:qt[ie.CANCELLED],icon:Vl,color:Ut[ie.CANCELLED]},{value:ie.DISCOUNTED,label:qt[ie.DISCOUNTED],icon:kn,color:Ut[ie.DISCOUNTED]}],Gt=[{value:fe.PENDING,label:ga[fe.PENDING],icon:Cd,color:pa[fe.PENDING]},{value:fe.PROCESSING,label:ga[fe.PROCESSING],icon:Il,color:pa[fe.PROCESSING]},{value:fe.VALID,label:ga[fe.VALID],icon:kn,color:pa[fe.VALID]},{value:fe.INVALID,label:ga[fe.INVALID],icon:Vl,color:pa[fe.INVALID]}];function ya({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=s?.getFilterValue(),o=Array.isArray(a)?new Set(a):a!==void 0?new Set([a]):new Set;return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ha,{className:"mr-2 h-4 w-4"}),n,o?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:o.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:o.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[o.size," selected"]}):t.filter(l=>o.has(l.value)).map(l=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:l.label},l.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(it,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ot,{children:"No results found."}),e.jsx(gs,{children:t.map(l=>{const d=o.has(l.value);return e.jsxs(Ae,{onSelect:()=>{const x=new Set(o);d?x.delete(l.value):x.add(l.value);const u=Array.from(x);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:_("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(bt,{className:_("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)})}),o.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ot,{}),e.jsx(gs,{children:e.jsx(Ae,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const fh=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),jh={email:"",plan_id:0,total_amount:0,period:""};function Si({refetch:s,trigger:n,defaultValues:t}){const{t:r}=V("order"),[a,o]=m.useState(!1),l=Ce({resolver:Te(fh),defaultValues:{...jh,...t},mode:"onChange"}),[d,x]=m.useState([]);return m.useEffect(()=>{a&&_s.getList().then(({data:u})=>{x(u)})},[a]),e.jsxs(de,{open:a,onOpenChange:o,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("div",{children:r("dialog.addOrder")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("dialog.assignOrder")}),e.jsx(qe,{})]}),e.jsxs(De,{...l,children:[e.jsx(j,{control:l.control,name:"email",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.userEmail")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dialog.placeholders.email"),...u})})]})}),e.jsx(j,{control:l.control,name:"plan_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(b,{children:e.jsxs(X,{value:u.value?u.value?.toString():void 0,onValueChange:i=>u.onChange(parseInt(i)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(Q,{children:d.map(i=>e.jsx(q,{value:i.id.toString(),children:i.name},i.id))})]})})]})}),e.jsx(j,{control:l.control,name:"period",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.orderPeriod")}),e.jsx(b,{children:e.jsxs(X,{value:u.value,onValueChange:u.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dialog.placeholders.period")})}),e.jsx(Q,{children:Object.keys(qm).map(i=>e.jsx(q,{value:i,children:r(`period.${i}`)},i))})]})})]})}),e.jsx(j,{control:l.control,name:"total_amount",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.paymentAmount")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dialog.placeholders.amount"),value:u.value/100,onChange:i=>u.onChange(parseFloat(i.currentTarget.value)*100)})}),e.jsx(R,{})]})}),e.jsxs(Oe,{children:[e.jsx(L,{variant:"outline",onClick:()=>o(!1),children:r("dialog.actions.cancel")}),e.jsx(L,{type:"submit",onClick:()=>{l.handleSubmit(u=>{gt.assign(u).then(({data:i})=>{i&&(s&&s(),l.reset(),o(!1),$.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function vh({table:s,refetch:n}){const{t}=V("order"),r=s.getState().columnFilters.length>0,a=Object.values($s).filter(x=>typeof x=="number").map(x=>({label:t(`type.${$s[x]}`),value:x,color:x===$s.NEW?"green-500":x===$s.RENEWAL?"blue-500":x===$s.UPGRADE?"purple-500":"orange-500"})),o=Object.values(Ze).map(x=>({label:t(`period.${x}`),value:x,color:x===Ze.MONTH_PRICE?"slate-500":x===Ze.QUARTER_PRICE?"cyan-500":x===Ze.HALF_YEAR_PRICE?"indigo-500":x===Ze.YEAR_PRICE?"violet-500":x===Ze.TWO_YEAR_PRICE?"fuchsia-500":x===Ze.THREE_YEAR_PRICE?"pink-500":x===Ze.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(ie).filter(x=>typeof x=="number").map(x=>({label:t(`status.${ie[x]}`),value:x,icon:x===ie.PENDING?Dt[0].icon:x===ie.PROCESSING?Dt[1].icon:x===ie.COMPLETED?Dt[2].icon:x===ie.CANCELLED?Dt[3].icon:Dt[4].icon,color:x===ie.PENDING?"yellow-500":x===ie.PROCESSING?"blue-500":x===ie.COMPLETED?"green-500":x===ie.CANCELLED?"red-500":"green-500"})),d=Object.values(fe).filter(x=>typeof x=="number").map(x=>({label:t(`commission.${fe[x]}`),value:x,icon:x===fe.PENDING?Gt[0].icon:x===fe.PROCESSING?Gt[1].icon:x===fe.VALID?Gt[2].icon:Gt[3].icon,color:x===fe.PENDING?"yellow-500":x===fe.PROCESSING?"blue-500":x===fe.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Si,{refetch:n}),e.jsx(D,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:x=>s.getColumn("trade_no")?.setFilterValue(x.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(ya,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(ya,{column:s.getColumn("period"),title:t("table.columns.period"),options:o}),s.getColumn("status")&&e.jsx(ya,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(ya,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}function is({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:_("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:_("text-sm",r),children:n||"-"})]})}function bh({status:s}){const{t:n}=V("order"),t={[ie.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[ie.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[ie.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[ie.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[ie.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(U,{variant:"secondary",className:_("font-medium",t[s]),children:n(`status.${ie[s]}`)})}function yh({id:s,trigger:n}){const[t,r]=m.useState(!1),[a,o]=m.useState(),{t:l}=V("order");return m.useEffect(()=>{(async()=>{if(t){const{data:x}=await gt.getInfo({id:s});o(x)}})()},[t,s]),e.jsxs(de,{onOpenChange:r,open:t,children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"max-w-xl",children:[e.jsxs(he,{className:"space-y-2",children:[e.jsx(me,{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(bh,{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(is,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Bs,{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(aa,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(is,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(is,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(is,{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(is,{label:l("dialog.fields.paymentAmount"),value:Ks(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Re,{className:"my-2"}),e.jsx(is,{label:l("dialog.fields.balancePayment"),value:Ks(a?.balance_amount||0)}),e.jsx(is,{label:l("dialog.fields.discountAmount"),value:Ks(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(is,{label:l("dialog.fields.refundAmount"),value:Ks(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(is,{label:l("dialog.fields.deductionAmount"),value:Ks(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(is,{label:l("dialog.fields.createdAt"),value:ne(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(is,{label:l("dialog.fields.updatedAt"),value:ne(a?.updated_at),valueClassName:"font-mono text-xs"})]})]}),a?.commission_status!==void 0&&a?.commission_balance&&e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.commissionInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(is,{label:l("dialog.fields.commissionStatus"),value:e.jsx(U,{variant:"secondary",className:_("font-medium",a?.commission_status===fe.PENDING?"bg-yellow-100 text-yellow-800 hover:bg-yellow-100":a?.commission_status===fe.PROCESSING?"bg-blue-100 text-blue-800 hover:bg-blue-100":a?.commission_status===fe.VALID?"bg-green-100 text-green-800 hover:bg-green-100":a?.commission_status===fe.INVALID?"bg-red-100 text-red-800 hover:bg-red-100":"bg-orange-100 text-orange-800 hover:bg-orange-100"),children:a?.commission_status!==void 0?l(`commission.${fe[a.commission_status]}`):l("dialog.commissionStatusActive")})}),e.jsx(is,{label:l("dialog.fields.commissionAmount"),value:Ks(a?.commission_balance||0),valueClassName:"font-medium text-orange-600"}),a?.actual_commission_balance&&e.jsx(is,{label:l("dialog.fields.actualCommissionAmount"),value:Ks(a?.actual_commission_balance||0),valueClassName:"font-medium text-orange-700"}),a?.invite_user&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"my-2"}),e.jsx(is,{label:l("dialog.fields.inviteUser"),value:e.jsxs(Bs,{to:`/user/manage?email=${a.invite_user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.invite_user.email,e.jsx(aa,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})}),e.jsx(is,{label:l("dialog.fields.inviteUserId"),value:a?.invite_user?.id,valueClassName:"font-mono text-xs"})]})]})]})]})]})]})}const _h={[$s.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[$s.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[$s.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[$s.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Nh={[Ze.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},wh=s=>ie[s],Ch=s=>fe[s],Sh=s=>$s[s],kh=s=>{const{t:n}=V("order");return[{accessorKey:"trade_no",header:({column:t})=>e.jsx(z,{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(yh,{trigger:e.jsxs(G,{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(aa,{className:"h-3.5 w-3.5 opacity-70"})]}),id:t.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.type")}),cell:({row:t})=>{const r=t.getValue("type"),a=_h[r];return e.jsx(U,{variant:"secondary",className:_("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(z,{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(z,{column:t,title:n("table.columns.period")}),cell:({row:t})=>{const r=t.getValue("period"),a=Nh[r];return e.jsx(U,{variant:"secondary",className:_("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(z,{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(z,{column:t,title:n("table.columns.status")}),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(ji,{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=Dt.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.${wh(r.value)}`)})]}),r.value===ie.PENDING&&e.jsxs(Hs,{modal:!0,children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(qs,{align:"end",className:"w-[140px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await gt.markPaid({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await gt.makeCancel({trade_no:t.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("table.columns.commissionStatus")}),cell:({row:t})=>{const r=t.original.status,a=t.original.commission_balance,o=Gt.find(l=>l.value===t.getValue("commission_status"));return a==0||!o?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:[o.icon&&e.jsx(o.icon,{className:`h-4 w-4 text-${o.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${Ch(o.value)}`)})]}),o.value===fe.PENDING&&r===ie.COMPLETED&&e.jsxs(Hs,{modal:!0,children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(qs,{align:"end",className:"w-[120px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await gt.update({trade_no:t.original.trade_no,commission_status:fe.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await gt.update({trade_no:t.original.trade_no,commission_status:fe.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.createdAt")}),cell:({row:t})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:ne(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function Th(){const[s]=Ml(),[n,t]=m.useState({}),[r,a]=m.useState({}),[o,l]=m.useState([]),[d,x]=m.useState([]),[u,i]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const P=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([w,I])=>{const y=s.get(w);return y?{id:w,value:I==="number"?parseInt(y):y}:null}).filter(Boolean);P.length>0&&l(P)},[s]);const{refetch:c,data:p,isLoading:F}=re({queryKey:["orderList",u,o,d],queryFn:()=>gt.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:o,sort:d})}),T=Ye({data:p?.data??[],columns:kh(c),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:o,pagination:u},rowCount:p?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:x,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:i,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:T,toolbar:e.jsx(vh,{table:T,refetch:c}),showPagination:!0})}function Dh(){const{t:s}=V("order");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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 Fh=Object.freeze(Object.defineProperty({__proto__:null,default:Dh},Symbol.toStringTag,{value:"Module"}));function Ph({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ha,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(o=>a.has(o.value)).map(o=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(it,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ot,{children:"No results found."}),e.jsx(gs,{children:t.map(o=>{const l=a.has(o.value);return e.jsxs(Ae,{onSelect:()=>{l?a.delete(o.value):a.add(o.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:_("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(bt,{className:_("h-4 w-4")})}),o.icon&&e.jsx(o.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${o.color}`}),e.jsx("span",{children:o.label}),r?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(o.value)})]},o.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ot,{}),e.jsx(gs,{children:e.jsx(Ae,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Lh=s=>h.object({id:h.coerce.number().nullable().optional(),name:h.string().min(1,s("form.name.required")),code:h.string().nullable(),type:h.coerce.number(),value:h.coerce.number(),started_at:h.coerce.number(),ended_at:h.coerce.number(),limit_use:h.union([h.string(),h.number()]).nullable(),limit_use_with_user:h.union([h.string(),h.number()]).nullable(),generate_count:h.coerce.number().nullable().optional(),limit_plan_ids:h.array(h.coerce.number()).default([]).nullable(),limit_period:h.array(h.nativeEnum(Zt)).default([]).nullable()}).refine(n=>n.ended_at>n.started_at,{message:s("form.validity.endTimeError"),path:["ended_at"]}),kr={name:"",code:null,type:Cs.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},Rh=s=>[{label:s("form.timeRange.presets.1week"),days:7},{label:s("form.timeRange.presets.2weeks"),days:14},{label:s("form.timeRange.presets.1month"),days:30},{label:s("form.timeRange.presets.3months"),days:90},{label:s("form.timeRange.presets.6months"),days:180},{label:s("form.timeRange.presets.1year"),days:365}];function ki({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:o}){const{t:l}=V("coupon"),[d,x]=m.useState(!1),u=a??d,i=o??x,[c,p]=m.useState([]),F=Lh(l),T=Rh(l),C=Ce({resolver:Te(F),defaultValues:s||kr});m.useEffect(()=>{s&&C.reset(s)},[s,C]),m.useEffect(()=>{_s.getList().then(({data:N})=>p(N))},[]);const P=N=>{if(!N)return;const S=(O,E)=>{const g=new Date(E*1e3);return O.setHours(g.getHours(),g.getMinutes(),g.getSeconds()),Math.floor(O.getTime()/1e3)};N.from&&C.setValue("started_at",S(N.from,C.watch("started_at"))),N.to&&C.setValue("ended_at",S(N.to,C.watch("ended_at")))},w=N=>{const S=new Date,O=Math.floor(S.getTime()/1e3),E=Math.floor((S.getTime()+N*24*60*60*1e3)/1e3);C.setValue("started_at",O),C.setValue("ended_at",E)},I=async N=>{const S=await Ia.save(N);if(N.generate_count&&typeof S=="string"){const O=new Blob([S],{type:"text/csv;charset=utf-8;"}),E=document.createElement("a");E.href=window.URL.createObjectURL(O),E.download=`coupons_${new Date().getTime()}.csv`,E.click(),window.URL.revokeObjectURL(E.href)}i(!1),t==="create"&&C.reset(kr),n()},y=(N,S)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:S}),e.jsx(D,{type:"datetime-local",step:"1",value:ne(C.watch(N),"YYYY-MM-DDTHH:mm:ss"),onChange:O=>{const E=new Date(O.target.value);C.setValue(N,Math.floor(E.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(de,{open:u,onOpenChange:i,children:[r&&e.jsx(cs,{asChild:!0,children:r}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(De,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(I),className:"space-y-4",children:[e.jsx(j,{control:C.control,name:"name",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.name.label")}),e.jsx(D,{placeholder:l("form.name.placeholder"),...N}),e.jsx(R,{})]})}),t==="create"&&e.jsx(j,{control:C.control,name:"generate_count",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...N,value:N.value??"",onChange:S=>N.onChange(S.target.value===""?null:parseInt(S.target.value)),className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(R,{})]})}),(!C.watch("generate_count")||C.watch("generate_count")==null)&&e.jsx(j,{control:C.control,name:"code",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.code.label")}),e.jsx(D,{placeholder:l("form.code.placeholder"),...N,value:N.value??"",className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.code.description")}),e.jsx(R,{})]})}),e.jsxs(f,{children:[e.jsx(v,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(j,{control:C.control,name:"type",render:({field:N})=>e.jsxs(X,{value:N.value.toString(),onValueChange:S=>{const O=N.value,E=parseInt(S);N.onChange(E);const g=C.getValues("value");g&&(O===Cs.AMOUNT&&E===Cs.PERCENTAGE?C.setValue("value",g/100):O===Cs.PERCENTAGE&&E===Cs.AMOUNT&&C.setValue("value",g*100))},children:[e.jsx(J,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Z,{placeholder:l("form.type.placeholder")})}),e.jsx(Q,{children:Object.entries(Um).map(([S,O])=>e.jsx(q,{value:S,children:l(`table.toolbar.types.${S}`)},S))})]})}),e.jsx(j,{control:C.control,name:"value",render:({field:N})=>{const S=N.value==null?"":C.watch("type")===Cs.AMOUNT&&typeof N.value=="number"?(N.value/100).toString():N.value.toString();return e.jsx(D,{type:"number",placeholder:l("form.value.placeholder"),...N,value:S,onChange:O=>{const E=O.target.value;if(E===""){N.onChange("");return}const g=parseFloat(E);isNaN(g)||N.onChange(C.watch("type")===Cs.AMOUNT?Math.round(g*100):g)},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:C.watch("type")==Cs.AMOUNT?"¥":"%"})})]})]}),e.jsxs(f,{children:[e.jsx(v,{children:l("form.validity.label")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:_("w-full justify-start text-left font-normal",!C.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"truncate",children:[ne(C.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",ne(C.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})]})}),e.jsxs(We,{className:"w-auto p-0",align:"start",children:[e.jsxs("div",{className:"border-b border-border p-3",children:[e.jsx("div",{className:"mb-2 text-sm font-medium text-muted-foreground",children:l("form.timeRange.quickSet")}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-6",children:T.map(N=>e.jsx(L,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>w(N.days),type:"button",children:N.label},N.days))})]}),e.jsx("div",{className:"hidden border-b border-border sm:block",children:e.jsx(ks,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:P,numberOfMonths:2})}),e.jsx("div",{className:"border-b border-border sm:hidden",children:e.jsx(ks,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:P,numberOfMonths:1})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center",children:[y("started_at",l("table.validity.startTime")),e.jsx("div",{className:"text-center text-sm text-muted-foreground sm:mt-6",children:l("form.validity.to")}),y("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(R,{})]}),e.jsx(j,{control:C.control,name:"limit_use",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...N,value:N.value??"",onChange:S=>N.onChange(S.target.value===""?null:parseInt(S.target.value)),className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:C.control,name:"limit_use_with_user",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...N,value:N.value??"",onChange:S=>N.onChange(S.target.value===""?null:parseInt(S.target.value)),className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:C.control,name:"limit_period",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitPeriod.label")}),e.jsx(nt,{options:Object.entries(Zt).filter(([S])=>isNaN(Number(S))).map(([S,O])=>({label:l(`coupon:period.${O}`),value:S})),onChange:S=>{if(S.length===0){N.onChange([]);return}const O=S.map(E=>Zt[E.value]);N.onChange(O)},value:(N.value||[]).map(S=>({label:l(`coupon:period.${S}`),value:Object.entries(Zt).find(([O,E])=>E===S)?.[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(A,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:C.control,name:"limit_plan_ids",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitPlan.label")}),e.jsx(nt,{options:c?.map(S=>({label:S.name,value:S.id.toString()}))||[],onChange:S=>N.onChange(S.map(O=>Number(O.value))),value:(c||[]).filter(S=>(N.value||[]).includes(S.id)).map(S=>({label:S.name,value:S.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(R,{})]})}),e.jsx(Oe,{children:e.jsx(L,{type:"submit",disabled:C.formState.isSubmitting,children:C.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function Eh({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(ki,{refetch:n,dialogTrigger:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("div",{children:r("form.add")})]})}),e.jsx(D,{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(Ph,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:Cs.AMOUNT,label:r(`table.toolbar.types.${Cs.AMOUNT}`)},{value:Cs.PERCENTAGE,label:r(`table.toolbar.types.${Cs.PERCENTAGE}`)}]}),t&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}const Ti=m.createContext(void 0);function Ih({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,o]=m.useState(null),l=x=>{o(x),r(!0)},d=()=>{r(!1),o(null)};return e.jsxs(Ti.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(ki,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function Vh(){const s=m.useContext(Ti);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Mh=s=>{const{t:n}=V("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.original.show,onCheckedChange:r=>{Ia.update({id:t.original.id,show:r}).then(({data:a})=>!a&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`table.toolbar.types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.code")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.limitUse")}),cell:({row:t})=>e.jsx(U,{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(z,{column:t,title:n("table.columns.limitUseWithUser")}),cell:({row:t})=>e.jsx(U,{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(z,{column:t,title:n("table.columns.validity")}),cell:({row:t})=>{const[r,a]=m.useState(!1),o=Date.now(),l=t.original.started_at*1e3,d=t.original.ended_at*1e3,x=o>d,u=oe.jsx(z,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=Vh();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(rt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(hs,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{Ia.drop({id:t.original.id}).then(({data:a})=>{a&&($.success("删除成功"),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 Oh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,o]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:i,data:c}=re({queryKey:["couponList",x,a,l],queryFn:()=>Ia.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:a,sort:l})}),p=Ye({data:c?.data??[],columns:Mh(i),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},pageCount:Math.ceil((c?.total??0)/x.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,onPaginationChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ih,{refetch:i,children:e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:p,toolbar:e.jsx(Eh,{table:p,refetch:i})})})})}function zh(){const{t:s}=V("coupon");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Oh,{})})]})]})}const $h=Object.freeze(Object.defineProperty({__proto__:null,default:zh},Symbol.toStringTag,{value:"Module"})),Ah=h.object({name:h.string().min(1,"请输入模板名称"),description:h.string().optional(),type:h.number().min(1).max(4),status:h.boolean(),sort:h.number().min(0),icon:h.string().optional(),background_image:h.string().optional(),conditions:h.object({allowed_plans:h.array(h.number()).optional(),disallowed_plans:h.array(h.number()).optional(),new_user_only:h.boolean().optional(),new_user_max_days:h.number().optional(),paid_user_only:h.boolean().optional(),require_invite:h.boolean().optional()}).optional(),limits:h.object({max_use_per_user:h.number().optional(),cooldown_hours:h.number().optional(),invite_reward_rate:h.number().optional()}).optional(),rewards:h.object({balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional(),reset_package:h.boolean().optional(),plan_id:h.number().optional(),plan_validity_days:h.number().optional(),random_rewards:h.array(h.object({weight:h.number(),balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional()})).optional()}),special_config:h.object({start_time:h.number().optional(),end_time:h.number().optional(),festival_bonus:h.number().optional()}).optional()});function Di({template:s,refetch:n,open:t,onOpenChange:r}){const{t:a}=V("giftCard"),[o,l]=m.useState(!1),[d,x]=m.useState([]),[u,i]=m.useState([]),c=Ce({resolver:Te(Ah),defaultValues:{name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{},special_config:{}}}),{fields:p,append:F,remove:T}=Sd({control:c.control,name:"rewards.random_rewards"});m.useEffect(()=>{t&&(async()=>{try{const S=(await _s.getList()).data||[];x(S),i(S.map(O=>({label:O.name,value:O.id.toString()})))}catch(N){console.error("Failed to fetch plans:",N),$.error("Failed to load plan list")}})()},[t]),m.useEffect(()=>{if(s){const y=s.rewards||{};c.reset({name:s.name,description:s.description||"",type:s.type,status:s.status,sort:s.sort,icon:s.icon||"",background_image:s.background_image||"",conditions:s.conditions&&!Array.isArray(s.conditions)?s.conditions:{},limits:s.limits&&!Array.isArray(s.limits)?{...s.limits,invite_reward_rate:s.limits.invite_reward_rate||void 0}:{},rewards:{balance:y.balance?y.balance/100:void 0,transfer_enable:typeof y.transfer_enable=="number"?y.transfer_enable/1024/1024/1024:void 0,expire_days:y.expire_days,device_limit:y.device_limit,reset_package:y.reset_package,plan_id:y.plan_id,plan_validity_days:y.plan_validity_days,random_rewards:y.random_rewards?.map(N=>({weight:N.weight,balance:N.balance?N.balance/100:void 0,transfer_enable:typeof N.transfer_enable=="number"?N.transfer_enable/1024/1024/1024:void 0,expire_days:N.expire_days,device_limit:N.device_limit}))||[]},special_config:s.special_config&&!Array.isArray(s.special_config)?s.special_config:{}})}else c.reset({name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{random_rewards:[]},special_config:{}})},[s,c]);const C=y=>{console.error("Form validation failed:",y),$.error(a("messages.formInvalid"))},P=async y=>{l(!0);const N=JSON.parse(JSON.stringify(y));N.rewards&&(typeof N.rewards.balance=="number"&&(N.rewards.balance=Math.round(N.rewards.balance*100)),typeof N.rewards.transfer_enable=="number"&&(N.rewards.transfer_enable=Math.round(N.rewards.transfer_enable*1024*1024*1024)),N.rewards.random_rewards&&N.rewards.random_rewards.forEach(O=>{typeof O.balance=="number"&&(O.balance=Math.round(O.balance*100)),typeof O.transfer_enable=="number"&&(O.transfer_enable=Math.round(O.transfer_enable*1024*1024*1024))}));const S={...N,conditions:N.conditions||{},limits:N.limits||{},rewards:N.rewards||{},special_config:N.special_config||{}};try{s?(await Ps.updateTemplate({id:s.id,...S}),$.success(a("messages.templateUpdated"))):(await Ps.createTemplate(S),$.success(a("messages.templateCreated"))),n(),r(!1)}catch(O){const E=O?.response?.data?.errors;E&&Object.keys(E).forEach(g=>{c.setError(g,{type:"manual",message:E[g][0]})}),$.error(a(s?"messages.updateTemplateFailed":"messages.createTemplateFailed"))}finally{l(!1)}},w=c.watch("type"),I=w===1;return e.jsx(de,{open:t,onOpenChange:r,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:a(s?"template.form.edit":"template.form.add")})}),e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(P,C),className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"name",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("template.form.name.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"type",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.type.label")}),e.jsxs(X,{value:y.value.toString(),onValueChange:N=>y.onChange(parseInt(N)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:a("template.form.type.placeholder")})})}),e.jsx(Q,{children:[1,2,3].map(N=>e.jsx(q,{value:N.toString(),children:a(`types.${N}`)},N))})]}),e.jsx(R,{})]})})]}),e.jsx(j,{control:c.control,name:"description",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.description.label")}),e.jsx(b,{children:e.jsx(Es,{placeholder:a("template.form.description.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:e.jsx(j,{control:c.control,name:"status",render:({field:y})=>e.jsxs(f,{className:"col-span-3 flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:a("template.form.status.label")}),e.jsx(A,{children:a("template.form.status.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})})}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.rewards.title")})}),e.jsxs(Pe,{className:"space-y-4",children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"rewards.balance",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.balance.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.balance.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"rewards.transfer_enable",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.transfer_enable.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.placeholder"),value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"rewards.expire_days",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.expire_days.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.expire_days.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"rewards.device_limit",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.device_limit.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.device_limit.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})]}),e.jsx(j,{control:c.control,name:"rewards.reset_package",render:({field:y})=>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(v,{children:a("template.form.rewards.reset_package.label")}),e.jsx(A,{children:a("template.form.rewards.reset_package.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})})]}),w===4&&e.jsx("p",{children:a("template.form.rewards.task_card.description")}),w===2&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"rewards.plan_id",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.plan_id.label")}),e.jsxs(X,{value:y.value?.toString(),onValueChange:N=>y.onChange(parseInt(N,10)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:a("template.form.rewards.plan_id.placeholder")})})}),e.jsx(Q,{children:d.map(N=>e.jsx(q,{value:N.id.toString(),children:N.name},N.id))})]}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"rewards.plan_validity_days",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.plan_validity_days.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.plan_validity_days.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})]}),w===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{children:a("template.form.rewards.random_rewards.label")}),p.map((y,N)=>e.jsxs("div",{className:"flex items-center space-x-2 rounded-md border p-2",children:[e.jsx(j,{control:c.control,name:`rewards.random_rewards.${N}.weight`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.random_rewards.weight"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${N}.balance`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.balance.label"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${N}.transfer_enable`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.label")+" (GB)",value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${N}.expire_days`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.expire_days.label"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${N}.device_limit`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.device_limit.label"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(L,{type:"button",variant:"ghost",size:"icon",onClick:()=>T(N),children:e.jsx(kd,{className:"h-4 w-4"})})]},y.id)),e.jsx(L,{type:"button",variant:"outline",onClick:()=>F({weight:10,balance:void 0,transfer_enable:void 0,expire_days:void 0,device_limit:void 0}),children:a("template.form.rewards.random_rewards.add")})]})]})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.conditions.title")})}),e.jsxs(Pe,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsx(j,{control:c.control,name:"conditions.new_user_max_days",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.conditions.new_user_max_days.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.conditions.new_user_max_days.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(j,{control:c.control,name:"conditions.new_user_only",render:({field:y})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{children:a("template.form.conditions.new_user_only.label")})}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})}),e.jsx(j,{control:c.control,name:"conditions.paid_user_only",render:({field:y})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{children:a("template.form.conditions.paid_user_only.label")})}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})}),e.jsx(j,{control:c.control,name:"conditions.require_invite",render:({field:y})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{children:a("template.form.conditions.require_invite.label")})}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})})]}),e.jsx(j,{control:c.control,name:"conditions.allowed_plans",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.conditions.allowed_plans.label")}),e.jsx(b,{children:e.jsx(nt,{value:y.value?.map(N=>({label:d.find(S=>S.id===N)?.name||`ID: ${N}`,value:N.toString()}))??[],onChange:N=>y.onChange(N.map(S=>parseInt(S.value))),options:u,placeholder:a("template.form.conditions.allowed_plans.placeholder")})})]})}),e.jsx(j,{control:c.control,name:"conditions.disallowed_plans",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.conditions.disallowed_plans.label")}),e.jsx(b,{children:e.jsx(nt,{value:y.value?.map(N=>({label:d.find(S=>S.id===N)?.name||`ID: ${N}`,value:N.toString()}))??[],onChange:N=>y.onChange(N.map(S=>parseInt(S.value))),options:u,placeholder:a("template.form.conditions.disallowed_plans.placeholder")})})]})})]})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.limits.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"limits.max_use_per_user",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.limits.max_use_per_user.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.limits.max_use_per_user.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"limits.cooldown_hours",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.limits.cooldown_hours.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.limits.cooldown_hours.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"limits.invite_reward_rate",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.limits.invite_reward_rate.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",step:"0.01",placeholder:a("template.form.limits.invite_reward_rate.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})}),e.jsx(A,{children:a("template.form.limits.invite_reward_rate.description")})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.special_config.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-3 items-end gap-4",children:[e.jsx(j,{control:c.control,name:"special_config.start_time",render:({field:y})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:a("template.form.special_config.start_time.label")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(L,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!y.value&&"text-muted-foreground"),children:[y.value?Ee(new Date(y.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.start_time.placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:y.value?new Date(y.value*1e3):void 0,onSelect:N=>y.onChange(N?Math.floor(N.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"special_config.end_time",render:({field:y})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:a("template.form.special_config.end_time.label")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(L,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!y.value&&"text-muted-foreground"),children:[y.value?Ee(new Date(y.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.end_time.placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:y.value?new Date(y.value*1e3):void 0,onSelect:N=>y.onChange(N?Math.floor(N.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"special_config.festival_bonus",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.special_config.festival_bonus.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",step:"0.1",placeholder:a("template.form.special_config.festival_bonus.placeholder"),...y,value:y.value??"",onChange:N=>{const S=N.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.display.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"icon",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.icon.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("template.form.icon.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"background_image",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.background_image.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("template.form.background_image.placeholder"),...y})}),e.jsx(R,{})]})})]})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:()=>r(!1),children:a("common:cancel")}),e.jsx(L,{type:"submit",disabled:o,children:a(o?"common:saving":"common:submit")})]})]})})]})})}const Fi=m.createContext(void 0);function qh({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,o]=m.useState(null),l=x=>{o(x),r(!!x)},d=()=>{r(!1),o(null)};return e.jsxs(Fi.Provider,{value:{isOpen:t,editingTemplate:a,setEditingTemplate:l,closeEdit:d},children:[s,e.jsx(Di,{template:a,refetch:n,open:t,onOpenChange:r})]})}function Uh(){const s=m.useContext(Fi);if(s===void 0)throw new Error("useTemplateEdit must be used within a TemplateEditProvider");return s}function Hh({rewards:s,type:n}){const{t}=V(["giftCard","common"]),r=[];return s&&(s.balance&&r.push(`${t("template.form.rewards.balance.short_label")}: ${s.balance/100} ${t("common:currency.yuan","元")}`),s.transfer_enable&&r.push(`${t("template.form.rewards.transfer_enable.short_label")}: ${Le(s.transfer_enable)}`),s.expire_days&&r.push(`${t("template.form.rewards.expire_days.short_label")}: ${s.expire_days}${t("common:time.day","天")}`),s.device_limit&&r.push(`${t("template.form.rewards.device_limit.short_label")}: ${s.device_limit}`),n===2&&s.plan_id&&r.push(`${t("template.form.rewards.plan_id.short_label")}: ${s.plan_id}`),n===2&&s.plan_validity_days&&r.push(`${t("template.form.rewards.plan_validity_days.short_label")}: ${s.plan_validity_days}${t("common:time.day","天")}`),n===3&&s.random_rewards?.length&&r.push(t("types.3"))),r.length===0?e.jsx(U,{variant:"secondary",children:t("template.table.columns.no_rewards")}):e.jsx("div",{className:"flex flex-col space-y-1",children:r.map((a,o)=>e.jsx(U,{variant:"outline",className:"whitespace-nowrap",children:a},o))})}const Kh=s=>{const{t:n}=V("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"status",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.status")}),cell:({row:t})=>{const[r,a]=m.useState(!1);return e.jsx(ee,{checked:t.original.status,disabled:r,onCheckedChange:async o=>{a(!0);try{const{data:l}=await Ps.updateTemplate({id:t.original.id,status:o});l?($.success(n("messages.templateUpdated")),s()):$.error(n("messages.updateTemplateFailed"))}catch{$.error(n("messages.updateTemplateFailed"))}finally{a(!1)}}})},enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:300},{accessorKey:"type",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"rewards",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.rewards")}),cell:({row:t})=>e.jsx(Hh,{rewards:t.original.rewards,type:t.original.type}),enableSorting:!1},{accessorKey:"sort",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.sort")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.sort}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.original.created_at)}),enableSorting:!0},{id:"actions",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.actions")}),cell:({row:t})=>{const{setEditingTemplate:r}=Uh();return e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>r(t.original),children:[e.jsx(rt,{className:"h-4 w-4"}),n("template.actions.edit")]}),e.jsx(hs,{title:n("template.actions.deleteConfirm.title"),description:n("template.actions.deleteConfirm.description"),confirmText:n("template.actions.deleteConfirm.confirmText"),onConfirm:async()=>{try{const{data:a}=await Ps.deleteTemplate({id:t.original.id});a?($.success(n("messages.templateDeleted")),s()):$.error(n("messages.deleteTemplateFailed"))}catch{$.error(n("messages.deleteTemplateFailed"))}},children:e.jsxs(L,{variant:"outline",size:"sm",children:[e.jsx(xs,{className:"h-4 w-4"}),n("template.actions.delete")]})})]})},enableSorting:!1}]};function Pi({table:s}){const{t:n}=V("common");return e.jsxs(Hs,{children:[e.jsx(Td,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(Ol,{className:"mr-2 h-4 w-4"}),n("table.viewOptions.button")]})}),e.jsxs(qs,{align:"end",className:"w-[150px]",children:[e.jsx(Ga,{children:n("table.viewOptions.label")}),e.jsx(at,{}),s.getAllColumns().filter(t=>typeof t.accessorFn<"u"&&t.getCanHide()).map(t=>e.jsx(Zl,{className:"capitalize",checked:t.getIsVisible(),onCheckedChange:r=>t.toggleVisibility(!!r),children:t.id},t.id))]})]})}function Oa({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Dd,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):t.filter(a=>r.has(a.value)).map(a=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:a.label},`selected-${a.value}`))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(it,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ot,{children:"No results found."}),e.jsx(gs,{children:t.map(a=>{const o=r.has(a.value);return e.jsxs(Ae,{onSelect:()=>{o?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:_("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(_a,{className:_("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(Ot,{}),e.jsx(gs,{children:e.jsx(Ae,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function Bh({table:s,refetch:n}){const{t}=V("giftCard"),[r,a]=m.useState(!1),o=s.getState().columnFilters.length>0,l=[{label:t("types.1"),value:"1"},{label:t("types.2"),value:"2"},{label:t("types.3"),value:"3"},{label:t("types.4"),value:"4"},{label:t("types.5"),value:"5"},{label:t("types.6"),value:"6"},{label:t("types.7"),value:"7"},{label:t("types.8"),value:"8"},{label:t("types.9"),value:"9"},{label:t("types.10"),value:"10"}],d=[{label:t("common.enabled"),value:"true"},{label:t("common.disabled"),value:"false"}];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.jsx(D,{placeholder:t("common.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:x=>s.getColumn("name")?.setFilterValue(x.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(Oa,{column:s.getColumn("type"),title:t("template.table.columns.type"),options:l}),s.getColumn("status")&&e.jsx(Oa,{column:s.getColumn("status"),title:t("template.table.columns.status"),options:d}),o&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),t("template.form.add")]}),e.jsx(Pi,{table:s})]}),e.jsx(Di,{template:null,refetch:n,open:r,onOpenChange:a})]})}function Gh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,o]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:i,data:c}=re({queryKey:["giftCardTemplates",x,a,l],queryFn:()=>Ps.getTemplates({per_page:x.pageSize,page:x.pageIndex+1,filter:a,sort:l})});console.log(c);const p=Ye({data:c?.data??[],columns:Kh(i),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},pageCount:Math.ceil((c?.total??0)/x.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,onPaginationChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(qh,{refetch:i,children:e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:p,toolbar:e.jsx(Bh,{table:p,refetch:i})})})})}const Wh=h.object({template_id:h.number().min(1,"请选择一个模板"),count:h.number().min(1,"生成数量必须大于0").max(1e4,"单次最多生成10000个"),prefix:h.string().optional(),expires_hours:h.number().min(1,"有效期必须大于0"),max_usage:h.number().min(1,"最大使用次数必须大于0"),download_csv:h.boolean().optional()});function Yh({refetch:s,open:n,onOpenChange:t}){const{t:r}=V("giftCard"),[a,o]=m.useState(!1),[l,d]=m.useState([]);m.useEffect(()=>{n&&Ps.getTemplates({per_page:1e3,page:1}).then(({data:i})=>{d(i||[])})},[n]);const x=Ce({resolver:Te(Wh),defaultValues:{count:10,prefix:"",expires_hours:24*30,max_usage:1,download_csv:!1}}),u=async i=>{o(!0);try{if(i.download_csv){const c=await Ps.generateCodes(i);if(c&&c instanceof Blob){const p=window.URL.createObjectURL(c),F=document.createElement("a");F.href=p,F.download=`gift_codes_${new Date().getTime()}.csv`,document.body.appendChild(F),F.click(),F.remove(),window.URL.revokeObjectURL(p),$.success(r("messages.codesGenerated")),s(),t(!1),x.reset()}}else await Ps.generateCodes(i),$.success(r("messages.codesGenerated")),s(),t(!1),x.reset()}catch{$.error(r("messages.generateCodesFailed"))}finally{o(!1)}};return e.jsx(de,{open:n,onOpenChange:t,children:e.jsxs(oe,{children:[e.jsx(he,{children:e.jsx(me,{children:r("code.form.generate")})}),e.jsx(De,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(u),className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"template_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.template_id.label")}),e.jsxs(X,{onValueChange:c=>i.onChange(parseInt(c)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:r("code.form.template_id.placeholder")})})}),e.jsx(Q,{children:l.map(c=>e.jsx(q,{value:c.id.toString(),children:c.name},c.id))})]}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"count",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.count.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...i,onChange:c=>i.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"prefix",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.prefix.label")}),e.jsx(b,{children:e.jsx(D,{...i})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"expires_hours",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.expires_hours.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...i,onChange:c=>i.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"max_usage",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.max_usage.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...i,onChange:c=>i.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"download_csv",render:({field:i})=>e.jsxs(f,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(b,{children:e.jsx("input",{type:"checkbox",checked:i.value,onChange:c=>i.onChange(c.target.checked)})}),e.jsx(v,{children:r("code.form.download_csv")})]})}),e.jsxs(Oe,{children:[e.jsx(L,{type:"button",variant:"outline",onClick:()=>t(!1),children:r("common.cancel")}),e.jsx(L,{type:"submit",disabled:a,children:r(a?"code.form.submit.generating":"code.form.submit.generate")})]})]})})]})})}function Jh({table:s,refetch:n}){const{t}=V("giftCard"),[r,a]=m.useState(!1),o=s.getState().columnFilters.length>0,l=Object.entries(t("code.status",{returnObjects:!0})).map(([d,x])=>({value:d,label:x}));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.jsx(D,{placeholder:t("common.search"),value:s.getColumn("code")?.getFilterValue()??"",onChange:d=>s.getColumn("code")?.setFilterValue(d.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("status")&&e.jsx(Oa,{column:s.getColumn("status"),title:t("code.table.columns.status"),options:l}),o&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),t("code.form.generate")]}),e.jsxs(L,{variant:"outline",size:"sm",disabled:!0,children:[e.jsx(ta,{className:"h-4 w-4 mr-2"}),t("common.export")]}),e.jsx(Pi,{table:s})]}),e.jsx(Yh,{refetch:n,open:r,onOpenChange:a})]})}const Qh=0,Xh=1,Zh=2,fn=3,eg=s=>{const{t:n}=V("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id})},{accessorKey:"code",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.code")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:"secondary",children:t.original.code}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>Et(t.original.code).then(()=>{$.success(n("common:copy.success"))}),children:e.jsx($n,{className:"h-4 w-4"})})]})},{accessorKey:"template_name",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.template_name")})},{accessorKey:"status",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.status")}),cell:({row:t})=>{const r=t.original.status,a=r===fn,o=r===Qh||r===fn;return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:r===Xh?"secondary":r===Zh||r===fn?"destructive":"default",children:n(`code.status.${r}`)}),o&&e.jsx(ee,{checked:!a,onCheckedChange:async l=>{const d=l?"enable":"disable";try{const{data:x}=await Ps.toggleCode({id:t.original.id,action:d});x?($.success(n("messages.codeStatusUpdated")),s()):$.error(n("messages.updateCodeStatusFailed"))}catch{$.error(n("messages.updateCodeStatusFailed"))}}})]})}},{accessorKey:"expires_at",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.expires_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.original.expires_at)})},{accessorKey:"usage_count",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.usage_count")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.usage_count})},{accessorKey:"max_usage",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.max_usage")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.max_usage})},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.original.created_at)})}]};function sg(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,o]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:i,data:c}=re({queryKey:["giftCardCodes",x,a,l],queryFn:()=>Ps.getCodes({per_page:x.pageSize,page:x.pageIndex+1,filter:a,sort:l})}),p=Ye({data:c?.data??[],columns:eg(i),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},pageCount:Math.ceil((c?.total??0)/x.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,onPaginationChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:p,toolbar:e.jsx(Jh,{table:p,refetch:i})})})}const tg=()=>{const{t:s}=V("giftCard");return[{accessorKey:"id",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.id")}),cell:({row:n})=>e.jsx(U,{children:n.original.id})},{accessorKey:"code",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.code")}),cell:({row:n})=>e.jsx(U,{variant:"secondary",children:n.original.code})},{accessorKey:"user_email",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.user_email")})},{accessorKey:"template_name",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.template_name")})},{accessorKey:"created_at",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.created_at")}),cell:({row:n})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(n.original.created_at)})}]};function ag(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,o]=m.useState({pageIndex:0,pageSize:20}),{data:l}=re({queryKey:["giftCardUsages",a,s,t],queryFn:()=>Ps.getUsages({per_page:a.pageSize,page:a.pageIndex+1,filter:s,sort:t})}),d=Ye({data:l?.data??[],columns:tg(),state:{sorting:t,columnFilters:s,pagination:a},pageCount:Math.ceil((l?.total??0)/a.pageSize),rowCount:l?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,onSortingChange:r,onColumnFiltersChange:n,onPaginationChange:o,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js()});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{placeholder:"搜索用户邮箱...",value:d.getColumn("user_email")?.getFilterValue()??"",onChange:x=>d.getColumn("user_email")?.setFilterValue(x.target.value),className:"h-8 w-[150px] lg:w-[250px]"})}),e.jsx(rs,{table:d})]})}function ng(){const{t:s}=V("giftCard"),{data:n,isLoading:t}=re({queryKey:["giftCardStats"],queryFn:()=>Ps.getStatistics({})}),r=n?.data?.total_stats,a=[{title:s("statistics.total.templates_count"),value:r?.templates_count},{title:s("statistics.total.active_templates_count"),value:r?.active_templates_count},{title:s("statistics.total.codes_count"),value:r?.codes_count},{title:s("statistics.total.used_codes_count"),value:r?.used_codes_count}];return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:a.map((o,l)=>e.jsxs(ke,{children:[e.jsx(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:e.jsx(Me,{className:"text-sm font-medium",children:o.title})}),e.jsx(Pe,{children:t?e.jsx(be,{className:"h-8 w-1/2"}):e.jsx("div",{className:"text-2xl font-bold",children:o.value??0})})]},l))})}function rg(){const{t:s}=V("giftCard"),[n,t]=m.useState("templates");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-6 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.jsxs(yt,{value:n,onValueChange:t,className:"flex-1",children:[e.jsxs(lt,{className:"grid w-full grid-cols-4",children:[e.jsx(Ge,{value:"templates",children:s("tabs.templates")}),e.jsx(Ge,{value:"codes",children:s("tabs.codes")}),e.jsx(Ge,{value:"usages",children:s("tabs.usages")}),e.jsx(Ge,{value:"statistics",children:s("tabs.statistics")})]}),e.jsx(ys,{value:"templates",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("template.description")})]})}),e.jsx(Gh,{})]})}),e.jsx(ys,{value:"codes",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("code.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("code.description")})]})}),e.jsx(sg,{})]})}),e.jsx(ys,{value:"usages",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("usage.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("usage.description")})]})}),e.jsx(ag,{})]})}),e.jsx(ys,{value:"statistics",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("statistics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("statistics.description")})]})}),e.jsx(ng,{})]})})]})]})]})}const lg=Object.freeze(Object.defineProperty({__proto__:null,default:rg},Symbol.toStringTag,{value:"Module"}));function ig({open:s,onOpenChange:n,table:t}){const{t:r}=V("user"),[a,o]=m.useState(!1),[l,d]=m.useState(""),[x,u]=m.useState(""),i=async()=>{if(!l||!x){$.error(r("messages.send_mail.required_fields"));return}try{o(!0),await Us.sendMail({subject:l,content:x,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),$.success(r("messages.send_mail.success")),n(!1),d(""),u("")}catch{$.error(r("messages.send_mail.failed"))}finally{o(!1)}};return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(oe,{className:"sm:max-w-[500px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("send_mail.title")}),e.jsx(qe,{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(D,{id:"subject",value:l,onChange:c=>d(c.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(Es,{id:"content",value:x,onChange:c=>u(c.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(Oe,{children:e.jsx(G,{type:"submit",onClick:i,disabled:a,children:r(a?"send_mail.sending":"send_mail.send")})})]})})}function og({trigger:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),[a,o]=m.useState(30),{data:l,isLoading:d}=re({queryKey:["trafficResetStats",a],queryFn:()=>la.getStats({days:a}),enabled:t}),x=[{title:n("traffic_reset.stats.total_resets"),value:l?.data?.total_resets||0,icon:Jt,color:"text-blue-600",bgColor:"bg-blue-100"},{title:n("traffic_reset.stats.auto_resets"),value:l?.data?.auto_resets||0,icon:Pa,color:"text-green-600",bgColor:"bg-green-100"},{title:n("traffic_reset.stats.manual_resets"),value:l?.data?.manual_resets||0,icon:Ss,color:"text-orange-600",bgColor:"bg-orange-100"},{title:n("traffic_reset.stats.cron_resets"),value:l?.data?.cron_resets||0,icon:An,color:"text-purple-600",bgColor:"bg-purple-100"}],u=[{value:7,label:n("traffic_reset.stats.days_options.week")},{value:30,label:n("traffic_reset.stats.days_options.month")},{value:90,label:n("traffic_reset.stats.days_options.quarter")},{value:365,label:n("traffic_reset.stats.days_options.year")}];return e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(cs,{asChild:!0,children:s}),e.jsxs(oe,{className:"max-w-2xl",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(Mn,{className:"h-5 w-5"}),n("traffic_reset.stats.title")]}),e.jsx(qe,{children:n("traffic_reset.stats.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium",children:n("traffic_reset.stats.time_range")}),e.jsxs(X,{value:a.toString(),onValueChange:i=>o(Number(i)),children:[e.jsx(J,{className:"w-[180px]",children:e.jsx(Z,{})}),e.jsx(Q,{children:u.map(i=>e.jsx(q,{value:i.value.toString(),children:i.label},i.value))})]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(sa,{className:"h-6 w-6 animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-4",children:x.map((i,c)=>e.jsxs(ke,{className:"relative overflow-hidden",children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Me,{className:"text-sm font-medium text-muted-foreground",children:i.title}),e.jsx("div",{className:`rounded-lg p-2 ${i.bgColor}`,children:e.jsx(i.icon,{className:`h-4 w-4 ${i.color}`})})]}),e.jsxs(Pe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:i.value.toLocaleString()}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n("traffic_reset.stats.in_period",{days:a})})]})]},c))}),l?.data&&e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsx(Me,{className:"text-lg",children:n("traffic_reset.stats.breakdown")}),e.jsx(et,{children:n("traffic_reset.stats.breakdown_description")})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.auto_percentage")}),e.jsxs(U,{variant:"outline",className:"border-green-200 bg-green-50 text-green-700",children:[l.data.total_resets>0?(l.data.auto_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.manual_percentage")}),e.jsxs(U,{variant:"outline",className:"border-orange-200 bg-orange-50 text-orange-700",children:[l.data.total_resets>0?(l.data.manual_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.cron_percentage")}),e.jsxs(U,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:[l.data.total_resets>0?(l.data.cron_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]})]})})]})]})]})]})}const cg=h.object({email_prefix:h.string().optional(),email_suffix:h.string().min(1),password:h.string().optional(),expired_at:h.number().optional().nullable(),plan_id:h.number().nullable(),generate_count:h.number().optional().nullable(),download_csv:h.boolean().optional()}).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"]}),dg={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0,download_csv:!1};function mg({refetch:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),a=Ce({resolver:Te(cg),defaultValues:dg,mode:"onChange"}),[o,l]=m.useState([]);return m.useEffect(()=>{t&&_s.getList().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{size:"sm",variant:"outline",className:"gap-0 space-x-2",children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:n("generate.title")}),e.jsx(qe,{})]}),e.jsxs(De,{...a,children:[e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(j,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(D,{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(j,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(D,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(j,{control:a.control,name:"password",render:({field:d})=>e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:n("generate.form.expire_time")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(G,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?ne(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(We,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Fd,{asChild:!0,children:e.jsx(G,{variant:"outline",className:"w-full",onClick:()=>{d.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(ks,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:x=>{x&&d.onChange(x?.getTime()/1e3)}})})]})]})]})}),e.jsx(j,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.subscription")}),e.jsx(b,{children:e.jsxs(X,{value:d.value?d.value.toString():"null",onValueChange:x=>d.onChange(x==="null"?null:parseInt(x)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"null",children:n("generate.form.subscription_none")}),o.map(x=>e.jsx(q,{value:x.id.toString(),children:x.name},x.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(j,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.generate_count")}),e.jsx(D,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:d.value||"",onChange:x=>d.onChange(x.target.value?parseInt(x.target.value):null)})]})}),a.watch("generate_count")&&e.jsx(j,{control:a.control,name:"download_csv",render:({field:d})=>e.jsxs(f,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(b,{children:e.jsx(Yn,{checked:d.value,onCheckedChange:d.onChange})}),e.jsx(v,{children:n("generate.form.download_csv")})]})})]}),e.jsxs(Oe,{children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:n("generate.form.cancel")}),e.jsx(G,{onClick:()=>a.handleSubmit(async d=>{if(d.download_csv){const x=await Us.generate(d);if(x&&x instanceof Blob){const u=window.URL.createObjectURL(x),i=document.createElement("a");i.href=u,i.download=`users_${new Date().getTime()}.csv`,document.body.appendChild(i),i.click(),i.remove(),window.URL.revokeObjectURL(u),$.success(n("generate.form.success")),a.reset(),s(),r(!1)}}else{const{data:x}=await Us.generate(d);x&&($.success(n("generate.form.success")),a.reset(),s(),r(!1))}})(),children:n("generate.form.submit")})]})]})]})}const ug=1,xg=1e6;let jn=0;function hg(){return jn=(jn+1)%Number.MAX_SAFE_INTEGER,jn.toString()}const vn=new Map,Tr=s=>{if(vn.has(s))return;const n=setTimeout(()=>{vn.delete(s),ea({type:"REMOVE_TOAST",toastId:s})},xg);vn.set(s,n)},gg=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,ug)};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?Tr(t):s.toasts.forEach(r=>{Tr(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)}}},Ca=[];let Sa={toasts:[]};function ea(s){Sa=gg(Sa,s),Ca.forEach(n=>{n(Sa)})}function pg({...s}){const n=hg(),t=a=>ea({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>ea({type:"DISMISS_TOAST",toastId:n});return ea({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function fg(){const[s,n]=m.useState(Sa);return m.useEffect(()=>(Ca.push(n),()=>{const t=Ca.indexOf(n);t>-1&&Ca.splice(t,1)}),[s]),{...s,toast:pg,dismiss:t=>ea({type:"DISMISS_TOAST",toastId:t})}}const Jn=$r,Li=Ar,jg=qr,Ri=m.forwardRef(({className:s,...n},t)=>e.jsx(za,{className:_("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}));Ri.displayName=za.displayName;const vg=vt("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"}}),nn=m.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(jg,{children:[e.jsx(Ri,{}),e.jsxs($a,{ref:a,className:_(vg({side:s}),n),...r,children:[e.jsxs(Rn,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));nn.displayName=$a.displayName;const rn=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});rn.displayName="SheetHeader";const Ei=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ei.displayName="SheetFooter";const ln=m.forwardRef(({className:s,...n},t)=>e.jsx(Aa,{ref:t,className:_("text-lg font-semibold text-foreground",s),...n}));ln.displayName=Aa.displayName;const on=m.forwardRef(({className:s,...n},t)=>e.jsx(qa,{ref:t,className:_("text-sm text-muted-foreground",s),...n}));on.displayName=qa.displayName;function bg({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=V("user"),{toast:o}=fg(),l=s.getState().columnFilters.length>0,[d,x]=m.useState([]),[u,i]=m.useState(!1),[c,p]=m.useState(!1),[F,T]=m.useState(!1),[C,P]=m.useState(!1),w=async()=>{try{const te=await Us.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),ae=te;console.log(te);const B=new Blob([ae],{type:"text/csv;charset=utf-8;"}),se=window.URL.createObjectURL(B),je=document.createElement("a");je.href=se,je.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(je),je.click(),je.remove(),window.URL.revokeObjectURL(se),o({title:a("messages.success"),description:a("messages.export.success")})}catch{o({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},I=async()=>{try{P(!0),await Us.batchBan({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),o({title:a("messages.success"),description:a("messages.batch_ban.success")}),n()}catch{o({title:a("messages.error"),description:a("messages.batch_ban.failed"),variant:"destructive"})}finally{P(!1),T(!1)}},y=[{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.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{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"}]}],N=te=>te*1024*1024*1024,S=te=>te/(1024*1024*1024),O=()=>{x([...d,{field:"",operator:"",value:""}])},E=te=>{x(d.filter((ae,B)=>B!==te))},g=(te,ae,B)=>{const se=[...d];if(se[te]={...se[te],[ae]:B},ae==="field"){const je=y.find(ms=>ms.value===B);je&&(se[te].operator=je.operators[0].value,se[te].value=je.type==="boolean"?!1:"")}x(se)},k=(te,ae)=>{const B=y.find(se=>se.value===te.field);if(!B)return null;switch(B.type){case"text":return e.jsx(D,{placeholder:a("filter.sheet.value"),value:te.value,onChange:se=>g(ae,"value",se.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(D,{type:"number",placeholder:a("filter.sheet.value_number",{unit:B.unit}),value:B.unit==="GB"?S(te.value||0):te.value,onChange:se=>{const je=Number(se.target.value);g(ae,"value",B.unit==="GB"?N(je):je)}}),B.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:B.unit})]});case"date":return e.jsx(ks,{mode:"single",selected:te.value,onSelect:se=>g(ae,"value",se),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(X,{value:te.value,onValueChange:se=>g(ae,"value",se),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("filter.sheet.value")})}),e.jsx(Q,{children:B.useOptions?r.map(se=>e.jsx(q,{value:se.value.toString(),children:se.label},se.value)):B.options?.map(se=>e.jsx(q,{value:se.value.toString(),children:se.label},se.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ee,{checked:te.value,onCheckedChange:se=>g(ae,"value",se)}),e.jsx(Xe,{children:te.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},W=()=>{const te=d.filter(ae=>ae.field&&ae.operator&&ae.value!=="").map(ae=>{const B=y.find(je=>je.value===ae.field);let se=ae.value;return ae.operator==="contains"?{id:ae.field,value:se}:(B?.type==="date"&&se instanceof Date&&(se=Math.floor(se.getTime()/1e3)),B?.type==="boolean"&&(se=se?1:0),{id:ae.field,value:`${ae.operator}:${se}`})});s.setColumnFilters(te),i(!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(mg,{refetch:n}),e.jsx(D,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:te=>s.getColumn("email")?.setFilterValue(te.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Jn,{open:u,onOpenChange:i,children:[e.jsx(Li,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ol,{className:"mr-2 h-4 w-4"}),a("filter.advanced"),d.length>0&&e.jsx(U,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:d.length})]})}),e.jsxs(nn,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(rn,{children:[e.jsx(ln,{children:a("filter.sheet.title")}),e.jsx(on,{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(L,{variant:"outline",size:"sm",onClick:O,children:a("filter.sheet.add")})]}),e.jsx(jt,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((te,ae)=>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(Xe,{children:a("filter.sheet.condition",{number:ae+1})}),e.jsx(L,{variant:"ghost",size:"sm",onClick:()=>E(ae),children:e.jsx(os,{className:"h-4 w-4"})})]}),e.jsxs(X,{value:te.field,onValueChange:B=>g(ae,"field",B),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("filter.sheet.field")})}),e.jsx(Q,{children:e.jsx(ws,{children:y.map(B=>e.jsx(q,{value:B.value,className:"cursor-pointer",children:B.label},B.value))})})]}),te.field&&e.jsxs(X,{value:te.operator,onValueChange:B=>g(ae,"operator",B),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("filter.sheet.operator")})}),e.jsx(Q,{children:y.find(B=>B.value===te.field)?.operators.map(B=>e.jsx(q,{value:B.value,children:B.label},B.value))})]}),te.field&&te.operator&&k(te,ae)]},ae))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{variant:"outline",onClick:()=>{x([]),i(!1)},children:a("filter.sheet.reset")}),e.jsx(L,{onClick:W,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),x([])},className:"h-8 px-2 lg:px-3",children:[a("filter.sheet.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]}),e.jsxs(Hs,{modal:!1,children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(qs,{children:[e.jsx(Se,{onClick:()=>p(!0),children:a("actions.send_email")}),e.jsx(Se,{onClick:w,children:a("actions.export_csv")}),e.jsx(at,{}),e.jsx(Se,{asChild:!0,children:e.jsx(og,{trigger:e.jsx("div",{className:"w-full cursor-pointer px-2 py-1.5 text-sm",children:a("actions.traffic_reset_stats")})})}),e.jsx(at,{}),e.jsx(Se,{onClick:()=>T(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(ig,{open:c,onOpenChange:p,table:s}),e.jsx(Gn,{open:F,onOpenChange:T,children:e.jsxs(Ya,{children:[e.jsxs(Ja,{children:[e.jsx(Xa,{children:a("actions.confirm_ban.title")}),e.jsx(Za,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs(Qa,{children:[e.jsx(sn,{disabled:C,children:a("actions.confirm_ban.cancel")}),e.jsx(en,{onClick:I,disabled:C,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(C?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const Ii=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"})}),Vi=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"})}),yg=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"})}),_g=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"})}),bn=[{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:Yd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ii,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:Le(s.original.u/parseFloat(s.original.server_rate))})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:Le(s.original.d/parseFloat(s.original.server_rate))})]})},{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(U,{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:Le(n)})}}];function Mi({user_id:s,dialogTrigger:n}){const{t}=V(["traffic"]),[r,a]=m.useState(!1),[o,l]=m.useState({pageIndex:0,pageSize:20}),{data:d,isLoading:x}=re({queryKey:["userStats",s,o,r],queryFn:()=>r?Us.getStats({user_id:s,pageSize:o.pageSize,page:o.pageIndex+1}):null}),u=Ye({data:d?.data??[],columns:bn,pageCount:Math.ceil((d?.total??0)/o.pageSize),state:{pagination:o},manualPagination:!0,getCoreRowModel:Je(),onPaginationChange:l});return e.jsxs(de,{open:r,onOpenChange:a,children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"sm:max-w-[700px]",children:[e.jsx(he,{children:e.jsx(me,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Un,{children:[e.jsx(Hn,{children:u.getHeaderGroups().map(i=>e.jsx(Zs,{children:i.headers.map(c=>e.jsx(Bn,{className:_("h-10 px-2 text-xs",c.id==="total"&&"text-right"),children:c.isPlaceholder?null:Da(c.column.columnDef.header,c.getContext())},c.id))},i.id))}),e.jsx(Kn,{children:x?Array.from({length:o.pageSize}).map((i,c)=>e.jsx(Zs,{children:Array.from({length:bn.length}).map((p,F)=>e.jsx(Lt,{className:"p-2",children:e.jsx(be,{className:"h-6 w-full"})},F))},c)):u.getRowModel().rows?.length?u.getRowModel().rows.map(i=>e.jsx(Zs,{"data-state":i.getIsSelected()&&"selected",className:"h-10",children:i.getVisibleCells().map(c=>e.jsx(Lt,{className:"px-2",children:Da(c.column.columnDef.cell,c.getContext())},c.id))},i.id)):e.jsx(Zs,{children:e.jsx(Lt,{colSpan:bn.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(X,{value:`${u.getState().pagination.pageSize}`,onValueChange:i=>{u.setPageSize(Number(i))},children:[e.jsx(J,{className:"h-8 w-[70px]",children:e.jsx(Z,{placeholder:u.getState().pagination.pageSize})}),e.jsx(Q,{side:"top",children:[10,20,30,40,50].map(i=>e.jsx(q,{value:`${i}`,children:i},i))})]}),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:u.getState().pagination.pageIndex+1,total:u.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>u.previousPage(),disabled:!u.getCanPreviousPage()||x,children:e.jsx(yg,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>u.nextPage(),disabled:!u.getCanNextPage()||x,children:e.jsx(_g,{className:"h-4 w-4"})})]})]})]})]})]})]})}function Ng({user:s,trigger:n,onSuccess:t}){const{t:r}=V("user"),[a,o]=m.useState(!1),[l,d]=m.useState(""),[x,u]=m.useState(!1),{data:i,isLoading:c}=re({queryKey:["trafficResetHistory",s.id],queryFn:()=>la.getUserHistory(s.id,{limit:10}),enabled:a}),p=async()=>{try{u(!0);const{data:C}=await la.resetUser({user_id:s.id,reason:l.trim()||void 0});C&&($.success(r("traffic_reset.reset_success")),o(!1),d(""),t?.())}finally{u(!1)}},F=C=>{switch(C){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},T=C=>{switch(C){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}};return e.jsxs(de,{open:a,onOpenChange:o,children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-hidden",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-5 w-5"}),r("traffic_reset.title")]}),e.jsx(qe,{children:r("traffic_reset.description",{email:s.email})})]}),e.jsxs(yt,{defaultValue:"reset",className:"w-full",children:[e.jsxs(lt,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ge,{value:"reset",className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-4 w-4"}),r("traffic_reset.tabs.reset")]}),e.jsxs(Ge,{value:"history",className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),r("traffic_reset.tabs.history")]})]}),e.jsxs(ys,{value:"reset",className:"space-y-4",children:[e.jsxs(ke,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Me,{className:"flex items-center gap-2 text-lg",children:[e.jsx($l,{className:"h-5 w-5"}),r("traffic_reset.user_info")]})}),e.jsx(Pe,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.email")}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.used_traffic")}),e.jsx("p",{className:"font-medium",children:Le(s.total_used)})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.total_traffic")}),e.jsx("p",{className:"font-medium",children:Le(s.transfer_enable)})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.expire_time")}),e.jsx("p",{className:"font-medium",children:s.expired_at?ne(s.expired_at):r("columns.expire_status.permanent")})]})]})})]}),e.jsxs(ke,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Me,{className:"flex items-center gap-2 text-lg text-amber-800",children:[e.jsx(Yt,{className:"h-5 w-5"}),r("traffic_reset.warning.title")]})}),e.jsx(Pe,{children:e.jsxs("ul",{className:"space-y-2 text-sm text-amber-700",children:[e.jsxs("li",{children:["• ",r("traffic_reset.warning.irreversible")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.reset_to_zero")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.logged")]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"reason",children:r("traffic_reset.reason.label")}),e.jsx(Es,{id:"reason",placeholder:r("traffic_reset.reason.placeholder"),value:l,onChange:C=>d(C.target.value),className:"min-h-[80px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("traffic_reset.reason.optional")})]}),e.jsxs(Oe,{children:[e.jsx(G,{variant:"outline",onClick:()=>o(!1),children:r("common:cancel")}),e.jsx(G,{onClick:p,disabled:x,className:"bg-destructive hover:bg-destructive/90",children:x?e.jsxs(e.Fragment,{children:[e.jsx(sa,{className:"mr-2 h-4 w-4 animate-spin"}),r("traffic_reset.resetting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Jt,{className:"mr-2 h-4 w-4"}),r("traffic_reset.confirm_reset")]})})]})]}),e.jsx(ys,{value:"history",className:"space-y-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(sa,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[i?.data?.user&&e.jsxs(ke,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsx(Me,{className:"text-lg",children:r("traffic_reset.history.summary")})}),e.jsx(Pe,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.reset_count")}),e.jsx("p",{className:"font-medium",children:i.data.user.reset_count})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.last_reset")}),e.jsx("p",{className:"font-medium",children:i.data.user.last_reset_at?ne(i.data.user.last_reset_at):r("traffic_reset.history.never")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.next_reset")}),e.jsx("p",{className:"font-medium",children:i.data.user.next_reset_at?ne(i.data.user.next_reset_at):r("traffic_reset.history.no_schedule")})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{className:"pb-3",children:[e.jsx(Me,{className:"text-lg",children:r("traffic_reset.history.records")}),e.jsx(et,{children:r("traffic_reset.history.recent_records")})]}),e.jsx(Pe,{children:e.jsx(jt,{className:"h-[300px]",children:i?.data?.history?.length?e.jsx("div",{className:"space-y-3",children:i.data.history.map((C,P)=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between rounded-lg border bg-card p-3",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:F(C.reset_type),children:C.reset_type_name}),e.jsx(U,{variant:"outline",className:T(C.trigger_source),children:C.trigger_source_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs(Xe,{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(An,{className:"h-3 w-3"}),r("traffic_reset.history.reset_time")]}),e.jsx("p",{className:"font-medium",children:ne(C.reset_time)})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.traffic_cleared")}),e.jsx("p",{className:"font-medium text-destructive",children:C.old_traffic.formatted})]})]})]})}),P{o(s)},[s]),e.jsxs(de,{children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"max-w-xl",children:[e.jsxs(he,{className:"space-y-2",children:[e.jsx(me,{className:"text-lg font-medium",children:r("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:[r("dialog.fields.userId"),":",a.id]}),e.jsx(Cg,{banned:a.banned,isAdmin:a.is_admin,isStaff:a.is_staff})]})})]}),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:r("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{label:r("dialog.fields.email"),value:a.email,valueClassName:"font-medium"}),e.jsx(ve,{label:r("dialog.fields.uuid"),value:a.uuid,valueClassName:"font-mono text-xs"}),e.jsx(ve,{label:r("dialog.fields.token"),value:a.token,valueClassName:"font-mono text-xs"}),e.jsx(ve,{label:r("dialog.fields.remarks"),value:a.remarks}),e.jsx(ve,{label:r("dialog.fields.telegramId"),value:a.telegram_id?e.jsx("span",{className:"font-mono text-xs",children:a.telegram_id}):"-"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:r("dialog.subscriptionInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{label:r("dialog.fields.subscriptionPlan"),value:a.plan?.name,valueClassName:"font-medium"}),e.jsx(ve,{label:r("dialog.fields.permissionGroup"),value:a.group?.name,valueClassName:"font-medium"}),e.jsx(ve,{label:r("dialog.fields.expiredAt"),value:e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx("span",{className:"font-mono text-xs",children:a.expired_at==null?r("columns.expire_status.permanent"):ne(a.expired_at,"YYYY-MM-DD")})}),e.jsx(ce,{side:"bottom",className:"space-y-1 p-3",children:a.expired_at!=null?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r("columns.expire_time"),":"," ",ne(a.expired_at)]}),e.jsx("p",{className:_("text-sm font-medium",a.expired_ate.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"})}),Tg=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"})}),Dg=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"})}),Dr=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"})}),Fg=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"})}),Pg=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"})}),Lg=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"})}),Rg=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"})}),Eg=(s,n,t,r)=>{const{t:a}=V("user");return[{accessorKey:"is_admin",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(o,l,d)=>d.includes(o.getValue(l)),size:0},{accessorKey:"is_staff",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(o,l,d)=>d.includes(o.getValue(l)),size:0},{accessorKey:"id",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.id")}),cell:({row:o})=>e.jsx(U,{variant:"outline",children:o.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.email")}),cell:({row:o})=>{const l=o.original.t||0,d=Date.now()/1e3-l<120,x=Math.floor(Date.now()/1e3-l);let u=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:ne(l)});if(!d&&l!==0){const F=Math.floor(x/60),T=Math.floor(F/60),C=Math.floor(T/24);C>0?u+=` +`).filter(ae=>ae.trim()!=="");g.onChange(te)}})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.anytls.tls.server_name.label","SNI")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dynamic_form.anytls.tls.server_name.placeholder","服务器名称"),...g})})]})}),e.jsx(j,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dynamic_form.anytls.tls.allow_insecure","允许不安全连接")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(b,{children:e.jsx(ee,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]})})};return e.jsx(pe,{children:E[s]?.()})};function Hx(){const{t:s}=V("server"),n=h.object({start:h.string().min(1,s("form.dynamic_rate.start_time_error")),end:h.string().min(1,s("form.dynamic_rate.end_time_error")),rate:h.string().min(1,s("form.dynamic_rate.multiplier_error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.dynamic_rate.multiplier_error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.dynamic_rate.multiplier_error_gte_zero")})}),t=h.object({id:h.number().optional().nullable(),specific_key:h.string().optional().nullable(),code:h.string().optional(),show:h.boolean().optional().nullable(),name:h.string().min(1,s("form.name.error")),rate:h.string().min(1,s("form.rate.error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.rate.error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.rate.error_gte_zero")}),rate_time_enable:h.boolean().default(!1),rate_time_ranges:h.array(n).default([]),tags:h.array(h.string()).default([]),excludes:h.array(h.string()).default([]),ips:h.array(h.string()).default([]),group_ids:h.array(h.string()).default([]),host:h.string().min(1,s("form.host.error")),port:h.string().min(1,s("form.port.error")),server_port:h.string().min(1,s("form.server_port.error")),parent_id:h.string().default("0").nullable(),route_ids:h.array(h.string()).default([]),protocol_settings:h.record(h.any()).default({}).nullable()}),r={id:null,specific_key:null,code:"",show:!1,name:"",rate:"1",rate_time_enable:!1,rate_time_ranges:[],tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null},{isOpen:a,setIsOpen:i,editingServer:l,setEditingServer:d,serverType:x,setServerType:u,refetch:o}=Ni(),[c,p]=m.useState([]),[F,T]=m.useState([]),[C,P]=m.useState([]),N=Ce({resolver:Te(t),defaultValues:r,mode:"onChange"});m.useEffect(()=>{I()},[a]),m.useEffect(()=>{l?.type&&l.type!==x&&u(l.type)},[l,x,u]),m.useEffect(()=>{l?l.type===x&&N.reset({...r,...l}):N.reset({...r,protocol_settings:Ve[x].schema.parse({})})},[l,N,x]);const I=async()=>{if(!a)return;const[E,g,k]=await Promise.all([Nt.getList(),Ga.getList(),ft.getList()]);p(E.data?.map(W=>({label:W.name,value:W.id.toString()}))||[]),T(g.data?.map(W=>({label:W.remarks,value:W.id.toString()}))||[]),P(k.data||[])},y=m.useMemo(()=>C?.filter(E=>(E.parent_id===0||E.parent_id===null)&&E.type===x&&E.id!==N.watch("id")),[x,C,N]),w=()=>e.jsxs(Hs,{children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx($e,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(qs,{align:"start",children:e.jsx(pm,{children:Fs.map(({type:E,label:g})=>e.jsx(Se,{onClick:()=>{u(E),i(!0)},className:"cursor-pointer",children:e.jsx(U,{variant:"outline",className:"text-white",style:{background:bs[E]},children:g})},E))})})]}),S=()=>{i(!1),d(null),N.reset(r)},O=async()=>{const E=N.getValues();(await ft.save({...E,type:x})).data&&(S(),$.success(s("form.success")),o())};return e.jsxs(de,{open:a,onOpenChange:S,children:[w(),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Ue,{})]}),e.jsxs(De,{...N,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:N.control,name:"name",render:({field:E})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:s("form.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:"rate",render:({field:E})=>{const g=N.watch("parent_id")!="0"&&N.watch("parent_id")!==null;return e.jsxs(f,{className:"flex-[1]",children:[e.jsx("div",{className:"relative",children:e.jsx(v,{children:s("form.rate.label")})}),e.jsx(b,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",min:"0",step:"0.1",...E,disabled:g,className:g?"cursor-not-allowed bg-muted/50":""}),g&&e.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2",children:e.jsx($e,{icon:"ph:lock-simple",className:"size-4 text-muted-foreground/60"})})]})}),e.jsx(R,{})]})}})]}),N.watch("parent_id")!="0"&&N.watch("parent_id")!==null&&e.jsxs("div",{className:"ml-auto flex w-fit items-center gap-1 text-xs text-muted-foreground",children:[e.jsx($e,{icon:"ph:info",className:"size-3"}),s("form.rate.child_node_note")]})]}),e.jsx(j,{control:N.control,name:"rate_time_enable",render:({field:E})=>e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(v,{children:s("form.dynamic_rate.enable_label")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("form.dynamic_rate.enable_description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:E.value,onCheckedChange:E.onChange})})]}),e.jsx(R,{})]})}),N.watch("rate_time_enable")&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(v,{className:"",children:s("form.dynamic_rate.rules_label")}),e.jsxs(L,{type:"button",variant:"outline",size:"sm",onClick:()=>{const E=N.getValues("rate_time_ranges")||[];N.setValue("rate_time_ranges",[...E,{start:"00:00",end:"23:59",rate:"1"}])},children:[e.jsx($e,{icon:"ion:add",className:"mr-1 size-4"}),s("form.dynamic_rate.add_rule")]})]}),(N.watch("rate_time_ranges")||[]).map((E,g)=>e.jsxs("div",{className:"space-y-2 rounded border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:s("form.dynamic_rate.rule_title",{index:g+1})}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",onClick:()=>{const k=N.getValues("rate_time_ranges")||[];k.splice(g,1),N.setValue("rate_time_ranges",[...k])},children:e.jsx($e,{icon:"ion:trash-outline",className:"size-4"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(j,{control:N.control,name:`rate_time_ranges.${g}.start`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-xs",children:s("form.dynamic_rate.start_time")}),e.jsx(b,{children:e.jsx(D,{type:"time",...k,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:`rate_time_ranges.${g}.end`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-xs",children:s("form.dynamic_rate.end_time")}),e.jsx(b,{children:e.jsx(D,{type:"time",...k,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:`rate_time_ranges.${g}.rate`,render:({field:k})=>e.jsxs(f,{children:[e.jsx(v,{className:"text-xs",children:s("form.dynamic_rate.multiplier")}),e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...k,className:"text-sm",placeholder:"1.0"})}),e.jsx(R,{})]})})]})]},g)),(N.watch("rate_time_ranges")||[]).length===0&&e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:s("form.dynamic_rate.no_rules")})]}),e.jsx(j,{control:N.control,name:"code",render:({field:E})=>e.jsxs(f,{children:[e.jsxs(v,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(b,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...E,value:E.value||""})}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:"tags",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.tags.label")}),e.jsx(b,{children:e.jsx(an,{value:E.value,onChange:E.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:"group_ids",render:({field:E})=>e.jsxs(f,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(nn,{dialogTrigger:e.jsx(L,{variant:"link",children:s("form.groups.add")}),refetch:I})]}),e.jsx(b,{children:e.jsx(rt,{options:c,onChange:g=>E.onChange(g.map(k=>k.value)),value:c?.filter(g=>E.value.includes(g.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(R,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:N.control,name:"host",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.host.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{control:N.control,name:"port",render:({field:E})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx($e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Ra,{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(b,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...E})}),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const g=E.value;g&&N.setValue("server_port",g)},children:e.jsx($e,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ce,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:"server_port",render:({field:E})=>e.jsxs(f,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx($e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Ra,{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(b,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...E})}),e.jsx(R,{})]})})]})]}),a&&e.jsx(Ux,{serverType:x,value:N.watch("protocol_settings"),onChange:E=>N.setValue("protocol_settings",E,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(j,{control:N.control,name:"parent_id",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.parent.label")}),e.jsxs(X,{onValueChange:E.onChange,value:E.value?.toString()||"0",children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("form.parent.none")}),y?.map(g=>e.jsx(q,{value:g.id.toString(),className:"cursor-pointer",children:g.name},g.id))]})]}),e.jsx(R,{})]})}),e.jsx(j,{control:N.control,name:"route_ids",render:({field:E})=>e.jsxs(f,{children:[e.jsx(v,{children:s("form.route.label")}),e.jsx(b,{children:e.jsx(rt,{options:F,onChange:g=>E.onChange(g.map(k=>k.value)),value:F?.filter(g=>E.value.includes(g.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(R,{})]})})]}),e.jsxs(Oe,{className:"mt-6 flex flex-col gap-2 sm:flex-row sm:gap-0",children:[e.jsx(L,{type:"button",variant:"outline",onClick:S,className:"w-full sm:w-auto",children:s("form.cancel")}),e.jsx(L,{type:"submit",onClick:O,className:"w-full sm:w-auto",children:s("form.submit")})]})]})]})]})}function Cr({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ka,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(ot,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ct,{children:"No results found."}),e.jsx(gs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(qe,{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:_("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(yt,{className:_("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(Ot,{}),e.jsx(gs,{children:e.jsx(qe,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Kx=[{value:ge.Shadowsocks,label:Fs.find(s=>s.type===ge.Shadowsocks)?.label,color:bs[ge.Shadowsocks]},{value:ge.Vmess,label:Fs.find(s=>s.type===ge.Vmess)?.label,color:bs[ge.Vmess]},{value:ge.Trojan,label:Fs.find(s=>s.type===ge.Trojan)?.label,color:bs[ge.Trojan]},{value:ge.Hysteria,label:Fs.find(s=>s.type===ge.Hysteria)?.label,color:bs[ge.Hysteria]},{value:ge.Vless,label:Fs.find(s=>s.type===ge.Vless)?.label,color:bs[ge.Vless]},{value:ge.Tuic,label:Fs.find(s=>s.type===ge.Tuic)?.label,color:bs[ge.Tuic]},{value:ge.Socks,label:Fs.find(s=>s.type===ge.Socks)?.label,color:bs[ge.Socks]},{value:ge.Naive,label:Fs.find(s=>s.type===ge.Naive)?.label,color:bs[ge.Naive]},{value:ge.Http,label:Fs.find(s=>s.type===ge.Http)?.label,color:bs[ge.Http]},{value:ge.Mieru,label:Fs.find(s=>s.type===ge.Mieru)?.label,color:bs[ge.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(Hx,{}),e.jsx(D,{placeholder:i("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(Cr,{column:s.getColumn("type"),title:i("toolbar.type"),options:Kx}),s.getColumn("group_ids")&&e.jsx(Cr,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(os,{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(L,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const Oa=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"})}),va={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"},Be=(s,n)=>n>0?Math.round(s/n*100):0,Gx=s=>{const{t:n}=V("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ha,{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(z,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(U,{variant:"outline",className:_("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:bs[t.original.type]},children:[e.jsx(Rl,{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(L,{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(),Zs(a||r.toString()).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(xa,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-2 p-3 ",children:[e.jsxs("p",{className:"font-medium",children:[Fs.find(i=>i.type===t.original.type)?.label,t.original.parent?" (子节点)":""]}),e.jsxs("div",{className:"mt-1 grid gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:n("columns.customId")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-xs font-medium max-w-[120px] truncate",children:a??"—"}),e.jsx(L,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/60 hover:text-muted-foreground",onClick:i=>{i.stopPropagation(),a&&Zs(a).then(()=>{$.success(n("common:copy.success"))})},disabled:!a,children:e.jsx(xa,{className:"size-3"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:n("columns.originalId")}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-xs font-semibold ",children:t.original.id}),e.jsx(L,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/60 hover:text-muted-foreground",onClick:i=>{i.stopPropagation(),Zs(String(t.original.id)).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(xa,{className:"size-3"})})]})]})]})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=m.useState(!!t.getValue("show"));return e.jsx(ee,{checked:r,onCheckedChange:async i=>{a(i),ft.update({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?bs[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(z,{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:_("h-2.5 w-2.5 rounded-full",va[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:_("h-2.5 w-2.5 rounded-full",va[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:_("h-2.5 w-2.5 rounded-full",va[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:_("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",va[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.jsxs("div",{className:" space-y-3",children:[e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)}),t.original.load_status&&e.jsxs("div",{className:"border-t border-border/50 pt-3",children:[e.jsx("p",{className:"mb-3 text-sm font-medium",children:n("columns.loadStatus.details")}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsx("div",{children:e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.cpu"),":"]}),e.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",t.original.load_status.cpu>=90?"bg-destructive":t.original.load_status.cpu>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Math.min(100,t.original.load_status.cpu)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",t.original.load_status.cpu>=90?"text-destructive":t.original.load_status.cpu>=70?"text-yellow-600":"text-emerald-600"),children:[Math.round(t.original.load_status.cpu),"%"]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.memory"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",Be(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"bg-destructive":Be(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Be(t.original.load_status.mem.used,t.original.load_status.mem.total)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",Be(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"text-destructive":Be(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Be(t.original.load_status.mem.used,t.original.load_status.mem.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[Le(t.original.load_status.mem.used)," ","/"," ",Le(t.original.load_status.mem.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.swap"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",Be(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"bg-destructive":Be(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Be(t.original.load_status.swap.used,t.original.load_status.swap.total)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",Be(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"text-destructive":Be(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"text-yellow-600":"text-emerald-600"),children:[Be(t.original.load_status.swap.used,t.original.load_status.swap.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[Le(t.original.load_status.swap.used)," ","/"," ",Le(t.original.load_status.swap.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.disk"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:_("h-full transition-all duration-300",Be(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"bg-destructive":Be(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Be(t.original.load_status.disk.used,t.original.load_status.disk.total)}%`}})}),e.jsxs("span",{className:_("min-w-[3rem] text-right font-semibold",Be(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"text-destructive":Be(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Be(t.original.load_status.disk.used,t.original.load_status.disk.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[Le(t.original.load_status.disk.used)," ","/"," ",Le(t.original.load_status.disk.total)]})]})]})]})]})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(z,{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(pe,{delayDuration:0,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{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(),Zs(r).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(xa,{className:"size-3"})})}),e.jsx(ce,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(z,{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(Oa,{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(z,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(U,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(z,{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(U,{variant:"secondary",className:_("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(z,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(U,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:bs[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:i}=Ni();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Hs,{modal:!1,children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Ea,{className:"size-4"})})}),e.jsxs(qs,{align:"end",className:"w-40",children:[e.jsx(Se,{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(vd,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(Se,{className:"cursor-pointer",onClick:async()=>{ft.copy({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(An,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(nt,{}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(hs,{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()=>{ft.drop({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(xs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Wx(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState({pageSize:500,pageIndex:0}),[x,u]=m.useState([]),[o,c]=m.useState(!1),[p,F]=m.useState({}),[T,C]=m.useState([]),{refetch:P}=re({queryKey:["nodeList"],queryFn:async()=>{const{data:O}=await ft.getList();return C(O),O}}),{data:N}=re({queryKey:["groups"],queryFn:async()=>{const{data:O}=await Nt.getList();return O}});m.useEffect(()=>{r({"drag-handle":o,show:!o,host:!o,online:!o,rate:!o,groups:!o,type:!1,actions:!o}),F({name:o?2e3:200}),d({pageSize:o?99999:500,pageIndex:0})},[o]);const I=(O,E)=>{o&&(O.dataTransfer.setData("text/plain",E.toString()),O.currentTarget.classList.add("opacity-50"))},y=(O,E)=>{if(!o)return;O.preventDefault(),O.currentTarget.classList.remove("bg-muted");const g=parseInt(O.dataTransfer.getData("text/plain"));if(g===E)return;const k=[...T],[W]=k.splice(g,1);k.splice(E,0,W),C(k)},w=async()=>{if(!o){c(!0);return}const O=T?.map((E,g)=>({id:E.id,order:g+1}));ft.sort(O).then(()=>{$.success("排序保存成功"),c(!1),P()}).finally(()=>{c(!1)})},S=Ye({data:T||[],columns:Gx(P),state:{sorting:x,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:p,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:F,onPaginationChange:d,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Cx,{refetch:P,children:e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:S,toolbar:O=>e.jsx(Bx,{table:O,refetch:P,saveOrder:w,isSortMode:o,groups:N||[]}),draggable:o,onDragStart:I,onDragEnd:O=>O.currentTarget.classList.remove("opacity-50"),onDragOver:O=>{O.preventDefault(),O.currentTarget.classList.add("bg-muted")},onDragLeave:O=>O.currentTarget.classList.remove("bg-muted"),onDrop:y,showPagination:!o})})})}function Yx(){const{t:s}=V("server");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Wx,{})})]})]})}const Jx=Object.freeze(Object.defineProperty({__proto__:null,default:Yx},Symbol.toStringTag,{value:"Module"}));function Qx({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(nn,{refetch:n}),e.jsx(D,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:_("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}const Xx=s=>{const{t:n}=V("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Oa,{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(z,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Rl,{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(z,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(nn,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(lt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(hs,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Nt.drop({id:t.original.id}).then(({data:r})=>{r&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 Zx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),{data:x,refetch:u,isLoading:o}=re({queryKey:["serverGroupList"],queryFn:async()=>{const{data:p}=await Nt.getList();return p}}),c=Ye({data:x||[],columns:Xx(u),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:c,toolbar:p=>e.jsx(Qx,{table:p,refetch:u}),isLoading:o})}function eh(){const{t:s}=V("group");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Zx,{})})]})]})}const sh=Object.freeze(Object.defineProperty({__proto__:null,default:eh},Symbol.toStringTag,{value:"Module"})),th=s=>h.object({remarks:h.string().min(1,s("form.validation.remarks")),match:h.array(h.string()),action:h.enum(["block","dns"]),action_value:h.string().optional()});function wi({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="create"}){const{t:a}=V("route"),i=Ce({resolver:Te(th(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1);return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx($e,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ue,{})]}),e.jsxs(De,{...i,children:[e.jsx(j,{control:i.control,name:"remarks",render:({field:x})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:a("form.remarksPlaceholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(j,{control:i.control,name:"match",render:({field:x})=>e.jsxs(f,{className:"flex-[2]",children:[e.jsx(v,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(Es,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:Array.isArray(x.value)?x.value.join(` +`):"",onChange:u=>{const o=u.target.value.split(` +`);x.onChange(o)}})})}),e.jsx(R,{})]})}),e.jsx(j,{control:i.control,name:"action",render:({field:x})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsxs(X,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"block",children:a("actions.block")}),e.jsx(q,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(R,{})]})}),i.watch("action")==="dns"&&e.jsx(j,{control:i.control,name:"action_value",render:({field:x})=>e.jsxs(f,{children:[e.jsx(v,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(b,{children:e.jsx(D,{type:"text",placeholder:a("form.dnsPlaceholder"),...x})})})]})}),e.jsxs(Oe,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(L,{variant:"outline",children:a("form.cancel")})}),e.jsx(L,{type:"submit",onClick:()=>{const x=i.getValues(),u={...x,match:Array.isArray(x.match)?x.match.filter(o=>o.trim()!==""):[]};Ga.save(u).then(({data:o})=>{o&&(d(!1),s&&s(),$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function ah({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(wi,{refetch:n}),e.jsx(D,{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(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}function nh({columns:s,data:n,refetch:t}){const[r,a]=m.useState({}),[i,l]=m.useState({}),[d,x]=m.useState([]),[u,o]=m.useState([]),c=Ye({data:n,columns:s,state:{sorting:u,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:o,onColumnFiltersChange:x,onColumnVisibilityChange:l,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:c,toolbar:p=>e.jsx(ah,{table:p,refetch:t})})}const rh=s=>{const{t:n}=V("route"),t={block:{icon:bd,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:yd,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(z,{column:r,title:n("columns.id")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:r.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:r})=>e.jsx(z,{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(z,{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(z,{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(U,{variant:t[a]?.variant||"default",className:_("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(wi,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(lt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(hs,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ga.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 lh(){const{t:s}=V("route"),[n,t]=m.useState([]);function r(){Ga.getList().then(({data:a})=>{t(a)})}return m.useEffect(()=>{r()},[]),e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(nh,{data:n,columns:rh(r),refetch:r})})]})]})}const ih=Object.freeze(Object.defineProperty({__proto__:null,default:lh},Symbol.toStringTag,{value:"Module"})),Ci=m.createContext(void 0);function oh({children:s,refreshData:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null);return e.jsx(Ci.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function Yn(){const s=m.useContext(Ci);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function ch({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=Yn(),{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(L,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx($e,{icon:"ion:add"}),e.jsx("div",{children:a("plan.add")})]}),e.jsx(D,{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(L,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const Sr={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"}},dh=s=>{const{t:n}=V("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ha,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.show")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{_s.update({id:t.original.id,show:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.sell")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{_s.update({id:t.original.id,sell:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(z,{column:t,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{_s.update({id:t.original.id,renew:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("plan.columns.stats")}),cell:({row:t})=>{const r=t.getValue("users_count")||0,a=t.original.active_users_count||0,i=r>0?Math.round(a/r*100):0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-slate-50 px-2 py-1 hover:bg-slate-100 transition-colors cursor-help",children:[e.jsx(Da,{className:"h-3.5 w-3.5 text-slate-500"}),e.jsx("span",{className:"text-sm font-medium text-slate-700",children:r})]})}),e.jsx(ce,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"总用户数"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"所有使用该套餐的用户(包括已过期)"})]})})]})}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-green-50 px-2 py-1 hover:bg-green-100 transition-colors cursor-help",children:[e.jsx(_d,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:a})]})}),e.jsx(ce,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"有效期内用户"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"当前仍在有效期内的活跃用户"}),r>0&&e.jsxs("p",{className:"text-xs font-medium text-green-600",children:["活跃率:",i,"%"]})]})})]})})]})},enableSorting:!0,size:120},{accessorKey:"group",header:({column:t})=>e.jsx(z,{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(U,{variant:"secondary",className:_("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(z,{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 r?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(U,{variant:"secondary",className:_("px-2 py-0.5 font-medium transition-colors text-nowrap",Sr[l].color,Sr[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))}):e.jsx("div",{className:"flex items-center",children:e.jsx(U,{variant:"outline",className:"px-2 py-0.5 text-xs text-muted-foreground border-dashed",children:n("plan.columns.price_period.no_price")})})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=Yn();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(lt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(hs,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{_s.drop({id:t.original.id}).then(({data:i})=>{i&&($.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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")})]})})]})}}]},mh=h.object({id:h.number().nullable(),group_id:h.union([h.number(),h.string()]).nullable().optional(),name:h.string().min(1).max(250),tags:h.array(h.string()).nullable().optional(),content:h.string().nullable().optional(),transfer_enable:h.union([h.number().min(0),h.string().min(1)]),prices:h.object({monthly:h.union([h.number(),h.string()]).nullable().optional(),quarterly:h.union([h.number(),h.string()]).nullable().optional(),half_yearly:h.union([h.number(),h.string()]).nullable().optional(),yearly:h.union([h.number(),h.string()]).nullable().optional(),two_yearly:h.union([h.number(),h.string()]).nullable().optional(),three_yearly:h.union([h.number(),h.string()]).nullable().optional(),onetime:h.union([h.number(),h.string()]).nullable().optional(),reset_traffic:h.union([h.number(),h.string()]).nullable().optional()}).default({}),speed_limit:h.union([h.number(),h.string()]).nullable().optional(),capacity_limit:h.union([h.number(),h.string()]).nullable().optional(),device_limit:h.union([h.number(),h.string()]).nullable().optional(),force_update:h.boolean().optional(),reset_traffic_method:h.number().nullable(),users_count:h.number().optional(),active_users_count:h.number().optional()}),Jn=m.forwardRef(({className:s,...n},t)=>e.jsx(El,{ref:t,className:_("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(Nd,{className:_("flex items-center justify-center text-current"),children:e.jsx(yt,{className:"h-4 w-4"})})}));Jn.displayName=El.displayName;const ba={id:null,group_id:null,name:"",tags:[],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},ya={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}},uh=[{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 xh(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=Yn(),[i,l]=m.useState(!1),{t:d}=V("subscribe"),x=Ce({resolver:Te(mh),defaultValues:{...ba,...t||{}},mode:"onChange"});m.useEffect(()=>{t?x.reset({...ba,...t}):x.reset(ba)},[t,x]);const u=new zn({html:!0}),[o,c]=m.useState();async function p(){Nt.getList().then(({data:N})=>{c(N)})}m.useEffect(()=>{s&&p()},[s]);const F=async N=>{l(!0),_s.save(N).then(({data:I})=>{I&&($.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),P(),a())}).finally(()=>{l(!1)})},T=N=>{const I=Object.values(N).map(y=>y?.message).filter(Boolean);$.error(I.join(` +`)||d("plan.form.submit.error.validation","表单校验失败"))},C=N=>{if(isNaN(N))return;const I=Object.entries(ya).reduce((y,[w,S])=>{const O=N*S.months*S.discount;return{...y,[w]:O.toFixed(2)}},{});x.setValue("prices",I,{shouldDirty:!0})},P=()=>{n(!1),r(null),x.reset(ba)};return e.jsx(de,{open:s,onOpenChange:P,children:e.jsxs(oe,{children:[e.jsxs(he,{children:[e.jsx(me,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ue,{})]}),e.jsx(De,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(F,T),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"name",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:d("plan.form.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:d("plan.form.name.placeholder"),...N})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"tags",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:d("plan.form.tags.label","标签")}),e.jsx(b,{children:e.jsx(an,{value:N.value||[],onChange:N.onChange,placeholder:d("plan.form.tags.placeholder","输入标签后按回车确认"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"group_id",render:({field:N})=>e.jsxs(f,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(nn,{dialogTrigger:e.jsx(L,{variant:"link",children:d("plan.form.group.add")}),refetch:p})]}),e.jsxs(X,{value:N.value?.toString()??"",onValueChange:I=>N.onChange(I?Number(I):null),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(Q,{children:o?.map(I=>e.jsx(q,{value:I.id.toString(),children:I.name},I.id))})]}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"transfer_enable",render:({field:N})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...N})}),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(R,{})]})}),e.jsx(j,{control:x.control,name:"speed_limit",render:({field:N})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...N,value:N.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(R,{})]})}),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(D,{type:"number",step:"0.01",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:N=>{const I=parseFloat(N.target.value);C(I)}})]}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const N=Object.keys(ya).reduce((I,y)=>({...I,[y]:""}),{});x.setValue("prices",N,{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(ya).filter(([N])=>!["onetime","reset_traffic"].includes(N)).map(([N,I])=>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(j,{control:x.control,name:`prices.${N}`,render:({field:y})=>e.jsxs(f,{children:[e.jsxs(v,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${N}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",I.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:I.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,step:"0.01",...y,value:y.value??"",onChange:w=>y.onChange(w.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"})})]})]})})},N))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(ya).filter(([N])=>["onetime","reset_traffic"].includes(N)).map(([N,I])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(j,{control:x.control,name:`prices.${N}`,render:({field:y})=>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(v,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${N}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(N==="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(b,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,step:"0.01",...y,value:y.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"})})]})]})})})},N))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(j,{control:x.control,name:"device_limit",render:({field:N})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...N,value:N.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(R,{})]})}),e.jsx(j,{control:x.control,name:"capacity_limit",render:({field:N})=>e.jsxs(f,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(b,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...N,value:N.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(R,{})]})})]}),e.jsx(j,{control:x.control,name:"reset_traffic_method",render:({field:N})=>e.jsxs(f,{children:[e.jsx(v,{children:d("plan.form.reset_method.label")}),e.jsxs(X,{value:N.value?.toString()??"null",onValueChange:I=>N.onChange(I=="null"?null:Number(I)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(Q,{children:uh.map(I=>e.jsx(q,{value:I.value?.toString()??"null",children:d(`plan.form.reset_method.options.${I.label}`)},I.value))})]}),e.jsx(A,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"content",render:({field:N})=>{const[I,y]=m.useState(!1);return e.jsxs(f,{className:"space-y-2",children:[e.jsxs(v,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d("plan.form.content.label"),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",type:"button",onClick:()=>y(!I),children:I?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(I?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(pe,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",type:"button",onClick:()=>{N.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 ${I?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(b,{children:e.jsx($n,{style:{height:"400px"},value:N.value||"",renderHTML:w=>u.render(w),onChange:({text:w})=>N.onChange(w),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"})})}),I&&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:u.render(N.value||"")}})})]})]}),e.jsx(A,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(R,{})]})}})]}),e.jsx(Oe,{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(j,{control:x.control,name:"force_update",render:({field:N})=>e.jsxs(f,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(b,{children:e.jsx(Jn,{checked:N.value,onCheckedChange:N.onChange})}),e.jsx("div",{className:"",children:e.jsx(v,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:P,children:d("plan.form.submit.cancel")}),e.jsx(L,{type:"submit",disabled:i,children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})})]})})}function hh(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState(!1),[o,c]=m.useState({pageSize:20,pageIndex:0}),[p,F]=m.useState([]),{refetch:T}=re({queryKey:["planList"],queryFn:async()=>{const{data:y}=await _s.getList();return F(y),y}});m.useEffect(()=>{r({"drag-handle":x}),c({pageSize:x?99999:10,pageIndex:0})},[x]);const C=(y,w)=>{x&&(y.dataTransfer.setData("text/plain",w.toString()),y.currentTarget.classList.add("opacity-50"))},P=(y,w)=>{if(!x)return;y.preventDefault(),y.currentTarget.classList.remove("bg-muted");const S=parseInt(y.dataTransfer.getData("text/plain"));if(S===w)return;const O=[...p],[E]=O.splice(S,1);O.splice(w,0,E),F(O)},N=async()=>{if(!x){u(!0);return}const y=p?.map(w=>w.id);_s.sort(y).then(()=>{$.success("排序保存成功"),u(!1),T()}).finally(()=>{u(!1)})},I=Ye({data:p||[],columns:dh(T),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:o},enableRowSelection:!0,onPaginationChange:c,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}},pageCount:x?1:void 0});return e.jsx(oh,{refreshData:T,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(rs,{table:I,toolbar:y=>e.jsx(ch,{table:y,refetch:T,saveOrder:N,isSortMode:x}),draggable:x,onDragStart:C,onDragEnd:y=>y.currentTarget.classList.remove("opacity-50"),onDragOver:y=>{y.preventDefault(),y.currentTarget.classList.add("bg-muted")},onDragLeave:y=>y.currentTarget.classList.remove("bg-muted"),onDrop:P,showPagination:!x}),e.jsx(xh,{})]})})}function gh(){const{t:s}=V("subscribe");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(hh,{})})]})]})}const ph=Object.freeze(Object.defineProperty({__proto__:null,default:gh},Symbol.toStringTag,{value:"Module"})),Ft=[{value:ie.PENDING,label:qt[ie.PENDING],icon:wd,color:Ut[ie.PENDING]},{value:ie.PROCESSING,label:qt[ie.PROCESSING],icon:Il,color:Ut[ie.PROCESSING]},{value:ie.COMPLETED,label:qt[ie.COMPLETED],icon:Tn,color:Ut[ie.COMPLETED]},{value:ie.CANCELLED,label:qt[ie.CANCELLED],icon:Vl,color:Ut[ie.CANCELLED]},{value:ie.DISCOUNTED,label:qt[ie.DISCOUNTED],icon:Tn,color:Ut[ie.DISCOUNTED]}],Gt=[{value:fe.PENDING,label:pa[fe.PENDING],icon:Cd,color:fa[fe.PENDING]},{value:fe.PROCESSING,label:pa[fe.PROCESSING],icon:Il,color:fa[fe.PROCESSING]},{value:fe.VALID,label:pa[fe.VALID],icon:Tn,color:fa[fe.VALID]},{value:fe.INVALID,label:pa[fe.INVALID],icon:Vl,color:fa[fe.INVALID]}];function _a({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(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ka,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[i.size," selected"]}):t.filter(l=>i.has(l.value)).map(l=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:l.label},l.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(ot,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ct,{children:"No results found."}),e.jsx(gs,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(qe,{onSelect:()=>{const x=new Set(i);d?x.delete(l.value):x.add(l.value);const u=Array.from(x);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:_("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(yt,{className:_("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(Ot,{}),e.jsx(gs,{children:e.jsx(qe,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const fh=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),jh={email:"",plan_id:0,total_amount:0,period:""};function Si({refetch:s,trigger:n,defaultValues:t}){const{t:r}=V("order"),[a,i]=m.useState(!1),l=Ce({resolver:Te(fh),defaultValues:{...jh,...t},mode:"onChange"}),[d,x]=m.useState([]);return m.useEffect(()=>{a&&_s.getList().then(({data:u})=>{x(u)})},[a]),e.jsxs(de,{open:a,onOpenChange:i,children:[e.jsx(cs,{asChild:!0,children:n||e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx($e,{icon:"ion:add"}),e.jsx("div",{children:r("dialog.addOrder")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("dialog.assignOrder")}),e.jsx(Ue,{})]}),e.jsxs(De,{...l,children:[e.jsx(j,{control:l.control,name:"email",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.userEmail")}),e.jsx(b,{children:e.jsx(D,{placeholder:r("dialog.placeholders.email"),...u})})]})}),e.jsx(j,{control:l.control,name:"plan_id",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(b,{children:e.jsxs(X,{value:u.value?u.value?.toString():void 0,onValueChange:o=>u.onChange(parseInt(o)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(Q,{children:d.map(o=>e.jsx(q,{value:o.id.toString(),children:o.name},o.id))})]})})]})}),e.jsx(j,{control:l.control,name:"period",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.orderPeriod")}),e.jsx(b,{children:e.jsxs(X,{value:u.value,onValueChange:u.onChange,children:[e.jsx(J,{children:e.jsx(Z,{placeholder:r("dialog.placeholders.period")})}),e.jsx(Q,{children:Object.keys(qm).map(o=>e.jsx(q,{value:o,children:r(`period.${o}`)},o))})]})})]})}),e.jsx(j,{control:l.control,name:"total_amount",render:({field:u})=>e.jsxs(f,{children:[e.jsx(v,{children:r("dialog.fields.paymentAmount")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:r("dialog.placeholders.amount"),value:u.value/100,onChange:o=>u.onChange(parseFloat(o.currentTarget.value)*100)})}),e.jsx(R,{})]})}),e.jsxs(Oe,{children:[e.jsx(L,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(L,{type:"submit",onClick:()=>{l.handleSubmit(u=>{pt.assign(u).then(({data:o})=>{o&&(s&&s(),l.reset(),i(!1),$.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function vh({table:s,refetch:n}){const{t}=V("order"),r=s.getState().columnFilters.length>0,a=Object.values($s).filter(x=>typeof x=="number").map(x=>({label:t(`type.${$s[x]}`),value:x,color:x===$s.NEW?"green-500":x===$s.RENEWAL?"blue-500":x===$s.UPGRADE?"purple-500":"orange-500"})),i=Object.values(Ze).map(x=>({label:t(`period.${x}`),value:x,color:x===Ze.MONTH_PRICE?"slate-500":x===Ze.QUARTER_PRICE?"cyan-500":x===Ze.HALF_YEAR_PRICE?"indigo-500":x===Ze.YEAR_PRICE?"violet-500":x===Ze.TWO_YEAR_PRICE?"fuchsia-500":x===Ze.THREE_YEAR_PRICE?"pink-500":x===Ze.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(ie).filter(x=>typeof x=="number").map(x=>({label:t(`status.${ie[x]}`),value:x,icon:x===ie.PENDING?Ft[0].icon:x===ie.PROCESSING?Ft[1].icon:x===ie.COMPLETED?Ft[2].icon:x===ie.CANCELLED?Ft[3].icon:Ft[4].icon,color:x===ie.PENDING?"yellow-500":x===ie.PROCESSING?"blue-500":x===ie.COMPLETED?"green-500":x===ie.CANCELLED?"red-500":"green-500"})),d=Object.values(fe).filter(x=>typeof x=="number").map(x=>({label:t(`commission.${fe[x]}`),value:x,icon:x===fe.PENDING?Gt[0].icon:x===fe.PROCESSING?Gt[1].icon:x===fe.VALID?Gt[2].icon:Gt[3].icon,color:x===fe.PENDING?"yellow-500":x===fe.PROCESSING?"blue-500":x===fe.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Si,{refetch:n}),e.jsx(D,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:x=>s.getColumn("trade_no")?.setFilterValue(x.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(_a,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(_a,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(_a,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(_a,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}function is({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:_("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:_("text-sm",r),children:n||"-"})]})}function bh({status:s}){const{t:n}=V("order"),t={[ie.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[ie.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[ie.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[ie.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[ie.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(U,{variant:"secondary",className:_("font-medium",t[s]),children:n(`status.${ie[s]}`)})}function yh({id:s,trigger:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(),{t:l}=V("order");return m.useEffect(()=>{(async()=>{if(t){const{data:x}=await pt.getInfo({id:s});i(x)}})()},[t,s]),e.jsxs(de,{onOpenChange:r,open:t,children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"max-w-xl",children:[e.jsxs(he,{className:"space-y-2",children:[e.jsx(me,{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(bh,{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(is,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Bs,{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(aa,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(is,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(is,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(is,{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(is,{label:l("dialog.fields.paymentAmount"),value:Ks(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Re,{className:"my-2"}),e.jsx(is,{label:l("dialog.fields.balancePayment"),value:Ks(a?.balance_amount||0)}),e.jsx(is,{label:l("dialog.fields.discountAmount"),value:Ks(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(is,{label:l("dialog.fields.refundAmount"),value:Ks(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(is,{label:l("dialog.fields.deductionAmount"),value:Ks(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(is,{label:l("dialog.fields.createdAt"),value:ne(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(is,{label:l("dialog.fields.updatedAt"),value:ne(a?.updated_at),valueClassName:"font-mono text-xs"})]})]}),a?.commission_status!==void 0&&a?.commission_balance&&e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.commissionInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(is,{label:l("dialog.fields.commissionStatus"),value:e.jsx(U,{variant:"secondary",className:_("font-medium",a?.commission_status===fe.PENDING?"bg-yellow-100 text-yellow-800 hover:bg-yellow-100":a?.commission_status===fe.PROCESSING?"bg-blue-100 text-blue-800 hover:bg-blue-100":a?.commission_status===fe.VALID?"bg-green-100 text-green-800 hover:bg-green-100":a?.commission_status===fe.INVALID?"bg-red-100 text-red-800 hover:bg-red-100":"bg-orange-100 text-orange-800 hover:bg-orange-100"),children:a?.commission_status!==void 0?l(`commission.${fe[a.commission_status]}`):l("dialog.commissionStatusActive")})}),e.jsx(is,{label:l("dialog.fields.commissionAmount"),value:Ks(a?.commission_balance||0),valueClassName:"font-medium text-orange-600"}),a?.actual_commission_balance&&e.jsx(is,{label:l("dialog.fields.actualCommissionAmount"),value:Ks(a?.actual_commission_balance||0),valueClassName:"font-medium text-orange-700"}),a?.invite_user&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"my-2"}),e.jsx(is,{label:l("dialog.fields.inviteUser"),value:e.jsxs(Bs,{to:`/user/manage?email=${a.invite_user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.invite_user.email,e.jsx(aa,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})}),e.jsx(is,{label:l("dialog.fields.inviteUserId"),value:a?.invite_user?.id,valueClassName:"font-mono text-xs"})]})]})]})]})]})]})}const _h={[$s.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[$s.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[$s.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[$s.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Nh={[Ze.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},wh=s=>ie[s],Ch=s=>fe[s],Sh=s=>$s[s],kh=s=>{const{t:n}=V("order");return[{accessorKey:"trade_no",header:({column:t})=>e.jsx(z,{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(yh,{trigger:e.jsxs(G,{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(aa,{className:"h-3.5 w-3.5 opacity-70"})]}),id:t.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.type")}),cell:({row:t})=>{const r=t.getValue("type"),a=_h[r];return e.jsx(U,{variant:"secondary",className:_("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(z,{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(z,{column:t,title:n("table.columns.period")}),cell:({row:t})=>{const r=t.getValue("period"),a=Nh[r];return e.jsx(U,{variant:"secondary",className:_("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(z,{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(z,{column:t,title:n("table.columns.status")}),e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(ji,{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=Ft.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.${wh(r.value)}`)})]}),r.value===ie.PENDING&&e.jsxs(Hs,{modal:!0,children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Ea,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(qs,{align:"end",className:"w-[140px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await pt.markPaid({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await pt.makeCancel({trade_no:t.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("table.columns.commissionStatus")}),cell:({row:t})=>{const r=t.original.status,a=t.original.commission_balance,i=Gt.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.${Ch(i.value)}`)})]}),i.value===fe.PENDING&&r===ie.COMPLETED&&e.jsxs(Hs,{modal:!0,children:[e.jsx(Gs,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Ea,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(qs,{align:"end",className:"w-[120px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await pt.update({trade_no:t.original.trade_no,commission_status:fe.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await pt.update({trade_no:t.original.trade_no,commission_status:fe.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.createdAt")}),cell:({row:t})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:ne(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function Th(){const[s]=Ml(),[n,t]=m.useState({}),[r,a]=m.useState({}),[i,l]=m.useState([]),[d,x]=m.useState([]),[u,o]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const P=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([N,I])=>{const y=s.get(N);return y?{id:N,value:I==="number"?parseInt(y):y}:null}).filter(Boolean);P.length>0&&l(P)},[s]);const{refetch:c,data:p,isLoading:F}=re({queryKey:["orderList",u,i,d],queryFn:()=>pt.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:i,sort:d})}),T=Ye({data:p?.data??[],columns:kh(c),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:u},rowCount:p?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:x,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:o,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(rs,{table:T,toolbar:e.jsx(vh,{table:T,refetch:c}),showPagination:!0})}function Dh(){const{t:s}=V("order");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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 Fh=Object.freeze(Object.defineProperty({__proto__:null,default:Dh},Symbol.toStringTag,{value:"Module"}));function Ph({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ka,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(ot,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ct,{children:"No results found."}),e.jsx(gs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(qe,{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:_("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(yt,{className:_("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(Ot,{}),e.jsx(gs,{children:e.jsx(qe,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Lh=s=>h.object({id:h.coerce.number().nullable().optional(),name:h.string().min(1,s("form.name.required")),code:h.string().nullable(),type:h.coerce.number(),value:h.coerce.number(),started_at:h.coerce.number(),ended_at:h.coerce.number(),limit_use:h.union([h.string(),h.number()]).nullable(),limit_use_with_user:h.union([h.string(),h.number()]).nullable(),generate_count:h.coerce.number().nullable().optional(),limit_plan_ids:h.array(h.coerce.number()).default([]).nullable(),limit_period:h.array(h.nativeEnum(Zt)).default([]).nullable()}).refine(n=>n.ended_at>n.started_at,{message:s("form.validity.endTimeError"),path:["ended_at"]}),kr={name:"",code:null,type:Cs.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},Rh=s=>[{label:s("form.timeRange.presets.1week"),days:7},{label:s("form.timeRange.presets.2weeks"),days:14},{label:s("form.timeRange.presets.1month"),days:30},{label:s("form.timeRange.presets.3months"),days:90},{label:s("form.timeRange.presets.6months"),days:180},{label:s("form.timeRange.presets.1year"),days:365}];function ki({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=V("coupon"),[d,x]=m.useState(!1),u=a??d,o=i??x,[c,p]=m.useState([]),F=Lh(l),T=Rh(l),C=Ce({resolver:Te(F),defaultValues:s||kr});m.useEffect(()=>{s&&C.reset(s)},[s,C]),m.useEffect(()=>{_s.getList().then(({data:w})=>p(w))},[]);const P=w=>{if(!w)return;const S=(O,E)=>{const g=new Date(E*1e3);return O.setHours(g.getHours(),g.getMinutes(),g.getSeconds()),Math.floor(O.getTime()/1e3)};w.from&&C.setValue("started_at",S(w.from,C.watch("started_at"))),w.to&&C.setValue("ended_at",S(w.to,C.watch("ended_at")))},N=w=>{const S=new Date,O=Math.floor(S.getTime()/1e3),E=Math.floor((S.getTime()+w*24*60*60*1e3)/1e3);C.setValue("started_at",O),C.setValue("ended_at",E)},I=async w=>{const S=await Va.save(w);if(w.generate_count&&typeof S=="string"){const O=new Blob([S],{type:"text/csv;charset=utf-8;"}),E=document.createElement("a");E.href=window.URL.createObjectURL(O),E.download=`coupons_${new Date().getTime()}.csv`,E.click(),window.URL.revokeObjectURL(E.href)}o(!1),t==="create"&&C.reset(kr),n()},y=(w,S)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:S}),e.jsx(D,{type:"datetime-local",step:"1",value:ne(C.watch(w),"YYYY-MM-DDTHH:mm:ss"),onChange:O=>{const E=new Date(O.target.value);C.setValue(w,Math.floor(E.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(de,{open:u,onOpenChange:o,children:[r&&e.jsx(cs,{asChild:!0,children:r}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(De,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(I),className:"space-y-4",children:[e.jsx(j,{control:C.control,name:"name",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.name.label")}),e.jsx(D,{placeholder:l("form.name.placeholder"),...w}),e.jsx(R,{})]})}),t==="create"&&e.jsx(j,{control:C.control,name:"generate_count",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...w,value:w.value??"",onChange:S=>w.onChange(S.target.value===""?null:parseInt(S.target.value)),className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(R,{})]})}),(!C.watch("generate_count")||C.watch("generate_count")==null)&&e.jsx(j,{control:C.control,name:"code",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.code.label")}),e.jsx(D,{placeholder:l("form.code.placeholder"),...w,value:w.value??"",className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.code.description")}),e.jsx(R,{})]})}),e.jsxs(f,{children:[e.jsx(v,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(j,{control:C.control,name:"type",render:({field:w})=>e.jsxs(X,{value:w.value.toString(),onValueChange:S=>{const O=w.value,E=parseInt(S);w.onChange(E);const g=C.getValues("value");g&&(O===Cs.AMOUNT&&E===Cs.PERCENTAGE?C.setValue("value",g/100):O===Cs.PERCENTAGE&&E===Cs.AMOUNT&&C.setValue("value",g*100))},children:[e.jsx(J,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Z,{placeholder:l("form.type.placeholder")})}),e.jsx(Q,{children:Object.entries(Um).map(([S,O])=>e.jsx(q,{value:S,children:l(`table.toolbar.types.${S}`)},S))})]})}),e.jsx(j,{control:C.control,name:"value",render:({field:w})=>{const S=w.value==null?"":C.watch("type")===Cs.AMOUNT&&typeof w.value=="number"?(w.value/100).toString():w.value.toString();return e.jsx(D,{type:"number",placeholder:l("form.value.placeholder"),...w,value:S,onChange:O=>{const E=O.target.value;if(E===""){w.onChange("");return}const g=parseFloat(E);isNaN(g)||w.onChange(C.watch("type")===Cs.AMOUNT?Math.round(g*100):g)},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:C.watch("type")==Cs.AMOUNT?"¥":"%"})})]})]}),e.jsxs(f,{children:[e.jsx(v,{children:l("form.validity.label")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:_("w-full justify-start text-left font-normal",!C.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"truncate",children:[ne(C.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",ne(C.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})]})}),e.jsxs(We,{className:"w-auto p-0",align:"start",children:[e.jsxs("div",{className:"border-b border-border p-3",children:[e.jsx("div",{className:"mb-2 text-sm font-medium text-muted-foreground",children:l("form.timeRange.quickSet")}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-6",children:T.map(w=>e.jsx(L,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>N(w.days),type:"button",children:w.label},w.days))})]}),e.jsx("div",{className:"hidden border-b border-border sm:block",children:e.jsx(ks,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:P,numberOfMonths:2})}),e.jsx("div",{className:"border-b border-border sm:hidden",children:e.jsx(ks,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:P,numberOfMonths:1})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center",children:[y("started_at",l("table.validity.startTime")),e.jsx("div",{className:"text-center text-sm text-muted-foreground sm:mt-6",children:l("form.validity.to")}),y("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(R,{})]}),e.jsx(j,{control:C.control,name:"limit_use",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...w,value:w.value??"",onChange:S=>w.onChange(S.target.value===""?null:parseInt(S.target.value)),className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:C.control,name:"limit_use_with_user",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...w,value:w.value??"",onChange:S=>w.onChange(S.target.value===""?null:parseInt(S.target.value)),className:"h-9"}),e.jsx(A,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:C.control,name:"limit_period",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitPeriod.label")}),e.jsx(rt,{options:Object.entries(Zt).filter(([S])=>isNaN(Number(S))).map(([S,O])=>({label:l(`coupon:period.${O}`),value:S})),onChange:S=>{if(S.length===0){w.onChange([]);return}const O=S.map(E=>Zt[E.value]);w.onChange(O)},value:(w.value||[]).map(S=>({label:l(`coupon:period.${S}`),value:Object.entries(Zt).find(([O,E])=>E===S)?.[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(A,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(R,{})]})}),e.jsx(j,{control:C.control,name:"limit_plan_ids",render:({field:w})=>e.jsxs(f,{children:[e.jsx(v,{children:l("form.limitPlan.label")}),e.jsx(rt,{options:c?.map(S=>({label:S.name,value:S.id.toString()}))||[],onChange:S=>w.onChange(S.map(O=>Number(O.value))),value:(c||[]).filter(S=>(w.value||[]).includes(S.id)).map(S=>({label:S.name,value:S.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(R,{})]})}),e.jsx(Oe,{children:e.jsx(L,{type:"submit",disabled:C.formState.isSubmitting,children:C.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function Eh({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(ki,{refetch:n,dialogTrigger:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx($e,{icon:"ion:add"}),e.jsx("div",{children:r("form.add")})]})}),e.jsx(D,{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(Ph,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:Cs.AMOUNT,label:r(`table.toolbar.types.${Cs.AMOUNT}`)},{value:Cs.PERCENTAGE,label:r(`table.toolbar.types.${Cs.PERCENTAGE}`)}]}),t&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}const Ti=m.createContext(void 0);function Ih({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=x=>{i(x),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(Ti.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(ki,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function Vh(){const s=m.useContext(Ti);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Mh=s=>{const{t:n}=V("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx(ee,{defaultChecked:t.original.show,onCheckedChange:r=>{Va.update({id:t.original.id,show:r}).then(({data:a})=>!a&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(z,{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(z,{column:t,title:n("table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`table.toolbar.types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.code")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:t})=>e.jsx(z,{column:t,title:n("table.columns.limitUse")}),cell:({row:t})=>e.jsx(U,{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(z,{column:t,title:n("table.columns.limitUseWithUser")}),cell:({row:t})=>e.jsx(U,{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(z,{column:t,title:n("table.columns.validity")}),cell:({row:t})=>{const[r,a]=m.useState(!1),i=Date.now(),l=t.original.started_at*1e3,d=t.original.ended_at*1e3,x=i>d,u=ie.jsx(z,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=Vh();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(lt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(hs,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{Va.drop({id:t.original.id}).then(({data:a})=>{a&&($.success("删除成功"),s())})},children:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(xs,{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 Oh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=re({queryKey:["couponList",x,a,l],queryFn:()=>Va.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:a,sort:l})}),p=Ye({data:c?.data??[],columns:Mh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},pageCount:Math.ceil((c?.total??0)/x.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ih,{refetch:o,children:e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:p,toolbar:e.jsx(Eh,{table:p,refetch:o})})})})}function zh(){const{t:s}=V("coupon");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Oh,{})})]})]})}const $h=Object.freeze(Object.defineProperty({__proto__:null,default:zh},Symbol.toStringTag,{value:"Module"})),Ah=h.object({name:h.string().min(1,"请输入模板名称"),description:h.string().optional(),type:h.number().min(1).max(4),status:h.boolean(),sort:h.number().min(0),icon:h.string().optional(),background_image:h.string().optional(),conditions:h.object({allowed_plans:h.array(h.number()).optional(),disallowed_plans:h.array(h.number()).optional(),new_user_only:h.boolean().optional(),new_user_max_days:h.number().optional(),paid_user_only:h.boolean().optional(),require_invite:h.boolean().optional()}).optional(),limits:h.object({max_use_per_user:h.number().optional(),cooldown_hours:h.number().optional(),invite_reward_rate:h.number().optional()}).optional(),rewards:h.object({balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional(),reset_package:h.boolean().optional(),plan_id:h.number().optional(),plan_validity_days:h.number().optional(),random_rewards:h.array(h.object({weight:h.number(),balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional()})).optional()}),special_config:h.object({start_time:h.number().optional(),end_time:h.number().optional(),festival_bonus:h.number().optional()}).optional()});function Di({template:s,refetch:n,open:t,onOpenChange:r}){const{t:a}=V("giftCard"),[i,l]=m.useState(!1),[d,x]=m.useState([]),[u,o]=m.useState([]),c=Ce({resolver:Te(Ah),defaultValues:{name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{},special_config:{}}}),{fields:p,append:F,remove:T}=Sd({control:c.control,name:"rewards.random_rewards"});m.useEffect(()=>{t&&(async()=>{try{const S=(await _s.getList()).data||[];x(S),o(S.map(O=>({label:O.name,value:O.id.toString()})))}catch(w){console.error("Failed to fetch plans:",w),$.error("Failed to load plan list")}})()},[t]),m.useEffect(()=>{if(s){const y=s.rewards||{};c.reset({name:s.name,description:s.description||"",type:s.type,status:s.status,sort:s.sort,icon:s.icon||"",background_image:s.background_image||"",conditions:s.conditions&&!Array.isArray(s.conditions)?s.conditions:{},limits:s.limits&&!Array.isArray(s.limits)?{...s.limits,invite_reward_rate:s.limits.invite_reward_rate||void 0}:{},rewards:{balance:y.balance?y.balance/100:void 0,transfer_enable:typeof y.transfer_enable=="number"?y.transfer_enable/1024/1024/1024:void 0,expire_days:y.expire_days,device_limit:y.device_limit,reset_package:y.reset_package,plan_id:y.plan_id,plan_validity_days:y.plan_validity_days,random_rewards:y.random_rewards?.map(w=>({weight:w.weight,balance:w.balance?w.balance/100:void 0,transfer_enable:typeof w.transfer_enable=="number"?w.transfer_enable/1024/1024/1024:void 0,expire_days:w.expire_days,device_limit:w.device_limit}))||[]},special_config:s.special_config&&!Array.isArray(s.special_config)?s.special_config:{}})}else c.reset({name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{random_rewards:[]},special_config:{}})},[s,c]);const C=y=>{console.error("Form validation failed:",y),$.error(a("messages.formInvalid"))},P=async y=>{l(!0);const w=JSON.parse(JSON.stringify(y));w.rewards&&(typeof w.rewards.balance=="number"&&(w.rewards.balance=Math.round(w.rewards.balance*100)),typeof w.rewards.transfer_enable=="number"&&(w.rewards.transfer_enable=Math.round(w.rewards.transfer_enable*1024*1024*1024)),w.rewards.random_rewards&&w.rewards.random_rewards.forEach(O=>{typeof O.balance=="number"&&(O.balance=Math.round(O.balance*100)),typeof O.transfer_enable=="number"&&(O.transfer_enable=Math.round(O.transfer_enable*1024*1024*1024))}));const S={...w,conditions:w.conditions||{},limits:w.limits||{},rewards:w.rewards||{},special_config:w.special_config||{}};try{s?(await Ps.updateTemplate({id:s.id,...S}),$.success(a("messages.templateUpdated"))):(await Ps.createTemplate(S),$.success(a("messages.templateCreated"))),n(),r(!1)}catch(O){const E=O?.response?.data?.errors;E&&Object.keys(E).forEach(g=>{c.setError(g,{type:"manual",message:E[g][0]})}),$.error(a(s?"messages.updateTemplateFailed":"messages.createTemplateFailed"))}finally{l(!1)}},N=c.watch("type"),I=N===1;return e.jsx(de,{open:t,onOpenChange:r,children:e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:a(s?"template.form.edit":"template.form.add")})}),e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(P,C),className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"name",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.name.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("template.form.name.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"type",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.type.label")}),e.jsxs(X,{value:y.value.toString(),onValueChange:w=>y.onChange(parseInt(w)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:a("template.form.type.placeholder")})})}),e.jsx(Q,{children:[1,2,3].map(w=>e.jsx(q,{value:w.toString(),children:a(`types.${w}`)},w))})]}),e.jsx(R,{})]})})]}),e.jsx(j,{control:c.control,name:"description",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.description.label")}),e.jsx(b,{children:e.jsx(Es,{placeholder:a("template.form.description.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:e.jsx(j,{control:c.control,name:"status",render:({field:y})=>e.jsxs(f,{className:"col-span-3 flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:a("template.form.status.label")}),e.jsx(A,{children:a("template.form.status.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})})}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.rewards.title")})}),e.jsxs(Pe,{className:"space-y-4",children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"rewards.balance",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.balance.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.balance.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"rewards.transfer_enable",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.transfer_enable.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.placeholder"),value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"rewards.expire_days",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.expire_days.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.expire_days.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"rewards.device_limit",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.device_limit.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.device_limit.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})]}),e.jsx(j,{control:c.control,name:"rewards.reset_package",render:({field:y})=>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(v,{children:a("template.form.rewards.reset_package.label")}),e.jsx(A,{children:a("template.form.rewards.reset_package.description")})]}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})})]}),N===4&&e.jsx("p",{children:a("template.form.rewards.task_card.description")}),N===2&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"rewards.plan_id",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.plan_id.label")}),e.jsxs(X,{value:y.value?.toString(),onValueChange:w=>y.onChange(parseInt(w,10)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:a("template.form.rewards.plan_id.placeholder")})})}),e.jsx(Q,{children:d.map(w=>e.jsx(q,{value:w.id.toString(),children:w.name},w.id))})]}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"rewards.plan_validity_days",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.rewards.plan_validity_days.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.plan_validity_days.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})]}),N===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{children:a("template.form.rewards.random_rewards.label")}),p.map((y,w)=>e.jsxs("div",{className:"flex items-center space-x-2 rounded-md border p-2",children:[e.jsx(j,{control:c.control,name:`rewards.random_rewards.${w}.weight`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.random_rewards.weight"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${w}.balance`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.balance.label"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${w}.transfer_enable`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.label")+" (GB)",value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${w}.expire_days`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.expire_days.label"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(j,{control:c.control,name:`rewards.random_rewards.${w}.device_limit`,render:({field:S})=>e.jsx(f,{children:e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.device_limit.label"),...S,value:S.value??"",onChange:O=>{const E=O.target.valueAsNumber;S.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(L,{type:"button",variant:"ghost",size:"icon",onClick:()=>T(w),children:e.jsx(kd,{className:"h-4 w-4"})})]},y.id)),e.jsx(L,{type:"button",variant:"outline",onClick:()=>F({weight:10,balance:void 0,transfer_enable:void 0,expire_days:void 0,device_limit:void 0}),children:a("template.form.rewards.random_rewards.add")})]})]})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.conditions.title")})}),e.jsxs(Pe,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsx(j,{control:c.control,name:"conditions.new_user_max_days",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.conditions.new_user_max_days.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.conditions.new_user_max_days.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(j,{control:c.control,name:"conditions.new_user_only",render:({field:y})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{children:a("template.form.conditions.new_user_only.label")})}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})}),e.jsx(j,{control:c.control,name:"conditions.paid_user_only",render:({field:y})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{children:a("template.form.conditions.paid_user_only.label")})}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})}),e.jsx(j,{control:c.control,name:"conditions.require_invite",render:({field:y})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{children:a("template.form.conditions.require_invite.label")})}),e.jsx(b,{children:e.jsx(ee,{checked:y.value,onCheckedChange:y.onChange})})]})})]}),e.jsx(j,{control:c.control,name:"conditions.allowed_plans",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.conditions.allowed_plans.label")}),e.jsx(b,{children:e.jsx(rt,{value:y.value?.map(w=>({label:d.find(S=>S.id===w)?.name||`ID: ${w}`,value:w.toString()}))??[],onChange:w=>y.onChange(w.map(S=>parseInt(S.value))),options:u,placeholder:a("template.form.conditions.allowed_plans.placeholder")})})]})}),e.jsx(j,{control:c.control,name:"conditions.disallowed_plans",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.conditions.disallowed_plans.label")}),e.jsx(b,{children:e.jsx(rt,{value:y.value?.map(w=>({label:d.find(S=>S.id===w)?.name||`ID: ${w}`,value:w.toString()}))??[],onChange:w=>y.onChange(w.map(S=>parseInt(S.value))),options:u,placeholder:a("template.form.conditions.disallowed_plans.placeholder")})})]})})]})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.limits.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"limits.max_use_per_user",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.limits.max_use_per_user.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.limits.max_use_per_user.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"limits.cooldown_hours",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.limits.cooldown_hours.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",placeholder:a("template.form.limits.cooldown_hours.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})}),e.jsx(j,{control:c.control,name:"limits.invite_reward_rate",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.limits.invite_reward_rate.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",step:"0.01",placeholder:a("template.form.limits.invite_reward_rate.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})}),e.jsx(A,{children:a("template.form.limits.invite_reward_rate.description")})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.special_config.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-3 items-end gap-4",children:[e.jsx(j,{control:c.control,name:"special_config.start_time",render:({field:y})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:a("template.form.special_config.start_time.label")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(L,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!y.value&&"text-muted-foreground"),children:[y.value?Ee(new Date(y.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.start_time.placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:y.value?new Date(y.value*1e3):void 0,onSelect:w=>y.onChange(w?Math.floor(w.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"special_config.end_time",render:({field:y})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:a("template.form.special_config.end_time.label")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(L,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!y.value&&"text-muted-foreground"),children:[y.value?Ee(new Date(y.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.end_time.placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:y.value?new Date(y.value*1e3):void 0,onSelect:w=>y.onChange(w?Math.floor(w.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"special_config.festival_bonus",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.special_config.festival_bonus.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",step:"0.1",placeholder:a("template.form.special_config.festival_bonus.placeholder"),...y,value:y.value??"",onChange:w=>{const S=w.target.valueAsNumber;y.onChange(isNaN(S)?void 0:S)}})})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Me,{children:a("template.form.display.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:c.control,name:"icon",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.icon.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("template.form.icon.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx(j,{control:c.control,name:"background_image",render:({field:y})=>e.jsxs(f,{children:[e.jsx(v,{children:a("template.form.background_image.label")}),e.jsx(b,{children:e.jsx(D,{placeholder:a("template.form.background_image.placeholder"),...y})}),e.jsx(R,{})]})})]})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:()=>r(!1),children:a("common:cancel")}),e.jsx(L,{type:"submit",disabled:i,children:a(i?"common:saving":"common:submit")})]})]})})]})})}const Fi=m.createContext(void 0);function qh({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=x=>{i(x),r(!!x)},d=()=>{r(!1),i(null)};return e.jsxs(Fi.Provider,{value:{isOpen:t,editingTemplate:a,setEditingTemplate:l,closeEdit:d},children:[s,e.jsx(Di,{template:a,refetch:n,open:t,onOpenChange:r})]})}function Uh(){const s=m.useContext(Fi);if(s===void 0)throw new Error("useTemplateEdit must be used within a TemplateEditProvider");return s}function Hh({rewards:s,type:n}){const{t}=V(["giftCard","common"]),r=[];return s&&(s.balance&&r.push(`${t("template.form.rewards.balance.short_label")}: ${s.balance/100} ${t("common:currency.yuan","元")}`),s.transfer_enable&&r.push(`${t("template.form.rewards.transfer_enable.short_label")}: ${Le(s.transfer_enable)}`),s.expire_days&&r.push(`${t("template.form.rewards.expire_days.short_label")}: ${s.expire_days}${t("common:time.day","天")}`),s.device_limit&&r.push(`${t("template.form.rewards.device_limit.short_label")}: ${s.device_limit}`),n===2&&s.plan_id&&r.push(`${t("template.form.rewards.plan_id.short_label")}: ${s.plan_id}`),n===2&&s.plan_validity_days&&r.push(`${t("template.form.rewards.plan_validity_days.short_label")}: ${s.plan_validity_days}${t("common:time.day","天")}`),n===3&&s.random_rewards?.length&&r.push(t("types.3"))),r.length===0?e.jsx(U,{variant:"secondary",children:t("template.table.columns.no_rewards")}):e.jsx("div",{className:"flex flex-col space-y-1",children:r.map((a,i)=>e.jsx(U,{variant:"outline",className:"whitespace-nowrap",children:a},i))})}const Kh=s=>{const{t:n}=V("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"status",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.status")}),cell:({row:t})=>{const[r,a]=m.useState(!1);return e.jsx(ee,{checked:t.original.status,disabled:r,onCheckedChange:async i=>{a(!0);try{const{data:l}=await Ps.updateTemplate({id:t.original.id,status:i});l?($.success(n("messages.templateUpdated")),s()):$.error(n("messages.updateTemplateFailed"))}catch{$.error(n("messages.updateTemplateFailed"))}finally{a(!1)}}})},enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:300},{accessorKey:"type",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"rewards",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.rewards")}),cell:({row:t})=>e.jsx(Hh,{rewards:t.original.rewards,type:t.original.type}),enableSorting:!1},{accessorKey:"sort",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.sort")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.sort}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.original.created_at)}),enableSorting:!0},{id:"actions",header:({column:t})=>e.jsx(z,{column:t,title:n("template.table.columns.actions")}),cell:({row:t})=>{const{setEditingTemplate:r}=Uh();return e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>r(t.original),children:[e.jsx(lt,{className:"h-4 w-4"}),n("template.actions.edit")]}),e.jsx(hs,{title:n("template.actions.deleteConfirm.title"),description:n("template.actions.deleteConfirm.description"),confirmText:n("template.actions.deleteConfirm.confirmText"),onConfirm:async()=>{try{const{data:a}=await Ps.deleteTemplate({id:t.original.id});a?($.success(n("messages.templateDeleted")),s()):$.error(n("messages.deleteTemplateFailed"))}catch{$.error(n("messages.deleteTemplateFailed"))}},children:e.jsxs(L,{variant:"outline",size:"sm",children:[e.jsx(xs,{className:"h-4 w-4"}),n("template.actions.delete")]})})]})},enableSorting:!1}]};function Pi({table:s}){const{t:n}=V("common");return e.jsxs(Hs,{children:[e.jsx(Td,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(Ol,{className:"mr-2 h-4 w-4"}),n("table.viewOptions.button")]})}),e.jsxs(qs,{align:"end",className:"w-[150px]",children:[e.jsx(Wa,{children:n("table.viewOptions.label")}),e.jsx(nt,{}),s.getAllColumns().filter(t=>typeof t.accessorFn<"u"&&t.getCanHide()).map(t=>e.jsx(Zl,{className:"capitalize",checked:t.getIsVisible(),onCheckedChange:r=>t.toggleVisibility(!!r),children:t.id},t.id))]})]})}function za({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Dd,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):t.filter(a=>r.has(a.value)).map(a=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:a.label},`selected-${a.value}`))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ys,{children:[e.jsx(ot,{placeholder:n}),e.jsxs(Js,{children:[e.jsx(ct,{children:"No results found."}),e.jsx(gs,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(qe,{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:_("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(Na,{className:_("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(Ot,{}),e.jsx(gs,{children:e.jsx(qe,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function Bh({table:s,refetch:n}){const{t}=V("giftCard"),[r,a]=m.useState(!1),i=s.getState().columnFilters.length>0,l=[{label:t("types.1"),value:"1"},{label:t("types.2"),value:"2"},{label:t("types.3"),value:"3"},{label:t("types.4"),value:"4"},{label:t("types.5"),value:"5"},{label:t("types.6"),value:"6"},{label:t("types.7"),value:"7"},{label:t("types.8"),value:"8"},{label:t("types.9"),value:"9"},{label:t("types.10"),value:"10"}],d=[{label:t("common.enabled"),value:"true"},{label:t("common.disabled"),value:"false"}];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.jsx(D,{placeholder:t("common.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:x=>s.getColumn("name")?.setFilterValue(x.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(za,{column:s.getColumn("type"),title:t("template.table.columns.type"),options:l}),s.getColumn("status")&&e.jsx(za,{column:s.getColumn("status"),title:t("template.table.columns.status"),options:d}),i&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),t("template.form.add")]}),e.jsx(Pi,{table:s})]}),e.jsx(Di,{template:null,refetch:n,open:r,onOpenChange:a})]})}function Gh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=re({queryKey:["giftCardTemplates",x,a,l],queryFn:()=>Ps.getTemplates({per_page:x.pageSize,page:x.pageIndex+1,filter:a,sort:l})});console.log(c);const p=Ye({data:c?.data??[],columns:Kh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},pageCount:Math.ceil((c?.total??0)/x.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(qh,{refetch:o,children:e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:p,toolbar:e.jsx(Bh,{table:p,refetch:o})})})})}const Wh=h.object({template_id:h.number().min(1,"请选择一个模板"),count:h.number().min(1,"生成数量必须大于0").max(1e4,"单次最多生成10000个"),prefix:h.string().optional(),expires_hours:h.number().min(1,"有效期必须大于0"),max_usage:h.number().min(1,"最大使用次数必须大于0"),download_csv:h.boolean().optional()});function Yh({refetch:s,open:n,onOpenChange:t}){const{t:r}=V("giftCard"),[a,i]=m.useState(!1),[l,d]=m.useState([]);m.useEffect(()=>{n&&Ps.getTemplates({per_page:1e3,page:1}).then(({data:o})=>{d(o||[])})},[n]);const x=Ce({resolver:Te(Wh),defaultValues:{count:10,prefix:"",expires_hours:24*30,max_usage:1,download_csv:!1}}),u=async o=>{i(!0);try{if(o.download_csv){const c=await Ps.generateCodes(o);if(c&&c instanceof Blob){const p=window.URL.createObjectURL(c),F=document.createElement("a");F.href=p,F.download=`gift_codes_${new Date().getTime()}.csv`,document.body.appendChild(F),F.click(),F.remove(),window.URL.revokeObjectURL(p),$.success(r("messages.codesGenerated")),s(),t(!1),x.reset()}}else await Ps.generateCodes(o),$.success(r("messages.codesGenerated")),s(),t(!1),x.reset()}catch{$.error(r("messages.generateCodesFailed"))}finally{i(!1)}};return e.jsx(de,{open:n,onOpenChange:t,children:e.jsxs(oe,{children:[e.jsx(he,{children:e.jsx(me,{children:r("code.form.generate")})}),e.jsx(De,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(u),className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"template_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.template_id.label")}),e.jsxs(X,{onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(b,{children:e.jsx(J,{children:e.jsx(Z,{placeholder:r("code.form.template_id.placeholder")})})}),e.jsx(Q,{children:l.map(c=>e.jsx(q,{value:c.id.toString(),children:c.name},c.id))})]}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"count",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.count.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"prefix",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.prefix.label")}),e.jsx(b,{children:e.jsx(D,{...o})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"expires_hours",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.expires_hours.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"max_usage",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:r("code.form.max_usage.label")}),e.jsx(b,{children:e.jsx(D,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(j,{control:x.control,name:"download_csv",render:({field:o})=>e.jsxs(f,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(b,{children:e.jsx("input",{type:"checkbox",checked:o.value,onChange:c=>o.onChange(c.target.checked)})}),e.jsx(v,{children:r("code.form.download_csv")})]})}),e.jsxs(Oe,{children:[e.jsx(L,{type:"button",variant:"outline",onClick:()=>t(!1),children:r("common.cancel")}),e.jsx(L,{type:"submit",disabled:a,children:r(a?"code.form.submit.generating":"code.form.submit.generate")})]})]})})]})})}function Jh({table:s,refetch:n}){const{t}=V("giftCard"),[r,a]=m.useState(!1),i=s.getState().columnFilters.length>0,l=Object.entries(t("code.status",{returnObjects:!0})).map(([d,x])=>({value:d,label:x}));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.jsx(D,{placeholder:t("common.search"),value:s.getColumn("code")?.getFilterValue()??"",onChange:d=>s.getColumn("code")?.setFilterValue(d.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("status")&&e.jsx(za,{column:s.getColumn("status"),title:t("code.table.columns.status"),options:l}),i&&e.jsxs(L,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(zl,{className:"h-4 w-4 mr-2"}),t("code.form.generate")]}),e.jsxs(L,{variant:"outline",size:"sm",disabled:!0,children:[e.jsx(ta,{className:"h-4 w-4 mr-2"}),t("common.export")]}),e.jsx(Pi,{table:s})]}),e.jsx(Yh,{refetch:n,open:r,onOpenChange:a})]})}const Qh=0,Xh=1,Zh=2,jn=3,eg=s=>{const{t:n}=V("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id})},{accessorKey:"code",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.code")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:"secondary",children:t.original.code}),e.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>Zs(t.original.code).then(()=>{$.success(n("common:copy.success"))}),children:e.jsx(An,{className:"h-4 w-4"})})]})},{accessorKey:"template_name",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.template_name")})},{accessorKey:"status",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.status")}),cell:({row:t})=>{const r=t.original.status,a=r===jn,i=r===Qh||r===jn;return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:r===Xh?"secondary":r===Zh||r===jn?"destructive":"default",children:n(`code.status.${r}`)}),i&&e.jsx(ee,{checked:!a,onCheckedChange:async l=>{const d=l?"enable":"disable";try{const{data:x}=await Ps.toggleCode({id:t.original.id,action:d});x?($.success(n("messages.codeStatusUpdated")),s()):$.error(n("messages.updateCodeStatusFailed"))}catch{$.error(n("messages.updateCodeStatusFailed"))}}})]})}},{accessorKey:"expires_at",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.expires_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.original.expires_at)})},{accessorKey:"usage_count",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.usage_count")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.usage_count})},{accessorKey:"max_usage",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.max_usage")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.max_usage})},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("code.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.original.created_at)})}]};function sg(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=re({queryKey:["giftCardCodes",x,a,l],queryFn:()=>Ps.getCodes({per_page:x.pageSize,page:x.pageIndex+1,filter:a,sort:l})}),p=Ye({data:c?.data??[],columns:eg(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},pageCount:Math.ceil((c?.total??0)/x.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:u,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(rs,{table:p,toolbar:e.jsx(Jh,{table:p,refetch:o})})})}const tg=()=>{const{t:s}=V("giftCard");return[{accessorKey:"id",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.id")}),cell:({row:n})=>e.jsx(U,{children:n.original.id})},{accessorKey:"code",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.code")}),cell:({row:n})=>e.jsx(U,{variant:"secondary",children:n.original.code})},{accessorKey:"user_email",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.user_email")})},{accessorKey:"template_name",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.template_name")})},{accessorKey:"created_at",header:({column:n})=>e.jsx(z,{column:n,title:s("usage.table.columns.created_at")}),cell:({row:n})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(n.original.created_at)})}]};function ag(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState({pageIndex:0,pageSize:20}),{data:l}=re({queryKey:["giftCardUsages",a,s,t],queryFn:()=>Ps.getUsages({per_page:a.pageSize,page:a.pageIndex+1,filter:s,sort:t})}),d=Ye({data:l?.data??[],columns:tg(),state:{sorting:t,columnFilters:s,pagination:a},pageCount:Math.ceil((l?.total??0)/a.pageSize),rowCount:l?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,onSortingChange:r,onColumnFiltersChange:n,onPaginationChange:i,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),getSortedRowModel:js()});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{placeholder:"搜索用户邮箱...",value:d.getColumn("user_email")?.getFilterValue()??"",onChange:x=>d.getColumn("user_email")?.setFilterValue(x.target.value),className:"h-8 w-[150px] lg:w-[250px]"})}),e.jsx(rs,{table:d})]})}function ng(){const{t:s}=V("giftCard"),{data:n,isLoading:t}=re({queryKey:["giftCardStats"],queryFn:()=>Ps.getStatistics({})}),r=n?.data?.total_stats,a=[{title:s("statistics.total.templates_count"),value:r?.templates_count},{title:s("statistics.total.active_templates_count"),value:r?.active_templates_count},{title:s("statistics.total.codes_count"),value:r?.codes_count},{title:s("statistics.total.used_codes_count"),value:r?.used_codes_count}];return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:a.map((i,l)=>e.jsxs(ke,{children:[e.jsx(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:e.jsx(Me,{className:"text-sm font-medium",children:i.title})}),e.jsx(Pe,{children:t?e.jsx(be,{className:"h-8 w-1/2"}):e.jsx("div",{className:"text-2xl font-bold",children:i.value??0})})]},l))})}function rg(){const{t:s}=V("giftCard"),[n,t]=m.useState("templates");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-6 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.jsxs(_t,{value:n,onValueChange:t,className:"flex-1",children:[e.jsxs(it,{className:"grid w-full grid-cols-4",children:[e.jsx(Ge,{value:"templates",children:s("tabs.templates")}),e.jsx(Ge,{value:"codes",children:s("tabs.codes")}),e.jsx(Ge,{value:"usages",children:s("tabs.usages")}),e.jsx(Ge,{value:"statistics",children:s("tabs.statistics")})]}),e.jsx(ys,{value:"templates",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("template.description")})]})}),e.jsx(Gh,{})]})}),e.jsx(ys,{value:"codes",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("code.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("code.description")})]})}),e.jsx(sg,{})]})}),e.jsx(ys,{value:"usages",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("usage.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("usage.description")})]})}),e.jsx(ag,{})]})}),e.jsx(ys,{value:"statistics",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("statistics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("statistics.description")})]})}),e.jsx(ng,{})]})})]})]})]})}const lg=Object.freeze(Object.defineProperty({__proto__:null,default:rg},Symbol.toStringTag,{value:"Module"}));function ig({open:s,onOpenChange:n,table:t}){const{t:r}=V("user"),[a,i]=m.useState(!1),[l,d]=m.useState(""),[x,u]=m.useState(""),o=async()=>{if(!l||!x){$.error(r("messages.send_mail.required_fields"));return}try{i(!0),await Us.sendMail({subject:l,content:x,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),$.success(r("messages.send_mail.success")),n(!1),d(""),u("")}catch{$.error(r("messages.send_mail.failed"))}finally{i(!1)}};return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(oe,{className:"sm:max-w-[500px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("send_mail.title")}),e.jsx(Ue,{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(D,{id:"subject",value:l,onChange:c=>d(c.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(Es,{id:"content",value:x,onChange:c=>u(c.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(Oe,{children:e.jsx(G,{type:"submit",onClick:o,disabled:a,children:r(a?"send_mail.sending":"send_mail.send")})})]})})}function og({trigger:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),[a,i]=m.useState(30),{data:l,isLoading:d}=re({queryKey:["trafficResetStats",a],queryFn:()=>la.getStats({days:a}),enabled:t}),x=[{title:n("traffic_reset.stats.total_resets"),value:l?.data?.total_resets||0,icon:Jt,color:"text-blue-600",bgColor:"bg-blue-100"},{title:n("traffic_reset.stats.auto_resets"),value:l?.data?.auto_resets||0,icon:La,color:"text-green-600",bgColor:"bg-green-100"},{title:n("traffic_reset.stats.manual_resets"),value:l?.data?.manual_resets||0,icon:Ss,color:"text-orange-600",bgColor:"bg-orange-100"},{title:n("traffic_reset.stats.cron_resets"),value:l?.data?.cron_resets||0,icon:qn,color:"text-purple-600",bgColor:"bg-purple-100"}],u=[{value:7,label:n("traffic_reset.stats.days_options.week")},{value:30,label:n("traffic_reset.stats.days_options.month")},{value:90,label:n("traffic_reset.stats.days_options.quarter")},{value:365,label:n("traffic_reset.stats.days_options.year")}];return e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(cs,{asChild:!0,children:s}),e.jsxs(oe,{className:"max-w-2xl",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(On,{className:"h-5 w-5"}),n("traffic_reset.stats.title")]}),e.jsx(Ue,{children:n("traffic_reset.stats.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium",children:n("traffic_reset.stats.time_range")}),e.jsxs(X,{value:a.toString(),onValueChange:o=>i(Number(o)),children:[e.jsx(J,{className:"w-[180px]",children:e.jsx(Z,{})}),e.jsx(Q,{children:u.map(o=>e.jsx(q,{value:o.value.toString(),children:o.label},o.value))})]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(sa,{className:"h-6 w-6 animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-4",children:x.map((o,c)=>e.jsxs(ke,{className:"relative overflow-hidden",children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Me,{className:"text-sm font-medium text-muted-foreground",children:o.title}),e.jsx("div",{className:`rounded-lg p-2 ${o.bgColor}`,children:e.jsx(o.icon,{className:`h-4 w-4 ${o.color}`})})]}),e.jsxs(Pe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:o.value.toLocaleString()}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n("traffic_reset.stats.in_period",{days:a})})]})]},c))}),l?.data&&e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsx(Me,{className:"text-lg",children:n("traffic_reset.stats.breakdown")}),e.jsx(st,{children:n("traffic_reset.stats.breakdown_description")})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.auto_percentage")}),e.jsxs(U,{variant:"outline",className:"border-green-200 bg-green-50 text-green-700",children:[l.data.total_resets>0?(l.data.auto_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.manual_percentage")}),e.jsxs(U,{variant:"outline",className:"border-orange-200 bg-orange-50 text-orange-700",children:[l.data.total_resets>0?(l.data.manual_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.cron_percentage")}),e.jsxs(U,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:[l.data.total_resets>0?(l.data.cron_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]})]})})]})]})]})]})}const cg=h.object({email_prefix:h.string().optional(),email_suffix:h.string().min(1),password:h.string().optional(),expired_at:h.number().optional().nullable(),plan_id:h.number().nullable(),generate_count:h.number().optional().nullable(),download_csv:h.boolean().optional()}).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"]}),dg={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0,download_csv:!1};function mg({refetch:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),a=Ce({resolver:Te(cg),defaultValues:dg,mode:"onChange"}),[i,l]=m.useState([]);return m.useEffect(()=>{t&&_s.getList().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{size:"sm",variant:"outline",className:"gap-0 space-x-2",children:[e.jsx($e,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(oe,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:n("generate.title")}),e.jsx(Ue,{})]}),e.jsxs(De,{...a,children:[e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(j,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(D,{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(j,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(D,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(j,{control:a.control,name:"password",render:({field:d})=>e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(R,{})]})}),e.jsx(j,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:n("generate.form.expire_time")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(G,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?ne(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(We,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Fd,{asChild:!0,children:e.jsx(G,{variant:"outline",className:"w-full",onClick:()=>{d.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(ks,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:x=>{x&&d.onChange(x?.getTime()/1e3)}})})]})]})]})}),e.jsx(j,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.subscription")}),e.jsx(b,{children:e.jsxs(X,{value:d.value?d.value.toString():"null",onValueChange:x=>d.onChange(x==="null"?null:parseInt(x)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"null",children:n("generate.form.subscription_none")}),i.map(x=>e.jsx(q,{value:x.id.toString(),children:x.name},x.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(j,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(f,{children:[e.jsx(v,{children:n("generate.form.generate_count")}),e.jsx(D,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:d.value||"",onChange:x=>d.onChange(x.target.value?parseInt(x.target.value):null)})]})}),a.watch("generate_count")&&e.jsx(j,{control:a.control,name:"download_csv",render:({field:d})=>e.jsxs(f,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(b,{children:e.jsx(Jn,{checked:d.value,onCheckedChange:d.onChange})}),e.jsx(v,{children:n("generate.form.download_csv")})]})})]}),e.jsxs(Oe,{children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:n("generate.form.cancel")}),e.jsx(G,{onClick:()=>a.handleSubmit(async d=>{if(d.download_csv){const x=await Us.generate(d);if(x&&x instanceof Blob){const u=window.URL.createObjectURL(x),o=document.createElement("a");o.href=u,o.download=`users_${new Date().getTime()}.csv`,document.body.appendChild(o),o.click(),o.remove(),window.URL.revokeObjectURL(u),$.success(n("generate.form.success")),a.reset(),s(),r(!1)}}else{const{data:x}=await Us.generate(d);x&&($.success(n("generate.form.success")),a.reset(),s(),r(!1))}})(),children:n("generate.form.submit")})]})]})]})}const ug=1,xg=1e6;let vn=0;function hg(){return vn=(vn+1)%Number.MAX_SAFE_INTEGER,vn.toString()}const bn=new Map,Tr=s=>{if(bn.has(s))return;const n=setTimeout(()=>{bn.delete(s),ea({type:"REMOVE_TOAST",toastId:s})},xg);bn.set(s,n)},gg=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,ug)};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?Tr(t):s.toasts.forEach(r=>{Tr(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)}}},Sa=[];let ka={toasts:[]};function ea(s){ka=gg(ka,s),Sa.forEach(n=>{n(ka)})}function pg({...s}){const n=hg(),t=a=>ea({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>ea({type:"DISMISS_TOAST",toastId:n});return ea({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function fg(){const[s,n]=m.useState(ka);return m.useEffect(()=>(Sa.push(n),()=>{const t=Sa.indexOf(n);t>-1&&Sa.splice(t,1)}),[s]),{...s,toast:pg,dismiss:t=>ea({type:"DISMISS_TOAST",toastId:t})}}const Qn=$r,Li=Ar,jg=qr,Ri=m.forwardRef(({className:s,...n},t)=>e.jsx($a,{className:_("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}));Ri.displayName=$a.displayName;const vg=bt("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"}}),rn=m.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(jg,{children:[e.jsx(Ri,{}),e.jsxs(Aa,{ref:a,className:_(vg({side:s}),n),...r,children:[e.jsxs(En,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));rn.displayName=Aa.displayName;const ln=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});ln.displayName="SheetHeader";const Ei=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ei.displayName="SheetFooter";const on=m.forwardRef(({className:s,...n},t)=>e.jsx(qa,{ref:t,className:_("text-lg font-semibold text-foreground",s),...n}));on.displayName=qa.displayName;const cn=m.forwardRef(({className:s,...n},t)=>e.jsx(Ua,{ref:t,className:_("text-sm text-muted-foreground",s),...n}));cn.displayName=Ua.displayName;function bg({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=V("user"),{toast:i}=fg(),l=s.getState().columnFilters.length>0,[d,x]=m.useState([]),[u,o]=m.useState(!1),[c,p]=m.useState(!1),[F,T]=m.useState(!1),[C,P]=m.useState(!1),N=async()=>{try{const te=await Us.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),ae=te;console.log(te);const B=new Blob([ae],{type:"text/csv;charset=utf-8;"}),se=window.URL.createObjectURL(B),je=document.createElement("a");je.href=se,je.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(je),je.click(),je.remove(),window.URL.revokeObjectURL(se),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},I=async()=>{try{P(!0),await Us.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{P(!1),T(!1)}},y=[{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.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{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"}]}],w=te=>te*1024*1024*1024,S=te=>te/(1024*1024*1024),O=()=>{x([...d,{field:"",operator:"",value:""}])},E=te=>{x(d.filter((ae,B)=>B!==te))},g=(te,ae,B)=>{const se=[...d];if(se[te]={...se[te],[ae]:B},ae==="field"){const je=y.find(ms=>ms.value===B);je&&(se[te].operator=je.operators[0].value,se[te].value=je.type==="boolean"?!1:"")}x(se)},k=(te,ae)=>{const B=y.find(se=>se.value===te.field);if(!B)return null;switch(B.type){case"text":return e.jsx(D,{placeholder:a("filter.sheet.value"),value:te.value,onChange:se=>g(ae,"value",se.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(D,{type:"number",placeholder:a("filter.sheet.value_number",{unit:B.unit}),value:B.unit==="GB"?S(te.value||0):te.value,onChange:se=>{const je=Number(se.target.value);g(ae,"value",B.unit==="GB"?w(je):je)}}),B.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:B.unit})]});case"date":return e.jsx(ks,{mode:"single",selected:te.value,onSelect:se=>g(ae,"value",se),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(X,{value:te.value,onValueChange:se=>g(ae,"value",se),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("filter.sheet.value")})}),e.jsx(Q,{children:B.useOptions?r.map(se=>e.jsx(q,{value:se.value.toString(),children:se.label},se.value)):B.options?.map(se=>e.jsx(q,{value:se.value.toString(),children:se.label},se.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ee,{checked:te.value,onCheckedChange:se=>g(ae,"value",se)}),e.jsx(Xe,{children:te.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},W=()=>{const te=d.filter(ae=>ae.field&&ae.operator&&ae.value!=="").map(ae=>{const B=y.find(je=>je.value===ae.field);let se=ae.value;return ae.operator==="contains"?{id:ae.field,value:se}:(B?.type==="date"&&se instanceof Date&&(se=Math.floor(se.getTime()/1e3)),B?.type==="boolean"&&(se=se?1:0),{id:ae.field,value:`${ae.operator}:${se}`})});s.setColumnFilters(te),o(!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(mg,{refetch:n}),e.jsx(D,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:te=>s.getColumn("email")?.setFilterValue(te.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Qn,{open:u,onOpenChange:o,children:[e.jsx(Li,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ol,{className:"mr-2 h-4 w-4"}),a("filter.advanced"),d.length>0&&e.jsx(U,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:d.length})]})}),e.jsxs(rn,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(ln,{children:[e.jsx(on,{children:a("filter.sheet.title")}),e.jsx(cn,{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(L,{variant:"outline",size:"sm",onClick:O,children:a("filter.sheet.add")})]}),e.jsx(vt,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((te,ae)=>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(Xe,{children:a("filter.sheet.condition",{number:ae+1})}),e.jsx(L,{variant:"ghost",size:"sm",onClick:()=>E(ae),children:e.jsx(os,{className:"h-4 w-4"})})]}),e.jsxs(X,{value:te.field,onValueChange:B=>g(ae,"field",B),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("filter.sheet.field")})}),e.jsx(Q,{children:e.jsx(ws,{children:y.map(B=>e.jsx(q,{value:B.value,className:"cursor-pointer",children:B.label},B.value))})})]}),te.field&&e.jsxs(X,{value:te.operator,onValueChange:B=>g(ae,"operator",B),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:a("filter.sheet.operator")})}),e.jsx(Q,{children:y.find(B=>B.value===te.field)?.operators.map(B=>e.jsx(q,{value:B.value,children:B.label},B.value))})]}),te.field&&te.operator&&k(te,ae)]},ae))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{variant:"outline",onClick:()=>{x([]),o(!1)},children:a("filter.sheet.reset")}),e.jsx(L,{onClick:W,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),x([])},className:"h-8 px-2 lg:px-3",children:[a("filter.sheet.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]}),e.jsxs(Hs,{modal:!1,children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(qs,{children:[e.jsx(Se,{onClick:()=>p(!0),children:a("actions.send_email")}),e.jsx(Se,{onClick:N,children:a("actions.export_csv")}),e.jsx(nt,{}),e.jsx(Se,{asChild:!0,children:e.jsx(og,{trigger:e.jsx("div",{className:"w-full cursor-pointer px-2 py-1.5 text-sm",children:a("actions.traffic_reset_stats")})})}),e.jsx(nt,{}),e.jsx(Se,{onClick:()=>T(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(ig,{open:c,onOpenChange:p,table:s}),e.jsx(Wn,{open:F,onOpenChange:T,children:e.jsxs(Ja,{children:[e.jsxs(Qa,{children:[e.jsx(Za,{children:a("actions.confirm_ban.title")}),e.jsx(en,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs(Xa,{children:[e.jsx(tn,{disabled:C,children:a("actions.confirm_ban.cancel")}),e.jsx(sn,{onClick:I,disabled:C,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(C?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const Ii=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"})}),Vi=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"})}),yg=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"})}),_g=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"})}),yn=[{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:Yd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ii,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:Le(s.original.u/parseFloat(s.original.server_rate))})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Vi,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:Le(s.original.d/parseFloat(s.original.server_rate))})]})},{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(U,{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:Le(n)})}}];function Mi({user_id:s,dialogTrigger:n}){const{t}=V(["traffic"]),[r,a]=m.useState(!1),[i,l]=m.useState({pageIndex:0,pageSize:20}),{data:d,isLoading:x}=re({queryKey:["userStats",s,i,r],queryFn:()=>r?Us.getStats({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),u=Ye({data:d?.data??[],columns:yn,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:Je(),onPaginationChange:l});return e.jsxs(de,{open:r,onOpenChange:a,children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"sm:max-w-[700px]",children:[e.jsx(he,{children:e.jsx(me,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Hn,{children:[e.jsx(Kn,{children:u.getHeaderGroups().map(o=>e.jsx(et,{children:o.headers.map(c=>e.jsx(Gn,{className:_("h-10 px-2 text-xs",c.id==="total"&&"text-right"),children:c.isPlaceholder?null:Fa(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsx(Bn,{children:x?Array.from({length:i.pageSize}).map((o,c)=>e.jsx(et,{children:Array.from({length:yn.length}).map((p,F)=>e.jsx(Rt,{className:"p-2",children:e.jsx(be,{className:"h-6 w-full"})},F))},c)):u.getRowModel().rows?.length?u.getRowModel().rows.map(o=>e.jsx(et,{"data-state":o.getIsSelected()&&"selected",className:"h-10",children:o.getVisibleCells().map(c=>e.jsx(Rt,{className:"px-2",children:Fa(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsx(et,{children:e.jsx(Rt,{colSpan:yn.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(X,{value:`${u.getState().pagination.pageSize}`,onValueChange:o=>{u.setPageSize(Number(o))},children:[e.jsx(J,{className:"h-8 w-[70px]",children:e.jsx(Z,{placeholder:u.getState().pagination.pageSize})}),e.jsx(Q,{side:"top",children:[10,20,30,40,50].map(o=>e.jsx(q,{value:`${o}`,children:o},o))})]}),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:u.getState().pagination.pageIndex+1,total:u.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>u.previousPage(),disabled:!u.getCanPreviousPage()||x,children:e.jsx(yg,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>u.nextPage(),disabled:!u.getCanNextPage()||x,children:e.jsx(_g,{className:"h-4 w-4"})})]})]})]})]})]})]})}function Ng({user:s,trigger:n,onSuccess:t}){const{t:r}=V("user"),[a,i]=m.useState(!1),[l,d]=m.useState(""),[x,u]=m.useState(!1),{data:o,isLoading:c}=re({queryKey:["trafficResetHistory",s.id],queryFn:()=>la.getUserHistory(s.id,{limit:10}),enabled:a}),p=async()=>{try{u(!0);const{data:C}=await la.resetUser({user_id:s.id,reason:l.trim()||void 0});C&&($.success(r("traffic_reset.reset_success")),i(!1),d(""),t?.())}finally{u(!1)}},F=C=>{switch(C){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},T=C=>{switch(C){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}};return e.jsxs(de,{open:a,onOpenChange:i,children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"max-h-[90vh] max-w-4xl overflow-hidden",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-5 w-5"}),r("traffic_reset.title")]}),e.jsx(Ue,{children:r("traffic_reset.description",{email:s.email})})]}),e.jsxs(_t,{defaultValue:"reset",className:"w-full",children:[e.jsxs(it,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ge,{value:"reset",className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-4 w-4"}),r("traffic_reset.tabs.reset")]}),e.jsxs(Ge,{value:"history",className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),r("traffic_reset.tabs.history")]})]}),e.jsxs(ys,{value:"reset",className:"space-y-4",children:[e.jsxs(ke,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Me,{className:"flex items-center gap-2 text-lg",children:[e.jsx($l,{className:"h-5 w-5"}),r("traffic_reset.user_info")]})}),e.jsx(Pe,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.email")}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.used_traffic")}),e.jsx("p",{className:"font-medium",children:Le(s.total_used)})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.total_traffic")}),e.jsx("p",{className:"font-medium",children:Le(s.transfer_enable)})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("columns.expire_time")}),e.jsx("p",{className:"font-medium",children:s.expired_at?ne(s.expired_at):r("columns.expire_status.permanent")})]})]})})]}),e.jsxs(ke,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Me,{className:"flex items-center gap-2 text-lg text-amber-800",children:[e.jsx(Yt,{className:"h-5 w-5"}),r("traffic_reset.warning.title")]})}),e.jsx(Pe,{children:e.jsxs("ul",{className:"space-y-2 text-sm text-amber-700",children:[e.jsxs("li",{children:["• ",r("traffic_reset.warning.irreversible")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.reset_to_zero")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.logged")]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Xe,{htmlFor:"reason",children:r("traffic_reset.reason.label")}),e.jsx(Es,{id:"reason",placeholder:r("traffic_reset.reason.placeholder"),value:l,onChange:C=>d(C.target.value),className:"min-h-[80px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("traffic_reset.reason.optional")})]}),e.jsxs(Oe,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:r("common:cancel")}),e.jsx(G,{onClick:p,disabled:x,className:"bg-destructive hover:bg-destructive/90",children:x?e.jsxs(e.Fragment,{children:[e.jsx(sa,{className:"mr-2 h-4 w-4 animate-spin"}),r("traffic_reset.resetting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Jt,{className:"mr-2 h-4 w-4"}),r("traffic_reset.confirm_reset")]})})]})]}),e.jsx(ys,{value:"history",className:"space-y-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(sa,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[o?.data?.user&&e.jsxs(ke,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsx(Me,{className:"text-lg",children:r("traffic_reset.history.summary")})}),e.jsx(Pe,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.reset_count")}),e.jsx("p",{className:"font-medium",children:o.data.user.reset_count})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.last_reset")}),e.jsx("p",{className:"font-medium",children:o.data.user.last_reset_at?ne(o.data.user.last_reset_at):r("traffic_reset.history.never")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.next_reset")}),e.jsx("p",{className:"font-medium",children:o.data.user.next_reset_at?ne(o.data.user.next_reset_at):r("traffic_reset.history.no_schedule")})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{className:"pb-3",children:[e.jsx(Me,{className:"text-lg",children:r("traffic_reset.history.records")}),e.jsx(st,{children:r("traffic_reset.history.recent_records")})]}),e.jsx(Pe,{children:e.jsx(vt,{className:"h-[300px]",children:o?.data?.history?.length?e.jsx("div",{className:"space-y-3",children:o.data.history.map((C,P)=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between rounded-lg border bg-card p-3",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:F(C.reset_type),children:C.reset_type_name}),e.jsx(U,{variant:"outline",className:T(C.trigger_source),children:C.trigger_source_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs(Xe,{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(qn,{className:"h-3 w-3"}),r("traffic_reset.history.reset_time")]}),e.jsx("p",{className:"font-medium",children:ne(C.reset_time)})]}),e.jsxs("div",{children:[e.jsx(Xe,{className:"text-muted-foreground",children:r("traffic_reset.history.traffic_cleared")}),e.jsx("p",{className:"font-medium text-destructive",children:C.old_traffic.formatted})]})]})]})}),P{i(s)},[s]),e.jsxs(de,{children:[e.jsx(cs,{asChild:!0,children:n}),e.jsxs(oe,{className:"max-w-xl",children:[e.jsxs(he,{className:"space-y-2",children:[e.jsx(me,{className:"text-lg font-medium",children:r("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:[r("dialog.fields.userId"),":",a.id]}),e.jsx(Cg,{banned:a.banned,isAdmin:a.is_admin,isStaff:a.is_staff})]})})]}),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:r("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{label:r("dialog.fields.email"),value:a.email,valueClassName:"font-medium"}),e.jsx(ve,{label:r("dialog.fields.uuid"),value:a.uuid,valueClassName:"font-mono text-xs"}),e.jsx(ve,{label:r("dialog.fields.token"),value:a.token,valueClassName:"font-mono text-xs"}),e.jsx(ve,{label:r("dialog.fields.remarks"),value:a.remarks}),e.jsx(ve,{label:r("dialog.fields.telegramId"),value:a.telegram_id?e.jsx("span",{className:"font-mono text-xs",children:a.telegram_id}):"-"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:r("dialog.subscriptionInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ve,{label:r("dialog.fields.subscriptionPlan"),value:a.plan?.name,valueClassName:"font-medium"}),e.jsx(ve,{label:r("dialog.fields.permissionGroup"),value:a.group?.name,valueClassName:"font-medium"}),e.jsx(ve,{label:r("dialog.fields.expiredAt"),value:e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx("span",{className:"font-mono text-xs",children:a.expired_at==null?r("columns.expire_status.permanent"):ne(a.expired_at,"YYYY-MM-DD")})}),e.jsx(ce,{side:"bottom",className:"space-y-1 p-3",children:a.expired_at!=null?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r("columns.expire_time"),":"," ",ne(a.expired_at)]}),e.jsx("p",{className:_("text-sm font-medium",a.expired_ate.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"})}),Tg=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"})}),Dg=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"})}),Dr=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"})}),Fg=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"})}),Pg=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"})}),Lg=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"})}),Rg=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"})}),Eg=(s,n,t,r)=>{const{t:a}=V("user");return[{accessorKey:"is_admin",header:({column:i})=>e.jsx(z,{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(z,{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(z,{column:i,title:a("columns.id")}),cell:({row:i})=>e.jsx(U,{variant:"outline",children:i.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:i})=>e.jsx(z,{column:i,title:a("columns.email")}),cell:({row:i})=>{const l=i.original.t||0,d=Date.now()/1e3-l<120,x=Math.floor(Date.now()/1e3-l);let u=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:ne(l)});if(!d&&l!==0){const F=Math.floor(x/60),T=Math.floor(F/60),C=Math.floor(T/24);C>0?u+=` `+a("columns.online_status.offline_duration.days",{count:C}):T>0?u+=` `+a("columns.online_status.offline_duration.hours",{count:T}):F>0?u+=` `+a("columns.online_status.offline_duration.minutes",{count:F}):u+=` -`+a("columns.online_status.offline_duration.seconds",{count:x})}const[i,c]=ka.useState(!1),p=o.original.email;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsxs("div",{className:"group flex items-center gap-2.5",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[e.jsx("div",{className:_("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(Sg,{user:o.original,trigger:e.jsx("span",{className:"cursor-pointer font-medium text-foreground/90 transition-colors hover:text-primary hover:underline",children:p})}),e.jsx("button",{type:"button",className:_("ml-1 rounded bg-transparent p-1 transition-opacity hover:bg-muted",i?"opacity-100":"pointer-events-none opacity-0","group-hover:pointer-events-auto group-hover:opacity-100"),tabIndex:-1,"aria-label":a("columns.actions_menu.copy_email",{defaultValue:"Copy Email"}),onClick:F=>{F.stopPropagation(),Et(p),$.success(a("common:copy.success"))},style:{lineHeight:0},children:e.jsx($n,{className:"h-4 w-4 text-muted-foreground"})})]})}),e.jsx(ce,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:u})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.online_count")}),cell:({row:o})=>{const l=o.original.device_limit,d=o.original.online_count||0;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(U,{variant:"outline",className:_("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:o})=>e.jsx(z,{column:o,title:a("columns.status")}),cell:({row:o})=>{const l=o.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(U,{className:_("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:(o,l,d)=>d.includes(o.getValue(l))},{accessorKey:"plan_id",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.subscription")}),cell:({row:o})=>e.jsx("div",{className:"min-w-[10em] break-all",children:o.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.group")}),cell:({row:o})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(U,{variant:"outline",className:_("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:o.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.used_traffic")}),cell:({row:o})=>{const l=Le(o.original?.total_used),d=Le(o.original?.transfer_enable),x=o.original?.total_used/o.original?.transfer_enable*100||0;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{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:[x.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:_("h-full rounded-full transition-all",x>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(x,100)}%`}})})]})}),e.jsx(ce,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",d]})})]})})}},{accessorKey:"transfer_enable",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.total_traffic")}),cell:({row:o})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:Le(o.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:o})=>e.jsx(z,{column:o,title:a("columns.expire_time")}),cell:({row:o})=>{const l=o.original.expired_at,d=Date.now()/1e3,x=l!=null&&le.jsx(z,{column:o,title:a("columns.balance")}),cell:({row:o})=>{const l=pr(o.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:o})=>e.jsx(z,{column:o,title:a("columns.commission")}),cell:({row:o})=>{const l=pr(o.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:o})=>e.jsx(z,{column:o,title:a("columns.register_time")}),cell:({row:o})=>e.jsx("div",{className:"truncate",children:ne(o.original?.created_at)}),size:1e3},{id:"actions",header:({column:o})=>e.jsx(z,{column:o,className:"justify-end",title:a("columns.actions")}),cell:({row:o,table:l})=>e.jsxs(Hs,{modal:!1,children:[e.jsx(Gs,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(G,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Ra,{className:"size-4"})})})}),e.jsxs(qs,{align:"end",className:"min-w-[40px]",children:[e.jsx(Se,{onSelect:d=>{d.preventDefault(),t(o.original),r(!0)},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(kg,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Si,{defaultValues:{email:o.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Tg,{className:"mr-2"}),a("columns.actions_menu.assign_order")]})})}),e.jsx(Se,{onSelect:()=>{Et(o.original.subscribe_url).then(()=>{$.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Dg,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsxs(Se,{className:"",onSelect:()=>{Us.resetSecret(o.original.id).then(({data:d})=>{d&&$.success("重置成功")})},children:[e.jsx(Dr,{className:"mr-4"}),a("columns.actions_menu.reset_secret")]}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(G,{variant:"ghost",className:"h-auto w-full justify-start px-2 py-1.5 font-normal",asChild:!0,children:e.jsxs(Bs,{to:`/finance/order?user_id=eq:${o.original.id}`,children:[e.jsx(Fg,{className:"mr-2"}),a("columns.actions_menu.orders")]})})}),e.jsxs(Se,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+o.original?.id}])},children:[e.jsx(Pg,{className:"mr-4"}),a("columns.actions_menu.invites")]}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Mi,{user_id:o.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Lg,{className:"mr-2"}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Ng,{user:o.original,onSuccess:s,trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Dr,{className:"mr-2"}),a("columns.actions_menu.reset_traffic")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(wg,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:o.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:d}=await Us.destroy(o.original.id);d&&($.success(a("common:delete.success")),s())}catch{$.error(a("common:delete.failed"))}},children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5 text-destructive hover:text-destructive",children:[e.jsx(Rg,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},Oi=m.createContext(void 0),Qn=()=>{const s=m.useContext(Oi);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},zi=({children:s,refreshData:n})=>{const[t,r]=m.useState(!1),[a,o]=m.useState(null),l={isOpen:t,setIsOpen:r,editingUser:a,setEditingUser:o,refreshData:n};return e.jsx(Oi.Provider,{value:l,children:s})},Ig=h.object({id:h.number().default(0),email:h.string().email().default(""),invite_user_email:h.string().email().nullable().optional().default(null),password:h.string().optional().nullable().default(null),balance:h.coerce.number().default(0),commission_balance:h.coerce.number().default(0),u:h.coerce.number().default(0),d:h.coerce.number().default(0),transfer_enable:h.number().default(0),expired_at:h.number().nullable().default(null),plan_id:h.number().nullable().default(null),banned:h.boolean().default(!1),commission_type:h.number().default(0),commission_rate:h.number().nullable().default(null),discount:h.number().nullable().default(null),speed_limit:h.number().nullable().default(null),device_limit:h.number().nullable().default(null),is_admin:h.boolean().default(!1),is_staff:h.boolean().default(!1),remarks:h.string().nullable().default(null)});function $i(){const{t:s}=V("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=Qn(),[o,l]=m.useState(!1),[d,x]=m.useState([]),u=Ce({resolver:Te(Ig)});return m.useEffect(()=>{n&&_s.getList().then(({data:i})=>{x(i)})},[n]),m.useEffect(()=>{if(r){const i=r.invite_user?.email,{invite_user:c,...p}=r;u.reset({...p,invite_user_email:i||null,password:null,u:p.u?(p.u/1024/1024/1024).toFixed(3):"",d:p.d?(p.d/1024/1024/1024).toFixed(3):""})}},[r,u]),e.jsx(Jn,{open:n,onOpenChange:t,children:e.jsxs(nn,{className:"max-w-[90%] space-y-4",children:[e.jsxs(rn,{children:[e.jsx(ln,{children:s("edit.title")}),e.jsx(on,{})]}),e.jsxs(De,{...u,children:[e.jsx(j,{control:u.control,name:"email",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.email")}),e.jsx(b,{children:e.jsx(D,{...i,placeholder:s("edit.form.email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...i})]})}),e.jsx(j,{control:u.control,name:"invite_user_email",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.inviter_email")}),e.jsx(b,{children:e.jsx(D,{value:i.value||"",onChange:c=>i.onChange(c.target.value?c.target.value:null),placeholder:s("edit.form.inviter_email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...i})]})}),e.jsx(j,{control:u.control,name:"password",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.password")}),e.jsx(b,{children:e.jsx(D,{type:"password",value:i.value||"",onChange:i.onChange,placeholder:s("edit.form.password_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...i})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(j,{control:u.control,name:"balance",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.balance")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value||"",onChange:i.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(R,{...i})]})}),e.jsx(j,{control:u.control,name:"commission_balance",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.commission_balance")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value||"",onChange:i.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(R,{...i})]})}),e.jsx(j,{control:u.control,name:"u",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.upload")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",step:"any",value:i.value??"",onChange:c=>i.onChange(c.target.value),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(R,{...i})]})}),e.jsx(j,{control:u.control,name:"d",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.download")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",step:"any",value:i.value??"",onChange:c=>i.onChange(c.target.value),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(R,{...i})]})})]}),e.jsx(j,{control:u.control,name:"transfer_enable",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.total_traffic")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value/1024/1024/1024||"",onChange:c=>i.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"expired_at",render:({field:i})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:s("edit.form.expire_time")}),e.jsxs(es,{open:o,onOpenChange:l,children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(L,{type:"button",variant:"outline",className:_("w-full pl-3 text-left font-normal",!i.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[i.value?ne(i.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:c=>{c.preventDefault()},onEscapeKeyDown:c=>{c.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(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{i.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+1),c.setHours(23,59,59,999),i.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+3),c.setHours(23,59,59,999),i.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(ks,{mode:"single",selected:i.value?new Date(i.value*1e3):void 0,onSelect:c=>{if(c){const p=new Date(i.value?i.value*1e3:Date.now());c.setHours(p.getHours(),p.getMinutes(),p.getSeconds()),i.onChange(Math.floor(c.getTime()/1e3))}},disabled:c=>c{const c=new Date;c.setHours(23,59,59,999),i.onChange(Math.floor(c.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(D,{type:"datetime-local",step:"1",value:ne(i.value,"YYYY-MM-DDTHH:mm:ss"),onChange:c=>{const p=new Date(c.target.value);isNaN(p.getTime())||i.onChange(Math.floor(p.getTime()/1e3))},className:"flex-1"}),e.jsx(L,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:u.control,name:"plan_id",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.subscription")}),e.jsx(b,{children:e.jsxs(X,{value:i.value!==null?String(i.value):"null",onValueChange:c=>i.onChange(c==="null"?null:parseInt(c)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"null",children:s("edit.form.subscription_none")}),d.map(c=>e.jsx(q,{value:String(c.id),children:c.name},c.id))]})]})})]})}),e.jsx(j,{control:u.control,name:"banned",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.account_status")}),e.jsx(b,{children:e.jsxs(X,{value:i.value.toString(),onValueChange:c=>i.onChange(c==="true"),children:[e.jsx(J,{children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(q,{value:"true",children:s("columns.status_text.banned")}),e.jsx(q,{value:"false",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(j,{control:u.control,name:"commission_type",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.commission_type")}),e.jsx(b,{children:e.jsxs(X,{value:i.value.toString(),onValueChange:c=>i.onChange(parseInt(c)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx(q,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx(q,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(j,{control:u.control,name:"commission_rate",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.commission_rate")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value||"",onChange:c=>i.onChange(parseInt(c.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(j,{control:u.control,name:"discount",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.discount")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value||"",onChange:c=>i.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"speed_limit",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.speed_limit")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value||"",onChange:c=>i.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"device_limit",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.device_limit")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:i.value||"",onChange:c=>i.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"is_admin",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:c=>i.onChange(c)})})}),e.jsx(R,{})]})}),e.jsx(j,{control:u.control,name:"is_staff",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:i.value,onCheckedChange:c=>i.onChange(c)})})})]})}),e.jsx(j,{control:u.control,name:"remarks",render:({field:i})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.remarks")}),e.jsx(b,{children:e.jsx(Es,{className:"h-24",value:i.value||"",onChange:c=>i.onChange(c.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(R,{})]})}),e.jsxs(Ei,{children:[e.jsx(L,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(L,{type:"submit",onClick:()=>{u.handleSubmit(i=>{const c={id:i.id};u.formState.dirtyFields.u&&(c.u=Math.round(parseFloat(i.u)*1024*1024*1024)),u.formState.dirtyFields.d&&(c.d=Math.round(parseFloat(i.d)*1024*1024*1024)),Object.keys(i).forEach(p=>{p!=="u"&&p!=="d"&&p!=="id"&&u.formState.dirtyFields[p]&&(c[p]=i[p])}),Us.update(c).then(({data:p})=>{p&&($.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function Vg(){const[s]=Ml(),[n,t]=m.useState({}),[r,a]=m.useState({is_admin:!1,is_staff:!1}),[o,l]=m.useState([]),[d,x]=m.useState([]),[u,i]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const N=s.get("email");N&&l(S=>S.some(E=>E.id==="email")?S:[...S,{id:"email",value:N}])},[s]);const{refetch:c,data:p,isLoading:F}=re({queryKey:["userList",u,o,d],queryFn:()=>Us.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:o,sort:d})}),[T,C]=m.useState([]),[P,w]=m.useState([]);m.useEffect(()=>{_t.getList().then(({data:N})=>{C(N)}),_s.getList().then(({data:N})=>{w(N)})},[]);const I=T.map(N=>({label:N.name,value:N.id})),y=P.map(N=>({label:N.name,value:N.id}));return e.jsxs(zi,{refreshData:c,children:[e.jsx(Mg,{data:p?.data||[],rowCount:p?.total??0,sorting:d,setSorting:x,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:o,setColumnFilters:l,pagination:u,setPagination:i,refetch:c,serverGroupList:T,permissionGroups:I,subscriptionPlans:y,isLoading:F}),e.jsx($i,{})]})}function Mg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:o,rowSelection:l,setRowSelection:d,columnFilters:x,setColumnFilters:u,pagination:i,setPagination:c,refetch:p,serverGroupList:F,permissionGroups:T,subscriptionPlans:C,isLoading:P}){const{setIsOpen:w,setEditingUser:I}=Qn(),y=Ye({data:s,columns:Eg(p,F,I,w),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:x,pagination:i},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:u,onColumnVisibilityChange:o,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:c,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),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(bg,{table:y,refetch:p,serverGroupList:F,permissionGroups:T,subscriptionPlans:C}),e.jsx(rs,{table:y,isLoading:P})]})}function Og(){const{t:s}=V("user");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Vg,{})})})]})]})}const zg=Object.freeze(Object.defineProperty({__proto__:null,default:Og},Symbol.toStringTag,{value:"Module"})),$g=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 Ag({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(yt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(lt,{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(Oa,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:us.LOW,icon:$g,color:"gray"},{label:n("level.medium"),value:us.MIDDLE,icon:Ii,color:"yellow"},{label:n("level.high"),value:us.HIGH,icon:Vi,color:"red"}]})]})})}function qg(){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 Ug=vt("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"}}),Ai=m.forwardRef(({className:s,variant:n,layout:t,children:r,...a},o)=>e.jsx("div",{className:_(Ug({variant:n,layout:t,className:s}),"relative group"),ref:o,...a,children:m.Children.map(r,l=>m.isValidElement(l)&&typeof l.type!="string"?m.cloneElement(l,{variant:n,layout:t}):l)}));Ai.displayName="ChatBubble";const Hg=vt("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"}}),qi=m.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...o},l)=>e.jsx("div",{className:_(Hg({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...o,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(qg,{})}):a}));qi.displayName="ChatBubbleMessage";const Kg=m.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:_("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}));Kg.displayName="ChatBubbleActionWrapper";const Ui=m.forwardRef(({className:s,...n},t)=>e.jsx(Es,{autoComplete:"off",ref:t,name:"message",className:_("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}));Ui.displayName="ChatInput";const Hi=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"})}),Ki=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"})}),Fr=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"})}),Bg=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"})}),Gg=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"})}),Wg=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 Yg(){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(be,{className:"h-8 w-3/4"}),e.jsx(be,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(be,{className:"h-20 w-2/3"},s))})]})}function Jg(){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(be,{className:"h-5 w-4/5"}),e.jsx(be,{className:"h-4 w-2/3"}),e.jsx(be,{className:"h-3 w-1/2"})]},s))})}function Qg({ticket:s,isActive:n,onClick:t}){const{t:r}=V("ticket"),a=o=>{switch(o){case us.HIGH:return"bg-red-50 text-red-600 border-red-200";case us.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case us.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:_("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(U,{variant:s.status===tt.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===tt.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:ne(s.updated_at)}),e.jsx("div",{className:_("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===us.LOW?"low":s.level===us.MIDDLE?"medium":"high"}`)})]})]})}function Xg({ticketId:s,dialogTrigger:n}){const{t}=V("ticket"),r=Ws(),a=m.useRef(null),o=m.useRef(null),[l,d]=m.useState(!1),[x,u]=m.useState(""),[i,c]=m.useState(!1),[p,F]=m.useState(s),[T,C]=m.useState(""),[P,w]=m.useState(!1),{setIsOpen:I,setEditingUser:y}=Qn(),{data:N,isLoading:S,refetch:O}=re({queryKey:["tickets",l],queryFn:()=>l?Pt.getList({filter:[{id:"status",value:[tt.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:E,refetch:g,isLoading:k}=re({queryKey:["ticket",p,l],queryFn:()=>l?Pt.getInfo(p):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),W=E?.data,ae=(N?.data||[]).filter(le=>le.subject.toLowerCase().includes(T.toLowerCase())||le.user?.email.toLowerCase().includes(T.toLowerCase())),B=(le="smooth")=>{if(a.current){const{scrollHeight:Ts,clientHeight:Ns}=a.current;a.current.scrollTo({top:Ts-Ns,behavior:le})}};m.useEffect(()=>{if(!l)return;const le=requestAnimationFrame(()=>{B("instant"),setTimeout(()=>B(),1e3)});return()=>{cancelAnimationFrame(le)}},[l,W?.messages]);const se=async()=>{const le=x.trim();!le||i||(c(!0),Pt.reply({id:p,message:le}).then(()=>{u(""),g(),B(),setTimeout(()=>{o.current?.focus()},0)}).finally(()=>{c(!1)}))},je=async()=>{Pt.close(p).then(()=>{$.success(t("actions.close_success")),g(),O()})},ms=()=>{W?.user&&r("/finance/order?user_id="+W.user.id)},ze=W?.status===tt.CLOSED;return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(cs,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(oe,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(me,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 z-50 md:hidden",onClick:()=>w(!P),children:e.jsx(Fr,{className:_("h-4 w-4 transition-transform",!P&&"rotate-180")})}),e.jsxs("div",{className:_("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",P?"-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(G,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 md:flex",onClick:()=>w(!P),children:e.jsx(Fr,{className:_("h-4 w-4 transition-transform",!P&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Bg,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(D,{placeholder:t("list.search_placeholder"),value:T,onChange:le=>C(le.target.value),className:"pl-8"})]})]}),e.jsx(jt,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:S?e.jsx(Jg,{}):ae.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(T?"list.no_search_results":"list.no_tickets")}):ae.map(le=>e.jsx(Qg,{ticket:le,isActive:le.id===p,onClick:()=>{F(le.id),window.innerWidth<768&&w(!0)}},le.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!P&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>w(!0)}),k?e.jsx(Yg,{}):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:W?.subject}),e.jsx(U,{variant:ze?"secondary":"default",children:t(ze?"status.closed":"status.processing")}),!ze&&e.jsx(hs,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:je,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(Hi,{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(Ma,{className:"h-4 w-4"}),e.jsx("span",{children:W?.user?.email})]}),e.jsx(Re,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Ki,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",ne(W?.created_at)]})]}),e.jsx(Re,{orientation:"vertical",className:"h-4"}),e.jsx(U,{variant:"outline",children:W?.level!=null&&t(`level.${W.level===us.LOW?"low":W.level===us.MIDDLE?"medium":"high"}`)})]})]}),W?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.user_info"),onClick:()=>{y(W.user),I(!0)},children:e.jsx(Ma,{className:"h-4 w-4"})}),e.jsx(Mi,{user_id:W.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Gg,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:ms,children:e.jsx(Wg,{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:W?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):W?.messages?.map(le=>e.jsx(Ai,{variant:le.is_from_admin?"sent":"received",className:le.is_from_admin?"ml-auto":"mr-auto",children:e.jsx(qi,{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:ne(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(Ui,{ref:o,disabled:ze||i,placeholder:t(ze?"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:x,onChange:le=>u(le.target.value),onKeyDown:le=>{le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),se())}}),e.jsx(G,{disabled:ze||i||!x.trim(),onClick:se,children:t(i?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const Zg=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"})}),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:"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"})}),sp=s=>{const{t:n}=V("ticket");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.subject")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Zg,{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(z,{column:t,title:n("columns.level")}),cell:({row:t})=>{const r=t.getValue("level"),a=r===us.LOW?"default":r===us.MIDDLE?"secondary":"destructive";return e.jsx(U,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===us.LOW?"low":r===us.MIDDLE?"medium":"high"}`)})},filterFn:(t,r,a)=>a.includes(t.getValue(r))},{accessorKey:"status",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.status")}),cell:({row:t})=>{const r=t.getValue("status"),a=t.original.reply_status,o=r===tt.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===tt.CLOSED?"default":a===0?"secondary":"destructive";return e.jsx(U,{variant:l,className:"whitespace-nowrap",children:o})}},{accessorKey:"updated_at",header:({column:t})=>e.jsx(z,{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(Ki,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ne(t.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const r=t.original.status!==tt.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Xg,{ticketId:t.original.id,dialogTrigger:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(ep,{className:"h-4 w-4"})})}),r&&e.jsx(hs,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),cancelText:n("common:cancel"),variant:"destructive",onConfirm:async()=>{Pt.close(t.original.id).then(()=>{$.success(n("actions.close_success")),s()})},children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(Hi,{className:"h-4 w-4"})})})]})}}]};function tp(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,o]=m.useState([{id:"status",value:"0"}]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:i,data:c}=re({queryKey:["orderList",x,a,l],queryFn:()=>Pt.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:a,sort:l})}),p=Ye({data:c?.data??[],columns:sp(i),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:o,onColumnVisibilityChange:r,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:u,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ag,{table:p,refetch:i}),e.jsx(rs,{table:p,showPagination:!0})]})}function ap(){const{t:s}=V("ticket");return e.jsxs(zi,{refreshData:()=>{},children:[e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(tp,{})})]})]}),e.jsx($i,{})]})}const np=Object.freeze(Object.defineProperty({__proto__:null,default:ap},Symbol.toStringTag,{value:"Module"}));function rp({table:s,refetch:n}){const{t}=V("user"),r=s.getState().columnFilters.length>0,[a,o]=m.useState(),[l,d]=m.useState(),[x,u]=m.useState(!1),i=[{value:"monthly",label:t("traffic_reset_logs.filters.reset_types.monthly")},{value:"first_day_month",label:t("traffic_reset_logs.filters.reset_types.first_day_month")},{value:"yearly",label:t("traffic_reset_logs.filters.reset_types.yearly")},{value:"first_day_year",label:t("traffic_reset_logs.filters.reset_types.first_day_year")},{value:"manual",label:t("traffic_reset_logs.filters.reset_types.manual")}],c=[{value:"auto",label:t("traffic_reset_logs.filters.trigger_sources.auto")},{value:"manual",label:t("traffic_reset_logs.filters.trigger_sources.manual")},{value:"cron",label:t("traffic_reset_logs.filters.trigger_sources.cron")}],p=()=>{let P=s.getState().columnFilters.filter(w=>w.id!=="date_range");(a||l)&&P.push({id:"date_range",value:{start:a?Ee(a,"yyyy-MM-dd"):null,end:l?Ee(l,"yyyy-MM-dd"):null}}),s.setColumnFilters(P)},F=async()=>{try{u(!0);const P=s.getState().columnFilters.reduce((g,k)=>{if(k.value)if(k.id==="date_range"){const W=k.value;W.start&&(g.start_date=W.start),W.end&&(g.end_date=W.end)}else g[k.id]=k.value;return g},{}),I=(await la.getLogs({...P,page:1,per_page:1e4})).data.map(g=>({ID:g.id,用户邮箱:g.user_email,用户ID:g.user_id,重置类型:g.reset_type_name,触发源:g.trigger_source_name,清零流量:g.old_traffic.formatted,"上传流量(GB)":(g.old_traffic.upload/1024**3).toFixed(2),"下载流量(GB)":(g.old_traffic.download/1024**3).toFixed(2),重置时间:Ee(new Date(g.reset_time),"yyyy-MM-dd HH:mm:ss"),记录时间:Ee(new Date(g.created_at),"yyyy-MM-dd HH:mm:ss"),原因:g.reason||""})),y=Object.keys(I[0]||{}),N=[y.join(","),...I.map(g=>y.map(k=>{const W=g[k];return typeof W=="string"&&W.includes(",")?`"${W}"`:W}).join(","))].join(` -`),S=new Blob([N],{type:"text/csv;charset=utf-8;"}),O=document.createElement("a"),E=URL.createObjectURL(S);O.setAttribute("href",E),O.setAttribute("download",`traffic-reset-logs-${Ee(new Date,"yyyy-MM-dd")}.csv`),O.style.visibility="hidden",document.body.appendChild(O),O.click(),document.body.removeChild(O),$.success(t("traffic_reset_logs.actions.export_success"))}catch(C){console.error("导出失败:",C),$.error(t("traffic_reset_logs.actions.export_failed"))}finally{u(!1)}},T=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.search_user")}),e.jsx(D,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:C=>s.getColumn("user_email")?.setFilterValue(C.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.reset_type")}),e.jsxs(X,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:C=>s.getColumn("reset_type")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-9",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),i.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.trigger_source")}),e.jsxs(X,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:C=>s.getColumn("trigger_source")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-9",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.start_date")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:_("h-9 w-full justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),a?Ee(a,"MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:a,onSelect:o,initialFocus:!0})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.end_date")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:_("h-9 w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),l?Ee(l,"MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]})]})]}),(a||l)&&e.jsxs(L,{variant:"outline",className:"w-full",onClick:p,children:[e.jsx(ur,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]}),r&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),o(void 0),d(void 0)},className:"w-full",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between md:hidden",children:[e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(Jn,{children:[e.jsx(Li,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(Pd,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.reset_type"),r&&e.jsx("div",{className:"ml-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:s.getState().columnFilters.length})]})}),e.jsxs(nn,{side:"bottom",className:"h-[85vh]",children:[e.jsxs(rn,{className:"mb-4",children:[e.jsx(ln,{children:t("traffic_reset_logs.filters.filter_title")}),e.jsx(on,{children:t("traffic_reset_logs.filters.filter_description")})]}),e.jsx("div",{className:"max-h-[calc(85vh-120px)] overflow-y-auto",children:e.jsx(T,{})})]})]})}),e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",onClick:F,disabled:x,children:[e.jsx(ta,{className:"mr-2 h-4 w-4"}),t(x?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})]}),e.jsxs("div",{className:"hidden items-center justify-between md:flex",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(D,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:C=>s.getColumn("user_email")?.setFilterValue(C.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(X,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:C=>s.getColumn("reset_type")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-8 w-[180px]",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),i.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]}),e.jsxs(X,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:C=>s.getColumn("trigger_source")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-8 w-[180px]",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:_("h-8 w-[140px] justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),a?Ee(a,"yyyy-MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:a,onSelect:o,initialFocus:!0})})]}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:_("h-8 w-[140px] justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),l?Ee(l,"yyyy-MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]}),(a||l)&&e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",onClick:p,children:[e.jsx(ur,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]})]}),r&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),o(void 0),d(void 0)},className:"h-8 px-2 lg:px-3",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",onClick:F,disabled:x,children:[e.jsx(ta,{className:"mr-2 h-4 w-4"}),t(x?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})})]})]})}const lp=()=>{const{t:s}=V("user"),n=a=>{switch(a){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";case"first_day_month":return"bg-orange-100 text-orange-800 border-orange-200";case"first_day_year":return"bg-indigo-100 text-indigo-800 border-indigo-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},t=a=>{switch(a){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},r=a=>{switch(a){case"manual":return e.jsx(Pa,{className:"h-3 w-3"});case"cron":return e.jsx(Rd,{className:"h-3 w-3"});case"auto":return e.jsx(Ld,{className:"h-3 w-3"});default:return e.jsx(Pa,{className:"h-3 w-3"})}};return[{accessorKey:"id",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.id"),className:"w-[60px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[60px]",children:e.jsx(U,{variant:"outline",className:"text-xs",children:a.original.id})}),enableSorting:!0,enableHiding:!0,size:60},{accessorKey:"user_email",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.user"),className:"min-w-[200px]"}),cell:({row:a})=>e.jsxs("div",{className:"flex min-w-[200px] items-start gap-2",children:[e.jsx($l,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:a.original.user_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",a.original.user_id]})]})]}),enableSorting:!1,enableHiding:!1,size:100},{accessorKey:"trigger_source",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.trigger_source"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:e.jsxs(U,{variant:"outline",className:_("flex items-center gap-1.5 border text-xs",t(a.original.trigger_source)),children:[r(a.original.trigger_source),e.jsx("span",{className:"truncate",children:a.original.trigger_source_name})]})})}),e.jsx(ce,{side:"bottom",className:"max-w-[200px]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:a.original.trigger_source_name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[a.original.trigger_source==="manual"&&s("traffic_reset_logs.trigger_descriptions.manual"),a.original.trigger_source==="cron"&&s("traffic_reset_logs.trigger_descriptions.cron"),a.original.trigger_source==="auto"&&s("traffic_reset_logs.trigger_descriptions.auto"),!["manual","cron","auto"].includes(a.original.trigger_source)&&s("traffic_reset_logs.trigger_descriptions.other")]})]})})]})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,o,l)=>l.includes(a.getValue(o)),size:120},{accessorKey:"reset_type",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.reset_type"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(U,{className:_("border text-xs",n(a.original.reset_type)),children:e.jsx("span",{className:"truncate",children:a.original.reset_type_name})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,o,l)=>l.includes(a.getValue(o)),size:120},{accessorKey:"old_traffic",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.cleared_traffic"),className:"w-[120px]"}),cell:({row:a})=>{const o=a.original.old_traffic;return e.jsx("div",{className:"w-[120px]",children:e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"cursor-pointer text-center",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:o.formatted}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("traffic_reset_logs.columns.cleared")})]})}),e.jsxs(ce,{side:"bottom",className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Rt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.upload"),":"," ",(o.upload/1024**3).toFixed(2)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ta,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.download"),":"," ",(o.download/1024**3).toFixed(2)," GB"]})]})]})]})})})},enableSorting:!1,enableHiding:!1,size:120},{accessorKey:"reset_time",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.reset_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Jt,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ne(a.original.reset_time,"MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne(a.original.reset_time,"HH:mm")})]})]})}),enableSorting:!0,enableHiding:!0,size:140},{accessorKey:"created_at",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.log_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(An,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ne(a.original.created_at,"YYYY-MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne(a.original.created_at,"H:m:s")})]})]})}),enableSorting:!0,enableHiding:!1,size:1400}]};function ip(){const[s,n]=m.useState({}),[t,r]=m.useState({reset_time:!1}),[a,o]=m.useState([]),[l,d]=m.useState([{id:"created_at",desc:!0}]),[x,u]=m.useState({pageIndex:0,pageSize:20}),i={page:x.pageIndex+1,per_page:x.pageSize,...a.reduce((T,C)=>{if(C.value)if(C.id==="date_range"){const P=C.value;P.start&&(T.start_date=P.start),P.end&&(T.end_date=P.end)}else T[C.id]=C.value;return T},{})},{refetch:c,data:p,isLoading:F}=re({queryKey:["trafficResetLogs",x,a,l],queryFn:()=>la.getLogs(i)});return e.jsx(op,{data:p?.data??[],rowCount:p?.total??0,sorting:l,setSorting:d,columnVisibility:t,setColumnVisibility:r,rowSelection:s,setRowSelection:n,columnFilters:a,setColumnFilters:o,pagination:x,setPagination:u,refetch:c,isLoading:F})}function op({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:o,rowSelection:l,setRowSelection:d,columnFilters:x,setColumnFilters:u,pagination:i,setPagination:c,refetch:p,isLoading:F}){const T=Ye({data:s,columns:lp(),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:x,pagination:i},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:u,onColumnVisibilityChange:o,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:c,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnVisibility:{reset_time:!1}}});return e.jsxs("div",{className:"h-full space-y-4",children:[e.jsx(rp,{table:T,refetch:p}),e.jsx(rs,{table:T,isLoading:F})]})}function cp(){const{t:s}=V("user");return e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ds,{})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-4 space-y-2 md:mb-2 md:flex md:items-center md:justify-between md:space-y-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight md:text-2xl",children:s("traffic_reset_logs.title")}),e.jsx("p",{className:"text-sm text-muted-foreground md:mt-2",children:s("traffic_reset_logs.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-hidden px-4 py-1",children:e.jsx("div",{className:"h-full w-full",children:e.jsx(ip,{})})})]})]})}const dp=Object.freeze(Object.defineProperty({__proto__:null,default:cp},Symbol.toStringTag,{value:"Module"}));export{we as _,pp as a,hp as c,gp as g,fp as r}; +`+a("columns.online_status.offline_duration.seconds",{count:x})}const[o,c]=Ta.useState(!1),p=i.original.email;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsxs("div",{className:"group flex items-center gap-2.5",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[e.jsx("div",{className:_("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(Sg,{user:i.original,trigger:e.jsx("span",{className:"cursor-pointer font-medium text-foreground/90 transition-colors hover:text-primary hover:underline",children:p})}),e.jsx("button",{type:"button",className:_("ml-1 rounded bg-transparent p-1 transition-opacity hover:bg-muted",o?"opacity-100":"pointer-events-none opacity-0","group-hover:pointer-events-auto group-hover:opacity-100"),tabIndex:-1,"aria-label":a("columns.actions_menu.copy_email",{defaultValue:"Copy Email"}),onClick:F=>{F.stopPropagation(),Zs(p),$.success(a("common:copy.success"))},style:{lineHeight:0},children:e.jsx(An,{className:"h-4 w-4 text-muted-foreground"})})]})}),e.jsx(ce,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:u})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(z,{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(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(U,{variant:"outline",className:_("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(z,{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(U,{className:_("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(z,{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(z,{column:i,title:a("columns.group")}),cell:({row:i})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(U,{variant:"outline",className:_("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(z,{column:i,title:a("columns.used_traffic")}),cell:({row:i})=>{const l=Le(i.original?.total_used),d=Le(i.original?.transfer_enable),x=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{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:[x.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:_("h-full rounded-full transition-all",x>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(x,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(z,{column:i,title:a("columns.total_traffic")}),cell:({row:i})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:Le(i.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:i})=>e.jsx(z,{column:i,title:a("columns.expire_time")}),cell:({row:i})=>{const l=i.original.expired_at,d=Date.now()/1e3,x=l!=null&&le.jsx(z,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=pr(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(z,{column:i,title:a("columns.commission")}),cell:({row:i})=>{const l=pr(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(z,{column:i,title:a("columns.register_time")}),cell:({row:i})=>e.jsx("div",{className:"truncate",children:ne(i.original?.created_at)}),size:1e3},{id:"actions",header:({column:i})=>e.jsx(z,{column:i,className:"justify-end",title:a("columns.actions")}),cell:({row:i,table:l})=>e.jsxs(Hs,{modal:!1,children:[e.jsx(Gs,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(G,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Ea,{className:"size-4"})})})}),e.jsxs(qs,{align:"end",className:"min-w-[40px]",children:[e.jsx(Se,{onSelect:d=>{d.preventDefault(),t(i.original),r(!0)},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(kg,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Si,{defaultValues:{email:i.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Tg,{className:"mr-2"}),a("columns.actions_menu.assign_order")]})})}),e.jsx(Se,{onSelect:()=>{Zs(i.original.subscribe_url).then(()=>{$.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Dg,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsxs(Se,{className:"",onSelect:()=>{Us.resetSecret(i.original.id).then(({data:d})=>{d&&$.success("重置成功")})},children:[e.jsx(Dr,{className:"mr-4"}),a("columns.actions_menu.reset_secret")]}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(G,{variant:"ghost",className:"h-auto w-full justify-start px-2 py-1.5 font-normal",asChild:!0,children:e.jsxs(Bs,{to:`/finance/order?user_id=eq:${i.original.id}`,children:[e.jsx(Fg,{className:"mr-2"}),a("columns.actions_menu.orders")]})})}),e.jsxs(Se,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:[e.jsx(Pg,{className:"mr-4"}),a("columns.actions_menu.invites")]}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Mi,{user_id:i.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Lg,{className:"mr-2"}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Ng,{user:i.original,onSuccess:s,trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Dr,{className:"mr-2"}),a("columns.actions_menu.reset_traffic")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(wg,{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 Us.destroy(i.original.id);d&&($.success(a("common:delete.success")),s())}catch{$.error(a("common:delete.failed"))}},children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5 text-destructive hover:text-destructive",children:[e.jsx(Rg,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},Oi=m.createContext(void 0),Xn=()=>{const s=m.useContext(Oi);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},zi=({children:s,refreshData:n})=>{const[t,r]=m.useState(!1),[a,i]=m.useState(null),l={isOpen:t,setIsOpen:r,editingUser:a,setEditingUser:i,refreshData:n};return e.jsx(Oi.Provider,{value:l,children:s})},Ig=h.object({id:h.number().default(0),email:h.string().email().default(""),invite_user_email:h.string().email().nullable().optional().default(null),password:h.string().optional().nullable().default(null),balance:h.coerce.number().default(0),commission_balance:h.coerce.number().default(0),u:h.coerce.number().default(0),d:h.coerce.number().default(0),transfer_enable:h.number().default(0),expired_at:h.number().nullable().default(null),plan_id:h.number().nullable().default(null),banned:h.boolean().default(!1),commission_type:h.number().default(0),commission_rate:h.number().nullable().default(null),discount:h.number().nullable().default(null),speed_limit:h.number().nullable().default(null),device_limit:h.number().nullable().default(null),is_admin:h.boolean().default(!1),is_staff:h.boolean().default(!1),remarks:h.string().nullable().default(null)});function $i(){const{t:s}=V("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=Xn(),[i,l]=m.useState(!1),[d,x]=m.useState([]),u=Ce({resolver:Te(Ig)});return m.useEffect(()=>{n&&_s.getList().then(({data:o})=>{x(o)})},[n]),m.useEffect(()=>{if(r){const o=r.invite_user?.email,{invite_user:c,...p}=r;u.reset({...p,invite_user_email:o||null,password:null,u:p.u?(p.u/1024/1024/1024).toFixed(3):"",d:p.d?(p.d/1024/1024/1024).toFixed(3):""})}},[r,u]),e.jsx(Qn,{open:n,onOpenChange:t,children:e.jsxs(rn,{className:"max-w-[90%] space-y-4",children:[e.jsxs(ln,{children:[e.jsx(on,{children:s("edit.title")}),e.jsx(cn,{})]}),e.jsxs(De,{...u,children:[e.jsx(j,{control:u.control,name:"email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.email")}),e.jsx(b,{children:e.jsx(D,{...o,placeholder:s("edit.form.email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsx(j,{control:u.control,name:"invite_user_email",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.inviter_email")}),e.jsx(b,{children:e.jsx(D,{value:o.value||"",onChange:c=>o.onChange(c.target.value?c.target.value:null),placeholder:s("edit.form.inviter_email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsx(j,{control:u.control,name:"password",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.password")}),e.jsx(b,{children:e.jsx(D,{type:"password",value:o.value||"",onChange:o.onChange,placeholder:s("edit.form.password_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(j,{control:u.control,name:"balance",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.balance")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.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(R,{...o})]})}),e.jsx(j,{control:u.control,name:"commission_balance",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.commission_balance")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.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(R,{...o})]})}),e.jsx(j,{control:u.control,name:"u",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.upload")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",step:"any",value:o.value??"",onChange:c=>o.onChange(c.target.value),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(R,{...o})]})}),e.jsx(j,{control:u.control,name:"d",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.download")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",step:"any",value:o.value??"",onChange:c=>o.onChange(c.target.value),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(R,{...o})]})})]}),e.jsx(j,{control:u.control,name:"transfer_enable",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.total_traffic")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value/1024/1024/1024||"",onChange:c=>o.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"expired_at",render:({field:o})=>e.jsxs(f,{className:"flex flex-col",children:[e.jsx(v,{children:s("edit.form.expire_time")}),e.jsxs(es,{open:i,onOpenChange:l,children:[e.jsx(ss,{asChild:!0,children:e.jsx(b,{children:e.jsxs(L,{type:"button",variant:"outline",className:_("w-full pl-3 text-left font-normal",!o.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[o.value?ne(o.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(Ss,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:c=>{c.preventDefault()},onEscapeKeyDown:c=>{c.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(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{o.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+1),c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+3),c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(ks,{mode:"single",selected:o.value?new Date(o.value*1e3):void 0,onSelect:c=>{if(c){const p=new Date(o.value?o.value*1e3:Date.now());c.setHours(p.getHours(),p.getMinutes(),p.getSeconds()),o.onChange(Math.floor(c.getTime()/1e3))}},disabled:c=>c{const c=new Date;c.setHours(23,59,59,999),o.onChange(Math.floor(c.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(D,{type:"datetime-local",step:"1",value:ne(o.value,"YYYY-MM-DDTHH:mm:ss"),onChange:c=>{const p=new Date(c.target.value);isNaN(p.getTime())||o.onChange(Math.floor(p.getTime()/1e3))},className:"flex-1"}),e.jsx(L,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(R,{})]})}),e.jsx(j,{control:u.control,name:"plan_id",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.subscription")}),e.jsx(b,{children:e.jsxs(X,{value:o.value!==null?String(o.value):"null",onValueChange:c=>o.onChange(c==="null"?null:parseInt(c)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"null",children:s("edit.form.subscription_none")}),d.map(c=>e.jsx(q,{value:String(c.id),children:c.name},c.id))]})]})})]})}),e.jsx(j,{control:u.control,name:"banned",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.account_status")}),e.jsx(b,{children:e.jsxs(X,{value:o.value.toString(),onValueChange:c=>o.onChange(c==="true"),children:[e.jsx(J,{children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(q,{value:"true",children:s("columns.status_text.banned")}),e.jsx(q,{value:"false",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(j,{control:u.control,name:"commission_type",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.commission_type")}),e.jsx(b,{children:e.jsxs(X,{value:o.value.toString(),onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(J,{children:e.jsx(Z,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx(q,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx(q,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(j,{control:u.control,name:"commission_rate",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.commission_rate")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.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(j,{control:u.control,name:"discount",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.discount")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"speed_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.speed_limit")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"device_limit",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.device_limit")}),e.jsx(b,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.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(R,{})]})}),e.jsx(j,{control:u.control,name:"is_admin",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:o.value,onCheckedChange:c=>o.onChange(c)})})}),e.jsx(R,{})]})}),e.jsx(j,{control:u.control,name:"is_staff",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(b,{children:e.jsx(ee,{checked:o.value,onCheckedChange:c=>o.onChange(c)})})})]})}),e.jsx(j,{control:u.control,name:"remarks",render:({field:o})=>e.jsxs(f,{children:[e.jsx(v,{children:s("edit.form.remarks")}),e.jsx(b,{children:e.jsx(Es,{className:"h-24",value:o.value||"",onChange:c=>o.onChange(c.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(R,{})]})}),e.jsxs(Ei,{children:[e.jsx(L,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(L,{type:"submit",onClick:()=>{u.handleSubmit(o=>{const c={id:o.id};u.formState.dirtyFields.u&&(c.u=Math.round(parseFloat(o.u)*1024*1024*1024)),u.formState.dirtyFields.d&&(c.d=Math.round(parseFloat(o.d)*1024*1024*1024)),Object.keys(o).forEach(p=>{p!=="u"&&p!=="d"&&p!=="id"&&u.formState.dirtyFields[p]&&(c[p]=o[p])}),Us.update(c).then(({data:p})=>{p&&($.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function Vg(){const[s]=Ml(),[n,t]=m.useState({}),[r,a]=m.useState({is_admin:!1,is_staff:!1}),[i,l]=m.useState([]),[d,x]=m.useState([]),[u,o]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const w=s.get("email");w&&l(S=>S.some(E=>E.id==="email")?S:[...S,{id:"email",value:w}])},[s]);const{refetch:c,data:p,isLoading:F}=re({queryKey:["userList",u,i,d],queryFn:()=>Us.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:i,sort:d})}),[T,C]=m.useState([]),[P,N]=m.useState([]);m.useEffect(()=>{Nt.getList().then(({data:w})=>{C(w)}),_s.getList().then(({data:w})=>{N(w)})},[]);const I=T.map(w=>({label:w.name,value:w.id})),y=P.map(w=>({label:w.name,value:w.id}));return e.jsxs(zi,{refreshData:c,children:[e.jsx(Mg,{data:p?.data||[],rowCount:p?.total??0,sorting:d,setSorting:x,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:u,setPagination:o,refetch:c,serverGroupList:T,permissionGroups:I,subscriptionPlans:y,isLoading:F}),e.jsx($i,{})]})}function Mg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:x,setColumnFilters:u,pagination:o,setPagination:c,refetch:p,serverGroupList:F,permissionGroups:T,subscriptionPlans:C,isLoading:P}){const{setIsOpen:N,setEditingUser:I}=Xn(),y=Ye({data:s,columns:Eg(p,F,I,N),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:x,pagination:o},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:u,onColumnVisibilityChange:i,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:c,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),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(bg,{table:y,refetch:p,serverGroupList:F,permissionGroups:T,subscriptionPlans:C}),e.jsx(rs,{table:y,isLoading:P})]})}function Og(){const{t:s}=V("user");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(Vg,{})})})]})]})}const zg=Object.freeze(Object.defineProperty({__proto__:null,default:Og},Symbol.toStringTag,{value:"Module"})),$g=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 Ag({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(_t,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(it,{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(za,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:us.LOW,icon:$g,color:"gray"},{label:n("level.medium"),value:us.MIDDLE,icon:Ii,color:"yellow"},{label:n("level.high"),value:us.HIGH,icon:Vi,color:"red"}]})]})})}function qg(){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 Ug=bt("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"}}),Ai=m.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:_(Ug({variant:n,layout:t,className:s}),"relative group"),ref:i,...a,children:m.Children.map(r,l=>m.isValidElement(l)&&typeof l.type!="string"?m.cloneElement(l,{variant:n,layout:t}):l)}));Ai.displayName="ChatBubble";const Hg=bt("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"}}),qi=m.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:_(Hg({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(qg,{})}):a}));qi.displayName="ChatBubbleMessage";const Kg=m.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:_("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}));Kg.displayName="ChatBubbleActionWrapper";const Ui=m.forwardRef(({className:s,...n},t)=>e.jsx(Es,{autoComplete:"off",ref:t,name:"message",className:_("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}));Ui.displayName="ChatInput";const Hi=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"})}),Ki=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"})}),Fr=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"})}),Bg=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"})}),Gg=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"})}),Wg=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 Yg(){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(be,{className:"h-8 w-3/4"}),e.jsx(be,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(be,{className:"h-20 w-2/3"},s))})]})}function Jg(){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(be,{className:"h-5 w-4/5"}),e.jsx(be,{className:"h-4 w-2/3"}),e.jsx(be,{className:"h-3 w-1/2"})]},s))})}function Qg({ticket:s,isActive:n,onClick:t}){const{t:r}=V("ticket"),a=i=>{switch(i){case us.HIGH:return"bg-red-50 text-red-600 border-red-200";case us.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case us.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:_("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(U,{variant:s.status===at.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===at.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:ne(s.updated_at)}),e.jsx("div",{className:_("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===us.LOW?"low":s.level===us.MIDDLE?"medium":"high"}`)})]})]})}function Xg({ticketId:s,dialogTrigger:n}){const{t}=V("ticket"),r=Ws(),a=m.useRef(null),i=m.useRef(null),[l,d]=m.useState(!1),[x,u]=m.useState(""),[o,c]=m.useState(!1),[p,F]=m.useState(s),[T,C]=m.useState(""),[P,N]=m.useState(!1),{setIsOpen:I,setEditingUser:y}=Xn(),{data:w,isLoading:S,refetch:O}=re({queryKey:["tickets",l],queryFn:()=>l?Lt.getList({filter:[{id:"status",value:[at.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:E,refetch:g,isLoading:k}=re({queryKey:["ticket",p,l],queryFn:()=>l?Lt.getInfo(p):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),W=E?.data,ae=(w?.data||[]).filter(le=>le.subject.toLowerCase().includes(T.toLowerCase())||le.user?.email.toLowerCase().includes(T.toLowerCase())),B=(le="smooth")=>{if(a.current){const{scrollHeight:Ts,clientHeight:Ns}=a.current;a.current.scrollTo({top:Ts-Ns,behavior:le})}};m.useEffect(()=>{if(!l)return;const le=requestAnimationFrame(()=>{B("instant"),setTimeout(()=>B(),1e3)});return()=>{cancelAnimationFrame(le)}},[l,W?.messages]);const se=async()=>{const le=x.trim();!le||o||(c(!0),Lt.reply({id:p,message:le}).then(()=>{u(""),g(),B(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{c(!1)}))},je=async()=>{Lt.close(p).then(()=>{$.success(t("actions.close_success")),g(),O()})},ms=()=>{W?.user&&r("/finance/order?user_id="+W.user.id)},ze=W?.status===at.CLOSED;return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(cs,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(oe,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(me,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 z-50 md:hidden",onClick:()=>N(!P),children:e.jsx(Fr,{className:_("h-4 w-4 transition-transform",!P&&"rotate-180")})}),e.jsxs("div",{className:_("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",P?"-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(G,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 md:flex",onClick:()=>N(!P),children:e.jsx(Fr,{className:_("h-4 w-4 transition-transform",!P&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Bg,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(D,{placeholder:t("list.search_placeholder"),value:T,onChange:le=>C(le.target.value),className:"pl-8"})]})]}),e.jsx(vt,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:S?e.jsx(Jg,{}):ae.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(T?"list.no_search_results":"list.no_tickets")}):ae.map(le=>e.jsx(Qg,{ticket:le,isActive:le.id===p,onClick:()=>{F(le.id),window.innerWidth<768&&N(!0)}},le.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!P&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>N(!0)}),k?e.jsx(Yg,{}):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:W?.subject}),e.jsx(U,{variant:ze?"secondary":"default",children:t(ze?"status.closed":"status.processing")}),!ze&&e.jsx(hs,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:je,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(Hi,{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(Oa,{className:"h-4 w-4"}),e.jsx("span",{children:W?.user?.email})]}),e.jsx(Re,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Ki,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",ne(W?.created_at)]})]}),e.jsx(Re,{orientation:"vertical",className:"h-4"}),e.jsx(U,{variant:"outline",children:W?.level!=null&&t(`level.${W.level===us.LOW?"low":W.level===us.MIDDLE?"medium":"high"}`)})]})]}),W?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.user_info"),onClick:()=>{y(W.user),I(!0)},children:e.jsx(Oa,{className:"h-4 w-4"})}),e.jsx(Mi,{user_id:W.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Gg,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:ms,children:e.jsx(Wg,{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:W?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):W?.messages?.map(le=>e.jsx(Ai,{variant:le.is_from_admin?"sent":"received",className:le.is_from_admin?"ml-auto":"mr-auto",children:e.jsx(qi,{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:ne(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(Ui,{ref:i,disabled:ze||o,placeholder:t(ze?"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:x,onChange:le=>u(le.target.value),onKeyDown:le=>{le.key==="Enter"&&!le.shiftKey&&(le.preventDefault(),se())}}),e.jsx(G,{disabled:ze||o||!x.trim(),onClick:se,children:t(o?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const Zg=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"})}),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:"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"})}),sp=s=>{const{t:n}=V("ticket");return[{accessorKey:"id",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.subject")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Zg,{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(z,{column:t,title:n("columns.level")}),cell:({row:t})=>{const r=t.getValue("level"),a=r===us.LOW?"default":r===us.MIDDLE?"secondary":"destructive";return e.jsx(U,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===us.LOW?"low":r===us.MIDDLE?"medium":"high"}`)})},filterFn:(t,r,a)=>a.includes(t.getValue(r))},{accessorKey:"status",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.status")}),cell:({row:t})=>{const r=t.getValue("status"),a=t.original.reply_status,i=r===at.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===at.CLOSED?"default":a===0?"secondary":"destructive";return e.jsx(U,{variant:l,className:"whitespace-nowrap",children:i})}},{accessorKey:"updated_at",header:({column:t})=>e.jsx(z,{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(Ki,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ne(t.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(z,{column:t,title:n("columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ne(t.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const r=t.original.status!==at.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Xg,{ticketId:t.original.id,dialogTrigger:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(ep,{className:"h-4 w-4"})})}),r&&e.jsx(hs,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),cancelText:n("common:cancel"),variant:"destructive",onConfirm:async()=>{Lt.close(t.original.id).then(()=>{$.success(n("actions.close_success")),s()})},children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(Hi,{className:"h-4 w-4"})})})]})}}]};function tp(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([{id:"status",value:"0"}]),[l,d]=m.useState([]),[x,u]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=re({queryKey:["orderList",x,a,l],queryFn:()=>Lt.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:a,sort:l})}),p=Ye({data:c?.data??[],columns:sp(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:x},rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:u,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ag,{table:p,refetch:o}),e.jsx(rs,{table:p,showPagination:!0})]})}function ap(){const{t:s}=V("ticket");return e.jsxs(zi,{refreshData:()=>{},children:[e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(ds,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{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(tp,{})})]})]}),e.jsx($i,{})]})}const np=Object.freeze(Object.defineProperty({__proto__:null,default:ap},Symbol.toStringTag,{value:"Module"}));function rp({table:s,refetch:n}){const{t}=V("user"),r=s.getState().columnFilters.length>0,[a,i]=m.useState(),[l,d]=m.useState(),[x,u]=m.useState(!1),o=[{value:"monthly",label:t("traffic_reset_logs.filters.reset_types.monthly")},{value:"first_day_month",label:t("traffic_reset_logs.filters.reset_types.first_day_month")},{value:"yearly",label:t("traffic_reset_logs.filters.reset_types.yearly")},{value:"first_day_year",label:t("traffic_reset_logs.filters.reset_types.first_day_year")},{value:"manual",label:t("traffic_reset_logs.filters.reset_types.manual")}],c=[{value:"auto",label:t("traffic_reset_logs.filters.trigger_sources.auto")},{value:"manual",label:t("traffic_reset_logs.filters.trigger_sources.manual")},{value:"cron",label:t("traffic_reset_logs.filters.trigger_sources.cron")}],p=()=>{let P=s.getState().columnFilters.filter(N=>N.id!=="date_range");(a||l)&&P.push({id:"date_range",value:{start:a?Ee(a,"yyyy-MM-dd"):null,end:l?Ee(l,"yyyy-MM-dd"):null}}),s.setColumnFilters(P)},F=async()=>{try{u(!0);const P=s.getState().columnFilters.reduce((g,k)=>{if(k.value)if(k.id==="date_range"){const W=k.value;W.start&&(g.start_date=W.start),W.end&&(g.end_date=W.end)}else g[k.id]=k.value;return g},{}),I=(await la.getLogs({...P,page:1,per_page:1e4})).data.map(g=>({ID:g.id,用户邮箱:g.user_email,用户ID:g.user_id,重置类型:g.reset_type_name,触发源:g.trigger_source_name,清零流量:g.old_traffic.formatted,"上传流量(GB)":(g.old_traffic.upload/1024**3).toFixed(2),"下载流量(GB)":(g.old_traffic.download/1024**3).toFixed(2),重置时间:Ee(new Date(g.reset_time),"yyyy-MM-dd HH:mm:ss"),记录时间:Ee(new Date(g.created_at),"yyyy-MM-dd HH:mm:ss"),原因:g.reason||""})),y=Object.keys(I[0]||{}),w=[y.join(","),...I.map(g=>y.map(k=>{const W=g[k];return typeof W=="string"&&W.includes(",")?`"${W}"`:W}).join(","))].join(` +`),S=new Blob([w],{type:"text/csv;charset=utf-8;"}),O=document.createElement("a"),E=URL.createObjectURL(S);O.setAttribute("href",E),O.setAttribute("download",`traffic-reset-logs-${Ee(new Date,"yyyy-MM-dd")}.csv`),O.style.visibility="hidden",document.body.appendChild(O),O.click(),document.body.removeChild(O),$.success(t("traffic_reset_logs.actions.export_success"))}catch(C){console.error("导出失败:",C),$.error(t("traffic_reset_logs.actions.export_failed"))}finally{u(!1)}},T=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.search_user")}),e.jsx(D,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:C=>s.getColumn("user_email")?.setFilterValue(C.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.reset_type")}),e.jsxs(X,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:C=>s.getColumn("reset_type")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-9",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),o.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.trigger_source")}),e.jsxs(X,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:C=>s.getColumn("trigger_source")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-9",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.start_date")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:_("h-9 w-full justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),a?Ee(a,"MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.end_date")}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:_("h-9 w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),l?Ee(l,"MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]})]})]}),(a||l)&&e.jsxs(L,{variant:"outline",className:"w-full",onClick:p,children:[e.jsx(ur,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]}),r&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"w-full",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between md:hidden",children:[e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(Qn,{children:[e.jsx(Li,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(Pd,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.reset_type"),r&&e.jsx("div",{className:"ml-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:s.getState().columnFilters.length})]})}),e.jsxs(rn,{side:"bottom",className:"h-[85vh]",children:[e.jsxs(ln,{className:"mb-4",children:[e.jsx(on,{children:t("traffic_reset_logs.filters.filter_title")}),e.jsx(cn,{children:t("traffic_reset_logs.filters.filter_description")})]}),e.jsx("div",{className:"max-h-[calc(85vh-120px)] overflow-y-auto",children:e.jsx(T,{})})]})]})}),e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",onClick:F,disabled:x,children:[e.jsx(ta,{className:"mr-2 h-4 w-4"}),t(x?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})]}),e.jsxs("div",{className:"hidden items-center justify-between md:flex",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(D,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:C=>s.getColumn("user_email")?.setFilterValue(C.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(X,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:C=>s.getColumn("reset_type")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-8 w-[180px]",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),o.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]}),e.jsxs(X,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:C=>s.getColumn("trigger_source")?.setFilterValue(C==="all"?"":C),children:[e.jsx(J,{className:"h-8 w-[180px]",children:e.jsx(Z,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Q,{children:[e.jsx(q,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(C=>e.jsx(q,{value:C.value,children:C.label},C.value))]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:_("h-8 w-[140px] justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),a?Ee(a,"yyyy-MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]}),e.jsxs(es,{children:[e.jsx(ss,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:_("h-8 w-[140px] justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),l?Ee(l,"yyyy-MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(We,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]}),(a||l)&&e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",onClick:p,children:[e.jsx(ur,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]})]}),r&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"h-8 px-2 lg:px-3",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",onClick:F,disabled:x,children:[e.jsx(ta,{className:"mr-2 h-4 w-4"}),t(x?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})})]})]})}const lp=()=>{const{t:s}=V("user"),n=a=>{switch(a){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";case"first_day_month":return"bg-orange-100 text-orange-800 border-orange-200";case"first_day_year":return"bg-indigo-100 text-indigo-800 border-indigo-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},t=a=>{switch(a){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},r=a=>{switch(a){case"manual":return e.jsx(La,{className:"h-3 w-3"});case"cron":return e.jsx(Rd,{className:"h-3 w-3"});case"auto":return e.jsx(Ld,{className:"h-3 w-3"});default:return e.jsx(La,{className:"h-3 w-3"})}};return[{accessorKey:"id",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.id"),className:"w-[60px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[60px]",children:e.jsx(U,{variant:"outline",className:"text-xs",children:a.original.id})}),enableSorting:!0,enableHiding:!0,size:60},{accessorKey:"user_email",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.user"),className:"min-w-[200px]"}),cell:({row:a})=>e.jsxs("div",{className:"flex min-w-[200px] items-start gap-2",children:[e.jsx($l,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:a.original.user_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",a.original.user_id]})]})]}),enableSorting:!1,enableHiding:!1,size:100},{accessorKey:"trigger_source",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.trigger_source"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:e.jsxs(U,{variant:"outline",className:_("flex items-center gap-1.5 border text-xs",t(a.original.trigger_source)),children:[r(a.original.trigger_source),e.jsx("span",{className:"truncate",children:a.original.trigger_source_name})]})})}),e.jsx(ce,{side:"bottom",className:"max-w-[200px]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:a.original.trigger_source_name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[a.original.trigger_source==="manual"&&s("traffic_reset_logs.trigger_descriptions.manual"),a.original.trigger_source==="cron"&&s("traffic_reset_logs.trigger_descriptions.cron"),a.original.trigger_source==="auto"&&s("traffic_reset_logs.trigger_descriptions.auto"),!["manual","cron","auto"].includes(a.original.trigger_source)&&s("traffic_reset_logs.trigger_descriptions.other")]})]})})]})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,i,l)=>l.includes(a.getValue(i)),size:120},{accessorKey:"reset_type",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.reset_type"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(U,{className:_("border text-xs",n(a.original.reset_type)),children:e.jsx("span",{className:"truncate",children:a.original.reset_type_name})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,i,l)=>l.includes(a.getValue(i)),size:120},{accessorKey:"old_traffic",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.cleared_traffic"),className:"w-[120px]"}),cell:({row:a})=>{const i=a.original.old_traffic;return e.jsx("div",{className:"w-[120px]",children:e.jsx(pe,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"cursor-pointer text-center",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:i.formatted}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("traffic_reset_logs.columns.cleared")})]})}),e.jsxs(ce,{side:"bottom",className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Et,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.upload"),":"," ",(i.upload/1024**3).toFixed(2)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ta,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.download"),":"," ",(i.download/1024**3).toFixed(2)," GB"]})]})]})]})})})},enableSorting:!1,enableHiding:!1,size:120},{accessorKey:"reset_time",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.reset_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Jt,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ne(a.original.reset_time,"MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne(a.original.reset_time,"HH:mm")})]})]})}),enableSorting:!0,enableHiding:!0,size:140},{accessorKey:"created_at",header:({column:a})=>e.jsx(z,{column:a,title:s("traffic_reset_logs.columns.log_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(qn,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ne(a.original.created_at,"YYYY-MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne(a.original.created_at,"H:m:s")})]})]})}),enableSorting:!0,enableHiding:!1,size:1400}]};function ip(){const[s,n]=m.useState({}),[t,r]=m.useState({reset_time:!1}),[a,i]=m.useState([]),[l,d]=m.useState([{id:"created_at",desc:!0}]),[x,u]=m.useState({pageIndex:0,pageSize:20}),o={page:x.pageIndex+1,per_page:x.pageSize,...a.reduce((T,C)=>{if(C.value)if(C.id==="date_range"){const P=C.value;P.start&&(T.start_date=P.start),P.end&&(T.end_date=P.end)}else T[C.id]=C.value;return T},{})},{refetch:c,data:p,isLoading:F}=re({queryKey:["trafficResetLogs",x,a,l],queryFn:()=>la.getLogs(o)});return e.jsx(op,{data:p?.data??[],rowCount:p?.total??0,sorting:l,setSorting:d,columnVisibility:t,setColumnVisibility:r,rowSelection:s,setRowSelection:n,columnFilters:a,setColumnFilters:i,pagination:x,setPagination:u,refetch:c,isLoading:F})}function op({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:x,setColumnFilters:u,pagination:o,setPagination:c,refetch:p,isLoading:F}){const T=Ye({data:s,columns:lp(),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:x,pagination:o},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:u,onColumnVisibilityChange:i,getCoreRowModel:Je(),getFilteredRowModel:fs(),getPaginationRowModel:ts(),onPaginationChange:c,getSortedRowModel:js(),getFacetedRowModel:Ls(),getFacetedUniqueValues:Rs(),initialState:{columnVisibility:{reset_time:!1}}});return e.jsxs("div",{className:"h-full space-y-4",children:[e.jsx(rp,{table:T,refetch:p}),e.jsx(rs,{table:T,isLoading:F})]})}function cp(){const{t:s}=V("user");return e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ds,{})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(as,{}),e.jsx(ns,{})]})]}),e.jsxs(Qe,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-4 space-y-2 md:mb-2 md:flex md:items-center md:justify-between md:space-y-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight md:text-2xl",children:s("traffic_reset_logs.title")}),e.jsx("p",{className:"text-sm text-muted-foreground md:mt-2",children:s("traffic_reset_logs.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-hidden px-4 py-1",children:e.jsx("div",{className:"h-full w-full",children:e.jsx(ip,{})})})]})]})}const dp=Object.freeze(Object.defineProperty({__proto__:null,default:cp},Symbol.toStringTag,{value:"Module"}));export{we as _,pp as a,hp as c,gp as g,fp as r}; diff --git a/public/assets/admin/index.html b/public/assets/admin/index.html index d7e9f89..4f75d40 100644 --- a/public/assets/admin/index.html +++ b/public/assets/admin/index.html @@ -16,7 +16,7 @@ title: 'Xboard', version: '1.0.0', logo: 'https://xboard.io/i6mages/logo.png', - secure_path: '/ea25d015', + secure_path: '/afbced4e', } diff --git a/public/assets/admin/locales/en-US.js b/public/assets/admin/locales/en-US.js index 4a9a2c1..24a3ea3 100644 --- a/public/assets/admin/locales/en-US.js +++ b/public/assets/admin/locales/en-US.js @@ -2037,6 +2037,8 @@ window.XBOARD_TRANSLATIONS['en-US'] = { "disk": "Disk Usage", "lastUpdate": "Last Updated" }, + "customId": "Custom ID", + "originalId": "Original ID", "type": "Type", "actions": "Actions", "copyAddress": "Copy Connection Address", @@ -2081,7 +2083,9 @@ window.XBOARD_TRANSLATIONS['en-US'] = { "label": "Base Rate", "error": "Base rate is required", "error_numeric": "Base rate must be a number", - "error_gte_zero": "Base rate must be greater than or equal to 0" + "error_gte_zero": "Base rate must be greater than or equal to 0", + "child_node_tooltip": "Child node's base rate is inherited from parent node and cannot be set separately", + "child_node_note": "Child node rate inherited from parent" }, "dynamic_rate": { "section_title": "Dynamic Rate Configuration", diff --git a/public/assets/admin/locales/zh-CN.js b/public/assets/admin/locales/zh-CN.js index ee32a34..03e99b6 100644 --- a/public/assets/admin/locales/zh-CN.js +++ b/public/assets/admin/locales/zh-CN.js @@ -2004,6 +2004,8 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "disk": "磁盘使用", "lastUpdate": "最后更新" }, + "customId": "自定义ID", + "originalId": "原始ID", "type": "类型", "actions": "操作", "copyAddress": "复制连接地址", @@ -2048,7 +2050,9 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "label": "基础倍率", "error": "基础倍率不能为空", "error_numeric": "基础倍率必须是数字", - "error_gte_zero": "基础倍率必须大于或等于0" + "error_gte_zero": "基础倍率必须大于或等于0", + "child_node_tooltip": "子节点的基础倍率继承自父节点,无法单独设置", + "child_node_note": "子节点倍率继承自父节点" }, "dynamic_rate": { "section_title": "动态倍率配置",