diff --git a/app/Console/Commands/ResetTraffic.php b/app/Console/Commands/ResetTraffic.php index 1282f44..0af2200 100644 --- a/app/Console/Commands/ResetTraffic.php +++ b/app/Console/Commands/ResetTraffic.php @@ -4,32 +4,33 @@ namespace App\Console\Commands; use App\Services\TrafficResetService; use App\Utils\Helper; +use Carbon\Carbon; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; class ResetTraffic extends Command { - /** + /** * The name and signature of the console command. - */ + */ protected $signature = 'reset:traffic {--batch-size=100 : 分批处理的批次大小} {--dry-run : 预演模式,不实际执行重置} {--max-time=300 : 最大执行时间(秒)}'; - /** + /** * The console command description. - */ + */ protected $description = '流量重置 - 分批处理所有需要重置的用户'; - /** + /** * 流量重置服务 - */ + */ private TrafficResetService $trafficResetService; /** * Create a new command instance. */ public function __construct(TrafficResetService $trafficResetService) - { - parent::__construct(); + { + parent::__construct(); $this->trafficResetService = $trafficResetService; } @@ -177,7 +178,7 @@ class ResetTraffic extends Command 'ID' => $user->id, '邮箱' => substr($user->email, 0, 20) . (strlen($user->email) > 20 ? '...' : ''), '套餐' => $user->plan->name ?? 'N/A', - '下次重置' => $user->next_reset_at->format('m-d H:i'), + '下次重置' => Carbon::createFromTimestamp($user->next_reset_at)->format('Y-m-d H:i:s'), '当前流量' => Helper::trafficConvert(($user->u ?? 0) + ($user->d ?? 0)), '重置次数' => $user->reset_count, ]; diff --git a/app/Console/Commands/SendRemindMail.php b/app/Console/Commands/SendRemindMail.php index 331f46b..5fdb2d1 100644 --- a/app/Console/Commands/SendRemindMail.php +++ b/app/Console/Commands/SendRemindMail.php @@ -52,7 +52,7 @@ class SendRemindMail extends Command } $startTime = microtime(true); - $progressBar = $this->output->createProgressBar(ceil($totalUsers / $chunkSize)); + $progressBar = $this->output->createProgressBar((int) ceil($totalUsers / $chunkSize)); $progressBar->start(); $statistics = $mailService->processUsersInChunks($chunkSize, function () use ($progressBar) { diff --git a/app/Http/Controllers/V2/Admin/SystemController.php b/app/Http/Controllers/V2/Admin/SystemController.php index 4d75f45..f6448f2 100644 --- a/app/Http/Controllers/V2/Admin/SystemController.php +++ b/app/Http/Controllers/V2/Admin/SystemController.php @@ -13,6 +13,7 @@ use Laravel\Horizon\Contracts\MetricsRepository; use Laravel\Horizon\Contracts\SupervisorRepository; use Laravel\Horizon\Contracts\WorkloadRepository; use Laravel\Horizon\WaitTimeCalculator; +use App\Helpers\ResponseEnum; class SystemController extends Controller { @@ -257,7 +258,7 @@ class SystemController extends Controller ]); } catch (\Exception $e) { - return $this->error('清除日志失败:' . $e->getMessage()); + return $this->fail(ResponseEnum::HTTP_ERROR, null, '清除日志失败:' . $e->getMessage()); } } @@ -293,7 +294,7 @@ class SystemController extends Controller return $this->success($stats); } catch (\Exception $e) { - return $this->error('获取统计信息失败:' . $e->getMessage()); + return $this->fail(ResponseEnum::HTTP_ERROR, null, '获取统计信息失败:' . $e->getMessage()); } } } diff --git a/app/Http/Controllers/V2/Admin/TrafficResetController.php b/app/Http/Controllers/V2/Admin/TrafficResetController.php index a77265b..53e4f54 100644 --- a/app/Http/Controllers/V2/Admin/TrafficResetController.php +++ b/app/Http/Controllers/V2/Admin/TrafficResetController.php @@ -71,7 +71,7 @@ class TrafficResetController extends Controller $logs = $query->paginate($perPage); // 格式化数据 - $logs->getCollection()->transform(function ($log) { + $formattedLogs = $logs->getCollection()->map(function (TrafficResetLog $log) { return [ 'id' => $log->id, 'user_id' => $log->user_id, @@ -99,7 +99,7 @@ class TrafficResetController extends Controller }); return response()->json([ - 'data' => $logs->items(), + 'data' => $formattedLogs->toArray(), 'pagination' => [ 'current_page' => $logs->currentPage(), 'last_page' => $logs->lastPage(), @@ -198,7 +198,8 @@ class TrafficResetController extends Controller $history = $this->trafficResetService->getUserResetHistory($user, $limit); - $data = $history->map(function ($log) { + /** @var \Illuminate\Database\Eloquent\Collection $history */ + $data = $history->map(function (TrafficResetLog $log) { return [ 'id' => $log->id, 'reset_type' => $log->reset_type, diff --git a/app/Http/Requests/Admin/UserUpdate.php b/app/Http/Requests/Admin/UserUpdate.php index 793606d..c40d93d 100644 --- a/app/Http/Requests/Admin/UserUpdate.php +++ b/app/Http/Requests/Admin/UserUpdate.php @@ -18,12 +18,12 @@ class UserUpdate extends FormRequest 'password' => 'nullable|min:8', 'transfer_enable' => 'numeric', 'expired_at' => 'nullable|integer', - 'banned' => 'in:0,1', + 'banned' => 'bool', 'plan_id' => 'nullable|integer', 'commission_rate' => 'nullable|integer|min:0|max:100', 'discount' => 'nullable|integer|min:0|max:100', - 'is_admin' => 'required|in:0,1', - 'is_staff' => 'required|in:0,1', + 'is_admin' => 'boolean', + 'is_staff' => 'boolean', 'u' => 'integer', 'd' => 'integer', 'balance' => 'numeric', diff --git a/app/Models/Coupon.php b/app/Models/Coupon.php index 7d330a3..e6271b8 100644 --- a/app/Models/Coupon.php +++ b/app/Models/Coupon.php @@ -14,7 +14,8 @@ class Coupon extends Model 'created_at' => 'timestamp', 'updated_at' => 'timestamp', 'limit_plan_ids' => 'array', - 'limit_period' => 'array' + 'limit_period' => 'array', + 'show' => 'boolean', ]; public function getLimitPeriodAttribute($value) diff --git a/app/Models/InviteCode.php b/app/Models/InviteCode.php index 8489897..bf2af91 100644 --- a/app/Models/InviteCode.php +++ b/app/Models/InviteCode.php @@ -10,6 +10,7 @@ class InviteCode extends Model protected $dateFormat = 'U'; protected $casts = [ 'created_at' => 'timestamp', - 'updated_at' => 'timestamp' + 'updated_at' => 'timestamp', + 'status' => 'boolean', ]; } diff --git a/app/Models/Plan.php b/app/Models/Plan.php index b7aeed5..d18d364 100755 --- a/app/Models/Plan.php +++ b/app/Models/Plan.php @@ -23,7 +23,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne; * @property array|null $prices 价格配置 * @property int $sort 排序 * @property string|null $content 套餐描述 - * @property int $reset_traffic_method 流量重置方式 + * @property int|null $reset_traffic_method 流量重置方式 * @property int|null $capacity_limit 订阅人数限制 * @property int|null $device_limit 设备数量限制 * @property int $created_at diff --git a/app/Models/Plugin.php b/app/Models/Plugin.php index 4926c42..36b2469 100644 --- a/app/Models/Plugin.php +++ b/app/Models/Plugin.php @@ -11,6 +11,10 @@ class Plugin extends Model protected $guarded = [ 'id', 'created_at', - 'updated_at' + 'updated_at', + ]; + + protected $casts = [ + 'is_enabled' => 'boolean' ]; } diff --git a/app/Models/Server.php b/app/Models/Server.php index d18088e..bf6da5a 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -23,7 +23,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute; * @property array|null $group_ids 分组IDs * @property array|null $route_ids 路由IDs * @property array|null $tags 标签 - * @property string|null $show 是否显示 + * @property boolean $show 是否显示 * @property string|null $allow_insecure 是否允许不安全 * @property string|null $network 网络类型 * @property int|null $parent_id 父节点ID @@ -112,6 +112,7 @@ class Server extends Model 'protocol_settings' => 'array', 'last_check_at' => 'integer', 'last_push_at' => 'integer', + 'show' => 'boolean', 'created_at' => 'timestamp', 'updated_at' => 'timestamp' ]; diff --git a/app/Models/User.php b/app/Models/User.php index 8274a95..e648306 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -37,8 +37,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany; * @property int|null $last_login_at 最后登录时间 * @property int|null $parent_id 父账户ID * @property int|null $is_admin 是否管理员 - * @property \Carbon\Carbon|null $next_reset_at 下次流量重置时间 - * @property \Carbon\Carbon|null $last_reset_at 上次流量重置时间 + * @property int|null $next_reset_at 下次流量重置时间 + * @property int|null $last_reset_at 上次流量重置时间 * @property int $reset_count 流量重置次数 * @property int $created_at * @property int $updated_at @@ -64,7 +64,9 @@ class User extends Authenticatable protected $casts = [ 'created_at' => 'timestamp', 'updated_at' => 'timestamp', - 'banned' => 'integer', + 'banned' => 'boolean', + 'is_admin' => 'boolean', + 'is_staff' => 'boolean', 'remind_expire' => 'boolean', 'remind_traffic' => 'boolean', 'commission_auto_check' => 'boolean', diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 03675b1..3266fcb 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -53,10 +53,10 @@ class UserObserver $nextResetTime = $this->trafficResetService->calculateNextResetTime($user); if ($nextResetTime) { - $user->next_reset_at = $nextResetTime->timestamp; + $user->setAttribute('next_reset_at', $nextResetTime->timestamp); } else { // 如果计算结果为空,清除重置时间 - $user->next_reset_at = null; + $user->setAttribute('next_reset_at', null); } } catch (\Exception $e) { diff --git a/app/Providers/SettingServiceProvider.php b/app/Providers/SettingServiceProvider.php index 86c242d..921f02d 100644 --- a/app/Providers/SettingServiceProvider.php +++ b/app/Providers/SettingServiceProvider.php @@ -16,7 +16,7 @@ class SettingServiceProvider extends ServiceProvider public function register() { $this->app->scoped(Setting::class, function (Application $app) { - return new Setting(); + return Setting::getInstance(); }); } diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index 87160d9..3fe250c 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -87,13 +87,6 @@ class ServerService public static function getRoutes(array $routeIds) { $routes = ServerRoute::select(['id', 'match', 'action', 'action_value'])->whereIn('id', $routeIds)->get(); - // TODO: remove on 1.8.0 - foreach ($routes as $k => $route) { - $array = json_decode($route->match, true); - if (is_array($array)) - $routes[$k]['match'] = $array; - } - // TODO: remove on 1.8.0 return $routes; } diff --git a/app/Services/TrafficResetService.php b/app/Services/TrafficResetService.php index 9371684..6124c70 100644 --- a/app/Services/TrafficResetService.php +++ b/app/Services/TrafficResetService.php @@ -109,7 +109,6 @@ class TrafficResetService Plan::RESET_TRAFFIC_MONTHLY => $this->getNextMonthlyReset($user, $now), Plan::RESET_TRAFFIC_FIRST_DAY_YEAR => $this->getNextYearFirstDay($now), Plan::RESET_TRAFFIC_YEARLY => $this->getNextYearlyReset($user, $now), - Plan::RESET_TRAFFIC_NEVER => null, default => null, }; } @@ -251,6 +250,7 @@ class TrafficResetService Plan::RESET_TRAFFIC_MONTHLY => TrafficResetLog::TYPE_MONTHLY, Plan::RESET_TRAFFIC_FIRST_DAY_YEAR => TrafficResetLog::TYPE_FIRST_DAY_YEAR, Plan::RESET_TRAFFIC_YEARLY => TrafficResetLog::TYPE_YEARLY, + Plan::RESET_TRAFFIC_NEVER => TrafficResetLog::TYPE_MANUAL, default => TrafficResetLog::TYPE_MANUAL, }; } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 8813c04..27f6cdb 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -145,8 +145,8 @@ class UserService 'total_available' => $user->transfer_enable ?? 0, 'remaining' => $user->getRemainingTraffic(), 'usage_percentage' => $user->getTrafficUsagePercentage(), - 'next_reset_at' => $user->next_reset_at?->timestamp, - 'last_reset_at' => $user->last_reset_at?->timestamp, + 'next_reset_at' => $user->next_reset_at, + 'last_reset_at' => $user->last_reset_at, 'reset_count' => $user->reset_count, ]; } diff --git a/app/Support/Setting.php b/app/Support/Setting.php index c7c549a..0c657a2 100644 --- a/app/Support/Setting.php +++ b/app/Support/Setting.php @@ -135,9 +135,9 @@ class Setting // 处理JSON格式的值 foreach ($settings as $key => $value) { - if (is_string($value) && $value !== null) { + if (is_string($value)) { $decoded = json_decode($value, true); - if (json_last_error() === JSON_ERROR_NONE) { + if (json_last_error() === JSON_ERROR_NONE && $decoded !== null) { $settings[$key] = $decoded; } } diff --git a/database/migrations/2025_01_04_optimize_plan_table.php b/database/migrations/2025_01_04_optimize_plan_table.php index 9d9a1ac..366edde 100644 --- a/database/migrations/2025_01_04_optimize_plan_table.php +++ b/database/migrations/2025_01_04_optimize_plan_table.php @@ -122,7 +122,7 @@ return new class extends Migration { $table->integer('group_id')->change(); $table->integer('transfer_enable')->change(); $table->integer('speed_limit')->nullable()->change(); - $table->boolean('reset_traffic_method')->nullable()->change(); + $table->integer('reset_traffic_method')->nullable()->change(); $table->integer('capacity_limit')->nullable()->change(); }); } diff --git a/public/assets/admin/assets/index.css b/public/assets/admin/assets/index.css index c86f14c..e3bef52 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{left:.25rem}.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-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-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}.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-\[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-\[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-\[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-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-\[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{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}.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-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-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\/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-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}.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-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}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\:relative:focus-within{position:relative}.focus-within\:z-20:focus-within{z-index:20}.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:hover{background-color:hsl(var(--primary))}.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-foreground:hover{color:hsl(var(--primary-foreground))}.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\:bg-primary:focus{background-color:hsl(var(--primary))}.focus\:text-accent-foreground:focus{color:hsl(var(--accent-foreground))}.focus\:text-destructive:focus{color:hsl(var(--destructive))}.focus\:text-primary-foreground:focus{color:hsl(var(--primary-foreground))}.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\: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-selected\:bg-accent[aria-selected=true]{background-color:hsl(var(--accent))}.aria-selected\:bg-accent\/50[aria-selected=true]{background-color:hsl(var(--accent) / .5)}.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))}.aria-selected\:opacity-100[aria-selected=true]{opacity:1}.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-\[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-\[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-\[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[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))}.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-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-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\: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\: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\: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))}.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}.\[\&\:has\(\>\.day-range-end\)\]\:rounded-r-md:has(>.day-range-end){border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\>\.day-range-start\)\]\:rounded-l-md:has(>.day-range-start){border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[aria-selected\]\)\]\:rounded-md:has([aria-selected]){border-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[aria-selected\]\)\]\:bg-accent:has([aria-selected]){background-color:hsl(var(--accent))}.first\:\[\&\:has\(\[aria-selected\]\)\]\:rounded-l-md:has([aria-selected]):first-child{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.last\:\[\&\:has\(\[aria-selected\]\)\]\:rounded-r-md:has([aria-selected]):last-child{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[aria-selected\]\.day-outside\)\]\:bg-accent\/50:has([aria-selected].day-outside){background-color:hsl(var(--accent) / .5)}.\[\&\:has\(\[aria-selected\]\.day-range-end\)\]\:rounded-r-md:has([aria-selected].day-range-end){border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\&\>\[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}.\[\&\>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} +*,: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{left:.25rem}.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-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-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}.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-\[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-\[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-\[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-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-\[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{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}.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-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-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\/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-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}.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-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}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\:relative:focus-within{position:relative}.focus-within\:z-20:focus-within{z-index:20}.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:hover{background-color:hsl(var(--primary))}.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-foreground:hover{color:hsl(var(--primary-foreground))}.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\:bg-primary:focus{background-color:hsl(var(--primary))}.focus\:text-accent-foreground:focus{color:hsl(var(--accent-foreground))}.focus\:text-destructive:focus{color:hsl(var(--destructive))}.focus\:text-primary-foreground:focus{color:hsl(var(--primary-foreground))}.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\: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-selected\:bg-accent[aria-selected=true]{background-color:hsl(var(--accent))}.aria-selected\:bg-accent\/50[aria-selected=true]{background-color:hsl(var(--accent) / .5)}.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))}.aria-selected\:opacity-100[aria-selected=true]{opacity:1}.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-\[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-\[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-\[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[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))}.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-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-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\: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))}.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}.\[\&\:has\(\>\.day-range-end\)\]\:rounded-r-md:has(>.day-range-end){border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\>\.day-range-start\)\]\:rounded-l-md:has(>.day-range-start){border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[aria-selected\]\)\]\:rounded-md:has([aria-selected]){border-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[aria-selected\]\)\]\:bg-accent:has([aria-selected]){background-color:hsl(var(--accent))}.first\:\[\&\:has\(\[aria-selected\]\)\]\:rounded-l-md:has([aria-selected]):first-child{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.last\:\[\&\:has\(\[aria-selected\]\)\]\:rounded-r-md:has([aria-selected]):last-child{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[aria-selected\]\.day-outside\)\]\:bg-accent\/50:has([aria-selected].day-outside){background-color:hsl(var(--accent) / .5)}.\[\&\:has\(\[aria-selected\]\.day-range-end\)\]\:rounded-r-md:has([aria-selected].day-range-end){border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\&\>\[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}.\[\&\>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} diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index d52fbfd..ca16438 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,20 +1,20 @@ -import{r as m,j as e,t as Oi,c as zi,I as Yt,a as it,S as vn,u as As,b as $i,d as bn,R as Nr,e as _r,f as Ai,F as qi,C as Hi,L as wr,T as Cr,g as Sr,h as Ui,i as Ki,k as Bi,l as Gi,m as A,z as x,n as V,o as we,p as Ce,q as ne,s as Ts,v as ke,w as Wi,x as Yi,O as yn,y as Ji,A as Qi,B as Xi,D as Zi,E as eo,G as so,Q as to,H as ao,J as no,K as ro,P as lo,M as io,N as oo,U as co,V as mo,W as kr,X as Tr,Y as Da,Z as Pa,_ as Nn,$ as ms,a0 as La,a1 as Ea,a2 as Dr,a3 as Pr,a4 as Lr,a5 as _n,a6 as Er,a7 as uo,a8 as Rr,a9 as Fr,aa as Ir,ab as Vr,ac as ot,ad as Mr,ae as xo,af as Or,ag as zr,ah as ho,ai as go,aj as fo,ak as po,al as jo,am as vo,an as bo,ao as yo,ap as No,aq as _o,ar as wo,as as $r,at as Co,au as So,av as Ys,aw as Ar,ax as ko,ay as To,az as qr,aA as wn,aB as Do,aC as Po,aD as Jn,aE as Lo,aF as Hr,aG as Eo,aH as Ur,aI as Ro,aJ as Fo,aK as Io,aL as Vo,aM as Mo,aN as Oo,aO as Kr,aP as zo,aQ as $o,aR as Ao,aS as es,aT as qo,aU as Cn,aV as Ho,aW as Uo,aX as Br,aY as Gr,aZ as Wr,a_ as Ko,a$ as Bo,b0 as Go,b1 as Yr,b2 as Wo,b3 as Sn,b4 as Jr,b5 as Yo,b6 as Qr,b7 as Jo,b8 as Xr,b9 as Qo,ba as Zr,bb as el,bc as Xo,bd as Zo,be as sl,bf as ec,bg as sc,bh as tl,bi as tc,bj as al,bk as ac,bl as nc,bm as _s,bn as Pe,bo as Cs,bp as rc,bq as lc,br as ic,bs as oc,bt as cc,bu as dc,bv as Qn,bw as Xn,bx as mc,by as uc,bz as kn,bA as xc,bB as hc,bC as ja,bD as wt,bE as va,bF as gc,bG as nl,bH as fc,bI as pc,bJ as rl,bK as jc,bL as vc,bM as Zn,bN as dn,bO as mn,bP as bc,bQ as yc,bR as ll,bS as Nc,bT as _c,bU as wc,bV as ba,bW as un,bX as ss,bY as ya,bZ as Cc,b_ as Qa,b$ as Sc,c0 as er,c1 as ds,c2 as qt,c3 as Ht,c4 as xn,c5 as il,c6 as ts,c7 as us,c8 as ol,c9 as cl,ca as kc,cb as Tc,cc as Dc,cd as Pc,ce as Lc,cf as dl,cg as Ec,ch as Rc,ci as Be,cj as sr,ck as Fc,cl as ml,cm as ul,cn as xl,co as hl,cp as gl,cq as fl,cr as Ic,cs as Vc,ct as Mc,cu as Ra,cv as ct,cw as vs,cx as bs,cy as Oc,cz as zc,cA as $c,cB as Ac,cC as pl,cD as qc,cE as Hc,cF as Uc,cG as Kc,cH as hn,cI as Tn,cJ as Dn,cK as Bc,cL as Es,cM as Rs,cN as Fa,cO as Gc,cP as Na,cQ as Wc,cR as tr,cS as jl,cT as ar,cU as _a,cV as Yc,cW as Jc,cX as Qc,cY as Xc,cZ as Zc,c_ as vl,c$ as ed,d0 as sd,d1 as bl,d2 as gn,d3 as yl,d4 as td,d5 as fn,d6 as Nl,d7 as ad,d8 as Ut,d9 as Pn,da as nd,db as rd,dc as nr,dd as _l,de as ld,df as id,dg as od,dh as rr}from"./vendor.js";import"./index.js";var bg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yg(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function cd(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 dd={theme:"system",setTheme:()=>null},wl=m.createContext(dd);function md({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 u=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(u);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(wl.Provider,{...r,value:l,children:s})}const ud=()=>{const s=m.useContext(wl);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},xd=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),hd=function(s,n){return new URL(s,n).href},lr={},ye=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]"),u=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(o=>{if(o=hd(o,r),o in lr)return;lr[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(!!r)for(let S=l.length-1;S>=0;S--){const p=l[S];if(p.href===o&&(!c||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const C=document.createElement("link");if(C.rel=c?"stylesheet":xd,c||(C.as="script"),C.crossOrigin="",C.href=o,u&&C.setAttribute("nonce",u),document.head.appendChild(C),c)return new Promise((S,p)=>{C.addEventListener("load",S),C.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function y(...s){return Oi(zi(s))}const Tt=it("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),P=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:u,...o},c)=>{const h=r?vn:"button";return e.jsxs(h,{className:y(Tt({variant:n,size:t,className:s})),disabled:l||i,ref:c,...o,children:[(d&&l||!d&&!u&&l)&&e.jsx(Yt,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&u&&e.jsx("div",{className:"ml-2",children:u}),u&&l&&e.jsx(Yt,{className:"ml-2 h-4 w-4 animate-spin"})]})});P.displayName="Button";function ht({className:s,minimal:n=!1}){const t=As(),r=$i(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:y("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{}),a]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function ir(){const s=As();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(P,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(P,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function gd(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(P,{variant:"outline",children:"Learn more"})})]})})}function fd(s){return typeof s>"u"}function pd(s){return s===null}function jd(s){return pd(s)||fd(s)}class vd{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 jd(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 Cl({prefixKey:s="",storage:n=sessionStorage}){return new vd({prefixKey:s,storage:n})}const Sl="Xboard_",bd=function(s={}){return Cl({prefixKey:s.prefixKey||"",storage:localStorage})},yd=function(s={}){return Cl({prefixKey:s.prefixKey||"",storage:sessionStorage})},Ln=bd({prefixKey:Sl});yd({prefixKey:Sl});const kl="access_token";function Jt(){return Ln.get(kl)}function Tl(){Ln.remove(kl)}const or=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Nd({children:s}){const n=As(),t=bn(),r=Jt();return m.useEffect(()=>{if(!r.value&&!or.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),or.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const Te=m.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(Nr,{ref:a,decorative:t,orientation:n,className:y("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));Te.displayName=Nr.displayName;const _d=it("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ae=m.forwardRef(({className:s,...n},t)=>e.jsx(_r,{ref:t,className:y(_d(),s),...n}));Ae.displayName=_r.displayName;const Se=qi,Dl=m.createContext({}),b=({...s})=>e.jsx(Dl.Provider,{value:{name:s.name},children:e.jsx(Hi,{...s})}),Ia=()=>{const s=m.useContext(Dl),n=m.useContext(Pl),{getFieldState:t,formState:r}=Ai(),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}},Pl=m.createContext({}),j=m.forwardRef(({className:s,...n},t)=>{const r=m.useId();return e.jsx(Pl.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:y("space-y-2",s),...n})})});j.displayName="FormItem";const v=m.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Ia();return e.jsx(Ae,{ref:t,className:y(r&&"text-destructive",s),htmlFor:a,...n})});v.displayName="FormLabel";const N=m.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Ia();return e.jsx(vn,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});N.displayName="FormControl";const O=m.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Ia();return e.jsx("p",{ref:t,id:r,className:y("text-[0.8rem] text-muted-foreground",s),...n})});O.displayName="FormDescription";const L=m.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Ia(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:y("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});L.displayName="FormMessage";const Dt=Ui,dt=m.forwardRef(({className:s,...n},t)=>e.jsx(wr,{ref:t,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));dt.displayName=wr.displayName;const Xe=m.forwardRef(({className:s,...n},t)=>e.jsx(Cr,{ref:t,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));Xe.displayName=Cr.displayName;const Ss=m.forwardRef(({className:s,...n},t)=>e.jsx(Sr,{ref:t,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));Ss.displayName=Sr.displayName;function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Ki(s).format(n))}function wd(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function bt(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Vs(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 wa(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 Bi(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 Oe(s){const n=s/1024,t=n/1024,r=t/1024,a=r/1024;return a>=1?bt(a)+" TB":r>=1?bt(r)+" GB":t>=1?bt(t)+" MB":bt(n)+" KB"}const cr="i18nextLng";function Cd(){return console.log(localStorage.getItem(cr)),localStorage.getItem(cr)}function Ll(){Tl();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 Sd=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function kd(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const yt=Gi.create({baseURL:kd(),timeout:12e3,headers:{"Content-Type":"application/json"}});yt.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=Jt();if(!Sd.includes(s.url?.split("?")[0]||"")){if(!n.value)return Ll(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Cd()||"zh-CN",s},s=>Promise.reject(s));yt.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)&&Ll(),A.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const M={get:(s,n)=>yt.get(s,n),post:(s,n,t)=>yt.post(s,n,t),put:(s,n,t)=>yt.put(s,n,t),delete:(s,n)=>yt.delete(s,n)},Td="access_token";function Dd(s){Ln.set(Td,s)}const et=window?.settings?.secure_path,Ca={getStats:()=>M.get(et+"/monitor/api/stats"),getOverride:()=>M.get(et+"/stat/getOverride"),getOrderStat:s=>M.get(et+"/stat/getOrder",{params:s}),getStatsData:()=>M.get(et+"/stat/getStats"),getNodeTrafficData:s=>M.get(et+"/stat/getTrafficRank",{params:s}),getServerLastRank:()=>M.get(et+"/stat/getServerLastRank"),getServerYesterdayRank:()=>M.get(et+"/stat/getServerYesterdayRank")},Rt=window?.settings?.secure_path,Kt={getList:()=>M.get(Rt+"/theme/getThemes"),getConfig:s=>M.post(Rt+"/theme/getThemeConfig",{name:s}),updateConfig:(s,n)=>M.post(Rt+"/theme/saveThemeConfig",{name:s,config:n}),upload:s=>{const n=new FormData;return n.append("file",s),M.post(Rt+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},drop:s=>M.post(Rt+"/theme/delete",{name:s})},gt=window?.settings?.secure_path,at={getList:()=>M.get(gt+"/server/manage/getNodes"),save:s=>M.post(gt+"/server/manage/save",s),drop:s=>M.post(gt+"/server/manage/drop",s),copy:s=>M.post(gt+"/server/manage/copy",s),update:s=>M.post(gt+"/server/manage/update",s),sort:s=>M.post(gt+"/server/manage/sort",s)},Xa=window?.settings?.secure_path,mt={getList:()=>M.get(Xa+"/server/group/fetch"),save:s=>M.post(Xa+"/server/group/save",s),drop:s=>M.post(Xa+"/server/group/drop",s)},Za=window?.settings?.secure_path,Va={getList:()=>M.get(Za+"/server/route/fetch"),save:s=>M.post(Za+"/server/route/save",s),drop:s=>M.post(Za+"/server/route/drop",s)},st=window?.settings?.secure_path,nt={getList:()=>M.get(st+"/payment/fetch"),getMethodList:()=>M.get(st+"/payment/getPaymentMethods"),getMethodForm:s=>M.post(st+"/payment/getPaymentForm",s),save:s=>M.post(st+"/payment/save",s),drop:s=>M.post(st+"/payment/drop",s),updateStatus:s=>M.post(st+"/payment/show",s),sort:s=>M.post(st+"/payment/sort",s)},Ft=window?.settings?.secure_path,Qt={getList:()=>M.get(`${Ft}/notice/fetch`),save:s=>M.post(`${Ft}/notice/save`,s),drop:s=>M.post(`${Ft}/notice/drop`,{id:s}),updateStatus:s=>M.post(`${Ft}/notice/show`,{id:s}),sort:s=>M.post(`${Ft}/notice/sort`,{ids:s})},ft=window?.settings?.secure_path,Ct={getList:()=>M.get(ft+"/knowledge/fetch"),getInfo:s=>M.get(ft+"/knowledge/fetch?id="+s),save:s=>M.post(ft+"/knowledge/save",s),drop:s=>M.post(ft+"/knowledge/drop",s),updateStatus:s=>M.post(ft+"/knowledge/show",s),sort:s=>M.post(ft+"/knowledge/sort",s)},It=window?.settings?.secure_path,gs={getList:()=>M.get(It+"/plan/fetch"),save:s=>M.post(It+"/plan/save",s),update:s=>M.post(It+"/plan/update",s),drop:s=>M.post(It+"/plan/drop",s),sort:s=>M.post(It+"/plan/sort",{ids:s})},pt=window?.settings?.secure_path,tt={getList:s=>M.post(pt+"/order/fetch",s),getInfo:s=>M.post(pt+"/order/detail",s),markPaid:s=>M.post(pt+"/order/paid",s),makeCancel:s=>M.post(pt+"/order/cancel",s),update:s=>M.post(pt+"/order/update",s),assign:s=>M.post(pt+"/order/assign",s)},ra=window?.settings?.secure_path,Sa={getList:s=>M.post(ra+"/coupon/fetch",s),save:s=>M.post(ra+"/coupon/generate",s),drop:s=>M.post(ra+"/coupon/drop",s),update:s=>M.post(ra+"/coupon/update",s)},ls=window?.settings?.secure_path,Ps={getList:s=>M.post(`${ls}/user/fetch`,s),update:s=>M.post(`${ls}/user/update`,s),resetSecret:s=>M.post(`${ls}/user/resetSecret`,{id:s}),generate:s=>s.download_csv?M.post(`${ls}/user/generate`,s,{responseType:"blob"}):M.post(`${ls}/user/generate`,s),getStats:s=>M.post(`${ls}/stat/getStatUser`,s),destroy:s=>M.post(`${ls}/user/destroy`,{id:s}),sendMail:s=>M.post(`${ls}/user/sendMail`,s),dumpCSV:s=>M.post(`${ls}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>M.post(`${ls}/user/ban`,s)},Xt={getLogs:s=>M.get(`${ls}/traffic-reset/logs`,{params:s}),getStats:s=>M.get(`${ls}/traffic-reset/stats`,{params:s}),resetUser:s=>M.post(`${ls}/traffic-reset/reset-user`,s),getUserHistory:(s,n)=>M.get(`${ls}/traffic-reset/user/${s}/history`,{params:n})},la=window?.settings?.secure_path,Nt={getList:s=>M.post(la+"/ticket/fetch",s),getInfo:s=>M.get(la+"/ticket/fetch?id= "+s),reply:s=>M.post(la+"/ticket/reply",s),close:s=>M.post(la+"/ticket/close",{id:s})},Ue=window?.settings?.secure_path,he={getSettings:(s="")=>M.get(Ue+"/config/fetch?key="+s),saveSettings:s=>M.post(Ue+"/config/save",s),getEmailTemplate:()=>M.get(Ue+"/config/getEmailTemplate"),sendTestMail:()=>M.post(Ue+"/config/testSendMail"),setTelegramWebhook:()=>M.post(Ue+"/config/setTelegramWebhook"),updateSystemConfig:s=>M.post(Ue+"/config/save",s),getSystemStatus:()=>M.get(`${Ue}/system/getSystemStatus`),getQueueStats:()=>M.get(`${Ue}/system/getQueueStats`),getQueueWorkload:()=>M.get(`${Ue}/system/getQueueWorkload`),getQueueMasters:()=>M.get(`${Ue}/system/getQueueMasters`),getHorizonFailedJobs:s=>M.get(`${Ue}/system/getHorizonFailedJobs`,{params:s}),getSystemLog:s=>M.get(`${Ue}/system/getSystemLog`,{params:s}),getLogFiles:()=>M.get(`${Ue}/log/files`),getLogContent:s=>M.get(`${Ue}/log/fetch`,{params:s}),getLogClearStats:s=>M.get(`${Ue}/system/getLogClearStats`,{params:s}),clearSystemLog:s=>M.post(`${Ue}/system/clearSystemLog`,s)},Is=window?.settings?.secure_path,Ms={getPluginList:()=>M.get(`${Is}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),M.post(`${Is}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>M.post(`${Is}/plugin/delete`,{code:s}),installPlugin:s=>M.post(`${Is}/plugin/install`,{code:s}),uninstallPlugin:s=>M.post(`${Is}/plugin/uninstall`,{code:s}),enablePlugin:s=>M.post(`${Is}/plugin/enable`,{code:s}),disablePlugin:s=>M.post(`${Is}/plugin/disable`,{code:s}),getPluginConfig:s=>M.get(`${Is}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>M.post(`${Is}/plugin/config`,{code:s,config:n})};window?.settings?.secure_path;const Pd=x.object({subscribe_template_singbox:x.string().optional().default(""),subscribe_template_clash:x.string().optional().default(""),subscribe_template_clashmeta:x.string().optional().default(""),subscribe_template_stash:x.string().optional().default(""),subscribe_template_surge:x.string().optional().default(""),subscribe_template_surfboard:x.string().optional().default("")}),dr=[{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"}],mr={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function Ld(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),[a,i]=m.useState("singbox"),l=we({resolver:Ce(Pd),defaultValues:mr,mode:"onChange"}),{data:d,isLoading:u}=ne({queryKey:["settings","client"],queryFn:()=>he.getSettings("subscribe_template")}),{mutateAsync:o}=Ts({mutationFn:he.saveSettings,onSuccess:()=>{A.success(s("common.autoSaved"))},onError:C=>{console.error("保存失败:",C),A.error(s("common.saveFailed"))}});m.useEffect(()=>{if(d?.data?.subscribe_template){const C=d.data.subscribe_template;Object.entries(C).forEach(([S,p])=>{if(S in mr){const _=typeof p=="string"?p:"";l.setValue(S,_)}}),r.current=l.getValues()}},[d,l]);const c=m.useCallback(ke.debounce(async C=>{if(!r.current||!ke.isEqual(C,r.current)){t(!0);try{await o(C),r.current=C}catch(S){console.error("保存设置失败:",S)}finally{t(!1)}}},1500),[o]),h=m.useCallback(()=>{const C=l.getValues();c(C)},[l,c]),k=m.useCallback((C,S)=>e.jsx(b,{control:l.control,name:C,render:({field:p})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s(`subscribe_template.${C.replace("subscribe_template_","")}.title`)}),e.jsx(N,{children:e.jsx(Wi,{height:"500px",defaultLanguage:S,value:p.value||"",onChange:_=>{p.onChange(_||""),h()},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})}),e.jsx(O,{children:s(`subscribe_template.${C.replace("subscribe_template_","")}.description`)}),e.jsx(L,{})]})}),[l.control,s,h]);return u?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(Se,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Dt,{value:a,onValueChange:i,className:"w-full",children:[e.jsx(dt,{className:"",children:dr.map(({key:C,label:S})=>e.jsx(Xe,{value:C,className:"text-xs",children:S},C))}),dr.map(({key:C,language:S})=>e.jsx(Ss,{value:C,className:"mt-4",children:k(`subscribe_template_${C}`,S)},C))]}),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 Ed(){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(Te,{}),e.jsx(Ld,{})]})}const Rd=()=>e.jsx(Nd,{children:e.jsx(yn,{})}),Fd=Yi([{path:"/sign-in",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Qd);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Rd,{}),children:[{path:"/",lazy:async()=>({Component:(await ye(()=>Promise.resolve().then(()=>lm),void 0,import.meta.url)).default}),errorElement:e.jsx(ht,{}),children:[{index:!0,lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Sm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(ht,{}),children:[{path:"system",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Fm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>zm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Um);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Ym);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>eu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>ru);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>du);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>gu);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>bu);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(Ed,{})}]},{path:"payment",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>ku);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Pu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Fu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Au);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Yu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(ht,{}),children:[{path:"manage",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Cx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Px);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Vx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(ht,{}),children:[{path:"plan",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Kx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>rh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>hh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(ht,{}),children:[{path:"manage",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Uh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>dg);return{default:s}},void 0,import.meta.url)).default})},{path:"traffic-reset-logs",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>fg);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:ht},{path:"/404",Component:ir},{path:"/503",Component:gd},{path:"*",Component:ir}]);function Id(){return M.get("/user/info")}const en={token:Jt()?.value||"",userInfo:null,isLoggedIn:!!Jt()?.value,loading:!1,error:null},Bt=Ji("user/fetchUserInfo",async()=>(await Id()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),El=Qi({name:"user",initialState:en,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>en},extraReducers:s=>{s.addCase(Bt.pending,n=>{n.loading=!0,n.error=null}).addCase(Bt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(Bt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return en})}}),{setToken:Vd,resetUserState:Md}=El.actions,Od=s=>s.user.userInfo,zd=El.reducer,Rl=Xi({reducer:{user:zd}});Jt()?.value&&Rl.dispatch(Bt());Zi.use(eo).use(so).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 $d=new to;ao.createRoot(document.getElementById("root")).render(e.jsx(no.StrictMode,{children:e.jsx(ro,{client:$d,children:e.jsx(lo,{store:Rl,children:e.jsxs(md,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(io,{router:Fd}),e.jsx(oo,{richColors:!0,position:"top-right"})]})})})}));const Ee=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Ee.displayName="Card";const Fe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:y("flex flex-col space-y-1.5 p-6",s),...n}));Fe.displayName="CardHeader";const Ge=m.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:y("font-semibold leading-none tracking-tight",s),...n}));Ge.displayName="CardTitle";const Os=m.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:y("text-sm text-muted-foreground",s),...n}));Os.displayName="CardDescription";const Ie=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:y("p-6 pt-0",s),...n}));Ie.displayName="CardContent";const Ad=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:y("flex items-center p-6 pt-0",s),...n}));Ad.displayName="CardFooter";const D=m.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:r,...t}));D.displayName="Input";const Fl=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:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}),e.jsx(P,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>a(i=>!i),children:r?e.jsx(co,{size:18}):e.jsx(mo,{size:18})})]})});Fl.displayName="PasswordInput";const qd=s=>M.post("/passport/auth/login",s);function Hd({className:s,onForgotPassword:n,...t}){const r=As(),a=kr(),{t:i}=V("auth"),l=x.object({email:x.string().min(1,{message:i("signIn.validation.emailRequired")}),password:x.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=we({resolver:Ce(l),defaultValues:{email:"",password:""}});async function u(o){try{const{data:c}=await qd(o);Dd(c.auth_data),a(Vd(c.auth_data)),await a(Bt()).unwrap(),r("/")}catch(c){console.error("Login failed:",c),c.response?.data?.message&&d.setError("root",{message:c.response.data.message})}}return e.jsx("div",{className:y("grid gap-6",s),...t,children:e.jsx(Se,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(u),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(b,{control:d.control,name:"email",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:i("signIn.email")}),e.jsx(N,{children:e.jsx(D,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"password",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:i("signIn.password")}),e.jsx(N,{children:e.jsx(Fl,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(L,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(P,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const ge=Tr,as=Dr,Ud=Pr,Gs=Nn,Il=m.forwardRef(({className:s,...n},t)=>e.jsx(Da,{ref:t,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));Il.displayName=Da.displayName;const de=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Ud,{children:[e.jsx(Il,{}),e.jsxs(Pa,{ref:r,className:y("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...t,children:[n,e.jsxs(Nn,{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(ms,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));de.displayName=Pa.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Le=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Le.displayName="DialogFooter";const fe=m.forwardRef(({className:s,...n},t)=>e.jsx(La,{ref:t,className:y("text-lg font-semibold leading-none tracking-tight",s),...n}));fe.displayName=La.displayName;const Ve=m.forwardRef(({className:s,...n},t)=>e.jsx(Ea,{ref:t,className:y("text-sm text-muted-foreground",s),...n}));Ve.displayName=Ea.displayName;const St=it("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),G=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?vn:"button";return e.jsx(l,{className:y(St({variant:n,size:t,className:s})),ref:i,...a})});G.displayName="Button";const zs=ho,$s=go,Kd=fo,Bd=m.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Lr,{ref:a,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...r,children:[t,e.jsx(_n,{className:"ml-auto h-4 w-4"})]}));Bd.displayName=Lr.displayName;const Gd=m.forwardRef(({className:s,...n},t)=>e.jsx(Er,{ref:t,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));Gd.displayName=Er.displayName;const Ls=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(uo,{children:e.jsx(Rr,{ref:r,sideOffset:n,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t})}));Ls.displayName=Rr.displayName;const _e=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Fr,{ref:r,className:y("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...t}));_e.displayName=Fr.displayName;const Wd=m.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Ir,{ref:a,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Vr,{children:e.jsx(ot,{className:"h-4 w-4"})})}),n]}));Wd.displayName=Ir.displayName;const Yd=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Mr,{ref:r,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Vr,{children:e.jsx(xo,{className:"h-4 w-4 fill-current"})})}),n]}));Yd.displayName=Mr.displayName;const En=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Or,{ref:r,className:y("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));En.displayName=Or.displayName;const rt=m.forwardRef(({className:s,...n},t)=>e.jsx(zr,{ref:t,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));rt.displayName=zr.displayName;const pn=({className:s,...n})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...n});pn.displayName="DropdownMenuShortcut";const sn=[{code:"en-US",name:"English",flag:po,shortName:"EN"},{code:"zh-CN",name:"中文",flag:jo,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:vo,shortName:"KR"}];function Vl(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=sn.find(a=>a.code===s.language)||sn[1],r=t.flag;return e.jsxs(zs,{children:[e.jsx($s,{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(Ls,{align:"end",className:"w-[120px]",children:sn.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(_e,{onClick:()=>n(a.code),className:y("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:y("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function Jd(){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(Vl,{})}),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(Ee,{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(Hd,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(de,{className:"max-w-[90vw] sm:max-w-lg",children:e.jsxs(ve,{children:[e.jsx(fe,{children:t("signIn.resetPassword.title")}),e.jsx(Ve,{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:()=>wa(r).then(()=>{A.success(t("common:copy.success"))}),children:e.jsx(bo,{className:"h-4 w-4"})})]})})]})})})]})}const Qd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"})),ze=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:y("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",t&&"md:h-svh",s),...r}));ze.displayName="Layout";const $e=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));$e.displayName="LayoutHeader";const He=m.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));He.displayName="LayoutBody";const Ml=yo,Ol=No,zl=_o,be=wo,ue=Co,xe=So,ce=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx($r,{ref:r,sideOffset:n,className:y("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...t}));ce.displayName=$r.displayName;function Ma(){const{pathname:s}=bn();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function $l({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 Xd(){const[s,n]=$l({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 Zd({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const u=`${a(d.title)}-${d.href}`;return n&&l?m.createElement(tm,{...d,sub:l,key:u,closeNav:r}):n?m.createElement(sm,{...d,key:u,closeNav:r}):l?m.createElement(em,{...d,sub:l,key:u,closeNav:r}):m.createElement(Al,{...d,key:u,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",t),children:e.jsx(be,{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 Al({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Ma(),{t:d}=V();return e.jsxs(Ys,{to:r,onClick:a,className:y(Tt({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 em({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ma(),{isExpanded:l,toggleItem:d}=Xd(),{t:u}=V(),o=!!r?.find(k=>i(k.href)),c=u(s),h=l(c)||o;return e.jsxs(Ml,{open:h,onOpenChange:()=>d(c),children:[e.jsxs(Ol,{className:y(Tt({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),u(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(t)}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Ar,{stroke:1})})]}),e.jsx(zl,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(k=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Al,{...k,subLink:!0,closeNav:a})},u(k.title)))})})]})}function sm({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Ma(),{t:l}=V();return e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(Ys,{to:r,onClick:a,className:y(Tt({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 tm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ma(),{t:l}=V(),d=!!r?.find(u=>i(u.href));return e.jsxs(zs,{children:[e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsx($s,{asChild:!0,children:e.jsx(P,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ce,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Ar,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(Ls,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(En,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(rt,{}),r.map(({title:u,icon:o,label:c,href:h})=>e.jsx(_e,{asChild:!0,children:e.jsxs(Ys,{to:h,onClick:a,className:`${i(h)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(u)}),c&&e.jsx("span",{className:"ml-auto text-xs",children:l(c)})]})},`${l(u)}-${h}`))]})]})}const ql=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(ko,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(To,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(qr,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(wn,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Do,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Po,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Jn,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Lo,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(Hr,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Eo,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Ur,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Ro,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Fo,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Io,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Jn,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Vo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Mo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(Oo,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(Kr,{size:18})}]}];function am({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:y(`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(ze,{className:`flex h-full flex-col ${r?"h-[100vh] md:h-full":""}`,children:[e.jsxs($e,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(zo,{}):e.jsx($o,{})})]}),e.jsx(Zd,{id:"sidebar-menu",className:y("flex-1 overflow-auto overscroll-contain",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:ql}),e.jsx("div",{className:y("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:y("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:y("whitespace-nowrap tracking-wide","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(P,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(Ao,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function nm(){const[s,n]=$l({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 rm(){const[s,n]=nm();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(am,{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(yn,{})})]})}const lm=Object.freeze(Object.defineProperty({__proto__:null,default:rm},Symbol.toStringTag,{value:"Module"})),Js=m.forwardRef(({className:s,...n},t)=>e.jsx(es,{ref:t,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Js.displayName=es.displayName;const im=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(de,{className:"overflow-hidden p-0",children:e.jsx(Js,{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})})}),ut=m.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(qo,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(es.Input,{ref:t,className:y("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));ut.displayName=es.Input.displayName;const Qs=m.forwardRef(({className:s,...n},t)=>e.jsx(es.List,{ref:t,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Qs.displayName=es.List.displayName;const xt=m.forwardRef((s,n)=>e.jsx(es.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));xt.displayName=es.Empty.displayName;const fs=m.forwardRef(({className:s,...n},t)=>e.jsx(es.Group,{ref:t,className:y("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));fs.displayName=es.Group.displayName;const Pt=m.forwardRef(({className:s,...n},t)=>e.jsx(es.Separator,{ref:t,className:y("-mx-1 h-px bg-border",s),...n}));Pt.displayName=es.Separator.displayName;const We=m.forwardRef(({className:s,...n},t)=>e.jsx(es.Item,{ref:t,className:y("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));We.displayName=es.Item.displayName;function om(){const s=[];for(const n of ql)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function ns(){const[s,n]=m.useState(!1),t=As(),r=om(),{t:a}=V("search"),{t:i}=V("nav");m.useEffect(()=>{const d=u=>{u.key==="k"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),n(o=>!o))};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(Cn,{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(im,{open:s,onOpenChange:n,children:[e.jsx(ut,{placeholder:a("placeholder")}),e.jsxs(Qs,{children:[e.jsx(xt,{children:a("noResults")}),e.jsx(fs,{heading:a("title"),children:r.map(d=>e.jsxs(We,{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 Ye(){const{theme:s,setTheme:n}=ud();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(P,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(Ho,{size:20}):e.jsx(Uo,{size:20})}),e.jsx(Vl,{})]})}const Hl=m.forwardRef(({className:s,...n},t)=>e.jsx(Br,{ref:t,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));Hl.displayName=Br.displayName;const Ul=m.forwardRef(({className:s,...n},t)=>e.jsx(Gr,{ref:t,className:y("aspect-square h-full w-full",s),...n}));Ul.displayName=Gr.displayName;const Kl=m.forwardRef(({className:s,...n},t)=>e.jsx(Wr,{ref:t,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));Kl.displayName=Wr.displayName;function Je(){const s=As(),n=kr(),t=Ko(Od),{t:r}=V(["common"]),a=()=>{Tl(),n(Md()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(zs,{children:[e.jsx($s,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(Hl,{className:"h-8 w-8",children:[e.jsx(Ul,{src:t?.avatar_url,alt:i}),e.jsx(Kl,{children:l})]})})}),e.jsxs(Ls,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(En,{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(rt,{}),e.jsx(_e,{asChild:!0,children:e.jsxs(Ys,{to:"/config/system",children:[r("common:settings"),e.jsx(pn,{children:"⌘S"})]})}),e.jsx(rt,{}),e.jsxs(_e,{onClick:a,children:[r("common:logout"),e.jsx(pn,{children:"⇧⌘Q"})]})]})]})}const J=Bo,rs=ec,Q=Go,W=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Yr,{ref:r,className:y("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...t,children:[n,e.jsx(Wo,{asChild:!0,children:e.jsx(Sn,{className:"h-4 w-4 opacity-50"})})]}));W.displayName=Yr.displayName;const Bl=m.forwardRef(({className:s,...n},t)=>e.jsx(Jr,{ref:t,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Yo,{className:"h-4 w-4"})}));Bl.displayName=Jr.displayName;const Gl=m.forwardRef(({className:s,...n},t)=>e.jsx(Qr,{ref:t,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Sn,{className:"h-4 w-4"})}));Gl.displayName=Qr.displayName;const Y=m.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(Jo,{children:e.jsxs(Xr,{ref:a,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",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(Bl,{}),e.jsx(Qo,{className:y("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Gl,{})]})}));Y.displayName=Xr.displayName;const cm=m.forwardRef(({className:s,...n},t)=>e.jsx(Zr,{ref:t,className:y("px-2 py-1.5 text-sm font-semibold",s),...n}));cm.displayName=Zr.displayName;const $=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(el,{ref:r,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xo,{children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsx(Zo,{children:n})]}));$.displayName=el.displayName;const dm=m.forwardRef(({className:s,...n},t)=>e.jsx(sl,{ref:t,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));dm.displayName=sl.displayName;function ks({className:s,classNames:n,showOutsideDays:t=!0,...r}){return e.jsx(sc,{showOutsideDays:t,className:y("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:y(St({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:y("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:y(St({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:a,...i})=>e.jsx(tl,{className:y("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(_n,{className:y("h-4 w-4",a),...i})},...r})}ks.displayName="Calendar";const os=ac,cs=nc,Ze=m.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(tc,{children:e.jsx(al,{ref:a,align:n,sideOffset:t,className:y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})}));Ze.displayName=al.displayName;const Us={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},$t=s=>(s/100).toFixed(2),mm=({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"))?`¥${$t(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},um=[{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"}],xm=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=_s(t,7);break;case"30d":r=_s(t,30);break;case"90d":r=_s(t,90);break;case"180d":r=_s(t,180);break;case"365d":r=_s(t,365);break;default:r=_s(t,30)}return{startDate:r,endDate:t}};function hm(){const[s,n]=m.useState("amount"),[t,r]=m.useState("30d"),[a,i]=m.useState({from:_s(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:u}=xm(t,a),{data:o}=ne({queryKey:["orderStat",{start_date:Pe(d,"yyyy-MM-dd"),end_date:Pe(u,"yyyy-MM-dd")}],queryFn:async()=>{const{data:c}=await Ca.getOrderStat({start_date:Pe(d,"yyyy-MM-dd"),end_date:Pe(u,"yyyy-MM-dd")});return c},refetchInterval:3e4});return e.jsxs(Ee,{children:[e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ge,{children:l("dashboard:overview.title")}),e.jsxs(Os,{children:[o?.summary.start_date," ",l("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(J,{value:t,onValueChange:c=>r(c),children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Q,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(Y,{children:um.map(c=>e.jsx($,{value:c.value,children:l(c.label)},c.value))})]}),t==="custom"&&e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Cs,{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:[Pe(a.from,"yyyy-MM-dd")," -"," ",Pe(a.to,"yyyy-MM-dd")]}):Pe(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(Ze,{className:"w-auto p-0",align:"end",children:e.jsx(ks,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:c=>{c?.from&&c?.to&&i({from:c.from,to:c.to})},numberOfMonths:2})})]})]}),e.jsx(Dt,{value:s,onValueChange:c=>n(c),children:e.jsxs(dt,{children:[e.jsx(Xe,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(Xe,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(Ie,{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:["¥",$t(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",$t(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",$t(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(rc,{width:"100%",height:"100%",children:e.jsxs(lc,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Us.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Us.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:Us.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Us.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(ic,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>Pe(new Date(c),"MM-dd",{locale:mc})}),e.jsx(oc,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>s==="amount"?`¥${$t(c)}`:l("dashboard:overview.transactions",{count:c})}),e.jsx(cc,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(dc,{content:e.jsx(mm,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Qn,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Us.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Qn,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Us.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xn,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Us.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Xn,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Us.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function je({className:s,...n}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...n})}function gm(){return e.jsxs(Ee,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(je,{className:"h-4 w-[120px]"}),e.jsx(je,{className:"h-4 w-4"})]}),e.jsxs(Ie,{children:[e.jsx(je,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(je,{className:"h-4 w-[100px]"})]})]})]})}function fm(){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(gm,{},n))})}var le=(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))(le||{});const Vt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Mt={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var ws=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(ws||{}),Ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(Ne||{});const ia={0:"待确认",1:"发放中",2:"有效",3:"无效"},oa={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var qe=(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))(qe||{});const pm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var oe=(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))(oe||{});const js=[{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"}],is={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50",anytls:"#7E57C2"};var hs=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(hs||{});const jm={1:"按金额优惠",2:"按比例优惠"};var Ws=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Ws||{}),Qe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Qe||{}),Gt=(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))(Gt||{});function Ks({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(Ee,{className:y("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(Ge,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(gc,{className:y("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("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 vm({className:s}){const n=As(),{t}=V(),{data:r,isLoading:a}=ne({queryKey:["dashboardStats"],queryFn:async()=>(await Ca.getStatsData()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(fm,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",Ne.PENDING.toString()),l.set("status",le.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Ks,{title:t("dashboard:stats.todayIncome"),value:Vs(r.todayIncome),icon:e.jsx(uc,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Ks,{title:t("dashboard:stats.monthlyIncome"),value:Vs(r.currentMonthIncome),icon:e.jsx(kn,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Ks,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(xc,{className:y("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(Ks,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(hc,{className:y("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(Ks,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(ja,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Ks,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Ks,{title:t("dashboard:stats.monthlyUpload"),value:Oe(r.monthTraffic.upload),icon:e.jsx(wt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:Oe(r.todayTraffic.upload)})}),e.jsx(Ks,{title:t("dashboard:stats.monthlyDownload"),value:Oe(r.monthTraffic.download),icon:e.jsx(va,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:Oe(r.todayTraffic.download)})})]})}const lt=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(nl,{ref:r,className:y("relative overflow-hidden",s),...t,children:[e.jsx(fc,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(ka,{}),e.jsx(pc,{})]}));lt.displayName=nl.displayName;const ka=m.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(rl,{ref:r,orientation:n,className:y("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...t,children:e.jsx(jc,{className:"relative flex-1 rounded-full bg-border"})}));ka.displayName=rl.displayName;const jn={today:{getValue:()=>{const s=bc();return{start:s,end:yc(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:_s(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:_s(s,30),end:s}}},custom:{getValue:()=>null}};function ur({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(J,{value:s,onValueChange:t,children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Q,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(Y,{position:"popper",className:"z-50",children:Object.entries(jn).map(([l])=>e.jsx($,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(Cs,{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:[Pe(n.from,"yyyy-MM-dd")," -"," ",Pe(n.to,"yyyy-MM-dd")]}):Pe(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(Ze,{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 jt=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function bm({className:s}){const{t:n}=V(),[t,r]=m.useState("today"),[a,i]=m.useState({from:_s(new Date,7),to:new Date}),[l,d]=m.useState("today"),[u,o]=m.useState({from:_s(new Date,7),to:new Date}),c=m.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:jn[t].getValue(),[t,a]),h=m.useMemo(()=>l==="custom"?{start:u.from,end:u.to}:jn[l].getValue(),[l,u]),{data:k}=ne({queryKey:["nodeTrafficRank",c.start,c.end],queryFn:()=>Ca.getNodeTrafficData({type:"node",start_time:ke.round(c.start.getTime()/1e3),end_time:ke.round(c.end.getTime()/1e3)}),refetchInterval:3e4}),{data:C}=ne({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>Ca.getNodeTrafficData({type:"user",start_time:ke.round(h.start.getTime()/1e3),end_time:ke.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Ee,{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(Ge,{className:"flex items-center text-base font-medium",children:[e.jsx(vc,{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(ur,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(Zn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Ie,{className:"flex-1",children:k?.data?e.jsxs(lt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:k.data.map(S=>e.jsx(be,{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:S.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?e.jsx(dn,{className:"mr-1 h-3 w-3"}):e.jsx(mn,{className:"mr-1 h-3 w-3"}),Math.abs(S.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:`${S.value/k.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:jt(S.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:jt(S.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:jt(S.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?"+":"",S.change,"%"]})]})})]})},S.id))}),e.jsx(ka,{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(Ee,{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(Ge,{className:"flex items-center text-base font-medium",children:[e.jsx(ja,{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(ur,{selectedRange:l,customDateRange:u,onRangeChange:d,onCustomRangeChange:o}),e.jsx(Zn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Ie,{className:"flex-1",children:C?.data?e.jsxs(lt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:C.data.map(S=>e.jsx(be,{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:S.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?e.jsx(dn,{className:"mr-1 h-3 w-3"}):e.jsx(mn,{className:"mr-1 h-3 w-3"}),Math.abs(S.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:`${S.value/C.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:jt(S.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:jt(S.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:jt(S.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?"+":"",S.change,"%"]})]})})]})},S.id))}),e.jsx(ka,{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 ym=it("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:y(ym({variant:n}),s),...t})}const ha=m.forwardRef(({className:s,value:n,...t},r)=>e.jsx(ll,{ref:r,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(Nc,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));ha.displayName=ll.displayName;const Rn=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:y("w-full caption-bottom text-sm",s),...n})}));Rn.displayName="Table";const Fn=m.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:y("[&_tr]:border-b",s),...n}));Fn.displayName="TableHeader";const In=m.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:y("[&_tr:last-child]:border-0",s),...n}));In.displayName="TableBody";const Nm=m.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Nm.displayName="TableFooter";const Bs=m.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Bs.displayName="TableRow";const Vn=m.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:y("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Vn.displayName="TableHead";const _t=m.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:y("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));_t.displayName="TableCell";const _m=m.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:y("mt-4 text-sm text-muted-foreground",s),...n}));_m.displayName="TableCaption";function Mn({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(J,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:s.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx($,{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(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.firstPage")}),e.jsx(_c,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.previousPage")}),e.jsx(tl,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.nextPage")}),e.jsx(_n,{className:"h-4 w-4"})]}),e.jsxs(P,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.lastPage")}),e.jsx(wc,{className:"h-4 w-4"})]})]})]})]})}function xs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:u=!0,isLoading:o=!1}){const{t:c}=V("common"),h=m.useRef(null),k=s.getAllColumns().filter(_=>_.getIsPinned()==="left"),C=s.getAllColumns().filter(_=>_.getIsPinned()==="right"),S=_=>k.slice(0,_).reduce((f,T)=>f+(T.getSize()??0),0),p=_=>C.slice(_+1).reduce((f,T)=>f+(T.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:h,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:s.getHeaderGroups().map(_=>e.jsx(Bs,{className:"hover:bg-transparent",children:_.headers.map((f,T)=>{const E=f.column.getIsPinned()==="left",g=f.column.getIsPinned()==="right",w=E?S(k.indexOf(f.column)):void 0,R=g?p(C.indexOf(f.column)):void 0;return e.jsx(Vn,{colSpan:f.colSpan,style:{width:f.getSize(),...E&&{left:w},...g&&{right:R}},className:y("h-11 bg-card px-4 text-muted-foreground",(E||g)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",E&&"before:right-0",g&&"before:left-0"]),children:f.isPlaceholder?null:ba(f.column.columnDef.header,f.getContext())},f.id)})},_.id))}),e.jsx(In,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((_,f)=>e.jsx(Bs,{"data-state":_.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:T=>r?.(T,f),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:T=>d?.(T,f),children:_.getVisibleCells().map((T,E)=>{const g=T.column.getIsPinned()==="left",w=T.column.getIsPinned()==="right",R=g?S(k.indexOf(T.column)):void 0,H=w?p(C.indexOf(T.column)):void 0;return e.jsx(_t,{style:{width:T.column.getSize(),...g&&{left:R},...w&&{right:H}},className:y("bg-card",(g||w)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",g&&"before:right-0",w&&"before:left-0"]),children:ba(T.column.columnDef.cell,T.getContext())},T.id)})},_.id)):e.jsx(Bs,{children:e.jsx(_t,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:c("table.noData")})})})]})})}),u&&e.jsx(Mn,{table:s})]})}const ga=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"})},Ot=il(),zt=il();function ca({data:s,isLoading:n,searchKeyword:t,selectedLevel:r,total:a,currentPage:i,pageSize:l,onViewDetail:d,onPageChange:u}){const{t:o}=V(),c=C=>{switch(C.toLowerCase()){case"info":return e.jsx(qt,{className:"h-4 w-4 text-blue-500"});case"warning":return e.jsx(Ht,{className:"h-4 w-4 text-yellow-500"});case"error":return e.jsx(xn,{className:"h-4 w-4 text-red-500"});default:return e.jsx(qt,{className:"h-4 w-4 text-slate-500"})}},h=m.useMemo(()=>[Ot.accessor("level",{id:"level",header:()=>o("dashboard:systemLog.level","级别"),size:80,cell:({getValue:C,row:S})=>{const p=C();return e.jsxs("div",{className:"flex items-center gap-1",children:[c(p),e.jsx("span",{className:y(p.toLowerCase()==="error"&&"text-red-600",p.toLowerCase()==="warning"&&"text-yellow-600",p.toLowerCase()==="info"&&"text-blue-600"),children:p})]})}}),Ot.accessor("created_at",{id:"created_at",header:()=>o("dashboard:systemLog.time","时间"),size:160,cell:({getValue:C})=>ga(C())}),Ot.accessor(C=>C.title||C.message||"",{id:"title",header:()=>o("dashboard:systemLog.logTitle","标题"),cell:({getValue:C})=>e.jsx("span",{className:"inline-block max-w-[300px] truncate",children:C()})}),Ot.accessor("method",{id:"method",header:()=>o("dashboard:systemLog.method","请求方法"),size:100,cell:({getValue:C})=>{const S=C();return S?e.jsx(U,{variant:"outline",className:y(S==="GET"&&"border-blue-200 bg-blue-50 text-blue-700",S==="POST"&&"border-green-200 bg-green-50 text-green-700",S==="PUT"&&"border-amber-200 bg-amber-50 text-amber-700",S==="DELETE"&&"border-red-200 bg-red-50 text-red-700"),children:S}):null}}),Ot.display({id:"actions",header:()=>o("dashboard:systemLog.action","操作"),size:80,cell:({row:C})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>d(C.original),"aria-label":o("dashboard:systemLog.viewDetail","查看详情"),children:e.jsx(un,{className:"h-4 w-4"})})})],[o,d]),k=ss({data:s,columns:h,getCoreRowModel:ts(),getPaginationRowModel:us(),pageCount:Math.ceil(a/l),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:l}},onPaginationChange:C=>{if(typeof C=="function"){const S=C({pageIndex:i-1,pageSize:l});u(S.pageIndex+1)}else u(C.pageIndex+1)}});return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(xs,{table:k,showPagination:!1,isLoading:n}),e.jsx(Mn,{table:k}),(t||r&&r!=="all")&&e.jsx("div",{className:"text-center text-sm text-muted-foreground",children:t&&r&&r!=="all"?`筛选结果: 包含"${t}"且级别为"${r}"的日志共 ${a} 条`:t?`搜索结果: 包含"${t}"的日志共 ${a} 条`:`筛选结果: 级别为"${r}"的日志共 ${a} 条`})]})}function wm(){const{t:s}=V(),[n,t]=m.useState(0),[r,a]=m.useState(!1),[i,l]=m.useState(1),[d]=m.useState(10),[u,o]=m.useState(null),[c,h]=m.useState(!1),[k,C]=m.useState(!1),[S,p]=m.useState(1),[_]=m.useState(10),[f,T]=m.useState(null),[E,g]=m.useState(!1),[w,R]=m.useState(""),[H,I]=m.useState(""),[K,ae]=m.useState("all"),[ee,te]=m.useState(!1),[q,F]=m.useState(30),[X,ys]=m.useState("all"),[De,ie]=m.useState(1e3),[Ns,Fs]=m.useState(!1),[Xs,Lt]=m.useState(null),[Zt,Et]=m.useState(!1);m.useEffect(()=>{const B=setTimeout(()=>{I(w),w!==H&&p(1)},500);return()=>clearTimeout(B)},[w]);const{data:qs,isLoading:Ja,refetch:se,isRefetching:pe}=ne({queryKey:["systemStatus",n],queryFn:async()=>(await he.getSystemStatus()).data,refetchInterval:3e4}),{data:re,isLoading:Zs,refetch:pg,isRefetching:Un}=ne({queryKey:["queueStats",n],queryFn:async()=>(await he.getQueueStats()).data,refetchInterval:3e4}),{data:Kn,isLoading:_i,refetch:wi}=ne({queryKey:["failedJobs",i,d],queryFn:async()=>{const B=await he.getHorizonFailedJobs({current:i,page_size:d});return{data:B.data,total:B.total||0}},enabled:r}),{data:Bn,isLoading:ea,refetch:Ci}=ne({queryKey:["systemLogs",S,_,K,H],queryFn:async()=>{const B={current:S,page_size:_};K&&K!=="all"&&(B.level=K),H.trim()&&(B.keyword=H.trim());const Hs=await he.getSystemLog(B);return{data:Hs.data,total:Hs.total||0}},enabled:k}),Gn=Kn?.data||[],Si=Kn?.total||0,sa=Bn?.data||[],ta=Bn?.total||0,ki=m.useMemo(()=>[zt.display({id:"failed_at",header:()=>s("dashboard:queue.details.time","时间"),cell:({row:B})=>ga(B.original.failed_at)}),zt.display({id:"queue",header:()=>s("dashboard:queue.details.queue","队列"),cell:({row:B})=>B.original.queue}),zt.display({id:"name",header:()=>s("dashboard:queue.details.name","任务名称"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[150px] truncate",children:B.original.name})}),e.jsx(ce,{children:e.jsx("span",{children:B.original.name})})]})})}),zt.display({id:"exception",header:()=>s("dashboard:queue.details.exception","异常信息"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[200px] truncate",children:B.original.exception.split(` -`)[0]})}),e.jsx(ce,{className:"max-w-[300px] whitespace-pre-wrap",children:e.jsx("span",{children:B.original.exception})})]})})}),zt.display({id:"actions",header:()=>s("dashboard:queue.details.action","操作"),size:80,cell:({row:B})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Li(B.original),"aria-label":s("dashboard:queue.details.viewDetail","查看详情"),children:e.jsx(un,{className:"h-4 w-4"})})})],[s]),Wn=ss({data:Gn,columns:ki,getCoreRowModel:ts(),getPaginationRowModel:us(),pageCount:Math.ceil(Si/d),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:d}},onPaginationChange:B=>{if(typeof B=="function"){const Hs=B({pageIndex:i-1,pageSize:d});Yn(Hs.pageIndex+1)}else Yn(B.pageIndex+1)}}),Ti=()=>{t(B=>B+1)},Yn=B=>{l(B)},aa=B=>{p(B)},Di=B=>{ae(B),p(1)},Pi=()=>{R(""),I(""),ae("all"),p(1)},na=B=>{T(B),g(!0)},Li=B=>{o(B),h(!0)},Ei=async()=>{try{const B=await he.getLogClearStats({days:q,level:X==="all"?void 0:X});Lt(B.data),Et(!0)}catch(B){console.error("获取清理统计失败:",B),A.error("获取清理统计失败")}},Ri=async()=>{Fs(!0);try{const B=await he.clearSystemLog({days:q,level:X==="all"?void 0:X,limit:De});B.data.status==="success"?(A.success(`清理完成!已清理 ${B.data.cleared_count} 条日志`),te(!1),Et(!1),Lt(null),se()):A.error(B.data.message||"清理失败")}catch(B){console.error("清理日志失败:",B),A.error("清理日志失败")}finally{Fs(!1)}};if(Ja||Zs)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(ya,{className:"h-6 w-6 animate-spin"})});const Fi=B=>B?e.jsx(ol,{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(Ee,{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(Ge,{className:"flex items-center gap-2",children:[e.jsx(Cc,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Os,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:Ti,disabled:pe||Un,children:e.jsx(Qa,{className:y("h-4 w-4",(pe||Un)&&"animate-spin")})})]}),e.jsx(Ie,{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:[Fi(re?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(U,{variant:re?.status?"secondary":"destructive",children:re?.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:re?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(be,{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:re?.recentJobs||0}),e.jsx(ha,{value:(re?.recentJobs||0)/(re?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:re?.periods?.recentJobs||0})})})]})}),e.jsx(be,{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:re?.jobsPerMinute||0}),e.jsx(ha,{value:(re?.jobsPerMinute||0)/(re?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:re?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Fe,{children:[e.jsxs(Ge,{className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Os,{children:s("dashboard:queue.details.description")})]}),e.jsx(Ie,{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:re?.failedJobs||0}),e.jsx(un,{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:re?.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:[re?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:re?.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:[re?.processes||0," /"," ",(re?.processes||0)+(re?.pausedMasters||0)]})]}),e.jsx(ha,{value:(re?.processes||0)/((re?.processes||0)+(re?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]}),e.jsxs(Ee,{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(Ge,{className:"flex items-center gap-2",children:[e.jsx(er,{className:"h-5 w-5"}),s("dashboard:systemLog.title","系统日志")]}),e.jsx(Os,{children:s("dashboard:systemLog.description","查看系统运行日志记录")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>C(!0),children:s("dashboard:systemLog.viewAll","查看全部")}),e.jsxs(G,{variant:"outline",onClick:()=>te(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.clearLogs","清理日志")]})]})]}),e.jsx(Ie,{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(qt,{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:qs?.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(Ht,{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:qs?.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(xn,{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:qs?.logs?.error||0})]})]}),qs?.logs&&qs.logs.total>0&&e.jsxs("div",{className:"mt-3 text-center text-sm text-muted-foreground",children:[s("dashboard:systemLog.totalLogs","总日志数"),":"," ",qs.logs.total]})]})})]}),e.jsx(ge,{open:r,onOpenChange:a,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:queue.details.failedJobsDetailTitle","失败任务详情")})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(xs,{table:Wn,showPagination:!1,isLoading:_i}),e.jsx(Mn,{table:Wn}),Gn.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:s("dashboard:queue.details.noFailedJobs","暂无失败任务")})]}),e.jsxs(Le,{children:[e.jsxs(G,{variant:"outline",onClick:()=>wi(),children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh","刷新")]}),e.jsx(Gs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})]})]})}),e.jsx(ge,{open:c,onOpenChange:h,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:queue.details.jobDetailTitle","任务详情")})}),u&&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","任务ID")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:u.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:u.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:u.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:u.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:u.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:u.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(u.payload),null,2)}catch{return u.payload}})()})})]})]}),e.jsx(Le,{children:e.jsx(G,{variant:"outline",onClick:()=>h(!1),children:s("common.close","关闭")})})]})}),e.jsx(ge,{open:k,onOpenChange:C,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:systemLog.title","系统日志")})}),e.jsxs(Dt,{value:K,onValueChange:Di,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(dt,{className:"grid w-auto grid-cols-4",children:[e.jsxs(Xe,{value:"all",className:"flex items-center gap-2",children:[e.jsx(er,{className:"h-4 w-4"}),s("dashboard:systemLog.tabs.all","全部")]}),e.jsxs(Xe,{value:"info",className:"flex items-center gap-2",children:[e.jsx(qt,{className:"h-4 w-4 text-blue-500"}),s("dashboard:systemLog.tabs.info","信息")]}),e.jsxs(Xe,{value:"warning",className:"flex items-center gap-2",children:[e.jsx(Ht,{className:"h-4 w-4 text-yellow-500"}),s("dashboard:systemLog.tabs.warning","警告")]}),e.jsxs(Xe,{value:"error",className:"flex items-center gap-2",children:[e.jsx(xn,{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(Cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(D,{placeholder:s("dashboard:systemLog.search","搜索日志内容..."),value:w,onChange:B=>R(B.target.value),className:"w-full md:w-64"})]})]}),e.jsx(Ss,{value:"all",className:"mt-0",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:_,onViewDetail:na,onPageChange:aa})}),e.jsx(Ss,{value:"info",className:"mt-0 overflow-x-auto",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:_,onViewDetail:na,onPageChange:aa})}),e.jsx(Ss,{value:"warning",className:"mt-0",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:_,onViewDetail:na,onPageChange:aa})}),e.jsx(Ss,{value:"error",className:"mt-0",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:_,onViewDetail:na,onPageChange:aa})})]}),e.jsxs(Le,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Ci(),children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh","刷新")]}),e.jsx(G,{variant:"outline",onClick:Pi,children:s("dashboard:systemLog.filter.reset","重置筛选")}),e.jsx(Gs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})]})]})}),e.jsx(ge,{open:E,onOpenChange:g,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:systemLog.detailTitle","日志详情")})}),f&&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(qt,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:f.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:ga(f.created_at)||ga(f.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:f.title||f.message||""})]}),(f.host||f.ip)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.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:f.host})]}),f.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","IP地址")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:f.ip})]})]}),f.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","URI")}),e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 p-3",children:e.jsx("code",{className:"text-sm",children:f.uri})})]}),f.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:f.method})})]}),f.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(f.data),null,2)}catch{return f.data}})()})})]}),f.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 B=JSON.parse(f.context);if(B.exception){const Hs=B.exception,Ii=Hs["\0*\0message"]||"",Vi=Hs["\0*\0file"]||"",Mi=Hs["\0*\0line"]||"";return`${Ii} +import{r as m,j as e,t as Oi,c as zi,I as Yt,a as it,S as vn,u as As,b as $i,d as bn,R as Nr,e as _r,f as Ai,F as qi,C as Hi,L as wr,T as Cr,g as Sr,h as Ui,i as Ki,k as Bi,l as Gi,m as A,z as x,n as V,o as we,p as Ce,q as ne,s as Ts,v as ke,w as Wi,x as Yi,O as yn,y as Ji,A as Qi,B as Xi,D as Zi,E as eo,G as so,Q as to,H as ao,J as no,K as ro,P as lo,M as io,N as oo,U as co,V as mo,W as kr,X as Tr,Y as Da,Z as Pa,_ as Nn,$ as ms,a0 as La,a1 as Ra,a2 as Dr,a3 as Pr,a4 as Lr,a5 as _n,a6 as Rr,a7 as uo,a8 as Er,a9 as Fr,aa as Ir,ab as Vr,ac as ot,ad as Mr,ae as xo,af as Or,ag as zr,ah as ho,ai as go,aj as fo,ak as po,al as jo,am as vo,an as bo,ao as yo,ap as No,aq as _o,ar as wo,as as $r,at as Co,au as So,av as Ys,aw as Ar,ax as ko,ay as To,az as qr,aA as wn,aB as Do,aC as Po,aD as Jn,aE as Lo,aF as Hr,aG as Ro,aH as Ur,aI as Eo,aJ as Fo,aK as Io,aL as Vo,aM as Mo,aN as Oo,aO as Kr,aP as zo,aQ as $o,aR as Ao,aS as es,aT as qo,aU as Cn,aV as Ho,aW as Uo,aX as Br,aY as Gr,aZ as Wr,a_ as Ko,a$ as Bo,b0 as Go,b1 as Yr,b2 as Wo,b3 as Sn,b4 as Jr,b5 as Yo,b6 as Qr,b7 as Jo,b8 as Xr,b9 as Qo,ba as Zr,bb as el,bc as Xo,bd as Zo,be as sl,bf as ec,bg as sc,bh as tl,bi as tc,bj as al,bk as ac,bl as nc,bm as ws,bn as Pe,bo as Ss,bp as rc,bq as lc,br as ic,bs as oc,bt as cc,bu as dc,bv as Qn,bw as Xn,bx as mc,by as uc,bz as kn,bA as xc,bB as hc,bC as ja,bD as wt,bE as va,bF as gc,bG as nl,bH as fc,bI as pc,bJ as rl,bK as jc,bL as vc,bM as Zn,bN as dn,bO as mn,bP as bc,bQ as yc,bR as ll,bS as Nc,bT as _c,bU as wc,bV as ba,bW as un,bX as ss,bY as ya,bZ as Cc,b_ as Qa,b$ as Sc,c0 as er,c1 as ds,c2 as qt,c3 as Ht,c4 as xn,c5 as il,c6 as ts,c7 as us,c8 as ol,c9 as cl,ca as kc,cb as Tc,cc as Dc,cd as Pc,ce as Lc,cf as dl,cg as Rc,ch as Ec,ci as Be,cj as sr,ck as Fc,cl as ml,cm as ul,cn as xl,co as hl,cp as gl,cq as fl,cr as Ic,cs as Vc,ct as Mc,cu as Ea,cv as ct,cw as bs,cx as ys,cy as Oc,cz as zc,cA as $c,cB as Ac,cC as pl,cD as qc,cE as Hc,cF as Uc,cG as Kc,cH as hn,cI as Tn,cJ as Dn,cK as Bc,cL as Rs,cM as Es,cN as Fa,cO as Gc,cP as Na,cQ as Wc,cR as tr,cS as jl,cT as ar,cU as _a,cV as Yc,cW as Jc,cX as Qc,cY as Xc,cZ as Zc,c_ as vl,c$ as ed,d0 as sd,d1 as bl,d2 as gn,d3 as yl,d4 as td,d5 as fn,d6 as Nl,d7 as ad,d8 as Ut,d9 as Pn,da as nd,db as rd,dc as nr,dd as _l,de as ld,df as id,dg as od,dh as rr}from"./vendor.js";import"./index.js";var yg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ng(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function cd(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 dd={theme:"system",setTheme:()=>null},wl=m.createContext(dd);function md({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 u=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(u);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(wl.Provider,{...r,value:l,children:s})}const ud=()=>{const s=m.useContext(wl);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},xd=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),hd=function(s,n){return new URL(s,n).href},lr={},ye=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]"),u=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(o=>{if(o=hd(o,r),o in lr)return;lr[o]=!0;const c=o.endsWith(".css"),h=c?'[rel="stylesheet"]':"";if(!!r)for(let S=l.length-1;S>=0;S--){const f=l[S];if(f.href===o&&(!c||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const C=document.createElement("link");if(C.rel=c?"stylesheet":xd,c||(C.as="script"),C.crossOrigin="",C.href=o,u&&C.setAttribute("nonce",u),document.head.appendChild(C),c)return new Promise((S,f)=>{C.addEventListener("load",S),C.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function b(...s){return Oi(zi(s))}const Tt=it("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:u,...o},c)=>{const h=r?vn:"button";return e.jsxs(h,{className:b(Tt({variant:n,size:t,className:s})),disabled:l||i,ref:c,...o,children:[(d&&l||!d&&!u&&l)&&e.jsx(Yt,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&u&&e.jsx("div",{className:"ml-2",children:u}),u&&l&&e.jsx(Yt,{className:"ml-2 h-4 w-4 animate-spin"})]})});L.displayName="Button";function ht({className:s,minimal:n=!1}){const t=As(),r=$i(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:b("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 ir(){const s=As();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 gd(){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 fd(s){return typeof s>"u"}function pd(s){return s===null}function jd(s){return pd(s)||fd(s)}class vd{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 jd(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 Cl({prefixKey:s="",storage:n=sessionStorage}){return new vd({prefixKey:s,storage:n})}const Sl="Xboard_",bd=function(s={}){return Cl({prefixKey:s.prefixKey||"",storage:localStorage})},yd=function(s={}){return Cl({prefixKey:s.prefixKey||"",storage:sessionStorage})},Ln=bd({prefixKey:Sl});yd({prefixKey:Sl});const kl="access_token";function Jt(){return Ln.get(kl)}function Tl(){Ln.remove(kl)}const or=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Nd({children:s}){const n=As(),t=bn(),r=Jt();return m.useEffect(()=>{if(!r.value&&!or.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),or.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const Te=m.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(Nr,{ref:a,decorative:t,orientation:n,className:b("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));Te.displayName=Nr.displayName;const _d=it("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ae=m.forwardRef(({className:s,...n},t)=>e.jsx(_r,{ref:t,className:b(_d(),s),...n}));Ae.displayName=_r.displayName;const Se=qi,Dl=m.createContext({}),v=({...s})=>e.jsx(Dl.Provider,{value:{name:s.name},children:e.jsx(Hi,{...s})}),Ia=()=>{const s=m.useContext(Dl),n=m.useContext(Pl),{getFieldState:t,formState:r}=Ai(),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}},Pl=m.createContext({}),p=m.forwardRef(({className:s,...n},t)=>{const r=m.useId();return e.jsx(Pl.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:b("space-y-2",s),...n})})});p.displayName="FormItem";const j=m.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Ia();return e.jsx(Ae,{ref:t,className:b(r&&"text-destructive",s),htmlFor:a,...n})});j.displayName="FormLabel";const y=m.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Ia();return e.jsx(vn,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});y.displayName="FormControl";const O=m.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Ia();return e.jsx("p",{ref:t,id:r,className:b("text-[0.8rem] text-muted-foreground",s),...n})});O.displayName="FormDescription";const E=m.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Ia(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:b("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});E.displayName="FormMessage";const Dt=Ui,dt=m.forwardRef(({className:s,...n},t)=>e.jsx(wr,{ref:t,className:b("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));dt.displayName=wr.displayName;const Xe=m.forwardRef(({className:s,...n},t)=>e.jsx(Cr,{ref:t,className:b("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}));Xe.displayName=Cr.displayName;const ks=m.forwardRef(({className:s,...n},t)=>e.jsx(Sr,{ref:t,className:b("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ks.displayName=Sr.displayName;function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Ki(s).format(n))}function wd(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function bt(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Vs(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 wa(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 Bi(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 Oe(s){const n=s/1024,t=n/1024,r=t/1024,a=r/1024;return a>=1?bt(a)+" TB":r>=1?bt(r)+" GB":t>=1?bt(t)+" MB":bt(n)+" KB"}const cr="i18nextLng";function Cd(){return console.log(localStorage.getItem(cr)),localStorage.getItem(cr)}function Ll(){Tl();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 Sd=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function kd(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const yt=Gi.create({baseURL:kd(),timeout:12e3,headers:{"Content-Type":"application/json"}});yt.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=Jt();if(!Sd.includes(s.url?.split("?")[0]||"")){if(!n.value)return Ll(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Cd()||"zh-CN",s},s=>Promise.reject(s));yt.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)&&Ll(),A.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const M={get:(s,n)=>yt.get(s,n),post:(s,n,t)=>yt.post(s,n,t),put:(s,n,t)=>yt.put(s,n,t),delete:(s,n)=>yt.delete(s,n)},Td="access_token";function Dd(s){Ln.set(Td,s)}const et=window?.settings?.secure_path,Ca={getStats:()=>M.get(et+"/monitor/api/stats"),getOverride:()=>M.get(et+"/stat/getOverride"),getOrderStat:s=>M.get(et+"/stat/getOrder",{params:s}),getStatsData:()=>M.get(et+"/stat/getStats"),getNodeTrafficData:s=>M.get(et+"/stat/getTrafficRank",{params:s}),getServerLastRank:()=>M.get(et+"/stat/getServerLastRank"),getServerYesterdayRank:()=>M.get(et+"/stat/getServerYesterdayRank")},Et=window?.settings?.secure_path,Kt={getList:()=>M.get(Et+"/theme/getThemes"),getConfig:s=>M.post(Et+"/theme/getThemeConfig",{name:s}),updateConfig:(s,n)=>M.post(Et+"/theme/saveThemeConfig",{name:s,config:n}),upload:s=>{const n=new FormData;return n.append("file",s),M.post(Et+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},drop:s=>M.post(Et+"/theme/delete",{name:s})},gt=window?.settings?.secure_path,at={getList:()=>M.get(gt+"/server/manage/getNodes"),save:s=>M.post(gt+"/server/manage/save",s),drop:s=>M.post(gt+"/server/manage/drop",s),copy:s=>M.post(gt+"/server/manage/copy",s),update:s=>M.post(gt+"/server/manage/update",s),sort:s=>M.post(gt+"/server/manage/sort",s)},Xa=window?.settings?.secure_path,mt={getList:()=>M.get(Xa+"/server/group/fetch"),save:s=>M.post(Xa+"/server/group/save",s),drop:s=>M.post(Xa+"/server/group/drop",s)},Za=window?.settings?.secure_path,Va={getList:()=>M.get(Za+"/server/route/fetch"),save:s=>M.post(Za+"/server/route/save",s),drop:s=>M.post(Za+"/server/route/drop",s)},st=window?.settings?.secure_path,nt={getList:()=>M.get(st+"/payment/fetch"),getMethodList:()=>M.get(st+"/payment/getPaymentMethods"),getMethodForm:s=>M.post(st+"/payment/getPaymentForm",s),save:s=>M.post(st+"/payment/save",s),drop:s=>M.post(st+"/payment/drop",s),updateStatus:s=>M.post(st+"/payment/show",s),sort:s=>M.post(st+"/payment/sort",s)},Ft=window?.settings?.secure_path,Qt={getList:()=>M.get(`${Ft}/notice/fetch`),save:s=>M.post(`${Ft}/notice/save`,s),drop:s=>M.post(`${Ft}/notice/drop`,{id:s}),updateStatus:s=>M.post(`${Ft}/notice/show`,{id:s}),sort:s=>M.post(`${Ft}/notice/sort`,{ids:s})},ft=window?.settings?.secure_path,Ct={getList:()=>M.get(ft+"/knowledge/fetch"),getInfo:s=>M.get(ft+"/knowledge/fetch?id="+s),save:s=>M.post(ft+"/knowledge/save",s),drop:s=>M.post(ft+"/knowledge/drop",s),updateStatus:s=>M.post(ft+"/knowledge/show",s),sort:s=>M.post(ft+"/knowledge/sort",s)},It=window?.settings?.secure_path,gs={getList:()=>M.get(It+"/plan/fetch"),save:s=>M.post(It+"/plan/save",s),update:s=>M.post(It+"/plan/update",s),drop:s=>M.post(It+"/plan/drop",s),sort:s=>M.post(It+"/plan/sort",{ids:s})},pt=window?.settings?.secure_path,tt={getList:s=>M.post(pt+"/order/fetch",s),getInfo:s=>M.post(pt+"/order/detail",s),markPaid:s=>M.post(pt+"/order/paid",s),makeCancel:s=>M.post(pt+"/order/cancel",s),update:s=>M.post(pt+"/order/update",s),assign:s=>M.post(pt+"/order/assign",s)},ra=window?.settings?.secure_path,Sa={getList:s=>M.post(ra+"/coupon/fetch",s),save:s=>M.post(ra+"/coupon/generate",s),drop:s=>M.post(ra+"/coupon/drop",s),update:s=>M.post(ra+"/coupon/update",s)},ls=window?.settings?.secure_path,Ps={getList:s=>M.post(`${ls}/user/fetch`,s),update:s=>M.post(`${ls}/user/update`,s),resetSecret:s=>M.post(`${ls}/user/resetSecret`,{id:s}),generate:s=>s.download_csv?M.post(`${ls}/user/generate`,s,{responseType:"blob"}):M.post(`${ls}/user/generate`,s),getStats:s=>M.post(`${ls}/stat/getStatUser`,s),destroy:s=>M.post(`${ls}/user/destroy`,{id:s}),sendMail:s=>M.post(`${ls}/user/sendMail`,s),dumpCSV:s=>M.post(`${ls}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>M.post(`${ls}/user/ban`,s)},Xt={getLogs:s=>M.get(`${ls}/traffic-reset/logs`,{params:s}),getStats:s=>M.get(`${ls}/traffic-reset/stats`,{params:s}),resetUser:s=>M.post(`${ls}/traffic-reset/reset-user`,s),getUserHistory:(s,n)=>M.get(`${ls}/traffic-reset/user/${s}/history`,{params:n})},la=window?.settings?.secure_path,Nt={getList:s=>M.post(la+"/ticket/fetch",s),getInfo:s=>M.get(la+"/ticket/fetch?id= "+s),reply:s=>M.post(la+"/ticket/reply",s),close:s=>M.post(la+"/ticket/close",{id:s})},Ue=window?.settings?.secure_path,he={getSettings:(s="")=>M.get(Ue+"/config/fetch?key="+s),saveSettings:s=>M.post(Ue+"/config/save",s),getEmailTemplate:()=>M.get(Ue+"/config/getEmailTemplate"),sendTestMail:()=>M.post(Ue+"/config/testSendMail"),setTelegramWebhook:()=>M.post(Ue+"/config/setTelegramWebhook"),updateSystemConfig:s=>M.post(Ue+"/config/save",s),getSystemStatus:()=>M.get(`${Ue}/system/getSystemStatus`),getQueueStats:()=>M.get(`${Ue}/system/getQueueStats`),getQueueWorkload:()=>M.get(`${Ue}/system/getQueueWorkload`),getQueueMasters:()=>M.get(`${Ue}/system/getQueueMasters`),getHorizonFailedJobs:s=>M.get(`${Ue}/system/getHorizonFailedJobs`,{params:s}),getSystemLog:s=>M.get(`${Ue}/system/getSystemLog`,{params:s}),getLogFiles:()=>M.get(`${Ue}/log/files`),getLogContent:s=>M.get(`${Ue}/log/fetch`,{params:s}),getLogClearStats:s=>M.get(`${Ue}/system/getLogClearStats`,{params:s}),clearSystemLog:s=>M.post(`${Ue}/system/clearSystemLog`,s)},Is=window?.settings?.secure_path,Ms={getPluginList:()=>M.get(`${Is}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),M.post(`${Is}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>M.post(`${Is}/plugin/delete`,{code:s}),installPlugin:s=>M.post(`${Is}/plugin/install`,{code:s}),uninstallPlugin:s=>M.post(`${Is}/plugin/uninstall`,{code:s}),enablePlugin:s=>M.post(`${Is}/plugin/enable`,{code:s}),disablePlugin:s=>M.post(`${Is}/plugin/disable`,{code:s}),getPluginConfig:s=>M.get(`${Is}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>M.post(`${Is}/plugin/config`,{code:s,config:n})};window?.settings?.secure_path;const Pd=x.object({subscribe_template_singbox:x.string().optional().default(""),subscribe_template_clash:x.string().optional().default(""),subscribe_template_clashmeta:x.string().optional().default(""),subscribe_template_stash:x.string().optional().default(""),subscribe_template_surge:x.string().optional().default(""),subscribe_template_surfboard:x.string().optional().default("")}),dr=[{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"}],mr={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function Ld(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),[a,i]=m.useState("singbox"),l=we({resolver:Ce(Pd),defaultValues:mr,mode:"onChange"}),{data:d,isLoading:u}=ne({queryKey:["settings","client"],queryFn:()=>he.getSettings("subscribe_template")}),{mutateAsync:o}=Ts({mutationFn:he.saveSettings,onSuccess:()=>{A.success(s("common.autoSaved"))},onError:C=>{console.error("保存失败:",C),A.error(s("common.saveFailed"))}});m.useEffect(()=>{if(d?.data?.subscribe_template){const C=d.data.subscribe_template;Object.entries(C).forEach(([S,f])=>{if(S in mr){const N=typeof f=="string"?f:"";l.setValue(S,N)}}),r.current=l.getValues()}},[d,l]);const c=m.useCallback(ke.debounce(async C=>{if(!r.current||!ke.isEqual(C,r.current)){t(!0);try{await o(C),r.current=C}catch(S){console.error("保存设置失败:",S)}finally{t(!1)}}},1500),[o]),h=m.useCallback(()=>{const C=l.getValues();c(C)},[l,c]),k=m.useCallback((C,S)=>e.jsx(v,{control:l.control,name:C,render:({field:f})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s(`subscribe_template.${C.replace("subscribe_template_","")}.title`)}),e.jsx(y,{children:e.jsx(Wi,{height:"500px",defaultLanguage:S,value:f.value||"",onChange:N=>{f.onChange(N||""),h()},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})}),e.jsx(O,{children:s(`subscribe_template.${C.replace("subscribe_template_","")}.description`)}),e.jsx(E,{})]})}),[l.control,s,h]);return u?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(Se,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Dt,{value:a,onValueChange:i,className:"w-full",children:[e.jsx(dt,{className:"",children:dr.map(({key:C,label:S})=>e.jsx(Xe,{value:C,className:"text-xs",children:S},C))}),dr.map(({key:C,language:S})=>e.jsx(ks,{value:C,className:"mt-4",children:k(`subscribe_template_${C}`,S)},C))]}),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 Rd(){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(Te,{}),e.jsx(Ld,{})]})}const Ed=()=>e.jsx(Nd,{children:e.jsx(yn,{})}),Fd=Yi([{path:"/sign-in",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Qd);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Ed,{}),children:[{path:"/",lazy:async()=>({Component:(await ye(()=>Promise.resolve().then(()=>lm),void 0,import.meta.url)).default}),errorElement:e.jsx(ht,{}),children:[{index:!0,lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Sm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(ht,{}),children:[{path:"system",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Fm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>zm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Um);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Ym);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>eu);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>ru);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>du);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>gu);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>bu);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(Rd,{})}]},{path:"payment",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>ku);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Pu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Fu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Au);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Yu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(ht,{}),children:[{path:"manage",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Cx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Px);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Vx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(ht,{}),children:[{path:"plan",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Kx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>rh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>gh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(ht,{}),children:[{path:"manage",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>Kh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>mg);return{default:s}},void 0,import.meta.url)).default})},{path:"traffic-reset-logs",lazy:async()=>({Component:(await ye(async()=>{const{default:s}=await Promise.resolve().then(()=>pg);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:ht},{path:"/404",Component:ir},{path:"/503",Component:gd},{path:"*",Component:ir}]);function Id(){return M.get("/user/info")}const en={token:Jt()?.value||"",userInfo:null,isLoggedIn:!!Jt()?.value,loading:!1,error:null},Bt=Ji("user/fetchUserInfo",async()=>(await Id()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),Rl=Qi({name:"user",initialState:en,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>en},extraReducers:s=>{s.addCase(Bt.pending,n=>{n.loading=!0,n.error=null}).addCase(Bt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(Bt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return en})}}),{setToken:Vd,resetUserState:Md}=Rl.actions,Od=s=>s.user.userInfo,zd=Rl.reducer,El=Xi({reducer:{user:zd}});Jt()?.value&&El.dispatch(Bt());Zi.use(eo).use(so).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 $d=new to;ao.createRoot(document.getElementById("root")).render(e.jsx(no.StrictMode,{children:e.jsx(ro,{client:$d,children:e.jsx(lo,{store:El,children:e.jsxs(md,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(io,{router:Fd}),e.jsx(oo,{richColors:!0,position:"top-right"})]})})})}));const Re=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:b("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Re.displayName="Card";const Fe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:b("flex flex-col space-y-1.5 p-6",s),...n}));Fe.displayName="CardHeader";const Ge=m.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:b("font-semibold leading-none tracking-tight",s),...n}));Ge.displayName="CardTitle";const Os=m.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:b("text-sm text-muted-foreground",s),...n}));Os.displayName="CardDescription";const Ie=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:b("p-6 pt-0",s),...n}));Ie.displayName="CardContent";const Ad=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:b("flex items-center p-6 pt-0",s),...n}));Ad.displayName="CardFooter";const P=m.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:b("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}));P.displayName="Input";const Fl=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:b("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(co,{size:18}):e.jsx(mo,{size:18})})]})});Fl.displayName="PasswordInput";const qd=s=>M.post("/passport/auth/login",s);function Hd({className:s,onForgotPassword:n,...t}){const r=As(),a=kr(),{t:i}=V("auth"),l=x.object({email:x.string().min(1,{message:i("signIn.validation.emailRequired")}),password:x.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=we({resolver:Ce(l),defaultValues:{email:"",password:""}});async function u(o){try{const{data:c}=await qd(o);Dd(c.auth_data),a(Vd(c.auth_data)),await a(Bt()).unwrap(),r("/")}catch(c){console.error("Login failed:",c),c.response?.data?.message&&d.setError("root",{message:c.response.data.message})}}return e.jsx("div",{className:b("grid gap-6",s),...t,children:e.jsx(Se,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(u),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(v,{control:d.control,name:"email",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:i("signIn.email")}),e.jsx(y,{children:e.jsx(P,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"password",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:i("signIn.password")}),e.jsx(y,{children:e.jsx(Fl,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(E,{})]})}),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 ge=Tr,as=Dr,Ud=Pr,Gs=Nn,Il=m.forwardRef(({className:s,...n},t)=>e.jsx(Da,{ref:t,className:b("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}));Il.displayName=Da.displayName;const de=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Ud,{children:[e.jsx(Il,{}),e.jsxs(Pa,{ref:r,className:b("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(Nn,{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(ms,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));de.displayName=Pa.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:b("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Le=({className:s,...n})=>e.jsx("div",{className:b("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Le.displayName="DialogFooter";const fe=m.forwardRef(({className:s,...n},t)=>e.jsx(La,{ref:t,className:b("text-lg font-semibold leading-none tracking-tight",s),...n}));fe.displayName=La.displayName;const Ve=m.forwardRef(({className:s,...n},t)=>e.jsx(Ra,{ref:t,className:b("text-sm text-muted-foreground",s),...n}));Ve.displayName=Ra.displayName;const St=it("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),G=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,...a},i)=>{const l=r?vn:"button";return e.jsx(l,{className:b(St({variant:n,size:t,className:s})),ref:i,...a})});G.displayName="Button";const zs=ho,$s=go,Kd=fo,Bd=m.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Lr,{ref:a,className:b("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(_n,{className:"ml-auto h-4 w-4"})]}));Bd.displayName=Lr.displayName;const Gd=m.forwardRef(({className:s,...n},t)=>e.jsx(Rr,{ref:t,className:b("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}));Gd.displayName=Rr.displayName;const Ls=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(uo,{children:e.jsx(Er,{ref:r,sideOffset:n,className:b("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})}));Ls.displayName=Er.displayName;const _e=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Fr,{ref:r,className:b("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}));_e.displayName=Fr.displayName;const Wd=m.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Ir,{ref:a,className:b("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(Vr,{children:e.jsx(ot,{className:"h-4 w-4"})})}),n]}));Wd.displayName=Ir.displayName;const Yd=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Mr,{ref:r,className:b("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(Vr,{children:e.jsx(xo,{className:"h-4 w-4 fill-current"})})}),n]}));Yd.displayName=Mr.displayName;const Rn=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Or,{ref:r,className:b("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Rn.displayName=Or.displayName;const rt=m.forwardRef(({className:s,...n},t)=>e.jsx(zr,{ref:t,className:b("-mx-1 my-1 h-px bg-muted",s),...n}));rt.displayName=zr.displayName;const pn=({className:s,...n})=>e.jsx("span",{className:b("ml-auto text-xs tracking-widest opacity-60",s),...n});pn.displayName="DropdownMenuShortcut";const sn=[{code:"en-US",name:"English",flag:po,shortName:"EN"},{code:"zh-CN",name:"中文",flag:jo,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:vo,shortName:"KR"}];function Vl(){const{i18n:s}=V(),n=a=>{s.changeLanguage(a)},t=sn.find(a=>a.code===s.language)||sn[1],r=t.flag;return e.jsxs(zs,{children:[e.jsx($s,{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(Ls,{align:"end",className:"w-[120px]",children:sn.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(_e,{onClick:()=>n(a.code),className:b("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:b("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function Jd(){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(Vl,{})}),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(Re,{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(Hd,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(de,{className:"max-w-[90vw] sm:max-w-lg",children:e.jsxs(ve,{children:[e.jsx(fe,{children:t("signIn.resetPassword.title")}),e.jsx(Ve,{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:()=>wa(r).then(()=>{A.success(t("common:copy.success"))}),children:e.jsx(bo,{className:"h-4 w-4"})})]})})]})})})]})}const Qd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"})),ze=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:b("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}));ze.displayName="Layout";const $e=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:b("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));$e.displayName="LayoutHeader";const He=m.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:b("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));He.displayName="LayoutBody";const Ml=yo,Ol=No,zl=_o,be=wo,ue=Co,xe=So,ce=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx($r,{ref:r,sideOffset:n,className:b("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=$r.displayName;function Ma(){const{pathname:s}=bn();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function $l({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 Xd(){const[s,n]=$l({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 Zd({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=V(),i=({sub:l,...d})=>{const u=`${a(d.title)}-${d.href}`;return n&&l?m.createElement(tm,{...d,sub:l,key:u,closeNav:r}):n?m.createElement(sm,{...d,key:u,closeNav:r}):l?m.createElement(em,{...d,sub:l,key:u,closeNav:r}):m.createElement(Al,{...d,key:u,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:b("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(be,{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 Al({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Ma(),{t:d}=V();return e.jsxs(Ys,{to:r,onClick:a,className:b(Tt({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 em({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ma(),{isExpanded:l,toggleItem:d}=Xd(),{t:u}=V(),o=!!r?.find(k=>i(k.href)),c=u(s),h=l(c)||o;return e.jsxs(Ml,{open:h,onOpenChange:()=>d(c),children:[e.jsxs(Ol,{className:b(Tt({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),u(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(t)}),e.jsx("span",{className:b('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Ar,{stroke:1})})]}),e.jsx(zl,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(k=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Al,{...k,subLink:!0,closeNav:a})},u(k.title)))})})]})}function sm({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Ma(),{t:l}=V();return e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsxs(Ys,{to:r,onClick:a,className:b(Tt({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 tm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ma(),{t:l}=V(),d=!!r?.find(u=>i(u.href));return e.jsxs(zs,{children:[e.jsxs(ue,{delayDuration:0,children:[e.jsx(xe,{asChild:!0,children:e.jsx($s,{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(Ar,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(Ls,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Rn,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(rt,{}),r.map(({title:u,icon:o,label:c,href:h})=>e.jsx(_e,{asChild:!0,children:e.jsxs(Ys,{to:h,onClick:a,className:`${i(h)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(u)}),c&&e.jsx("span",{className:"ml-auto text-xs",children:l(c)})]})},`${l(u)}-${h}`))]})]})}const ql=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(ko,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(To,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(qr,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(wn,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Do,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Po,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Jn,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Lo,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(Hr,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Ro,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Ur,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Eo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Fo,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Io,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Jn,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Vo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Mo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(Oo,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(Kr,{size:18})}]}];function am({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:b(`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(ze,{className:`flex h-full flex-col ${r?"h-[100vh] md:h-full":""}`,children:[e.jsxs($e,{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(zo,{}):e.jsx($o,{})})]}),e.jsx(Zd,{id:"sidebar-menu",className:b("flex-1 overflow-auto overscroll-contain",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:ql}),e.jsx("div",{className:b("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:b("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:b("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(Ao,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function nm(){const[s,n]=$l({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 rm(){const[s,n]=nm();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(am,{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(yn,{})})]})}const lm=Object.freeze(Object.defineProperty({__proto__:null,default:rm},Symbol.toStringTag,{value:"Module"})),Js=m.forwardRef(({className:s,...n},t)=>e.jsx(es,{ref:t,className:b("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Js.displayName=es.displayName;const im=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(de,{className:"overflow-hidden p-0",children:e.jsx(Js,{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})})}),ut=m.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(qo,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(es.Input,{ref:t,className:b("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})]}));ut.displayName=es.Input.displayName;const Qs=m.forwardRef(({className:s,...n},t)=>e.jsx(es.List,{ref:t,className:b("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Qs.displayName=es.List.displayName;const xt=m.forwardRef((s,n)=>e.jsx(es.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));xt.displayName=es.Empty.displayName;const fs=m.forwardRef(({className:s,...n},t)=>e.jsx(es.Group,{ref:t,className:b("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}));fs.displayName=es.Group.displayName;const Pt=m.forwardRef(({className:s,...n},t)=>e.jsx(es.Separator,{ref:t,className:b("-mx-1 h-px bg-border",s),...n}));Pt.displayName=es.Separator.displayName;const We=m.forwardRef(({className:s,...n},t)=>e.jsx(es.Item,{ref:t,className:b("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}));We.displayName=es.Item.displayName;function om(){const s=[];for(const n of ql)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function ns(){const[s,n]=m.useState(!1),t=As(),r=om(),{t:a}=V("search"),{t:i}=V("nav");m.useEffect(()=>{const d=u=>{u.key==="k"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),n(o=>!o))};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(Cn,{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(im,{open:s,onOpenChange:n,children:[e.jsx(ut,{placeholder:a("placeholder")}),e.jsxs(Qs,{children:[e.jsx(xt,{children:a("noResults")}),e.jsx(fs,{heading:a("title"),children:r.map(d=>e.jsxs(We,{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 Ye(){const{theme:s,setTheme:n}=ud();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(Ho,{size:20}):e.jsx(Uo,{size:20})}),e.jsx(Vl,{})]})}const Hl=m.forwardRef(({className:s,...n},t)=>e.jsx(Br,{ref:t,className:b("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));Hl.displayName=Br.displayName;const Ul=m.forwardRef(({className:s,...n},t)=>e.jsx(Gr,{ref:t,className:b("aspect-square h-full w-full",s),...n}));Ul.displayName=Gr.displayName;const Kl=m.forwardRef(({className:s,...n},t)=>e.jsx(Wr,{ref:t,className:b("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));Kl.displayName=Wr.displayName;function Je(){const s=As(),n=kr(),t=Ko(Od),{t:r}=V(["common"]),a=()=>{Tl(),n(Md()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(zs,{children:[e.jsx($s,{asChild:!0,children:e.jsx(L,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(Hl,{className:"h-8 w-8",children:[e.jsx(Ul,{src:t?.avatar_url,alt:i}),e.jsx(Kl,{children:l})]})})}),e.jsxs(Ls,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Rn,{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(rt,{}),e.jsx(_e,{asChild:!0,children:e.jsxs(Ys,{to:"/config/system",children:[r("common:settings"),e.jsx(pn,{children:"⌘S"})]})}),e.jsx(rt,{}),e.jsxs(_e,{onClick:a,children:[r("common:logout"),e.jsx(pn,{children:"⇧⌘Q"})]})]})]})}const J=Bo,rs=ec,Q=Go,W=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Yr,{ref:r,className:b("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(Wo,{asChild:!0,children:e.jsx(Sn,{className:"h-4 w-4 opacity-50"})})]}));W.displayName=Yr.displayName;const Bl=m.forwardRef(({className:s,...n},t)=>e.jsx(Jr,{ref:t,className:b("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Yo,{className:"h-4 w-4"})}));Bl.displayName=Jr.displayName;const Gl=m.forwardRef(({className:s,...n},t)=>e.jsx(Qr,{ref:t,className:b("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Sn,{className:"h-4 w-4"})}));Gl.displayName=Qr.displayName;const Y=m.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(Jo,{children:e.jsxs(Xr,{ref:a,className:b("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(Bl,{}),e.jsx(Qo,{className:b("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Gl,{})]})}));Y.displayName=Xr.displayName;const cm=m.forwardRef(({className:s,...n},t)=>e.jsx(Zr,{ref:t,className:b("px-2 py-1.5 text-sm font-semibold",s),...n}));cm.displayName=Zr.displayName;const $=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(el,{ref:r,className:b("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(Xo,{children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsx(Zo,{children:n})]}));$.displayName=el.displayName;const dm=m.forwardRef(({className:s,...n},t)=>e.jsx(sl,{ref:t,className:b("-mx-1 my-1 h-px bg-muted",s),...n}));dm.displayName=sl.displayName;function vs({className:s,classNames:n,showOutsideDays:t=!0,...r}){return e.jsx(sc,{showOutsideDays:t,className:b("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:b(St({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:b("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:b(St({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:a,...i})=>e.jsx(tl,{className:b("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>e.jsx(_n,{className:b("h-4 w-4",a),...i})},...r})}vs.displayName="Calendar";const os=ac,cs=nc,Ze=m.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(tc,{children:e.jsx(al,{ref:a,align:n,sideOffset:t,className:b("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})}));Ze.displayName=al.displayName;const Us={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},$t=s=>(s/100).toFixed(2),mm=({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"))?`¥${$t(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},um=[{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"}],xm=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=ws(t,7);break;case"30d":r=ws(t,30);break;case"90d":r=ws(t,90);break;case"180d":r=ws(t,180);break;case"365d":r=ws(t,365);break;default:r=ws(t,30)}return{startDate:r,endDate:t}};function hm(){const[s,n]=m.useState("amount"),[t,r]=m.useState("30d"),[a,i]=m.useState({from:ws(new Date,7),to:new Date}),{t:l}=V(),{startDate:d,endDate:u}=xm(t,a),{data:o}=ne({queryKey:["orderStat",{start_date:Pe(d,"yyyy-MM-dd"),end_date:Pe(u,"yyyy-MM-dd")}],queryFn:async()=>{const{data:c}=await Ca.getOrderStat({start_date:Pe(d,"yyyy-MM-dd"),end_date:Pe(u,"yyyy-MM-dd")});return c},refetchInterval:3e4});return e.jsxs(Re,{children:[e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ge,{children:l("dashboard:overview.title")}),e.jsxs(Os,{children:[o?.summary.start_date," ",l("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(J,{value:t,onValueChange:c=>r(c),children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Q,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(Y,{children:um.map(c=>e.jsx($,{value:c.value,children:l(c.label)},c.value))})]}),t==="custom"&&e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:b("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:[Pe(a.from,"yyyy-MM-dd")," -"," ",Pe(a.to,"yyyy-MM-dd")]}):Pe(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(Ze,{className:"w-auto p-0",align:"end",children:e.jsx(vs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:c=>{c?.from&&c?.to&&i({from:c.from,to:c.to})},numberOfMonths:2})})]})]}),e.jsx(Dt,{value:s,onValueChange:c=>n(c),children:e.jsxs(dt,{children:[e.jsx(Xe,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx(Xe,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(Ie,{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:["¥",$t(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",$t(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",$t(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(rc,{width:"100%",height:"100%",children:e.jsxs(lc,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:Us.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Us.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:Us.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Us.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(ic,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>Pe(new Date(c),"MM-dd",{locale:mc})}),e.jsx(oc,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:c=>s==="amount"?`¥${$t(c)}`:l("dashboard:overview.transactions",{count:c})}),e.jsx(cc,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(dc,{content:e.jsx(mm,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Qn,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Us.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Qn,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Us.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Xn,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Us.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Xn,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Us.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function je({className:s,...n}){return e.jsx("div",{className:b("animate-pulse rounded-md bg-primary/10",s),...n})}function gm(){return e.jsxs(Re,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(je,{className:"h-4 w-[120px]"}),e.jsx(je,{className:"h-4 w-4"})]}),e.jsxs(Ie,{children:[e.jsx(je,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(je,{className:"h-4 w-[100px]"})]})]})]})}function fm(){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(gm,{},n))})}var le=(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))(le||{});const Vt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Mt={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Cs=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Cs||{}),Ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(Ne||{});const ia={0:"待确认",1:"发放中",2:"有效",3:"无效"},oa={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var qe=(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))(qe||{});const pm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var oe=(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))(oe||{});const js=[{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"}],is={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50",anytls:"#7E57C2"};var hs=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(hs||{});const jm={1:"按金额优惠",2:"按比例优惠"};var Ws=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Ws||{}),Qe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Qe||{}),Gt=(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))(Gt||{});function Ks({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(Re,{className:b("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(Ge,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(gc,{className:b("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:b("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 vm({className:s}){const n=As(),{t}=V(),{data:r,isLoading:a}=ne({queryKey:["dashboardStats"],queryFn:async()=>(await Ca.getStatsData()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(fm,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",Ne.PENDING.toString()),l.set("status",le.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:b("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Ks,{title:t("dashboard:stats.todayIncome"),value:Vs(r.todayIncome),icon:e.jsx(uc,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Ks,{title:t("dashboard:stats.monthlyIncome"),value:Vs(r.currentMonthIncome),icon:e.jsx(kn,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Ks,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(xc,{className:b("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(Ks,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(hc,{className:b("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(Ks,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(ja,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Ks,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(ja,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Ks,{title:t("dashboard:stats.monthlyUpload"),value:Oe(r.monthTraffic.upload),icon:e.jsx(wt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:Oe(r.todayTraffic.upload)})}),e.jsx(Ks,{title:t("dashboard:stats.monthlyDownload"),value:Oe(r.monthTraffic.download),icon:e.jsx(va,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:Oe(r.todayTraffic.download)})})]})}const lt=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(nl,{ref:r,className:b("relative overflow-hidden",s),...t,children:[e.jsx(fc,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(ka,{}),e.jsx(pc,{})]}));lt.displayName=nl.displayName;const ka=m.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(rl,{ref:r,orientation:n,className:b("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(jc,{className:"relative flex-1 rounded-full bg-border"})}));ka.displayName=rl.displayName;const jn={today:{getValue:()=>{const s=bc();return{start:s,end:yc(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:ws(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:ws(s,30),end:s}}},custom:{getValue:()=>null}};function ur({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(J,{value:s,onValueChange:t,children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Q,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(Y,{position:"popper",className:"z-50",children:Object.entries(jn).map(([l])=>e.jsx($,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:b("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:[Pe(n.from,"yyyy-MM-dd")," -"," ",Pe(n.to,"yyyy-MM-dd")]}):Pe(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(Ze,{className:"w-auto p-0",align:"end",children:e.jsx(vs,{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 jt=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function bm({className:s}){const{t:n}=V(),[t,r]=m.useState("today"),[a,i]=m.useState({from:ws(new Date,7),to:new Date}),[l,d]=m.useState("today"),[u,o]=m.useState({from:ws(new Date,7),to:new Date}),c=m.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:jn[t].getValue(),[t,a]),h=m.useMemo(()=>l==="custom"?{start:u.from,end:u.to}:jn[l].getValue(),[l,u]),{data:k}=ne({queryKey:["nodeTrafficRank",c.start,c.end],queryFn:()=>Ca.getNodeTrafficData({type:"node",start_time:ke.round(c.start.getTime()/1e3),end_time:ke.round(c.end.getTime()/1e3)}),refetchInterval:3e4}),{data:C}=ne({queryKey:["userTrafficRank",h.start,h.end],queryFn:()=>Ca.getNodeTrafficData({type:"user",start_time:ke.round(h.start.getTime()/1e3),end_time:ke.round(h.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:b("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Re,{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(Ge,{className:"flex items-center text-base font-medium",children:[e.jsx(vc,{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(ur,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(Zn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Ie,{className:"flex-1",children:k?.data?e.jsxs(lt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:k.data.map(S=>e.jsx(be,{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:S.name}),e.jsxs("span",{className:b("ml-2 flex items-center text-xs font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?e.jsx(dn,{className:"mr-1 h-3 w-3"}):e.jsx(mn,{className:"mr-1 h-3 w-3"}),Math.abs(S.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:`${S.value/k.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:jt(S.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:jt(S.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:jt(S.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:b("font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?"+":"",S.change,"%"]})]})})]})},S.id))}),e.jsx(ka,{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(Re,{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(Ge,{className:"flex items-center text-base font-medium",children:[e.jsx(ja,{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(ur,{selectedRange:l,customDateRange:u,onRangeChange:d,onCustomRangeChange:o}),e.jsx(Zn,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Ie,{className:"flex-1",children:C?.data?e.jsxs(lt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:C.data.map(S=>e.jsx(be,{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:S.name}),e.jsxs("span",{className:b("ml-2 flex items-center text-xs font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?e.jsx(dn,{className:"mr-1 h-3 w-3"}):e.jsx(mn,{className:"mr-1 h-3 w-3"}),Math.abs(S.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:`${S.value/C.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:jt(S.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:jt(S.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:jt(S.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:b("font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?"+":"",S.change,"%"]})]})})]})},S.id))}),e.jsx(ka,{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 ym=it("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:b(ym({variant:n}),s),...t})}const ha=m.forwardRef(({className:s,value:n,...t},r)=>e.jsx(ll,{ref:r,className:b("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(Nc,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));ha.displayName=ll.displayName;const En=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:b("w-full caption-bottom text-sm",s),...n})}));En.displayName="Table";const Fn=m.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:b("[&_tr]:border-b",s),...n}));Fn.displayName="TableHeader";const In=m.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:b("[&_tr:last-child]:border-0",s),...n}));In.displayName="TableBody";const Nm=m.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:b("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Nm.displayName="TableFooter";const Bs=m.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:b("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Bs.displayName="TableRow";const Vn=m.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:b("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}));Vn.displayName="TableHead";const _t=m.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:b("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));_t.displayName="TableCell";const _m=m.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:b("mt-4 text-sm text-muted-foreground",s),...n}));_m.displayName="TableCaption";function Mn({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(J,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:s.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx($,{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(P,{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(_c,{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(tl,{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(_n,{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(wc,{className:"h-4 w-4"})]})]})]})]})}function xs({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:u=!0,isLoading:o=!1}){const{t:c}=V("common"),h=m.useRef(null),k=s.getAllColumns().filter(N=>N.getIsPinned()==="left"),C=s.getAllColumns().filter(N=>N.getIsPinned()==="right"),S=N=>k.slice(0,N).reduce((_,T)=>_+(T.getSize()??0),0),f=N=>C.slice(N+1).reduce((_,T)=>_+(T.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:h,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(En,{children:[e.jsx(Fn,{children:s.getHeaderGroups().map(N=>e.jsx(Bs,{className:"hover:bg-transparent",children:N.headers.map((_,T)=>{const D=_.column.getIsPinned()==="left",g=_.column.getIsPinned()==="right",w=D?S(k.indexOf(_.column)):void 0,R=g?f(C.indexOf(_.column)):void 0;return e.jsx(Vn,{colSpan:_.colSpan,style:{width:_.getSize(),...D&&{left:w},...g&&{right:R}},className:b("h-11 bg-card px-4 text-muted-foreground",(D||g)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",D&&"before:right-0",g&&"before:left-0"]),children:_.isPlaceholder?null:ba(_.column.columnDef.header,_.getContext())},_.id)})},N.id))}),e.jsx(In,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((N,_)=>e.jsx(Bs,{"data-state":N.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:T=>r?.(T,_),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:T=>d?.(T,_),children:N.getVisibleCells().map((T,D)=>{const g=T.column.getIsPinned()==="left",w=T.column.getIsPinned()==="right",R=g?S(k.indexOf(T.column)):void 0,H=w?f(C.indexOf(T.column)):void 0;return e.jsx(_t,{style:{width:T.column.getSize(),...g&&{left:R},...w&&{right:H}},className:b("bg-card",(g||w)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",g&&"before:right-0",w&&"before:left-0"]),children:ba(T.column.columnDef.cell,T.getContext())},T.id)})},N.id)):e.jsx(Bs,{children:e.jsx(_t,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:c("table.noData")})})})]})})}),u&&e.jsx(Mn,{table:s})]})}const ga=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"})},Ot=il(),zt=il();function ca({data:s,isLoading:n,searchKeyword:t,selectedLevel:r,total:a,currentPage:i,pageSize:l,onViewDetail:d,onPageChange:u}){const{t:o}=V(),c=C=>{switch(C.toLowerCase()){case"info":return e.jsx(qt,{className:"h-4 w-4 text-blue-500"});case"warning":return e.jsx(Ht,{className:"h-4 w-4 text-yellow-500"});case"error":return e.jsx(xn,{className:"h-4 w-4 text-red-500"});default:return e.jsx(qt,{className:"h-4 w-4 text-slate-500"})}},h=m.useMemo(()=>[Ot.accessor("level",{id:"level",header:()=>o("dashboard:systemLog.level","级别"),size:80,cell:({getValue:C,row:S})=>{const f=C();return e.jsxs("div",{className:"flex items-center gap-1",children:[c(f),e.jsx("span",{className:b(f.toLowerCase()==="error"&&"text-red-600",f.toLowerCase()==="warning"&&"text-yellow-600",f.toLowerCase()==="info"&&"text-blue-600"),children:f})]})}}),Ot.accessor("created_at",{id:"created_at",header:()=>o("dashboard:systemLog.time","时间"),size:160,cell:({getValue:C})=>ga(C())}),Ot.accessor(C=>C.title||C.message||"",{id:"title",header:()=>o("dashboard:systemLog.logTitle","标题"),cell:({getValue:C})=>e.jsx("span",{className:"inline-block max-w-[300px] truncate",children:C()})}),Ot.accessor("method",{id:"method",header:()=>o("dashboard:systemLog.method","请求方法"),size:100,cell:({getValue:C})=>{const S=C();return S?e.jsx(U,{variant:"outline",className:b(S==="GET"&&"border-blue-200 bg-blue-50 text-blue-700",S==="POST"&&"border-green-200 bg-green-50 text-green-700",S==="PUT"&&"border-amber-200 bg-amber-50 text-amber-700",S==="DELETE"&&"border-red-200 bg-red-50 text-red-700"),children:S}):null}}),Ot.display({id:"actions",header:()=>o("dashboard:systemLog.action","操作"),size:80,cell:({row:C})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>d(C.original),"aria-label":o("dashboard:systemLog.viewDetail","查看详情"),children:e.jsx(un,{className:"h-4 w-4"})})})],[o,d]),k=ss({data:s,columns:h,getCoreRowModel:ts(),getPaginationRowModel:us(),pageCount:Math.ceil(a/l),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:l}},onPaginationChange:C=>{if(typeof C=="function"){const S=C({pageIndex:i-1,pageSize:l});u(S.pageIndex+1)}else u(C.pageIndex+1)}});return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(xs,{table:k,showPagination:!1,isLoading:n}),e.jsx(Mn,{table:k}),(t||r&&r!=="all")&&e.jsx("div",{className:"text-center text-sm text-muted-foreground",children:t&&r&&r!=="all"?`筛选结果: 包含"${t}"且级别为"${r}"的日志共 ${a} 条`:t?`搜索结果: 包含"${t}"的日志共 ${a} 条`:`筛选结果: 级别为"${r}"的日志共 ${a} 条`})]})}function wm(){const{t:s}=V(),[n,t]=m.useState(0),[r,a]=m.useState(!1),[i,l]=m.useState(1),[d]=m.useState(10),[u,o]=m.useState(null),[c,h]=m.useState(!1),[k,C]=m.useState(!1),[S,f]=m.useState(1),[N]=m.useState(10),[_,T]=m.useState(null),[D,g]=m.useState(!1),[w,R]=m.useState(""),[H,I]=m.useState(""),[K,ae]=m.useState("all"),[ee,te]=m.useState(!1),[q,F]=m.useState(30),[X,Ns]=m.useState("all"),[De,ie]=m.useState(1e3),[_s,Fs]=m.useState(!1),[Xs,Lt]=m.useState(null),[Zt,Rt]=m.useState(!1);m.useEffect(()=>{const B=setTimeout(()=>{I(w),w!==H&&f(1)},500);return()=>clearTimeout(B)},[w]);const{data:qs,isLoading:Ja,refetch:se,isRefetching:pe}=ne({queryKey:["systemStatus",n],queryFn:async()=>(await he.getSystemStatus()).data,refetchInterval:3e4}),{data:re,isLoading:Zs,refetch:jg,isRefetching:Un}=ne({queryKey:["queueStats",n],queryFn:async()=>(await he.getQueueStats()).data,refetchInterval:3e4}),{data:Kn,isLoading:_i,refetch:wi}=ne({queryKey:["failedJobs",i,d],queryFn:async()=>{const B=await he.getHorizonFailedJobs({current:i,page_size:d});return{data:B.data,total:B.total||0}},enabled:r}),{data:Bn,isLoading:ea,refetch:Ci}=ne({queryKey:["systemLogs",S,N,K,H],queryFn:async()=>{const B={current:S,page_size:N};K&&K!=="all"&&(B.level=K),H.trim()&&(B.keyword=H.trim());const Hs=await he.getSystemLog(B);return{data:Hs.data,total:Hs.total||0}},enabled:k}),Gn=Kn?.data||[],Si=Kn?.total||0,sa=Bn?.data||[],ta=Bn?.total||0,ki=m.useMemo(()=>[zt.display({id:"failed_at",header:()=>s("dashboard:queue.details.time","时间"),cell:({row:B})=>ga(B.original.failed_at)}),zt.display({id:"queue",header:()=>s("dashboard:queue.details.queue","队列"),cell:({row:B})=>B.original.queue}),zt.display({id:"name",header:()=>s("dashboard:queue.details.name","任务名称"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[150px] truncate",children:B.original.name})}),e.jsx(ce,{children:e.jsx("span",{children:B.original.name})})]})})}),zt.display({id:"exception",header:()=>s("dashboard:queue.details.exception","异常信息"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[200px] truncate",children:B.original.exception.split(` +`)[0]})}),e.jsx(ce,{className:"max-w-[300px] whitespace-pre-wrap",children:e.jsx("span",{children:B.original.exception})})]})})}),zt.display({id:"actions",header:()=>s("dashboard:queue.details.action","操作"),size:80,cell:({row:B})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Li(B.original),"aria-label":s("dashboard:queue.details.viewDetail","查看详情"),children:e.jsx(un,{className:"h-4 w-4"})})})],[s]),Wn=ss({data:Gn,columns:ki,getCoreRowModel:ts(),getPaginationRowModel:us(),pageCount:Math.ceil(Si/d),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:d}},onPaginationChange:B=>{if(typeof B=="function"){const Hs=B({pageIndex:i-1,pageSize:d});Yn(Hs.pageIndex+1)}else Yn(B.pageIndex+1)}}),Ti=()=>{t(B=>B+1)},Yn=B=>{l(B)},aa=B=>{f(B)},Di=B=>{ae(B),f(1)},Pi=()=>{R(""),I(""),ae("all"),f(1)},na=B=>{T(B),g(!0)},Li=B=>{o(B),h(!0)},Ri=async()=>{try{const B=await he.getLogClearStats({days:q,level:X==="all"?void 0:X});Lt(B.data),Rt(!0)}catch(B){console.error("获取清理统计失败:",B),A.error("获取清理统计失败")}},Ei=async()=>{Fs(!0);try{const B=await he.clearSystemLog({days:q,level:X==="all"?void 0:X,limit:De});B.data.status==="success"?(A.success(`清理完成!已清理 ${B.data.cleared_count} 条日志`),te(!1),Rt(!1),Lt(null),se()):A.error(B.data.message||"清理失败")}catch(B){console.error("清理日志失败:",B),A.error("清理日志失败")}finally{Fs(!1)}};if(Ja||Zs)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(ya,{className:"h-6 w-6 animate-spin"})});const Fi=B=>B?e.jsx(ol,{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(Re,{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(Ge,{className:"flex items-center gap-2",children:[e.jsx(Cc,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Os,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:Ti,disabled:pe||Un,children:e.jsx(Qa,{className:b("h-4 w-4",(pe||Un)&&"animate-spin")})})]}),e.jsx(Ie,{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:[Fi(re?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(U,{variant:re?.status?"secondary":"destructive",children:re?.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:re?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(be,{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:re?.recentJobs||0}),e.jsx(ha,{value:(re?.recentJobs||0)/(re?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:re?.periods?.recentJobs||0})})})]})}),e.jsx(be,{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:re?.jobsPerMinute||0}),e.jsx(ha,{value:(re?.jobsPerMinute||0)/(re?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ce,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:re?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(Re,{children:[e.jsxs(Fe,{children:[e.jsxs(Ge,{className:"flex items-center gap-2",children:[e.jsx(Sc,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Os,{children:s("dashboard:queue.details.description")})]}),e.jsx(Ie,{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:re?.failedJobs||0}),e.jsx(un,{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:re?.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:[re?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:re?.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:[re?.processes||0," /"," ",(re?.processes||0)+(re?.pausedMasters||0)]})]}),e.jsx(ha,{value:(re?.processes||0)/((re?.processes||0)+(re?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]}),e.jsxs(Re,{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(Ge,{className:"flex items-center gap-2",children:[e.jsx(er,{className:"h-5 w-5"}),s("dashboard:systemLog.title","系统日志")]}),e.jsx(Os,{children:s("dashboard:systemLog.description","查看系统运行日志记录")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>C(!0),children:s("dashboard:systemLog.viewAll","查看全部")}),e.jsxs(G,{variant:"outline",onClick:()=>te(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.clearLogs","清理日志")]})]})]}),e.jsx(Ie,{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(qt,{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:qs?.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(Ht,{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:qs?.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(xn,{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:qs?.logs?.error||0})]})]}),qs?.logs&&qs.logs.total>0&&e.jsxs("div",{className:"mt-3 text-center text-sm text-muted-foreground",children:[s("dashboard:systemLog.totalLogs","总日志数"),":"," ",qs.logs.total]})]})})]}),e.jsx(ge,{open:r,onOpenChange:a,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:queue.details.failedJobsDetailTitle","失败任务详情")})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(xs,{table:Wn,showPagination:!1,isLoading:_i}),e.jsx(Mn,{table:Wn}),Gn.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:s("dashboard:queue.details.noFailedJobs","暂无失败任务")})]}),e.jsxs(Le,{children:[e.jsxs(G,{variant:"outline",onClick:()=>wi(),children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh","刷新")]}),e.jsx(Gs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})]})]})}),e.jsx(ge,{open:c,onOpenChange:h,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:queue.details.jobDetailTitle","任务详情")})}),u&&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","任务ID")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:u.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:u.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:u.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:u.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:u.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:u.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(u.payload),null,2)}catch{return u.payload}})()})})]})]}),e.jsx(Le,{children:e.jsx(G,{variant:"outline",onClick:()=>h(!1),children:s("common.close","关闭")})})]})}),e.jsx(ge,{open:k,onOpenChange:C,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:systemLog.title","系统日志")})}),e.jsxs(Dt,{value:K,onValueChange:Di,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(dt,{className:"grid w-auto grid-cols-4",children:[e.jsxs(Xe,{value:"all",className:"flex items-center gap-2",children:[e.jsx(er,{className:"h-4 w-4"}),s("dashboard:systemLog.tabs.all","全部")]}),e.jsxs(Xe,{value:"info",className:"flex items-center gap-2",children:[e.jsx(qt,{className:"h-4 w-4 text-blue-500"}),s("dashboard:systemLog.tabs.info","信息")]}),e.jsxs(Xe,{value:"warning",className:"flex items-center gap-2",children:[e.jsx(Ht,{className:"h-4 w-4 text-yellow-500"}),s("dashboard:systemLog.tabs.warning","警告")]}),e.jsxs(Xe,{value:"error",className:"flex items-center gap-2",children:[e.jsx(xn,{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(Cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(P,{placeholder:s("dashboard:systemLog.search","搜索日志内容..."),value:w,onChange:B=>R(B.target.value),className:"w-full md:w-64"})]})]}),e.jsx(ks,{value:"all",className:"mt-0",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:N,onViewDetail:na,onPageChange:aa})}),e.jsx(ks,{value:"info",className:"mt-0 overflow-x-auto",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:N,onViewDetail:na,onPageChange:aa})}),e.jsx(ks,{value:"warning",className:"mt-0",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:N,onViewDetail:na,onPageChange:aa})}),e.jsx(ks,{value:"error",className:"mt-0",children:e.jsx(ca,{data:sa,isLoading:ea,searchKeyword:H,selectedLevel:K,total:ta,currentPage:S,pageSize:N,onViewDetail:na,onPageChange:aa})})]}),e.jsxs(Le,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Ci(),children:[e.jsx(Qa,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh","刷新")]}),e.jsx(G,{variant:"outline",onClick:Pi,children:s("dashboard:systemLog.filter.reset","重置筛选")}),e.jsx(Gs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})]})]})}),e.jsx(ge,{open:D,onOpenChange:g,children:e.jsxs(de,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(fe,{children:s("dashboard:systemLog.detailTitle","日志详情")})}),_&&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(qt,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:_.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:ga(_.created_at)||ga(_.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:_.title||_.message||""})]}),(_.host||_.ip)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[_.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:_.host})]}),_.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","IP地址")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:_.ip})]})]}),_.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","URI")}),e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 p-3",children:e.jsx("code",{className:"text-sm",children:_.uri})})]}),_.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:_.method})})]}),_.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(_.data),null,2)}catch{return _.data}})()})})]}),_.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 B=JSON.parse(_.context);if(B.exception){const Hs=B.exception,Ii=Hs["\0*\0message"]||"",Vi=Hs["\0*\0file"]||"",Mi=Hs["\0*\0line"]||"";return`${Ii} File: ${Vi} -Line: ${Mi}`}return JSON.stringify(B,null,2)}catch{return f.context}})()})})]})]}),e.jsx(Le,{children:e.jsx(Gs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})})]})}),e.jsx(ge,{open:ee,onOpenChange:te,children:e.jsxs(de,{className:"max-w-2xl",children:[e.jsx(ve,{children:e.jsxs(fe,{className:"flex items-center gap-2",children:[e.jsx(ds,{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(Ae,{htmlFor:"clearDays",children:s("dashboard:systemLog.clearDays","清理天数")}),e.jsx(D,{id:"clearDays",type:"number",min:"1",max:"365",value:q,onChange:B=>F(parseInt(B.target.value)||30),placeholder:"30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearDaysDesc","清理多少天前的日志 (1-365天)")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{htmlFor:"clearLevel",children:s("dashboard:systemLog.clearLevel","日志级别")}),e.jsxs(J,{value:X,onValueChange:ys,children:[e.jsx(W,{children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:s("dashboard:systemLog.tabs.all","全部")}),e.jsx($,{value:"info",children:s("dashboard:systemLog.tabs.info","信息")}),e.jsx($,{value:"warning",children:s("dashboard:systemLog.tabs.warning","警告")}),e.jsx($,{value:"error",children:s("dashboard:systemLog.tabs.error","错误")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{htmlFor:"clearLimit",children:s("dashboard:systemLog.clearLimit","单次限制")}),e.jsx(D,{id:"clearLimit",type:"number",min:"100",max:"10000",value:De,onChange:B=>ie(parseInt(B.target.value)||1e3),placeholder:"1000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearLimitDesc","单次清理数量限制 (100-10000条)")})]})]}),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(kn,{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:Ei,disabled:Ns,children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.getStats","获取统计")]})]}),Zt&&Xs&&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:Xs.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:Xs.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(Ht,{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:Xs.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(Le,{children:[e.jsx(G,{variant:"outline",onClick:()=>{te(!1),Et(!1),Lt(null)},children:s("common.cancel","取消")}),e.jsx(G,{variant:"destructive",onClick:Ri,disabled:Ns||!Zt||!Xs,children:Ns?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"mr-2 h-4 w-4 animate-spin"}),s("dashboard:systemLog.clearing","清理中...")]}):e.jsxs(e.Fragment,{children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.confirmClear","确认清理")]})})]})]})})]})}function Cm(){const{t:s}=V();return e.jsxs(ze,{children:[e.jsxs($e,{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(ns,{}),e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsx(He,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(vm,{}),e.jsx(hm,{}),e.jsx(bm,{}),e.jsx(wm,{})]})})})]})}const Sm=Object.freeze(Object.defineProperty({__proto__:null,default:Cm},Symbol.toStringTag,{value:"Module"}));function km({className:s,items:n,...t}){const{pathname:r}=bn(),a=As(),[i,l]=m.useState(r??"/settings"),d=o=>{l(o),a(o)},{t:u}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(J,{value:i,onValueChange:d,children:[e.jsx(W,{className:"h-12 sm:w-48",children:e.jsx(Q,{placeholder:"Theme"})}),e.jsx(Y,{children:n.map(o=>e.jsx($,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:u(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:y("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(o=>e.jsxs(Ys,{to:o.href,className:y(Tt({variant:"ghost"}),r===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),u(o.title)]},o.href))})})]})}const Tm=[{title:"site.title",key:"site",icon:e.jsx(kc,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Ur,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Kr,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Tc,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(Hr,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Dc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Pc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(qr,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(Lc,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Dm(){const{t:s}=V("settings");return e.jsxs(ze,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Te,{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(km,{items:Tm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(yn,{})})})]})]})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:Dm},Symbol.toStringTag,{value:"Module"})),Z=m.forwardRef(({className:s,...n},t)=>e.jsx(dl,{className:y("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:t,children:e.jsx(Ec,{className:y("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Z.displayName=dl.displayName;const Ds=m.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:y("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...n}));Ds.displayName="Textarea";const Lm=x.object({logo:x.string().nullable().default(""),force_https:x.number().nullable().default(0),stop_register:x.number().nullable().default(0),app_name:x.string().nullable().default(""),app_description:x.string().nullable().default(""),app_url:x.string().nullable().default(""),subscribe_url:x.string().nullable().default(""),try_out_plan_id:x.number().nullable().default(0),try_out_hour:x.coerce.number().nullable().default(0),tos_url:x.string().nullable().default(""),currency:x.string().nullable().default(""),currency_symbol:x.string().nullable().default("")});function Em(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),{data:a}=ne({queryKey:["settings","site"],queryFn:()=>he.getSettings("site")}),{data:i}=ne({queryKey:["plans"],queryFn:()=>gs.getList()}),l=we({resolver:Ce(Lm),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=Ts({mutationFn:he.saveSettings,onSuccess:c=>{c.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(a?.data?.site){const c=a?.data?.site;Object.entries(c).forEach(([h,k])=>{l.setValue(h,k)}),r.current=c}},[a]);const u=m.useCallback(ke.debounce(async c=>{if(!ke.isEqual(c,r.current)){t(!0);try{const h=Object.entries(c).reduce((k,[C,S])=>(k[C]=S===null?"":S,k),{});await d(h),r.current=c}finally{t(!1)}}},1e3),[d]),o=m.useCallback(c=>{u(c)},[u]);return m.useEffect(()=>{const c=l.watch(h=>{o(h)});return()=>c.unsubscribe()},[l.watch,o]),e.jsx(Se,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:l.control,name:"app_name",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.siteName.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"app_description",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.siteDescription.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"app_url",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.siteUrl.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"force_https",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(O,{children:s("site.form.forceHttps.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"logo",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.logo.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"subscribe_url",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(N,{children:e.jsx(Ds,{placeholder:s("site.form.subscribeUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.subscribeUrl.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"tos_url",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.tosUrl.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"stop_register",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(O,{children:s("site.form.stopRegister.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"try_out_plan_id",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(N,{children:e.jsxs(J,{value:c.value?.toString(),onValueChange:h=>{c.onChange(Number(h)),o(l.getValues())},children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(h=>e.jsx($,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(O,{children:s("site.form.tryOut.description")}),e.jsx(L,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(b,{control:l.control,name:"try_out_hour",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.tryOut.duration.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"currency",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.currency.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:l.control,name:"currency_symbol",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.currencySymbol.description")}),e.jsx(L,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Rm(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(Te,{}),e.jsx(Em,{})]})}const Fm=Object.freeze(Object.defineProperty({__proto__:null,default:Rm},Symbol.toStringTag,{value:"Module"})),Im=x.object({email_verify:x.boolean().nullable(),safe_mode_enable:x.boolean().nullable(),secure_path:x.string().nullable(),email_whitelist_enable:x.boolean().nullable(),email_whitelist_suffix:x.array(x.string().nullable()).nullable(),email_gmail_limit_enable:x.boolean().nullable(),recaptcha_enable:x.boolean().nullable(),recaptcha_key:x.string().nullable(),recaptcha_site_key:x.string().nullable(),register_limit_by_ip_enable:x.boolean().nullable(),register_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:x.boolean().nullable(),password_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable()}),Vm={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,recaptcha_enable:!1,recaptcha_key:"",recaptcha_site_key:"",register_limit_by_ip_enable:!1,register_limit_count:"",register_limit_expire:"",password_limit_enable:!1,password_limit_count:"",password_limit_expire:""};function Mm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(Im),defaultValues:Vm,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","safe"],queryFn:()=>he.getSettings("safe")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data.safe){const o=i.data.safe;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"email_verify",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(O,{children:s("safe.form.emailVerify.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(O,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(O,{children:s("safe.form.safeMode.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"secure_path",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.securePath.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(O,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("email_whitelist_enable")&&e.jsx(b,{control:a.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(N,{children:e.jsx(Ds,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` +Line: ${Mi}`}return JSON.stringify(B,null,2)}catch{return _.context}})()})})]})]}),e.jsx(Le,{children:e.jsx(Gs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common.close","关闭")})})})]})}),e.jsx(ge,{open:ee,onOpenChange:te,children:e.jsxs(de,{className:"max-w-2xl",children:[e.jsx(ve,{children:e.jsxs(fe,{className:"flex items-center gap-2",children:[e.jsx(ds,{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(Ae,{htmlFor:"clearDays",children:s("dashboard:systemLog.clearDays","清理天数")}),e.jsx(P,{id:"clearDays",type:"number",min:"1",max:"365",value:q,onChange:B=>F(parseInt(B.target.value)||30),placeholder:"30"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearDaysDesc","清理多少天前的日志 (1-365天)")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{htmlFor:"clearLevel",children:s("dashboard:systemLog.clearLevel","日志级别")}),e.jsxs(J,{value:X,onValueChange:Ns,children:[e.jsx(W,{children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:s("dashboard:systemLog.tabs.all","全部")}),e.jsx($,{value:"info",children:s("dashboard:systemLog.tabs.info","信息")}),e.jsx($,{value:"warning",children:s("dashboard:systemLog.tabs.warning","警告")}),e.jsx($,{value:"error",children:s("dashboard:systemLog.tabs.error","错误")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{htmlFor:"clearLimit",children:s("dashboard:systemLog.clearLimit","单次限制")}),e.jsx(P,{id:"clearLimit",type:"number",min:"100",max:"10000",value:De,onChange:B=>ie(parseInt(B.target.value)||1e3),placeholder:"1000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearLimitDesc","单次清理数量限制 (100-10000条)")})]})]}),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(kn,{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:Ri,disabled:_s,children:[e.jsx(Ss,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.getStats","获取统计")]})]}),Zt&&Xs&&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:Xs.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:Xs.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(Ht,{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:Xs.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(Le,{children:[e.jsx(G,{variant:"outline",onClick:()=>{te(!1),Rt(!1),Lt(null)},children:s("common.cancel","取消")}),e.jsx(G,{variant:"destructive",onClick:Ei,disabled:_s||!Zt||!Xs,children:_s?e.jsxs(e.Fragment,{children:[e.jsx(ya,{className:"mr-2 h-4 w-4 animate-spin"}),s("dashboard:systemLog.clearing","清理中...")]}):e.jsxs(e.Fragment,{children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.confirmClear","确认清理")]})})]})]})})]})}function Cm(){const{t:s}=V();return e.jsxs(ze,{children:[e.jsxs($e,{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(ns,{}),e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsx(He,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(vm,{}),e.jsx(hm,{}),e.jsx(bm,{}),e.jsx(wm,{})]})})})]})}const Sm=Object.freeze(Object.defineProperty({__proto__:null,default:Cm},Symbol.toStringTag,{value:"Module"}));function km({className:s,items:n,...t}){const{pathname:r}=bn(),a=As(),[i,l]=m.useState(r??"/settings"),d=o=>{l(o),a(o)},{t:u}=V("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(J,{value:i,onValueChange:d,children:[e.jsx(W,{className:"h-12 sm:w-48",children:e.jsx(Q,{placeholder:"Theme"})}),e.jsx(Y,{children:n.map(o=>e.jsx($,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:u(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:b("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(o=>e.jsxs(Ys,{to:o.href,className:b(Tt({variant:"ghost"}),r===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),u(o.title)]},o.href))})})]})}const Tm=[{title:"site.title",key:"site",icon:e.jsx(kc,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Ur,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Kr,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Tc,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(Hr,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Dc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Pc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(qr,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(Lc,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Dm(){const{t:s}=V("settings");return e.jsxs(ze,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Te,{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(km,{items:Tm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(yn,{})})})]})]})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:Dm},Symbol.toStringTag,{value:"Module"})),Z=m.forwardRef(({className:s,...n},t)=>e.jsx(dl,{className:b("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(Rc,{className:b("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")})}));Z.displayName=dl.displayName;const Ds=m.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:b("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}));Ds.displayName="Textarea";const Lm=x.object({logo:x.string().nullable().default(""),force_https:x.number().nullable().default(0),stop_register:x.number().nullable().default(0),app_name:x.string().nullable().default(""),app_description:x.string().nullable().default(""),app_url:x.string().nullable().default(""),subscribe_url:x.string().nullable().default(""),try_out_plan_id:x.number().nullable().default(0),try_out_hour:x.coerce.number().nullable().default(0),tos_url:x.string().nullable().default(""),currency:x.string().nullable().default(""),currency_symbol:x.string().nullable().default("")});function Rm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),{data:a}=ne({queryKey:["settings","site"],queryFn:()=>he.getSettings("site")}),{data:i}=ne({queryKey:["plans"],queryFn:()=>gs.getList()}),l=we({resolver:Ce(Lm),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=Ts({mutationFn:he.saveSettings,onSuccess:c=>{c.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(a?.data?.site){const c=a?.data?.site;Object.entries(c).forEach(([h,k])=>{l.setValue(h,k)}),r.current=c}},[a]);const u=m.useCallback(ke.debounce(async c=>{if(!ke.isEqual(c,r.current)){t(!0);try{const h=Object.entries(c).reduce((k,[C,S])=>(k[C]=S===null?"":S,k),{});await d(h),r.current=c}finally{t(!1)}}},1e3),[d]),o=m.useCallback(c=>{u(c)},[u]);return m.useEffect(()=>{const c=l.watch(h=>{o(h)});return()=>c.unsubscribe()},[l.watch,o]),e.jsx(Se,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:l.control,name:"app_name",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.siteName.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.siteName.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"app_description",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.siteDescription.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.siteDescription.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"app_url",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.siteUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.siteUrl.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"force_https",render:({field:c})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(O,{children:s("site.form.forceHttps.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"logo",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.logo.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.logo.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"subscribe_url",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(y,{children:e.jsx(Ds,{placeholder:s("site.form.subscribeUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.subscribeUrl.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"tos_url",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.tosUrl.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.tosUrl.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"stop_register",render:({field:c})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(O,{children:s("site.form.stopRegister.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:!!c.value,onCheckedChange:h=>{c.onChange(Number(h)),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"try_out_plan_id",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(y,{children:e.jsxs(J,{value:c.value?.toString(),onValueChange:h=>{c.onChange(Number(h)),o(l.getValues())},children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(h=>e.jsx($,{value:h.id.toString(),children:h.name},h.id.toString()))]})]})}),e.jsx(O,{children:s("site.form.tryOut.description")}),e.jsx(E,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(v,{control:l.control,name:"try_out_hour",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.tryOut.duration.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.tryOut.duration.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"currency",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.currency.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.currency.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:l.control,name:"currency_symbol",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("site.form.currencySymbol.placeholder"),...c,value:c.value||"",onChange:h=>{c.onChange(h),o(l.getValues())}})}),e.jsx(O,{children:s("site.form.currencySymbol.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Em(){const{t:s}=V("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(Te,{}),e.jsx(Rm,{})]})}const Fm=Object.freeze(Object.defineProperty({__proto__:null,default:Em},Symbol.toStringTag,{value:"Module"})),Im=x.object({email_verify:x.boolean().nullable(),safe_mode_enable:x.boolean().nullable(),secure_path:x.string().nullable(),email_whitelist_enable:x.boolean().nullable(),email_whitelist_suffix:x.array(x.string().nullable()).nullable(),email_gmail_limit_enable:x.boolean().nullable(),recaptcha_enable:x.boolean().nullable(),recaptcha_key:x.string().nullable(),recaptcha_site_key:x.string().nullable(),register_limit_by_ip_enable:x.boolean().nullable(),register_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:x.boolean().nullable(),password_limit_count:x.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:x.coerce.string().transform(s=>s===""?null:s).nullable()}),Vm={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,recaptcha_enable:!1,recaptcha_key:"",recaptcha_site_key:"",register_limit_by_ip_enable:!1,register_limit_count:"",register_limit_expire:"",password_limit_enable:!1,password_limit_count:"",password_limit_expire:""};function Mm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(Im),defaultValues:Vm,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","safe"],queryFn:()=>he.getSettings("safe")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data.safe){const o=i.data.safe;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"email_verify",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(O,{children:s("safe.form.emailVerify.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(O,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(O,{children:s("safe.form.safeMode.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"secure_path",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.securePath.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(O,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("email_whitelist_enable")&&e.jsx(v,{control:a.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(y,{children:e.jsx(Ds,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` `),onChange:c=>{const h=c.target.value.split(` -`).filter(Boolean);o.onChange(h),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(O,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:a.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.recaptcha.key.description")}),e.jsx(L,{})]})})]}),e.jsx(b,{control:a.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(O,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:a.control,name:"register_limit_count",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.registerLimit.count.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(L,{})]})})]}),e.jsx(b,{control:a.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(O,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:a.control,name:"password_limit_count",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(L,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function Om(){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(Te,{}),e.jsx(Mm,{})]})}const zm=Object.freeze(Object.defineProperty({__proto__:null,default:Om},Symbol.toStringTag,{value:"Module"})),$m=x.object({plan_change_enable:x.boolean().nullable().default(!1),reset_traffic_method:x.coerce.number().nullable().default(0),surplus_enable:x.boolean().nullable().default(!1),new_order_event_id:x.coerce.number().nullable().default(0),renew_order_event_id:x.coerce.number().nullable().default(0),change_order_event_id:x.coerce.number().nullable().default(0),show_info_to_server_enable:x.boolean().nullable().default(!1),show_protocol_to_server_enable:x.boolean().nullable().default(!1),default_remind_expire:x.boolean().nullable().default(!1),default_remind_traffic:x.boolean().nullable().default(!1),subscribe_path:x.string().nullable().default("s")}),Am={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 qm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce($m),defaultValues:Am,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","subscribe"],queryFn:()=>he.getSettings("subscribe")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.subscribe){const o=i?.data?.subscribe;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(O,{children:s("subscribe.plan_change_enable.description")}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择重置方式"})})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx($,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx($,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx($,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx($,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(O,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"surplus_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(O,{children:s("subscribe.surplus_enable.description")}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(N,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.new_order_event.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(N,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.renew_order_event.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(N,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.change_order_event.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"subscribe_path",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:"subscribe",...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:o.value||"s"})]}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(O,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(O,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Hm(){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(Te,{}),e.jsx(qm,{})]})}const Um=Object.freeze(Object.defineProperty({__proto__:null,default:Hm},Symbol.toStringTag,{value:"Module"})),Km=x.object({invite_force:x.boolean().default(!1),invite_commission:x.coerce.string().default("0"),invite_gen_limit:x.coerce.string().default("0"),invite_never_expire:x.boolean().default(!1),commission_first_time_enable:x.boolean().default(!1),commission_auto_check_enable:x.boolean().default(!1),commission_withdraw_limit:x.coerce.string().default("0"),commission_withdraw_method:x.array(x.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:x.boolean().default(!1),commission_distribution_enable:x.boolean().default(!1),commission_distribution_l1:x.coerce.number().default(0),commission_distribution_l2:x.coerce.number().default(0),commission_distribution_l3:x.coerce.number().default(0)}),Bm={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 Gm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(Km),defaultValues:Bm,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","invite"],queryFn:()=>he.getSettings("invite")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.invite){const o=i?.data?.invite;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"invite_force",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(O,{children:s("invite.invite_force.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"invite_commission",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("invite.invite_commission.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("invite.invite_gen_limit.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(O,{children:s("invite.invite_never_expire.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(O,{children:s("invite.commission_first_time.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(O,{children:s("invite.commission_auto_check.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_method.placeholder"),...o,value:Array.isArray(o.value)?o.value.join(","):"",onChange:c=>{const h=c.target.value.split(",").filter(Boolean);o.onChange(h),u(a.getValues())}})}),e.jsx(O,{children:s("invite.commission_withdraw_method.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(O,{children:s("invite.withdraw_close.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(O,{children:s("invite.commission_distribution.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:a.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:s("invite.commission_distribution.l1")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),u(a.getValues())}})}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:s("invite.commission_distribution.l2")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),u(a.getValues())}})}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:s("invite.commission_distribution.l3")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),u(a.getValues())}})}),e.jsx(L,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function Wm(){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(Te,{}),e.jsx(Gm,{})]})}const Ym=Object.freeze(Object.defineProperty({__proto__:null,default:Wm},Symbol.toStringTag,{value:"Module"})),Jm=x.object({frontend_theme:x.string().nullable(),frontend_theme_sidebar:x.string().nullable(),frontend_theme_header:x.string().nullable(),frontend_theme_color:x.string().nullable(),frontend_background_url:x.string().url().nullable()}),Qm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Xm(){const{data:s}=ne({queryKey:["settings","frontend"],queryFn:()=>he.getSettings("frontend")}),n=we({resolver:Ce(Jm),defaultValues:Qm,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){he.saveSettings(r).then(({data:a})=>{a&&A.success("更新成功")})}return e.jsx(Se,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(b,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:"边栏风格"}),e.jsx(O,{children:"边栏风格"})]}),e.jsx(N,{children:e.jsx(Z,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:"头部风格"}),e.jsx(O,{children:"边栏风格"})]}),e.jsx(N,{children:e.jsx(Z,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(j,{children:[e.jsx(v,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(N,{children:e.jsxs("select",{className:y(Tt({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(Sn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(O,{children:"主题色"}),e.jsx(L,{})]})}),e.jsx(b,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(j,{children:[e.jsx(v,{children:"背景"}),e.jsx(N,{children:e.jsx(D,{placeholder:"请输入图片地址",...r})}),e.jsx(O,{children:"将会在后台登录页面进行展示。"}),e.jsx(L,{})]})}),e.jsx(P,{type:"submit",children:"保存设置"})]})})}function Zm(){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(Te,{}),e.jsx(Xm,{})]})}const eu=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"})),su=x.object({server_pull_interval:x.coerce.number().nullable(),server_push_interval:x.coerce.number().nullable(),server_token:x.string().nullable(),device_limit_mode:x.coerce.number().nullable()}),tu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function au(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(su),defaultValues:tu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","server"],queryFn:()=>he.getSettings("server")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:c=>{c.data&&A.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(i?.data.server){const c=i.data.server;Object.entries(c).forEach(([h,k])=>{a.setValue(h,k)}),r.current=c}},[i]);const d=m.useCallback(ke.debounce(async c=>{if(!ke.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),u=m.useCallback(c=>{d(c)},[d]);m.useEffect(()=>{const c=a.watch(h=>{u(h)});return()=>c.unsubscribe()},[a.watch,u]);const o=()=>{const c=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let k="";for(let C=0;Ce.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("server.server_token.title")}),e.jsx(N,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...c,value:c.value||"",className:"pr-10"}),e.jsx(be,{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:h=>{h.preventDefault(),o()},children:e.jsx(Rc,{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(O,{children:s("server.server_token.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"server_pull_interval",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const k=h.target.value?Number(h.target.value):null;c.onChange(k)}})}),e.jsx(O,{children:s("server.server_pull_interval.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"server_push_interval",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const k=h.target.value?Number(h.target.value):null;c.onChange(k)}})}),e.jsx(O,{children:s("server.server_push_interval.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"device_limit_mode",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(J,{onValueChange:c.onChange,value:c.value?.toString()||"0",children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx($,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(O,{children:s("server.device_limit_mode.description")}),e.jsx(L,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.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("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(Te,{}),e.jsx(au,{})]})}const ru=Object.freeze(Object.defineProperty({__proto__:null,default:nu},Symbol.toStringTag,{value:"Module"}));function lu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(ol,{className:"h-5 w-5 text-green-500"}):e.jsx(cl,{className:"h-5 w-5 text-destructive"}),e.jsx(fe,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ve,{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(lt,{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 iu=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function ou(){const{t:s}=V("settings"),[n,t]=m.useState(null),[r,a]=m.useState(!1),i=m.useRef(null),[l,d]=m.useState(!1),u=we({resolver:Ce(iu),defaultValues:{},mode:"onBlur"}),{data:o}=ne({queryKey:["settings","email"],queryFn:()=>he.getSettings("email")}),{data:c}=ne({queryKey:["emailTemplate"],queryFn:()=>he.getEmailTemplate()}),{mutateAsync:h}=Ts({mutationFn:he.saveSettings,onSuccess:_=>{_.data&&A.success(s("common.autoSaved"))}}),{mutate:k,isPending:C}=Ts({mutationFn:he.sendTestMail,onMutate:()=>{t(null),a(!1)},onSuccess:_=>{t(_.data),a(!0),_.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});m.useEffect(()=>{if(o?.data.email){const _=o.data.email;Object.entries(_).forEach(([f,T])=>{u.setValue(f,T)}),i.current=_}},[o]);const S=m.useCallback(ke.debounce(async _=>{if(!ke.isEqual(_,i.current)){d(!0);try{await h(_),i.current=_}finally{d(!1)}}},1e3),[h]),p=m.useCallback(_=>{S(_)},[S]);return m.useEffect(()=>{const _=u.watch(f=>{p(f)});return()=>_.unsubscribe()},[u.watch,p]),e.jsxs(e.Fragment,{children:[e.jsx(Se,{...u,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:u.control,name:"email_host",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_host.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),..._,value:_.value||""})}),e.jsx(O,{children:s("email.email_host.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"email_port",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_port.title")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),..._,value:_.value||"",onChange:f=>{const T=f.target.value?Number(f.target.value):null;_.onChange(T)}})}),e.jsx(O,{children:s("email.email_port.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"email_encryption",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(J,{onValueChange:f=>{const T=f==="none"?"":f;_.onChange(T)},value:_.value===""||_.value===null||_.value===void 0?"none":_.value,children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择加密方式"})})}),e.jsxs(Y,{children:[e.jsx($,{value:"none",children:s("email.email_encryption.none")}),e.jsx($,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx($,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(O,{children:s("email.email_encryption.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"email_username",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_username.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),..._,value:_.value||""})}),e.jsx(O,{children:s("email.email_username.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"email_password",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_password.title")}),e.jsx(N,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),..._,value:_.value||""})}),e.jsx(O,{children:s("email.email_password.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"email_from_address",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_from.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),..._,value:_.value||""})}),e.jsx(O,{children:s("email.email_from.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"email_template",render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(J,{onValueChange:f=>{_.onChange(f),p(u.getValues())},value:_.value||void 0,children:[e.jsx(N,{children:e.jsx(W,{className:"w-[200px]",children:e.jsx(Q,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(Y,{children:c?.data?.map(f=>e.jsx($,{value:f,children:f},f))})]}),e.jsx(O,{children:s("email.email_template.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"remind_mail_enable",render:({field:_})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(O,{children:s("email.remind_mail.description")})]}),e.jsx(N,{children:e.jsx(Z,{checked:_.value||!1,onCheckedChange:f=>{_.onChange(f),p(u.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(P,{onClick:()=>k(),loading:C,disabled:C,children:s(C?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(lu,{open:r,onOpenChange:a,result:n})]})}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("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(Te,{}),e.jsx(ou,{})]})}const du=Object.freeze(Object.defineProperty({__proto__:null,default:cu},Symbol.toStringTag,{value:"Module"})),mu=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),uu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function xu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(mu),defaultValues:uu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","telegram"],queryFn:()=>he.getSettings("telegram")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}}),{mutate:d,isPending:u}=Ts({mutationFn:he.setTelegramWebhook,onSuccess:h=>{h.data&&A.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(i?.data.telegram){const h=i.data.telegram;Object.entries(h).forEach(([k,C])=>{a.setValue(k,C)}),r.current=h}},[i]);const o=m.useCallback(ke.debounce(async h=>{if(!ke.isEqual(h,r.current)){t(!0);try{await l(h),r.current=h}finally{t(!1)}}},1e3),[l]),c=m.useCallback(h=>{o(h)},[o]);return m.useEffect(()=>{const h=a.watch(k=>{c(k)});return()=>h.unsubscribe()},[a.watch,c]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(O,{children:s("telegram.bot_token.description")}),e.jsx(L,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(P,{loading:u,disabled:u,onClick:()=>d(),children:s(u?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(O,{children:s("telegram.webhook.description")}),e.jsx(L,{})]}),e.jsx(b,{control:a.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(O,{children:s("telegram.bot_enable.description")}),e.jsx(N,{children:e.jsx(Z,{checked:h.value||!1,onCheckedChange:k=>{h.onChange(k),c(a.getValues())}})}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(O,{children:s("telegram.discuss_link.description")}),e.jsx(L,{})]})}),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("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(Te,{}),e.jsx(xu,{})]})}const gu=Object.freeze(Object.defineProperty({__proto__:null,default:hu},Symbol.toStringTag,{value:"Module"})),fu=x.object({windows_version:x.string().nullable(),windows_download_url:x.string().nullable(),macos_version:x.string().nullable(),macos_download_url:x.string().nullable(),android_version:x.string().nullable(),android_download_url:x.string().nullable()}),pu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function ju(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(fu),defaultValues:pu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","app"],queryFn:()=>he.getSettings("app")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("app.save_success"))}});m.useEffect(()=>{if(i?.data.app){const o=i.data.app;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"windows_version",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.windows.version.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"windows_download_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.windows.download.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"macos_version",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.macos.version.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"macos_download_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.macos.download.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"android_version",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("app.android.version.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.android.version.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"android_download_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{className:"text-base",children:s("app.android.download.title")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.android.download.description")}),e.jsx(L,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.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("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(Te,{}),e.jsx(ju,{})]})}const bu=Object.freeze(Object.defineProperty({__proto__:null,default:vu},Symbol.toStringTag,{value:"Module"})),yu=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),xr={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function Wl({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=xr}){const{t:a}=V("payment"),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[o,c]=m.useState([]),[h,k]=m.useState([]),C=yu(a),S=we({resolver:Ce(C),defaultValues:r,mode:"onChange"}),p=S.watch("payment");m.useEffect(()=>{i&&(async()=>{const{data:T}=await nt.getMethodList();c(T)})()},[i]),m.useEffect(()=>{if(!p||!i)return;(async()=>{const T={payment:p,...t==="edit"&&{id:Number(S.getValues("id"))}};nt.getMethodForm(T).then(({data:E})=>{k(E);const g=E.reduce((w,R)=>(R.field_name&&(w[R.field_name]=R.value??""),w),{});S.setValue("config",g)})})()},[p,i,S,t]);const _=async f=>{u(!0);try{(await nt.save(f)).data&&(A.success(a("form.messages.success")),S.reset(xr),s(),l(!1))}finally{u(!1)}};return e.jsxs(ge,{open:i,onOpenChange:l,children:[e.jsx(as,{asChild:!0,children:n||e.jsxs(P,{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(de,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(Se,{...S,children:e.jsxs("form",{onSubmit:S.handleSubmit(_),className:"space-y-4",children:[e.jsx(b,{control:S.control,name:"name",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:a("form.fields.name.placeholder"),...f})}),e.jsx(O,{children:a("form.fields.name.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:S.control,name:"icon",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.icon.label")}),e.jsx(N,{children:e.jsx(D,{...f,value:f.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(O,{children:a("form.fields.icon.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:S.control,name:"notify_domain",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.notify_domain.label")}),e.jsx(N,{children:e.jsx(D,{...f,value:f.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(O,{children:a("form.fields.notify_domain.description")}),e.jsx(L,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:S.control,name:"handling_fee_percent",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(N,{children:e.jsx(D,{type:"number",...f,value:f.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(L,{})]})}),e.jsx(b,{control:S.control,name:"handling_fee_fixed",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(N,{children:e.jsx(D,{type:"number",...f,value:f.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(L,{})]})})]}),e.jsx(b,{control:S.control,name:"payment",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.payment.label")}),e.jsxs(J,{onValueChange:f.onChange,defaultValue:f.value,children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(Y,{children:o.map(T=>e.jsx($,{value:T,children:T},T))})]}),e.jsx(O,{children:a("form.fields.payment.description")}),e.jsx(L,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(f=>e.jsx(b,{control:S.control,name:`config.${f.field_name}`,render:({field:T})=>e.jsxs(j,{children:[e.jsx(v,{children:f.label}),e.jsx(N,{children:e.jsx(D,{...T,value:T.value||""})}),e.jsx(L,{})]})},f.field_name))}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function 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(P,{variant:"ghost",size:"default",className:y("-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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(sr,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(dn,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(mn,{className:"h-4 w-4 text-foreground/70"}):e.jsx(Fc,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:y("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",r),children:[e.jsx("span",{children:n}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(sr,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const On=Ic,Yl=Vc,Nu=Mc,Jl=m.forwardRef(({className:s,...n},t)=>e.jsx(ml,{className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));Jl.displayName=ml.displayName;const Oa=m.forwardRef(({className:s,...n},t)=>e.jsxs(Nu,{children:[e.jsx(Jl,{}),e.jsx(ul,{ref:t,className:y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));Oa.displayName=ul.displayName;const za=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...n});za.displayName="AlertDialogHeader";const $a=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});$a.displayName="AlertDialogFooter";const Aa=m.forwardRef(({className:s,...n},t)=>e.jsx(xl,{ref:t,className:y("text-lg font-semibold",s),...n}));Aa.displayName=xl.displayName;const qa=m.forwardRef(({className:s,...n},t)=>e.jsx(hl,{ref:t,className:y("text-sm text-muted-foreground",s),...n}));qa.displayName=hl.displayName;const Ha=m.forwardRef(({className:s,...n},t)=>e.jsx(gl,{ref:t,className:y(St(),s),...n}));Ha.displayName=gl.displayName;const Ua=m.forwardRef(({className:s,...n},t)=>e.jsx(fl,{ref:t,className:y(St({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Ua.displayName=fl.displayName;function ps({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(On,{children:[e.jsx(Yl,{asChild:!0,children:n}),e.jsxs(Oa,{className:y("sm:max-w-[425px]",d),children:[e.jsxs(za,{children:[e.jsx(Aa,{children:t}),e.jsx(qa,{children:r})]}),e.jsxs($a,{children:[e.jsx(Ua,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a})}),e.jsx(Ha,{asChild:!0,children:e.jsx(P,{variant:l,onClick:s,children:i})})]})]})]})}const Ql=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"})}),_u=({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(Ra,{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(Z,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await nt.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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{className:"ml-1",children:e.jsx(Ql,{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(Wl,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{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(ps,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await nt.drop({id:r.original.id});a&&s()},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(ds,{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 wu({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(Wl,{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(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Cu(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,o]=m.useState({"drag-handle":!1}),[c,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:k}=ne({queryKey:["paymentList"],queryFn:async()=>{const{data:f}=await nt.getList();return d(f?.map(T=>({...T,enable:!!T.enable}))||[]),f}});m.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const C=(f,T)=>{a&&(f.dataTransfer.setData("text/plain",T.toString()),f.currentTarget.classList.add("opacity-50"))},S=(f,T)=>{if(!a)return;f.preventDefault(),f.currentTarget.classList.remove("bg-muted");const E=parseInt(f.dataTransfer.getData("text/plain"));if(E===T)return;const g=[...l],[w]=g.splice(E,1);g.splice(T,0,w),d(g)},p=async()=>{a?nt.sort({ids:l.map(f=>f.id)}).then(()=>{k(),i(!1),A.success("排序保存成功")}):i(!0)},_=ss({data:l,columns:_u({refetch:k,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(xs,{table:_,toolbar:f=>e.jsx(wu,{table:f,refetch:k,saveOrder:p,isSortMode:a}),draggable:a,onDragStart:C,onDragEnd:f=>f.currentTarget.classList.remove("opacity-50"),onDragOver:f=>{f.preventDefault(),f.currentTarget.classList.add("bg-muted")},onDragLeave:f=>f.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!a})}function Su(){const{t:s}=V("payment");return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsx(ns,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Cu,{})})]})]})}const ku=Object.freeze(Object.defineProperty({__proto__:null,default:Su},Symbol.toStringTag,{value:"Module"}));function Tu({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,i]=m.useState(!0),[l,d]=m.useState(!1),[u,o]=m.useState(null),c=Oc({config:zc($c())}),h=we({resolver:Ce(c),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:p}=await Ms.getPluginConfig(s);o(p),h.reset({config:Object.fromEntries(Object.entries(p).map(([_,f])=>[_,f.value]))})}catch{A.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const k=async S=>{d(!0);try{await Ms.updatePluginConfig(s,S.config),A.success(r("messages.configSaveSuccess")),t()}catch{A.error(r("messages.configSaveError"))}finally{d(!1)}},C=(S,p)=>{switch(p.type){case"string":return e.jsx(b,{control:h.control,name:`config.${S}`,render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{children:p.label||p.description}),e.jsx(N,{children:e.jsx(D,{placeholder:p.placeholder,..._})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(L,{})]})},S);case"number":case"percentage":return e.jsx(b,{control:h.control,name:`config.${S}`,render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{children:p.label||p.description}),e.jsx(N,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:p.placeholder,..._,onChange:f=>{const T=Number(f.target.value);p.type==="percentage"?_.onChange(Math.min(100,Math.max(0,T))):_.onChange(T)},className:p.type==="percentage"?"pr-8":"",min:p.type==="percentage"?0:void 0,max:p.type==="percentage"?100:void 0,step:p.type==="percentage"?1:void 0}),p.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(Ac,{className:"h-4 w-4 text-muted-foreground"})})]})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(L,{})]})},S);case"select":return e.jsx(b,{control:h.control,name:`config.${S}`,render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{children:p.label||p.description}),e.jsxs(J,{onValueChange:_.onChange,defaultValue:_.value,children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:p.placeholder})})}),e.jsx(Y,{children:p.options?.map(f=>e.jsx($,{value:f.value,children:f.label},f.value))})]}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(L,{})]})},S);case"boolean":return e.jsx(b,{control:h.control,name:`config.${S}`,render:({field:_})=>e.jsxs(j,{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:p.label||p.description}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description})]}),e.jsx(N,{children:e.jsx(Z,{checked:_.value,onCheckedChange:_.onChange})})]})},S);case"text":return e.jsx(b,{control:h.control,name:`config.${S}`,render:({field:_})=>e.jsxs(j,{children:[e.jsx(v,{children:p.label||p.description}),e.jsx(N,{children:e.jsx(Ds,{placeholder:p.placeholder,..._})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(L,{})]})},S);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"})]}):e.jsx(Se,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(k),className:"space-y-4",children:[u&&Object.entries(u).map(([S,p])=>C(S,p)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(P,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function Du(){const{t:s}=V("plugin"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(null),[d,u]=m.useState(""),[o,c]=m.useState("all"),[h,k]=m.useState(!1),[C,S]=m.useState(!1),[p,_]=m.useState(!1),f=m.useRef(null),{data:T,isLoading:E,refetch:g}=ne({queryKey:["pluginList"],queryFn:async()=>{const{data:F}=await Ms.getPluginList();return F}});T&&[...new Set(T.map(F=>F.category||"other"))];const w=T?.filter(F=>{const X=F.name.toLowerCase().includes(d.toLowerCase())||F.description.toLowerCase().includes(d.toLowerCase())||F.code.toLowerCase().includes(d.toLowerCase()),ys=o==="all"||F.category===o;return X&&ys}),R=async F=>{t(F),Ms.installPlugin(F).then(()=>{A.success(s("messages.installSuccess")),g()}).catch(X=>{A.error(X.message||s("messages.installError"))}).finally(()=>{t(null)})},H=async F=>{t(F),Ms.uninstallPlugin(F).then(()=>{A.success(s("messages.uninstallSuccess")),g()}).catch(X=>{A.error(X.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},I=async(F,X)=>{t(F),(X?Ms.disablePlugin:Ms.enablePlugin)(F).then(()=>{A.success(s(X?"messages.disableSuccess":"messages.enableSuccess")),g()}).catch(De=>{A.error(De.message||s(X?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},K=F=>{T?.find(X=>X.code===F),l(F),a(!0)},ae=async F=>{if(!F.name.endsWith(".zip")){A.error(s("upload.error.format"));return}k(!0),Ms.uploadPlugin(F).then(()=>{A.success(s("messages.uploadSuccess")),S(!1),g()}).catch(X=>{A.error(X.message||s("messages.uploadError"))}).finally(()=>{k(!1),f.current&&(f.current.value="")})},ee=F=>{F.preventDefault(),F.stopPropagation(),F.type==="dragenter"||F.type==="dragover"?_(!0):F.type==="dragleave"&&_(!1)},te=F=>{F.preventDefault(),F.stopPropagation(),_(!1),F.dataTransfer.files&&F.dataTransfer.files[0]&&ae(F.dataTransfer.files[0])},q=async F=>{t(F),Ms.deletePlugin(F).then(()=>{A.success(s("messages.deleteSuccess")),g()}).catch(X=>{A.error(X.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(wn,{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(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Cn,{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:F=>u(F.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(P,{onClick:()=>S(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Dt,{defaultValue:"all",className:"w-full",children:[e.jsxs(dt,{children:[e.jsx(Xe,{value:"all",children:s("tabs.all")}),e.jsx(Xe,{value:"installed",children:s("tabs.installed")}),e.jsx(Xe,{value:"available",children:s("tabs.available")})]}),e.jsx(Ss,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:E?e.jsxs(e.Fragment,{children:[e.jsx(an,{}),e.jsx(an,{}),e.jsx(an,{})]}):w?.map(F=>e.jsx(tn,{plugin:F,onInstall:R,onUninstall:H,onToggleEnable:I,onOpenConfig:K,onDelete:q,isLoading:n===F.name},F.name))})}),e.jsx(Ss,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(F=>F.is_installed).map(F=>e.jsx(tn,{plugin:F,onInstall:R,onUninstall:H,onToggleEnable:I,onOpenConfig:K,onDelete:q,isLoading:n===F.name},F.name))})}),e.jsx(Ss,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(F=>!F.is_installed).map(F=>e.jsx(tn,{plugin:F,onInstall:R,onUninstall:H,onToggleEnable:I,onOpenConfig:K,onDelete:q,isLoading:n===F.name},F.code))})})]})]}),e.jsx(ge,{open:r,onOpenChange:a,children:e.jsxs(de,{className:"sm:max-w-lg",children:[e.jsxs(ve,{children:[e.jsxs(fe,{children:[T?.find(F=>F.code===i)?.name," ",s("config.title")]}),e.jsx(Ve,{children:s("config.description")})]}),i&&e.jsx(Tu,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),g()}})]})}),e.jsx(ge,{open:C,onOpenChange:S,children:e.jsxs(de,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:s("upload.title")}),e.jsx(Ve,{children:s("upload.description")})]}),e.jsxs("div",{className:y("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",p&&"border-primary/50 bg-muted/50"),onDragEnter:ee,onDragLeave:ee,onDragOver:ee,onDrop:te,children:[e.jsx("input",{type:"file",ref:f,className:"hidden",accept:".zip",onChange:F=>{const X=F.target.files?.[0];X&&ae(X)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(wt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>f.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function tn({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l}){const{t:d}=V("plugin");return e.jsxs(Ee,{className:"group relative overflow-hidden transition-all hover:shadow-md",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(Ge,{children:s.name}),s.is_installed&&e.jsx(U,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?d("status.enabled"):d("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Os,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[d("author"),": ",s.author]})})]})})]}),e.jsx(Ie,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(pl,{className:"mr-2 h-4 w-4"}),d("button.config")]}),e.jsxs(P,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),s.is_enabled?d("button.disable"):d("button.enable")]}),e.jsx(ps,{title:d("uninstall.title"),description:d("uninstall.description"),cancelText:d("common:cancel"),confirmText:d("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(P,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),d("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(P,{onClick:()=>n(s.code),disabled:l,loading:l,children:d("button.install")}),e.jsx(ps,{title:d("delete.title"),description:d("delete.description"),cancelText:d("common:cancel"),confirmText:d("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(P,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(ds,{className:"h-4 w-4"})})})]})})})]})}function an(){return e.jsxs(Ee,{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(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(je,{className:"h-5 w-[120px]"}),e.jsx(je,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(je,{className:"h-4 w-[300px]"}),e.jsx(je,{className:"h-4 w-[150px]"})]})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-8 w-8"})]})})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"})),Lu=(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(Ds,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:y(St({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Eu({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),o=we({defaultValues:n.configs.reduce((k,C)=>(k[C.field_name]="",k),{})}),c=async()=>{l(!0),Kt.getConfig(s).then(({data:k})=>{Object.entries(k).forEach(([C,S])=>{o.setValue(C,S)})}).finally(()=>{l(!1)})},h=async k=>{u(!0),Kt.updateConfig(s,k).then(()=>{A.success(t("config.success")),a(!1)}).finally(()=>{u(!1)})};return e.jsxs(ge,{open:r,onOpenChange:k=>{a(k),k?c():o.reset()},children:[e.jsx(as,{asChild:!0,children:e.jsx(P,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(de,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:t("config.title",{name:n.name})}),e.jsx(Ve,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ya,{className:"h-6 w-6 animate-spin"})}):e.jsx(Se,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(h),className:"space-y-4",children:[n.configs.map(k=>e.jsx(b,{control:o.control,name:k.field_name,render:({field:C})=>e.jsxs(j,{children:[e.jsx(v,{children:k.label}),e.jsx(N,{children:Lu(k,C)}),e.jsx(L,{})]})},k.field_name)),e.jsxs(Le,{className:"mt-6 gap-2",children:[e.jsx(P,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(P,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function Ru(){const{t:s}=V("theme"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[o,c]=m.useState(null),h=m.useRef(null),[k,C]=m.useState(0),{data:S,isLoading:p,refetch:_}=ne({queryKey:["themeList"],queryFn:async()=>{const{data:I}=await Kt.getList();return I}}),f=async I=>{t(I),he.updateSystemConfig({frontend_theme:I}).then(()=>{A.success("主题切换成功"),_()}).finally(()=>{t(null)})},T=async I=>{if(!I.name.endsWith(".zip")){A.error(s("upload.error.format"));return}a(!0),Kt.upload(I).then(()=>{A.success("主题上传成功"),l(!1),_()}).finally(()=>{a(!1),h.current&&(h.current.value="")})},E=I=>{I.preventDefault(),I.stopPropagation(),I.type==="dragenter"||I.type==="dragover"?u(!0):I.type==="dragleave"&&u(!1)},g=I=>{I.preventDefault(),I.stopPropagation(),u(!1),I.dataTransfer.files&&I.dataTransfer.files[0]&&T(I.dataTransfer.files[0])},w=()=>{o&&C(I=>I===0?o.images.length-1:I-1)},R=()=>{o&&C(I=>I===o.images.length-1?0:I+1)},H=(I,K)=>{C(0),c({name:I,images:K})};return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsx(ns,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(P,{onClick:()=>l(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(wt,{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:p?e.jsxs(e.Fragment,{children:[e.jsx(hr,{}),e.jsx(hr,{})]}):S?.themes&&Object.entries(S.themes).map(([I,K])=>e.jsx(Ee,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:K.background_url?`url(${K.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:y("relative z-10 h-full transition-colors",K.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!K.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(ps,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(I===S?.active){A.error(s("card.delete.error.active"));return}t(I),Kt.drop(I).then(()=>{A.success("主题删除成功"),_()}).finally(()=>{t(null)})},children:e.jsx(P,{disabled:n===I,loading:n===I,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(ds,{className:"h-4 w-4"})})})}),e.jsxs(Fe,{children:[e.jsx(Ge,{children:K.name}),e.jsx(Os,{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(Ie,{className:"flex items-center justify-end space-x-3",children:[K.images&&Array.isArray(K.images)&&K.images.length>0&&e.jsx(P,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>H(K.name,K.images),children:e.jsx(Hc,{className:"h-4 w-4"})}),e.jsx(Eu,{themeKey:I,themeInfo:K}),e.jsx(P,{onClick:()=>f(I),disabled:n===I||I===S.active,loading:n===I,variant:I===S.active?"secondary":"default",children:I===S.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},I))}),e.jsx(ge,{open:i,onOpenChange:l,children:e.jsxs(de,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:s("upload.title")}),e.jsx(Ve,{children:s("upload.description")})]}),e.jsxs("div",{className:y("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",d&&"border-primary/50 bg-muted/50"),onDragEnter:E,onDragLeave:E,onDragOver:E,onDrop:g,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:I=>{const K=I.target.files?.[0];K&&T(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(wt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(ge,{open:!!o,onOpenChange:I=>{I||(c(null),C(0))},children:e.jsxs(de,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(fe,{children:[o?.name," ",s("preview.title")]}),e.jsx(Ve,{className:"text-center",children:o&&s("preview.imageCount",{current:k+1,total:o.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:o?.images[k]&&e.jsx("img",{src:o.images[k],alt:`${o.name} 预览图 ${k+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:w,children:e.jsx(Uc,{className:"h-4 w-4"})}),e.jsx(P,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:R,children:e.jsx(Kc,{className:"h-4 w-4"})})]})]}),o&&o.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:o.images.map((I,K)=>e.jsx("button",{onClick:()=>C(K),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",k===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:I,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function hr(){return e.jsxs(Ee,{children:[e.jsxs(Fe,{children:[e.jsx(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-4 w-[300px]"})]}),e.jsxs(Ie,{className:"flex items-center justify-end space-x-3",children:[e.jsx(je,{className:"h-10 w-[100px]"}),e.jsx(je,{className:"h-10 w-[100px]"})]})]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Ru},Symbol.toStringTag,{value:"Module"})),zn=m.forwardRef(({className:s,value:n,onChange:t,...r},a)=>{const[i,l]=m.useState("");m.useEffect(()=>{if(i.includes(",")){const u=new Set([...n,...i.split(",").map(o=>o.trim())]);t(Array.from(u)),l("")}},[i,t,n]);const d=()=>{if(i){const u=new Set([...n,i]);t(Array.from(u)),l("")}};return e.jsxs("div",{className:y(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(u=>e.jsxs(U,{variant:"secondary",children:[u,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(o=>o!==u))},children:e.jsx(hn,{className:"w-3"})})]},u)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"||u.key===","?(u.preventDefault(),d()):u.key==="Backspace"&&i.length===0&&n.length>0&&(u.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});zn.displayName="InputTags";const Iu=x.object({id:x.number().nullable(),title:x.string().min(1).max(250),content:x.string().min(1),show:x.boolean(),tags:x.array(x.string()),img_url:x.string().nullable()}),Vu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Xl({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Vu}){const{t:a}=V("notice"),[i,l]=m.useState(!1),d=we({resolver:Ce(Iu),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new Tn({html:!0});return e.jsx(Se,{...d,children:e.jsxs(ge,{onOpenChange:l,open:i,children:[e.jsx(as,{asChild:!0,children:n||e.jsxs(P,{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(de,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ve,{})]}),e.jsx(b,{control:d.control,name:"title",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(N,{children:e.jsx(D,{placeholder:a("form.fields.title.placeholder"),...o})})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"content",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.content.label")}),e.jsx(N,{children:e.jsx(Dn,{style:{height:"500px"},value:o.value,renderHTML:c=>u.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"img_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(D,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"show",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"tags",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.fields.tags.label")}),e.jsx(N,{children:e.jsx(zn,{value:o.value,onChange:o.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(L,{})]})}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(P,{type:"submit",onClick:o=>{o.preventDefault(),d.handleSubmit(async c=>{Qt.save(c).then(({data:h})=>{h&&(A.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function Mu({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(Xl,{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(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const Ou=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Bc,{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(Z,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await Qt.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(Xl,{refetch:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{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(ps,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{Qt.drop(t.original.id).then(()=>{A.success(n("table.actions.delete.success")),s()})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ds,{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 zu(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,o]=m.useState(!1),[c,h]=m.useState({}),[k,C]=m.useState({pageSize:50,pageIndex:0}),[S,p]=m.useState([]),{refetch:_}=ne({queryKey:["notices"],queryFn:async()=>{const{data:w}=await Qt.getList();return p(w),w}});m.useEffect(()=>{r({"drag-handle":u,content:!u,created_at:!u,actions:!u}),C({pageSize:u?99999:50,pageIndex:0})},[u]);const f=(w,R)=>{u&&(w.dataTransfer.setData("text/plain",R.toString()),w.currentTarget.classList.add("opacity-50"))},T=(w,R)=>{if(!u)return;w.preventDefault(),w.currentTarget.classList.remove("bg-muted");const H=parseInt(w.dataTransfer.getData("text/plain"));if(H===R)return;const I=[...S],[K]=I.splice(H,1);I.splice(R,0,K),p(I)},E=async()=>{if(!u){o(!0);return}Qt.sort(S.map(w=>w.id)).then(()=>{A.success("排序保存成功"),o(!1),_()}).finally(()=>{o(!1)})},g=ss({data:S??[],columns:Ou(_),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:c,pagination:k},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:h,onPaginationChange:C,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(xs,{table:g,toolbar:w=>e.jsx(Mu,{table:w,refetch:_,saveOrder:E,isSortMode:u}),draggable:u,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:!u})})}function $u(){const{t:s}=V("notice");return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsx(ns,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(zu,{})})]})]})}const Au=Object.freeze(Object.defineProperty({__proto__:null,default:$u},Symbol.toStringTag,{value:"Module"})),qu=x.object({id:x.number().nullable(),language:x.string().max(250),category:x.string().max(250),title:x.string().min(1).max(250),body:x.string().min(1),show:x.boolean()}),Hu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Zl({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Hu}){const{t:a}=V("knowledge"),[i,l]=m.useState(!1),d=we({resolver:Ce(qu),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new Tn({html:!0});return m.useEffect(()=>{i&&r.id&&Ct.getInfo(r.id).then(({data:o})=>{d.reset(o)})},[r.id,d,i]),e.jsxs(ge,{onOpenChange:l,open:i,children:[e.jsx(as,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(de,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...d,children:[e.jsx(b,{control:d.control,name:"title",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(N,{children:e.jsx(D,{placeholder:a("form.titlePlaceholder"),...o})})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"category",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(N,{children:e.jsx(D,{placeholder:a("form.categoryPlaceholder"),...o})})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"language",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.language")}),e.jsx(N,{children:e.jsxs(J,{value:o.value,onValueChange:o.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.languagePlaceholder")})}),e.jsx(Y,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(c=>e.jsx($,{value:c.value,className:"cursor-pointer",children:a(`languages.${c.value}`)},c.value))})]})})]})}),e.jsx(b,{control:d.control,name:"body",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.content")}),e.jsx(N,{children:e.jsx(Dn,{style:{height:"500px"},value:o.value,renderHTML:c=>u.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(L,{})]})}),e.jsx(b,{control:d.control,name:"show",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(N,{children:e.jsx(Z,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(L,{})]})}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{d.handleSubmit(o=>{Ct.save(o).then(({data:c})=>{c&&(d.reset(),A.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function Uu({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(We,{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:y("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(ot,{className:y("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function Ku({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(Zl,{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(Uu,{column:s.getColumn("category"),title:i("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const Bu=({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(Ra,{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(Z,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Ct.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(Zl,{refreshData:s,dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{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(ps,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ct.drop({id:r.original.id}).then(({data:a})=>{a&&(A.success(t("messages.operationSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ds,{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 Gu(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,o]=m.useState({"drag-handle":!1}),[c,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:k,isLoading:C,data:S}=ne({queryKey:["knowledge"],queryFn:async()=>{const{data:E}=await Ct.getList();return d(E||[]),E}});m.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const p=(E,g)=>{a&&(E.dataTransfer.setData("text/plain",g.toString()),E.currentTarget.classList.add("opacity-50"))},_=(E,g)=>{if(!a)return;E.preventDefault(),E.currentTarget.classList.remove("bg-muted");const w=parseInt(E.dataTransfer.getData("text/plain"));if(w===g)return;const R=[...l],[H]=R.splice(w,1);R.splice(g,0,H),d(R)},f=async()=>{a?Ct.sort({ids:l.map(E=>E.id)}).then(()=>{k(),i(!1),A.success("排序保存成功")}):i(!0)},T=ss({data:l,columns:Bu({refetch:k,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,onPaginationChange:h,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:T,toolbar:E=>e.jsx(Ku,{table:E,refetch:k,saveOrder:f,isSortMode:a}),draggable:a,onDragStart:p,onDragEnd:E=>E.currentTarget.classList.remove("opacity-50"),onDragOver:E=>{E.preventDefault(),E.currentTarget.classList.add("bg-muted")},onDragLeave:E=>E.currentTarget.classList.remove("bg-muted"),onDrop:_,showPagination:!a})}function Wu(){const{t:s}=V("knowledge");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Gu,{})})]})]})}const Yu=Object.freeze(Object.defineProperty({__proto__:null,default:Wu},Symbol.toStringTag,{value:"Module"}));function Ju(s,n){const[t,r]=m.useState(s);return m.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function nn(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 Qu(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 Xu(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 ei=m.forwardRef(({className:s,...n},t)=>Gc(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);ei.displayName="CommandEmpty";const kt=m.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:u,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:c,hidePlaceholderWhenSelected:h,disabled:k,groupBy:C,className:S,badgeClassName:p,selectFirstItem:_=!0,creatable:f=!1,triggerSearchOnFocus:T=!1,commandProps:E,inputProps:g,hideClearAllButton:w=!1},R)=>{const H=m.useRef(null),[I,K]=m.useState(!1),ae=m.useRef(!1),[ee,te]=m.useState(!1),[q,F]=m.useState(s||[]),[X,ys]=m.useState(nn(r,C)),[De,ie]=m.useState(""),Ns=Ju(De,i||500);m.useImperativeHandle(R,()=>({selectedValue:[...q],input:H.current,focus:()=>H.current?.focus()}),[q]);const Fs=m.useCallback(se=>{const pe=q.filter(re=>re.value!==se.value);F(pe),n?.(pe)},[n,q]),Xs=m.useCallback(se=>{const pe=H.current;pe&&((se.key==="Delete"||se.key==="Backspace")&&pe.value===""&&q.length>0&&(q[q.length-1].fixed||Fs(q[q.length-1])),se.key==="Escape"&&pe.blur())},[Fs,q]);m.useEffect(()=>{s&&F(s)},[s]),m.useEffect(()=>{if(!a||l)return;const se=nn(a||[],C);JSON.stringify(se)!==JSON.stringify(X)&&ys(se)},[r,a,C,l,X]),m.useEffect(()=>{const se=async()=>{te(!0);const re=await l?.(Ns);ys(nn(re||[],C)),te(!1)};(async()=>{!l||!I||(T&&await se(),Ns&&await se())})()},[Ns,C,I,T]);const Lt=()=>{if(!f||Xu(X,[{value:De,label:De}])||q.find(pe=>pe.value===De))return;const se=e.jsx(We,{value:De,className:"cursor-pointer",onMouseDown:pe=>{pe.preventDefault(),pe.stopPropagation()},onSelect:pe=>{if(q.length>=o){c?.(q.length);return}ie("");const re=[...q,{value:pe,label:pe}];F(re),n?.(re)},children:`Create "${De}"`});if(!l&&De.length>0||l&&Ns.length>0&&!ee)return se},Zt=m.useCallback(()=>{if(u)return l&&!f&&Object.keys(X).length===0?e.jsx(We,{value:"-",disabled:!0,children:u}):e.jsx(ei,{children:u})},[f,u,l,X]),Et=m.useMemo(()=>Qu(X,q),[X,q]),qs=m.useCallback(()=>{if(E?.filter)return E.filter;if(f)return(se,pe)=>se.toLowerCase().includes(pe.toLowerCase())?1:-1},[f,E?.filter]),Ja=m.useCallback(()=>{const se=q.filter(pe=>pe.fixed);F(se),n?.(se)},[n,q]);return e.jsxs(Js,{...E,onKeyDown:se=>{Xs(se),E?.onKeyDown?.(se)},className:y("h-auto overflow-visible bg-transparent",E?.className),shouldFilter:E?.shouldFilter!==void 0?E.shouldFilter:!l,filter:qs(),children:[e.jsx("div",{className:y("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":q.length!==0,"cursor-text":!k&&q.length!==0},S),onClick:()=>{k||H.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[q.map(se=>e.jsxs(U,{className:y("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",p),"data-fixed":se.fixed,"data-disabled":k||void 0,children:[se.label,e.jsx("button",{className:y("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(k||se.fixed)&&"hidden"),onKeyDown:pe=>{pe.key==="Enter"&&Fs(se)},onMouseDown:pe=>{pe.preventDefault(),pe.stopPropagation()},onClick:()=>Fs(se),children:e.jsx(hn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},se.value)),e.jsx(es.Input,{...g,ref:H,value:De,disabled:k,onValueChange:se=>{ie(se),g?.onValueChange?.(se)},onBlur:se=>{ae.current===!1&&K(!1),g?.onBlur?.(se)},onFocus:se=>{K(!0),T&&l?.(Ns),g?.onFocus?.(se)},placeholder:h&&q.length!==0?"":t,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":q.length===0,"ml-1":q.length!==0},g?.className)}),e.jsx("button",{type:"button",onClick:Ja,className:y((w||k||q.length<1||q.filter(se=>se.fixed).length===q.length)&&"hidden"),children:e.jsx(hn,{})})]})}),e.jsx("div",{className:"relative",children:I&&e.jsx(Qs,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{ae.current=!1},onMouseEnter:()=>{ae.current=!0},onMouseUp:()=>{H.current?.focus()},children:ee?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Zt(),Lt(),!_&&e.jsx(We,{value:"-",className:"hidden"}),Object.entries(Et).map(([se,pe])=>e.jsx(fs,{heading:se,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:pe.map(re=>e.jsx(We,{value:re.value,disabled:re.disable,onMouseDown:Zs=>{Zs.preventDefault(),Zs.stopPropagation()},onSelect:()=>{if(q.length>=o){c?.(q.length);return}ie("");const Zs=[...q,re];F(Zs),n?.(Zs)},className:y("cursor-pointer",re.disable&&"cursor-default text-muted-foreground"),children:re.label},re.value))})},se))]})})})]})});kt.displayName="MultipleSelector";const Zu=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function Ka({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),i=we({resolver:Ce(Zu(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1),[u,o]=m.useState(!1),c=async h=>{o(!0),mt.save(h).then(()=>{A.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{o(!1)})};return e.jsxs(ge,{open:l,onOpenChange:d,children:[e.jsx(as,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ve,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(Se,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(b,{control:i.control,name:"name",render:({field:h})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.name")}),e.jsx(N,{children:e.jsx(D,{placeholder:a("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(O,{children:a("form.nameDescription")}),e.jsx(L,{})]})}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(Gs,{asChild:!0,children:e.jsx(P,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(P,{type:"submit",disabled:u||!i.formState.isValid,children:[u&&e.jsx(ya,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const si=m.createContext(void 0);function ex({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),[l,d]=m.useState(oe.Shadowsocks);return e.jsx(si.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function ti(){const s=m.useContext(si);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function rn({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,u]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,c]=m.useState(null),h=f=>{if(!f)return null;try{const T=JSON.parse(f);return typeof T!="object"||T===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},k={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:{}}}}}},C=()=>{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[]}},S=()=>{const f=h(d||"");if(f){A.error(f);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{A.error(a("network_settings.errors.save_failed"))}},p=f=>{u(f),c(h(f))},_=f=>{const T=k[f];if(T){const E=JSON.stringify(T.content,null,2);u(E),c(null)}};return m.useEffect(()=>{i&&console.log(n)},[i,n]),m.useEffect(()=>{i&&n&&Object.keys(n).length>0&&u(JSON.stringify(n,null,2))},[i,n]),e.jsxs(ge,{open:i,onOpenChange:f=>{!f&&i&&S(),l(f)},children:[e.jsx(as,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[C().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:C().map(f=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>_(f),children:a("network_settings.use_template",{template:k[f].label})},f))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ds,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:C().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:f=>p(f.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(G,{onClick:S,disabled:!!o,children:a("common.confirm")})]})]})]})}function Ng(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const sx={},tx=Object.freeze(Object.defineProperty({__proto__:null,default:sx},Symbol.toStringTag,{value:"Module"})),_g=cd(tx),gr=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),ax=()=>{try{const s=Wc.box.keyPair(),n=gr(tr.encodeBase64(s.secretKey)),t=gr(tr.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},nx=()=>{try{return ax()}catch(s){throw console.error("Error generating key pair:",s),s}},rx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},lx=()=>{const s=Math.floor(Math.random()*8)*2+2;return rx(s)},ix=x.object({cipher:x.string().default("aes-128-gcm"),plugin:x.string().optional().default(""),plugin_opts:x.string().optional().default(""),client_fingerprint:x.string().optional().default("chrome")}),ox=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),cx=x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),dx=x.object({version:x.coerce.number().default(2),alpn:x.string().default("h2"),obfs:x.object({open:x.coerce.boolean().default(!1),type:x.string().default("salamander"),password:x.string().default("")}).default({}),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),bandwidth:x.object({up:x.string().default(""),down:x.string().default("")}).default({}),hop_interval:x.number().optional(),port_range:x.string().optional()}),mx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),reality_settings:x.object({server_port:x.coerce.number().default(443),server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),public_key:x.string().default(""),private_key:x.string().default(""),short_id:x.string().default("")}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({}),flow:x.string().default("")}),ux=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),xx=x.object({}),hx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),gx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),fx=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),px=x.object({padding_scheme:x.array(x.string()).optional().default([]),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),Re={shadowsocks:{schema:ix,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"],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:ox,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:cx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:dx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:mx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:ux,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:xx},naive:{schema:gx},http:{schema:hx},mieru:{schema:fx,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:px,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"]}},jx=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Re[s]:null,i=a?.schema||x.record(x.any()),l=s?i.parse({}):{},d=we({resolver:Ce(i),defaultValues:l,mode:"onChange"});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(w=>{t(w)});return()=>g.unsubscribe()},[d,t]),!s||!a)return null;const E={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"cipher",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.shadowsocks.ciphers.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})}),e.jsx(b,{control:d.control,name:"plugin",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.plugin.label","插件")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:w=>g.onChange(w==="none"?"":w),value:g.value===""?"none":g.value||"none",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.plugin.placeholder","选择插件")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.shadowsocks.plugins.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})}),e.jsx(O,{children:g.value&&g.value!=="none"&&g.value!==""&&e.jsxs(e.Fragment,{children:[g.value==="obfs"&&r("dynamic_form.shadowsocks.plugin.obfs_hint","提示:配置格式如 obfs=http;obfs-host=www.bing.com;path=/"),g.value==="v2ray-plugin"&&r("dynamic_form.shadowsocks.plugin.v2ray_hint","提示:WebSocket模式格式为 mode=websocket;host=mydomain.me;path=/;tls=true,QUIC模式格式为 mode=quic;host=mydomain.me")]})})]})}),d.watch("plugin")&&d.watch("plugin")!=="none"&&d.watch("plugin")!==""&&e.jsx(b,{control:d.control,name:"plugin_opts",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.plugin_opts.label","插件选项")}),e.jsx(O,{children:r("dynamic_form.shadowsocks.plugin_opts.description","按照 key=value;key2=value2 格式输入插件选项")}),e.jsx(N,{children:e.jsx(D,{type:"text",placeholder:r("dynamic_form.shadowsocks.plugin_opts.placeholder","例如: mode=tls;host=bing.com"),...g})})]})}),(d.watch("plugin")==="shadow-tls"||d.watch("plugin")==="restls")&&e.jsx(b,{control:d.control,name:"client_fingerprint",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.shadowsocks.client_fingerprint","客户端指纹")}),e.jsx(N,{children:e.jsxs(J,{value:g.value||"chrome",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.client_fingerprint_placeholder","选择客户端指纹")})}),e.jsx(Y,{children:Re.shadowsocks.clientFingerprints.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})]})}),e.jsx(O,{children:r("dynamic_form.shadowsocks.client_fingerprint_description","客户端伪装指纹,用于降低被识别风险")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx($,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"network",render:({field:g})=>e.jsxs(j,{children:[e.jsxs(v,{children:[r("dynamic_form.vmess.network.label"),e.jsx(rn,{value:d.watch("network_settings"),setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")})]}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.vmess.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(b,{control:d.control,name:"allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"network",render:({field:g})=>e.jsxs(j,{children:[e.jsxs(v,{children:[r("dynamic_form.trojan.network.label"),e.jsx(rn,{value:d.watch("network_settings")||{},setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")||"tcp"})]}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value||"tcp",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.trojan.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"version",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(N,{children:e.jsxs(J,{value:(g.value||2).toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.hysteria.versions.map(w=>e.jsxs($,{value:w,className:"cursor-pointer",children:["V",w]},w))})})]})})]})}),d.watch("version")==1&&e.jsx(b,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value||"h2",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.hysteria.alpnOptions.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"obfs.open",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(b,{control:d.control,name:"obfs.type",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value||"salamander",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:e.jsx($,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(b,{control:d.control,name:"obfs.password",render:({field:g})=>e.jsxs(j,{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(N,{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 w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",R=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(H=>w[H%w.length]).join("");d.setValue("obfs.password",R),A.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Be,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(b,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"bandwidth.up",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{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(b,{control:d.control,name:"bandwidth.down",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{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(b,{control:d.control,name:"hop_interval",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...g,value:g.value||"",onChange:w=>{const R=w.target.value?parseInt(w.target.value):void 0;g.onChange(R)}})}),e.jsx(O,{children:r("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vless.tls.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx($,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx($,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{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(b,{control:d.control,name:"reality_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"reality_settings.server_port",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"reality_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(b,{control:d.control,name:"reality_settings.private_key",render:({field:g})=>e.jsxs(j,{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(N,{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 w=nx();d.setValue("reality_settings.private_key",w.privateKey),d.setValue("reality_settings.public_key",w.publicKey),A.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Be,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Na,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(b,{control:d.control,name:"reality_settings.public_key",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(N,{children:e.jsx(D,{...g})})]})}),e.jsx(b,{control:d.control,name:"reality_settings.short_id",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{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 w=lx();d.setValue("reality_settings.short_id",w),A.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Be,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Na,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(O,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(b,{control:d.control,name:"network",render:({field:g})=>e.jsxs(j,{children:[e.jsxs(v,{children:[r("dynamic_form.vless.network.label"),e.jsx(rn,{value:d.watch("network_settings"),setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")})]}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.vless.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})}),e.jsx(b,{control:d.control,name:"flow",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.vless.flow.label")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:w=>g.onChange(w==="none"?null:w),value:g.value||"none",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(Y,{children:Re.vless.flowOptions.map(w=>e.jsx($,{value:w,children:w},w))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"version",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.tuic.version.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.tuic.versions.map(w=>e.jsxs($,{value:w,children:["V",w]},w))})})]})})]})}),e.jsx(b,{control:d.control,name:"congestion_control",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.tuic.congestionControls.map(w=>e.jsx($,{value:w,children:w.toUpperCase()},w))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(N,{children:e.jsx(kt,{options:Re.tuic.alpnOptions,onChange:w=>g.onChange(w.map(R=>R.value)),value:Re.tuic.alpnOptions.filter(w=>g.value?.includes(w.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(b,{control:d.control,name:"udp_relay_mode",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.tuic.udpRelayModes.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.naive.tls.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx($,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.http.tls.label")}),e.jsx(N,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx($,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"transport",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.mieru.transportOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})}),e.jsx(b,{control:d.control,name:"multiplexing",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(N,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Re.mieru.multiplexingOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:d.control,name:"padding_scheme",render:({field:g})=>e.jsxs(j,{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",Re.anytls.defaultPaddingScheme),A.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(O,{children:r("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(N,{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);o.onChange(h),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(O,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:a.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.recaptcha.key.description")}),e.jsx(E,{})]})})]}),e.jsx(v,{control:a.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(O,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:a.control,name:"register_limit_count",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.registerLimit.count.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(E,{})]})})]}),e.jsx(v,{control:a.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(O,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:a.control,name:"password_limit_count",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(O,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(E,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function Om(){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(Te,{}),e.jsx(Mm,{})]})}const zm=Object.freeze(Object.defineProperty({__proto__:null,default:Om},Symbol.toStringTag,{value:"Module"})),$m=x.object({plan_change_enable:x.boolean().nullable().default(!1),reset_traffic_method:x.coerce.number().nullable().default(0),surplus_enable:x.boolean().nullable().default(!1),new_order_event_id:x.coerce.number().nullable().default(0),renew_order_event_id:x.coerce.number().nullable().default(0),change_order_event_id:x.coerce.number().nullable().default(0),show_info_to_server_enable:x.boolean().nullable().default(!1),show_protocol_to_server_enable:x.boolean().nullable().default(!1),default_remind_expire:x.boolean().nullable().default(!1),default_remind_traffic:x.boolean().nullable().default(!1),subscribe_path:x.string().nullable().default("s")}),Am={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 qm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce($m),defaultValues:Am,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","subscribe"],queryFn:()=>he.getSettings("subscribe")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.subscribe){const o=i?.data?.subscribe;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(O,{children:s("subscribe.plan_change_enable.description")}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择重置方式"})})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx($,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx($,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx($,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx($,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(O,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"surplus_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(O,{children:s("subscribe.surplus_enable.description")}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.new_order_event.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.renew_order_event.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(y,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(O,{children:s("subscribe.change_order_event.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"subscribe_path",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:"subscribe",...o,value:o.value||"",onChange:c=>{o.onChange(c),u(a.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:o.value||"s"})]}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(O,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(O,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value||!1,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Hm(){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(Te,{}),e.jsx(qm,{})]})}const Um=Object.freeze(Object.defineProperty({__proto__:null,default:Hm},Symbol.toStringTag,{value:"Module"})),Km=x.object({invite_force:x.boolean().default(!1),invite_commission:x.coerce.string().default("0"),invite_gen_limit:x.coerce.string().default("0"),invite_never_expire:x.boolean().default(!1),commission_first_time_enable:x.boolean().default(!1),commission_auto_check_enable:x.boolean().default(!1),commission_withdraw_limit:x.coerce.string().default("0"),commission_withdraw_method:x.array(x.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:x.boolean().default(!1),commission_distribution_enable:x.boolean().default(!1),commission_distribution_l1:x.coerce.number().default(0),commission_distribution_l2:x.coerce.number().default(0),commission_distribution_l3:x.coerce.number().default(0)}),Bm={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 Gm(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(Km),defaultValues:Bm,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","invite"],queryFn:()=>he.getSettings("invite")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.invite){const o=i?.data?.invite;Object.entries(o).forEach(([c,h])=>{typeof h=="number"?a.setValue(c,String(h)):a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"invite_force",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(O,{children:s("invite.invite_force.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"invite_commission",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("invite.invite_commission.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("invite.invite_gen_limit.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(O,{children:s("invite.invite_never_expire.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(O,{children:s("invite.commission_first_time.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(O,{children:s("invite.commission_auto_check.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("invite.commission_withdraw_method.placeholder"),...o,value:Array.isArray(o.value)?o.value.join(","):"",onChange:c=>{const h=c.target.value.split(",").filter(Boolean);o.onChange(h),u(a.getValues())}})}),e.jsx(O,{children:s("invite.commission_withdraw_method.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(O,{children:s("invite.withdraw_close.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(O,{children:s("invite.commission_distribution.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>{o.onChange(c),u(a.getValues())}})})]})}),a.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:a.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:s("invite.commission_distribution.l1")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),u(a.getValues())}})}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:s("invite.commission_distribution.l2")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),u(a.getValues())}})}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:s("invite.commission_distribution.l3")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:c=>{const h=c.target.value?Number(c.target.value):0;o.onChange(h),u(a.getValues())}})}),e.jsx(E,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function Wm(){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(Te,{}),e.jsx(Gm,{})]})}const Ym=Object.freeze(Object.defineProperty({__proto__:null,default:Wm},Symbol.toStringTag,{value:"Module"})),Jm=x.object({frontend_theme:x.string().nullable(),frontend_theme_sidebar:x.string().nullable(),frontend_theme_header:x.string().nullable(),frontend_theme_color:x.string().nullable(),frontend_background_url:x.string().url().nullable()}),Qm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Xm(){const{data:s}=ne({queryKey:["settings","frontend"],queryFn:()=>he.getSettings("frontend")}),n=we({resolver:Ce(Jm),defaultValues:Qm,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){he.saveSettings(r).then(({data:a})=>{a&&A.success("更新成功")})}return e.jsx(Se,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(v,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"边栏风格"}),e.jsx(O,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Z,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(v,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:"头部风格"}),e.jsx(O,{children:"边栏风格"})]}),e.jsx(y,{children:e.jsx(Z,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(v,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(p,{children:[e.jsx(j,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(y,{children:e.jsxs("select",{className:b(Tt({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(Sn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(O,{children:"主题色"}),e.jsx(E,{})]})}),e.jsx(v,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(p,{children:[e.jsx(j,{children:"背景"}),e.jsx(y,{children:e.jsx(P,{placeholder:"请输入图片地址",...r})}),e.jsx(O,{children:"将会在后台登录页面进行展示。"}),e.jsx(E,{})]})}),e.jsx(L,{type:"submit",children:"保存设置"})]})})}function Zm(){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(Te,{}),e.jsx(Xm,{})]})}const eu=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"})),su=x.object({server_pull_interval:x.coerce.number().nullable(),server_push_interval:x.coerce.number().nullable(),server_token:x.string().nullable(),device_limit_mode:x.coerce.number().nullable()}),tu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function au(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(su),defaultValues:tu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","server"],queryFn:()=>he.getSettings("server")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:c=>{c.data&&A.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(i?.data.server){const c=i.data.server;Object.entries(c).forEach(([h,k])=>{a.setValue(h,k)}),r.current=c}},[i]);const d=m.useCallback(ke.debounce(async c=>{if(!ke.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),u=m.useCallback(c=>{d(c)},[d]);m.useEffect(()=>{const c=a.watch(h=>{u(h)});return()=>c.unsubscribe()},[a.watch,u]);const o=()=>{const c=Math.floor(Math.random()*17)+16,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let k="";for(let C=0;Ce.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("server.server_token.title")}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(P,{placeholder:s("server.server_token.placeholder"),...c,value:c.value||"",className:"pr-10"}),e.jsx(be,{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:h=>{h.preventDefault(),o()},children:e.jsx(Ec,{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(O,{children:s("server.server_token.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"server_pull_interval",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const k=h.target.value?Number(h.target.value):null;c.onChange(k)}})}),e.jsx(O,{children:s("server.server_pull_interval.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"server_push_interval",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...c,value:c.value||"",onChange:h=>{const k=h.target.value?Number(h.target.value):null;c.onChange(k)}})}),e.jsx(O,{children:s("server.server_push_interval.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"device_limit_mode",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(J,{onValueChange:c.onChange,value:c.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx($,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(O,{children:s("server.device_limit_mode.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.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("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(Te,{}),e.jsx(au,{})]})}const ru=Object.freeze(Object.defineProperty({__proto__:null,default:nu},Symbol.toStringTag,{value:"Module"}));function lu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(ol,{className:"h-5 w-5 text-green-500"}):e.jsx(cl,{className:"h-5 w-5 text-destructive"}),e.jsx(fe,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ve,{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(lt,{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 iu=x.object({email_template:x.string().nullable().default("classic"),email_host:x.string().nullable().default(""),email_port:x.coerce.number().nullable().default(465),email_username:x.string().nullable().default(""),email_password:x.string().nullable().default(""),email_encryption:x.string().nullable().default(""),email_from_address:x.string().email().nullable().default(""),remind_mail_enable:x.boolean().nullable().default(!1)});function ou(){const{t:s}=V("settings"),[n,t]=m.useState(null),[r,a]=m.useState(!1),i=m.useRef(null),[l,d]=m.useState(!1),u=we({resolver:Ce(iu),defaultValues:{},mode:"onBlur"}),{data:o}=ne({queryKey:["settings","email"],queryFn:()=>he.getSettings("email")}),{data:c}=ne({queryKey:["emailTemplate"],queryFn:()=>he.getEmailTemplate()}),{mutateAsync:h}=Ts({mutationFn:he.saveSettings,onSuccess:N=>{N.data&&A.success(s("common.autoSaved"))}}),{mutate:k,isPending:C}=Ts({mutationFn:he.sendTestMail,onMutate:()=>{t(null),a(!1)},onSuccess:N=>{t(N.data),a(!0),N.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});m.useEffect(()=>{if(o?.data.email){const N=o.data.email;Object.entries(N).forEach(([_,T])=>{u.setValue(_,T)}),i.current=N}},[o]);const S=m.useCallback(ke.debounce(async N=>{if(!ke.isEqual(N,i.current)){d(!0);try{await h(N),i.current=N}finally{d(!1)}}},1e3),[h]),f=m.useCallback(N=>{S(N)},[S]);return m.useEffect(()=>{const N=u.watch(_=>{f(_)});return()=>N.unsubscribe()},[u.watch,f]),e.jsxs(e.Fragment,{children:[e.jsx(Se,{...u,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"email_host",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_host.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(O,{children:s("email.email_host.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"email_port",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_port.title")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:s("common.placeholder"),...N,value:N.value||"",onChange:_=>{const T=_.target.value?Number(_.target.value):null;N.onChange(T)}})}),e.jsx(O,{children:s("email.email_port.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"email_encryption",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(J,{onValueChange:_=>{const T=_==="none"?"":_;N.onChange(T)},value:N.value===""||N.value===null||N.value===void 0?"none":N.value,children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择加密方式"})})}),e.jsxs(Y,{children:[e.jsx($,{value:"none",children:s("email.email_encryption.none")}),e.jsx($,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx($,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(O,{children:s("email.email_encryption.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"email_username",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_username.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(O,{children:s("email.email_username.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"email_password",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_password.title")}),e.jsx(y,{children:e.jsx(P,{type:"password",placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(O,{children:s("email.email_password.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"email_from_address",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_from.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...N,value:N.value||""})}),e.jsx(O,{children:s("email.email_from.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"email_template",render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(J,{onValueChange:_=>{N.onChange(_),f(u.getValues())},value:N.value||void 0,children:[e.jsx(y,{children:e.jsx(W,{className:"w-[200px]",children:e.jsx(Q,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(Y,{children:c?.data?.map(_=>e.jsx($,{value:_,children:_},_))})]}),e.jsx(O,{children:s("email.email_template.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"remind_mail_enable",render:({field:N})=>e.jsxs(p,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(O,{children:s("email.remind_mail.description")})]}),e.jsx(y,{children:e.jsx(Z,{checked:N.value||!1,onCheckedChange:_=>{N.onChange(_),f(u.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(L,{onClick:()=>k(),loading:C,disabled:C,children:s(C?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(lu,{open:r,onOpenChange:a,result:n})]})}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("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(Te,{}),e.jsx(ou,{})]})}const du=Object.freeze(Object.defineProperty({__proto__:null,default:cu},Symbol.toStringTag,{value:"Module"})),mu=x.object({telegram_bot_enable:x.boolean().nullable(),telegram_bot_token:x.string().nullable(),telegram_discuss_link:x.string().nullable()}),uu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function xu(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(mu),defaultValues:uu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","telegram"],queryFn:()=>he.getSettings("telegram")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:h=>{h.data&&A.success(s("common.autoSaved"))}}),{mutate:d,isPending:u}=Ts({mutationFn:he.setTelegramWebhook,onSuccess:h=>{h.data&&A.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(i?.data.telegram){const h=i.data.telegram;Object.entries(h).forEach(([k,C])=>{a.setValue(k,C)}),r.current=h}},[i]);const o=m.useCallback(ke.debounce(async h=>{if(!ke.isEqual(h,r.current)){t(!0);try{await l(h),r.current=h}finally{t(!1)}}},1e3),[l]),c=m.useCallback(h=>{o(h)},[o]);return m.useEffect(()=>{const h=a.watch(k=>{c(k)});return()=>h.unsubscribe()},[a.watch,c]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"telegram_bot_token",render:({field:h})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("telegram.bot_token.placeholder"),...h,value:h.value||""})}),e.jsx(O,{children:s("telegram.bot_token.description")}),e.jsx(E,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(L,{loading:u,disabled:u,onClick:()=>d(),children:s(u?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(O,{children:s("telegram.webhook.description")}),e.jsx(E,{})]}),e.jsx(v,{control:a.control,name:"telegram_bot_enable",render:({field:h})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(O,{children:s("telegram.bot_enable.description")}),e.jsx(y,{children:e.jsx(Z,{checked:h.value||!1,onCheckedChange:k=>{h.onChange(k),c(a.getValues())}})}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"telegram_discuss_link",render:({field:h})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("telegram.discuss_link.placeholder"),...h,value:h.value||""})}),e.jsx(O,{children:s("telegram.discuss_link.description")}),e.jsx(E,{})]})}),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("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(Te,{}),e.jsx(xu,{})]})}const gu=Object.freeze(Object.defineProperty({__proto__:null,default:hu},Symbol.toStringTag,{value:"Module"})),fu=x.object({windows_version:x.string().nullable(),windows_download_url:x.string().nullable(),macos_version:x.string().nullable(),macos_download_url:x.string().nullable(),android_version:x.string().nullable(),android_download_url:x.string().nullable()}),pu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function ju(){const{t:s}=V("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Ce(fu),defaultValues:pu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","app"],queryFn:()=>he.getSettings("app")}),{mutateAsync:l}=Ts({mutationFn:he.saveSettings,onSuccess:o=>{o.data&&A.success(s("app.save_success"))}});m.useEffect(()=>{if(i?.data.app){const o=i.data.app;Object.entries(o).forEach(([c,h])=>{a.setValue(c,h)}),r.current=o}},[i]);const d=m.useCallback(ke.debounce(async o=>{if(!ke.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);return m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]),e.jsx(Se,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"windows_version",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.windows.version.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"windows_download_url",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.windows.download.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"macos_version",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.macos.version.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"macos_download_url",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.macos.download.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"android_version",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("app.android.version.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.android.version.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"android_download_url",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{className:"text-base",children:s("app.android.download.title")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(O,{children:s("app.android.download.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.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("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(Te,{}),e.jsx(ju,{})]})}const bu=Object.freeze(Object.defineProperty({__proto__:null,default:vu},Symbol.toStringTag,{value:"Module"})),yu=s=>x.object({id:x.number().nullable(),name:x.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:x.string().optional().nullable(),notify_domain:x.string().refine(t=>!t||/^https?:\/\/\S+/.test(t),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:x.coerce.number().min(0).optional().nullable(),handling_fee_percent:x.coerce.number().min(0).max(100).optional().nullable(),payment:x.string().min(1,s("form.validation.payment.required")),config:x.record(x.string(),x.string())}),xr={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function Wl({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=xr}){const{t:a}=V("payment"),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[o,c]=m.useState([]),[h,k]=m.useState([]),C=yu(a),S=we({resolver:Ce(C),defaultValues:r,mode:"onChange"}),f=S.watch("payment");m.useEffect(()=>{i&&(async()=>{const{data:T}=await nt.getMethodList();c(T)})()},[i]),m.useEffect(()=>{if(!f||!i)return;(async()=>{const T={payment:f,...t==="edit"&&{id:Number(S.getValues("id"))}};nt.getMethodForm(T).then(({data:D})=>{k(D);const g=D.reduce((w,R)=>(R.field_name&&(w[R.field_name]=R.value??""),w),{});S.setValue("config",g)})})()},[f,i,S,t]);const N=async _=>{u(!0);try{(await nt.save(_)).data&&(A.success(a("form.messages.success")),S.reset(xr),s(),l(!1))}finally{u(!1)}};return e.jsxs(ge,{open:i,onOpenChange:l,children:[e.jsx(as,{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(de,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(Se,{...S,children:e.jsxs("form",{onSubmit:S.handleSubmit(N),className:"space-y-4",children:[e.jsx(v,{control:S.control,name:"name",render:({field:_})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:a("form.fields.name.placeholder"),..._})}),e.jsx(O,{children:a("form.fields.name.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:S.control,name:"icon",render:({field:_})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.icon.label")}),e.jsx(y,{children:e.jsx(P,{..._,value:_.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(O,{children:a("form.fields.icon.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:S.control,name:"notify_domain",render:({field:_})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.notify_domain.label")}),e.jsx(y,{children:e.jsx(P,{..._,value:_.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(O,{children:a("form.fields.notify_domain.description")}),e.jsx(E,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:S.control,name:"handling_fee_percent",render:({field:_})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(y,{children:e.jsx(P,{type:"number",..._,value:_.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(E,{})]})}),e.jsx(v,{control:S.control,name:"handling_fee_fixed",render:({field:_})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(y,{children:e.jsx(P,{type:"number",..._,value:_.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(E,{})]})})]}),e.jsx(v,{control:S.control,name:"payment",render:({field:_})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.payment.label")}),e.jsxs(J,{onValueChange:_.onChange,defaultValue:_.value,children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(Y,{children:o.map(T=>e.jsx($,{value:T,children:T},T))})]}),e.jsx(O,{children:a("form.fields.payment.description")}),e.jsx(E,{})]})}),h.length>0&&e.jsx("div",{className:"space-y-4",children:h.map(_=>e.jsx(v,{control:S.control,name:`config.${_.field_name}`,render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:_.label}),e.jsx(y,{children:e.jsx(P,{...T,value:T.value||""})}),e.jsx(E,{})]})},_.field_name))}),e.jsxs(Le,{children:[e.jsx(Gs,{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:b("-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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(sr,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ce,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(dn,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(mn,{className:"h-4 w-4 text-foreground/70"}):e.jsx(Fc,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:b("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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(sr,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ce,{children:t})]})})]})}const On=Ic,Yl=Vc,Nu=Mc,Jl=m.forwardRef(({className:s,...n},t)=>e.jsx(ml,{className:b("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}));Jl.displayName=ml.displayName;const Oa=m.forwardRef(({className:s,...n},t)=>e.jsxs(Nu,{children:[e.jsx(Jl,{}),e.jsx(ul,{ref:t,className:b("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})]}));Oa.displayName=ul.displayName;const za=({className:s,...n})=>e.jsx("div",{className:b("flex flex-col space-y-2 text-center sm:text-left",s),...n});za.displayName="AlertDialogHeader";const $a=({className:s,...n})=>e.jsx("div",{className:b("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});$a.displayName="AlertDialogFooter";const Aa=m.forwardRef(({className:s,...n},t)=>e.jsx(xl,{ref:t,className:b("text-lg font-semibold",s),...n}));Aa.displayName=xl.displayName;const qa=m.forwardRef(({className:s,...n},t)=>e.jsx(hl,{ref:t,className:b("text-sm text-muted-foreground",s),...n}));qa.displayName=hl.displayName;const Ha=m.forwardRef(({className:s,...n},t)=>e.jsx(gl,{ref:t,className:b(St(),s),...n}));Ha.displayName=gl.displayName;const Ua=m.forwardRef(({className:s,...n},t)=>e.jsx(fl,{ref:t,className:b(St({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Ua.displayName=fl.displayName;function ps({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(On,{children:[e.jsx(Yl,{asChild:!0,children:n}),e.jsxs(Oa,{className:b("sm:max-w-[425px]",d),children:[e.jsxs(za,{children:[e.jsx(Aa,{children:t}),e.jsx(qa,{children:r})]}),e.jsxs($a,{children:[e.jsx(Ua,{asChild:!0,children:e.jsx(L,{variant:"outline",children:a})}),e.jsx(Ha,{asChild:!0,children:e.jsx(L,{variant:l,onClick:s,children:i})})]})]})]})}const Ql=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"})}),_u=({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(Ea,{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(Z,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await nt.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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{className:"ml-1",children:e.jsx(Ql,{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(Wl,{refetch:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{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(ps,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await nt.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(ds,{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 wu({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(Wl,{refetch:n}),e.jsx(P,{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(ms,{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 Cu(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,o]=m.useState({"drag-handle":!1}),[c,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:k}=ne({queryKey:["paymentList"],queryFn:async()=>{const{data:_}=await nt.getList();return d(_?.map(T=>({...T,enable:!!T.enable}))||[]),_}});m.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const C=(_,T)=>{a&&(_.dataTransfer.setData("text/plain",T.toString()),_.currentTarget.classList.add("opacity-50"))},S=(_,T)=>{if(!a)return;_.preventDefault(),_.currentTarget.classList.remove("bg-muted");const D=parseInt(_.dataTransfer.getData("text/plain"));if(D===T)return;const g=[...l],[w]=g.splice(D,1);g.splice(T,0,w),d(g)},f=async()=>{a?nt.sort({ids:l.map(_=>_.id)}).then(()=>{k(),i(!1),A.success("排序保存成功")}):i(!0)},N=ss({data:l,columns:_u({refetch:k,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(xs,{table:N,toolbar:_=>e.jsx(wu,{table:_,refetch:k,saveOrder:f,isSortMode:a}),draggable:a,onDragStart:C,onDragEnd:_=>_.currentTarget.classList.remove("opacity-50"),onDragOver:_=>{_.preventDefault(),_.currentTarget.classList.add("bg-muted")},onDragLeave:_=>_.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!a})}function Su(){const{t:s}=V("payment");return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsx(ns,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Cu,{})})]})]})}const ku=Object.freeze(Object.defineProperty({__proto__:null,default:Su},Symbol.toStringTag,{value:"Module"}));function Tu({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=V("plugin"),[a,i]=m.useState(!0),[l,d]=m.useState(!1),[u,o]=m.useState(null),c=Oc({config:zc($c())}),h=we({resolver:Ce(c),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:f}=await Ms.getPluginConfig(s);o(f),h.reset({config:Object.fromEntries(Object.entries(f).map(([N,_])=>[N,_.value]))})}catch{A.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const k=async S=>{d(!0);try{await Ms.updatePluginConfig(s,S.config),A.success(r("messages.configSaveSuccess")),t()}catch{A.error(r("messages.configSaveError"))}finally{d(!1)}},C=(S,f)=>{switch(f.type){case"string":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{children:f.label||f.description}),e.jsx(y,{children:e.jsx(P,{placeholder:f.placeholder,...N})}),f.description&&f.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:f.description}),e.jsx(E,{})]})},S);case"number":case"percentage":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{children:f.label||f.description}),e.jsx(y,{children:e.jsxs("div",{className:"relative",children:[e.jsx(P,{type:"number",placeholder:f.placeholder,...N,onChange:_=>{const T=Number(_.target.value);f.type==="percentage"?N.onChange(Math.min(100,Math.max(0,T))):N.onChange(T)},className:f.type==="percentage"?"pr-8":"",min:f.type==="percentage"?0:void 0,max:f.type==="percentage"?100:void 0,step:f.type==="percentage"?1:void 0}),f.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(Ac,{className:"h-4 w-4 text-muted-foreground"})})]})}),f.description&&f.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:f.description}),e.jsx(E,{})]})},S);case"select":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{children:f.label||f.description}),e.jsxs(J,{onValueChange:N.onChange,defaultValue:N.value,children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:f.placeholder})})}),e.jsx(Y,{children:f.options?.map(_=>e.jsx($,{value:_.value,children:_.label},_.value))})]}),f.description&&f.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:f.description}),e.jsx(E,{})]})},S);case"boolean":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(p,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(j,{className:"text-base",children:f.label||f.description}),f.description&&f.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:f.description})]}),e.jsx(y,{children:e.jsx(Z,{checked:N.value,onCheckedChange:N.onChange})})]})},S);case"text":return e.jsx(v,{control:h.control,name:`config.${S}`,render:({field:N})=>e.jsxs(p,{children:[e.jsx(j,{children:f.label||f.description}),e.jsx(y,{children:e.jsx(Ds,{placeholder:f.placeholder,...N})}),f.description&&f.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:f.description}),e.jsx(E,{})]})},S);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"})]}):e.jsx(Se,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(k),className:"space-y-4",children:[u&&Object.entries(u).map(([S,f])=>C(S,f)),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 Du(){const{t:s}=V("plugin"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(null),[d,u]=m.useState(""),[o,c]=m.useState("all"),[h,k]=m.useState(!1),[C,S]=m.useState(!1),[f,N]=m.useState(!1),_=m.useRef(null),{data:T,isLoading:D,refetch:g}=ne({queryKey:["pluginList"],queryFn:async()=>{const{data:F}=await Ms.getPluginList();return F}});T&&[...new Set(T.map(F=>F.category||"other"))];const w=T?.filter(F=>{const X=F.name.toLowerCase().includes(d.toLowerCase())||F.description.toLowerCase().includes(d.toLowerCase())||F.code.toLowerCase().includes(d.toLowerCase()),Ns=o==="all"||F.category===o;return X&&Ns}),R=async F=>{t(F),Ms.installPlugin(F).then(()=>{A.success(s("messages.installSuccess")),g()}).catch(X=>{A.error(X.message||s("messages.installError"))}).finally(()=>{t(null)})},H=async F=>{t(F),Ms.uninstallPlugin(F).then(()=>{A.success(s("messages.uninstallSuccess")),g()}).catch(X=>{A.error(X.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},I=async(F,X)=>{t(F),(X?Ms.disablePlugin:Ms.enablePlugin)(F).then(()=>{A.success(s(X?"messages.disableSuccess":"messages.enableSuccess")),g()}).catch(De=>{A.error(De.message||s(X?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},K=F=>{T?.find(X=>X.code===F),l(F),a(!0)},ae=async F=>{if(!F.name.endsWith(".zip")){A.error(s("upload.error.format"));return}k(!0),Ms.uploadPlugin(F).then(()=>{A.success(s("messages.uploadSuccess")),S(!1),g()}).catch(X=>{A.error(X.message||s("messages.uploadError"))}).finally(()=>{k(!1),_.current&&(_.current.value="")})},ee=F=>{F.preventDefault(),F.stopPropagation(),F.type==="dragenter"||F.type==="dragover"?N(!0):F.type==="dragleave"&&N(!1)},te=F=>{F.preventDefault(),F.stopPropagation(),N(!1),F.dataTransfer.files&&F.dataTransfer.files[0]&&ae(F.dataTransfer.files[0])},q=async F=>{t(F),Ms.deletePlugin(F).then(()=>{A.success(s("messages.deleteSuccess")),g()}).catch(X=>{A.error(X.message||s("messages.deleteError"))}).finally(()=>{t(null)})};return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(wn,{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(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Cn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(P,{placeholder:s("search.placeholder"),value:d,onChange:F=>u(F.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(L,{onClick:()=>S(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(wt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(Dt,{defaultValue:"all",className:"w-full",children:[e.jsxs(dt,{children:[e.jsx(Xe,{value:"all",children:s("tabs.all")}),e.jsx(Xe,{value:"installed",children:s("tabs.installed")}),e.jsx(Xe,{value:"available",children:s("tabs.available")})]}),e.jsx(ks,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:D?e.jsxs(e.Fragment,{children:[e.jsx(an,{}),e.jsx(an,{}),e.jsx(an,{})]}):w?.map(F=>e.jsx(tn,{plugin:F,onInstall:R,onUninstall:H,onToggleEnable:I,onOpenConfig:K,onDelete:q,isLoading:n===F.name},F.name))})}),e.jsx(ks,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(F=>F.is_installed).map(F=>e.jsx(tn,{plugin:F,onInstall:R,onUninstall:H,onToggleEnable:I,onOpenConfig:K,onDelete:q,isLoading:n===F.name},F.name))})}),e.jsx(ks,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:w?.filter(F=>!F.is_installed).map(F=>e.jsx(tn,{plugin:F,onInstall:R,onUninstall:H,onToggleEnable:I,onOpenConfig:K,onDelete:q,isLoading:n===F.name},F.code))})})]})]}),e.jsx(ge,{open:r,onOpenChange:a,children:e.jsxs(de,{className:"sm:max-w-lg",children:[e.jsxs(ve,{children:[e.jsxs(fe,{children:[T?.find(F=>F.code===i)?.name," ",s("config.title")]}),e.jsx(Ve,{children:s("config.description")})]}),i&&e.jsx(Tu,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),g()}})]})}),e.jsx(ge,{open:C,onOpenChange:S,children:e.jsxs(de,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:s("upload.title")}),e.jsx(Ve,{children:s("upload.description")})]}),e.jsxs("div",{className:b("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",f&&"border-primary/50 bg-muted/50"),onDragEnter:ee,onDragLeave:ee,onDragOver:ee,onDrop:te,children:[e.jsx("input",{type:"file",ref:_,className:"hidden",accept:".zip",onChange:F=>{const X=F.target.files?.[0];X&&ae(X)}}),h?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(wt,{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:()=>_.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})})]})]})}function tn({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l}){const{t:d}=V("plugin");return e.jsxs(Re,{className:"group relative overflow-hidden transition-all hover:shadow-md",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(Ge,{children:s.name}),s.is_installed&&e.jsx(U,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?d("status.enabled"):d("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(wn,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Os,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[d("author"),": ",s.author]})})]})})]}),e.jsx(Ie,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(pl,{className:"mr-2 h-4 w-4"}),d("button.config")]}),e.jsxs(L,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(qc,{className:"mr-2 h-4 w-4"}),s.is_enabled?d("button.disable"):d("button.enable")]}),e.jsx(ps,{title:d("uninstall.title"),description:d("uninstall.description"),cancelText:d("common:cancel"),confirmText:d("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(L,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(ds,{className:"mr-2 h-4 w-4"}),d("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(L,{onClick:()=>n(s.code),disabled:l,loading:l,children:d("button.install")}),e.jsx(ps,{title:d("delete.title"),description:d("delete.description"),cancelText:d("common:cancel"),confirmText:d("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(L,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(ds,{className:"h-4 w-4"})})})]})})})]})}function an(){return e.jsxs(Re,{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(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(je,{className:"h-5 w-[120px]"}),e.jsx(je,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(je,{className:"h-4 w-[300px]"}),e.jsx(je,{className:"h-4 w-[150px]"})]})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-8 w-8"})]})})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"})),Lu=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(P,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(Ds,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:b(St({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Ru({themeKey:s,themeInfo:n}){const{t}=V("theme"),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),o=we({defaultValues:n.configs.reduce((k,C)=>(k[C.field_name]="",k),{})}),c=async()=>{l(!0),Kt.getConfig(s).then(({data:k})=>{Object.entries(k).forEach(([C,S])=>{o.setValue(C,S)})}).finally(()=>{l(!1)})},h=async k=>{u(!0),Kt.updateConfig(s,k).then(()=>{A.success(t("config.success")),a(!1)}).finally(()=>{u(!1)})};return e.jsxs(ge,{open:r,onOpenChange:k=>{a(k),k?c():o.reset()},children:[e.jsx(as,{asChild:!0,children:e.jsx(L,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(de,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:t("config.title",{name:n.name})}),e.jsx(Ve,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ya,{className:"h-6 w-6 animate-spin"})}):e.jsx(Se,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(h),className:"space-y-4",children:[n.configs.map(k=>e.jsx(v,{control:o.control,name:k.field_name,render:({field:C})=>e.jsxs(p,{children:[e.jsx(j,{children:k.label}),e.jsx(y,{children:Lu(k,C)}),e.jsx(E,{})]})},k.field_name)),e.jsxs(Le,{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 Eu(){const{t:s}=V("theme"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[o,c]=m.useState(null),h=m.useRef(null),[k,C]=m.useState(0),{data:S,isLoading:f,refetch:N}=ne({queryKey:["themeList"],queryFn:async()=>{const{data:I}=await Kt.getList();return I}}),_=async I=>{t(I),he.updateSystemConfig({frontend_theme:I}).then(()=>{A.success("主题切换成功"),N()}).finally(()=>{t(null)})},T=async I=>{if(!I.name.endsWith(".zip")){A.error(s("upload.error.format"));return}a(!0),Kt.upload(I).then(()=>{A.success("主题上传成功"),l(!1),N()}).finally(()=>{a(!1),h.current&&(h.current.value="")})},D=I=>{I.preventDefault(),I.stopPropagation(),I.type==="dragenter"||I.type==="dragover"?u(!0):I.type==="dragleave"&&u(!1)},g=I=>{I.preventDefault(),I.stopPropagation(),u(!1),I.dataTransfer.files&&I.dataTransfer.files[0]&&T(I.dataTransfer.files[0])},w=()=>{o&&C(I=>I===0?o.images.length-1:I-1)},R=()=>{o&&C(I=>I===o.images.length-1?0:I+1)},H=(I,K)=>{C(0),c({name:I,images:K})};return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsx(ns,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(wt,{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:f?e.jsxs(e.Fragment,{children:[e.jsx(hr,{}),e.jsx(hr,{})]}):S?.themes&&Object.entries(S.themes).map(([I,K])=>e.jsx(Re,{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:b("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(ps,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(I===S?.active){A.error(s("card.delete.error.active"));return}t(I),Kt.drop(I).then(()=>{A.success("主题删除成功"),N()}).finally(()=>{t(null)})},children:e.jsx(L,{disabled:n===I,loading:n===I,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(ds,{className:"h-4 w-4"})})})}),e.jsxs(Fe,{children:[e.jsx(Ge,{children:K.name}),e.jsx(Os,{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(Ie,{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:()=>H(K.name,K.images),children:e.jsx(Hc,{className:"h-4 w-4"})}),e.jsx(Ru,{themeKey:I,themeInfo:K}),e.jsx(L,{onClick:()=>_(I),disabled:n===I||I===S.active,loading:n===I,variant:I===S.active?"secondary":"default",children:I===S.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},I))}),e.jsx(ge,{open:i,onOpenChange:l,children:e.jsxs(de,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:s("upload.title")}),e.jsx(Ve,{children:s("upload.description")})]}),e.jsxs("div",{className:b("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:D,onDragLeave:D,onDragOver:D,onDrop:g,children:[e.jsx("input",{type:"file",ref:h,className:"hidden",accept:".zip",onChange:I=>{const K=I.target.files?.[0];K&&T(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(wt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>h.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(ge,{open:!!o,onOpenChange:I=>{I||(c(null),C(0))},children:e.jsxs(de,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(fe,{children:[o?.name," ",s("preview.title")]}),e.jsx(Ve,{className:"text-center",children:o&&s("preview.imageCount",{current:k+1,total:o.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:o?.images[k]&&e.jsx("img",{src:o.images[k],alt:`${o.name} 预览图 ${k+1}`,className:"h-full w-full object-contain"})}),o&&o.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:w,children:e.jsx(Uc,{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:R,children:e.jsx(Kc,{className:"h-4 w-4"})})]})]}),o&&o.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:o.images.map((I,K)=>e.jsx("button",{onClick:()=>C(K),className:b("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",k===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:I,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function hr(){return e.jsxs(Re,{children:[e.jsxs(Fe,{children:[e.jsx(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-4 w-[300px]"})]}),e.jsxs(Ie,{className:"flex items-center justify-end space-x-3",children:[e.jsx(je,{className:"h-10 w-[100px]"}),e.jsx(je,{className:"h-10 w-[100px]"})]})]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Eu},Symbol.toStringTag,{value:"Module"})),zn=m.forwardRef(({className:s,value:n,onChange:t,...r},a)=>{const[i,l]=m.useState("");m.useEffect(()=>{if(i.includes(",")){const u=new Set([...n,...i.split(",").map(o=>o.trim())]);t(Array.from(u)),l("")}},[i,t,n]);const d=()=>{if(i){const u=new Set([...n,i]);t(Array.from(u)),l("")}};return e.jsxs("div",{className:b(" 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(u=>e.jsxs(U,{variant:"secondary",children:[u,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(o=>o!==u))},children:e.jsx(hn,{className:"w-3"})})]},u)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"||u.key===","?(u.preventDefault(),d()):u.key==="Backspace"&&i.length===0&&n.length>0&&(u.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});zn.displayName="InputTags";const Iu=x.object({id:x.number().nullable(),title:x.string().min(1).max(250),content:x.string().min(1),show:x.boolean(),tags:x.array(x.string()),img_url:x.string().nullable()}),Vu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Xl({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Vu}){const{t:a}=V("notice"),[i,l]=m.useState(!1),d=we({resolver:Ce(Iu),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new Tn({html:!0});return e.jsx(Se,{...d,children:e.jsxs(ge,{onOpenChange:l,open:i,children:[e.jsx(as,{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(de,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ve,{})]}),e.jsx(v,{control:d.control,name:"title",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(P,{placeholder:a("form.fields.title.placeholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"content",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.content.label")}),e.jsx(y,{children:e.jsx(Dn,{style:{height:"500px"},value:o.value,renderHTML:c=>u.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"img_url",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(P,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"show",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"tags",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.fields.tags.label")}),e.jsx(y,{children:e.jsx(zn,{value:o.value,onChange:o.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(L,{type:"submit",onClick:o=>{o.preventDefault(),d.handleSubmit(async c=>{Qt.save(c).then(({data:h})=>{h&&(A.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function Mu({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(Xl,{refetch:n}),!r&&e.jsx(P,{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(ms,{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 Ou=s=>{const{t:n}=V("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Bc,{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(Z,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await Qt.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(Xl,{refetch:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{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(ps,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{Qt.drop(t.original.id).then(()=>{A.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(ds,{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 zu(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,o]=m.useState(!1),[c,h]=m.useState({}),[k,C]=m.useState({pageSize:50,pageIndex:0}),[S,f]=m.useState([]),{refetch:N}=ne({queryKey:["notices"],queryFn:async()=>{const{data:w}=await Qt.getList();return f(w),w}});m.useEffect(()=>{r({"drag-handle":u,content:!u,created_at:!u,actions:!u}),C({pageSize:u?99999:50,pageIndex:0})},[u]);const _=(w,R)=>{u&&(w.dataTransfer.setData("text/plain",R.toString()),w.currentTarget.classList.add("opacity-50"))},T=(w,R)=>{if(!u)return;w.preventDefault(),w.currentTarget.classList.remove("bg-muted");const H=parseInt(w.dataTransfer.getData("text/plain"));if(H===R)return;const I=[...S],[K]=I.splice(H,1);I.splice(R,0,K),f(I)},D=async()=>{if(!u){o(!0);return}Qt.sort(S.map(w=>w.id)).then(()=>{A.success("排序保存成功"),o(!1),N()}).finally(()=>{o(!1)})},g=ss({data:S??[],columns:Ou(N),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:c,pagination:k},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:h,onPaginationChange:C,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(xs,{table:g,toolbar:w=>e.jsx(Mu,{table:w,refetch:N,saveOrder:D,isSortMode:u}),draggable:u,onDragStart:_,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:!u})})}function $u(){const{t:s}=V("notice");return e.jsxs(ze,{children:[e.jsxs($e,{className:"flex items-center justify-between",children:[e.jsx(ns,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(zu,{})})]})]})}const Au=Object.freeze(Object.defineProperty({__proto__:null,default:$u},Symbol.toStringTag,{value:"Module"})),qu=x.object({id:x.number().nullable(),language:x.string().max(250),category:x.string().max(250),title:x.string().min(1).max(250),body:x.string().min(1),show:x.boolean()}),Hu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Zl({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=Hu}){const{t:a}=V("knowledge"),[i,l]=m.useState(!1),d=we({resolver:Ce(qu),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new Tn({html:!0});return m.useEffect(()=>{i&&r.id&&Ct.getInfo(r.id).then(({data:o})=>{d.reset(o)})},[r.id,d,i]),e.jsxs(ge,{onOpenChange:l,open:i,children:[e.jsx(as,{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(de,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...d,children:[e.jsx(v,{control:d.control,name:"title",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(P,{placeholder:a("form.titlePlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"category",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(y,{children:e.jsx(P,{placeholder:a("form.categoryPlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"language",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.language")}),e.jsx(y,{children:e.jsxs(J,{value:o.value,onValueChange:o.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.languagePlaceholder")})}),e.jsx(Y,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(c=>e.jsx($,{value:c.value,className:"cursor-pointer",children:a(`languages.${c.value}`)},c.value))})]})})]})}),e.jsx(v,{control:d.control,name:"body",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.content")}),e.jsx(y,{children:e.jsx(Dn,{style:{height:"500px"},value:o.value,renderHTML:c=>u.render(c),onChange:({text:c})=>{o.onChange(c)}})}),e.jsx(E,{})]})}),e.jsx(v,{control:d.control,name:"show",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(y,{children:e.jsx(Z,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(L,{type:"submit",onClick:()=>{d.handleSubmit(o=>{Ct.save(o).then(({data:c})=>{c&&(d.reset(),A.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function Uu({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(We,{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:b("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(ot,{className:b("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function Ku({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(Zl,{refreshData:n}),e.jsx(P,{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(Uu,{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(ms,{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 Bu=({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(Ea,{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(Z,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Ct.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(Zl,{refreshData:s,dialogTrigger:e.jsxs(L,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{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(ps,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ct.drop({id:r.original.id}).then(({data:a})=>{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(ds,{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 Gu(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,o]=m.useState({"drag-handle":!1}),[c,h]=m.useState({pageSize:20,pageIndex:0}),{refetch:k,isLoading:C,data:S}=ne({queryKey:["knowledge"],queryFn:async()=>{const{data:D}=await Ct.getList();return d(D||[]),D}});m.useEffect(()=>{o({"drag-handle":a,actions:!a}),h({pageSize:a?99999:10,pageIndex:0})},[a]);const f=(D,g)=>{a&&(D.dataTransfer.setData("text/plain",g.toString()),D.currentTarget.classList.add("opacity-50"))},N=(D,g)=>{if(!a)return;D.preventDefault(),D.currentTarget.classList.remove("bg-muted");const w=parseInt(D.dataTransfer.getData("text/plain"));if(w===g)return;const R=[...l],[H]=R.splice(w,1);R.splice(g,0,H),d(R)},_=async()=>{a?Ct.sort({ids:l.map(D=>D.id)}).then(()=>{k(),i(!1),A.success("排序保存成功")}):i(!0)},T=ss({data:l,columns:Bu({refetch:k,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:c},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:o,onPaginationChange:h,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:T,toolbar:D=>e.jsx(Ku,{table:D,refetch:k,saveOrder:_,isSortMode:a}),draggable:a,onDragStart:f,onDragEnd:D=>D.currentTarget.classList.remove("opacity-50"),onDragOver:D=>{D.preventDefault(),D.currentTarget.classList.add("bg-muted")},onDragLeave:D=>D.currentTarget.classList.remove("bg-muted"),onDrop:N,showPagination:!a})}function Wu(){const{t:s}=V("knowledge");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Gu,{})})]})]})}const Yu=Object.freeze(Object.defineProperty({__proto__:null,default:Wu},Symbol.toStringTag,{value:"Module"}));function Ju(s,n){const[t,r]=m.useState(s);return m.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function nn(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 Qu(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 Xu(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 ei=m.forwardRef(({className:s,...n},t)=>Gc(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:b("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);ei.displayName="CommandEmpty";const kt=m.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:u,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:c,hidePlaceholderWhenSelected:h,disabled:k,groupBy:C,className:S,badgeClassName:f,selectFirstItem:N=!0,creatable:_=!1,triggerSearchOnFocus:T=!1,commandProps:D,inputProps:g,hideClearAllButton:w=!1},R)=>{const H=m.useRef(null),[I,K]=m.useState(!1),ae=m.useRef(!1),[ee,te]=m.useState(!1),[q,F]=m.useState(s||[]),[X,Ns]=m.useState(nn(r,C)),[De,ie]=m.useState(""),_s=Ju(De,i||500);m.useImperativeHandle(R,()=>({selectedValue:[...q],input:H.current,focus:()=>H.current?.focus()}),[q]);const Fs=m.useCallback(se=>{const pe=q.filter(re=>re.value!==se.value);F(pe),n?.(pe)},[n,q]),Xs=m.useCallback(se=>{const pe=H.current;pe&&((se.key==="Delete"||se.key==="Backspace")&&pe.value===""&&q.length>0&&(q[q.length-1].fixed||Fs(q[q.length-1])),se.key==="Escape"&&pe.blur())},[Fs,q]);m.useEffect(()=>{s&&F(s)},[s]),m.useEffect(()=>{if(!a||l)return;const se=nn(a||[],C);JSON.stringify(se)!==JSON.stringify(X)&&Ns(se)},[r,a,C,l,X]),m.useEffect(()=>{const se=async()=>{te(!0);const re=await l?.(_s);Ns(nn(re||[],C)),te(!1)};(async()=>{!l||!I||(T&&await se(),_s&&await se())})()},[_s,C,I,T]);const Lt=()=>{if(!_||Xu(X,[{value:De,label:De}])||q.find(pe=>pe.value===De))return;const se=e.jsx(We,{value:De,className:"cursor-pointer",onMouseDown:pe=>{pe.preventDefault(),pe.stopPropagation()},onSelect:pe=>{if(q.length>=o){c?.(q.length);return}ie("");const re=[...q,{value:pe,label:pe}];F(re),n?.(re)},children:`Create "${De}"`});if(!l&&De.length>0||l&&_s.length>0&&!ee)return se},Zt=m.useCallback(()=>{if(u)return l&&!_&&Object.keys(X).length===0?e.jsx(We,{value:"-",disabled:!0,children:u}):e.jsx(ei,{children:u})},[_,u,l,X]),Rt=m.useMemo(()=>Qu(X,q),[X,q]),qs=m.useCallback(()=>{if(D?.filter)return D.filter;if(_)return(se,pe)=>se.toLowerCase().includes(pe.toLowerCase())?1:-1},[_,D?.filter]),Ja=m.useCallback(()=>{const se=q.filter(pe=>pe.fixed);F(se),n?.(se)},[n,q]);return e.jsxs(Js,{...D,onKeyDown:se=>{Xs(se),D?.onKeyDown?.(se)},className:b("h-auto overflow-visible bg-transparent",D?.className),shouldFilter:D?.shouldFilter!==void 0?D.shouldFilter:!l,filter:qs(),children:[e.jsx("div",{className:b("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":q.length!==0,"cursor-text":!k&&q.length!==0},S),onClick:()=>{k||H.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[q.map(se=>e.jsxs(U,{className:b("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",f),"data-fixed":se.fixed,"data-disabled":k||void 0,children:[se.label,e.jsx("button",{className:b("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(k||se.fixed)&&"hidden"),onKeyDown:pe=>{pe.key==="Enter"&&Fs(se)},onMouseDown:pe=>{pe.preventDefault(),pe.stopPropagation()},onClick:()=>Fs(se),children:e.jsx(hn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},se.value)),e.jsx(es.Input,{...g,ref:H,value:De,disabled:k,onValueChange:se=>{ie(se),g?.onValueChange?.(se)},onBlur:se=>{ae.current===!1&&K(!1),g?.onBlur?.(se)},onFocus:se=>{K(!0),T&&l?.(_s),g?.onFocus?.(se)},placeholder:h&&q.length!==0?"":t,className:b("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":h,"px-3 py-2":q.length===0,"ml-1":q.length!==0},g?.className)}),e.jsx("button",{type:"button",onClick:Ja,className:b((w||k||q.length<1||q.filter(se=>se.fixed).length===q.length)&&"hidden"),children:e.jsx(hn,{})})]})}),e.jsx("div",{className:"relative",children:I&&e.jsx(Qs,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{ae.current=!1},onMouseEnter:()=>{ae.current=!0},onMouseUp:()=>{H.current?.focus()},children:ee?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Zt(),Lt(),!N&&e.jsx(We,{value:"-",className:"hidden"}),Object.entries(Rt).map(([se,pe])=>e.jsx(fs,{heading:se,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:pe.map(re=>e.jsx(We,{value:re.value,disabled:re.disable,onMouseDown:Zs=>{Zs.preventDefault(),Zs.stopPropagation()},onSelect:()=>{if(q.length>=o){c?.(q.length);return}ie("");const Zs=[...q,re];F(Zs),n?.(Zs)},className:b("cursor-pointer",re.disable&&"cursor-default text-muted-foreground"),children:re.label},re.value))})},se))]})})})]})});kt.displayName="MultipleSelector";const Zu=s=>x.object({id:x.number().optional(),name:x.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function Ka({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=V("group"),i=we({resolver:Ce(Zu(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1),[u,o]=m.useState(!1),c=async h=>{o(!0),mt.save(h).then(()=>{A.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{o(!1)})};return e.jsxs(ge,{open:l,onOpenChange:d,children:[e.jsx(as,{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(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ve,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(Se,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(v,{control:i.control,name:"name",render:({field:h})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.name")}),e.jsx(y,{children:e.jsx(P,{placeholder:a("form.namePlaceholder"),...h,className:"w-full"})}),e.jsx(O,{children:a("form.nameDescription")}),e.jsx(E,{})]})}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(L,{type:"submit",disabled:u||!i.formState.isValid,children:[u&&e.jsx(ya,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const si=m.createContext(void 0);function ex({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),[l,d]=m.useState(oe.Shadowsocks);return e.jsx(si.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function ti(){const s=m.useContext(si);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function rn({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,u]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,c]=m.useState(null),h=_=>{if(!_)return null;try{const T=JSON.parse(_);return typeof T!="object"||T===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},k={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:{}}}}}},C=()=>{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[]}},S=()=>{const _=h(d||"");if(_){A.error(_);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{A.error(a("network_settings.errors.save_failed"))}},f=_=>{u(_),c(h(_))},N=_=>{const T=k[_];if(T){const D=JSON.stringify(T.content,null,2);u(D),c(null)}};return m.useEffect(()=>{i&&console.log(n)},[i,n]),m.useEffect(()=>{i&&n&&Object.keys(n).length>0&&u(JSON.stringify(n,null,2))},[i,n]),e.jsxs(ge,{open:i,onOpenChange:_=>{!_&&i&&S(),l(_)},children:[e.jsx(as,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[C().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:C().map(_=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>N(_),children:a("network_settings.use_template",{template:k[_].label})},_))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ds,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:C().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:_=>f(_.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(G,{onClick:S,disabled:!!o,children:a("common.confirm")})]})]})]})}function _g(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const sx={},tx=Object.freeze(Object.defineProperty({__proto__:null,default:sx},Symbol.toStringTag,{value:"Module"})),wg=cd(tx),gr=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),ax=()=>{try{const s=Wc.box.keyPair(),n=gr(tr.encodeBase64(s.secretKey)),t=gr(tr.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},nx=()=>{try{return ax()}catch(s){throw console.error("Error generating key pair:",s),s}},rx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},lx=()=>{const s=Math.floor(Math.random()*8)*2+2;return rx(s)},ix=x.object({cipher:x.string().default("aes-128-gcm"),plugin:x.string().optional().default(""),plugin_opts:x.string().optional().default(""),client_fingerprint:x.string().optional().default("chrome")}),ox=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),cx=x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({})}),dx=x.object({version:x.coerce.number().default(2),alpn:x.string().default("h2"),obfs:x.object({open:x.coerce.boolean().default(!1),type:x.string().default("salamander"),password:x.string().default("")}).default({}),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),bandwidth:x.object({up:x.string().default(""),down:x.string().default("")}).default({}),hop_interval:x.number().optional(),port_range:x.string().optional()}),mx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({}),reality_settings:x.object({server_port:x.coerce.number().default(443),server_name:x.string().default(""),allow_insecure:x.boolean().default(!1),public_key:x.string().default(""),private_key:x.string().default(""),short_id:x.string().default("")}).default({}),network:x.string().default("tcp"),network_settings:x.record(x.any()).default({}),flow:x.string().default("")}),ux=x.object({version:x.coerce.number().default(5),congestion_control:x.string().default("bbr"),alpn:x.array(x.string()).default(["h3"]),udp_relay_mode:x.string().default("native"),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),xx=x.object({}),hx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),gx=x.object({tls:x.coerce.number().default(0),tls_settings:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),fx=x.object({transport:x.string().default("tcp"),multiplexing:x.string().default("MULTIPLEXING_LOW")}),px=x.object({padding_scheme:x.array(x.string()).optional().default([]),tls:x.object({server_name:x.string().default(""),allow_insecure:x.boolean().default(!1)}).default({})}),Ee={shadowsocks:{schema:ix,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"],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:ox,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:cx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:dx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:mx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]},tuic:{schema:ux,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:xx},naive:{schema:gx},http:{schema:hx},mieru:{schema:fx,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:px,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"]}},jx=({serverType:s,value:n,onChange:t})=>{const{t:r}=V("server"),a=s?Ee[s]:null,i=a?.schema||x.record(x.any()),l=s?i.parse({}):{},d=we({resolver:Ce(i),defaultValues:l,mode:"onChange"});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(w=>{t(w)});return()=>g.unsubscribe()},[d,t]),!s||!a)return null;const D={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"cipher",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.shadowsocks.ciphers.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})}),e.jsx(v,{control:d.control,name:"plugin",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.plugin.label","插件")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:w=>g.onChange(w==="none"?"":w),value:g.value===""?"none":g.value||"none",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.plugin.placeholder","选择插件")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.shadowsocks.plugins.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})}),e.jsx(O,{children:g.value&&g.value!=="none"&&g.value!==""&&e.jsxs(e.Fragment,{children:[g.value==="obfs"&&r("dynamic_form.shadowsocks.plugin.obfs_hint","提示:配置格式如 obfs=http;obfs-host=www.bing.com;path=/"),g.value==="v2ray-plugin"&&r("dynamic_form.shadowsocks.plugin.v2ray_hint","提示:WebSocket模式格式为 mode=websocket;host=mydomain.me;path=/;tls=true,QUIC模式格式为 mode=quic;host=mydomain.me")]})})]})}),d.watch("plugin")&&d.watch("plugin")!=="none"&&d.watch("plugin")!==""&&e.jsx(v,{control:d.control,name:"plugin_opts",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.plugin_opts.label","插件选项")}),e.jsx(O,{children:r("dynamic_form.shadowsocks.plugin_opts.description","按照 key=value;key2=value2 格式输入插件选项")}),e.jsx(y,{children:e.jsx(P,{type:"text",placeholder:r("dynamic_form.shadowsocks.plugin_opts.placeholder","例如: mode=tls;host=bing.com"),...g})})]})}),(d.watch("plugin")==="shadow-tls"||d.watch("plugin")==="restls")&&e.jsx(v,{control:d.control,name:"client_fingerprint",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.shadowsocks.client_fingerprint","客户端指纹")}),e.jsx(y,{children:e.jsxs(J,{value:g.value||"chrome",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.client_fingerprint_placeholder","选择客户端指纹")})}),e.jsx(Y,{children:Ee.shadowsocks.clientFingerprints.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})]})}),e.jsx(O,{children:r("dynamic_form.shadowsocks.client_fingerprint_description","客户端伪装指纹,用于降低被识别风险")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx($,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"network",render:({field:g})=>e.jsxs(p,{children:[e.jsxs(j,{children:[r("dynamic_form.vmess.network.label"),e.jsx(rn,{value:d.watch("network_settings"),setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.vmess.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(v,{control:d.control,name:"allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"network",render:({field:g})=>e.jsxs(p,{children:[e.jsxs(j,{children:[r("dynamic_form.trojan.network.label"),e.jsx(rn,{value:d.watch("network_settings")||{},setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")||"tcp"})]}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value||"tcp",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.trojan.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"version",render:({field:g})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(y,{children:e.jsxs(J,{value:(g.value||2).toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.hysteria.versions.map(w=>e.jsxs($,{value:w,className:"cursor-pointer",children:["V",w]},w))})})]})})]})}),d.watch("version")==1&&e.jsx(v,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value||"h2",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.hysteria.alpnOptions.map(w=>e.jsx($,{value:w,children:w},w))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"obfs.open",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(v,{control:d.control,name:"obfs.type",render:({field:g})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value||"salamander",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:e.jsx($,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(v,{control:d.control,name:"obfs.password",render:({field:g})=>e.jsxs(p,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(P,{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 w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",R=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(H=>w[H%w.length]).join("");d.setValue("obfs.password",R),A.success(r("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Be,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(v,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"bandwidth.up",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(P,{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(v,{control:d.control,name:"bandwidth.down",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(P,{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(v,{control:d.control,name:"hop_interval",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:r("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...g,value:g.value||"",onChange:w=>{const R=w.target.value?parseInt(w.target.value):void 0;g.onChange(R)}})}),e.jsx(O,{children:r("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx($,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx($,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{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(v,{control:d.control,name:"reality_settings.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"reality_settings.server_port",render:({field:g})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"reality_settings.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(v,{control:d.control,name:"reality_settings.private_key",render:({field:g})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(P,{...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 w=nx();d.setValue("reality_settings.private_key",w.privateKey),d.setValue("reality_settings.public_key",w.publicKey),A.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.error(r("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Be,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Na,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(v,{control:d.control,name:"reality_settings.public_key",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(y,{children:e.jsx(P,{...g})})]})}),e.jsx(v,{control:d.control,name:"reality_settings.short_id",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{children:e.jsx(P,{...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 w=lx();d.setValue("reality_settings.short_id",w),A.success(r("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Be,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Na,{children:e.jsx(ce,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(O,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(v,{control:d.control,name:"network",render:({field:g})=>e.jsxs(p,{children:[e.jsxs(j,{children:[r("dynamic_form.vless.network.label"),e.jsx(rn,{value:d.watch("network_settings"),setValue:w=>d.setValue("network_settings",w),templateType:d.watch("network")})]}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.vless.networkOptions.map(w=>e.jsx($,{value:w.value,className:"cursor-pointer",children:w.label},w.value))})})]})})]})}),e.jsx(v,{control:d.control,name:"flow",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.vless.flow.label")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:w=>g.onChange(w==="none"?null:w),value:g.value||"none",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(Y,{children:Ee.vless.flowOptions.map(w=>e.jsx($,{value:w,children:w},w))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"version",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.tuic.version.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.tuic.versions.map(w=>e.jsxs($,{value:w,children:["V",w]},w))})})]})})]})}),e.jsx(v,{control:d.control,name:"congestion_control",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.tuic.congestionControls.map(w=>e.jsx($,{value:w,children:w.toUpperCase()},w))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(y,{children:e.jsx(kt,{options:Ee.tuic.alpnOptions,onChange:w=>g.onChange(w.map(R=>R.value)),value:Ee.tuic.alpnOptions.filter(w=>g.value?.includes(w.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(v,{control:d.control,name:"udp_relay_mode",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.tuic.udpRelayModes.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx($,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.http.tls.label")}),e.jsx(y,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:w=>g.onChange(Number(w)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx($,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"transport",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.mieru.transportOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})}),e.jsx(v,{control:d.control,name:"multiplexing",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(y,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(Y,{children:e.jsx(rs,{children:Ee.mieru.multiplexingOptions.map(w=>e.jsx($,{value:w.value,children:w.label},w.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:d.control,name:"padding_scheme",render:({field:g})=>e.jsxs(p,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(j,{children:r("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{d.setValue("padding_scheme",Ee.anytls.defaultPaddingScheme),A.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(O,{children:r("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(y,{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:w=>{const H=w.target.value.split(` -`).filter(I=>I.trim()!=="");g.onChange(H)}})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:r("dynamic_form.anytls.tls.server_name.label","SNI")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dynamic_form.anytls.tls.server_name.placeholder","服务器名称"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dynamic_form.anytls.tls.allow_insecure","允许不安全连接")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]})})};return e.jsx(be,{children:E[s]?.()})};function vx(){const{t:s}=V("server"),n=x.object({id:x.number().optional().nullable(),specific_key:x.string().optional().nullable(),code:x.string().optional(),show:x.boolean().optional().nullable(),name:x.string().min(1,s("form.name.error")),rate:x.string().min(1,s("form.rate.error")).refine(R=>!isNaN(parseFloat(R))&&isFinite(Number(R)),{message:s("form.rate.error_numeric")}).refine(R=>parseFloat(R)>=0,{message:s("form.rate.error_gte_zero")}),tags:x.array(x.string()).default([]),excludes:x.array(x.string()).default([]),ips:x.array(x.string()).default([]),group_ids:x.array(x.string()).default([]),host:x.string().min(1,s("form.host.error")),port:x.string().min(1,s("form.port.error")),server_port:x.string().min(1,s("form.server_port.error")),parent_id:x.string().default("0").nullable(),route_ids:x.array(x.string()).default([]),protocol_settings:x.record(x.any()).default({}).nullable()}),t={id:null,specific_key:null,code:"",show:!1,name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null},{isOpen:r,setIsOpen:a,editingServer:i,setEditingServer:l,serverType:d,setServerType:u,refetch:o}=ti(),[c,h]=m.useState([]),[k,C]=m.useState([]),[S,p]=m.useState([]),_=we({resolver:Ce(n),defaultValues:t,mode:"onChange"});m.useEffect(()=>{f()},[r]),m.useEffect(()=>{i?.type&&i.type!==d&&u(i.type)},[i,d,u]),m.useEffect(()=>{i?i.type===d&&_.reset({...t,...i}):_.reset({...t,protocol_settings:Re[d].schema.parse({})})},[i,_,d]);const f=async()=>{if(!r)return;const[R,H,I]=await Promise.all([mt.getList(),Va.getList(),at.getList()]);h(R.data?.map(K=>({label:K.name,value:K.id.toString()}))||[]),C(H.data?.map(K=>({label:K.remarks,value:K.id.toString()}))||[]),p(I.data||[])},T=m.useMemo(()=>S?.filter(R=>(R.parent_id===0||R.parent_id===null)&&R.type===d&&R.id!==_.watch("id")),[d,S,_]),E=()=>e.jsxs(zs,{children:[e.jsx($s,{asChild:!0,children:e.jsxs(P,{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(Ls,{align:"start",children:e.jsx(Kd,{children:js.map(({type:R,label:H})=>e.jsx(_e,{onClick:()=>{u(R),a(!0)},className:"cursor-pointer",children:e.jsx(U,{variant:"outline",className:"text-white",style:{background:is[R]},children:H})},R))})})]}),g=()=>{a(!1),l(null),_.reset(t)},w=async()=>{const R=_.getValues();(await at.save({...R,type:d})).data&&(g(),A.success(s("form.success")),o())};return e.jsxs(ge,{open:r,onOpenChange:g,children:[E(),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:s(i?"form.edit_node":"form.new_node")}),e.jsx(Ve,{})]}),e.jsxs(Se,{..._,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:_.control,name:"name",render:({field:R})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:s("form.name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...R})}),e.jsx(L,{})]})}),e.jsx(b,{control:_.control,name:"rate",render:({field:R})=>e.jsxs(j,{className:"flex-[1]",children:[e.jsx(v,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(N,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...R})})}),e.jsx(L,{})]})})]}),e.jsx(b,{control:_.control,name:"code",render:({field:R})=>e.jsxs(j,{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(N,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...R,value:R.value||""})}),e.jsx(L,{})]})}),e.jsx(b,{control:_.control,name:"tags",render:({field:R})=>e.jsxs(j,{children:[e.jsx(v,{children:s("form.tags.label")}),e.jsx(N,{children:e.jsx(zn,{value:R.value,onChange:R.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(L,{})]})}),e.jsx(b,{control:_.control,name:"group_ids",render:({field:R})=>e.jsxs(j,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Ka,{dialogTrigger:e.jsx(P,{variant:"link",children:s("form.groups.add")}),refetch:f})]}),e.jsx(N,{children:e.jsx(kt,{options:c,onChange:H=>R.onChange(H.map(I=>I.value)),value:c?.filter(H=>R.value.includes(H.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(L,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:_.control,name:"host",render:({field:R})=>e.jsxs(j,{children:[e.jsx(v,{children:s("form.host.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...R})}),e.jsx(L,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{control:_.control,name:"port",render:({field:R})=>e.jsxs(j,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(be,{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(Na,{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(N,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...R})}),e.jsx(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const H=R.value;H&&_.setValue("server_port",H)},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(L,{})]})}),e.jsx(b,{control:_.control,name:"server_port",render:({field:R})=>e.jsxs(j,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(be,{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(Na,{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(N,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...R})}),e.jsx(L,{})]})})]})]}),r&&e.jsx(jx,{serverType:d,value:_.watch("protocol_settings"),onChange:R=>_.setValue("protocol_settings",R,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(b,{control:_.control,name:"parent_id",render:({field:R})=>e.jsxs(j,{children:[e.jsx(v,{children:s("form.parent.label")}),e.jsxs(J,{onValueChange:R.onChange,value:R.value?.toString()||"0",children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("form.parent.none")}),T?.map(H=>e.jsx($,{value:H.id.toString(),className:"cursor-pointer",children:H.name},H.id))]})]}),e.jsx(L,{})]})}),e.jsx(b,{control:_.control,name:"route_ids",render:({field:R})=>e.jsxs(j,{children:[e.jsx(v,{children:s("form.route.label")}),e.jsx(N,{children:e.jsx(kt,{options:k,onChange:H=>R.onChange(H.map(I=>I.value)),value:k?.filter(H=>R.value.includes(H.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(L,{})]})})]}),e.jsxs(Le,{className:"mt-6 flex flex-col sm:flex-row gap-2 sm:gap-0",children:[e.jsx(P,{type:"button",variant:"outline",onClick:g,className:"w-full sm:w-auto",children:s("form.cancel")}),e.jsx(P,{type:"submit",onClick:w,className:"w-full sm:w-auto",children:s("form.submit")})]})]})]})]})}function fr({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(We,{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:y("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(ot,{className:y("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const bx=[{value:oe.Shadowsocks,label:js.find(s=>s.type===oe.Shadowsocks)?.label,color:is[oe.Shadowsocks]},{value:oe.Vmess,label:js.find(s=>s.type===oe.Vmess)?.label,color:is[oe.Vmess]},{value:oe.Trojan,label:js.find(s=>s.type===oe.Trojan)?.label,color:is[oe.Trojan]},{value:oe.Hysteria,label:js.find(s=>s.type===oe.Hysteria)?.label,color:is[oe.Hysteria]},{value:oe.Vless,label:js.find(s=>s.type===oe.Vless)?.label,color:is[oe.Vless]},{value:oe.Tuic,label:js.find(s=>s.type===oe.Tuic)?.label,color:is[oe.Tuic]},{value:oe.Socks,label:js.find(s=>s.type===oe.Socks)?.label,color:is[oe.Socks]},{value:oe.Naive,label:js.find(s=>s.type===oe.Naive)?.label,color:is[oe.Naive]},{value:oe.Http,label:js.find(s=>s.type===oe.Http)?.label,color:is[oe.Http]},{value:oe.Mieru,label:js.find(s=>s.type===oe.Mieru)?.label,color:is[oe.Mieru]}];function yx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("server");return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(vx,{}),e.jsx(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(fr,{column:s.getColumn("type"),title:i("toolbar.type"),options:bx}),s.getColumn("group_ids")&&e.jsx(fr,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]}),t&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const Ta=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"})}),da={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"},Me=(s,n)=>n>0?Math.round(s/n*100):0,Nx=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(Ra,{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(be,{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:y("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:is[t.original.type]},children:[e.jsx(jl,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:a??r}),t.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:t.original.parent?.code||t.original.parent?.id})]}):""]})]}),e.jsx(P,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:i=>{i.stopPropagation(),wa(a||r.toString()).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(ar,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[js.find(i=>i.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(Z,{checked:r,onCheckedChange:async i=>{a(i),at.update({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?is[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:y("h-2.5 w-2.5 rounded-full",da[0])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.0")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",da[1])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.1")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",da[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(be,{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:y("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",da[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:y("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:y("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:y("h-full transition-all duration-300",Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"bg-destructive":Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Me(t.original.load_status.mem.used,t.original.load_status.mem.total)}%`}})}),e.jsxs("span",{className:y("min-w-[3rem] text-right font-semibold",Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"text-destructive":Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Me(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:[Oe(t.original.load_status.mem.used)," ","/"," ",Oe(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:y("h-full transition-all duration-300",Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"bg-destructive":Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Me(t.original.load_status.swap.used,t.original.load_status.swap.total)}%`}})}),e.jsxs("span",{className:y("min-w-[3rem] text-right font-semibold",Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"text-destructive":Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"text-yellow-600":"text-emerald-600"),children:[Me(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:[Oe(t.original.load_status.swap.used)," ","/"," ",Oe(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:y("h-full transition-all duration-300",Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"bg-destructive":Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Me(t.original.load_status.disk.used,t.original.load_status.disk.total)}%`}})}),e.jsxs("span",{className:y("min-w-[3rem] text-right font-semibold",Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"text-destructive":Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Me(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:[Oe(t.original.load_status.disk.used)," ","/"," ",Oe(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(be,{delayDuration:0,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:i=>{i.stopPropagation(),wa(r).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(ar,{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(Ta,{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:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children: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:is[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}=ti();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(zs,{modal:!1,children:[e.jsx($s,{asChild:!0,children:e.jsx(P,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(_a,{className:"size-4"})})}),e.jsxs(Ls,{align:"end",className:"w-40",children:[e.jsx(_e,{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(Yc,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(_e,{className:"cursor-pointer",onClick:async()=>{at.copy({id:t.original.id}).then(({data:l})=>{l&&(A.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Jc,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(rt,{}),e.jsx(_e,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(ps,{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()=>{at.drop({id:t.original.id}).then(({data:l})=>{l&&(A.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(ds,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function _x(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState({pageSize:500,pageIndex:0}),[u,o]=m.useState([]),[c,h]=m.useState(!1),[k,C]=m.useState({}),[S,p]=m.useState([]),{refetch:_}=ne({queryKey:["nodeList"],queryFn:async()=>{const{data:R}=await at.getList();return p(R),R}}),{data:f}=ne({queryKey:["groups"],queryFn:async()=>{const{data:R}=await mt.getList();return R}});m.useEffect(()=>{r({"drag-handle":c,show:!c,host:!c,online:!c,rate:!c,groups:!c,type:!1,actions:!c}),C({name:c?2e3:200}),d({pageSize:c?99999:500,pageIndex:0})},[c]);const T=(R,H)=>{c&&(R.dataTransfer.setData("text/plain",H.toString()),R.currentTarget.classList.add("opacity-50"))},E=(R,H)=>{if(!c)return;R.preventDefault(),R.currentTarget.classList.remove("bg-muted");const I=parseInt(R.dataTransfer.getData("text/plain"));if(I===H)return;const K=[...S],[ae]=K.splice(I,1);K.splice(H,0,ae),p(K)},g=async()=>{if(!c){h(!0);return}const R=S?.map((H,I)=>({id:H.id,order:I+1}));at.sort(R).then(()=>{A.success("排序保存成功"),h(!1),_()}).finally(()=>{h(!1)})},w=ss({data:S||[],columns:Nx(_),state:{sorting:u,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:k,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:C,onPaginationChange:d,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ex,{refetch:_,children:e.jsx("div",{className:"space-y-4",children:e.jsx(xs,{table:w,toolbar:R=>e.jsx(yx,{table:R,refetch:_,saveOrder:g,isSortMode:c,groups:f||[]}),draggable:c,onDragStart:T,onDragEnd:R=>R.currentTarget.classList.remove("opacity-50"),onDragOver:R=>{R.preventDefault(),R.currentTarget.classList.add("bg-muted")},onDragLeave:R=>R.currentTarget.classList.remove("bg-muted"),onDrop:E,showPagination:!c})})})}function wx(){const{t:s}=V("server");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(_x,{})})]})]})}const Cx=Object.freeze(Object.defineProperty({__proto__:null,default:wx},Symbol.toStringTag,{value:"Module"}));function Sx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(Ka,{refetch:n}),e.jsx(D,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:y("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]})})}const kx=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(Ta,{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(jl,{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(Ka,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(ps,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{mt.drop({id:t.original.id}).then(({data:r})=>{r&&(A.success(n("messages.updateSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ds,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Tx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),{data:u,refetch:o,isLoading:c}=ne({queryKey:["serverGroupList"],queryFn:async()=>{const{data:k}=await mt.getList();return k}}),h=ss({data:u||[],columns:kx(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:h,toolbar:k=>e.jsx(Sx,{table:k,refetch:o}),isLoading:c})}function Dx(){const{t:s}=V("group");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Tx,{})})]})]})}const Px=Object.freeze(Object.defineProperty({__proto__:null,default:Dx},Symbol.toStringTag,{value:"Module"})),Lx=s=>x.object({remarks:x.string().min(1,s("form.validation.remarks")),match:x.array(x.string()),action:x.enum(["block","dns"]),action_value:x.string().optional()});function ai({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="create"}){const{t:a}=V("route"),i=we({resolver:Ce(Lx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1);return e.jsxs(ge,{open:l,onOpenChange:d,children:[e.jsx(as,{asChild:!0,children:n||e.jsxs(P,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Be,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...i,children:[e.jsx(b,{control:i.control,name:"remarks",render:({field:u})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(D,{type:"text",placeholder:a("form.remarksPlaceholder"),...u})})}),e.jsx(L,{})]})}),e.jsx(b,{control:i.control,name:"match",render:({field:u})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(v,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(Ds,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:Array.isArray(u.value)?u.value.join(` +`).filter(I=>I.trim()!=="");g.onChange(H)}})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:r("dynamic_form.anytls.tls.server_name.label","SNI")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dynamic_form.anytls.tls.server_name.placeholder","服务器名称"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dynamic_form.anytls.tls.allow_insecure","允许不安全连接")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(y,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]})})};return e.jsx(be,{children:D[s]?.()})};function vx(){const{t:s}=V("server"),n=x.object({id:x.number().optional().nullable(),specific_key:x.string().optional().nullable(),code:x.string().optional(),show:x.boolean().optional().nullable(),name:x.string().min(1,s("form.name.error")),rate:x.string().min(1,s("form.rate.error")).refine(R=>!isNaN(parseFloat(R))&&isFinite(Number(R)),{message:s("form.rate.error_numeric")}).refine(R=>parseFloat(R)>=0,{message:s("form.rate.error_gte_zero")}),tags:x.array(x.string()).default([]),excludes:x.array(x.string()).default([]),ips:x.array(x.string()).default([]),group_ids:x.array(x.string()).default([]),host:x.string().min(1,s("form.host.error")),port:x.string().min(1,s("form.port.error")),server_port:x.string().min(1,s("form.server_port.error")),parent_id:x.string().default("0").nullable(),route_ids:x.array(x.string()).default([]),protocol_settings:x.record(x.any()).default({}).nullable()}),t={id:null,specific_key:null,code:"",show:!1,name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null},{isOpen:r,setIsOpen:a,editingServer:i,setEditingServer:l,serverType:d,setServerType:u,refetch:o}=ti(),[c,h]=m.useState([]),[k,C]=m.useState([]),[S,f]=m.useState([]),N=we({resolver:Ce(n),defaultValues:t,mode:"onChange"});m.useEffect(()=>{_()},[r]),m.useEffect(()=>{i?.type&&i.type!==d&&u(i.type)},[i,d,u]),m.useEffect(()=>{i?i.type===d&&N.reset({...t,...i}):N.reset({...t,protocol_settings:Ee[d].schema.parse({})})},[i,N,d]);const _=async()=>{if(!r)return;const[R,H,I]=await Promise.all([mt.getList(),Va.getList(),at.getList()]);h(R.data?.map(K=>({label:K.name,value:K.id.toString()}))||[]),C(H.data?.map(K=>({label:K.remarks,value:K.id.toString()}))||[]),f(I.data||[])},T=m.useMemo(()=>S?.filter(R=>(R.parent_id===0||R.parent_id===null)&&R.type===d&&R.id!==N.watch("id")),[d,S,N]),D=()=>e.jsxs(zs,{children:[e.jsx($s,{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(Ls,{align:"start",children:e.jsx(Kd,{children:js.map(({type:R,label:H})=>e.jsx(_e,{onClick:()=>{u(R),a(!0)},className:"cursor-pointer",children:e.jsx(U,{variant:"outline",className:"text-white",style:{background:is[R]},children:H})},R))})})]}),g=()=>{a(!1),l(null),N.reset(t)},w=async()=>{const R=N.getValues();(await at.save({...R,type:d})).data&&(g(),A.success(s("form.success")),o())};return e.jsxs(ge,{open:r,onOpenChange:g,children:[D(),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:s(i?"form.edit_node":"form.new_node")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...N,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:N.control,name:"name",render:({field:R})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:s("form.name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("form.name.placeholder"),...R})}),e.jsx(E,{})]})}),e.jsx(v,{control:N.control,name:"rate",render:({field:R})=>e.jsxs(p,{className:"flex-[1]",children:[e.jsx(j,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(y,{children:e.jsx(P,{type:"number",min:"0",step:"0.1",...R})})}),e.jsx(E,{})]})})]}),e.jsx(v,{control:N.control,name:"code",render:({field:R})=>e.jsxs(p,{children:[e.jsxs(j,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(y,{children:e.jsx(P,{placeholder:s("form.code.placeholder"),...R,value:R.value||""})}),e.jsx(E,{})]})}),e.jsx(v,{control:N.control,name:"tags",render:({field:R})=>e.jsxs(p,{children:[e.jsx(j,{children:s("form.tags.label")}),e.jsx(y,{children:e.jsx(zn,{value:R.value,onChange:R.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsx(v,{control:N.control,name:"group_ids",render:({field:R})=>e.jsxs(p,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Ka,{dialogTrigger:e.jsx(L,{variant:"link",children:s("form.groups.add")}),refetch:_})]}),e.jsx(y,{children:e.jsx(kt,{options:c,onChange:H=>R.onChange(H.map(I=>I.value)),value:c?.filter(H=>R.value.includes(H.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(E,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:N.control,name:"host",render:({field:R})=>e.jsxs(p,{children:[e.jsx(j,{children:s("form.host.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:s("form.host.placeholder"),...R})}),e.jsx(E,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(v,{control:N.control,name:"port",render:({field:R})=>e.jsxs(p,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(be,{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(Na,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{children:e.jsx(P,{placeholder:s("form.port.placeholder"),...R})}),e.jsx(be,{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 H=R.value;H&&N.setValue("server_port",H)},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(E,{})]})}),e.jsx(v,{control:N.control,name:"server_port",render:({field:R})=>e.jsxs(p,{className:"flex-1",children:[e.jsxs(j,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(be,{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(Na,{children:e.jsx(ce,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(y,{children:e.jsx(P,{placeholder:s("form.server_port.placeholder"),...R})}),e.jsx(E,{})]})})]})]}),r&&e.jsx(jx,{serverType:d,value:N.watch("protocol_settings"),onChange:R=>N.setValue("protocol_settings",R,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(v,{control:N.control,name:"parent_id",render:({field:R})=>e.jsxs(p,{children:[e.jsx(j,{children:s("form.parent.label")}),e.jsxs(J,{onValueChange:R.onChange,value:R.value?.toString()||"0",children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("form.parent.none")}),T?.map(H=>e.jsx($,{value:H.id.toString(),className:"cursor-pointer",children:H.name},H.id))]})]}),e.jsx(E,{})]})}),e.jsx(v,{control:N.control,name:"route_ids",render:({field:R})=>e.jsxs(p,{children:[e.jsx(j,{children:s("form.route.label")}),e.jsx(y,{children:e.jsx(kt,{options:k,onChange:H=>R.onChange(H.map(I=>I.value)),value:k?.filter(H=>R.value.includes(H.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(E,{})]})})]}),e.jsxs(Le,{className:"mt-6 flex flex-col sm:flex-row gap-2 sm:gap-0",children:[e.jsx(L,{type:"button",variant:"outline",onClick:g,className:"w-full sm:w-auto",children:s("form.cancel")}),e.jsx(L,{type:"submit",onClick:w,className:"w-full sm:w-auto",children:s("form.submit")})]})]})]})]})}function fr({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(We,{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:b("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(ot,{className:b("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const bx=[{value:oe.Shadowsocks,label:js.find(s=>s.type===oe.Shadowsocks)?.label,color:is[oe.Shadowsocks]},{value:oe.Vmess,label:js.find(s=>s.type===oe.Vmess)?.label,color:is[oe.Vmess]},{value:oe.Trojan,label:js.find(s=>s.type===oe.Trojan)?.label,color:is[oe.Trojan]},{value:oe.Hysteria,label:js.find(s=>s.type===oe.Hysteria)?.label,color:is[oe.Hysteria]},{value:oe.Vless,label:js.find(s=>s.type===oe.Vless)?.label,color:is[oe.Vless]},{value:oe.Tuic,label:js.find(s=>s.type===oe.Tuic)?.label,color:is[oe.Tuic]},{value:oe.Socks,label:js.find(s=>s.type===oe.Socks)?.label,color:is[oe.Socks]},{value:oe.Naive,label:js.find(s=>s.type===oe.Naive)?.label,color:is[oe.Naive]},{value:oe.Http,label:js.find(s=>s.type===oe.Http)?.label,color:is[oe.Http]},{value:oe.Mieru,label:js.find(s=>s.type===oe.Mieru)?.label,color:is[oe.Mieru]}];function yx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=V("server");return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(vx,{}),e.jsx(P,{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(fr,{column:s.getColumn("type"),title:i("toolbar.type"),options:bx}),s.getColumn("group_ids")&&e.jsx(fr,{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(ms,{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 Ta=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"})}),da={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"},Me=(s,n)=>n>0?Math.round(s/n*100):0,Nx=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(Ea,{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(be,{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:b("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:is[t.original.type]},children:[e.jsx(jl,{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(),wa(a||r.toString()).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(ar,{className:"size-3"})})]})}),e.jsxs(ce,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[js.find(i=>i.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(Z,{checked:r,onCheckedChange:async i=>{a(i),at.update({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?is[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:b("h-2.5 w-2.5 rounded-full",da[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:b("h-2.5 w-2.5 rounded-full",da[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:b("h-2.5 w-2.5 rounded-full",da[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(be,{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:b("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",da[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:b("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:b("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:b("h-full transition-all duration-300",Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"bg-destructive":Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Me(t.original.load_status.mem.used,t.original.load_status.mem.total)}%`}})}),e.jsxs("span",{className:b("min-w-[3rem] text-right font-semibold",Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"text-destructive":Me(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Me(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:[Oe(t.original.load_status.mem.used)," ","/"," ",Oe(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:b("h-full transition-all duration-300",Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"bg-destructive":Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Me(t.original.load_status.swap.used,t.original.load_status.swap.total)}%`}})}),e.jsxs("span",{className:b("min-w-[3rem] text-right font-semibold",Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"text-destructive":Me(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"text-yellow-600":"text-emerald-600"),children:[Me(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:[Oe(t.original.load_status.swap.used)," ","/"," ",Oe(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:b("h-full transition-all duration-300",Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"bg-destructive":Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Me(t.original.load_status.disk.used,t.original.load_status.disk.total)}%`}})}),e.jsxs("span",{className:b("min-w-[3rem] text-right font-semibold",Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"text-destructive":Me(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Me(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:[Oe(t.original.load_status.disk.used)," ","/"," ",Oe(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(be,{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(),wa(r).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(ar,{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(Ta,{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:b("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:is[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}=ti();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(zs,{modal:!1,children:[e.jsx($s,{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(_a,{className:"size-4"})})}),e.jsxs(Ls,{align:"end",className:"w-40",children:[e.jsx(_e,{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(Yc,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(_e,{className:"cursor-pointer",onClick:async()=>{at.copy({id:t.original.id}).then(({data:l})=>{l&&(A.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Jc,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(rt,{}),e.jsx(_e,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(ps,{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()=>{at.drop({id:t.original.id}).then(({data:l})=>{l&&(A.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(ds,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function _x(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState({pageSize:500,pageIndex:0}),[u,o]=m.useState([]),[c,h]=m.useState(!1),[k,C]=m.useState({}),[S,f]=m.useState([]),{refetch:N}=ne({queryKey:["nodeList"],queryFn:async()=>{const{data:R}=await at.getList();return f(R),R}}),{data:_}=ne({queryKey:["groups"],queryFn:async()=>{const{data:R}=await mt.getList();return R}});m.useEffect(()=>{r({"drag-handle":c,show:!c,host:!c,online:!c,rate:!c,groups:!c,type:!1,actions:!c}),C({name:c?2e3:200}),d({pageSize:c?99999:500,pageIndex:0})},[c]);const T=(R,H)=>{c&&(R.dataTransfer.setData("text/plain",H.toString()),R.currentTarget.classList.add("opacity-50"))},D=(R,H)=>{if(!c)return;R.preventDefault(),R.currentTarget.classList.remove("bg-muted");const I=parseInt(R.dataTransfer.getData("text/plain"));if(I===H)return;const K=[...S],[ae]=K.splice(I,1);K.splice(H,0,ae),f(K)},g=async()=>{if(!c){h(!0);return}const R=S?.map((H,I)=>({id:H.id,order:I+1}));at.sort(R).then(()=>{A.success("排序保存成功"),h(!1),N()}).finally(()=>{h(!1)})},w=ss({data:S||[],columns:Nx(N),state:{sorting:u,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:k,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:C,onPaginationChange:d,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ex,{refetch:N,children:e.jsx("div",{className:"space-y-4",children:e.jsx(xs,{table:w,toolbar:R=>e.jsx(yx,{table:R,refetch:N,saveOrder:g,isSortMode:c,groups:_||[]}),draggable:c,onDragStart:T,onDragEnd:R=>R.currentTarget.classList.remove("opacity-50"),onDragOver:R=>{R.preventDefault(),R.currentTarget.classList.add("bg-muted")},onDragLeave:R=>R.currentTarget.classList.remove("bg-muted"),onDrop:D,showPagination:!c})})})}function wx(){const{t:s}=V("server");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(_x,{})})]})]})}const Cx=Object.freeze(Object.defineProperty({__proto__:null,default:wx},Symbol.toStringTag,{value:"Module"}));function Sx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(Ka,{refetch:n}),e.jsx(P,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:b("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(ms,{className:"ml-2 h-4 w-4"})]})]})})}const kx=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(Ta,{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(jl,{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(Ka,{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(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(ps,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{mt.drop({id:t.original.id}).then(({data:r})=>{r&&(A.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(ds,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Tx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),{data:u,refetch:o,isLoading:c}=ne({queryKey:["serverGroupList"],queryFn:async()=>{const{data:k}=await mt.getList();return k}}),h=ss({data:u||[],columns:kx(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:h,toolbar:k=>e.jsx(Sx,{table:k,refetch:o}),isLoading:c})}function Dx(){const{t:s}=V("group");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Tx,{})})]})]})}const Px=Object.freeze(Object.defineProperty({__proto__:null,default:Dx},Symbol.toStringTag,{value:"Module"})),Lx=s=>x.object({remarks:x.string().min(1,s("form.validation.remarks")),match:x.array(x.string()),action:x.enum(["block","dns"]),action_value:x.string().optional()});function ai({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="create"}){const{t:a}=V("route"),i=we({resolver:Ce(Lx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1);return e.jsxs(ge,{open:l,onOpenChange:d,children:[e.jsx(as,{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(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...i,children:[e.jsx(v,{control:i.control,name:"remarks",render:({field:u})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(P,{type:"text",placeholder:a("form.remarksPlaceholder"),...u})})}),e.jsx(E,{})]})}),e.jsx(v,{control:i.control,name:"match",render:({field:u})=>e.jsxs(p,{className:"flex-[2]",children:[e.jsx(j,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(Ds,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:Array.isArray(u.value)?u.value.join(` `):"",onChange:o=>{const c=o.target.value.split(` -`);u.onChange(c)}})})}),e.jsx(L,{})]})}),e.jsx(b,{control:i.control,name:"action",render:({field:u})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsxs(J,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"block",children:a("actions.block")}),e.jsx($,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(L,{})]})}),i.watch("action")==="dns"&&e.jsx(b,{control:i.control,name:"action_value",render:({field:u})=>e.jsxs(j,{children:[e.jsx(v,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(D,{type:"text",placeholder:a("form.dnsPlaceholder"),...u})})})]})}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(P,{variant:"outline",children:a("form.cancel")})}),e.jsx(P,{type:"submit",onClick:()=>{const u=i.getValues(),o={...u,match:Array.isArray(u.match)?u.match.filter(c=>c.trim()!==""):[]};Va.save(o).then(({data:c})=>{c&&(d(!1),s&&s(),A.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function Ex({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("route");return e.jsx("div",{className:"flex items-center justify-between ",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[e.jsx(ai,{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(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]})})}function Rx({columns:s,data:n,refetch:t}){const[r,a]=m.useState({}),[i,l]=m.useState({}),[d,u]=m.useState([]),[o,c]=m.useState([]),h=ss({data:n,columns:s,state:{sorting:o,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:c,onColumnFiltersChange:u,onColumnVisibilityChange:l,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:h,toolbar:k=>e.jsx(Ex,{table:k,refetch:t})})}const Fx=s=>{const{t:n}=V("route"),t={block:{icon:Qc,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:Xc,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:y("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(ai,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(ps,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Va.drop({id:r.original.id}).then(({data:a})=>{a&&(A.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ds,{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 Ix(){const{t:s}=V("route"),[n,t]=m.useState([]);function r(){Va.getList().then(({data:a})=>{t(a)})}return m.useEffect(()=>{r()},[]),e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Rx,{data:n,columns:Fx(r),refetch:r})})]})]})}const Vx=Object.freeze(Object.defineProperty({__proto__:null,default:Ix},Symbol.toStringTag,{value:"Module"})),ni=m.createContext(void 0);function Mx({children:s,refreshData:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null);return e.jsx(ni.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function $n(){const s=m.useContext(ni);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function Ox({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=$n(),{t:a}=V("subscribe");return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(P,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx(Be,{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(P,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const pr={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},zx=s=>{const{t:n}=V("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ra,{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(Z,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{gs.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(Z,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{gs.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(Z,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{gs.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(be,{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(ja,{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(be,{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(Zc,{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:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(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 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:y("px-2 py-0.5 font-medium transition-colors text-nowrap",pr[l].color,pr[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=$n();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(ps,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{gs.drop({id:t.original.id}).then(({data:i})=>{i&&(A.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ds,{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")})]})})]})}}]},$x=x.object({id:x.number().nullable(),group_id:x.union([x.number(),x.string()]).nullable().optional(),name:x.string().min(1).max(250),content:x.string().nullable().optional(),transfer_enable:x.union([x.number().min(0),x.string().min(1)]),prices:x.object({monthly:x.union([x.number(),x.string()]).nullable().optional(),quarterly:x.union([x.number(),x.string()]).nullable().optional(),half_yearly:x.union([x.number(),x.string()]).nullable().optional(),yearly:x.union([x.number(),x.string()]).nullable().optional(),two_yearly:x.union([x.number(),x.string()]).nullable().optional(),three_yearly:x.union([x.number(),x.string()]).nullable().optional(),onetime:x.union([x.number(),x.string()]).nullable().optional(),reset_traffic:x.union([x.number(),x.string()]).nullable().optional()}).default({}),speed_limit:x.union([x.number(),x.string()]).nullable().optional(),capacity_limit:x.union([x.number(),x.string()]).nullable().optional(),device_limit:x.union([x.number(),x.string()]).nullable().optional(),force_update:x.boolean().optional(),reset_traffic_method:x.number().nullable(),users_count:x.number().optional(),active_users_count:x.number().optional(),group:x.object({id:x.number(),name:x.string()}).optional()}),An=m.forwardRef(({className:s,...n},t)=>e.jsx(vl,{ref:t,className:y("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...n,children:e.jsx(ed,{className:y("flex items-center justify-center text-current"),children:e.jsx(ot,{className:"h-4 w-4"})})}));An.displayName=vl.displayName;const ma={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},ua={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},Ax=[{value:null,label:"follow_system"},{value:0,label:"monthly_first"},{value:1,label:"monthly_reset"},{value:2,label:"no_reset"},{value:3,label:"yearly_first"},{value:4,label:"yearly_reset"}];function qx(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=$n(),[i,l]=m.useState(!1),{t:d}=V("subscribe"),u=we({resolver:Ce($x),defaultValues:{...ma,...t||{}},mode:"onChange"});m.useEffect(()=>{t?u.reset({...ma,...t}):u.reset(ma)},[t,u]);const o=new Tn({html:!0}),[c,h]=m.useState();async function k(){mt.getList().then(({data:p})=>{h(p)})}m.useEffect(()=>{s&&k()},[s]);const C=p=>{if(isNaN(p))return;const _=Object.entries(ua).reduce((f,[T,E])=>{const g=p*E.months*E.discount;return{...f,[T]:g.toFixed(2)}},{});u.setValue("prices",_,{shouldDirty:!0})},S=()=>{n(!1),r(null),u.reset(ma)};return e.jsx(ge,{open:s,onOpenChange:S,children:e.jsxs(de,{children:[e.jsxs(ve,{children:[e.jsx(fe,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...u,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:u.control,name:"name",render:({field:p})=>e.jsxs(j,{children:[e.jsx(v,{children:d("plan.form.name.label")}),e.jsx(N,{children:e.jsx(D,{placeholder:d("plan.form.name.placeholder"),...p})}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"group_id",render:({field:p})=>e.jsxs(j,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(Ka,{dialogTrigger:e.jsx(P,{variant:"link",children:d("plan.form.group.add")}),refetch:k})]}),e.jsxs(J,{value:p.value?.toString()??"",onValueChange:_=>p.onChange(_?Number(_):null),children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(Y,{children:c?.map(_=>e.jsx($,{value:_.id.toString(),children:_.name},_.id))})]}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"transfer_enable",render:({field:p})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...p})}),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(L,{})]})}),e.jsx(b,{control:u.control,name:"speed_limit",render:({field:p})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...p,value:p.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(L,{})]})}),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",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:p=>{const _=parseFloat(p.target.value);C(_)}})]}),e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const p=Object.keys(ua).reduce((_,f)=>({..._,[f]:""}),{});u.setValue("prices",p,{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(ua).filter(([p])=>!["onetime","reset_traffic"].includes(p)).map(([p,_])=>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(b,{control:u.control,name:`prices.${p}`,render:({field:f})=>e.jsxs(j,{children:[e.jsxs(v,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${p}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",_.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:_.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(N,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...f,value:f.value??"",onChange:T=>f.onChange(T.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"})})]})]})})},p))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(ua).filter(([p])=>["onetime","reset_traffic"].includes(p)).map(([p,_])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(b,{control:u.control,name:`prices.${p}`,render:({field:f})=>e.jsx(j,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(v,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${p}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(p==="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(N,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...f,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"})})]})]})})})},p))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(b,{control:u.control,name:"device_limit",render:({field:p})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...p,value:p.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(L,{})]})}),e.jsx(b,{control:u.control,name:"capacity_limit",render:({field:p})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(v,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...p,value:p.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(L,{})]})})]}),e.jsx(b,{control:u.control,name:"reset_traffic_method",render:({field:p})=>e.jsxs(j,{children:[e.jsx(v,{children:d("plan.form.reset_method.label")}),e.jsxs(J,{value:p.value?.toString()??"null",onValueChange:_=>p.onChange(_=="null"?null:Number(_)),children:[e.jsx(N,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(Y,{children:Ax.map(_=>e.jsx($,{value:_.value?.toString()??"null",children:d(`plan.form.reset_method.options.${_.label}`)},_.value))})]}),e.jsx(O,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:u.control,name:"content",render:({field:p})=>{const[_,f]=m.useState(!1);return e.jsxs(j,{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(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>f(!_),children:_?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(ce,{side:"top",children:e.jsx("p",{className:"text-xs",children:d(_?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{p.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 ${_?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(N,{children:e.jsx(Dn,{style:{height:"400px"},value:p.value||"",renderHTML:T=>o.render(T),onChange:({text:T})=>p.onChange(T),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"})})}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:d("plan.form.content.preview")}),e.jsx("div",{className:"prose prose-sm dark:prose-invert h-[400px] max-w-none overflow-y-auto rounded-md border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:o.render(p.value||"")}})})]})]}),e.jsx(O,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(L,{})]})}})]}),e.jsx(Le,{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(b,{control:u.control,name:"force_update",render:({field:p})=>e.jsxs(j,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(N,{children:e.jsx(An,{checked:p.value,onCheckedChange:p.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(P,{type:"button",variant:"outline",onClick:S,children:d("plan.form.submit.cancel")}),e.jsx(P,{type:"submit",disabled:i,onClick:()=>{u.handleSubmit(async p=>{l(!0),gs.save(p).then(({data:_})=>{_&&(A.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),S(),a())}).finally(()=>{l(!1)})})()},children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function Hx(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,o]=m.useState(!1),[c,h]=m.useState({pageSize:20,pageIndex:0}),[k,C]=m.useState([]),{refetch:S}=ne({queryKey:["planList"],queryFn:async()=>{const{data:E}=await gs.getList();return C(E),E}});m.useEffect(()=>{r({"drag-handle":u}),h({pageSize:u?99999:10,pageIndex:0})},[u]);const p=(E,g)=>{u&&(E.dataTransfer.setData("text/plain",g.toString()),E.currentTarget.classList.add("opacity-50"))},_=(E,g)=>{if(!u)return;E.preventDefault(),E.currentTarget.classList.remove("bg-muted");const w=parseInt(E.dataTransfer.getData("text/plain"));if(w===g)return;const R=[...k],[H]=R.splice(w,1);R.splice(g,0,H),C(R)},f=async()=>{if(!u){o(!0);return}const E=k?.map(g=>g.id);gs.sort(E).then(()=>{A.success("排序保存成功"),o(!1),S()}).finally(()=>{o(!1)})},T=ss({data:k||[],columns:zx(S),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:c},enableRowSelection:!0,onPaginationChange:h,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}},pageCount:u?1:void 0});return e.jsx(Mx,{refreshData:S,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{table:T,toolbar:E=>e.jsx(Ox,{table:E,refetch:S,saveOrder:f,isSortMode:u}),draggable:u,onDragStart:p,onDragEnd:E=>E.currentTarget.classList.remove("opacity-50"),onDragOver:E=>{E.preventDefault(),E.currentTarget.classList.add("bg-muted")},onDragLeave:E=>E.currentTarget.classList.remove("bg-muted"),onDrop:_,showPagination:!u}),e.jsx(qx,{})]})})}function Ux(){const{t:s}=V("subscribe");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("plan.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("plan.page.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Hx,{})})]})]})}const Kx=Object.freeze(Object.defineProperty({__proto__:null,default:Ux},Symbol.toStringTag,{value:"Module"})),vt=[{value:le.PENDING,label:Vt[le.PENDING],icon:sd,color:Mt[le.PENDING]},{value:le.PROCESSING,label:Vt[le.PROCESSING],icon:bl,color:Mt[le.PROCESSING]},{value:le.COMPLETED,label:Vt[le.COMPLETED],icon:gn,color:Mt[le.COMPLETED]},{value:le.CANCELLED,label:Vt[le.CANCELLED],icon:yl,color:Mt[le.CANCELLED]},{value:le.DISCOUNTED,label:Vt[le.DISCOUNTED],icon:gn,color:Mt[le.DISCOUNTED]}],At=[{value:Ne.PENDING,label:ia[Ne.PENDING],icon:td,color:oa[Ne.PENDING]},{value:Ne.PROCESSING,label:ia[Ne.PROCESSING],icon:bl,color:oa[Ne.PROCESSING]},{value:Ne.VALID,label:ia[Ne.VALID],icon:gn,color:oa[Ne.VALID]},{value:Ne.INVALID,label:ia[Ne.INVALID],icon:yl,color:oa[Ne.INVALID]}];function xa({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(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(We,{onSelect:()=>{const u=new Set(i);d?u.delete(l.value):u.add(l.value);const o=Array.from(u);s?.setFilterValue(o.length?o:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ot,{className:y("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Bx=x.object({email:x.string().min(1),plan_id:x.number(),period:x.string(),total_amount:x.number()}),Gx={email:"",plan_id:0,total_amount:0,period:""};function ri({refetch:s,trigger:n,defaultValues:t}){const{t:r}=V("order"),[a,i]=m.useState(!1),l=we({resolver:Ce(Bx),defaultValues:{...Gx,...t},mode:"onChange"}),[d,u]=m.useState([]);return m.useEffect(()=>{a&&gs.getList().then(({data:o})=>{u(o)})},[a]),e.jsxs(ge,{open:a,onOpenChange:i,children:[e.jsx(as,{asChild:!0,children:n||e.jsxs(P,{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(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:r("dialog.assignOrder")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...l,children:[e.jsx(b,{control:l.control,name:"email",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dialog.fields.userEmail")}),e.jsx(N,{children:e.jsx(D,{placeholder:r("dialog.placeholders.email"),...o})})]})}),e.jsx(b,{control:l.control,name:"plan_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(N,{children:e.jsxs(J,{value:o.value?o.value?.toString():void 0,onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(Y,{children:d.map(c=>e.jsx($,{value:c.id.toString(),children:c.name},c.id))})]})})]})}),e.jsx(b,{control:l.control,name:"period",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dialog.fields.orderPeriod")}),e.jsx(N,{children:e.jsxs(J,{value:o.value,onValueChange:o.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.period")})}),e.jsx(Y,{children:Object.keys(pm).map(c=>e.jsx($,{value:c,children:r(`period.${c}`)},c))})]})})]})}),e.jsx(b,{control:l.control,name:"total_amount",render:({field:o})=>e.jsxs(j,{children:[e.jsx(v,{children:r("dialog.fields.paymentAmount")}),e.jsx(N,{children:e.jsx(D,{type:"number",placeholder:r("dialog.placeholders.amount"),value:o.value/100,onChange:c=>o.onChange(parseFloat(c.currentTarget.value)*100)})}),e.jsx(L,{})]})}),e.jsxs(Le,{children:[e.jsx(P,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(P,{type:"submit",onClick:()=>{l.handleSubmit(o=>{tt.assign(o).then(({data:c})=>{c&&(s&&s(),l.reset(),i(!1),A.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function Wx({table:s,refetch:n}){const{t}=V("order"),r=s.getState().columnFilters.length>0,a=Object.values(ws).filter(u=>typeof u=="number").map(u=>({label:t(`type.${ws[u]}`),value:u,color:u===ws.NEW?"green-500":u===ws.RENEWAL?"blue-500":u===ws.UPGRADE?"purple-500":"orange-500"})),i=Object.values(qe).map(u=>({label:t(`period.${u}`),value:u,color:u===qe.MONTH_PRICE?"slate-500":u===qe.QUARTER_PRICE?"cyan-500":u===qe.HALF_YEAR_PRICE?"indigo-500":u===qe.YEAR_PRICE?"violet-500":u===qe.TWO_YEAR_PRICE?"fuchsia-500":u===qe.THREE_YEAR_PRICE?"pink-500":u===qe.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(le).filter(u=>typeof u=="number").map(u=>({label:t(`status.${le[u]}`),value:u,icon:u===le.PENDING?vt[0].icon:u===le.PROCESSING?vt[1].icon:u===le.COMPLETED?vt[2].icon:u===le.CANCELLED?vt[3].icon:vt[4].icon,color:u===le.PENDING?"yellow-500":u===le.PROCESSING?"blue-500":u===le.COMPLETED?"green-500":u===le.CANCELLED?"red-500":"green-500"})),d=Object.values(Ne).filter(u=>typeof u=="number").map(u=>({label:t(`commission.${Ne[u]}`),value:u,icon:u===Ne.PENDING?At[0].icon:u===Ne.PROCESSING?At[1].icon:u===Ne.VALID?At[2].icon:At[3].icon,color:u===Ne.PENDING?"yellow-500":u===Ne.PROCESSING?"blue-500":u===Ne.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ri,{refetch:n}),e.jsx(D,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:u=>s.getColumn("trade_no")?.setFilterValue(u.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(xa,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(xa,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(xa,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(xa,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]})}function Ke({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:y("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:y("text-sm",r),children:n||"-"})]})}function Yx({status:s}){const{t:n}=V("order"),t={[le.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[le.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[le.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[le.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[le.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(U,{variant:"secondary",className:y("font-medium",t[s]),children:n(`status.${le[s]}`)})}function Jx({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:u}=await tt.getInfo({id:s});i(u)}})()},[t,s]),e.jsxs(ge,{onOpenChange:r,open:t,children:[e.jsx(as,{asChild:!0,children:n}),e.jsxs(de,{className:"max-w-xl",children:[e.jsxs(ve,{className:"space-y-2",children:[e.jsx(fe,{className:"text-lg font-medium",children:l("dialog.title")}),e.jsx("div",{className:"flex items-center justify-between text-sm",children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-muted-foreground",children:[l("table.columns.tradeNo"),":",a?.trade_no]}),!!a?.status&&e.jsx(Yx,{status:a.status})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Ke,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Ys,{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(fn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(Ke,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(Ke,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(Ke,{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(Ke,{label:l("dialog.fields.paymentAmount"),value:Vs(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Te,{className:"my-2"}),e.jsx(Ke,{label:l("dialog.fields.balancePayment"),value:Vs(a?.balance_amount||0)}),e.jsx(Ke,{label:l("dialog.fields.discountAmount"),value:Vs(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(Ke,{label:l("dialog.fields.refundAmount"),value:Vs(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(Ke,{label:l("dialog.fields.deductionAmount"),value:Vs(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(Ke,{label:l("dialog.fields.createdAt"),value:me(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(Ke,{label:l("dialog.fields.updatedAt"),value:me(a?.updated_at),valueClassName:"font-mono text-xs"})]})]}),a?.commission_status===1&&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(Ke,{label:l("dialog.fields.commissionStatus"),value:e.jsx(U,{variant:"secondary",className:"bg-orange-100 font-medium text-orange-800 hover:bg-orange-100",children:l("dialog.commissionStatusActive")})}),e.jsx(Ke,{label:l("dialog.fields.commissionAmount"),value:Vs(a?.commission_balance||0),valueClassName:"font-medium text-orange-600"}),a?.actual_commission_balance&&e.jsx(Ke,{label:l("dialog.fields.actualCommissionAmount"),value:Vs(a?.actual_commission_balance||0),valueClassName:"font-medium text-orange-700"}),a?.invite_user&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"my-2"}),e.jsx(Ke,{label:l("dialog.fields.inviteUser"),value:e.jsxs(Ys,{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(fn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})}),e.jsx(Ke,{label:l("dialog.fields.inviteUserId"),value:a?.invite_user?.id,valueClassName:"font-mono text-xs"})]})]})]})]})]})]})}const Qx={[ws.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[ws.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[ws.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[ws.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Xx={[qe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Zx=s=>le[s],eh=s=>Ne[s],sh=s=>ws[s],th=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(Jx,{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(fn,{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=Qx[r];return e.jsx(U,{variant:"secondary",className:y("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=Xx[r];return e.jsx(U,{variant:"secondary",className:y("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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(Ql,{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=vt.find(a=>a.value===t.getValue("status"));return r?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.icon&&e.jsx(r.icon,{className:`h-4 w-4 text-${r.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${Zx(r.value)}`)})]}),r.value===le.PENDING&&e.jsxs(zs,{modal:!0,children:[e.jsx($s,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ls,{align:"end",className:"w-[140px]",children:[e.jsx(_e,{className:"cursor-pointer",onClick:async()=>{await tt.markPaid({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(_e,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await tt.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=At.find(l=>l.value===t.getValue("commission_status"));return a==0||!i?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i.icon&&e.jsx(i.icon,{className:`h-4 w-4 text-${i.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${eh(i.value)}`)})]}),i.value===Ne.PENDING&&r===le.COMPLETED&&e.jsxs(zs,{modal:!0,children:[e.jsx($s,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ls,{align:"end",className:"w-[120px]",children:[e.jsx(_e,{className:"cursor-pointer",onClick:async()=>{await tt.update({trade_no:t.original.trade_no,commission_status:Ne.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(_e,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await tt.update({trade_no:t.original.trade_no,commission_status:Ne.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:me(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function ah(){const[s]=Nl(),[n,t]=m.useState({}),[r,a]=m.useState({}),[i,l]=m.useState([]),[d,u]=m.useState([]),[o,c]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const _=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([f,T])=>{const E=s.get(f);return E?{id:f,value:T==="number"?parseInt(E):E}:null}).filter(Boolean);_.length>0&&l(_)},[s]);const{refetch:h,data:k,isLoading:C}=ne({queryKey:["orderList",o,i,d],queryFn:()=>tt.getList({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),S=ss({data:k?.data??[],columns:th(h),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:o},rowCount:k?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:u,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),onPaginationChange:c,getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:S,toolbar:e.jsx(Wx,{table:S,refetch:h}),showPagination:!0})}function nh(){const{t:s}=V("order");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(ah,{})})]})]})}const rh=Object.freeze(Object.defineProperty({__proto__:null,default:nh},Symbol.toStringTag,{value:"Module"}));function lh({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(We,{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:y("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(ot,{className:y("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const ih=x.object({id:x.coerce.number().nullable().optional(),name:x.string().min(1,"请输入优惠券名称"),code:x.string().nullable(),type:x.coerce.number(),value:x.coerce.number(),started_at:x.coerce.number(),ended_at:x.coerce.number(),limit_use:x.union([x.string(),x.number()]).nullable(),limit_use_with_user:x.union([x.string(),x.number()]).nullable(),generate_count:x.coerce.number().nullable().optional(),limit_plan_ids:x.array(x.coerce.number()).default([]).nullable(),limit_period:x.array(x.nativeEnum(Gt)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),jr={name:"",code:null,type:hs.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:null,limit_use_with_user:null,limit_plan_ids:[],limit_period:[],generate_count:null};function li({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=V("coupon"),[d,u]=m.useState(!1),o=a??d,c=i??u,[h,k]=m.useState([]),C=we({resolver:Ce(ih),defaultValues:s||jr});m.useEffect(()=>{s&&C.reset(s)},[s,C]),m.useEffect(()=>{gs.getList().then(({data:f})=>k(f))},[]);const S=f=>{if(!f)return;const T=(E,g)=>{const w=new Date(g*1e3);return E.setHours(w.getHours(),w.getMinutes(),w.getSeconds()),Math.floor(E.getTime()/1e3)};f.from&&C.setValue("started_at",T(f.from,C.watch("started_at"))),f.to&&C.setValue("ended_at",T(f.to,C.watch("ended_at")))},p=async f=>{const T=await Sa.save(f);if(f.generate_count&&T){const E=new Blob([T],{type:"text/csv;charset=utf-8;"}),g=document.createElement("a");g.href=window.URL.createObjectURL(E),g.download=`coupons_${new Date().getTime()}.csv`,g.click(),window.URL.revokeObjectURL(g.href)}c(!1),t==="create"&&C.reset(jr),n()},_=(f,T)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:T}),e.jsx(D,{type:"datetime-local",step:"1",value:me(C.watch(f),"YYYY-MM-DDTHH:mm:ss"),onChange:E=>{const g=new Date(E.target.value);C.setValue(f,Math.floor(g.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(ge,{open:o,onOpenChange:c,children:[r&&e.jsx(as,{asChild:!0,children:r}),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(Se,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(p),className:"space-y-4",children:[e.jsx(b,{control:C.control,name:"name",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.name.label")}),e.jsx(D,{placeholder:l("form.name.placeholder"),...f}),e.jsx(L,{})]})}),t==="create"&&e.jsx(b,{control:C.control,name:"generate_count",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...f,value:f.value===void 0?"":f.value,onChange:T=>f.onChange(T.target.value===""?"":parseInt(T.target.value)),className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(L,{})]})}),(!C.watch("generate_count")||C.watch("generate_count")==null)&&e.jsx(b,{control:C.control,name:"code",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.code.label")}),e.jsx(D,{placeholder:l("form.code.placeholder"),...f,className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.code.description")}),e.jsx(L,{})]})}),e.jsxs(j,{children:[e.jsx(v,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(b,{control:C.control,name:"type",render:({field:f})=>e.jsxs(J,{value:f.value.toString(),onValueChange:T=>{const E=f.value,g=parseInt(T);f.onChange(g);const w=C.getValues("value");w&&(E===hs.AMOUNT&&g===hs.PERCENTAGE?C.setValue("value",w/100):E===hs.PERCENTAGE&&g===hs.AMOUNT&&C.setValue("value",w*100))},children:[e.jsx(W,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Q,{placeholder:l("form.type.placeholder")})}),e.jsx(Y,{children:Object.entries(jm).map(([T,E])=>e.jsx($,{value:T,children:l(`table.toolbar.types.${T}`)},T))})]})}),e.jsx(b,{control:C.control,name:"value",render:({field:f})=>{const T=f.value==null?"":C.watch("type")===hs.AMOUNT&&typeof f.value=="number"?(f.value/100).toString():f.value.toString();return e.jsx(D,{type:"number",placeholder:l("form.value.placeholder"),...f,value:T,onChange:E=>{const g=E.target.value;if(g===""){f.onChange("");return}const w=parseFloat(g);isNaN(w)||f.onChange(C.watch("type")===hs.AMOUNT?Math.round(w*100):w)},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")==hs.AMOUNT?"¥":"%"})})]})]}),e.jsxs(j,{children:[e.jsx(v,{children:l("form.validity.label")}),e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",className:y("w-full justify-start text-left font-normal",!C.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),me(C.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",me(C.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(Ze,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(ks,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:S,numberOfMonths:2})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-4",children:[_("started_at",l("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:l("form.validity.to")}),_("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(L,{})]}),e.jsx(b,{control:C.control,name:"limit_use",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...f,value:f.value===null?"":f.value,onChange:T=>f.onChange(T.target.value===""?null:parseInt(T.target.value)),className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:C.control,name:"limit_use_with_user",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...f,value:f.value===null?"":f.value,onChange:T=>f.onChange(T.target.value===""?null:parseInt(T.target.value)),className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:C.control,name:"limit_period",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.limitPeriod.label")}),e.jsx(kt,{options:Object.entries(Gt).filter(([T])=>isNaN(Number(T))).map(([T,E])=>({label:l(`coupon:period.${E}`),value:T})),onChange:T=>{if(T.length===0){f.onChange([]);return}const E=T.map(g=>Gt[g.value]);f.onChange(E)},value:(f.value||[]).map(T=>({label:l(`coupon:period.${T}`),value:Object.entries(Gt).find(([E,g])=>g===T)?.[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(O,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(L,{})]})}),e.jsx(b,{control:C.control,name:"limit_plan_ids",render:({field:f})=>e.jsxs(j,{children:[e.jsx(v,{children:l("form.limitPlan.label")}),e.jsx(kt,{options:h?.map(T=>({label:T.name,value:T.id.toString()}))||[],onChange:T=>f.onChange(T.map(E=>Number(E.value))),value:(h||[]).filter(T=>(f.value||[]).includes(T.id)).map(T=>({label:T.name,value:T.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(L,{})]})}),e.jsx(Le,{children:e.jsx(P,{type:"submit",disabled:C.formState.isSubmitting,children:C.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function oh({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(li,{refetch:n,dialogTrigger:e.jsxs(P,{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(lh,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:hs.AMOUNT,label:r(`table.toolbar.types.${hs.AMOUNT}`)},{value:hs.PERCENTAGE,label:r(`table.toolbar.types.${hs.PERCENTAGE}`)}]}),t&&e.jsxs(P,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]})]})}const ii=m.createContext(void 0);function ch({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=u=>{i(u),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(ii.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(li,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function dh(){const s=m.useContext(ii);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(Z,{defaultChecked:t.original.show,onCheckedChange:r=>{Sa.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,u=i>d,o=ie.jsx(z,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=dh();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(ps,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{Sa.drop({id:t.original.id}).then(({data:a})=>{a&&(A.success("删除成功"),s())})},children:e.jsxs(P,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ds,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete")})]})})]})}}]};function uh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=ne({queryKey:["couponList",u,a,l],queryFn:()=>Sa.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),k=ss({data:h?.data??[],columns:mh(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((h?.total??0)/u.pageSize),rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:o,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ch,{refetch:c,children:e.jsx("div",{className:"space-y-4",children:e.jsx(xs,{table:k,toolbar:e.jsx(oh,{table:k,refetch:c})})})})}function xh(){const{t:s}=V("coupon");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(uh,{})})]})]})}const hh=Object.freeze(Object.defineProperty({__proto__:null,default:xh},Symbol.toStringTag,{value:"Module"})),gh=1,fh=1e6;let ln=0;function ph(){return ln=(ln+1)%Number.MAX_SAFE_INTEGER,ln.toString()}const on=new Map,vr=s=>{if(on.has(s))return;const n=setTimeout(()=>{on.delete(s),Wt({type:"REMOVE_TOAST",toastId:s})},fh);on.set(s,n)},jh=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,gh)};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?vr(t):s.toasts.forEach(r=>{vr(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)}}},fa=[];let pa={toasts:[]};function Wt(s){pa=jh(pa,s),fa.forEach(n=>{n(pa)})}function vh({...s}){const n=ph(),t=a=>Wt({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>Wt({type:"DISMISS_TOAST",toastId:n});return Wt({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function oi(){const[s,n]=m.useState(pa);return m.useEffect(()=>(fa.push(n),()=>{const t=fa.indexOf(n);t>-1&&fa.splice(t,1)}),[s]),{...s,toast:vh,dismiss:t=>Wt({type:"DISMISS_TOAST",toastId:t})}}function bh({open:s,onOpenChange:n,table:t}){const{t:r}=V("user"),{toast:a}=oi(),[i,l]=m.useState(!1),[d,u]=m.useState(""),[o,c]=m.useState(""),h=async()=>{if(!d||!o){a({title:r("messages.error"),description:r("messages.send_mail.required_fields"),variant:"destructive"});return}try{l(!0),await Ps.sendMail({subject:d,content:o,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),a({title:r("messages.success"),description:r("messages.send_mail.success")}),n(!1),u(""),c("")}catch{a({title:r("messages.error"),description:r("messages.send_mail.failed"),variant:"destructive"})}finally{l(!1)}};return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(de,{className:"sm:max-w-[500px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:r("send_mail.title")}),e.jsx(Ve,{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:d,onChange:k=>u(k.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(Ds,{id:"content",value:o,onChange:k=>c(k.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(Le,{children:e.jsx(G,{type:"submit",onClick:h,disabled:i,children:r(i?"send_mail.sending":"send_mail.send")})})]})})}function yh({trigger:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),[a,i]=m.useState(30),{data:l,isLoading:d}=ne({queryKey:["trafficResetStats",a],queryFn:()=>Xt.getStats({days:a}),enabled:t}),u=[{title:n("traffic_reset.stats.total_resets"),value:l?.data?.total_resets||0,icon:Ut,color:"text-blue-600",bgColor:"bg-blue-100"},{title:n("traffic_reset.stats.auto_resets"),value:l?.data?.auto_resets||0,icon:pl,color:"text-green-600",bgColor:"bg-green-100"},{title:n("traffic_reset.stats.manual_resets"),value:l?.data?.manual_resets||0,icon:Cs,color:"text-orange-600",bgColor:"bg-orange-100"},{title:n("traffic_reset.stats.cron_resets"),value:l?.data?.cron_resets||0,icon:Pn,color:"text-purple-600",bgColor:"bg-purple-100"}],o=[{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(ge,{open:t,onOpenChange:r,children:[e.jsx(as,{asChild:!0,children:s}),e.jsxs(de,{className:"max-w-2xl",children:[e.jsxs(ve,{children:[e.jsxs(fe,{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"h-5 w-5"}),n("traffic_reset.stats.title")]}),e.jsx(Ve,{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(J,{value:a.toString(),onValueChange:c=>i(Number(c)),children:[e.jsx(W,{className:"w-[180px]",children:e.jsx(Q,{})}),e.jsx(Y,{children:o.map(c=>e.jsx($,{value:c.value.toString(),children:c.label},c.value))})]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Yt,{className:"h-6 w-6 animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.map((c,h)=>e.jsxs(Ee,{className:"relative overflow-hidden",children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ge,{className:"text-sm font-medium text-muted-foreground",children:c.title}),e.jsx("div",{className:`rounded-lg p-2 ${c.bgColor}`,children:e.jsx(c.icon,{className:`h-4 w-4 ${c.color}`})})]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"text-2xl font-bold",children:c.value.toLocaleString()}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n("traffic_reset.stats.in_period",{days:a})})]})]},h))}),l?.data&&e.jsxs(Ee,{children:[e.jsxs(Fe,{children:[e.jsx(Ge,{className:"text-lg",children:n("traffic_reset.stats.breakdown")}),e.jsx(Os,{children:n("traffic_reset.stats.breakdown_description")})]}),e.jsx(Ie,{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 Nh=x.object({email_prefix:x.string().optional(),email_suffix:x.string().min(1),password:x.string().optional(),expired_at:x.number().optional().nullable(),plan_id:x.number().nullable(),generate_count:x.number().optional().nullable(),download_csv:x.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"]}),_h={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0,download_csv:!1};function wh({refetch:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),a=we({resolver:Ce(Nh),defaultValues:_h,mode:"onChange"}),[i,l]=m.useState([]);return m.useEffect(()=>{t&&gs.getList().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(ge,{open:t,onOpenChange:r,children:[e.jsx(as,{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(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:n("generate.title")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...a,children:[e.jsxs(j,{children:[e.jsx(v,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(b,{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(b,{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(b,{control:a.control,name:"password",render:({field:d})=>e.jsxs(j,{children:[e.jsx(v,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(L,{})]})}),e.jsx(b,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(j,{className:"flex flex-col",children:[e.jsx(v,{children:n("generate.form.expire_time")}),e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(N,{children:e.jsxs(G,{variant:"outline",className:y("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?me(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(Cs,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(Ze,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(nd,{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:u=>{u&&d.onChange(u?.getTime()/1e3)}})})]})]})]})}),e.jsx(b,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(j,{children:[e.jsx(v,{children:n("generate.form.subscription")}),e.jsx(N,{children:e.jsxs(J,{value:d.value?d.value.toString():"null",onValueChange:u=>d.onChange(u==="null"?null:parseInt(u)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx($,{value:"null",children:n("generate.form.subscription_none")}),i.map(u=>e.jsx($,{value:u.id.toString(),children:u.name},u.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(b,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(j,{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:u=>d.onChange(u.target.value?parseInt(u.target.value):null)})]})}),a.watch("generate_count")&&e.jsx(b,{control:a.control,name:"download_csv",render:({field:d})=>e.jsxs(j,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(N,{children:e.jsx(An,{checked:d.value,onCheckedChange:d.onChange})}),e.jsx(v,{children:n("generate.form.download_csv")})]})})]}),e.jsxs(Le,{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 u=await Ps.generate(d);if(u&&u instanceof Blob){const o=window.URL.createObjectURL(u),c=document.createElement("a");c.href=o,c.download=`users_${new Date().getTime()}.csv`,document.body.appendChild(c),c.click(),c.remove(),window.URL.revokeObjectURL(o),A.success(n("generate.form.success")),a.reset(),s(),r(!1)}}else{const{data:u}=await Ps.generate(d);u&&(A.success(n("generate.form.success")),a.reset(),s(),r(!1))}})(),children:n("generate.form.submit")})]})]})]})}const qn=Tr,ci=Dr,Ch=Pr,di=m.forwardRef(({className:s,...n},t)=>e.jsx(Da,{className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:t}));di.displayName=Da.displayName;const Sh=it("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"}}),Ba=m.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(Ch,{children:[e.jsx(di,{}),e.jsxs(Pa,{ref:a,className:y(Sh({side:s}),n),...r,children:[e.jsxs(Nn,{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(ms,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));Ba.displayName=Pa.displayName;const Ga=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ga.displayName="SheetHeader";const mi=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});mi.displayName="SheetFooter";const Wa=m.forwardRef(({className:s,...n},t)=>e.jsx(La,{ref:t,className:y("text-lg font-semibold text-foreground",s),...n}));Wa.displayName=La.displayName;const Ya=m.forwardRef(({className:s,...n},t)=>e.jsx(Ea,{ref:t,className:y("text-sm text-muted-foreground",s),...n}));Ya.displayName=Ea.displayName;function kh({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=V("user"),{toast:i}=oi(),l=s.getState().columnFilters.length>0,[d,u]=m.useState([]),[o,c]=m.useState(!1),[h,k]=m.useState(!1),[C,S]=m.useState(!1),[p,_]=m.useState(!1),f=async()=>{try{const ee=await Ps.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),te=ee;console.log(ee);const q=new Blob([te],{type:"text/csv;charset=utf-8;"}),F=window.URL.createObjectURL(q),X=document.createElement("a");X.href=F,X.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(X),X.click(),X.remove(),window.URL.revokeObjectURL(F),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},T=async()=>{try{_(!0),await Ps.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{_(!1),S(!1)}},E=[{label:a("filter.fields.email"),value:"email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.id"),value:"id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:a("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{label:a("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.token"),value:"token",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.banned"),value:"banned",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],options:[{label:a("filter.status.normal"),value:"0"},{label:a("filter.status.banned"),value:"1"}]},{label:a("filter.fields.remark"),value:"remarks",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.inviter_email"),value:"invite_user.email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]}],g=ee=>ee*1024*1024*1024,w=ee=>ee/(1024*1024*1024),R=()=>{u([...d,{field:"",operator:"",value:""}])},H=ee=>{u(d.filter((te,q)=>q!==ee))},I=(ee,te,q)=>{const F=[...d];if(F[ee]={...F[ee],[te]:q},te==="field"){const X=E.find(ys=>ys.value===q);X&&(F[ee].operator=X.operators[0].value,F[ee].value=X.type==="boolean"?!1:"")}u(F)},K=(ee,te)=>{const q=E.find(F=>F.value===ee.field);if(!q)return null;switch(q.type){case"text":return e.jsx(D,{placeholder:a("filter.sheet.value"),value:ee.value,onChange:F=>I(te,"value",F.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:q.unit}),value:q.unit==="GB"?w(ee.value||0):ee.value,onChange:F=>{const X=Number(F.target.value);I(te,"value",q.unit==="GB"?g(X):X)}}),q.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:q.unit})]});case"date":return e.jsx(ks,{mode:"single",selected:ee.value,onSelect:F=>I(te,"value",F),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(J,{value:ee.value,onValueChange:F=>I(te,"value",F),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.value")})}),e.jsx(Y,{children:q.useOptions?r.map(F=>e.jsx($,{value:F.value.toString(),children:F.label},F.value)):q.options?.map(F=>e.jsx($,{value:F.value.toString(),children:F.label},F.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Z,{checked:ee.value,onCheckedChange:F=>I(te,"value",F)}),e.jsx(Ae,{children:ee.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},ae=()=>{const ee=d.filter(te=>te.field&&te.operator&&te.value!=="").map(te=>{const q=E.find(X=>X.value===te.field);let F=te.value;return te.operator==="contains"?{id:te.field,value:F}:(q?.type==="date"&&F instanceof Date&&(F=Math.floor(F.getTime()/1e3)),q?.type==="boolean"&&(F=F?1:0),{id:te.field,value:`${te.operator}:${F}`})});s.setColumnFilters(ee),c(!1)};return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsx(wh,{refetch:n}),e.jsx(D,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:ee=>s.getColumn("email")?.setFilterValue(ee.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(qn,{open:o,onOpenChange:c,children:[e.jsx(ci,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(rd,{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(Ba,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(Ga,{children:[e.jsx(Wa,{children:a("filter.sheet.title")}),e.jsx(Ya,{children:a("filter.sheet.description")})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:a("filter.sheet.conditions")}),e.jsx(P,{variant:"outline",size:"sm",onClick:R,children:a("filter.sheet.add")})]}),e.jsx(lt,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((ee,te)=>e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:a("filter.sheet.condition",{number:te+1})}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>H(te),children:e.jsx(ms,{className:"h-4 w-4"})})]}),e.jsxs(J,{value:ee.field,onValueChange:q=>I(te,"field",q),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.field")})}),e.jsx(Y,{children:e.jsx(rs,{children:E.map(q=>e.jsx($,{value:q.value,className:"cursor-pointer",children:q.label},q.value))})})]}),ee.field&&e.jsxs(J,{value:ee.operator,onValueChange:q=>I(te,"operator",q),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.operator")})}),e.jsx(Y,{children:E.find(q=>q.value===ee.field)?.operators.map(q=>e.jsx($,{value:q.value,children:q.label},q.value))})]}),ee.field&&ee.operator&&K(ee,te)]},te))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(P,{variant:"outline",onClick:()=>{u([]),c(!1)},children:a("filter.sheet.reset")}),e.jsx(P,{onClick:ae,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(P,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[a("filter.sheet.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]}),e.jsxs(zs,{modal:!1,children:[e.jsx($s,{asChild:!0,children:e.jsx(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(Ls,{children:[e.jsx(_e,{onClick:()=>k(!0),children:a("actions.send_email")}),e.jsx(_e,{onClick:f,children:a("actions.export_csv")}),e.jsx(rt,{}),e.jsx(_e,{asChild:!0,children:e.jsx(yh,{trigger:e.jsx("div",{className:"w-full cursor-pointer px-2 py-1.5 text-sm",children:a("actions.traffic_reset_stats")})})}),e.jsx(rt,{}),e.jsx(_e,{onClick:()=>S(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(bh,{open:h,onOpenChange:k,table:s}),e.jsx(On,{open:C,onOpenChange:S,children:e.jsxs(Oa,{children:[e.jsxs(za,{children:[e.jsx(Aa,{children:a("actions.confirm_ban.title")}),e.jsx(qa,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs($a,{children:[e.jsx(Ua,{disabled:p,children:a("actions.confirm_ban.cancel")}),e.jsx(Ha,{onClick:T,disabled:p,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(p?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const ui=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"})}),xi=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42"})}),Th=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M17 11H9.41l3.3-3.29a1 1 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l5 5a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L9.41 13H17a1 1 0 0 0 0-2"})}),Dh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M17.92 11.62a1 1 0 0 0-.21-.33l-5-5a1 1 0 0 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l5-5a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76"})}),cn=[{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:wd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ui,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:Oe(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(xi,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:Oe(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:Oe(n)})}}];function hi({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:u}=ne({queryKey:["userStats",s,i,r],queryFn:()=>r?Ps.getStats({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),o=ss({data:d?.data??[],columns:cn,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:ts(),onPaginationChange:l});return e.jsxs(ge,{open:r,onOpenChange:a,children:[e.jsx(as,{asChild:!0,children:n}),e.jsxs(de,{className:"sm:max-w-[700px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(Rn,{children:[e.jsx(Fn,{children:o.getHeaderGroups().map(c=>e.jsx(Bs,{children:c.headers.map(h=>e.jsx(Vn,{className:y("h-10 px-2 text-xs",h.id==="total"&&"text-right"),children:h.isPlaceholder?null:ba(h.column.columnDef.header,h.getContext())},h.id))},c.id))}),e.jsx(In,{children:u?Array.from({length:i.pageSize}).map((c,h)=>e.jsx(Bs,{children:Array.from({length:cn.length}).map((k,C)=>e.jsx(_t,{className:"p-2",children:e.jsx(je,{className:"h-6 w-full"})},C))},h)):o.getRowModel().rows?.length?o.getRowModel().rows.map(c=>e.jsx(Bs,{"data-state":c.getIsSelected()&&"selected",className:"h-10",children:c.getVisibleCells().map(h=>e.jsx(_t,{className:"px-2",children:ba(h.column.columnDef.cell,h.getContext())},h.id))},c.id)):e.jsx(Bs,{children:e.jsx(_t,{colSpan:cn.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(J,{value:`${o.getState().pagination.pageSize}`,onValueChange:c=>{o.setPageSize(Number(c))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:o.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50].map(c=>e.jsx($,{value:`${c}`,children:c},c))})]}),e.jsx("p",{className:"text-sm font-medium",children:t("trafficRecord.records")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex w-[100px] items-center justify-center text-sm",children:t("trafficRecord.page",{current:o.getState().pagination.pageIndex+1,total:o.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||u,children:e.jsx(Th,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||u,children:e.jsx(Dh,{className:"h-4 w-4"})})]})]})]})]})]})]})}function Ph({user:s,trigger:n,onSuccess:t}){const{t:r}=V("user"),[a,i]=m.useState(!1),[l,d]=m.useState(""),[u,o]=m.useState(!1),{data:c,isLoading:h}=ne({queryKey:["trafficResetHistory",s.id],queryFn:()=>Xt.getUserHistory(s.id,{limit:10}),enabled:a}),k=async()=>{try{o(!0);const{data:p}=await Xt.resetUser({user_id:s.id,reason:l.trim()||void 0});p&&(A.success(r("traffic_reset.reset_success")),i(!1),d(""),t?.())}catch(p){A.error(p?.response?.data?.message||r("traffic_reset.reset_failed"))}finally{o(!1)}},C=p=>{switch(p){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"}},S=p=>{switch(p){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(ge,{open:a,onOpenChange:i,children:[e.jsx(as,{asChild:!0,children:n}),e.jsxs(de,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs(ve,{children:[e.jsxs(fe,{className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-5 w-5"}),r("traffic_reset.title")]}),e.jsx(Ve,{children:r("traffic_reset.description",{email:s.email})})]}),e.jsxs(Dt,{defaultValue:"reset",className:"w-full",children:[e.jsxs(dt,{className:"grid w-full grid-cols-2",children:[e.jsxs(Xe,{value:"reset",className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-4 w-4"}),r("traffic_reset.tabs.reset")]}),e.jsxs(Xe,{value:"history",className:"flex items-center gap-2",children:[e.jsx(nr,{className:"h-4 w-4"}),r("traffic_reset.tabs.history")]})]}),e.jsxs(Ss,{value:"reset",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Ge,{className:"text-lg flex items-center gap-2",children:[e.jsx(_l,{className:"h-5 w-5"}),r("traffic_reset.user_info")]})}),e.jsx(Ie,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.email")}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.used_traffic")}),e.jsx("p",{className:"font-medium",children:Oe(s.total_used)})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.total_traffic")}),e.jsx("p",{className:"font-medium",children:Oe(s.transfer_enable)})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.expire_time")}),e.jsx("p",{className:"font-medium",children:s.expired_at?me(s.expired_at):r("columns.expire_status.permanent")})]})]})})]}),e.jsxs(Ee,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Ge,{className:"text-lg flex items-center gap-2 text-amber-800",children:[e.jsx(Ht,{className:"h-5 w-5"}),r("traffic_reset.warning.title")]})}),e.jsx(Ie,{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(Ae,{htmlFor:"reason",children:r("traffic_reset.reason.label")}),e.jsx(Ds,{id:"reason",placeholder:r("traffic_reset.reason.placeholder"),value:l,onChange:p=>d(p.target.value),className:"min-h-[80px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("traffic_reset.reason.optional")})]}),e.jsxs(Le,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:r("common:cancel")}),e.jsx(G,{onClick:k,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Yt,{className:"mr-2 h-4 w-4 animate-spin"}),r("traffic_reset.resetting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),r("traffic_reset.confirm_reset")]})})]})]}),e.jsx(Ss,{value:"history",className:"space-y-4",children:h?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Yt,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[c?.data?.user&&e.jsxs(Ee,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsx(Ge,{className:"text-lg",children:r("traffic_reset.history.summary")})}),e.jsx(Ie,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.reset_count")}),e.jsx("p",{className:"font-medium",children:c.data.user.reset_count})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.last_reset")}),e.jsx("p",{className:"font-medium",children:c.data.user.last_reset_at?me(c.data.user.last_reset_at):r("traffic_reset.history.never")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.next_reset")}),e.jsx("p",{className:"font-medium",children:c.data.user.next_reset_at?me(c.data.user.next_reset_at):r("traffic_reset.history.no_schedule")})]})]})})]}),e.jsxs(Ee,{children:[e.jsxs(Fe,{className:"pb-3",children:[e.jsx(Ge,{className:"text-lg",children:r("traffic_reset.history.records")}),e.jsx(Os,{children:r("traffic_reset.history.recent_records")})]}),e.jsx(Ie,{children:e.jsx(lt,{className:"h-[300px]",children:c?.data?.history?.length?e.jsx("div",{className:"space-y-3",children:c.data.history.map((p,_)=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between p-3 rounded-lg border bg-card",children:e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:C(p.reset_type),children:p.reset_type_name}),e.jsx(U,{variant:"outline",className:S(p.trigger_source),children:p.trigger_source_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs(Ae,{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Pn,{className:"h-3 w-3"}),r("traffic_reset.history.reset_time")]}),e.jsx("p",{className:"font-medium",children:me(p.reset_time)})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.traffic_cleared")}),e.jsx("p",{className:"font-medium text-destructive",children:p.old_traffic.formatted})]})]})]})}),_e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M5 18h4.24a1 1 0 0 0 .71-.29l6.92-6.93L19.71 8a1 1 0 0 0 0-1.42l-4.24-4.29a1 1 0 0 0-1.42 0l-2.82 2.83l-6.94 6.93a1 1 0 0 0-.29.71V17a1 1 0 0 0 1 1m9.76-13.59l2.83 2.83l-1.42 1.42l-2.83-2.83ZM6 13.17l5.93-5.93l2.83 2.83L8.83 16H6ZM21 20H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2"})}),Rh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M19 11h-6V5a1 1 0 0 0-2 0v6H5a1 1 0 0 0 0 2h6v6a1 1 0 0 0 2 0v-6h6a1 1 0 0 0 0-2"})}),Fh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"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"})}),br=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"})}),Ih=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"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"})}),Vh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"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"})}),Mh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2m0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1"})}),Oh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M20 6h-4V5a3 3 0 0 0-3-3h-2a3 3 0 0 0-3 3v1H4a1 1 0 0 0 0 2h1v11a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8h1a1 1 0 0 0 0-2M10 5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1h-4Zm7 14a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V8h10Z"})}),zh=(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,u=Math.floor(Date.now()/1e3-l);let o=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:me(l)});if(!d&&l!==0){const c=Math.floor(u/60),h=Math.floor(c/60),k=Math.floor(h/24);k>0?o+=` +`);u.onChange(c)}})})}),e.jsx(E,{})]})}),e.jsx(v,{control:i.control,name:"action",render:({field:u})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsxs(J,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(Y,{children:[e.jsx($,{value:"block",children:a("actions.block")}),e.jsx($,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(E,{})]})}),i.watch("action")==="dns"&&e.jsx(v,{control:i.control,name:"action_value",render:({field:u})=>e.jsxs(p,{children:[e.jsx(j,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(y,{children:e.jsx(P,{type:"text",placeholder:a("form.dnsPlaceholder"),...u})})})]})}),e.jsxs(Le,{children:[e.jsx(Gs,{asChild:!0,children:e.jsx(L,{variant:"outline",children:a("form.cancel")})}),e.jsx(L,{type:"submit",onClick:()=>{const u=i.getValues(),o={...u,match:Array.isArray(u.match)?u.match.filter(c=>c.trim()!==""):[]};Va.save(o).then(({data:c})=>{c&&(d(!1),s&&s(),A.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function Rx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=V("route");return e.jsx("div",{className:"flex items-center justify-between ",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[e.jsx(ai,{refetch:n}),e.jsx(P,{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(ms,{className:"ml-2 h-4 w-4"})]})]})})}function Ex({columns:s,data:n,refetch:t}){const[r,a]=m.useState({}),[i,l]=m.useState({}),[d,u]=m.useState([]),[o,c]=m.useState([]),h=ss({data:n,columns:s,state:{sorting:o,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:c,onColumnFiltersChange:u,onColumnVisibilityChange:l,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:h,toolbar:k=>e.jsx(Rx,{table:k,refetch:t})})}const Fx=s=>{const{t:n}=V("route"),t={block:{icon:Qc,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:Xc,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:b("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(ai,{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(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(ps,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Va.drop({id:r.original.id}).then(({data:a})=>{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(ds,{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 Ix(){const{t:s}=V("route"),[n,t]=m.useState([]);function r(){Va.getList().then(({data:a})=>{t(a)})}return m.useEffect(()=>{r()},[]),e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(Ex,{data:n,columns:Fx(r),refetch:r})})]})]})}const Vx=Object.freeze(Object.defineProperty({__proto__:null,default:Ix},Symbol.toStringTag,{value:"Module"})),ni=m.createContext(void 0);function Mx({children:s,refreshData:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null);return e.jsx(ni.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function $n(){const s=m.useContext(ni);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function Ox({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=$n(),{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(P,{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 pr={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},zx=s=>{const{t:n}=V("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ea,{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(Z,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{gs.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(Z,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{gs.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(Z,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{gs.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(be,{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(ja,{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(be,{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(Zc,{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:b("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 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:b("px-2 py-0.5 font-medium transition-colors text-nowrap",pr[l].color,pr[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(z,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=$n();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(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(ps,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{gs.drop({id:t.original.id}).then(({data:i})=>{i&&(A.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(ds,{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")})]})})]})}}]},$x=x.object({id:x.number().nullable(),group_id:x.union([x.number(),x.string()]).nullable().optional(),name:x.string().min(1).max(250),content:x.string().nullable().optional(),transfer_enable:x.union([x.number().min(0),x.string().min(1)]),prices:x.object({monthly:x.union([x.number(),x.string()]).nullable().optional(),quarterly:x.union([x.number(),x.string()]).nullable().optional(),half_yearly:x.union([x.number(),x.string()]).nullable().optional(),yearly:x.union([x.number(),x.string()]).nullable().optional(),two_yearly:x.union([x.number(),x.string()]).nullable().optional(),three_yearly:x.union([x.number(),x.string()]).nullable().optional(),onetime:x.union([x.number(),x.string()]).nullable().optional(),reset_traffic:x.union([x.number(),x.string()]).nullable().optional()}).default({}),speed_limit:x.union([x.number(),x.string()]).nullable().optional(),capacity_limit:x.union([x.number(),x.string()]).nullable().optional(),device_limit:x.union([x.number(),x.string()]).nullable().optional(),force_update:x.boolean().optional(),reset_traffic_method:x.number().nullable(),users_count:x.number().optional(),active_users_count:x.number().optional(),group:x.object({id:x.number(),name:x.string()}).optional()}),An=m.forwardRef(({className:s,...n},t)=>e.jsx(vl,{ref:t,className:b("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(ed,{className:b("flex items-center justify-center text-current"),children:e.jsx(ot,{className:"h-4 w-4"})})}));An.displayName=vl.displayName;const ma={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},ua={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},Ax=[{value:null,label:"follow_system"},{value:0,label:"monthly_first"},{value:1,label:"monthly_reset"},{value:2,label:"no_reset"},{value:3,label:"yearly_first"},{value:4,label:"yearly_reset"}];function qx(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=$n(),[i,l]=m.useState(!1),{t:d}=V("subscribe"),u=we({resolver:Ce($x),defaultValues:{...ma,...t||{}},mode:"onChange"});m.useEffect(()=>{t?u.reset({...ma,...t}):u.reset(ma)},[t,u]);const o=new Tn({html:!0}),[c,h]=m.useState();async function k(){mt.getList().then(({data:f})=>{h(f)})}m.useEffect(()=>{s&&k()},[s]);const C=f=>{if(isNaN(f))return;const N=Object.entries(ua).reduce((_,[T,D])=>{const g=f*D.months*D.discount;return{..._,[T]:g.toFixed(2)}},{});u.setValue("prices",N,{shouldDirty:!0})},S=()=>{n(!1),r(null),u.reset(ma)};return e.jsx(ge,{open:s,onOpenChange:S,children:e.jsxs(de,{children:[e.jsxs(ve,{children:[e.jsx(fe,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...u,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"name",render:({field:f})=>e.jsxs(p,{children:[e.jsx(j,{children:d("plan.form.name.label")}),e.jsx(y,{children:e.jsx(P,{placeholder:d("plan.form.name.placeholder"),...f})}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"group_id",render:({field:f})=>e.jsxs(p,{children:[e.jsxs(j,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(Ka,{dialogTrigger:e.jsx(L,{variant:"link",children:d("plan.form.group.add")}),refetch:k})]}),e.jsxs(J,{value:f.value?.toString()??"",onValueChange:N=>f.onChange(N?Number(N):null),children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(Y,{children:c?.map(N=>e.jsx($,{value:N.id.toString(),children:N.name},N.id))})]}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"transfer_enable",render:({field:f})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(P,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...f})}),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(E,{})]})}),e.jsx(v,{control:u.control,name:"speed_limit",render:({field:f})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(P,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...f,value:f.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(E,{})]})}),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(P,{type:"number",placeholder:d("plan.form.price.base_price"),className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:f=>{const N=parseFloat(f.target.value);C(N)}})]}),e.jsx(be,{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 f=Object.keys(ua).reduce((N,_)=>({...N,[_]:""}),{});u.setValue("prices",f,{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(ua).filter(([f])=>!["onetime","reset_traffic"].includes(f)).map(([f,N])=>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(v,{control:u.control,name:`prices.${f}`,render:({field:_})=>e.jsxs(p,{children:[e.jsxs(j,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${f}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",N.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:N.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:"0.00",min:0,..._,value:_.value??"",onChange:T=>_.onChange(T.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"})})]})]})})},f))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(ua).filter(([f])=>["onetime","reset_traffic"].includes(f)).map(([f,N])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(v,{control:u.control,name:`prices.${f}`,render:({field:_})=>e.jsx(p,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(j,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${f}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(f==="onetime"?"plan.form.price.onetime_desc":"plan.form.price.reset_desc")})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:"0.00",min:0,..._,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"})})]})]})})})},f))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(v,{control:u.control,name:"device_limit",render:({field:f})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(P,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...f,value:f.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(E,{})]})}),e.jsx(v,{control:u.control,name:"capacity_limit",render:({field:f})=>e.jsxs(p,{className:"flex-1",children:[e.jsx(j,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(y,{children:e.jsx(P,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...f,value:f.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(E,{})]})})]}),e.jsx(v,{control:u.control,name:"reset_traffic_method",render:({field:f})=>e.jsxs(p,{children:[e.jsx(j,{children:d("plan.form.reset_method.label")}),e.jsxs(J,{value:f.value?.toString()??"null",onValueChange:N=>f.onChange(N=="null"?null:Number(N)),children:[e.jsx(y,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(Y,{children:Ax.map(N=>e.jsx($,{value:N.value?.toString()??"null",children:d(`plan.form.reset_method.options.${N.label}`)},N.value))})]}),e.jsx(O,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:u.control,name:"content",render:({field:f})=>{const[N,_]=m.useState(!1);return e.jsxs(p,{className:"space-y-2",children:[e.jsxs(j,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d("plan.form.content.label"),e.jsx(be,{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",onClick:()=>_(!N),children:N?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(N?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(be,{children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",onClick:()=>{f.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 ${N?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(y,{children:e.jsx(Dn,{style:{height:"400px"},value:f.value||"",renderHTML:T=>o.render(T),onChange:({text:T})=>f.onChange(T),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"})})}),N&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:d("plan.form.content.preview")}),e.jsx("div",{className:"prose prose-sm dark:prose-invert h-[400px] max-w-none overflow-y-auto rounded-md border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:o.render(f.value||"")}})})]})]}),e.jsx(O,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(E,{})]})}})]}),e.jsx(Le,{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(v,{control:u.control,name:"force_update",render:({field:f})=>e.jsxs(p,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(y,{children:e.jsx(An,{checked:f.value,onCheckedChange:f.onChange})}),e.jsx("div",{className:"",children:e.jsx(j,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(L,{type:"button",variant:"outline",onClick:S,children:d("plan.form.submit.cancel")}),e.jsx(L,{type:"submit",disabled:i,onClick:()=>{u.handleSubmit(async f=>{l(!0),gs.save(f).then(({data:N})=>{N&&(A.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),S(),a())}).finally(()=>{l(!1)})})()},children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function Hx(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,o]=m.useState(!1),[c,h]=m.useState({pageSize:20,pageIndex:0}),[k,C]=m.useState([]),{refetch:S}=ne({queryKey:["planList"],queryFn:async()=>{const{data:D}=await gs.getList();return C(D),D}});m.useEffect(()=>{r({"drag-handle":u}),h({pageSize:u?99999:10,pageIndex:0})},[u]);const f=(D,g)=>{u&&(D.dataTransfer.setData("text/plain",g.toString()),D.currentTarget.classList.add("opacity-50"))},N=(D,g)=>{if(!u)return;D.preventDefault(),D.currentTarget.classList.remove("bg-muted");const w=parseInt(D.dataTransfer.getData("text/plain"));if(w===g)return;const R=[...k],[H]=R.splice(w,1);R.splice(g,0,H),C(R)},_=async()=>{if(!u){o(!0);return}const D=k?.map(g=>g.id);gs.sort(D).then(()=>{A.success("排序保存成功"),o(!1),S()}).finally(()=>{o(!1)})},T=ss({data:k||[],columns:zx(S),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:c},enableRowSelection:!0,onPaginationChange:h,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}},pageCount:u?1:void 0});return e.jsx(Mx,{refreshData:S,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{table:T,toolbar:D=>e.jsx(Ox,{table:D,refetch:S,saveOrder:_,isSortMode:u}),draggable:u,onDragStart:f,onDragEnd:D=>D.currentTarget.classList.remove("opacity-50"),onDragOver:D=>{D.preventDefault(),D.currentTarget.classList.add("bg-muted")},onDragLeave:D=>D.currentTarget.classList.remove("bg-muted"),onDrop:N,showPagination:!u}),e.jsx(qx,{})]})})}function Ux(){const{t:s}=V("subscribe");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("plan.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("plan.page.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Hx,{})})]})]})}const Kx=Object.freeze(Object.defineProperty({__proto__:null,default:Ux},Symbol.toStringTag,{value:"Module"})),vt=[{value:le.PENDING,label:Vt[le.PENDING],icon:sd,color:Mt[le.PENDING]},{value:le.PROCESSING,label:Vt[le.PROCESSING],icon:bl,color:Mt[le.PROCESSING]},{value:le.COMPLETED,label:Vt[le.COMPLETED],icon:gn,color:Mt[le.COMPLETED]},{value:le.CANCELLED,label:Vt[le.CANCELLED],icon:yl,color:Mt[le.CANCELLED]},{value:le.DISCOUNTED,label:Vt[le.DISCOUNTED],icon:gn,color:Mt[le.DISCOUNTED]}],At=[{value:Ne.PENDING,label:ia[Ne.PENDING],icon:td,color:oa[Ne.PENDING]},{value:Ne.PROCESSING,label:ia[Ne.PROCESSING],icon:bl,color:oa[Ne.PROCESSING]},{value:Ne.VALID,label:ia[Ne.VALID],icon:gn,color:oa[Ne.VALID]},{value:Ne.INVALID,label:ia[Ne.INVALID],icon:yl,color:oa[Ne.INVALID]}];function xa({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(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(We,{onSelect:()=>{const u=new Set(i);d?u.delete(l.value):u.add(l.value);const o=Array.from(u);s?.setFilterValue(o.length?o:void 0)},children:[e.jsx("div",{className:b("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(ot,{className:b("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Bx=x.object({email:x.string().min(1),plan_id:x.number(),period:x.string(),total_amount:x.number()}),Gx={email:"",plan_id:0,total_amount:0,period:""};function ri({refetch:s,trigger:n,defaultValues:t}){const{t:r}=V("order"),[a,i]=m.useState(!1),l=we({resolver:Ce(Bx),defaultValues:{...Gx,...t},mode:"onChange"}),[d,u]=m.useState([]);return m.useEffect(()=>{a&&gs.getList().then(({data:o})=>{u(o)})},[a]),e.jsxs(ge,{open:a,onOpenChange:i,children:[e.jsx(as,{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(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:r("dialog.assignOrder")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...l,children:[e.jsx(v,{control:l.control,name:"email",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dialog.fields.userEmail")}),e.jsx(y,{children:e.jsx(P,{placeholder:r("dialog.placeholders.email"),...o})})]})}),e.jsx(v,{control:l.control,name:"plan_id",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(y,{children:e.jsxs(J,{value:o.value?o.value?.toString():void 0,onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(Y,{children:d.map(c=>e.jsx($,{value:c.id.toString(),children:c.name},c.id))})]})})]})}),e.jsx(v,{control:l.control,name:"period",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dialog.fields.orderPeriod")}),e.jsx(y,{children:e.jsxs(J,{value:o.value,onValueChange:o.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.period")})}),e.jsx(Y,{children:Object.keys(pm).map(c=>e.jsx($,{value:c,children:r(`period.${c}`)},c))})]})})]})}),e.jsx(v,{control:l.control,name:"total_amount",render:({field:o})=>e.jsxs(p,{children:[e.jsx(j,{children:r("dialog.fields.paymentAmount")}),e.jsx(y,{children:e.jsx(P,{type:"number",placeholder:r("dialog.placeholders.amount"),value:o.value/100,onChange:c=>o.onChange(parseFloat(c.currentTarget.value)*100)})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(L,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(L,{type:"submit",onClick:()=>{l.handleSubmit(o=>{tt.assign(o).then(({data:c})=>{c&&(s&&s(),l.reset(),i(!1),A.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function Wx({table:s,refetch:n}){const{t}=V("order"),r=s.getState().columnFilters.length>0,a=Object.values(Cs).filter(u=>typeof u=="number").map(u=>({label:t(`type.${Cs[u]}`),value:u,color:u===Cs.NEW?"green-500":u===Cs.RENEWAL?"blue-500":u===Cs.UPGRADE?"purple-500":"orange-500"})),i=Object.values(qe).map(u=>({label:t(`period.${u}`),value:u,color:u===qe.MONTH_PRICE?"slate-500":u===qe.QUARTER_PRICE?"cyan-500":u===qe.HALF_YEAR_PRICE?"indigo-500":u===qe.YEAR_PRICE?"violet-500":u===qe.TWO_YEAR_PRICE?"fuchsia-500":u===qe.THREE_YEAR_PRICE?"pink-500":u===qe.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(le).filter(u=>typeof u=="number").map(u=>({label:t(`status.${le[u]}`),value:u,icon:u===le.PENDING?vt[0].icon:u===le.PROCESSING?vt[1].icon:u===le.COMPLETED?vt[2].icon:u===le.CANCELLED?vt[3].icon:vt[4].icon,color:u===le.PENDING?"yellow-500":u===le.PROCESSING?"blue-500":u===le.COMPLETED?"green-500":u===le.CANCELLED?"red-500":"green-500"})),d=Object.values(Ne).filter(u=>typeof u=="number").map(u=>({label:t(`commission.${Ne[u]}`),value:u,icon:u===Ne.PENDING?At[0].icon:u===Ne.PROCESSING?At[1].icon:u===Ne.VALID?At[2].icon:At[3].icon,color:u===Ne.PENDING?"yellow-500":u===Ne.PROCESSING?"blue-500":u===Ne.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ri,{refetch:n}),e.jsx(P,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:u=>s.getColumn("trade_no")?.setFilterValue(u.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(xa,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(xa,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(xa,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(xa,{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(ms,{className:"ml-2 h-4 w-4"})]})]})}function Ke({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:b("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:b("text-sm",r),children:n||"-"})]})}function Yx({status:s}){const{t:n}=V("order"),t={[le.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[le.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[le.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[le.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[le.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(U,{variant:"secondary",className:b("font-medium",t[s]),children:n(`status.${le[s]}`)})}function Jx({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:u}=await tt.getInfo({id:s});i(u)}})()},[t,s]),e.jsxs(ge,{onOpenChange:r,open:t,children:[e.jsx(as,{asChild:!0,children:n}),e.jsxs(de,{className:"max-w-xl",children:[e.jsxs(ve,{className:"space-y-2",children:[e.jsx(fe,{className:"text-lg font-medium",children:l("dialog.title")}),e.jsx("div",{className:"flex items-center justify-between text-sm",children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-muted-foreground",children:[l("table.columns.tradeNo"),":",a?.trade_no]}),!!a?.status&&e.jsx(Yx,{status:a.status})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Ke,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Ys,{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(fn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(Ke,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(Ke,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(Ke,{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(Ke,{label:l("dialog.fields.paymentAmount"),value:Vs(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Te,{className:"my-2"}),e.jsx(Ke,{label:l("dialog.fields.balancePayment"),value:Vs(a?.balance_amount||0)}),e.jsx(Ke,{label:l("dialog.fields.discountAmount"),value:Vs(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(Ke,{label:l("dialog.fields.refundAmount"),value:Vs(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(Ke,{label:l("dialog.fields.deductionAmount"),value:Vs(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(Ke,{label:l("dialog.fields.createdAt"),value:me(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(Ke,{label:l("dialog.fields.updatedAt"),value:me(a?.updated_at),valueClassName:"font-mono text-xs"})]})]}),a?.commission_status===1&&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(Ke,{label:l("dialog.fields.commissionStatus"),value:e.jsx(U,{variant:"secondary",className:"bg-orange-100 font-medium text-orange-800 hover:bg-orange-100",children:l("dialog.commissionStatusActive")})}),e.jsx(Ke,{label:l("dialog.fields.commissionAmount"),value:Vs(a?.commission_balance||0),valueClassName:"font-medium text-orange-600"}),a?.actual_commission_balance&&e.jsx(Ke,{label:l("dialog.fields.actualCommissionAmount"),value:Vs(a?.actual_commission_balance||0),valueClassName:"font-medium text-orange-700"}),a?.invite_user&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"my-2"}),e.jsx(Ke,{label:l("dialog.fields.inviteUser"),value:e.jsxs(Ys,{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(fn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})}),e.jsx(Ke,{label:l("dialog.fields.inviteUserId"),value:a?.invite_user?.id,valueClassName:"font-mono text-xs"})]})]})]})]})]})]})}const Qx={[Cs.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Cs.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Cs.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Cs.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Xx={[qe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[qe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Zx=s=>le[s],eh=s=>Ne[s],sh=s=>Cs[s],th=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(Jx,{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(fn,{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=Qx[r];return e.jsx(U,{variant:"secondary",className:b("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=Xx[r];return e.jsx(U,{variant:"secondary",className:b("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(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsx(Ql,{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=vt.find(a=>a.value===t.getValue("status"));return r?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.icon&&e.jsx(r.icon,{className:`h-4 w-4 text-${r.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${Zx(r.value)}`)})]}),r.value===le.PENDING&&e.jsxs(zs,{modal:!0,children:[e.jsx($s,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ls,{align:"end",className:"w-[140px]",children:[e.jsx(_e,{className:"cursor-pointer",onClick:async()=>{await tt.markPaid({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(_e,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await tt.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=At.find(l=>l.value===t.getValue("commission_status"));return a==0||!i?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i.icon&&e.jsx(i.icon,{className:`h-4 w-4 text-${i.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${eh(i.value)}`)})]}),i.value===Ne.PENDING&&r===le.COMPLETED&&e.jsxs(zs,{modal:!0,children:[e.jsx($s,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ls,{align:"end",className:"w-[120px]",children:[e.jsx(_e,{className:"cursor-pointer",onClick:async()=>{await tt.update({trade_no:t.original.trade_no,commission_status:Ne.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(_e,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await tt.update({trade_no:t.original.trade_no,commission_status:Ne.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:me(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function ah(){const[s]=Nl(),[n,t]=m.useState({}),[r,a]=m.useState({}),[i,l]=m.useState([]),[d,u]=m.useState([]),[o,c]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const N=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([_,T])=>{const D=s.get(_);return D?{id:_,value:T==="number"?parseInt(D):D}:null}).filter(Boolean);N.length>0&&l(N)},[s]);const{refetch:h,data:k,isLoading:C}=ne({queryKey:["orderList",o,i,d],queryFn:()=>tt.getList({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),S=ss({data:k?.data??[],columns:th(h),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:o},rowCount:k?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:u,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),onPaginationChange:c,getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(xs,{table:S,toolbar:e.jsx(Wx,{table:S,refetch:h}),showPagination:!0})}function nh(){const{t:s}=V("order");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(ah,{})})]})]})}const rh=Object.freeze(Object.defineProperty({__proto__:null,default:nh},Symbol.toStringTag,{value:"Module"}));function lh({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fa,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(We,{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:b("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(ot,{className:b("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const ih=x.object({id:x.coerce.number().nullable().optional(),name:x.string().min(1,"请输入优惠券名称"),code:x.string().nullable(),type:x.coerce.number(),value:x.coerce.number(),started_at:x.coerce.number(),ended_at:x.coerce.number(),limit_use:x.union([x.string(),x.number()]).nullable(),limit_use_with_user:x.union([x.string(),x.number()]).nullable(),generate_count:x.coerce.number().nullable().optional(),limit_plan_ids:x.array(x.coerce.number()).default([]).nullable(),limit_period:x.array(x.nativeEnum(Gt)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),jr={name:"",code:null,type:hs.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},oh=[{label:"1周",days:7},{label:"2周",days:14},{label:"1个月",days:30},{label:"3个月",days:90},{label:"6个月",days:180},{label:"1年",days:365}];function li({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=V("coupon"),[d,u]=m.useState(!1),o=a??d,c=i??u,[h,k]=m.useState([]),C=we({resolver:Ce(ih),defaultValues:s||jr});m.useEffect(()=>{s&&C.reset(s)},[s,C]),m.useEffect(()=>{gs.getList().then(({data:T})=>k(T))},[]);const S=T=>{if(!T)return;const D=(g,w)=>{const R=new Date(w*1e3);return g.setHours(R.getHours(),R.getMinutes(),R.getSeconds()),Math.floor(g.getTime()/1e3)};T.from&&C.setValue("started_at",D(T.from,C.watch("started_at"))),T.to&&C.setValue("ended_at",D(T.to,C.watch("ended_at")))},f=T=>{const D=new Date,g=Math.floor(D.getTime()/1e3),w=Math.floor((D.getTime()+T*24*60*60*1e3)/1e3);C.setValue("started_at",g),C.setValue("ended_at",w)},N=async T=>{const D=await Sa.save(T);if(T.generate_count&&typeof D=="string"){const g=new Blob([D],{type:"text/csv;charset=utf-8;"}),w=document.createElement("a");w.href=window.URL.createObjectURL(g),w.download=`coupons_${new Date().getTime()}.csv`,w.click(),window.URL.revokeObjectURL(w.href)}c(!1),t==="create"&&C.reset(jr),n()},_=(T,D)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:D}),e.jsx(P,{type:"datetime-local",step:"1",value:me(C.watch(T),"YYYY-MM-DDTHH:mm:ss"),onChange:g=>{const w=new Date(g.target.value);C.setValue(T,Math.floor(w.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(ge,{open:o,onOpenChange:c,children:[r&&e.jsx(as,{asChild:!0,children:r}),e.jsxs(de,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(Se,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(N),className:"space-y-4",children:[e.jsx(v,{control:C.control,name:"name",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.name.label")}),e.jsx(P,{placeholder:l("form.name.placeholder"),...T}),e.jsx(E,{})]})}),t==="create"&&e.jsx(v,{control:C.control,name:"generate_count",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.generateCount.label")}),e.jsx(P,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...T,value:T.value??"",onChange:D=>T.onChange(D.target.value===""?null:parseInt(D.target.value)),className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(E,{})]})}),(!C.watch("generate_count")||C.watch("generate_count")==null)&&e.jsx(v,{control:C.control,name:"code",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.code.label")}),e.jsx(P,{placeholder:l("form.code.placeholder"),...T,value:T.value??"",className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.code.description")}),e.jsx(E,{})]})}),e.jsxs(p,{children:[e.jsx(j,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(v,{control:C.control,name:"type",render:({field:T})=>e.jsxs(J,{value:T.value.toString(),onValueChange:D=>{const g=T.value,w=parseInt(D);T.onChange(w);const R=C.getValues("value");R&&(g===hs.AMOUNT&&w===hs.PERCENTAGE?C.setValue("value",R/100):g===hs.PERCENTAGE&&w===hs.AMOUNT&&C.setValue("value",R*100))},children:[e.jsx(W,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Q,{placeholder:l("form.type.placeholder")})}),e.jsx(Y,{children:Object.entries(jm).map(([D,g])=>e.jsx($,{value:D,children:l(`table.toolbar.types.${D}`)},D))})]})}),e.jsx(v,{control:C.control,name:"value",render:({field:T})=>{const D=T.value==null?"":C.watch("type")===hs.AMOUNT&&typeof T.value=="number"?(T.value/100).toString():T.value.toString();return e.jsx(P,{type:"number",placeholder:l("form.value.placeholder"),...T,value:D,onChange:g=>{const w=g.target.value;if(w===""){T.onChange("");return}const R=parseFloat(w);isNaN(R)||T.onChange(C.watch("type")===hs.AMOUNT?Math.round(R*100):R)},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")==hs.AMOUNT?"¥":"%"})})]})]}),e.jsxs(p,{children:[e.jsx(j,{children:l("form.validity.label")}),e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:b("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:[me(C.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",me(C.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})]})}),e.jsxs(Ze,{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:"快速设置"}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-6",children:oh.map(T=>e.jsx(L,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>f(T.days),type:"button",children:T.label},T.days))})]}),e.jsx("div",{className:"hidden border-b border-border sm:block",children:e.jsx(vs,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:S,numberOfMonths:2})}),e.jsx("div",{className:"border-b border-border sm:hidden",children:e.jsx(vs,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:S,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:[_("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")}),_("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(E,{})]}),e.jsx(v,{control:C.control,name:"limit_use",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.limitUse.label")}),e.jsx(P,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...T,value:T.value??"",onChange:D=>T.onChange(D.target.value===""?null:parseInt(D.target.value)),className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:C.control,name:"limit_use_with_user",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.limitUseWithUser.label")}),e.jsx(P,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...T,value:T.value??"",onChange:D=>T.onChange(D.target.value===""?null:parseInt(D.target.value)),className:"h-9"}),e.jsx(O,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:C.control,name:"limit_period",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.limitPeriod.label")}),e.jsx(kt,{options:Object.entries(Gt).filter(([D])=>isNaN(Number(D))).map(([D,g])=>({label:l(`coupon:period.${g}`),value:D})),onChange:D=>{if(D.length===0){T.onChange([]);return}const g=D.map(w=>Gt[w.value]);T.onChange(g)},value:(T.value||[]).map(D=>({label:l(`coupon:period.${D}`),value:Object.entries(Gt).find(([g,w])=>w===D)?.[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(O,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(E,{})]})}),e.jsx(v,{control:C.control,name:"limit_plan_ids",render:({field:T})=>e.jsxs(p,{children:[e.jsx(j,{children:l("form.limitPlan.label")}),e.jsx(kt,{options:h?.map(D=>({label:D.name,value:D.id.toString()}))||[],onChange:D=>T.onChange(D.map(g=>Number(g.value))),value:(h||[]).filter(D=>(T.value||[]).includes(D.id)).map(D=>({label:D.name,value:D.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(E,{})]})}),e.jsx(Le,{children:e.jsx(L,{type:"submit",disabled:C.formState.isSubmitting,children:C.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function ch({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(li,{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(P,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(lh,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:hs.AMOUNT,label:r(`table.toolbar.types.${hs.AMOUNT}`)},{value:hs.PERCENTAGE,label:r(`table.toolbar.types.${hs.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(ms,{className:"ml-2 h-4 w-4"})]})]})}const ii=m.createContext(void 0);function dh({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=u=>{i(u),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(ii.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(li,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function mh(){const s=m.useContext(ii);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const uh=s=>{const{t:n}=V("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(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(Z,{defaultChecked:t.original.show,onCheckedChange:r=>{Sa.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,u=i>d,o=ie.jsx(z,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=mh();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(ct,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(ps,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{Sa.drop({id:t.original.id}).then(({data:a})=>{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(ds,{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 xh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=ne({queryKey:["couponList",u,a,l],queryFn:()=>Sa.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),k=ss({data:h?.data??[],columns:uh(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((h?.total??0)/u.pageSize),rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:o,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(dh,{refetch:c,children:e.jsx("div",{className:"space-y-4",children:e.jsx(xs,{table:k,toolbar:e.jsx(ch,{table:k,refetch:c})})})})}function hh(){const{t:s}=V("coupon");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(xh,{})})]})]})}const gh=Object.freeze(Object.defineProperty({__proto__:null,default:hh},Symbol.toStringTag,{value:"Module"})),fh=1,ph=1e6;let ln=0;function jh(){return ln=(ln+1)%Number.MAX_SAFE_INTEGER,ln.toString()}const on=new Map,vr=s=>{if(on.has(s))return;const n=setTimeout(()=>{on.delete(s),Wt({type:"REMOVE_TOAST",toastId:s})},ph);on.set(s,n)},vh=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,fh)};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?vr(t):s.toasts.forEach(r=>{vr(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)}}},fa=[];let pa={toasts:[]};function Wt(s){pa=vh(pa,s),fa.forEach(n=>{n(pa)})}function bh({...s}){const n=jh(),t=a=>Wt({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>Wt({type:"DISMISS_TOAST",toastId:n});return Wt({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function oi(){const[s,n]=m.useState(pa);return m.useEffect(()=>(fa.push(n),()=>{const t=fa.indexOf(n);t>-1&&fa.splice(t,1)}),[s]),{...s,toast:bh,dismiss:t=>Wt({type:"DISMISS_TOAST",toastId:t})}}function yh({open:s,onOpenChange:n,table:t}){const{t:r}=V("user"),{toast:a}=oi(),[i,l]=m.useState(!1),[d,u]=m.useState(""),[o,c]=m.useState(""),h=async()=>{if(!d||!o){a({title:r("messages.error"),description:r("messages.send_mail.required_fields"),variant:"destructive"});return}try{l(!0),await Ps.sendMail({subject:d,content:o,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),a({title:r("messages.success"),description:r("messages.send_mail.success")}),n(!1),u(""),c("")}catch{a({title:r("messages.error"),description:r("messages.send_mail.failed"),variant:"destructive"})}finally{l(!1)}};return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(de,{className:"sm:max-w-[500px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:r("send_mail.title")}),e.jsx(Ve,{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(P,{id:"subject",value:d,onChange:k=>u(k.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(Ds,{id:"content",value:o,onChange:k=>c(k.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(Le,{children:e.jsx(G,{type:"submit",onClick:h,disabled:i,children:r(i?"send_mail.sending":"send_mail.send")})})]})})}function Nh({trigger:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),[a,i]=m.useState(30),{data:l,isLoading:d}=ne({queryKey:["trafficResetStats",a],queryFn:()=>Xt.getStats({days:a}),enabled:t}),u=[{title:n("traffic_reset.stats.total_resets"),value:l?.data?.total_resets||0,icon:Ut,color:"text-blue-600",bgColor:"bg-blue-100"},{title:n("traffic_reset.stats.auto_resets"),value:l?.data?.auto_resets||0,icon:pl,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:Pn,color:"text-purple-600",bgColor:"bg-purple-100"}],o=[{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(ge,{open:t,onOpenChange:r,children:[e.jsx(as,{asChild:!0,children:s}),e.jsxs(de,{className:"max-w-2xl",children:[e.jsxs(ve,{children:[e.jsxs(fe,{className:"flex items-center gap-2",children:[e.jsx(kn,{className:"h-5 w-5"}),n("traffic_reset.stats.title")]}),e.jsx(Ve,{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(J,{value:a.toString(),onValueChange:c=>i(Number(c)),children:[e.jsx(W,{className:"w-[180px]",children:e.jsx(Q,{})}),e.jsx(Y,{children:o.map(c=>e.jsx($,{value:c.value.toString(),children:c.label},c.value))})]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Yt,{className:"h-6 w-6 animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.map((c,h)=>e.jsxs(Re,{className:"relative overflow-hidden",children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ge,{className:"text-sm font-medium text-muted-foreground",children:c.title}),e.jsx("div",{className:`rounded-lg p-2 ${c.bgColor}`,children:e.jsx(c.icon,{className:`h-4 w-4 ${c.color}`})})]}),e.jsxs(Ie,{children:[e.jsx("div",{className:"text-2xl font-bold",children:c.value.toLocaleString()}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n("traffic_reset.stats.in_period",{days:a})})]})]},h))}),l?.data&&e.jsxs(Re,{children:[e.jsxs(Fe,{children:[e.jsx(Ge,{className:"text-lg",children:n("traffic_reset.stats.breakdown")}),e.jsx(Os,{children:n("traffic_reset.stats.breakdown_description")})]}),e.jsx(Ie,{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 _h=x.object({email_prefix:x.string().optional(),email_suffix:x.string().min(1),password:x.string().optional(),expired_at:x.number().optional().nullable(),plan_id:x.number().nullable(),generate_count:x.number().optional().nullable(),download_csv:x.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"]}),wh={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0,download_csv:!1};function Ch({refetch:s}){const{t:n}=V("user"),[t,r]=m.useState(!1),a=we({resolver:Ce(_h),defaultValues:wh,mode:"onChange"}),[i,l]=m.useState([]);return m.useEffect(()=>{t&&gs.getList().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(ge,{open:t,onOpenChange:r,children:[e.jsx(as,{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(de,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(fe,{children:n("generate.title")}),e.jsx(Ve,{})]}),e.jsxs(Se,{...a,children:[e.jsxs(p,{children:[e.jsx(j,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(v,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(P,{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(v,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(P,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(v,{control:a.control,name:"password",render:({field:d})=>e.jsxs(p,{children:[e.jsx(j,{children:n("generate.form.password")}),e.jsx(P,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(E,{})]})}),e.jsx(v,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(p,{className:"flex flex-col",children:[e.jsx(j,{children:n("generate.form.expire_time")}),e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(y,{children:e.jsxs(G,{variant:"outline",className:b("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?me(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(Ze,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(nd,{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(vs,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:u=>{u&&d.onChange(u?.getTime()/1e3)}})})]})]})]})}),e.jsx(v,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(p,{children:[e.jsx(j,{children:n("generate.form.subscription")}),e.jsx(y,{children:e.jsxs(J,{value:d.value?d.value.toString():"null",onValueChange:u=>d.onChange(u==="null"?null:parseInt(u)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx($,{value:"null",children:n("generate.form.subscription_none")}),i.map(u=>e.jsx($,{value:u.id.toString(),children:u.name},u.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(v,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(p,{children:[e.jsx(j,{children:n("generate.form.generate_count")}),e.jsx(P,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:d.value||"",onChange:u=>d.onChange(u.target.value?parseInt(u.target.value):null)})]})}),a.watch("generate_count")&&e.jsx(v,{control:a.control,name:"download_csv",render:({field:d})=>e.jsxs(p,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(y,{children:e.jsx(An,{checked:d.value,onCheckedChange:d.onChange})}),e.jsx(j,{children:n("generate.form.download_csv")})]})})]}),e.jsxs(Le,{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 u=await Ps.generate(d);if(u&&u instanceof Blob){const o=window.URL.createObjectURL(u),c=document.createElement("a");c.href=o,c.download=`users_${new Date().getTime()}.csv`,document.body.appendChild(c),c.click(),c.remove(),window.URL.revokeObjectURL(o),A.success(n("generate.form.success")),a.reset(),s(),r(!1)}}else{const{data:u}=await Ps.generate(d);u&&(A.success(n("generate.form.success")),a.reset(),s(),r(!1))}})(),children:n("generate.form.submit")})]})]})]})}const qn=Tr,ci=Dr,Sh=Pr,di=m.forwardRef(({className:s,...n},t)=>e.jsx(Da,{className:b("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}));di.displayName=Da.displayName;const kh=it("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"}}),Ba=m.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(Sh,{children:[e.jsx(di,{}),e.jsxs(Pa,{ref:a,className:b(kh({side:s}),n),...r,children:[e.jsxs(Nn,{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(ms,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));Ba.displayName=Pa.displayName;const Ga=({className:s,...n})=>e.jsx("div",{className:b("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ga.displayName="SheetHeader";const mi=({className:s,...n})=>e.jsx("div",{className:b("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});mi.displayName="SheetFooter";const Wa=m.forwardRef(({className:s,...n},t)=>e.jsx(La,{ref:t,className:b("text-lg font-semibold text-foreground",s),...n}));Wa.displayName=La.displayName;const Ya=m.forwardRef(({className:s,...n},t)=>e.jsx(Ra,{ref:t,className:b("text-sm text-muted-foreground",s),...n}));Ya.displayName=Ra.displayName;function Th({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=V("user"),{toast:i}=oi(),l=s.getState().columnFilters.length>0,[d,u]=m.useState([]),[o,c]=m.useState(!1),[h,k]=m.useState(!1),[C,S]=m.useState(!1),[f,N]=m.useState(!1),_=async()=>{try{const ee=await Ps.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),te=ee;console.log(ee);const q=new Blob([te],{type:"text/csv;charset=utf-8;"}),F=window.URL.createObjectURL(q),X=document.createElement("a");X.href=F,X.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(X),X.click(),X.remove(),window.URL.revokeObjectURL(F),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},T=async()=>{try{N(!0),await Ps.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{N(!1),S(!1)}},D=[{label:a("filter.fields.email"),value:"email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.id"),value:"id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:a("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{label:a("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.token"),value:"token",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.banned"),value:"banned",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],options:[{label:a("filter.status.normal"),value:"0"},{label:a("filter.status.banned"),value:"1"}]},{label:a("filter.fields.remark"),value:"remarks",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.inviter_email"),value:"invite_user.email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]}],g=ee=>ee*1024*1024*1024,w=ee=>ee/(1024*1024*1024),R=()=>{u([...d,{field:"",operator:"",value:""}])},H=ee=>{u(d.filter((te,q)=>q!==ee))},I=(ee,te,q)=>{const F=[...d];if(F[ee]={...F[ee],[te]:q},te==="field"){const X=D.find(Ns=>Ns.value===q);X&&(F[ee].operator=X.operators[0].value,F[ee].value=X.type==="boolean"?!1:"")}u(F)},K=(ee,te)=>{const q=D.find(F=>F.value===ee.field);if(!q)return null;switch(q.type){case"text":return e.jsx(P,{placeholder:a("filter.sheet.value"),value:ee.value,onChange:F=>I(te,"value",F.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(P,{type:"number",placeholder:a("filter.sheet.value_number",{unit:q.unit}),value:q.unit==="GB"?w(ee.value||0):ee.value,onChange:F=>{const X=Number(F.target.value);I(te,"value",q.unit==="GB"?g(X):X)}}),q.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:q.unit})]});case"date":return e.jsx(vs,{mode:"single",selected:ee.value,onSelect:F=>I(te,"value",F),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(J,{value:ee.value,onValueChange:F=>I(te,"value",F),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.value")})}),e.jsx(Y,{children:q.useOptions?r.map(F=>e.jsx($,{value:F.value.toString(),children:F.label},F.value)):q.options?.map(F=>e.jsx($,{value:F.value.toString(),children:F.label},F.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Z,{checked:ee.value,onCheckedChange:F=>I(te,"value",F)}),e.jsx(Ae,{children:ee.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},ae=()=>{const ee=d.filter(te=>te.field&&te.operator&&te.value!=="").map(te=>{const q=D.find(X=>X.value===te.field);let F=te.value;return te.operator==="contains"?{id:te.field,value:F}:(q?.type==="date"&&F instanceof Date&&(F=Math.floor(F.getTime()/1e3)),q?.type==="boolean"&&(F=F?1:0),{id:te.field,value:`${te.operator}:${F}`})});s.setColumnFilters(ee),c(!1)};return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsx(Ch,{refetch:n}),e.jsx(P,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:ee=>s.getColumn("email")?.setFilterValue(ee.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(qn,{open:o,onOpenChange:c,children:[e.jsx(ci,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(rd,{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(Ba,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(Ga,{children:[e.jsx(Wa,{children:a("filter.sheet.title")}),e.jsx(Ya,{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:R,children:a("filter.sheet.add")})]}),e.jsx(lt,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((ee,te)=>e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:a("filter.sheet.condition",{number:te+1})}),e.jsx(L,{variant:"ghost",size:"sm",onClick:()=>H(te),children:e.jsx(ms,{className:"h-4 w-4"})})]}),e.jsxs(J,{value:ee.field,onValueChange:q=>I(te,"field",q),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.field")})}),e.jsx(Y,{children:e.jsx(rs,{children:D.map(q=>e.jsx($,{value:q.value,className:"cursor-pointer",children:q.label},q.value))})})]}),ee.field&&e.jsxs(J,{value:ee.operator,onValueChange:q=>I(te,"operator",q),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.operator")})}),e.jsx(Y,{children:D.find(q=>q.value===ee.field)?.operators.map(q=>e.jsx($,{value:q.value,children:q.label},q.value))})]}),ee.field&&ee.operator&&K(ee,te)]},te))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(L,{variant:"outline",onClick:()=>{u([]),c(!1)},children:a("filter.sheet.reset")}),e.jsx(L,{onClick:ae,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(L,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[a("filter.sheet.reset"),e.jsx(ms,{className:"ml-2 h-4 w-4"})]}),e.jsxs(zs,{modal:!1,children:[e.jsx($s,{asChild:!0,children:e.jsx(L,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(Ls,{children:[e.jsx(_e,{onClick:()=>k(!0),children:a("actions.send_email")}),e.jsx(_e,{onClick:_,children:a("actions.export_csv")}),e.jsx(rt,{}),e.jsx(_e,{asChild:!0,children:e.jsx(Nh,{trigger:e.jsx("div",{className:"w-full cursor-pointer px-2 py-1.5 text-sm",children:a("actions.traffic_reset_stats")})})}),e.jsx(rt,{}),e.jsx(_e,{onClick:()=>S(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(yh,{open:h,onOpenChange:k,table:s}),e.jsx(On,{open:C,onOpenChange:S,children:e.jsxs(Oa,{children:[e.jsxs(za,{children:[e.jsx(Aa,{children:a("actions.confirm_ban.title")}),e.jsx(qa,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs($a,{children:[e.jsx(Ua,{disabled:f,children:a("actions.confirm_ban.cancel")}),e.jsx(Ha,{onClick:T,disabled:f,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(f?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const ui=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"})}),xi=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"})}),Dh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M17 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"})}),Ph=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"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"})}),cn=[{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:wd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ui,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:Oe(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(xi,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:Oe(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:Oe(n)})}}];function hi({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:u}=ne({queryKey:["userStats",s,i,r],queryFn:()=>r?Ps.getStats({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),o=ss({data:d?.data??[],columns:cn,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:ts(),onPaginationChange:l});return e.jsxs(ge,{open:r,onOpenChange:a,children:[e.jsx(as,{asChild:!0,children:n}),e.jsxs(de,{className:"sm:max-w-[700px]",children:[e.jsx(ve,{children:e.jsx(fe,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(En,{children:[e.jsx(Fn,{children:o.getHeaderGroups().map(c=>e.jsx(Bs,{children:c.headers.map(h=>e.jsx(Vn,{className:b("h-10 px-2 text-xs",h.id==="total"&&"text-right"),children:h.isPlaceholder?null:ba(h.column.columnDef.header,h.getContext())},h.id))},c.id))}),e.jsx(In,{children:u?Array.from({length:i.pageSize}).map((c,h)=>e.jsx(Bs,{children:Array.from({length:cn.length}).map((k,C)=>e.jsx(_t,{className:"p-2",children:e.jsx(je,{className:"h-6 w-full"})},C))},h)):o.getRowModel().rows?.length?o.getRowModel().rows.map(c=>e.jsx(Bs,{"data-state":c.getIsSelected()&&"selected",className:"h-10",children:c.getVisibleCells().map(h=>e.jsx(_t,{className:"px-2",children:ba(h.column.columnDef.cell,h.getContext())},h.id))},c.id)):e.jsx(Bs,{children:e.jsx(_t,{colSpan:cn.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(J,{value:`${o.getState().pagination.pageSize}`,onValueChange:c=>{o.setPageSize(Number(c))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:o.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50].map(c=>e.jsx($,{value:`${c}`,children:c},c))})]}),e.jsx("p",{className:"text-sm font-medium",children:t("trafficRecord.records")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex w-[100px] items-center justify-center text-sm",children:t("trafficRecord.page",{current:o.getState().pagination.pageIndex+1,total:o.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||u,children:e.jsx(Dh,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||u,children:e.jsx(Ph,{className:"h-4 w-4"})})]})]})]})]})]})]})}function Lh({user:s,trigger:n,onSuccess:t}){const{t:r}=V("user"),[a,i]=m.useState(!1),[l,d]=m.useState(""),[u,o]=m.useState(!1),{data:c,isLoading:h}=ne({queryKey:["trafficResetHistory",s.id],queryFn:()=>Xt.getUserHistory(s.id,{limit:10}),enabled:a}),k=async()=>{try{o(!0);const{data:f}=await Xt.resetUser({user_id:s.id,reason:l.trim()||void 0});f&&(A.success(r("traffic_reset.reset_success")),i(!1),d(""),t?.())}catch(f){A.error(f?.response?.data?.message||r("traffic_reset.reset_failed"))}finally{o(!1)}},C=f=>{switch(f){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"}},S=f=>{switch(f){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(ge,{open:a,onOpenChange:i,children:[e.jsx(as,{asChild:!0,children:n}),e.jsxs(de,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs(ve,{children:[e.jsxs(fe,{className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-5 w-5"}),r("traffic_reset.title")]}),e.jsx(Ve,{children:r("traffic_reset.description",{email:s.email})})]}),e.jsxs(Dt,{defaultValue:"reset",className:"w-full",children:[e.jsxs(dt,{className:"grid w-full grid-cols-2",children:[e.jsxs(Xe,{value:"reset",className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-4 w-4"}),r("traffic_reset.tabs.reset")]}),e.jsxs(Xe,{value:"history",className:"flex items-center gap-2",children:[e.jsx(nr,{className:"h-4 w-4"}),r("traffic_reset.tabs.history")]})]}),e.jsxs(ks,{value:"reset",className:"space-y-4",children:[e.jsxs(Re,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Ge,{className:"text-lg flex items-center gap-2",children:[e.jsx(_l,{className:"h-5 w-5"}),r("traffic_reset.user_info")]})}),e.jsx(Ie,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.email")}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.used_traffic")}),e.jsx("p",{className:"font-medium",children:Oe(s.total_used)})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.total_traffic")}),e.jsx("p",{className:"font-medium",children:Oe(s.transfer_enable)})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("columns.expire_time")}),e.jsx("p",{className:"font-medium",children:s.expired_at?me(s.expired_at):r("columns.expire_status.permanent")})]})]})})]}),e.jsxs(Re,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Ge,{className:"text-lg flex items-center gap-2 text-amber-800",children:[e.jsx(Ht,{className:"h-5 w-5"}),r("traffic_reset.warning.title")]})}),e.jsx(Ie,{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(Ae,{htmlFor:"reason",children:r("traffic_reset.reason.label")}),e.jsx(Ds,{id:"reason",placeholder:r("traffic_reset.reason.placeholder"),value:l,onChange:f=>d(f.target.value),className:"min-h-[80px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("traffic_reset.reason.optional")})]}),e.jsxs(Le,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:r("common:cancel")}),e.jsx(G,{onClick:k,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Yt,{className:"mr-2 h-4 w-4 animate-spin"}),r("traffic_reset.resetting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),r("traffic_reset.confirm_reset")]})})]})]}),e.jsx(ks,{value:"history",className:"space-y-4",children:h?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Yt,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[c?.data?.user&&e.jsxs(Re,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsx(Ge,{className:"text-lg",children:r("traffic_reset.history.summary")})}),e.jsx(Ie,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.reset_count")}),e.jsx("p",{className:"font-medium",children:c.data.user.reset_count})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.last_reset")}),e.jsx("p",{className:"font-medium",children:c.data.user.last_reset_at?me(c.data.user.last_reset_at):r("traffic_reset.history.never")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.next_reset")}),e.jsx("p",{className:"font-medium",children:c.data.user.next_reset_at?me(c.data.user.next_reset_at):r("traffic_reset.history.no_schedule")})]})]})})]}),e.jsxs(Re,{children:[e.jsxs(Fe,{className:"pb-3",children:[e.jsx(Ge,{className:"text-lg",children:r("traffic_reset.history.records")}),e.jsx(Os,{children:r("traffic_reset.history.recent_records")})]}),e.jsx(Ie,{children:e.jsx(lt,{className:"h-[300px]",children:c?.data?.history?.length?e.jsx("div",{className:"space-y-3",children:c.data.history.map((f,N)=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between p-3 rounded-lg border bg-card",children:e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:C(f.reset_type),children:f.reset_type_name}),e.jsx(U,{variant:"outline",className:S(f.trigger_source),children:f.trigger_source_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs(Ae,{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Pn,{className:"h-3 w-3"}),r("traffic_reset.history.reset_time")]}),e.jsx("p",{className:"font-medium",children:me(f.reset_time)})]}),e.jsxs("div",{children:[e.jsx(Ae,{className:"text-muted-foreground",children:r("traffic_reset.history.traffic_cleared")}),e.jsx("p",{className:"font-medium text-destructive",children:f.old_traffic.formatted})]})]})]})}),Ne.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"})}),Fh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M19 11h-6V5a1 1 0 0 0-2 0v6H5a1 1 0 0 0 0 2h6v6a1 1 0 0 0 2 0v-6h6a1 1 0 0 0 0-2"})}),Ih=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M21 8.94a1.3 1.3 0 0 0-.06-.27v-.09a1 1 0 0 0-.19-.28l-6-6a1 1 0 0 0-.28-.19a.3.3 0 0 0-.09 0a.9.9 0 0 0-.33-.11H10a3 3 0 0 0-3 3v1H6a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-1h1a3 3 0 0 0 3-3zm-6-3.53L17.59 8H16a1 1 0 0 1-1-1ZM15 19a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h1v7a3 3 0 0 0 3 3h5Zm4-4a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3v3a3 3 0 0 0 3 3h3Z"})}),br=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M21 11a1 1 0 0 0-1 1a8.05 8.05 0 1 1-2.22-5.5h-2.4a1 1 0 0 0 0 2h4.53a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v1.77A10 10 0 1 0 22 12a1 1 0 0 0-1-1"})}),Vh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M9.5 10.5H12a1 1 0 0 0 0-2h-1V8a1 1 0 0 0-2 0v.55a2.5 2.5 0 0 0 .5 4.95h1a.5.5 0 0 1 0 1H8a1 1 0 0 0 0 2h1v.5a1 1 0 0 0 2 0v-.55a2.5 2.5 0 0 0-.5-4.95h-1a.5.5 0 0 1 0-1M21 12h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Z"})}),Mh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M12.3 12.22A4.92 4.92 0 0 0 14 8.5a5 5 0 0 0-10 0a4.92 4.92 0 0 0 1.7 3.72A8 8 0 0 0 1 19.5a1 1 0 0 0 2 0a6 6 0 0 1 12 0a1 1 0 0 0 2 0a8 8 0 0 0-4.7-7.28M9 11.5a3 3 0 1 1 3-3a3 3 0 0 1-3 3m9.74.32A5 5 0 0 0 15 3.5a1 1 0 0 0 0 2a3 3 0 0 1 3 3a3 3 0 0 1-1.5 2.59a1 1 0 0 0-.5.84a1 1 0 0 0 .45.86l.39.26l.13.07a7 7 0 0 1 4 6.38a1 1 0 0 0 2 0a9 9 0 0 0-4.23-7.68"})}),Oh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2m0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1"})}),zh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"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"})}),$h=(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,u=Math.floor(Date.now()/1e3-l);let o=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:me(l)});if(!d&&l!==0){const c=Math.floor(u/60),h=Math.floor(c/60),k=Math.floor(h/24);k>0?o+=` `+a("columns.online_status.offline_duration.days",{count:k}):h>0?o+=` `+a("columns.online_status.offline_duration.hours",{count:h}):c>0?o+=` `+a("columns.online_status.offline_duration.minutes",{count:c}):o+=` -`+a("columns.online_status.offline_duration.seconds",{count:u})}return e.jsx(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:y("size-2.5 rounded-full ring-2 ring-offset-2",d?"bg-green-500 ring-green-500/20":"bg-gray-300 ring-gray-300/20","transition-all duration-300")}),e.jsx("span",{className:"font-medium text-foreground/90",children:i.original.email})]})}),e.jsx(ce,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:o})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(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(be,{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:y("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:y("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:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5 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=Oe(i.original?.total_used),d=Oe(i.original?.transfer_enable),u=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(be,{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:[u.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:y("h-full rounded-full transition-all",u>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(u,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:Oe(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,u=l!=null&&le.jsx(z,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=bt(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=bt(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:me(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(zs,{modal:!1,children:[e.jsx($s,{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(_a,{className:"size-4"})})})}),e.jsxs(Ls,{align:"end",className:"min-w-[40px]",children:[e.jsx(_e,{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(Eh,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(ri,{defaultValues:{email:i.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Rh,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(_e,{onSelect:()=>{wa(i.original.subscribe_url).then(()=>{A.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(Fh,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(_e,{onSelect:()=>{Ps.resetSecret(i.original.id).then(({data:d})=>{d&&A.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(br,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(_e,{onSelect:()=>{},className:"p-0",children:e.jsxs(Ys,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=eq:${i.original?.id}`,children:[e.jsx(Ih,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(_e,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Vh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(hi,{user_id:i.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Mh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Ph,{user:i.original,onSuccess:s,trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(br,{className:"mr-2"}),a("columns.actions_menu.reset_traffic")]})})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Lh,{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 Ps.destroy(i.original.id);d&&(A.success(a("common:delete.success")),s())}catch{A.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(Oh,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},gi=m.createContext(void 0),Hn=()=>{const s=m.useContext(gi);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},fi=({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(gi.Provider,{value:l,children:s})},$h=x.object({id:x.number(),email:x.string().email(),invite_user_email:x.string().email().nullable().optional(),password:x.string().optional().nullable(),balance:x.coerce.number(),commission_balance:x.coerce.number(),u:x.number(),d:x.number(),transfer_enable:x.number(),expired_at:x.number().nullable(),plan_id:x.number().nullable(),banned:x.number(),commission_type:x.number(),commission_rate:x.number().nullable(),discount:x.number().nullable(),speed_limit:x.number().nullable(),device_limit:x.number().nullable(),is_admin:x.number(),is_staff:x.number(),remarks:x.string().nullable()});function pi(){const{t:s}=V("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=Hn(),[i,l]=m.useState(!1),[d,u]=m.useState([]),o=we({resolver:Ce($h),defaultValues:{id:0,email:"",invite_user_email:null,password:null,balance:0,commission_balance:0,u:0,d:0,transfer_enable:0,expired_at:null,plan_id:null,banned:0,commission_type:0,commission_rate:null,discount:null,speed_limit:null,device_limit:null,is_admin:0,is_staff:0,remarks:null}});return m.useEffect(()=>{n&&gs.getList().then(({data:c})=>{u(c)})},[n]),m.useEffect(()=>{if(r){const c=r.invite_user?.email,{invite_user:h,...k}=r;o.reset({...k,invite_user_email:c||null,password:null})}},[r,o]),e.jsx(qn,{open:n,onOpenChange:t,children:e.jsxs(Ba,{className:"max-w-[90%] space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Wa,{children:s("edit.title")}),e.jsx(Ya,{})]}),e.jsxs(Se,{...o,children:[e.jsx(b,{control:o.control,name:"email",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.email")}),e.jsx(N,{children:e.jsx(D,{...c,placeholder:s("edit.form.email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(L,{...c})]})}),e.jsx(b,{control:o.control,name:"invite_user_email",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.inviter_email")}),e.jsx(N,{children:e.jsx(D,{value:c.value||"",onChange:h=>c.onChange(h.target.value?h.target.value:null),placeholder:s("edit.form.inviter_email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(L,{...c})]})}),e.jsx(b,{control:o.control,name:"password",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.password")}),e.jsx(N,{children:e.jsx(D,{type:"password",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.password_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(L,{...c})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(b,{control:o.control,name:"balance",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.balance")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(L,{...c})]})}),e.jsx(b,{control:o.control,name:"commission_balance",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.commission_balance")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(L,{...c})]})}),e.jsx(b,{control:o.control,name:"u",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.upload")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(L,{...c})]})}),e.jsx(b,{control:o.control,name:"d",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.download")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(L,{...c})]})})]}),e.jsx(b,{control:o.control,name:"transfer_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.total_traffic")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(L,{})]})}),e.jsx(b,{control:o.control,name:"expired_at",render:({field:c})=>e.jsxs(j,{className:"flex flex-col",children:[e.jsx(v,{children:s("edit.form.expire_time")}),e.jsxs(os,{open:i,onOpenChange:l,children:[e.jsx(cs,{asChild:!0,children:e.jsx(N,{children:e.jsxs(P,{type:"button",variant:"outline",className:y("w-full pl-3 text-left font-normal",!c.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[c.value?me(c.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(Cs,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:h=>{h.preventDefault()},onEscapeKeyDown:h=>{h.preventDefault()},children:e.jsxs("div",{className:"flex flex-col space-y-3 p-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{c.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+1),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(P,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+3),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(ks,{mode:"single",selected:c.value?new Date(c.value*1e3):void 0,onSelect:h=>{if(h){const k=new Date(c.value?c.value*1e3:Date.now());h.setHours(k.getHours(),k.getMinutes(),k.getSeconds()),c.onChange(Math.floor(h.getTime()/1e3))}},disabled:h=>h{const h=new Date;h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3))},className:"h-6 px-2 text-xs",children:s("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"datetime-local",step:"1",value:me(c.value,"YYYY-MM-DDTHH:mm:ss"),onChange:h=>{const k=new Date(h.target.value);isNaN(k.getTime())||c.onChange(Math.floor(k.getTime()/1e3))},className:"flex-1"}),e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(L,{})]})}),e.jsx(b,{control:o.control,name:"plan_id",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.subscription")}),e.jsx(N,{children:e.jsxs(J,{value:c.value!==null?String(c.value):"null",onValueChange:h=>c.onChange(h==="null"?null:parseInt(h)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx($,{value:"null",children:s("edit.form.subscription_none")}),d.map(h=>e.jsx($,{value:String(h.id),children:h.name},h.id))]})]})})]})}),e.jsx(b,{control:o.control,name:"banned",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.account_status")}),e.jsx(N,{children:e.jsxs(J,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(W,{children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx($,{value:"1",children:s("columns.status_text.banned")}),e.jsx($,{value:"0",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(b,{control:o.control,name:"commission_type",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.commission_type")}),e.jsx(N,{children:e.jsxs(J,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx($,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx($,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(b,{control:o.control,name:"commission_rate",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.commission_rate")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(b,{control:o.control,name:"discount",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.discount")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(L,{})]})}),e.jsx(b,{control:o.control,name:"speed_limit",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.speed_limit")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(L,{})]})}),e.jsx(b,{control:o.control,name:"device_limit",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.device_limit")}),e.jsx(N,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(L,{})]})}),e.jsx(b,{control:o.control,name:"is_admin",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(N,{children:e.jsx(Z,{checked:c.value===1,onCheckedChange:h=>c.onChange(h?1:0)})})})]})}),e.jsx(b,{control:o.control,name:"is_staff",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(N,{children:e.jsx(Z,{checked:c.value===1,onCheckedChange:h=>c.onChange(h?1:0)})})})]})}),e.jsx(b,{control:o.control,name:"remarks",render:({field:c})=>e.jsxs(j,{children:[e.jsx(v,{children:s("edit.form.remarks")}),e.jsx(N,{children:e.jsx(Ds,{className:"h-24",value:c.value||"",onChange:h=>c.onChange(h.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(L,{})]})}),e.jsxs(mi,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(P,{type:"submit",onClick:()=>{o.handleSubmit(c=>{Ps.update(c).then(({data:h})=>{h&&(A.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function Ah(){const[s]=Nl(),[n,t]=m.useState({}),[r,a]=m.useState({is_admin:!1,is_staff:!1}),[i,l]=m.useState([]),[d,u]=m.useState([]),[o,c]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const g=s.get("email");g&&l(w=>w.some(H=>H.id==="email")?w:[...w,{id:"email",value:g}])},[s]);const{refetch:h,data:k,isLoading:C}=ne({queryKey:["userList",o,i,d],queryFn:()=>Ps.getList({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),[S,p]=m.useState([]),[_,f]=m.useState([]);m.useEffect(()=>{mt.getList().then(({data:g})=>{p(g)}),gs.getList().then(({data:g})=>{f(g)})},[]);const T=S.map(g=>({label:g.name,value:g.id})),E=_.map(g=>({label:g.name,value:g.id}));return e.jsxs(fi,{refreshData:h,children:[e.jsx(qh,{data:k?.data??[],rowCount:k?.total??0,sorting:d,setSorting:u,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:o,setPagination:c,refetch:h,serverGroupList:S,permissionGroups:T,subscriptionPlans:E,isLoading:C}),e.jsx(pi,{})]})}function qh({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:o,pagination:c,setPagination:h,refetch:k,serverGroupList:C,permissionGroups:S,subscriptionPlans:p,isLoading:_}){const{setIsOpen:f,setEditingUser:T}=Hn(),E=ss({data:s,columns:zh(k,C,T,f),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:c},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:o,onColumnVisibilityChange:i,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),onPaginationChange:h,getSortedRowModel:bs(),getFacetedRowModel:Es(),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(kh,{table:E,refetch:k,serverGroupList:C,permissionGroups:S,subscriptionPlans:p}),e.jsx(xs,{table:E,isLoading:_})]})}function Hh(){const{t:s}=V("user");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx("div",{className:"w-full",children:e.jsx(Ah,{})})})]})]})}const Uh=Object.freeze(Object.defineProperty({__proto__:null,default:Hh},Symbol.toStringTag,{value:"Module"}));function Kh({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ld,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(We,{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:y("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(id,{className:y("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Bh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M19 11H5a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})});function Gh({table:s}){const{t:n}=V("ticket");return e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-4",children:[e.jsx(Dt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(dt,{className:"grid w-full grid-cols-2",children:[e.jsx(Xe,{value:"0",children:n("status.pending")}),e.jsx(Xe,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(Kh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:Qe.LOW,icon:Bh,color:"gray"},{label:n("level.medium"),value:Qe.MIDDLE,icon:ui,color:"yellow"},{label:n("level.high"),value:Qe.HIGH,icon:xi,color:"red"}]})]})})}function Wh(){return e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[e.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}const Yh=it("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"}}),ji=m.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:y(Yh({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)}));ji.displayName="ChatBubble";const Jh=it("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"}}),vi=m.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:y(Jh({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...i,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(Wh,{})}):a}));vi.displayName="ChatBubbleMessage";const Qh=m.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:y("absolute top-1/2 -translate-y-1/2 flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",s==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",n),...r,children:t}));Qh.displayName="ChatBubbleActionWrapper";const bi=m.forwardRef(({className:s,...n},t)=>e.jsx(Ds,{autoComplete:"off",ref:t,name:"message",className:y("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}));bi.displayName="ChatInput";const yi=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"})}),Ni=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"})}),yr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"m11.29 12l3.54-3.54a1 1 0 0 0 0-1.41a1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29a1 1 0 0 0 .71-.29a1 1 0 0 0 0-1.41Z"})}),Xh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M21.71 20.29L18 16.61A9 9 0 1 0 16.61 18l3.68 3.68a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.39M11 18a7 7 0 1 1 7-7a7 7 0 0 1-7 7"})}),Zh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M3.71 16.29a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21a1 1 0 0 0-.21.33a1 1 0 0 0 .21 1.09a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1 1 0 0 0 .21-1.09a1 1 0 0 0-.21-.33M7 8h14a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m-3.29 3.29a1 1 0 0 0-1.09-.21a1.2 1.2 0 0 0-.33.21a1 1 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1 1 0 0 0-.21-.33M21 11H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2M3.71 6.29a1 1 0 0 0-.33-.21a1 1 0 0 0-1.09.21a1.2 1.2 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a1 1 0 0 0 1.09-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1.2 1.2 0 0 0-.21-.33M21 16H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})}),eg=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 sg(){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(je,{className:"h-8 w-3/4"}),e.jsx(je,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(je,{className:"h-20 w-2/3"},s))})]})}function tg(){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(je,{className:"h-5 w-4/5"}),e.jsx(je,{className:"h-4 w-2/3"}),e.jsx(je,{className:"h-3 w-1/2"})]},s))})}function ag({ticket:s,isActive:n,onClick:t}){const{t:r}=V("ticket"),a=i=>{switch(i){case Qe.HIGH:return"bg-red-50 text-red-600 border-red-200";case Qe.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case Qe.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:y("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===Ws.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Ws.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:me(s.updated_at)}),e.jsx("div",{className:y("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===Qe.LOW?"low":s.level===Qe.MIDDLE?"medium":"high"}`)})]})]})}function ng({ticketId:s,dialogTrigger:n}){const{t}=V("ticket"),r=As(),a=m.useRef(null),i=m.useRef(null),[l,d]=m.useState(!1),[u,o]=m.useState(""),[c,h]=m.useState(!1),[k,C]=m.useState(s),[S,p]=m.useState(""),[_,f]=m.useState(!1),{setIsOpen:T,setEditingUser:E}=Hn(),{data:g,isLoading:w,refetch:R}=ne({queryKey:["tickets",l],queryFn:()=>l?Nt.getList({filter:[{id:"status",value:[Ws.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:H,refetch:I,isLoading:K}=ne({queryKey:["ticket",k,l],queryFn:()=>l?Nt.getInfo(k):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),ae=H?.data,te=(g?.data||[]).filter(ie=>ie.subject.toLowerCase().includes(S.toLowerCase())||ie.user?.email.toLowerCase().includes(S.toLowerCase())),q=(ie="smooth")=>{if(a.current){const{scrollHeight:Ns,clientHeight:Fs}=a.current;a.current.scrollTo({top:Ns-Fs,behavior:ie})}};m.useEffect(()=>{if(!l)return;const ie=requestAnimationFrame(()=>{q("instant"),setTimeout(()=>q(),1e3)});return()=>{cancelAnimationFrame(ie)}},[l,ae?.messages]);const F=async()=>{const ie=u.trim();!ie||c||(h(!0),Nt.reply({id:k,message:ie}).then(()=>{o(""),I(),q(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{h(!1)}))},X=async()=>{Nt.close(k).then(()=>{A.success(t("actions.close_success")),I(),R()})},ys=()=>{ae?.user&&r("/finance/order?user_id="+ae.user.id)},De=ae?.status===Ws.CLOSED;return e.jsxs(ge,{open:l,onOpenChange:d,children:[e.jsx(as,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(de,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(fe,{}),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:()=>f(!_),children:e.jsx(yr,{className:y("h-4 w-4 transition-transform",!_&&"rotate-180")})}),e.jsxs("div",{className:y("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",_?"-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:()=>f(!_),children:e.jsx(yr,{className:y("h-4 w-4 transition-transform",!_&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Xh,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(D,{placeholder:t("list.search_placeholder"),value:S,onChange:ie=>p(ie.target.value),className:"pl-8"})]})]}),e.jsx(lt,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:w?e.jsx(tg,{}):te.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(S?"list.no_search_results":"list.no_tickets")}):te.map(ie=>e.jsx(ag,{ticket:ie,isActive:ie.id===k,onClick:()=>{C(ie.id),window.innerWidth<768&&f(!0)}},ie.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!_&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>f(!0)}),K?e.jsx(sg,{}):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:ae?.subject}),e.jsx(U,{variant:De?"secondary":"default",children:t(De?"status.closed":"status.processing")}),!De&&e.jsx(ps,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:X,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(yi,{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(Ta,{className:"h-4 w-4"}),e.jsx("span",{children:ae?.user?.email})]}),e.jsx(Te,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Ni,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",me(ae?.created_at)]})]}),e.jsx(Te,{orientation:"vertical",className:"h-4"}),e.jsx(U,{variant:"outline",children:ae?.level!=null&&t(`level.${ae.level===Qe.LOW?"low":ae.level===Qe.MIDDLE?"medium":"high"}`)})]})]}),ae?.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:()=>{E(ae.user),T(!0)},children:e.jsx(Ta,{className:"h-4 w-4"})}),e.jsx(hi,{user_id:ae.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Zh,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:ys,children:e.jsx(eg,{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:ae?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):ae?.messages?.map(ie=>e.jsx(ji,{variant:ie.is_from_admin?"sent":"received",className:ie.is_from_admin?"ml-auto":"mr-auto",children:e.jsx(vi,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:ie.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:me(ie.created_at)})})]})})},ie.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(bi,{ref:i,disabled:De||c,placeholder:t(De?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:u,onChange:ie=>o(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),F())}}),e.jsx(G,{disabled:De||c||!u.trim(),onClick:F,children:t(c?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const 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:"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"})}),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:"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"})}),ig=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(rg,{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===Qe.LOW?"default":r===Qe.MIDDLE?"secondary":"destructive";return e.jsx(U,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===Qe.LOW?"low":r===Qe.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===Ws.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===Ws.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(Ni,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:me(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:me(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!==Ws.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(ng,{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(lg,{className:"h-4 w-4"})})}),r&&e.jsx(ps,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{Nt.close(t.original.id).then(()=>{A.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(yi,{className:"h-4 w-4"})})})]})}}]};function og(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([{id:"status",value:"0"}]),[l,d]=m.useState([]),[u,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=ne({queryKey:["orderList",u,a,l],queryFn:()=>Nt.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),k=ss({data:h?.data??[],columns:ig(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),onPaginationChange:o,getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Gh,{table:k,refetch:c}),e.jsx(xs,{table:k,showPagination:!0})]})}function cg(){const{t:s}=V("ticket");return e.jsxs(fi,{refreshData:()=>{},children:[e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(og,{})})]})]}),e.jsx(pi,{})]})}const dg=Object.freeze(Object.defineProperty({__proto__:null,default:cg},Symbol.toStringTag,{value:"Module"}));function mg({table:s,refetch:n}){const{t}=V("user"),r=s.getState().columnFilters.length>0,[a,i]=m.useState(),[l,d]=m.useState(),[u,o]=m.useState(!1),c=[{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")}],h=[{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")}],k=()=>{let _=s.getState().columnFilters.filter(f=>f.id!=="date_range");(a||l)&&_.push({id:"date_range",value:{start:a?Pe(a,"yyyy-MM-dd"):null,end:l?Pe(l,"yyyy-MM-dd"):null}}),s.setColumnFilters(_)},C=async()=>{try{o(!0);const _=s.getState().columnFilters.reduce((I,K)=>{if(K.value)if(K.id==="date_range"){const ae=K.value;ae.start&&(I.start_date=ae.start),ae.end&&(I.end_date=ae.end)}else I[K.id]=K.value;return I},{}),T=(await Xt.getLogs({..._,page:1,per_page:1e4})).data.map(I=>({ID:I.id,用户邮箱:I.user_email,用户ID:I.user_id,重置类型:I.reset_type_name,触发源:I.trigger_source_name,清零流量:I.old_traffic.formatted,"上传流量(GB)":(I.old_traffic.upload/1024**3).toFixed(2),"下载流量(GB)":(I.old_traffic.download/1024**3).toFixed(2),重置时间:Pe(new Date(I.reset_time),"yyyy-MM-dd HH:mm:ss"),记录时间:Pe(new Date(I.created_at),"yyyy-MM-dd HH:mm:ss"),原因:I.reason||""})),E=Object.keys(T[0]||{}),g=[E.join(","),...T.map(I=>E.map(K=>{const ae=I[K];return typeof ae=="string"&&ae.includes(",")?`"${ae}"`:ae}).join(","))].join(` -`),w=new Blob([g],{type:"text/csv;charset=utf-8;"}),R=document.createElement("a"),H=URL.createObjectURL(w);R.setAttribute("href",H),R.setAttribute("download",`traffic-reset-logs-${Pe(new Date,"yyyy-MM-dd")}.csv`),R.style.visibility="hidden",document.body.appendChild(R),R.click(),document.body.removeChild(R),A.success(t("traffic_reset_logs.actions.export_success"))}catch(p){console.error("导出失败:",p),A.error(t("traffic_reset_logs.actions.export_failed"))}finally{o(!1)}},S=()=>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:p=>s.getColumn("user_email")?.setFilterValue(p.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(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:p=>s.getColumn("reset_type")?.setFilterValue(p==="all"?"":p),children:[e.jsx(W,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),c.map(p=>e.jsx($,{value:p.value,children:p.label},p.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(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:p=>s.getColumn("trigger_source")?.setFilterValue(p==="all"?"":p),children:[e.jsx(W,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),h.map(p=>e.jsx($,{value:p.value,children:p.label},p.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(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",className:y("h-9 w-full justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),a?Pe(a,"MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Ze,{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(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",className:y("h-9 w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),l?Pe(l,"MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]})]})]}),(a||l)&&e.jsxs(P,{variant:"outline",className:"w-full",onClick:k,children:[e.jsx(rr,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]}),r&&e.jsxs(P,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"w-full",children:[t("traffic_reset_logs.filters.reset"),e.jsx(ms,{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(ci,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(od,{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(Ba,{side:"bottom",className:"h-[85vh]",children:[e.jsxs(Ga,{className:"mb-4",children:[e.jsx(Wa,{children:t("traffic_reset_logs.filters.filter_title")}),e.jsx(Ya,{children:t("traffic_reset_logs.filters.filter_description")})]}),e.jsx("div",{className:"max-h-[calc(85vh-120px)] overflow-y-auto",children:e.jsx(S,{})})]})]})}),e.jsxs(P,{variant:"outline",size:"sm",className:"h-8",onClick:C,disabled:u,children:[e.jsx(va,{className:"mr-2 h-4 w-4"}),t(u?"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:p=>s.getColumn("user_email")?.setFilterValue(p.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:p=>s.getColumn("reset_type")?.setFilterValue(p==="all"?"":p),children:[e.jsx(W,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),c.map(p=>e.jsx($,{value:p.value,children:p.label},p.value))]})]}),e.jsxs(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:p=>s.getColumn("trigger_source")?.setFilterValue(p==="all"?"":p),children:[e.jsx(W,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),h.map(p=>e.jsx($,{value:p.value,children:p.label},p.value))]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:y("h-8 w-[140px] justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),a?Pe(a,"yyyy-MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]}),e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",className:y("h-8 w-[140px] justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),l?Pe(l,"yyyy-MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(ks,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]}),(a||l)&&e.jsxs(P,{variant:"outline",size:"sm",className:"h-8",onClick:k,children:[e.jsx(rr,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]})]}),r&&e.jsxs(P,{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(ms,{className:"ml-2 h-4 w-4"})]})]}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(P,{variant:"outline",size:"sm",className:"h-8 border-dashed",onClick:C,disabled:u,children:[e.jsx(va,{className:"mr-2 h-4 w-4"}),t(u?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})})]})]})}const ug=()=>{const{t:s}=V("user"),n=r=>{switch(r){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=r=>{switch(r){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[{accessorKey:"id",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.id"),className:"w-[60px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[60px]",children:e.jsx(U,{variant:"outline",className:"text-xs",children:r.original.id})}),enableSorting:!0,enableHiding:!0,size:60},{accessorKey:"user_email",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.user"),className:"min-w-[200px]"}),cell:({row:r})=>e.jsxs("div",{className:"flex items-start gap-2 min-w-[200px]",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 font-medium text-sm",children:r.original.user_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",r.original.user_id]})]})]}),enableSorting:!1,enableHiding:!1,size:100},{accessorKey:"reset_type",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.reset_type"),className:"w-[120px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(U,{className:y("border text-xs",n(r.original.reset_type)),children:e.jsx("span",{className:"truncate",children:r.original.reset_type_name})})}),enableSorting:!0,enableHiding:!1,filterFn:(r,a,i)=>i.includes(r.getValue(a)),size:120},{accessorKey:"trigger_source",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.trigger_source"),className:"w-[100px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[100px]",children:e.jsx(U,{variant:"outline",className:y("border text-xs",t(r.original.trigger_source)),children:e.jsx("span",{className:"truncate",children:r.original.trigger_source_name})})}),enableSorting:!0,enableHiding:!0,filterFn:(r,a,i)=>i.includes(r.getValue(a)),size:100},{accessorKey:"old_traffic",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.cleared_traffic"),className:"w-[120px]"}),cell:({row:r})=>{const a=r.original.old_traffic;return e.jsx("div",{className:"w-[120px]",children:e.jsx(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"text-center cursor-pointer",children:[e.jsx("div",{className:"font-medium text-destructive text-sm",children:a.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(wt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.upload"),":"," ",(a.upload/1024**3).toFixed(2)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(va,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.download"),":"," ",(a.download/1024**3).toFixed(2)," GB"]})]})]})]})})})},enableSorting:!1,enableHiding:!1,size:120},{accessorKey:"reset_time",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.reset_time"),className:"w-[140px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ut,{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:"font-medium text-sm",children:me(r.original.reset_time,"MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:me(r.original.reset_time,"HH:mm")})]})]})}),enableSorting:!0,enableHiding:!0,size:140},{accessorKey:"created_at",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.log_time"),className:"w-[140px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Pn,{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:"font-medium text-sm",children:me(r.original.created_at,"YYYY-MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:me(r.original.created_at,"H:m:s")})]})]})}),enableSorting:!0,enableHiding:!1,size:1400}]};function xg(){const[s,n]=m.useState({}),[t,r]=m.useState({id:!1,trigger_source:!1,reset_time:!1}),[a,i]=m.useState([]),[l,d]=m.useState([{id:"created_at",desc:!0}]),[u,o]=m.useState({pageIndex:0,pageSize:20}),c={page:u.pageIndex+1,per_page:u.pageSize,...a.reduce((S,p)=>{if(p.value)if(p.id==="date_range"){const _=p.value;_.start&&(S.start_date=_.start),_.end&&(S.end_date=_.end)}else S[p.id]=p.value;return S},{})},{refetch:h,data:k,isLoading:C}=ne({queryKey:["trafficResetLogs",u,a,l],queryFn:()=>Xt.getLogs(c)});return e.jsx(hg,{data:k?.data??[],rowCount:k?.total??0,sorting:l,setSorting:d,columnVisibility:t,setColumnVisibility:r,rowSelection:s,setRowSelection:n,columnFilters:a,setColumnFilters:i,pagination:u,setPagination:o,refetch:h,isLoading:C})}function hg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:o,pagination:c,setPagination:h,refetch:k,isLoading:C}){const S=ss({data:s,columns:ug(),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:c},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:o,onColumnVisibilityChange:i,getCoreRowModel:ts(),getFilteredRowModel:vs(),getPaginationRowModel:us(),onPaginationChange:h,getSortedRowModel:bs(),getFacetedRowModel:Es(),getFacetedUniqueValues:Rs(),initialState:{columnVisibility:{id:!1,trigger_source:!1,reset_time:!1},columnPinning:{left:["user_email"]}}});return e.jsxs("div",{className:"h-full space-y-4",children:[e.jsx(mg,{table:S,refetch:k}),e.jsx("div",{className:"rounded-md border",children:e.jsx(xs,{table:S,isLoading:C})})]})}function gg(){const{t:s}=V("user");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ns,{})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(xg,{})})})]})]})}const fg=Object.freeze(Object.defineProperty({__proto__:null,default:gg},Symbol.toStringTag,{value:"Module"}));export{Ng as a,bg as c,yg as g,_g as r}; +`+a("columns.online_status.offline_duration.seconds",{count:u})}return e.jsx(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:b("size-2.5 rounded-full ring-2 ring-offset-2",d?"bg-green-500 ring-green-500/20":"bg-gray-300 ring-gray-300/20","transition-all duration-300")}),e.jsx("span",{className:"font-medium text-foreground/90",children:i.original.email})]})}),e.jsx(ce,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:o})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(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(be,{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:b("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:b("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:b("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=Oe(i.original?.total_used),d=Oe(i.original?.transfer_enable),u=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(be,{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:[u.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:b("h-full rounded-full transition-all",u>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(u,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:Oe(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,u=l!=null&&le.jsx(z,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=bt(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=bt(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:me(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(zs,{modal:!1,children:[e.jsx($s,{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(_a,{className:"size-4"})})})}),e.jsxs(Ls,{align:"end",className:"min-w-[40px]",children:[e.jsx(_e,{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(Eh,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(ri,{defaultValues:{email:i.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Fh,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(_e,{onSelect:()=>{wa(i.original.subscribe_url).then(()=>{A.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(Ih,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(_e,{onSelect:()=>{Ps.resetSecret(i.original.id).then(({data:d})=>{d&&A.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(br,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(_e,{onSelect:()=>{},className:"p-0",children:e.jsxs(Ys,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=eq:${i.original?.id}`,children:[e.jsx(Vh,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(_e,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Mh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(hi,{user_id:i.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Oh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Lh,{user:i.original,onSuccess:s,trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(br,{className:"mr-2"}),a("columns.actions_menu.reset_traffic")]})})}),e.jsx(_e,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Rh,{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 Ps.destroy(i.original.id);d&&(A.success(a("common:delete.success")),s())}catch{A.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(zh,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},gi=m.createContext(void 0),Hn=()=>{const s=m.useContext(gi);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},fi=({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(gi.Provider,{value:l,children:s})},Ah=x.object({id:x.number().default(0),email:x.string().email().default(""),invite_user_email:x.string().email().nullable().optional().default(null),password:x.string().optional().nullable().default(null),balance:x.coerce.number().default(0),commission_balance:x.coerce.number().default(0),u:x.number().default(0),d:x.number().default(0),transfer_enable:x.number().default(0),expired_at:x.number().nullable().default(null),plan_id:x.number().nullable().default(null),banned:x.boolean().default(!1),commission_type:x.number().default(0),commission_rate:x.number().nullable().default(null),discount:x.number().nullable().default(null),speed_limit:x.number().nullable().default(null),device_limit:x.number().nullable().default(null),is_admin:x.boolean().default(!1),is_staff:x.boolean().default(!1),remarks:x.string().nullable().default(null)});function pi(){const{t:s}=V("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=Hn(),[i,l]=m.useState(!1),[d,u]=m.useState([]),o=we({resolver:Ce(Ah)});return m.useEffect(()=>{n&&gs.getList().then(({data:c})=>{u(c)})},[n]),m.useEffect(()=>{if(r){const c=r.invite_user?.email,{invite_user:h,...k}=r;o.reset({...k,invite_user_email:c||null,password:null})}},[r,o]),e.jsx(qn,{open:n,onOpenChange:t,children:e.jsxs(Ba,{className:"max-w-[90%] space-y-4",children:[e.jsxs(Ga,{children:[e.jsx(Wa,{children:s("edit.title")}),e.jsx(Ya,{})]}),e.jsxs(Se,{...o,children:[e.jsx(v,{control:o.control,name:"email",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.email")}),e.jsx(y,{children:e.jsx(P,{...c,placeholder:s("edit.form.email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(E,{...c})]})}),e.jsx(v,{control:o.control,name:"invite_user_email",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.inviter_email")}),e.jsx(y,{children:e.jsx(P,{value:c.value||"",onChange:h=>c.onChange(h.target.value?h.target.value:null),placeholder:s("edit.form.inviter_email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(E,{...c})]})}),e.jsx(v,{control:o.control,name:"password",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.password")}),e.jsx(y,{children:e.jsx(P,{type:"password",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.password_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(E,{...c})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(v,{control:o.control,name:"balance",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.balance")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(E,{...c})]})}),e.jsx(v,{control:o.control,name:"commission_balance",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.commission_balance")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value||"",onChange:c.onChange,placeholder:s("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(E,{...c})]})}),e.jsx(v,{control:o.control,name:"u",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.upload")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{...c})]})}),e.jsx(v,{control:o.control,name:"d",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.download")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{...c})]})})]}),e.jsx(v,{control:o.control,name:"transfer_enable",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.total_traffic")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value/1024/1024/1024||"",onChange:h=>c.onChange(parseInt(h.target.value)*1024*1024*1024),placeholder:s("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{})]})}),e.jsx(v,{control:o.control,name:"expired_at",render:({field:c})=>e.jsxs(p,{className:"flex flex-col",children:[e.jsx(j,{children:s("edit.form.expire_time")}),e.jsxs(os,{open:i,onOpenChange:l,children:[e.jsx(cs,{asChild:!0,children:e.jsx(y,{children:e.jsxs(L,{type:"button",variant:"outline",className:b("w-full pl-3 text-left font-normal",!c.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[c.value?me(c.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(Ze,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:h=>{h.preventDefault()},onEscapeKeyDown:h=>{h.preventDefault()},children:e.jsxs("div",{className:"flex flex-col space-y-3 p-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{c.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+1),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(L,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const h=new Date;h.setMonth(h.getMonth()+3),h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(vs,{mode:"single",selected:c.value?new Date(c.value*1e3):void 0,onSelect:h=>{if(h){const k=new Date(c.value?c.value*1e3:Date.now());h.setHours(k.getHours(),k.getMinutes(),k.getSeconds()),c.onChange(Math.floor(h.getTime()/1e3))}},disabled:h=>h{const h=new Date;h.setHours(23,59,59,999),c.onChange(Math.floor(h.getTime()/1e3))},className:"h-6 px-2 text-xs",children:s("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{type:"datetime-local",step:"1",value:me(c.value,"YYYY-MM-DDTHH:mm:ss"),onChange:h=>{const k=new Date(h.target.value);isNaN(k.getTime())||c.onChange(Math.floor(k.getTime()/1e3))},className:"flex-1"}),e.jsx(L,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(E,{})]})}),e.jsx(v,{control:o.control,name:"plan_id",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.subscription")}),e.jsx(y,{children:e.jsxs(J,{value:c.value!==null?String(c.value):"null",onValueChange:h=>c.onChange(h==="null"?null:parseInt(h)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx($,{value:"null",children:s("edit.form.subscription_none")}),d.map(h=>e.jsx($,{value:String(h.id),children:h.name},h.id))]})]})})]})}),e.jsx(v,{control:o.control,name:"banned",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.account_status")}),e.jsx(y,{children:e.jsxs(J,{value:c.value.toString(),onValueChange:h=>c.onChange(h==="true"),children:[e.jsx(W,{children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx($,{value:"true",children:s("columns.status_text.banned")}),e.jsx($,{value:"false",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(v,{control:o.control,name:"commission_type",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.commission_type")}),e.jsx(y,{children:e.jsxs(J,{value:c.value.toString(),onValueChange:h=>c.onChange(parseInt(h)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx($,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx($,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx($,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(v,{control:o.control,name:"commission_rate",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.commission_rate")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(v,{control:o.control,name:"discount",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.discount")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(E,{})]})}),e.jsx(v,{control:o.control,name:"speed_limit",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.speed_limit")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(E,{})]})}),e.jsx(v,{control:o.control,name:"device_limit",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.device_limit")}),e.jsx(y,{children:e.jsxs("div",{className:"flex",children:[e.jsx(P,{type:"number",value:c.value||"",onChange:h=>c.onChange(parseInt(h.currentTarget.value)||null),placeholder:s("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(E,{})]})}),e.jsx(v,{control:o.control,name:"is_admin",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(y,{children:e.jsx(Z,{checked:c.value,onCheckedChange:h=>c.onChange(h)})})}),e.jsx(E,{})]})}),e.jsx(v,{control:o.control,name:"is_staff",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(y,{children:e.jsx(Z,{checked:c.value,onCheckedChange:h=>c.onChange(h)})})})]})}),e.jsx(v,{control:o.control,name:"remarks",render:({field:c})=>e.jsxs(p,{children:[e.jsx(j,{children:s("edit.form.remarks")}),e.jsx(y,{children:e.jsx(Ds,{className:"h-24",value:c.value||"",onChange:h=>c.onChange(h.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(E,{})]})}),e.jsxs(mi,{children:[e.jsx(L,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(L,{type:"submit",onClick:()=>{o.handleSubmit(c=>{Ps.update(c).then(({data:h})=>{h&&(A.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function qh(){const[s]=Nl(),[n,t]=m.useState({}),[r,a]=m.useState({is_admin:!1,is_staff:!1}),[i,l]=m.useState([]),[d,u]=m.useState([]),[o,c]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const g=s.get("email");g&&l(w=>w.some(H=>H.id==="email")?w:[...w,{id:"email",value:g}])},[s]);const{refetch:h,data:k,isLoading:C}=ne({queryKey:["userList",o,i,d],queryFn:()=>Ps.getList({pageSize:o.pageSize,current:o.pageIndex+1,filter:i,sort:d})}),[S,f]=m.useState([]),[N,_]=m.useState([]);m.useEffect(()=>{mt.getList().then(({data:g})=>{f(g)}),gs.getList().then(({data:g})=>{_(g)})},[]);const T=S.map(g=>({label:g.name,value:g.id})),D=N.map(g=>({label:g.name,value:g.id}));return e.jsxs(fi,{refreshData:h,children:[e.jsx(Hh,{data:k?.data??[],rowCount:k?.total??0,sorting:d,setSorting:u,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:o,setPagination:c,refetch:h,serverGroupList:S,permissionGroups:T,subscriptionPlans:D,isLoading:C}),e.jsx(pi,{})]})}function Hh({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:o,pagination:c,setPagination:h,refetch:k,serverGroupList:C,permissionGroups:S,subscriptionPlans:f,isLoading:N}){const{setIsOpen:_,setEditingUser:T}=Hn(),D=ss({data:s,columns:$h(k,C,T,_),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:c},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:o,onColumnVisibilityChange:i,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),onPaginationChange:h,getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),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(Th,{table:D,refetch:k,serverGroupList:C,permissionGroups:S,subscriptionPlans:f}),e.jsx(xs,{table:D,isLoading:N})]})}function Uh(){const{t:s}=V("user");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(qh,{})})})]})]})}const Kh=Object.freeze(Object.defineProperty({__proto__:null,default:Uh},Symbol.toStringTag,{value:"Module"}));function Bh({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ld,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{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(Ze,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Js,{children:[e.jsx(ut,{placeholder:n}),e.jsxs(Qs,{children:[e.jsx(xt,{children:"No results found."}),e.jsx(fs,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(We,{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:b("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(id,{className:b("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(Pt,{}),e.jsx(fs,{children:e.jsx(We,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Gh=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 Wh({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(Dt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(dt,{className:"grid w-full grid-cols-2",children:[e.jsx(Xe,{value:"0",children:n("status.pending")}),e.jsx(Xe,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(Bh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:Qe.LOW,icon:Gh,color:"gray"},{label:n("level.medium"),value:Qe.MIDDLE,icon:ui,color:"yellow"},{label:n("level.high"),value:Qe.HIGH,icon:xi,color:"red"}]})]})})}function Yh(){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 Jh=it("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"}}),ji=m.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:b(Jh({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)}));ji.displayName="ChatBubble";const Qh=it("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"}}),vi=m.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:b(Qh({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...i,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(Yh,{})}):a}));vi.displayName="ChatBubbleMessage";const Xh=m.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:b("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}));Xh.displayName="ChatBubbleActionWrapper";const bi=m.forwardRef(({className:s,...n},t)=>e.jsx(Ds,{autoComplete:"off",ref:t,name:"message",className:b("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}));bi.displayName="ChatInput";const yi=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"})}),Ni=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"})}),yr=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"})}),Zh=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"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"})}),eg=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"})}),sg=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 tg(){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(je,{className:"h-8 w-3/4"}),e.jsx(je,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(je,{className:"h-20 w-2/3"},s))})]})}function ag(){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(je,{className:"h-5 w-4/5"}),e.jsx(je,{className:"h-4 w-2/3"}),e.jsx(je,{className:"h-3 w-1/2"})]},s))})}function ng({ticket:s,isActive:n,onClick:t}){const{t:r}=V("ticket"),a=i=>{switch(i){case Qe.HIGH:return"bg-red-50 text-red-600 border-red-200";case Qe.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case Qe.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:b("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===Ws.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Ws.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:me(s.updated_at)}),e.jsx("div",{className:b("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===Qe.LOW?"low":s.level===Qe.MIDDLE?"medium":"high"}`)})]})]})}function rg({ticketId:s,dialogTrigger:n}){const{t}=V("ticket"),r=As(),a=m.useRef(null),i=m.useRef(null),[l,d]=m.useState(!1),[u,o]=m.useState(""),[c,h]=m.useState(!1),[k,C]=m.useState(s),[S,f]=m.useState(""),[N,_]=m.useState(!1),{setIsOpen:T,setEditingUser:D}=Hn(),{data:g,isLoading:w,refetch:R}=ne({queryKey:["tickets",l],queryFn:()=>l?Nt.getList({filter:[{id:"status",value:[Ws.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:H,refetch:I,isLoading:K}=ne({queryKey:["ticket",k,l],queryFn:()=>l?Nt.getInfo(k):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),ae=H?.data,te=(g?.data||[]).filter(ie=>ie.subject.toLowerCase().includes(S.toLowerCase())||ie.user?.email.toLowerCase().includes(S.toLowerCase())),q=(ie="smooth")=>{if(a.current){const{scrollHeight:_s,clientHeight:Fs}=a.current;a.current.scrollTo({top:_s-Fs,behavior:ie})}};m.useEffect(()=>{if(!l)return;const ie=requestAnimationFrame(()=>{q("instant"),setTimeout(()=>q(),1e3)});return()=>{cancelAnimationFrame(ie)}},[l,ae?.messages]);const F=async()=>{const ie=u.trim();!ie||c||(h(!0),Nt.reply({id:k,message:ie}).then(()=>{o(""),I(),q(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{h(!1)}))},X=async()=>{Nt.close(k).then(()=>{A.success(t("actions.close_success")),I(),R()})},Ns=()=>{ae?.user&&r("/finance/order?user_id="+ae.user.id)},De=ae?.status===Ws.CLOSED;return e.jsxs(ge,{open:l,onOpenChange:d,children:[e.jsx(as,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(de,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(fe,{}),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),children:e.jsx(yr,{className:b("h-4 w-4 transition-transform",!N&&"rotate-180")})}),e.jsxs("div",{className:b("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",N?"-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),children:e.jsx(yr,{className:b("h-4 w-4 transition-transform",!N&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Zh,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(P,{placeholder:t("list.search_placeholder"),value:S,onChange:ie=>f(ie.target.value),className:"pl-8"})]})]}),e.jsx(lt,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:w?e.jsx(ag,{}):te.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(S?"list.no_search_results":"list.no_tickets")}):te.map(ie=>e.jsx(ng,{ticket:ie,isActive:ie.id===k,onClick:()=>{C(ie.id),window.innerWidth<768&&_(!0)}},ie.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!N&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>_(!0)}),K?e.jsx(tg,{}):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:ae?.subject}),e.jsx(U,{variant:De?"secondary":"default",children:t(De?"status.closed":"status.processing")}),!De&&e.jsx(ps,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:X,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(yi,{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(Ta,{className:"h-4 w-4"}),e.jsx("span",{children:ae?.user?.email})]}),e.jsx(Te,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Ni,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",me(ae?.created_at)]})]}),e.jsx(Te,{orientation:"vertical",className:"h-4"}),e.jsx(U,{variant:"outline",children:ae?.level!=null&&t(`level.${ae.level===Qe.LOW?"low":ae.level===Qe.MIDDLE?"medium":"high"}`)})]})]}),ae?.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:()=>{D(ae.user),T(!0)},children:e.jsx(Ta,{className:"h-4 w-4"})}),e.jsx(hi,{user_id:ae.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(eg,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:Ns,children:e.jsx(sg,{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:ae?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):ae?.messages?.map(ie=>e.jsx(ji,{variant:ie.is_from_admin?"sent":"received",className:ie.is_from_admin?"ml-auto":"mr-auto",children:e.jsx(vi,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:ie.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:me(ie.created_at)})})]})})},ie.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(bi,{ref:i,disabled:De||c,placeholder:t(De?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:u,onChange:ie=>o(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&!ie.shiftKey&&(ie.preventDefault(),F())}}),e.jsx(G,{disabled:De||c||!u.trim(),onClick:F,children:t(c?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const 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:"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"})}),ig=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"})}),og=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(lg,{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===Qe.LOW?"default":r===Qe.MIDDLE?"secondary":"destructive";return e.jsx(U,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===Qe.LOW?"low":r===Qe.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===Ws.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===Ws.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(Ni,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:me(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:me(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!==Ws.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(rg,{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(ig,{className:"h-4 w-4"})})}),r&&e.jsx(ps,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{Nt.close(t.original.id).then(()=>{A.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(yi,{className:"h-4 w-4"})})})]})}}]};function cg(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([{id:"status",value:"0"}]),[l,d]=m.useState([]),[u,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:c,data:h}=ne({queryKey:["orderList",u,a,l],queryFn:()=>Nt.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),k=ss({data:h?.data??[],columns:og(c),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},rowCount:h?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),onPaginationChange:o,getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Wh,{table:k,refetch:c}),e.jsx(xs,{table:k,showPagination:!0})]})}function dg(){const{t:s}=V("ticket");return e.jsxs(fi,{refreshData:()=>{},children:[e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx(ns,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(cg,{})})]})]}),e.jsx(pi,{})]})}const mg=Object.freeze(Object.defineProperty({__proto__:null,default:dg},Symbol.toStringTag,{value:"Module"}));function ug({table:s,refetch:n}){const{t}=V("user"),r=s.getState().columnFilters.length>0,[a,i]=m.useState(),[l,d]=m.useState(),[u,o]=m.useState(!1),c=[{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")}],h=[{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")}],k=()=>{let N=s.getState().columnFilters.filter(_=>_.id!=="date_range");(a||l)&&N.push({id:"date_range",value:{start:a?Pe(a,"yyyy-MM-dd"):null,end:l?Pe(l,"yyyy-MM-dd"):null}}),s.setColumnFilters(N)},C=async()=>{try{o(!0);const N=s.getState().columnFilters.reduce((I,K)=>{if(K.value)if(K.id==="date_range"){const ae=K.value;ae.start&&(I.start_date=ae.start),ae.end&&(I.end_date=ae.end)}else I[K.id]=K.value;return I},{}),T=(await Xt.getLogs({...N,page:1,per_page:1e4})).data.map(I=>({ID:I.id,用户邮箱:I.user_email,用户ID:I.user_id,重置类型:I.reset_type_name,触发源:I.trigger_source_name,清零流量:I.old_traffic.formatted,"上传流量(GB)":(I.old_traffic.upload/1024**3).toFixed(2),"下载流量(GB)":(I.old_traffic.download/1024**3).toFixed(2),重置时间:Pe(new Date(I.reset_time),"yyyy-MM-dd HH:mm:ss"),记录时间:Pe(new Date(I.created_at),"yyyy-MM-dd HH:mm:ss"),原因:I.reason||""})),D=Object.keys(T[0]||{}),g=[D.join(","),...T.map(I=>D.map(K=>{const ae=I[K];return typeof ae=="string"&&ae.includes(",")?`"${ae}"`:ae}).join(","))].join(` +`),w=new Blob([g],{type:"text/csv;charset=utf-8;"}),R=document.createElement("a"),H=URL.createObjectURL(w);R.setAttribute("href",H),R.setAttribute("download",`traffic-reset-logs-${Pe(new Date,"yyyy-MM-dd")}.csv`),R.style.visibility="hidden",document.body.appendChild(R),R.click(),document.body.removeChild(R),A.success(t("traffic_reset_logs.actions.export_success"))}catch(f){console.error("导出失败:",f),A.error(t("traffic_reset_logs.actions.export_failed"))}finally{o(!1)}},S=()=>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(P,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:f=>s.getColumn("user_email")?.setFilterValue(f.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(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:f=>s.getColumn("reset_type")?.setFilterValue(f==="all"?"":f),children:[e.jsx(W,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),c.map(f=>e.jsx($,{value:f.value,children:f.label},f.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(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:f=>s.getColumn("trigger_source")?.setFilterValue(f==="all"?"":f),children:[e.jsx(W,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),h.map(f=>e.jsx($,{value:f.value,children:f.label},f.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(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:b("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?Pe(a,"MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(vs,{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(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",className:b("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?Pe(l,"MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(vs,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]})]})]}),(a||l)&&e.jsxs(L,{variant:"outline",className:"w-full",onClick:k,children:[e.jsx(rr,{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(ms,{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(ci,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(od,{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(Ba,{side:"bottom",className:"h-[85vh]",children:[e.jsxs(Ga,{className:"mb-4",children:[e.jsx(Wa,{children:t("traffic_reset_logs.filters.filter_title")}),e.jsx(Ya,{children:t("traffic_reset_logs.filters.filter_description")})]}),e.jsx("div",{className:"max-h-[calc(85vh-120px)] overflow-y-auto",children:e.jsx(S,{})})]})]})}),e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",onClick:C,disabled:u,children:[e.jsx(va,{className:"mr-2 h-4 w-4"}),t(u?"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(P,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:f=>s.getColumn("user_email")?.setFilterValue(f.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:f=>s.getColumn("reset_type")?.setFilterValue(f==="all"?"":f),children:[e.jsx(W,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),c.map(f=>e.jsx($,{value:f.value,children:f.label},f.value))]})]}),e.jsxs(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:f=>s.getColumn("trigger_source")?.setFilterValue(f==="all"?"":f),children:[e.jsx(W,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Y,{children:[e.jsx($,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),h.map(f=>e.jsx($,{value:f.value,children:f.label},f.value))]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:b("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?Pe(a,"yyyy-MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(vs,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]}),e.jsxs(os,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(L,{variant:"outline",size:"sm",className:b("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?Pe(l,"yyyy-MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Ze,{className:"w-auto p-0",align:"start",children:e.jsx(vs,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]}),(a||l)&&e.jsxs(L,{variant:"outline",size:"sm",className:"h-8",onClick:k,children:[e.jsx(rr,{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(ms,{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:C,disabled:u,children:[e.jsx(va,{className:"mr-2 h-4 w-4"}),t(u?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})})]})]})}const xg=()=>{const{t:s}=V("user"),n=r=>{switch(r){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=r=>{switch(r){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[{accessorKey:"id",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.id"),className:"w-[60px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[60px]",children:e.jsx(U,{variant:"outline",className:"text-xs",children:r.original.id})}),enableSorting:!0,enableHiding:!0,size:60},{accessorKey:"user_email",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.user"),className:"min-w-[200px]"}),cell:({row:r})=>e.jsxs("div",{className:"flex items-start gap-2 min-w-[200px]",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 font-medium text-sm",children:r.original.user_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",r.original.user_id]})]})]}),enableSorting:!1,enableHiding:!1,size:100},{accessorKey:"reset_type",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.reset_type"),className:"w-[120px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(U,{className:b("border text-xs",n(r.original.reset_type)),children:e.jsx("span",{className:"truncate",children:r.original.reset_type_name})})}),enableSorting:!0,enableHiding:!1,filterFn:(r,a,i)=>i.includes(r.getValue(a)),size:120},{accessorKey:"trigger_source",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.trigger_source"),className:"w-[100px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[100px]",children:e.jsx(U,{variant:"outline",className:b("border text-xs",t(r.original.trigger_source)),children:e.jsx("span",{className:"truncate",children:r.original.trigger_source_name})})}),enableSorting:!0,enableHiding:!0,filterFn:(r,a,i)=>i.includes(r.getValue(a)),size:100},{accessorKey:"old_traffic",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.cleared_traffic"),className:"w-[120px]"}),cell:({row:r})=>{const a=r.original.old_traffic;return e.jsx("div",{className:"w-[120px]",children:e.jsx(be,{delayDuration:100,children:e.jsxs(ue,{children:[e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"text-center cursor-pointer",children:[e.jsx("div",{className:"font-medium text-destructive text-sm",children:a.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(wt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.upload"),":"," ",(a.upload/1024**3).toFixed(2)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(va,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.download"),":"," ",(a.download/1024**3).toFixed(2)," GB"]})]})]})]})})})},enableSorting:!1,enableHiding:!1,size:120},{accessorKey:"reset_time",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.reset_time"),className:"w-[140px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ut,{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:"font-medium text-sm",children:me(r.original.reset_time,"MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:me(r.original.reset_time,"HH:mm")})]})]})}),enableSorting:!0,enableHiding:!0,size:140},{accessorKey:"created_at",header:({column:r})=>e.jsx(z,{column:r,title:s("traffic_reset_logs.columns.log_time"),className:"w-[140px]"}),cell:({row:r})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Pn,{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:"font-medium text-sm",children:me(r.original.created_at,"YYYY-MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:me(r.original.created_at,"H:m:s")})]})]})}),enableSorting:!0,enableHiding:!1,size:1400}]};function hg(){const[s,n]=m.useState({}),[t,r]=m.useState({id:!1,trigger_source:!1,reset_time:!1}),[a,i]=m.useState([]),[l,d]=m.useState([{id:"created_at",desc:!0}]),[u,o]=m.useState({pageIndex:0,pageSize:20}),c={page:u.pageIndex+1,per_page:u.pageSize,...a.reduce((S,f)=>{if(f.value)if(f.id==="date_range"){const N=f.value;N.start&&(S.start_date=N.start),N.end&&(S.end_date=N.end)}else S[f.id]=f.value;return S},{})},{refetch:h,data:k,isLoading:C}=ne({queryKey:["trafficResetLogs",u,a,l],queryFn:()=>Xt.getLogs(c)});return e.jsx(gg,{data:k?.data??[],rowCount:k?.total??0,sorting:l,setSorting:d,columnVisibility:t,setColumnVisibility:r,rowSelection:s,setRowSelection:n,columnFilters:a,setColumnFilters:i,pagination:u,setPagination:o,refetch:h,isLoading:C})}function gg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:o,pagination:c,setPagination:h,refetch:k,isLoading:C}){const S=ss({data:s,columns:xg(),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:c},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:o,onColumnVisibilityChange:i,getCoreRowModel:ts(),getFilteredRowModel:bs(),getPaginationRowModel:us(),onPaginationChange:h,getSortedRowModel:ys(),getFacetedRowModel:Rs(),getFacetedUniqueValues:Es(),initialState:{columnVisibility:{id:!1,trigger_source:!1,reset_time:!1},columnPinning:{left:["user_email"]}}});return e.jsxs("div",{className:"h-full space-y-4",children:[e.jsx(ug,{table:S,refetch:k}),e.jsx("div",{className:"rounded-md border",children:e.jsx(xs,{table:S,isLoading:C})})]})}function fg(){const{t:s}=V("user");return e.jsxs(ze,{children:[e.jsxs($e,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ns,{})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ye,{}),e.jsx(Je,{})]})]}),e.jsxs(He,{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(hg,{})})})]})]})}const pg=Object.freeze(Object.defineProperty({__proto__:null,default:fg},Symbol.toStringTag,{value:"Module"}));export{_g as a,yg as c,Ng as g,wg as r};