diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 7c51e51..8ab0bef 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -59,7 +59,7 @@ import{r as m,j as e,t as il,c as ol,I as Na,a as Ts,S as Xt,u as os,b as ea,d a 3. 최대 동시 접속자: {{capacity}}명`}},force_update:{label:"사용자 플랜 강제 업데이트"},submit:{cancel:"취소",submit:"제출",submitting:"제출 중...",success:{add:"플랜이 성공적으로 추가되었습니다",update:"플랜이 성공적으로 업데이트되었습니다"}}},page:{description:"여기에서 구독 플랜을 구성할 수 있으며, 추가, 삭제 및 편집 작업을 수행할 수 있습니다."}}},$c={title:"주문 관리",description:"여기에서 사용자 주문을 확인할 수 있으며, 할당, 조회, 삭제 등의 작업을 수행할 수 있습니다.",table:{columns:{tradeNo:"주문 번호",type:"유형",plan:"구독 플랜",period:"기간",amount:"결제 금액",status:"주문 상태",commission:"수수료 금액",commissionStatus:"수수료 상태",createdAt:"생성 시간"}},type:{NEW:"신규 구매",RENEWAL:"갱신",UPGRADE:"업그레이드",RESET_FLOW:"트래픽 초기화"},period:{month_price:"월간",quarter_price:"분기",half_year_price:"반기",year_price:"연간",two_year_price:"2년",three_year_price:"3년",onetime_price:"일회성",reset_price:"초기화 패키지"},status:{PENDING:"대기 중",PROCESSING:"처리 중",CANCELLED:"취소됨",COMPLETED:"완료됨",DISCOUNTED:"할인 적용됨",tooltip:"[결제 완료] 표시 후 시스템이 활성화 및 완료 처리를 진행합니다"},commission:{PENDING:"대기 중",PROCESSING:"처리 중",VALID:"유효",INVALID:"무효"},actions:{markAsPaid:"결제 완료 표시",cancel:"주문 취소",openMenu:"메뉴 열기",reset:"초기화"},search:{placeholder:"주문 검색..."},dialog:{title:"주문 정보",basicInfo:"기본 정보",amountInfo:"금액 정보",timeInfo:"시간 정보",addOrder:"주문 추가",assignOrder:"주문 할당",fields:{userEmail:"사용자 이메일",orderPeriod:"주문 기간",subscriptionPlan:"구독 플랜",callbackNo:"콜백 번호",paymentAmount:"결제 금액",balancePayment:"잔액 결제",discountAmount:"할인 금액",refundAmount:"환불 금액",deductionAmount:"차감 금액",createdAt:"생성 시간",updatedAt:"업데이트 시간"},placeholders:{email:"사용자 이메일을 입력해주세요",plan:"구독 플랜을 선택해주세요",period:"구독 기간을 선택해주세요",amount:"결제 금액을 입력해주세요"},actions:{cancel:"취소",confirm:"확인"},messages:{addSuccess:"추가 완료"}}},Hc={title:"시스템 설정",description:"사이트, 보안, 구독, 초대 수수료, 노드, 이메일 및 알림을 포함한 핵심 시스템 구성을 관리합니다",server:{title:"서버 설정",description:"통신 키, 폴링 간격, 로드 밸런싱 및 기타 고급 옵션을 포함한 노드 통신 및 동기화 설정을 구성합니다.",server_token:{title:"통신 토큰",placeholder:"통신 토큰 입력",description:"서버 간 인증에 사용됩니다",generate_tooltip:"클릭하여 무작위 토큰 생성"},server_pull_interval:{title:"노드 풀 작업 폴링 간격",description:"노드가 패널에서 데이터를 가져오는 빈도입니다.",placeholder:"풀 간격 입력"},server_push_interval:{title:"노드 푸시 작업 폴링 간격",description:"노드가 패널로 데이터를 푸시하는 빈도입니다.",placeholder:"푸시 간격 입력"},device_limit_mode:{title:"기기 제한 모드",description:"완화 모드에서는 동일한 IP 주소의 여러 노드가 하나의 기기로 계산됩니다.",strict:"엄격 모드",relaxed:"완화 모드",placeholder:"기기 제한 모드 선택"}},invite:{title:"초대 및 수수료 설정",description:"초대 등록 및 수수료 관련 설정을 구성합니다.",invite_force:{title:"강제 초대 활성화",description:"활성화하면 초대받은 사용자만 등록할 수 있습니다."},invite_commission:{title:"초대 수수료 비율",description:"기본 전역 수수료 분배 비율입니다. 사용자 관리에서 개별 비율을 구성할 수 있습니다.",placeholder:"수수료 비율 입력"},invite_gen_limit:{title:"초대 코드 생성 제한",description:"사용자가 생성할 수 있는 최대 초대 코드 수",placeholder:"생성 제한 입력"},invite_never_expire:{title:"초대 코드 만료 없음",description:"활성화하면 초대 코드가 사용 후에도 만료되지 않으며, 그렇지 않으면 사용 후 만료됩니다."},commission_first_time:{title:"첫 결제 수수료만",description:"활성화하면 초대받은 사용자의 첫 결제에서만 수수료가 생성되며, 사용자 관리에서 개별적으로 구성할 수 있습니다."},commission_auto_check:{title:"자동 수수료 확인",description:"활성화하면 주문 완료 3일 후 수수료가 자동으로 확인됩니다."},commission_withdraw_limit:{title:"출금 임계값 (위안)",description:"이 임계값 미만의 출금 요청은 제출되지 않습니다.",placeholder:"출금 임계값 입력"},commission_withdraw_method:{title:"출금 방법",description:"지원되는 출금 방법, 여러 방법은 쉼표로 구분합니다.",placeholder:"출금 방법 입력, 쉼표로 구분"},withdraw_close:{title:"출금 비활성화",description:"활성화하면 사용자가 출금을 요청할 수 없으며, 초대 수수료는 사용자 잔액으로 직접 이동합니다."},commission_distribution:{title:"3단계 분배",description:"활성화하면 수수료가 설정된 세 비율에 따라 분할되며, 총합은 100%를 초과할 수 없습니다.",l1:"1단계 초대자 비율",l2:"2단계 초대자 비율",l3:"3단계 초대자 비율",placeholder:"비율 입력 예: 50"},saving:"저장 중..."},site:{title:"사이트 설정",description:"사이트 이름, 설명, 통화 단위 및 기타 핵심 설정을 포함한 기본 사이트 정보를 구성합니다.",form:{siteName:{label:"사이트 이름",placeholder:"사이트 이름을 입력해주세요",description:"사이트 이름이 표시되어야 하는 곳에 사용됩니다."},siteDescription:{label:"사이트 설명",placeholder:"사이트 설명을 입력해주세요",description:"사이트 설명이 표시되어야 하는 곳에 사용됩니다."},siteUrl:{label:"사이트 URL",placeholder:"사이트 URL을 입력해주세요, 끝에 /를 제외",description:"현재 웹사이트 URL, 이메일 및 URL이 필요한 다른 곳에서 사용됩니다."},forceHttps:{label:"HTTPS 강제",description:"사이트가 HTTPS를 사용하지 않지만 CDN 또는 리버스 프록시가 HTTPS를 강제할 때 활성화해야 합니다."},logo:{label:"LOGO",placeholder:"LOGO URL을 입력해주세요, 끝에 /를 제외",description:"LOGO가 표시되어야 하는 곳에 사용됩니다."},subscribeUrl:{label:"구독 URL",placeholder:"구독에 사용됩니다. 여러 URL은 ','로 구분. 비워두면 사이트 URL을 사용합니다.",description:"구독에 사용되며, 비워두면 사이트 URL을 사용합니다."},tosUrl:{label:"이용약관(TOS) URL",placeholder:"이용약관 URL을 입력해주세요, 끝에 /를 제외",description:"이용약관(TOS) 링크에 사용됩니다"},stopRegister:{label:"신규 사용자 등록 중지",description:"활성화하면 누구도 등록할 수 없습니다."},tryOut:{label:"등록 체험",placeholder:"비활성화",description:"체험용 구독을 선택하세요. 옵션이 없다면 먼저 구독 관리에서 추가하세요.",duration:{label:"체험 기간",placeholder:"0",description:"체험 기간(시간)."}},currency:{label:"통화 단위",placeholder:"CNY",description:"표시용으로만 사용되며, 변경하면 시스템의 모든 통화 단위에 영향을 미칩니다."},currencySymbol:{label:"통화 기호",placeholder:"¥",description:"표시용으로만 사용되며, 변경하면 시스템의 모든 통화 기호에 영향을 미칩니다."}}},safe:{title:"보안 설정",description:"로그인 인증, 비밀번호 정책 및 API 접근 설정을 포함한 시스템 보안 옵션을 구성합니다.",form:{emailVerify:{label:"이메일 인증",description:"활성화하면 사용자는 이메일을 인증해야 합니다."},gmailLimit:{label:"Gmail 별칭 비활성화",description:"활성화하면 Gmail 별칭으로 등록할 수 없습니다."},safeMode:{label:"안전 모드",description:"활성화하면 사이트 URL 이외의 도메인을 통한 접근이 403으로 차단됩니다."},securePath:{label:"관리자 경로",placeholder:"admin",description:"관리자 관리 경로, 변경하면 기존 관리자 경로가 수정됩니다"},emailWhitelist:{label:"이메일 접미사 화이트리스트",description:"활성화하면 목록의 이메일 접미사만 등록할 수 있습니다.",suffixes:{label:"이메일 접미사",placeholder:"이메일 접미사를 한 줄에 하나씩 입력",description:"허용된 이메일 접미사를 한 줄에 하나씩 입력하세요"}},recaptcha:{enable:{label:"reCAPTCHA 활성화",description:"활성화하면 사용자는 등록 시 reCAPTCHA 인증을 통과해야 합니다."},key:{label:"reCAPTCHA 키",placeholder:"reCAPTCHA 키 입력",description:"reCAPTCHA 키를 입력하세요"},siteKey:{label:"reCAPTCHA 사이트 키",placeholder:"reCAPTCHA 사이트 키 입력",description:"reCAPTCHA 사이트 키를 입력하세요"}},registerLimit:{enable:{label:"IP 등록 제한",description:"활성화하면 동일 IP에서의 등록 수가 제한됩니다."},count:{label:"등록 횟수",placeholder:"최대 등록 횟수 입력",description:"동일 IP에서 허용되는 최대 등록 횟수"},expire:{label:"제한 기간",placeholder:"제한 기간을 시간 단위로 입력",description:"등록 제한 기간(시간)"}},passwordLimit:{enable:{label:"비밀번호 시도 제한",description:"활성화하면 비밀번호 시도 횟수가 제한됩니다."},count:{label:"시도 횟수",placeholder:"최대 시도 횟수 입력",description:"허용되는 최대 비밀번호 시도 횟수"},expire:{label:"잠금 기간",placeholder:"잠금 기간을 시간 단위로 입력",description:"계정 잠금 기간(시간)"}}}},subscribe:{title:"구독 설정",description:"구독 링크 형식, 업데이트 빈도, 트래픽 통계 및 기타 설정을 포함한 구독 관련 구성을 관리합니다.",plan_change_enable:{title:"구독 변경 허용",description:"활성화하면 사용자가 구독 플랜을 변경할 수 있습니다."},reset_traffic_method:{title:"월간 트래픽 초기화 방식",description:"전역 트래픽 초기화 방식으로, 기본값은 매월 1일입니다. 구독 관리에서 구독별로 개별 설정할 수 있습니다.",options:{monthly_first:"매월 1일",monthly_reset:"월간 초기화",no_reset:"초기화 없음",yearly_first:"1월 1일",yearly_reset:"연간 초기화"}},surplus_enable:{title:"공제 플랜 활성화",description:"활성화하면 사용자가 구독을 변경할 때 시스템이 기존 구독에서 공제합니다. 자세한 내용은 문서를 참조하세요."},new_order_event:{title:"새 주문 이벤트",description:"새 주문이 생성될 때 실행할 작업을 선택합니다."}}},Gc={trafficRecord:{title:"트래픽 사용 기록",time:"시간",upload:"업로드",download:"다운로드",rate:"요금",total:"총계",noRecords:"기록이 없습니다",perPage:"페이지당 표시",records:"기록",page:"페이지 {{current}} / {{total}}",multiplier:"{{value}}배"}},qc={title:"티켓 관리",description:"여기에서 사용자 티켓을 확인할 수 있으며, 조회, 답변 및 종료 작업을 수행할 수 있습니다.",columns:{id:"티켓 ID",subject:"제목",level:"우선순위",status:"상태",updated_at:"최근 업데이트",created_at:"생성 시간",actions:"작업"},status:{closed:"종료됨",replied:"답변됨",pending:"대기 중",processing:"처리 중"},level:{low:"낮음",medium:"중간",high:"높음"},filter:{placeholder:"{field} 검색...",no_results:"검색 결과가 없습니다.",selected:"{count}개 선택됨",clear:"필터 초기화"},actions:{view_details:"상세 보기",close_ticket:"티켓 종료",close_confirm_title:"티켓 종료 확인",close_confirm_description:"종료 후에는 답변할 수 없습니다. 이 티켓을 종료하시겠습니까?",close_confirm_button:"티켓 종료",close_success:"티켓이 성공적으로 종료되었습니다",view_ticket:"티켓 보기"},detail:{no_messages:"메시지가 아직 없습니다",created_at:"생성 시간",user_info:"사용자 정보",traffic_records:"트래픽 기록",order_records:"주문 기록",input:{closed_placeholder:"티켓이 종료되었습니다",reply_placeholder:"답변을 입력하세요...",sending:"전송 중...",send:"전송"}}},Kc={manage:{title:"사용자 관리",description:"여기에서 사용자 추가, 삭제, 편집 및 조회 작업을 수행할 수 있습니다."},columns:{is_admin:"관리자",is_staff:"스태프",id:"ID",email:"이메일",online_count:"온라인 기기",status:"상태",subscription:"구독",group:"그룹",used_traffic:"사용된 트래픽",total_traffic:"총 트래픽",expire_time:"만료 시간",balance:"잔액",commission:"수수료",register_time:"등록 시간",actions:"작업",device_limit:{unlimited:"기기 제한 없음",limited:"최대 {{count}}대의 기기 허용"},status_text:{normal:"정상",banned:"차단됨"},online_status:{online:"현재 온라인",never:"접속 기록 없음",last_online:"마지막 접속: {{time}}",offline_duration:{days:"오프라인 기간: {{count}}일",hours:"오프라인 기간: {{count}}시간",minutes:"오프라인 기간: {{count}}분",seconds:"오프라인 기간: {{count}}초"}},expire_status:{permanent:"영구",expired:"{{days}}일 전 만료됨",remaining:"{{days}}일 남음"},actions_menu:{edit:"편집",assign_order:"주문 할당",copy_url:"구독 URL 복사",reset_secret:"UUID 및 URL 재설정",orders:"주문",invites:"초대",traffic_records:"트래픽 기록"}},filter:{selected:"{{count}}개 선택됨",no_results:"검색 결과가 없습니다.",clear:"필터 초기화",search_placeholder:"검색...",email_search:"사용자 이메일 검색...",advanced:"고급 필터",reset:"필터 초기화",sheet:{title:"고급 필터",description:"하나 이상의 필터 조건을 추가하여 사용자를 정확하게 찾기",conditions:"필터 조건",add:"조건 추가",condition:"조건 {{number}}",field:"필드 선택",operator:"연산자 선택",value:"값 입력",value_number:"값 입력 ({{unit}})",reset:"초기화",apply:"필터 적용"},fields:{email:"이메일",id:"사용자 ID",plan_id:"구독",transfer_enable:"트래픽",total_used:"사용된 트래픽",online_count:"온라인 기기",expired_at:"만료 시간",uuid:"UUID",token:"토큰",banned:"계정 상태",remark:"비고",inviter_email:"초대자 이메일",invite_user_id:"초대자 ID",is_admin:"관리자",is_staff:"스태프"},operators:{contains:"포함",eq:"일치",gt:"초과",lt:"미만"},status:{normal:"정상",banned:"차단됨"},boolean:{true:"예",false:"아니오"}},generate:{button:"사용자 생성",title:"사용자 생성",form:{email:"이메일",email_prefix:"계정 (일괄 생성시 비워두기)",email_domain:"도메인",password:"비밀번호",password_placeholder:"비워두면 이메일을 비밀번호로 사용",expire_time:"만료 시간",expire_time_placeholder:"사용자 만료 날짜 선택, 영구는 비워두기",permanent:"영구",subscription:"구독 플랜",subscription_none:"없음",generate_count:"생성 수량",generate_count_placeholder:"일괄 생성할 수량 입력",cancel:"취소",submit:"생성",success:"생성 완료"}},edit:{button:"사용자 정보 편집",title:"사용자 관리",form:{email:"이메일",email_placeholder:"이메일을 입력해주세요",inviter_email:"초대자 이메일",inviter_email_placeholder:"이메일을 입력해주세요",password:"비밀번호",password_placeholder:"변경하려면 새 비밀번호 입력",balance:"잔액",balance_placeholder:"잔액을 입력해주세요",commission_balance:"수수료 잔액",commission_balance_placeholder:"수수료 잔액을 입력해주세요",upload:"업로드 트래픽",upload_placeholder:"업로드 트래픽",download:"다운로드 트래픽",download_placeholder:"다운로드 트래픽",total_traffic:"총 트래픽",total_traffic_placeholder:"트래픽을 입력해주세요",expire_time:"만료 시간",expire_time_placeholder:"사용자 만료 날짜 선택, 영구는 비워두기",expire_time_specific:"특정 시간",expire_time_today:"오늘 종료로 설정",expire_time_permanent:"영구",expire_time_1month:"1개월",expire_time_3months:"3개월",expire_time_confirm:"확인",subscription:"구독 플랜",subscription_none:"없음",account_status:"계정 상태",commission_type:"수수료 유형",commission_type_system:"시스템 설정 따르기",commission_type_cycle:"주기별 수수료",commission_type_onetime:"일회성 수수료",commission_rate:"수수료율",commission_rate_placeholder:"사이트 수수료율을 따르려면 비워두기",discount:"전용 할인",discount_placeholder:"전용 할인이 없으면 비워두기",speed_limit:"속도 제한",speed_limit_placeholder:"속도 제한이 없으면 비워두기",device_limit:"기기 제한",device_limit_placeholder:"기기 제한이 없으면 비워두기",is_admin:"관리자 여부",is_staff:"스태프 여부",remarks:"비고",remarks_placeholder:"비고를 입력해주세요",cancel:"취소",submit:"제출",success:"수정 완료"}}},Bc={title:"라우트 관리",description:"모든 라우트 그룹을 관리하며, 추가, 삭제 및 편집 작업을 수행할 수 있습니다.",columns:{id:"그룹 ID",remarks:"비고",action:"동작",actions:"작업",matchRules:"{{count}}개 규칙 일치"},actions:{dns:"지정된 DNS 서버로 해석",block:"접근 차단"},form:{add:"라우트 추가",edit:"라우트 편집",create:"라우트 생성",remarks:"비고",remarksPlaceholder:"비고를 입력해주세요",match:"일치 규칙",matchPlaceholder:`example.com *.example.com`,action:"동작",actionPlaceholder:"동작을 선택해주세요",dns:"DNS 서버",dnsPlaceholder:"DNS 서버를 입력해주세요",cancel:"취소",submit:"제출",validation:{remarks:"올바른 비고를 입력해주세요"}},toolbar:{searchPlaceholder:"라우트 검색...",reset:"초기화"},messages:{deleteConfirm:"삭제 확인",deleteDescription:"이 작업은 이 라우트 그룹을 영구적으로 삭제하며 복구할 수 없습니다. 계속하시겠습니까?",deleteButton:"삭제",deleteSuccess:"삭제 완료",createSuccess:"생성 완료",updateSuccess:"업데이트 완료"}},Wc={title:"결제 설정",description:"알리페이, 위챗페이 등의 결제 수단을 설정합니다.",table:{columns:{id:"ID",enable:"활성화",name:"표시 이름",payment:"결제 게이트웨이",notify_url:"알림 URL",notify_url_tooltip:"결제 게이트웨이가 이 주소로 알림을 보냅니다. 방화벽을 통해 접근 가능한지 확인해주세요.",actions:"작업"},actions:{edit:"편집",delete:{title:"삭제 확인",description:"이 결제 수단을 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",success:"삭제 완료"}},toolbar:{search:"결제 수단 검색...",reset:"초기화",sort:{hint:"결제 수단을 드래그하여 정렬하고, 완료 후 저장을 클릭하세요",save:"순서 저장",edit:"순서 편집"}}},form:{add:{button:"결제 수단 추가",title:"결제 수단 추가"},edit:{title:"결제 수단 편집"},fields:{name:{label:"표시 이름",placeholder:"결제 이름 입력",description:"프론트엔드 표시용"},icon:{label:"아이콘 URL",placeholder:"https://example.com/icon.svg",description:"프론트엔드 표시용 아이콘 URL"},notify_domain:{label:"알림 도메인",placeholder:"https://example.com",description:"게이트웨이 알림용 도메인"},handling_fee_percent:{label:"수수료 비율 (%)",placeholder:"0-100"},handling_fee_fixed:{label:"고정 수수료",placeholder:"0"},payment:{label:"결제 게이트웨이",placeholder:"결제 게이트웨이 선택",description:"사용할 결제 게이트웨이 선택"}},validation:{name:{min:"이름은 최소 2자 이상이어야 합니다",max:"이름은 30자를 초과할 수 없습니다"},notify_domain:{url:"올바른 URL을 입력해주세요"},payment:{required:"결제 게이트웨이를 선택해주세요"}},buttons:{cancel:"취소",submit:"제출"},messages:{success:"저장 완료"}}},Yc={title:"공지사항 관리",description:"여기에서 공지사항을 구성할 수 있으며, 추가, 삭제, 편집 등의 작업을 수행할 수 있습니다.",table:{columns:{id:"ID",show:"표시 상태",title:"제목",actions:"작업"},toolbar:{search:"공지사항 제목 검색...",reset:"초기화",sort:{edit:"순서 편집",save:"순서 저장"}},actions:{edit:"편집",delete:{title:"삭제 확인",description:"이 공지사항을 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",success:"삭제 완료"}}},form:{add:{title:"공지사항 추가",button:"공지사항 추가"},edit:{title:"공지사항 편집"},fields:{title:{label:"제목",placeholder:"공지사항 제목을 입력해주세요"},content:{label:"내용"},img_url:{label:"배경 이미지",placeholder:"공지사항 배경 이미지 URL을 입력해주세요"},show:{label:"표시"},tags:{label:"태그",placeholder:"Enter를 눌러 태그 추가"}},buttons:{cancel:"취소",submit:"제출",success:"제출 완료"}}},Jc={title:"테마 설정",description:"테마 색상, 글꼴 크기 등을 포함한 테마 설정입니다. V2board를 프론트엔드와 백엔드로 분리하여 배포하는 경우 테마 설정이 적용되지 않습니다.",upload:{button:"테마 업로드",title:"테마 업로드",description:"유효한 테마 패키지(.zip 형식)를 업로드해주세요. 테마 패키지는 완전한 테마 파일 구조를 포함해야 합니다.",dragText:"테마 파일을 여기에 끌어다 놓거나",clickText:"클릭하여 선택",supportText:".zip 형식의 테마 패키지 지원",uploading:"업로드 중...",error:{format:"ZIP 형식의 테마 파일만 지원됩니다"}},preview:{title:"테마 미리보기",imageCount:"{{current}} / {{total}}"},card:{version:"버전: {{version}}",currentTheme:"현재 테마",activateTheme:"테마 활성화",configureTheme:"테마 설정",preview:"미리보기",delete:{title:"테마 삭제",description:"이 테마를 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",button:"삭제",error:{active:"현재 활성화된 테마는 삭제할 수 없습니다"}}},config:{title:"{{name}} 테마 구성",description:"테마 스타일, 레이아웃 및 기타 표시 옵션을 수정합니다.",cancel:"취소",save:"저장",success:"설정이 성공적으로 저장되었습니다"}},Qc={title:"쿠폰 관리",description:"여기에서 쿠폰을 관리할 수 있으며, 추가, 조회 및 삭제 작업을 수행할 수 있습니다.",table:{columns:{id:"ID",show:"활성화",name:"쿠폰 이름",type:"유형",code:"코드",limitUse:"남은 사용 횟수",limitUseWithUser:"사용자당 사용 횟수",validity:"유효 기간",actions:"작업"},validity:{expired:"{{days}}일 전 만료됨",notStarted:"{{days}}일 후 시작",remaining:"{{days}}일 남음",startTime:"시작 시간",endTime:"종료 시간",unlimited:"무제한",noLimit:"제한 없음"},actions:{edit:"편집",delete:"삭제",deleteConfirm:{title:"삭제 확인",description:"이 작업은 이 쿠폰을 영구적으로 삭제하며 취소할 수 없습니다. 계속하시겠습니까?",confirmText:"삭제"}},toolbar:{search:"쿠폰 검색...",type:"유형",reset:"초기화",types:{1:"고정 금액",2:"비율"}}},form:{add:"쿠폰 추가",edit:"쿠폰 편집",name:{label:"쿠폰 이름",placeholder:"쿠폰 이름 입력",required:"쿠폰 이름을 입력해주세요"},type:{label:"쿠폰 유형 및 값",placeholder:"쿠폰 유형 선택"},value:{placeholder:"값 입력"},validity:{label:"유효 기간",to:"부터",endTimeError:"종료 시간은 시작 시간보다 늦어야 합니다"},limitUse:{label:"최대 사용 횟수",placeholder:"최대 사용 횟수 설정, 무제한은 비워두기",description:"이 쿠폰의 총 사용 가능 횟수를 설정합니다. 무제한은 비워두세요"},limitUseWithUser:{label:"사용자당 사용 횟수",placeholder:"사용자당 사용 횟수 설정, 무제한은 비워두기",description:"각 사용자가 이 쿠폰을 사용할 수 있는 횟수를 제한합니다. 무제한은 비워두세요"},limitPeriod:{label:"구독 기간",placeholder:"특정 구독 기간으로 제한, 제한 없음은 비워두기",description:"이 쿠폰을 사용할 수 있는 구독 기간을 선택합니다. 제한이 없으면 비워두세요",empty:"일치하는 기간이 없습니다"},limitPlan:{label:"구독 플랜",placeholder:"특정 구독 플랜으로 제한, 제한 없음은 비워두기",empty:"일치하는 플랜이 없습니다"},code:{label:"사용자 지정 쿠폰 코드",placeholder:"사용자 지정 코드 입력, 자동 생성은 비워두기",description:"쿠폰 코드를 사용자 지정합니다. 자동 생성하려면 비워두세요"},generateCount:{label:"일괄 생성 수량",placeholder:"생성할 쿠폰 수량, 단일 쿠폰은 비워두기",description:"여러 쿠폰 코드를 한 번에 생성합니다. 단일 코드 생성은 비워두세요"},submit:{saving:"저장 중...",save:"저장"},error:{saveFailed:"쿠폰 저장 실패"}}},Zc={title:"권한 그룹",description:"모든 권한 그룹을 관리하며, 추가, 삭제 및 편집 작업을 수행할 수 있습니다.",columns:{id:"그룹 ID",name:"그룹 이름",usersCount:"사용자 수",serverCount:"노드 수",actions:"작업"},form:{add:"그룹 추가",edit:"그룹 편집",create:"그룹 생성",update:"업데이트",name:"그룹 이름",namePlaceholder:"그룹 이름을 입력해주세요",nameDescription:"그룹 이름은 서로 다른 사용자 그룹을 구분하는 데 사용되며, 의미 있는 이름을 사용하는 것이 좋습니다.",cancel:"취소",editDescription:"그룹 정보를 수정하면 즉시 적용됩니다.",createDescription:"새로운 권한 그룹을 생성하여 서로 다른 사용자에게 다른 권한을 할당합니다."},toolbar:{searchPlaceholder:"그룹 검색...",reset:"초기화"},messages:{deleteConfirm:"삭제 확인",deleteDescription:"이 작업은 이 권한 그룹을 영구적으로 삭제하며 복구할 수 없습니다. 계속하시겠습니까?",deleteButton:"삭제",createSuccess:"생성 완료",updateSuccess:"업데이트 완료",nameValidation:{min:"그룹 이름은 최소 2자 이상이어야 합니다",max:"그룹 이름은 50자를 초과할 수 없습니다",pattern:"그룹 이름은 문자, 숫자, 한자, 밑줄 및 하이픈만 포함할 수 있습니다"}}},Xc={title:"지식 베이스",description:"여기에서 지식 베이스를 구성할 수 있으며, 추가, 삭제 및 편집 작업을 수행할 수 있습니다.",columns:{id:"ID",status:"상태",title:"제목",category:"카테고리",actions:"작업"},form:{add:"지식 추가",edit:"지식 편집",title:"제목",titlePlaceholder:"지식 제목을 입력해주세요",category:"카테고리",categoryPlaceholder:"카테고리를 입력하면 자동으로 분류됩니다",language:"언어",languagePlaceholder:"언어를 선택해주세요",content:"내용",show:"표시",cancel:"취소",submit:"제출"},languages:{"en-US":"English","ja-JP":"日本語","ko-KR":"한국어","vi-VN":"Tiếng Việt","zh-CN":"简体中文","zh-TW":"繁體中文"},messages:{deleteConfirm:"삭제 확인",deleteDescription:"이 작업은 이 지식 베이스 기록을 영구적으로 삭제하며 복구할 수 없습니다. 계속하시겠습니까?",deleteButton:"삭제",operationSuccess:"작업 성공"},toolbar:{searchPlaceholder:"지식 검색...",reset:"초기화",sortModeHint:"지식 항목을 드래그하여 정렬하고, 완료 후 저장을 클릭하세요",editSort:"정렬 편집",saveSort:"정렬 저장"}},ed={en:{common:Qo,dashboard:Zo,search:Xo,nav:ec,sidebar:sc,server:tc,subscribe:ac,order:nc,settings:rc,traffic:lc,ticket:ic,user:oc,route:cc,payment:dc,notice:mc,theme:uc,coupon:hc,group:pc,knowledge:xc},zh:{common:fc,dashboard:gc,search:jc,nav:bc,sidebar:vc,server:yc,subscribe:_c,order:Nc,settings:wc,traffic:Cc,ticket:Sc,user:kc,route:Pc,payment:Tc,notice:Dc,theme:Rc,coupon:Ic,group:Ec,knowledge:Mc},ko:{common:Lc,dashboard:Oc,search:Vc,nav:Ac,sidebar:Fc,server:zc,subscribe:Uc,order:$c,settings:Hc,traffic:Gc,ticket:qc,user:Kc,route:Bc,payment:Wc,notice:Yc,theme:Jc,coupon:Qc,group:Zc,knowledge:Xc}};pl.use(xl).use(fl).init({resources:ed,fallbackLng:"en",supportedLngs:["en","zh","ko"],ns:["common","dashboard","search","nav","sidebar","server","subscribe","order","settings","traffic","ticket","user","route","payment","notice","theme","coupon","group","knowledge"],defaultNS:"common",fallbackNS:"common",detection:{order:["localStorage","navigator"],caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const sd=new gl;jl.createRoot(document.getElementById("root")).render(e.jsx(bl.StrictMode,{children:e.jsx(vl,{client:sd,children:e.jsx(yl,{store:Xn,children:e.jsxs(Po,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(_l,{router:Uo}),e.jsx(Nl,{richColors:!0,position:"top-right"})]})})})}));const Ge=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Ge.displayName="Card";const ss=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex flex-col space-y-1.5 p-6",s),...n}));ss.displayName="CardHeader";const vs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:y("font-semibold leading-none tracking-tight",s),...n}));vs.displayName="CardTitle";const tt=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:y("text-sm text-muted-foreground",s),...n}));tt.displayName="CardDescription";const ts=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("p-6 pt-0",s),...n}));ts.displayName="CardContent";const td=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex items-center p-6 pt-0",s),...n}));td.displayName="CardFooter";const ad=Ts("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Nt=m.forwardRef(({className:s,...n},a)=>e.jsx(qa,{ref:a,className:y(ad(),s),...n}));Nt.displayName=qa.displayName;const he=wl,er=m.createContext({}),j=({...s})=>e.jsx(er.Provider,{value:{name:s.name},children:e.jsx(Cl,{...s})}),It=()=>{const s=m.useContext(er),n=m.useContext(sr),{getFieldState:a,formState:l}=Sl(),r=a(s.name,l);if(!s)throw new Error("useFormField should be used within ");const{id:c}=n;return{id:c,name:s.name,formItemId:`${c}-form-item`,formDescriptionId:`${c}-form-item-description`,formMessageId:`${c}-form-item-message`,...r}},sr=m.createContext({}),g=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(sr.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:y("space-y-2",s),...n})})});g.displayName="FormItem";const b=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=It();return e.jsx(Nt,{ref:a,className:y(l&&"text-destructive",s),htmlFor:r,...n})});b.displayName="FormLabel";const _=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=It();return e.jsx(Xt,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});_.displayName="FormControl";const L=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=It();return e.jsx("p",{ref:a,id:l,className:y("text-[0.8rem] text-muted-foreground",s),...n})});L.displayName="FormDescription";const D=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=It(),o=r?String(r?.message):n;return o?e.jsx("p",{ref:l,id:c,className:y("text-[0.8rem] font-medium text-destructive",s),...a,children:o}):null});D.displayName="FormMessage";const T=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:l,...a}));T.displayName="Input";const tr=m.forwardRef(({className:s,...n},a)=>{const[l,r]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:l?"text":"password",className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}),e.jsx(R,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>r(c=>!c),children:l?e.jsx(kl,{size:18}):e.jsx(Pl,{size:18})})]})});tr.displayName="PasswordInput";const nd=s=>V({url:"/passport/auth/login",method:"post",data:s}),Yt=s=>s;function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Dl(s).format(n))}function rd(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function zs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const a=typeof s=="string"?parseFloat(s):s;if(isNaN(a))return n?"¥0.00":"0.00";const r=(a/100).toFixed(2).replace(/\.?0+$/,c=>c.includes(".")?".00":c);return n?`¥${r}`:r}function wt(s){navigator.clipboard?navigator.clipboard.writeText(s).then(()=>{$.success(Yt("复制成功"))}).catch(n=>{console.error("复制到剪贴板时出错:",n),Ma(s)}):Ma(s)}function Ma(s){const n=document.createElement("button"),a=new Tl(n,{text:()=>s});a.on("success",()=>{$.success(Yt("复制成功")),a.destroy()}),a.on("error",()=>{$.error(Yt("复制失败")),a.destroy()}),n.click()}function Ze(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?zs(r)+" TB":l>=1?zs(l)+" GB":a>=1?zs(a)+" MB":zs(n)+" KB"}const ld="access_token";function id(s){Rt.set(ld,s)}const od=p.object({email:p.string().min(1,{message:"请输入邮箱地址"}).email({message:"邮箱地址格式不正确"}),password:p.string().min(1,{message:"请输入密码"}).min(7,{message:"密码长度至少为7个字符"})});function cd({className:s,onForgotPassword:n,...a}){const l=os(),r=Ka(),c=ce({resolver:ue(od),defaultValues:{email:"",password:""}});async function o(u){nd(u).then(({data:h})=>{id(h.auth_data),r(Bo(h.auth_data)),r(Xs()).unwrap(),l("/")})}return e.jsx("div",{className:y("grid gap-6",s),...a,children:e.jsx(he,{...c,children:e.jsx("form",{onSubmit:c.handleSubmit(o),children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(j,{control:c.control,name:"email",render:({field:u})=>e.jsxs(g,{className:"space-y-1",children:[e.jsx(b,{children:"邮箱地址"}),e.jsx(_,{children:e.jsx(T,{placeholder:"name@example.com",...u})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"password",render:({field:u})=>e.jsxs(g,{className:"space-y-1",children:[e.jsx(b,{children:"密码"}),e.jsx(_,{children:e.jsx(tr,{placeholder:"请输入密码",...u})}),e.jsx(D,{})]})}),e.jsx(R,{className:"mt-2",loading:c.formState.isSubmitting,children:"登录"}),e.jsx(R,{variant:"link",type:"button",className:"mt-1 text-sm text-muted-foreground hover:text-primary",onClick:n,children:"忘记密码?"})]})})})})}const ge=Ba,Le=Wa,dd=Ya,dt=ta,ar=m.forwardRef(({className:s,...n},a)=>e.jsx(St,{ref:a,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));ar.displayName=St.displayName;const pe=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(dd,{children:[e.jsx(ar,{}),e.jsxs(kt,{ref:l,className:y("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a,children:[n,e.jsxs(ta,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pe.displayName=kt.displayName;const be=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});be.displayName="DialogHeader";const Oe=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Oe.displayName="DialogFooter";const je=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{ref:a,className:y("text-lg font-semibold leading-none tracking-tight",s),...n}));je.displayName=Pt.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Tt,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Te.displayName=Tt.displayName;const $s=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const o=l?Xt:"button";return e.jsx(o,{className:y($s({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";function md(){const[s,n]=m.useState(!1),a="php artisan reset:password 管理员邮箱";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"container grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-2 sm:w-[480px] lg:p-8",children:[e.jsx("div",{className:"mb-4 flex items-center justify-center",children:e.jsx("h1",{className:"text-3xl font-medium",children:window?.settings?.title})}),e.jsxs(Ge,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"登录"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请输入您的邮箱和密码登录系统"})]}),e.jsx(cd,{onForgotPassword:()=>n(!0)})]})]})}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(pe,{children:e.jsxs(be,{children:[e.jsx(je,{children:"忘记密码"}),e.jsx(Te,{children:"在站点目录下执行以下命令找回密码"}),e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12",children:a}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>wt(a),children:e.jsx(Rl,{className:"h-4 w-4"})})]})})]})})})]})}const ud=Object.freeze(Object.defineProperty({__proto__:null,default:md},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:y("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",a&&"md:h-svh",s),...l}));we.displayName="Layout";const Ce=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const ke=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));ke.displayName="LayoutBody";const nr=Il,rr=El,lr=Ml,ys=Vl,_s=Al,hd=Fl,pd=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(Ja,{ref:r,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...l,children:[a,e.jsx(aa,{className:"ml-auto h-4 w-4"})]}));pd.displayName=Ja.displayName;const xd=m.forwardRef(({className:s,...n},a)=>e.jsx(Qa,{ref:a,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));xd.displayName=Qa.displayName;const is=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Ll,{children:e.jsx(Za,{ref:l,sideOffset:n,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a})}));is.displayName=Za.displayName;const xe=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(Xa,{ref:l,className:y("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...a}));xe.displayName=Xa.displayName;const fd=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(en,{ref:r,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:a,...l,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(sn,{children:e.jsx(Ds,{className:"h-4 w-4"})})}),n]}));fd.displayName=en.displayName;const gd=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(tn,{ref:l,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(sn,{children:e.jsx(Ol,{className:"h-4 w-4 fill-current"})})}),n]}));gd.displayName=tn.displayName;const oa=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(an,{ref:l,className:y("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));oa.displayName=an.displayName;const at=m.forwardRef(({className:s,...n},a)=>e.jsx(nn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));at.displayName=nn.displayName;const Jt=({className:s,...n})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...n});Jt.displayName="DropdownMenuShortcut";const oe=zl,re=Ul,le=$l,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(rn,{ref:l,sideOffset:n,className:y("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a}));te.displayName=rn.displayName;function Et(){const{pathname:s}=ea();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function ir({key:s,defaultValue:n}){const[a,l]=m.useState(()=>{const r=localStorage.getItem(s);return r!==null?JSON.parse(r):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,l]}function jd(){const[s,n]=ir({key:"collapsed-sidebar-items",defaultValue:[]}),a=r=>!s.includes(r);return{isExpanded:a,toggleItem:r=>{a(r)?n([...s,r]):n(s.filter(c=>c!==r))}}}function bd({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=M(),c=({sub:o,...u})=>{const h=`${r(u.title)}-${u.href}`;return n&&o?m.createElement(_d,{...u,sub:o,key:h,closeNav:l}):n?m.createElement(yd,{...u,key:h,closeNav:l}):o?m.createElement(vd,{...u,sub:o,key:h,closeNav:l}):m.createElement(or,{...u,key:h,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",a),children:e.jsx(oe,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(c)})})})}function or({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:o}=Et(),{t:u}=M();return e.jsxs(Rs,{to:l,onClick:r,className:y(Hs({variant:o(l)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",c&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":o(l)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),u(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(a)})]})}function vd({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Et(),{isExpanded:o,toggleItem:u}=jd(),{t:h}=M(),i=!!l?.find(P=>c(P.href)),d=h(s),f=o(d)||i;return e.jsxs(nr,{open:f,onOpenChange:()=>u(d),children:[e.jsxs(rr,{className:y(Hs({variant:i?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),h(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:h(a)}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(ln,{stroke:1})})]}),e.jsx(lr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(P=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(or,{...P,subLink:!0,closeNav:r})},h(P.title)))})})]})}function yd({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=Et(),{t:o}=M();return e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsxs(Rs,{to:l,onClick:r,className:y(Hs({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:o(s)})]})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[o(s),a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:o(a)})]})]})}function _d({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Et(),{t:o}=M(),u=!!l?.find(h=>c(h.href));return e.jsxs(ys,{children:[e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:u?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[o(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:o(a)}),e.jsx(ln,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(is,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(oa,{children:[o(s)," ",a?`(${o(a)})`:""]}),e.jsx(at,{}),l.map(({title:h,icon:i,label:d,href:f})=>e.jsx(xe,{asChild:!0,children:e.jsxs(Rs,{to:f,onClick:r,className:`${c(f)?"bg-secondary":""}`,children:[i," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:o(h)}),d&&e.jsx("span",{className:"ml-auto text-xs",children:o(d)})]})},`${o(h)}-${f}`))]})]})}const cr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Hl,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Gl,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(on,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(ql,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Kl,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(wa,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Bl,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(cn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Wl,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(dn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Yl,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Jl,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Ql,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(wa,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Zl,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Xl,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(ei,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(mn,{size:18})}]}];function Nd({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=m.useState(!1),{t:c}=M();return m.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:y(`fixed left-0 right-0 top-0 z-50 w-full border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>r(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${l?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(we,{children:[e.jsxs(Ce,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":c("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":l,onClick:()=>r(o=>!o),children:l?e.jsx(si,{}):e.jsx(ti,{})})]}),e.jsx(bd,{id:"sidebar-menu",className:`h-full flex-1 overflow-auto ${l?"max-h-screen":"max-h-0 py-0 md:max-h-screen md:py-2"}`,closeNav:()=>r(!1),isCollapsed:n,links:cr}),e.jsx("div",{className:y("px-4 py-3 text-xs text-muted-foreground/70 border-t border-border/50 bg-muted/20","transition-all duration-200 ease-in-out",n?"text-center":"text-left"),children:e.jsxs("div",{className:y("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500/70"}),e.jsxs("span",{className:"tracking-wide",children:["v",window?.settings?.version]})]})}),e.jsx(R,{onClick:()=>a(o=>!o),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":c("common:toggleSidebar"),children:e.jsx(ai,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function wd(){const[s,n]=ir({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const a=()=>{n(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),[s,n]}function Cd(){const[s,n]=wd();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Nd,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(sa,{})})]})}const Sd=Object.freeze(Object.defineProperty({__proto__:null,default:Cd},Symbol.toStringTag,{value:"Module"})),Ns=m.forwardRef(({className:s,...n},a)=>e.jsx(Se,{ref:a,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ns.displayName=Se.displayName;const kd=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(pe,{className:"overflow-hidden p-0",children:e.jsx(Ns,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Es=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ni,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Se.Input,{ref:a,className:y("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Es.displayName=Se.Input.displayName;const ws=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.List,{ref:a,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));ws.displayName=Se.List.displayName;const Ms=m.forwardRef((s,n)=>e.jsx(Se.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ms.displayName=Se.Empty.displayName;const Me=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Group,{ref:a,className:y("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Me.displayName=Se.Group.displayName;const Gs=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Separator,{ref:a,className:y("-mx-1 h-px bg-border",s),...n}));Gs.displayName=Se.Separator.displayName;const Ne=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Item,{ref:a,className:y("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));Ne.displayName=Se.Item.displayName;function Pd(){const s=[];for(const n of cr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function De(){const[s,n]=m.useState(!1),a=os(),l=Pd(),{t:r}=M("search"),{t:c}=M("nav");m.useEffect(()=>{const u=h=>{h.key==="k"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),n(i=>!i))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const o=m.useCallback(u=>{n(!1),a(u)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(ri,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:r("placeholder")}),e.jsx("span",{className:"sr-only",children:r("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:r("shortcut.key")})]}),e.jsxs(kd,{open:s,onOpenChange:n,children:[e.jsx(Es,{placeholder:r("placeholder")}),e.jsxs(ws,{children:[e.jsx(Ms,{children:r("noResults")}),e.jsx(Me,{heading:r("title"),children:l.map(u=>e.jsxs(Ne,{value:`${u.parent?u.parent+" ":""}${u.title}`,onSelect:()=>o(u.href),children:[e.jsx("div",{className:"mr-2",children:u.icon}),e.jsx("span",{children:c(u.title)}),u.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c(u.parent)})]},u.href))})]})]})]})}const At=[{code:"en",name:"English",flag:li,shortName:"EN"},{code:"zh",name:"中文",flag:ii,shortName:"CN"},{code:"ko",name:"조선말",flag:oi,shortName:"KP"}];function Td(){const{i18n:s}=M(),n=r=>{s.changeLanguage(r)},a=At.find(r=>r.code===s.language)||At[0],l=a.flag;return e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(l,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:a.shortName})]})}),e.jsx(is,{align:"end",className:"w-[120px]",children:At.map(r=>{const c=r.flag,o=r.code===s.language;return e.jsxs(xe,{onClick:()=>n(r.code),className:y("flex items-center gap-2 px-2 py-1.5 cursor-pointer",o&&"bg-accent"),children:[e.jsx(c,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:y("text-sm",o&&"font-medium"),children:r.name})]},r.code)})})]})}function Re(){const{theme:s,setTheme:n}=To();return m.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",l=document.querySelector("meta[name='theme-color']");l&&l.setAttribute("content",a)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(ci,{size:20}):e.jsx(di,{size:20})}),e.jsx(Td,{})]})}const dr=m.forwardRef(({className:s,...n},a)=>e.jsx(un,{ref:a,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));dr.displayName=un.displayName;const mr=m.forwardRef(({className:s,...n},a)=>e.jsx(hn,{ref:a,className:y("aspect-square h-full w-full",s),...n}));mr.displayName=hn.displayName;const ur=m.forwardRef(({className:s,...n},a)=>e.jsx(pn,{ref:a,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ur.displayName=pn.displayName;function Ie(){const s=os(),n=Ka(),a=mi(Yo),{t:l}=M(["common"]),r=()=>{Jn(),n(Wo()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),o=c.substring(0,2).toUpperCase();return e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(dr,{className:"h-8 w-8",children:[e.jsx(mr,{src:a?.avatar_url,alt:c}),e.jsx(ur,{children:o})]})})}),e.jsxs(is,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(oa,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:c}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:a?.email||l("common:defaultEmail")})]})}),e.jsx(at,{}),e.jsx(xe,{asChild:!0,children:e.jsxs(Rs,{to:"/config/system",children:[l("common:settings"),e.jsx(Jt,{children:"⌘S"})]})}),e.jsx(at,{}),e.jsxs(xe,{onClick:r,children:[l("common:logout"),e.jsx(Jt,{children:"⇧⌘Q"})]})]})]})}const Qe=window?.settings?.secure_path,hr=5*60*1e3,Qt=new Map,Dd=s=>{const n=Qt.get(s);return n?Date.now()-n.timestamp>hr?(Qt.delete(s),null):n.data:null},Rd=(s,n)=>{Qt.set(s,{data:n,timestamp:Date.now()})},Id=async(s,n=hr)=>{const a=Dd(s);if(a)return a;const l=await V.get(s);return Rd(s,l),l},Ed={getList:()=>Id(`${Qe}/notice/fetch`),save:s=>V.post(`${Qe}/notice/save`,s),drop:s=>V.post(`${Qe}/notice/drop`,{id:s}),updateStatus:s=>V.post(`${Qe}/notice/show`,{id:s}),sort:s=>V.post(`${Qe}/notice/sort`,{ids:s})},La={getSystemStatus:()=>V.get(`${Qe}/system/getSystemStatus`),getQueueStats:()=>V.get(`${Qe}/system/getQueueStats`),getQueueWorkload:()=>V.get(`${Qe}/system/getQueueWorkload`),getQueueMasters:()=>V.get(`${Qe}/system/getQueueMasters`),getSystemLog:s=>V.get(`${Qe}/system/getSystemLog`,{params:s})},F=window?.settings?.secure_path,Md=s=>V.get(F+"/stat/getOrder",{params:s}),Ld=()=>V.get(F+"/stat/getStats"),Oa=s=>V.get(F+"/stat/getTrafficRank",{params:s}),Od=()=>V.get(F+"/theme/getThemes"),Vd=s=>V.post(F+"/theme/getThemeConfig",{name:s}),Ad=(s,n)=>V.post(F+"/theme/saveThemeConfig",{name:s,config:n}),Fd=s=>{const n=new FormData;return n.append("file",s),V.post(F+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},zd=s=>V.post(F+"/theme/delete",{name:s}),Ud=s=>V.post(F+"/config/save",s),pr=()=>V.get(F+"/server/manage/getNodes"),$d=s=>V.post(F+"/server/manage/save",s),Hd=s=>V.post(F+"/server/manage/drop",s),Gd=s=>V.post(F+"/server/manage/copy",s),qd=s=>V.post(F+"/server/manage/update",s),Kd=s=>V.post(F+"/server/manage/sort",s),Mt=()=>V.get(F+"/server/group/fetch"),Bd=s=>V.post(F+"/server/group/save",s),Wd=s=>V.post(F+"/server/group/drop",s),xr=()=>V.get(F+"/server/route/fetch"),Yd=s=>V.post(F+"/server/route/save",s),Jd=s=>V.post(F+"/server/route/drop",s),Qd=()=>V.get(F+"/payment/fetch"),Zd=()=>V.get(F+"/payment/getPaymentMethods"),Xd=s=>V.post(F+"/payment/getPaymentForm",s),em=s=>V.post(F+"/payment/save",s),sm=s=>V.post(F+"/payment/drop",s),tm=s=>V.post(F+"/payment/show",s),am=s=>V.post(F+"/payment/sort",s),nm=()=>V.get(F+"/notice/fetch"),rm=s=>V.post(F+"/notice/save",s),lm=s=>V.post(F+"/notice/drop",s),im=s=>V.post(F+"/notice/show",s),om=()=>V.get(F+"/knowledge/fetch"),cm=s=>V.get(F+"/knowledge/fetch?id="+s),dm=s=>V.post(F+"/knowledge/save",s),mm=s=>V.post(F+"/knowledge/drop",s),um=s=>V.post(F+"/knowledge/show",s),hm=s=>V.post(F+"/knowledge/sort",s),Ls=()=>V.get(F+"/plan/fetch"),pm=s=>V.post(F+"/plan/save",s),Ft=s=>V.post(F+"/plan/update",s),xm=s=>V.post(F+"/plan/drop",s),fm=s=>V.post(F+"/plan/sort",{ids:s}),gm=async s=>V.post(F+"/order/fetch",s),jm=s=>V.post(F+"/order/detail",s),bm=s=>V.post(F+"/order/paid",s),vm=s=>V.post(F+"/order/cancel",s),Va=s=>V.post(F+"/order/update",s),ym=s=>V.post(F+"/order/assign",s),_m=s=>V.post(F+"/coupon/fetch",s),Nm=s=>V.post(F+"/coupon/generate",s),wm=s=>V.post(F+"/coupon/drop",s),Cm=s=>V.post(F+"/coupon/update",s),Sm=s=>V.post(F+"/user/fetch",s),km=s=>V.post(F+"/user/update",s),Pm=s=>V.post(F+"/user/resetSecret",s),Tm=s=>V.post(F+"/user/generate",s),Dm=s=>V.post(F+"/stat/getStatUser",s),Rm=s=>V.post(F+"/ticket/fetch",s),Im=s=>V.get(F+"/ticket/fetch?id= "+s),Em=s=>V.post(F+"/ticket/reply",s),fr=s=>V.post(F+"/ticket/close",{id:s}),us=(s="")=>V.get(F+"/config/fetch?key="+s),hs=s=>V.post(F+"/config/save",s),Mm=()=>V.get(F+"/config/getEmailTemplate"),Lm=()=>V.post(F+"/config/testSendMail"),Om=()=>V.post(F+"/config/setTelegramWebhook"),Vm=Ed.sort,gr=ui,ca=m.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));ca.displayName=xn.displayName;const nt=m.forwardRef(({className:s,...n},a)=>e.jsx(fn,{ref:a,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));nt.displayName=fn.displayName;const Am=m.forwardRef(({className:s,...n},a)=>e.jsx(gn,{ref:a,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));Am.displayName=gn.displayName;const W=hi,xs=yi,Y=pi,K=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(jn,{ref:l,className:y("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...a,children:[n,e.jsx(xi,{asChild:!0,children:e.jsx(na,{className:"h-4 w-4 opacity-50"})})]}));K.displayName=jn.displayName;const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(fi,{className:"h-4 w-4"})}));jr.displayName=bn.displayName;const br=m.forwardRef(({className:s,...n},a)=>e.jsx(vn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(na,{className:"h-4 w-4"})}));br.displayName=vn.displayName;const B=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(gi,{children:e.jsxs(yn,{ref:r,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:a,...l,children:[e.jsx(jr,{}),e.jsx(ji,{className:y("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(br,{})]})}));B.displayName=yn.displayName;const Fm=m.forwardRef(({className:s,...n},a)=>e.jsx(_n,{ref:a,className:y("px-2 py-1.5 text-sm font-semibold",s),...n}));Fm.displayName=_n.displayName;const U=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Nn,{ref:l,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(bi,{children:e.jsx(Ds,{className:"h-4 w-4"})})}),e.jsx(vi,{children:n})]}));U.displayName=Nn.displayName;const zm=m.forwardRef(({className:s,...n},a)=>e.jsx(wn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));zm.displayName=wn.displayName;function Os({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(_i,{showOutsideDays:a,className:y("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:y($s({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:y("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",l.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:y($s({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx(Cn,{className:y("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(aa,{className:y("h-4 w-4",r),...c})},...l})}Os.displayName="Calendar";const as=wi,ns=Ci,We=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(Ni,{children:e.jsx(Sn,{ref:r,align:n,sideOffset:a,className:y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...l})}));We.displayName=Sn.displayName;const fs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Qs=s=>(s/100).toFixed(2),Um=({active:s,payload:n,label:a})=>{const{t:l}=M();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:a}),n.map((r,c)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[l(r.name),":"]}),e.jsx("span",{className:"font-medium",children:r.name.includes(l("dashboard:overview.amount"))?`¥${Qs(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},$m=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],Hm=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=$e(a,7);break;case"30d":l=$e(a,30);break;case"90d":l=$e(a,90);break;case"180d":l=$e(a,180);break;case"365d":l=$e(a,365);break;default:l=$e(a,30)}return{startDate:l,endDate:a}};function Gm(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:$e(new Date,7),to:new Date}),{t:o}=M(),{startDate:u,endDate:h}=Hm(a,r),{data:i}=se({queryKey:["orderStat",{start_date:Ue(u,"yyyy-MM-dd"),end_date:Ue(h,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await Md({start_date:Ue(u,"yyyy-MM-dd"),end_date:Ue(h,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(Ge,{children:[e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(vs,{children:o("dashboard:overview.title")}),e.jsxs(tt,{children:[i?.summary.start_date," ",o("dashboard:overview.to")," ",i?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(W,{value:a,onValueChange:d=>l(d),children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(Y,{placeholder:o("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:$m.map(d=>e.jsx(U,{value:d.value,children:o(d.label)},d.value))})]}),a==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r?.from?r.to?e.jsxs(e.Fragment,{children:[Ue(r.from,"yyyy-MM-dd")," -"," ",Ue(r.to,"yyyy-MM-dd")]}):Ue(r.from,"yyyy-MM-dd"):o("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Os,{mode:"range",defaultMonth:r?.from,selected:{from:r?.from,to:r?.to},onSelect:d=>{d?.from&&d?.to&&c({from:d.from,to:d.to})},numberOfMonths:2})})]})]}),e.jsx(gr,{value:s,onValueChange:d=>n(d),children:e.jsxs(ca,{children:[e.jsx(nt,{value:"amount",children:o("dashboard:overview.amount")}),e.jsx(nt,{value:"count",children:o("dashboard:overview.count")})]})})]})]})}),e.jsxs(ts,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:o("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(i?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("dashboard:overview.totalTransactions",{count:i?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o("dashboard:overview.avgOrderAmount")," ¥",Qs(i?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:o("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(i?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o("dashboard:overview.totalTransactions",{count:i?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o("dashboard:overview.commissionRate")," ",i?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Si,{width:"100%",height:"100%",children:e.jsxs(ki,{data:i?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:fs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:fs.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:fs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:fs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Pi,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Ue(new Date(d),"MM-dd",{locale:Ii})}),e.jsx(Ti,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${Qs(d)}`:o("dashboard:overview.transactions",{count:d})}),e.jsx(Di,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Ri,{content:e.jsx(Um,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ca,{type:"monotone",dataKey:"paid_total",name:o("dashboard:overview.orderAmount"),stroke:fs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ca,{type:"monotone",dataKey:"commission_total",name:o("dashboard:overview.commissionAmount"),stroke:fs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{dataKey:"paid_count",name:o("dashboard:overview.orderCount"),fill:fs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Sa,{dataKey:"commission_count",name:o("dashboard:overview.commissionCount"),fill:fs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function Ee({className:s,...n}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...n})}function qm(){return e.jsxs(Ge,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ee,{className:"h-4 w-[120px]"}),e.jsx(Ee,{className:"h-4 w-4"})]}),e.jsxs(ts,{children:[e.jsx(Ee,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx(Ee,{className:"h-4 w-[100px]"})]})]})]})}function Km(){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(qm,{},n))})}var Q=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(Q||{});const Ys={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Js={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var He=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(He||{}),ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(ne||{});const ut={0:"待确认",1:"发放中",2:"有效",3:"无效"},ht={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var de=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(de||{});const Bm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ye=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(ye||{});const Ps=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ls={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var js=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(js||{});const Wm={1:"按金额优惠",2:"按比例优惠"};var et=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(et||{}),Xe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Xe||{});function gs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:o,className:u}){return e.jsxs(Ge,{className:y("transition-colors",c&&"cursor-pointer hover:bg-muted/50",o&&"border-primary/50",u),onClick:c,children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(vs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Ai,{className:y("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("ml-1 text-xs",l.isPositive?"text-emerald-500":"text-red-500"),children:[l.isPositive?"+":"-",Math.abs(l.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:l.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]})}function Ym({className:s}){const n=os(),{t:a}=M(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await Ld()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Km,{});const c=()=>{const o=new URLSearchParams;o.set("commission_status",ne.PENDING.toString()),o.set("status",Q.COMPLETED.toString()),o.set("commission_balance","gt:0"),n(`/finance/order?${o.toString()}`)};return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(gs,{title:a("dashboard:stats.todayIncome"),value:ks(l.todayIncome),icon:e.jsx(Ei,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.monthlyIncome"),value:ks(l.currentMonthIncome),icon:e.jsx(Mi,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Li,{className:y("h-4 w-4",l.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:l.ticketPendingTotal>0?a("dashboard:stats.hasPendingTickets"):a("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:l.ticketPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Oi,{className:y("h-4 w-4",l.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:l.commissionPendingTotal>0?a("dashboard:stats.hasPendingCommission"):a("dashboard:stats.noPendingCommission"),onClick:c,highlight:l.commissionPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Ht,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Ht,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(gs,{title:a("dashboard:stats.monthlyUpload"),value:Ze(l.monthTraffic.upload),icon:e.jsx(Gt,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.upload)})}),e.jsx(gs,{title:a("dashboard:stats.monthlyDownload"),value:Ze(l.monthTraffic.download),icon:e.jsx(Vi,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.download)})})]})}const rt=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(kn,{ref:l,className:y("relative overflow-hidden",s),...a,children:[e.jsx(Fi,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ct,{}),e.jsx(zi,{})]}));rt.displayName=kn.displayName;const Ct=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Pn,{ref:l,orientation:n,className:y("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...a,children:e.jsx(Ui,{className:"relative flex-1 rounded-full bg-border"})}));Ct.displayName=Pn.displayName;const Zt={today:{getValue:()=>{const s=Hi();return{start:s,end:Gi(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:$e(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:$e(s,30),end:s}}},custom:{getValue:()=>null}};function Aa({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=M(),c={today:r("dashboard:trafficRank.today"),last7days:r("dashboard:trafficRank.last7days"),last30days:r("dashboard:trafficRank.last30days"),custom:r("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(W,{value:s,onValueChange:a,children:[e.jsx(K,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(Zt).map(([o])=>e.jsx(U,{value:o,children:c[o]},o))})]}),s==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[Ue(n.from,"yyyy-MM-dd")," -"," ",Ue(n.to,"yyyy-MM-dd")]}):Ue(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Os,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:o=>{o?.from&&o?.to&&l({from:o.from,to:o.to})},numberOfMonths:2})})]})]})}const As=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Jm({className:s}){const{t:n}=M(),[a,l]=m.useState("today"),[r,c]=m.useState({from:$e(new Date,7),to:new Date}),[o,u]=m.useState("today"),[h,i]=m.useState({from:$e(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:Zt[a].getValue(),[a,r]),f=m.useMemo(()=>o==="custom"?{start:h.from,end:h.to}:Zt[o].getValue(),[o,h]),{data:P}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Oa({type:"node",start_time:fe.round(d.start.getTime()/1e3),end_time:fe.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:E}=se({queryKey:["userTrafficRank",f.start,f.end],queryFn:()=>Oa({type:"user",start_time:fe.round(f.start.getTime()/1e3),end_time:fe.round(f.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Ge,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(vs,{className:"flex items-center text-base font-medium",children:[e.jsx($i,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Aa,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(ka,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:P?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:P.data.map(x=>e.jsx(oe,{delayDuration:200,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:x.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",x.change>=0?"text-green-600":"text-red-600"),children:[x.change>=0?e.jsx(qt,{className:"mr-1 h-3 w-3"}):e.jsx(Kt,{className:"mr-1 h-3 w-3"}),Math.abs(x.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:`${x.value/P.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(x.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(x.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(x.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",x.change>=0?"text-green-600":"text-red-600"),children:[x.change>=0?"+":"",x.change,"%"]})]})})]})},x.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(Ge,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(vs,{className:"flex items-center text-base font-medium",children:[e.jsx(Ht,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Aa,{selectedRange:o,customDateRange:h,onRangeChange:u,onCustomRangeChange:i}),e.jsx(ka,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:E?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:E.data.map(x=>e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:x.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",x.change>=0?"text-green-600":"text-red-600"),children:[x.change>=0?e.jsx(qt,{className:"mr-1 h-3 w-3"}):e.jsx(Kt,{className:"mr-1 h-3 w-3"}),Math.abs(x.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:`${x.value/E.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(x.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(x.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(x.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",x.change>=0?"text-green-600":"text-red-600"),children:[x.change>=0?"+":"",x.change,"%"]})]})})]})},x.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const Qm=Ts("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function H({className:s,variant:n,...a}){return e.jsx("div",{className:y(Qm({variant:n}),s),...a})}const bt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Tn,{ref:l,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(qi,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));bt.displayName=Tn.displayName;function Zm(){const{t:s}=M(),[n,a]=m.useState(null),[l,r]=m.useState(null),[c,o]=m.useState(!0),[u,h]=m.useState(!1),i=async()=>{try{h(!0);const[P,E]=await Promise.all([La.getSystemStatus(),La.getQueueStats()]);a(P.data),r(E.data)}catch(P){console.error("Error fetching system data:",P)}finally{o(!1),h(!1)}};m.useEffect(()=>{i();const P=setInterval(i,3e4);return()=>clearInterval(P)},[]);const d=()=>{i()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(ra,{className:"h-6 w-6 animate-spin"})});const f=P=>P?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Rn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ge,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Ki,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(tt,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Bi,{className:y("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f(l?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(H,{variant:l?.status?"secondary":"destructive",children:l?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:l?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.recentJobs||0}),e.jsx(bt,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.jobsPerMinute||0}),e.jsx(bt,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(Ge,{children:[e.jsxs(ss,{children:[e.jsxs(vs,{className:"flex items-center gap-2",children:[e.jsx(Wi,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(tt,{children:s("dashboard:queue.details.description")})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:l?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:l?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[l?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[l?.processes||0," /"," ",(l?.processes||0)+(l?.pausedMasters||0)]})]}),e.jsx(bt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Xm(){const{t:s}=M();return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(De,{}),e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsx(ke,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Ym,{}),e.jsx(Gm,{}),e.jsx(Jm,{}),e.jsx(Zm,{})]})})})]})}const eu=Object.freeze(Object.defineProperty({__proto__:null,default:Xm},Symbol.toStringTag,{value:"Module"})),ve=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(In,{ref:r,decorative:a,orientation:n,className:y("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));ve.displayName=In.displayName;function su({className:s,items:n,...a}){const{pathname:l}=ea(),r=os(),[c,o]=m.useState(l??"/settings"),u=i=>{o(i),r(i)},{t:h}=M("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(W,{value:c,onValueChange:u,children:[e.jsx(K,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(i=>e.jsx(U,{value:i.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:i.icon}),e.jsx("span",{className:"text-md",children:h(i.title)})]})},i.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:y("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(i=>e.jsxs(Rs,{to:i.href,className:y(Hs({variant:"ghost"}),l===i.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:i.icon}),h(i.title)]},i.href))})})]})}const tu=[{title:"site.title",key:"site",icon:e.jsx(Yi,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(dn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(mn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Ji,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(cn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Qi,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Zi,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(on,{size:18}),href:"/config/system/app",description:"app.description"}];function au(){const{t:s}=M("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(ve,{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(su,{items:tu})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(sa,{})})})]})]})]})}const nu=Object.freeze(Object.defineProperty({__proto__:null,default:au},Symbol.toStringTag,{value:"Module"})),G=m.forwardRef(({className:s,...n},a)=>e.jsx(En,{className:y("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:a,children:e.jsx(Xi,{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")})}));G.displayName=En.displayName;const Cs=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:y("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}));Cs.displayName="Textarea";const ru=p.object({logo:p.string().nullable().default(""),force_https:p.number().nullable().default(0),stop_register:p.number().nullable().default(0),app_name:p.string().nullable().default(""),app_description:p.string().nullable().default(""),app_url:p.string().nullable().default(""),subscribe_url:p.string().nullable().default(""),try_out_plan_id:p.number().nullable().default(0),try_out_hour:p.coerce.number().nullable().default(0),tos_url:p.string().nullable().default(""),currency:p.string().nullable().default(""),currency_symbol:p.string().nullable().default("")});function lu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>us("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Ls()}),o=ce({resolver:ue(ru),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=es({mutationFn:hs,onSuccess:d=>{d.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(r?.data?.site){const d=r?.data?.site;Object.entries(d).forEach(([f,P])=>{o.setValue(f,P)}),l.current=d}},[r]);const h=m.useCallback(fe.debounce(async d=>{if(!fe.isEqual(d,l.current)){a(!0);try{const f=Object.entries(d).reduce((P,[E,x])=>(P[E]=x===null?"":x,P),{});await u(f),l.current=d}finally{a(!1)}}},1e3),[u]),i=m.useCallback(d=>{h(d)},[h]);return m.useEffect(()=>{const d=o.watch(f=>{i(f)});return()=>d.unsubscribe()},[o.watch,i]),e.jsx(he,{...o,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:o.control,name:"app_name",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.siteName.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"app_description",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.siteDescription.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"app_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.siteUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"force_https",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(L,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:!!d.value,onCheckedChange:f=>{d.onChange(Number(f)),i(o.getValues())}})})]})}),e.jsx(j,{control:o.control,name:"logo",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.logo.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"subscribe_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(Cs,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.subscribeUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"tos_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.tosUrl.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"stop_register",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(L,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:!!d.value,onCheckedChange:f=>{d.onChange(Number(f)),i(o.getValues())}})})]})}),e.jsx(j,{control:o.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(W,{value:d.value?.toString(),onValueChange:f=>{d.onChange(Number(f)),i(o.getValues())},children:[e.jsx(K,{children:e.jsx(Y,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(f=>e.jsx(U,{value:f.id.toString(),children:f.name},f.id.toString()))]})]})}),e.jsx(L,{children:s("site.form.tryOut.description")}),e.jsx(D,{})]})}),!!o.watch("try_out_plan_id")&&e.jsx(j,{control:o.control,name:"try_out_hour",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.tryOut.duration.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"currency",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.currency.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:o.control,name:"currency_symbol",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:f=>{d.onChange(f),i(o.getValues())}})}),e.jsx(L,{children:s("site.form.currencySymbol.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function iu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(ve,{}),e.jsx(lu,{})]})}const ou=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),cu=p.object({email_verify:p.boolean().nullable(),safe_mode_enable:p.boolean().nullable(),secure_path:p.string().nullable(),email_whitelist_enable:p.boolean().nullable(),email_whitelist_suffix:p.array(p.string().nullable()).nullable(),email_gmail_limit_enable:p.boolean().nullable(),recaptcha_enable:p.boolean().nullable(),recaptcha_key:p.string().nullable(),recaptcha_site_key:p.string().nullable(),register_limit_by_ip_enable:p.boolean().nullable(),register_limit_count:p.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:p.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:p.boolean().nullable(),password_limit_count:p.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:p.coerce.string().transform(s=>s===""?null:s).nullable()}),du={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 mu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(cu),defaultValues:du,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>us("safe")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data.safe){const i=c.data.safe;Object.entries(i).forEach(([d,f])=>{typeof f=="number"?r.setValue(d,String(f)):r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"email_verify",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(L,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"email_gmail_limit_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(L,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"safe_mode_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(L,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"secure_path",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.securePath.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"email_whitelist_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(L,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(j,{control:r.control,name:"email_whitelist_suffix",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(Cs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...i,value:(i.value||[]).join(` `),onChange:d=>{const f=d.target.value.split(` -`).filter(Boolean);i.onChange(f),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(L,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"recaptcha_key",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.key.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.recaptcha.key.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_site_key",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(D,{})]})})]}),e.jsx(j,{control:r.control,name:"register_limit_by_ip_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(L,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"register_limit_count",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.registerLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"register_limit_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(D,{})]})})]}),e.jsx(j,{control:r.control,name:"password_limit_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(L,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"password_limit_count",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"password_limit_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function uu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ve,{}),e.jsx(mu,{})]})}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:uu},Symbol.toStringTag,{value:"Module"})),pu=p.object({plan_change_enable:p.boolean().nullable().default(!1),reset_traffic_method:p.coerce.number().nullable().default(0),surplus_enable:p.boolean().nullable().default(!1),new_order_event_id:p.coerce.number().nullable().default(0),renew_order_event_id:p.coerce.number().nullable().default(0),change_order_event_id:p.coerce.number().nullable().default(0),show_info_to_server_enable:p.boolean().nullable().default(!1),show_protocol_to_server_enable:p.boolean().nullable().default(!1),default_remind_expire:p.boolean().nullable().default(!1),default_remind_traffic:p.boolean().nullable().default(!1),subscribe_path:p.string().nullable().default("s")}),xu={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 fu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(pu),defaultValues:xu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","subscribe"],queryFn:()=>us("subscribe")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.subscribe){const i=c?.data?.subscribe;Object.entries(i).forEach(([d,f])=>{r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"plan_change_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(L,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"reset_traffic_method",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(U,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(U,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(U,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(U,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(L,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"surplus_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(L,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"new_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(L,{children:s("subscribe.new_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"renew_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(L,{children:s("renew_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"change_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(L,{children:s("subscribe.change_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"subscribe_path",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:"subscribe",...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:i.value||"s"})]}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"show_info_to_server_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(L,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"show_protocol_to_server_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(L,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function gu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ve,{}),e.jsx(fu,{})]})}const ju=Object.freeze(Object.defineProperty({__proto__:null,default:gu},Symbol.toStringTag,{value:"Module"})),bu=p.object({invite_force:p.boolean().default(!1),invite_commission:p.coerce.string().default("0"),invite_gen_limit:p.coerce.string().default("0"),invite_never_expire:p.boolean().default(!1),commission_first_time_enable:p.boolean().default(!1),commission_auto_check_enable:p.boolean().default(!1),commission_withdraw_limit:p.coerce.string().default("0"),commission_withdraw_method:p.array(p.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:p.boolean().default(!1),commission_distribution_enable:p.boolean().default(!1),commission_distribution_l1:p.coerce.number().default(0),commission_distribution_l2:p.coerce.number().default(0),commission_distribution_l3:p.coerce.number().default(0)}),vu={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 yu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(bu),defaultValues:vu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","invite"],queryFn:()=>us("invite")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.invite){const i=c?.data?.invite;Object.entries(i).forEach(([d,f])=>{typeof f=="number"?r.setValue(d,String(f)):r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"invite_force",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(L,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"invite_commission",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.invite_commission.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("invite.invite_commission.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"invite_gen_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.invite_gen_limit.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("invite.invite_gen_limit.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"invite_never_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(L,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_first_time_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(L,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_auto_check_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(L,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_method",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_method.placeholder"),...i,value:Array.isArray(i.value)?i.value.join(","):"",onChange:d=>{const f=d.target.value.split(",").filter(Boolean);i.onChange(f),h(r.getValues())}})}),e.jsx(L,{children:s("invite.commission_withdraw_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"withdraw_close_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(L,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(L,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"commission_distribution_l1",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:s("invite.commission_distribution.l1")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l2",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:s("invite.commission_distribution.l2")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l3",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:s("invite.commission_distribution.l3")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function _u(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ve,{}),e.jsx(yu,{})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"})),wu=p.object({frontend_theme:p.string().nullable(),frontend_theme_sidebar:p.string().nullable(),frontend_theme_header:p.string().nullable(),frontend_theme_color:p.string().nullable(),frontend_background_url:p.string().url().nullable()}),Cu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Su(){const{data:s}=se({queryKey:["settings","frontend"],queryFn:()=>us("frontend")}),n=ce({resolver:ue(wu),defaultValues:Cu,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([r,c])=>{n.setValue(r,c)})}},[s]);function a(l){hs(l).then(({data:r})=>{r&&$.success("更新成功")})}return e.jsx(he,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(j,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:"边栏风格"}),e.jsx(L,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(G,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:"头部风格"}),e.jsx(L,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(G,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(g,{children:[e.jsx(b,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:y(Hs({variant:"outline"}),"w-[200px] appearance-none font-normal"),...l,children:[e.jsx("option",{value:"default",children:"默认"}),e.jsx("option",{value:"black",children:"黑色"}),e.jsx("option",{value:"blackblue",children:"暗蓝色"}),e.jsx("option",{value:"green",children:"奶绿色"})]})}),e.jsx(na,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(L,{children:"主题色"}),e.jsx(D,{})]})}),e.jsx(j,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(g,{children:[e.jsx(b,{children:"背景"}),e.jsx(_,{children:e.jsx(T,{placeholder:"请输入图片地址",...l})}),e.jsx(L,{children:"将会在后台登录页面进行展示。"}),e.jsx(D,{})]})}),e.jsx(R,{type:"submit",children:"保存设置"})]})})}function ku(){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(ve,{}),e.jsx(Su,{})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:ku},Symbol.toStringTag,{value:"Module"})),Tu=p.object({server_pull_interval:p.coerce.number().nullable(),server_push_interval:p.coerce.number().nullable(),server_token:p.string().nullable(),device_limit_mode:p.coerce.number().nullable()}),Du={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Ru(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Tu),defaultValues:Du,mode:"onBlur"}),{data:c}=se({queryKey:["settings","server"],queryFn:()=>us("server")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:d=>{d.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(c?.data.server){const d=c.data.server;Object.entries(d).forEach(([f,P])=>{r.setValue(f,P)}),l.current=d}},[c]);const u=m.useCallback(fe.debounce(async d=>{if(!fe.isEqual(d,l.current)){a(!0);try{await o(d),l.current=d}finally{a(!1)}}},1e3),[o]),h=m.useCallback(d=>{u(d)},[u]);m.useEffect(()=>{const d=r.watch(f=>{h(f)});return()=>d.unsubscribe()},[r.watch,h]);const i=()=>{const d=Math.floor(Math.random()*17)+16,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let P="";for(let E=0;Ee.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.server_token.title")}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:f=>{f.preventDefault(),i()},children:e.jsx(eo,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(te,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(L,{children:s("server.server_token.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:f=>{const P=f.target.value?Number(f.target.value):null;d.onChange(P)}})}),e.jsx(L,{children:s("server.server_pull_interval.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:f=>{const P=f.target.value?Number(f.target.value):null;d.onChange(P)}})}),e.jsx(L,{children:s("server.server_push_interval.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(W,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(U,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(L,{children:s("server.device_limit_mode.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Iu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ve,{}),e.jsx(Ru,{})]})}const Eu=Object.freeze(Object.defineProperty({__proto__:null,default:Iu},Symbol.toStringTag,{value:"Module"}));function Mu({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Rn,{className:"h-5 w-5 text-destructive"}),e.jsx(je,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Te,{children:l?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:a.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:a.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:a.template_name})]})]}),a.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:a.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(rt,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:a.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:a.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:a.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:a.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:a.config.from.address?`${a.config.from.address}${a.config.from.name?` (${a.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:a.config.username||"未设置"})]})})})]})]})]})})}const Lu=p.object({email_template:p.string().nullable().default("classic"),email_host:p.string().nullable().default(""),email_port:p.string().regex(/^\d+$/).nullable().default("465"),email_username:p.string().nullable().default(""),email_password:p.string().nullable().default(""),email_encryption:p.string().nullable().default(""),email_from_address:p.string().email().nullable().default(""),remind_mail_enable:p.boolean().nullable().default(!1)});function Ou(){const{t:s}=M("settings"),[n,a]=m.useState(null),[l,r]=m.useState(!1),c=m.useRef(null),[o,u]=m.useState(!1),h=ce({resolver:ue(Lu),defaultValues:{},mode:"onBlur"}),{data:i}=se({queryKey:["settings","email"],queryFn:()=>us("email")}),{data:d}=se({queryKey:["emailTemplate"],queryFn:()=>Mm()}),{mutateAsync:f}=es({mutationFn:hs,onSuccess:k=>{k.data&&$.success(s("common.autoSaved"))}}),{mutate:P,isPending:E}=es({mutationFn:Lm,onMutate:()=>{a(null),r(!1)},onSuccess:k=>{a(k.data),r(!0),k.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(i?.data.email){const k=i.data.email;Object.entries(k).forEach(([v,w])=>{h.setValue(v,w)}),c.current=k}},[i]);const x=m.useCallback(fe.debounce(async k=>{if(!fe.isEqual(k,c.current)){u(!0);try{await f(k),c.current=k}finally{u(!1)}}},1e3),[f]),N=m.useCallback(k=>{x(k)},[x]);return m.useEffect(()=>{const k=h.watch(v=>{N(v)});return()=>k.unsubscribe()},[h.watch,N]),e.jsxs(e.Fragment,{children:[e.jsx(he,{...h,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:h.control,name:"email_host",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_host.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email.email_host.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_port",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_port.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("common.placeholder"),...k,value:k.value||"",onChange:v=>{const w=v.target.value?Number(v.target.value):null;k.onChange(w)}})}),e.jsx(L,{children:s("email.email_port.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_encryption",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(W,{onValueChange:k.onChange,value:k.value||"none",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(U,{value:"none",children:s("email.email_encryption.none")}),e.jsx(U,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(U,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(L,{children:s("email.email_encryption.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_username",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_username.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email.email_username.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_password",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email_password.title")}),e.jsx(_,{children:e.jsx(T,{type:"password",placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email_password.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_from_address",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email_from.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email_from.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_template",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email_template.title")}),e.jsxs(W,{onValueChange:v=>{k.onChange(v),N(h.getValues())},value:k.value||void 0,children:[e.jsx(_,{children:e.jsx(K,{className:"w-[200px]",children:e.jsx(Y,{placeholder:s("email_template.placeholder")})})}),e.jsx(B,{children:d?.data?.map(v=>e.jsx(U,{value:v,children:v},v))})]}),e.jsx(L,{children:s("email_template.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"remind_mail_enable",render:({field:k})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("remind_mail.title")}),e.jsx(L,{children:s("remind_mail.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:k.value||!1,onCheckedChange:v=>{k.onChange(v),N(h.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{onClick:()=>P(),loading:E,disabled:E,children:s(E?"test.sending":"test.title")})})]})}),o&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Mu,{open:l,onOpenChange:r,result:n})]})}function Vu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ve,{}),e.jsx(Ou,{})]})}const Au=Object.freeze(Object.defineProperty({__proto__:null,default:Vu},Symbol.toStringTag,{value:"Module"})),Fu=p.object({telegram_bot_enable:p.boolean().nullable(),telegram_bot_token:p.string().nullable(),telegram_discuss_link:p.string().nullable()}),zu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Uu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Fu),defaultValues:zu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","telegram"],queryFn:()=>us("telegram")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:f=>{f.data&&$.success(s("common.autoSaved"))}}),{mutate:u,isPending:h}=es({mutationFn:Om,onSuccess:f=>{f.data&&$.success(s("telegram.webhook_success"))}});m.useEffect(()=>{if(c?.data.telegram){const f=c.data.telegram;Object.entries(f).forEach(([P,E])=>{r.setValue(P,E)}),l.current=f}},[c]);const i=m.useCallback(fe.debounce(async f=>{if(!fe.isEqual(f,l.current)){a(!0);try{await o(f),l.current=f}finally{a(!1)}}},1e3),[o]),d=m.useCallback(f=>{i(f)},[i]);return m.useEffect(()=>{const f=r.watch(P=>{d(P)});return()=>f.unsubscribe()},[r.watch,d]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"telegram_bot_token",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("telegram.bot_token.placeholder"),...f,value:f.value||""})}),e.jsx(L,{children:s("telegram.bot_token.description")}),e.jsx(D,{})]})}),r.watch("telegram_bot_token")&&e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(R,{loading:h,disabled:h,onClick:()=>u(),children:s(h?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(L,{children:s("telegram.webhook.description")}),e.jsx(D,{})]}),e.jsx(j,{control:r.control,name:"telegram_bot_enable",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(L,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(G,{checked:f.value||!1,onCheckedChange:P=>{f.onChange(P),d(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"telegram_discuss_link",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("telegram.discuss_link.placeholder"),...f,value:f.value||""})}),e.jsx(L,{children:s("telegram.discuss_link.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function $u(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ve,{}),e.jsx(Uu,{})]})}const Hu=Object.freeze(Object.defineProperty({__proto__:null,default:$u},Symbol.toStringTag,{value:"Module"})),Gu=p.object({windows_version:p.string().nullable(),windows_download_url:p.string().nullable(),macos_version:p.string().nullable(),macos_download_url:p.string().nullable(),android_version:p.string().nullable(),android_download_url:p.string().nullable()}),qu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Ku(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Gu),defaultValues:qu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","app"],queryFn:()=>us("app")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(c?.data.app){const i=c.data.app;Object.entries(i).forEach(([d,f])=>{r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"windows_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.windows.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"windows_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.windows.download.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"macos_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.macos.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"macos_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.macos.download.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"android_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.android.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.android.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"android_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.android.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.android.download.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Bu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ve,{}),e.jsx(Ku,{})]})}const Wu=Object.freeze(Object.defineProperty({__proto__:null,default:Bu},Symbol.toStringTag,{value:"Module"})),da=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:y("w-full caption-bottom text-sm",s),...n})}));da.displayName="Table";const ma=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:y("[&_tr]:border-b",s),...n}));ma.displayName="TableHeader";const ua=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:y("[&_tr:last-child]:border-0",s),...n}));ua.displayName="TableBody";const Yu=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Yu.displayName="TableFooter";const bs=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));bs.displayName="TableRow";const ha=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:y("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));ha.displayName="TableHead";const Us=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:y("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Us.displayName="TableCell";const Ju=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:y("mt-4 text-sm text-muted-foreground",s),...n}));Ju.displayName="TableCaption";function Qu({table:s}){const[n,a]=m.useState("");m.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const l=r=>{const c=parseInt(r);!isNaN(c)&&c>=1&&c<=s.getPageCount()?s.setPageIndex(c-1):a((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex-1 text-sm text-muted-foreground",children:["已选择 ",s.getFilteredSelectedRowModel().rows.length," 项, 共"," ",s.getFilteredRowModel().rows.length," 项"]}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"每页显示"}),e.jsxs(W,{value:`${s.getState().pagination.pageSize}`,onValueChange:r=>{s.setPageSize(Number(r))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(r=>e.jsx(U,{value:`${r}`,children:r},r))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:"第"}),e.jsx(T,{type:"text",value:n,onChange:r=>a(r.target.value),onBlur:r=>l(r.target.value),onKeyDown:r=>{r.key==="Enter"&&l(r.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsxs("span",{children:["页,共 ",s.getPageCount()," 页"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到第一页"}),e.jsx(so,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"上一页"}),e.jsx(Cn,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"下一页"}),e.jsx(aa,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到最后一页"}),e.jsx(to,{className:"h-4 w-4"})]})]})]})]})}function Ye({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:o,onDrop:u,showPagination:h=!0,isLoading:i=!1}){const d=m.useRef(null),f=s.getAllColumns().filter(N=>N.getIsPinned()==="left"),P=s.getAllColumns().filter(N=>N.getIsPinned()==="right"),E=N=>f.slice(0,N).reduce((k,v)=>k+(v.getSize()??0),0),x=N=>P.slice(N+1).reduce((k,v)=>k+(v.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:d,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(da,{children:[e.jsx(ma,{children:s.getHeaderGroups().map(N=>e.jsx(bs,{className:"hover:bg-transparent",children:N.headers.map((k,v)=>{const w=k.column.getIsPinned()==="left",S=k.column.getIsPinned()==="right",C=w?E(f.indexOf(k.column)):void 0,I=S?x(P.indexOf(k.column)):void 0;return e.jsx(ha,{colSpan:k.colSpan,style:{width:k.getSize(),...w&&{left:C},...S&&{right:I}},className:y("h-11 bg-card px-4 text-muted-foreground",(w||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",w&&"before:right-0",S&&"before:left-0"]),children:k.isPlaceholder?null:vt(k.column.columnDef.header,k.getContext())},k.id)})},N.id))}),e.jsx(ua,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((N,k)=>e.jsx(bs,{"data-state":N.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:v=>l?.(v,k),onDragEnd:r,onDragOver:c,onDragLeave:o,onDrop:v=>u?.(v,k),children:N.getVisibleCells().map((v,w)=>{const S=v.column.getIsPinned()==="left",C=v.column.getIsPinned()==="right",I=S?E(f.indexOf(v.column)):void 0,A=C?x(P.indexOf(v.column)):void 0;return e.jsx(Us,{style:{width:v.column.getSize(),...S&&{left:I},...C&&{right:A}},className:y("bg-card",(S||C)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",S&&"before:right-0",C&&"before:left-0"]),children:vt(v.column.columnDef.cell,v.getContext())},v.id)})},N.id)):e.jsx(bs,{children:e.jsx(Us,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:"暂无数据"})})})]})})}),h&&e.jsx(Qu,{table:s})]})}const Zu=s=>p.object({id:p.number().nullable(),name:p.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:p.string().optional().nullable(),notify_domain:p.string().refine(a=>!a||/^https?:\/\/\S+/.test(a),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:p.coerce.number().min(0).optional().nullable(),handling_fee_percent:p.coerce.number().min(0).max(100).optional().nullable(),payment:p.string().min(1,s("form.validation.payment.required")),config:p.record(p.string(),p.string())}),Fa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function vr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Fa}){const{t:r}=M("payment"),[c,o]=m.useState(!1),[u,h]=m.useState(!1),[i,d]=m.useState([]),[f,P]=m.useState([]),E=Zu(r),x=ce({resolver:ue(E),defaultValues:l,mode:"onChange"}),N=x.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:w}=await Zd();d(w)})()},[c]),m.useEffect(()=>{if(!N||!c)return;(async()=>{const w={payment:N,...a==="edit"&&{id:Number(x.getValues("id"))}};Xd(w).then(({data:S})=>{P(S);const C=S.reduce((I,A)=>(A.field_name&&(I[A.field_name]=A.value??""),I),{});x.setValue("config",C)})})()},[N,c,x,a]);const k=async v=>{h(!0);try{(await em(v)).data&&($.success(r("form.messages.success")),x.reset(Fa),s(),o(!1))}finally{h(!1)}};return e.jsxs(ge,{open:c,onOpenChange:o,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(he,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(k),className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"name",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:r("form.fields.name.placeholder"),...v})}),e.jsx(L,{children:r("form.fields.name.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"icon",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.icon.label")}),e.jsx(_,{children:e.jsx(T,{...v,value:v.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(L,{children:r("form.fields.icon.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"notify_domain",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.notify_domain.label")}),e.jsx(_,{children:e.jsx(T,{...v,value:v.value||"",placeholder:r("form.fields.notify_domain.placeholder")})}),e.jsx(L,{children:r("form.fields.notify_domain.description")}),e.jsx(D,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:x.control,name:"handling_fee_percent",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(T,{type:"number",...v,value:v.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"handling_fee_fixed",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(T,{type:"number",...v,value:v.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(D,{})]})})]}),e.jsx(j,{control:x.control,name:"payment",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.payment.label")}),e.jsxs(W,{onValueChange:v.onChange,defaultValue:v.value,children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(B,{children:i.map(w=>e.jsx(U,{value:w,children:w},w))})]}),e.jsx(L,{children:r("form.fields.payment.description")}),e.jsx(D,{})]})}),f.length>0&&e.jsx("div",{className:"space-y-4",children:f.map(v=>e.jsx(j,{control:x.control,name:`config.${v.field_name}`,render:({field:w})=>e.jsxs(g,{children:[e.jsx(b,{children:v.label}),e.jsx(_,{children:e.jsx(T,{...w,value:w.value||""})}),e.jsx(D,{})]})},v.field_name))}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",disabled:u,children:r("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:a,className:l}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(R,{variant:"ghost",size:"default",className:y("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",l),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),a&&e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(Pa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(te,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(qt,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Kt,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ao,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:y("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",l),children:[e.jsx("span",{children:n}),a&&e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(te,{children:a})]})})]})}const Xu=no,eh=ro,sh=lo,yr=m.forwardRef(({className:s,...n},a)=>e.jsx(Mn,{className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:a}));yr.displayName=Mn.displayName;const _r=m.forwardRef(({className:s,...n},a)=>e.jsxs(sh,{children:[e.jsx(yr,{}),e.jsx(Ln,{ref:a,className:y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));_r.displayName=Ln.displayName;const Nr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...n});Nr.displayName="AlertDialogHeader";const wr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});wr.displayName="AlertDialogFooter";const Cr=m.forwardRef(({className:s,...n},a)=>e.jsx(On,{ref:a,className:y("text-lg font-semibold",s),...n}));Cr.displayName=On.displayName;const Sr=m.forwardRef(({className:s,...n},a)=>e.jsx(Vn,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Sr.displayName=Vn.displayName;const kr=m.forwardRef(({className:s,...n},a)=>e.jsx(An,{ref:a,className:y($s(),s),...n}));kr.displayName=An.displayName;const Pr=m.forwardRef(({className:s,...n},a)=>e.jsx(Fn,{ref:a,className:y($s({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Pr.displayName=Fn.displayName;function Je({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:o="default",className:u}){return e.jsxs(Xu,{children:[e.jsx(eh,{asChild:!0,children:n}),e.jsxs(_r,{className:y("sm:max-w-[425px]",u),children:[e.jsxs(Nr,{children:[e.jsx(Cr,{children:a}),e.jsx(Sr,{children:l})]}),e.jsxs(wr,{children:[e.jsx(Pr,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r})}),e.jsx(kr,{asChild:!0,children:e.jsx(R,{variant:o,onClick:s,children:c})})]})]})]})}const Tr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),th=({refetch:s,isSortMode:n=!1})=>{const{t:a}=M("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",children:l.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(G,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await tm({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.name")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.payment")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:l})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:l,title:a("table.columns.notify_url")}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{className:"ml-1",children:e.jsx(Tr,{className:"h-4 w-4"})}),e.jsx(te,{children:a("table.columns.notify_url_tooltip")})]})})]}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:l.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:l})=>e.jsx(O,{className:"justify-end",column:l,title:a("table.columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(vr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("table.actions.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await sm({id:l.original.id});r&&s()},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:a("table.actions.delete.title")})]})})]}),size:100}]};function ah({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=M("payment"),c=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:r("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vr,{refetch:n}),e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:o=>s.getColumn("name")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),c&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function nh(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[o,u]=m.useState([]),[h,i]=m.useState({"drag-handle":!1}),[d,f]=m.useState({pageSize:20,pageIndex:0}),{refetch:P}=se({queryKey:["paymentList"],queryFn:async()=>{const{data:v}=await Qd();return u(v?.map(w=>({...w,enable:!!w.enable}))||[]),v}});m.useEffect(()=>{i({"drag-handle":r,actions:!r}),f({pageSize:r?99999:10,pageIndex:0})},[r]);const E=(v,w)=>{r&&(v.dataTransfer.setData("text/plain",w.toString()),v.currentTarget.classList.add("opacity-50"))},x=(v,w)=>{if(!r)return;v.preventDefault(),v.currentTarget.classList.remove("bg-muted");const S=parseInt(v.dataTransfer.getData("text/plain"));if(S===w)return;const C=[...o],[I]=C.splice(S,1);C.splice(w,0,I),u(C)},N=async()=>{r?am({ids:o.map(v=>v.id)}).then(()=>{P(),c(!1),$.success("排序保存成功")}):c(!0)},k=Ae({data:o,columns:th({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:h,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:i,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(Ye,{table:k,toolbar:v=>e.jsx(ah,{table:v,refetch:P,saveOrder:N,isSortMode:r}),draggable:r,onDragStart:E,onDragEnd:v=>v.currentTarget.classList.remove("opacity-50"),onDragOver:v=>{v.preventDefault(),v.currentTarget.classList.add("bg-muted")},onDragLeave:v=>v.currentTarget.classList.remove("bg-muted"),onDrop:x,showPagination:!r})}function rh(){const{t:s}=M("payment");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(nh,{})})]})]})}const lh=Object.freeze(Object.defineProperty({__proto__:null,default:rh},Symbol.toStringTag,{value:"Module"})),ih=(s,n)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(T,{placeholder:s.placeholder,...n});break;case"textarea":a=e.jsx(Cs,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:y($s({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:a=null;break}return a};function oh({themeKey:s,themeInfo:n}){const{t:a}=M("theme"),[l,r]=m.useState(!1),[c,o]=m.useState(!1),[u,h]=m.useState(!1),i=ce({defaultValues:n.configs.reduce((P,E)=>(P[E.field_name]="",P),{})}),d=async()=>{o(!0),Vd(s).then(({data:P})=>{Object.entries(P).forEach(([E,x])=>{i.setValue(E,x)})}).finally(()=>{o(!1)})},f=async P=>{h(!0),Ad(s,P).then(()=>{$.success(a("config.success")),r(!1)}).finally(()=>{h(!1)})};return e.jsxs(ge,{open:l,onOpenChange:P=>{r(P),P?d():i.reset()},children:[e.jsx(Le,{asChild:!0,children:e.jsx(R,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(pe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:a("config.title",{name:n.name})}),e.jsx(Te,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ra,{className:"h-6 w-6 animate-spin"})}):e.jsx(he,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(f),className:"space-y-4",children:[n.configs.map(P=>e.jsx(j,{control:i.control,name:P.field_name,render:({field:E})=>e.jsxs(g,{children:[e.jsx(b,{children:P.label}),e.jsx(_,{children:ih(P,E)}),e.jsx(D,{})]})},P.field_name)),e.jsxs(Oe,{className:"mt-6 gap-2",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(R,{type:"submit",loading:u,children:a("config.save")})]})]})})]})]})}function ch(){const{t:s}=M("theme"),[n,a]=m.useState(null),[l,r]=m.useState(!1),[c,o]=m.useState(!1),[u,h]=m.useState(!1),[i,d]=m.useState(null),f=m.useRef(null),[P,E]=m.useState(0),{data:x,isLoading:N,refetch:k}=se({queryKey:["themeList"],queryFn:async()=>{const{data:z}=await Od();return z}}),v=async z=>{a(z),Ud({frontend_theme:z}).then(()=>{$.success("主题切换成功"),k()}).finally(()=>{a(null)})},w=async z=>{if(!z.name.endsWith(".zip")){$.error(s("upload.error.format"));return}r(!0),Fd(z).then(()=>{$.success("主题上传成功"),o(!1),k()}).finally(()=>{r(!1),f.current&&(f.current.value="")})},S=z=>{z.preventDefault(),z.stopPropagation(),z.type==="dragenter"||z.type==="dragover"?h(!0):z.type==="dragleave"&&h(!1)},C=z=>{z.preventDefault(),z.stopPropagation(),h(!1),z.dataTransfer.files&&z.dataTransfer.files[0]&&w(z.dataTransfer.files[0])},I=()=>{i&&E(z=>z===0?i.images.length-1:z-1)},A=()=>{i&&E(z=>z===i.images.length-1?0:z+1)},Z=(z,X)=>{E(0),d({name:z,images:X})};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(R,{onClick:()=>o(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:N?e.jsxs(e.Fragment,{children:[e.jsx(za,{}),e.jsx(za,{})]}):x?.themes&&Object.entries(x.themes).map(([z,X])=>e.jsx(Ge,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:X.background_url?`url(${X.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:y("relative z-10 h-full transition-colors",X.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!X.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Je,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(z===x?.active){$.error(s("card.delete.error.active"));return}a(z),zd(z).then(()=>{$.success("主题删除成功"),k()}).finally(()=>{a(null)})},children:e.jsx(R,{disabled:n===z,loading:n===z,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(ss,{children:[e.jsx(vs,{children:X.name}),e.jsx(tt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:X.description}),X.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:X.version})})]})})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(X.name,X.images),children:e.jsx(io,{className:"h-4 w-4"})}),e.jsx(oh,{themeKey:z,themeInfo:X}),e.jsx(R,{onClick:()=>v(z),disabled:n===z||z===x.active,loading:n===z,variant:z===x.active?"secondary":"default",children:z===x.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},z))}),e.jsx(ge,{open:c,onOpenChange:o,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsxs(be,{children:[e.jsx(je,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:y("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",u&&"border-primary/50 bg-muted/50"),onDragEnter:S,onDragLeave:S,onDragOver:S,onDrop:C,children:[e.jsx("input",{type:"file",ref:f,className:"hidden",accept:".zip",onChange:z=>{const X=z.target.files?.[0];X&&w(X)}}),l?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(Gt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>f.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(ge,{open:!!i,onOpenChange:z=>{z||(d(null),E(0))},children:e.jsxs(pe,{className:"max-w-4xl",children:[e.jsxs(be,{children:[e.jsxs(je,{children:[i?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:i&&s("preview.imageCount",{current:P+1,total:i.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:i?.images[P]&&e.jsx("img",{src:i.images[P],alt:`${i.name} 预览图 ${P+1}`,className:"h-full w-full object-contain"})}),i&&i.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:I,children:e.jsx(oo,{className:"h-4 w-4"})}),e.jsx(R,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:A,children:e.jsx(co,{className:"h-4 w-4"})})]})]}),i&&i.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:i.images.map((z,X)=>e.jsx("button",{onClick:()=>E(X),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",P===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:z,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function za(){return e.jsxs(Ge,{children:[e.jsxs(ss,{children:[e.jsx(Ee,{className:"h-6 w-[200px]"}),e.jsx(Ee,{className:"h-4 w-[300px]"})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[e.jsx(Ee,{className:"h-10 w-[100px]"}),e.jsx(Ee,{className:"h-10 w-[100px]"})]})]})}const dh=Object.freeze(Object.defineProperty({__proto__:null,default:ch},Symbol.toStringTag,{value:"Module"})),pa=m.forwardRef(({className:s,value:n,onChange:a,...l},r)=>{const[c,o]=m.useState("");m.useEffect(()=>{if(c.includes(",")){const h=new Set([...n,...c.split(",").map(i=>i.trim())]);a(Array.from(h)),o("")}},[c,a,n]);const u=()=>{if(c){const h=new Set([...n,c]);a(Array.from(h)),o("")}};return e.jsxs("div",{className:y(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(h=>e.jsxs(H,{variant:"secondary",children:[h,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(n.filter(i=>i!==h))},children:e.jsx(Bt,{className:"w-3"})})]},h)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:c,onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),u()):h.key==="Backspace"&&c.length===0&&n.length>0&&(h.preventDefault(),a(n.slice(0,-1)))},...l,ref:r})]})});pa.displayName="InputTags";const mh=p.object({id:p.number().nullable(),title:p.string().min(1).max(250),content:p.string().min(1),show:p.boolean(),tags:p.array(p.string()),img_url:p.string().nullable()}),uh={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Dr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=uh}){const{t:r}=M("notice"),[c,o]=m.useState(!1),u=ce({resolver:ue(mh),defaultValues:l,mode:"onChange",shouldFocusError:!0}),h=new la({html:!0});return e.jsx(he,{...u,children:e.jsxs(ge,{onOpenChange:o,open:c,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(j,{control:u.control,name:"title",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.fields.title.placeholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"content",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.content.label")}),e.jsx(_,{children:e.jsx(ia,{style:{height:"500px"},value:i.value,renderHTML:d=>h.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"img_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...i,value:i.value||""})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"tags",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(pa,{value:i.value,onChange:i.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",onClick:i=>{i.preventDefault(),u.handleSubmit(async d=>{rm(d).then(({data:f})=>{f&&($.success(r("form.buttons.success")),s(),o(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function hh({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=M("notice"),c=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!l&&e.jsx(Dr,{refetch:n}),!l&&e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),c&&!l&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const ph=s=>{const{t:n}=M("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(mo,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(H,{variant:"outline",className:"font-mono",children:a.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(G,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{const{data:l}=await im({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.title")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:a.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Dr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:a.original}),e.jsx(Je,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{lm({id:a.original.id}).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function xh(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),[h,i]=m.useState(!1),[d,f]=m.useState({}),[P,E]=m.useState({pageSize:50,pageIndex:0}),[x,N]=m.useState([]),{refetch:k}=se({queryKey:["notices"],queryFn:async()=>{const{data:I}=await nm();return N(I),I}});m.useEffect(()=>{l({"drag-handle":h,content:!h,created_at:!h,actions:!h}),E({pageSize:h?99999:50,pageIndex:0})},[h]);const v=(I,A)=>{h&&(I.dataTransfer.setData("text/plain",A.toString()),I.currentTarget.classList.add("opacity-50"))},w=(I,A)=>{if(!h)return;I.preventDefault(),I.currentTarget.classList.remove("bg-muted");const Z=parseInt(I.dataTransfer.getData("text/plain"));if(Z===A)return;const z=[...x],[X]=z.splice(Z,1);z.splice(A,0,X),N(z)},S=async()=>{if(!h){i(!0);return}Vm(x.map(I=>I.id)).then(()=>{$.success("排序保存成功"),i(!1),k()}).finally(()=>{i(!1)})},C=Ae({data:x??[],columns:ph(k),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:P},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:f,onPaginationChange:E,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:C,toolbar:I=>e.jsx(hh,{table:I,refetch:k,saveOrder:S,isSortMode:h}),draggable:h,onDragStart:v,onDragEnd:I=>I.currentTarget.classList.remove("opacity-50"),onDragOver:I=>{I.preventDefault(),I.currentTarget.classList.add("bg-muted")},onDragLeave:I=>I.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!h})})}function fh(){const{t:s}=M("notice");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(xh,{})})]})]})}const gh=Object.freeze(Object.defineProperty({__proto__:null,default:fh},Symbol.toStringTag,{value:"Module"})),jh=p.object({id:p.number().nullable(),language:p.string().max(250),category:p.string().max(250),title:p.string().min(1).max(250),body:p.string().min(1),show:p.boolean()}),bh={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Rr({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=bh}){const{t:r}=M("knowledge"),[c,o]=m.useState(!1),u=ce({resolver:ue(jh),defaultValues:l,mode:"onChange",shouldFocusError:!0}),h=new la({html:!0});return m.useEffect(()=>{c&&l.id&&cm(l.id).then(({data:i})=>{u.reset(i)})},[l.id,u,c]),e.jsxs(ge,{onOpenChange:o,open:c,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(he,{...u,children:[e.jsx(j,{control:u.control,name:"title",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.titlePlaceholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"category",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.categoryPlaceholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"language",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.language")}),e.jsx(_,{children:e.jsxs(W,{value:i.value,onValueChange:i.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx(U,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(j,{control:u.control,name:"body",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.content")}),e.jsx(_,{children:e.jsx(ia,{style:{height:"500px"},value:i.value,renderHTML:d=>h.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(D,{})]})}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{u.handleSubmit(i=>{dm(i).then(({data:d})=>{d&&(u.reset(),$.success(r("messages.operationSuccess")),o(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function vh({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Es,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function yh({table:s,refetch:n,saveOrder:a,isSortMode:l}){const r=s.getState().columnFilters.length>0,{t:c}=M("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{refreshData:n}),e.jsx(T,{placeholder:c("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(vh,{column:s.getColumn("category"),title:c("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(o=>o.getValue("category")))).map(o=>({label:o,value:o}))}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const _h=({refetch:s,isSortMode:n=!1})=>{const{t:a}=M("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",className:"justify-center",children:l.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(G,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{um({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.title")}),cell:({row:l})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:l.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.category")}),cell:({row:l})=>e.jsx(H,{variant:"secondary",className:"max-w-[180px] truncate",children:l.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:l})=>e.jsx(O,{className:"justify-end",column:l,title:a("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Rr,{refreshData:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("form.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{mm({id:l.original.id}).then(({data:r})=>{r&&($.success(a("messages.operationSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:a("messages.deleteButton")})]})})]}),size:100}]};function Nh(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[o,u]=m.useState([]),[h,i]=m.useState({"drag-handle":!1}),[d,f]=m.useState({pageSize:20,pageIndex:0}),{refetch:P,isLoading:E,data:x}=se({queryKey:["knowledge"],queryFn:async()=>{const{data:S}=await om();return u(S||[]),S}});m.useEffect(()=>{i({"drag-handle":r,actions:!r}),f({pageSize:r?99999:10,pageIndex:0})},[r]);const N=(S,C)=>{r&&(S.dataTransfer.setData("text/plain",C.toString()),S.currentTarget.classList.add("opacity-50"))},k=(S,C)=>{if(!r)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const I=parseInt(S.dataTransfer.getData("text/plain"));if(I===C)return;const A=[...o],[Z]=A.splice(I,1);A.splice(C,0,Z),u(A)},v=async()=>{r?hm({ids:o.map(S=>S.id)}).then(()=>{P(),c(!1),$.success("排序保存成功")}):c(!0)},w=Ae({data:o,columns:_h({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:h,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:i,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:w,toolbar:S=>e.jsx(yh,{table:S,refetch:P,saveOrder:v,isSortMode:r}),draggable:r,onDragStart:N,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!r})}function wh(){const{t:s}=M("knowledge");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Nh,{})})]})]})}const Ch=Object.freeze(Object.defineProperty({__proto__:null,default:wh},Symbol.toStringTag,{value:"Module"}));function Sh(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function zt(s,n){if(s.length===0)return{};if(!n)return{"":s};const a={};return s.forEach(l=>{const r=l[n]||"";a[r]||(a[r]=[]),a[r].push(l)}),a}function kh(s,n){const a=JSON.parse(JSON.stringify(s));for(const[l,r]of Object.entries(a))a[l]=r.filter(c=>!n.find(o=>o.value===c.value));return a}function Ph(s,n){for(const[,a]of Object.entries(s))if(a.some(l=>n.find(r=>r.value===l.value)))return!0;return!1}const Ir=m.forwardRef(({className:s,...n},a)=>uo(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Ir.displayName="CommandEmpty";const lt=m.forwardRef(({value:s,onChange:n,placeholder:a,defaultOptions:l=[],options:r,delay:c,onSearch:o,loadingIndicator:u,emptyIndicator:h,maxSelected:i=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:f,disabled:P,groupBy:E,className:x,badgeClassName:N,selectFirstItem:k=!0,creatable:v=!1,triggerSearchOnFocus:w=!1,commandProps:S,inputProps:C,hideClearAllButton:I=!1},A)=>{const Z=m.useRef(null),[z,X]=m.useState(!1),qs=m.useRef(!1),[va,ya]=m.useState(!1),[ee,Ks]=m.useState(s||[]),[Ss,_a]=m.useState(zt(l,E)),[ps,Ot]=m.useState(""),Bs=Sh(ps,c||500);m.useImperativeHandle(A,()=>({selectedValue:[...ee],input:Z.current,focus:()=>Z.current?.focus()}),[ee]);const mt=m.useCallback(q=>{const ae=ee.filter(Pe=>Pe.value!==q.value);Ks(ae),n?.(ae)},[n,ee]),sl=m.useCallback(q=>{const ae=Z.current;ae&&((q.key==="Delete"||q.key==="Backspace")&&ae.value===""&&ee.length>0&&(ee[ee.length-1].fixed||mt(ee[ee.length-1])),q.key==="Escape"&&ae.blur())},[mt,ee]);m.useEffect(()=>{s&&Ks(s)},[s]),m.useEffect(()=>{if(!r||o)return;const q=zt(r||[],E);JSON.stringify(q)!==JSON.stringify(Ss)&&_a(q)},[l,r,E,o,Ss]),m.useEffect(()=>{const q=async()=>{ya(!0);const Pe=await o?.(Bs);_a(zt(Pe||[],E)),ya(!1)};(async()=>{!o||!z||(w&&await q(),Bs&&await q())})()},[Bs,E,z,w]);const tl=()=>{if(!v||Ph(Ss,[{value:ps,label:ps}])||ee.find(ae=>ae.value===ps))return;const q=e.jsx(Ne,{value:ps,className:"cursor-pointer",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onSelect:ae=>{if(ee.length>=i){d?.(ee.length);return}Ot("");const Pe=[...ee,{value:ae,label:ae}];Ks(Pe),n?.(Pe)},children:`Create "${ps}"`});if(!o&&ps.length>0||o&&Bs.length>0&&!va)return q},al=m.useCallback(()=>{if(h)return o&&!v&&Object.keys(Ss).length===0?e.jsx(Ne,{value:"-",disabled:!0,children:h}):e.jsx(Ir,{children:h})},[v,h,o,Ss]),nl=m.useMemo(()=>kh(Ss,ee),[Ss,ee]),rl=m.useCallback(()=>{if(S?.filter)return S.filter;if(v)return(q,ae)=>q.toLowerCase().includes(ae.toLowerCase())?1:-1},[v,S?.filter]),ll=m.useCallback(()=>{const q=ee.filter(ae=>ae.fixed);Ks(q),n?.(q)},[n,ee]);return e.jsxs(Ns,{...S,onKeyDown:q=>{sl(q),S?.onKeyDown?.(q)},className:y("h-auto overflow-visible bg-transparent",S?.className),shouldFilter:S?.shouldFilter!==void 0?S.shouldFilter:!o,filter:rl(),children:[e.jsx("div",{className:y("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":ee.length!==0,"cursor-text":!P&&ee.length!==0},x),onClick:()=>{P||Z.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(q=>e.jsxs(H,{className:y("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",N),"data-fixed":q.fixed,"data-disabled":P||void 0,children:[q.label,e.jsx("button",{className:y("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(P||q.fixed)&&"hidden"),onKeyDown:ae=>{ae.key==="Enter"&&mt(q)},onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:()=>mt(q),children:e.jsx(Bt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},q.value)),e.jsx(Se.Input,{...C,ref:Z,value:ps,disabled:P,onValueChange:q=>{Ot(q),C?.onValueChange?.(q)},onBlur:q=>{qs.current===!1&&X(!1),C?.onBlur?.(q)},onFocus:q=>{X(!0),w&&o?.(Bs),C?.onFocus?.(q)},placeholder:f&&ee.length!==0?"":a,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":f,"px-3 py-2":ee.length===0,"ml-1":ee.length!==0},C?.className)}),e.jsx("button",{type:"button",onClick:ll,className:y((I||P||ee.length<1||ee.filter(q=>q.fixed).length===ee.length)&&"hidden"),children:e.jsx(Bt,{})})]})}),e.jsx("div",{className:"relative",children:z&&e.jsx(ws,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{qs.current=!1},onMouseEnter:()=>{qs.current=!0},onMouseUp:()=>{Z.current?.focus()},children:va?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[al(),tl(),!k&&e.jsx(Ne,{value:"-",className:"hidden"}),Object.entries(nl).map(([q,ae])=>e.jsx(Me,{heading:q,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ae.map(Pe=>e.jsx(Ne,{value:Pe.value,disabled:Pe.disable,onMouseDown:Ws=>{Ws.preventDefault(),Ws.stopPropagation()},onSelect:()=>{if(ee.length>=i){d?.(ee.length);return}Ot("");const Ws=[...ee,Pe];Ks(Ws),n?.(Ws)},className:y("cursor-pointer",Pe.disable&&"cursor-default text-muted-foreground"),children:Pe.label},Pe.value))})},q))]})})})]})});lt.displayName="MultipleSelector";const Th=s=>p.object({id:p.number().optional(),name:p.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 Lt({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=M("group"),c=ce({resolver:ue(Th(r)),defaultValues:a,mode:"onChange"}),[o,u]=m.useState(!1),[h,i]=m.useState(!1),d=async f=>{i(!0),Bd(f).then(()=>{$.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{i(!1)})};return e.jsxs(ge,{open:o,onOpenChange:u,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(he,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(j,{control:c.control,name:"name",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.name")}),e.jsx(_,{children:e.jsx(T,{placeholder:r("form.namePlaceholder"),...f,className:"w-full"})}),e.jsx(L,{children:r("form.nameDescription")}),e.jsx(D,{})]})}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(R,{type:"submit",disabled:h||!c.formState.isValid,children:[h&&e.jsx(ra,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Er=m.createContext(void 0);function Dh({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[o,u]=m.useState(ye.Shadowsocks);return e.jsx(Er.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:o,setServerType:u,refetch:n},children:s})}function Mr(){const s=m.useContext(Er);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Ut({dialogTrigger:s,value:n,setValue:a,templateType:l}){const{t:r}=M("server");m.useEffect(()=>{console.log(n)},[n]);const[c,o]=m.useState(!1),[u,h]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[i,d]=m.useState(null),f=v=>{if(!v)return null;try{const w=JSON.parse(v);return typeof w!="object"||w===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},P={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}}},E=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},x=()=>{const v=f(u||"");if(v){$.error(v);return}try{if(!u){a(null),o(!1);return}a(JSON.parse(u)),o(!1)}catch{$.error(r("network_settings.errors.save_failed"))}},N=v=>{h(v),d(f(v))},k=v=>{const w=P[v];if(w){const S=JSON.stringify(w.content,null,2);h(S),d(null)}};return m.useEffect(()=>{c&&console.log(n)},[c,n]),m.useEffect(()=>{c&&n&&Object.keys(n).length>0&&h(JSON.stringify(n,null,2))},[c,n]),e.jsxs(ge,{open:c,onOpenChange:v=>{!v&&c&&x(),o(v)},children:[e.jsx(Le,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:r("network_settings.edit_protocol")})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(je,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[E().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:E().map(v=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>k(v),children:r("network_settings.use_template",{template:P[v].label})},v))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Cs,{className:`min-h-[200px] font-mono text-sm ${i?"border-red-500 focus-visible:ring-red-500":""}`,value:u,placeholder:E().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:v=>N(v.target.value)}),i&&e.jsx("p",{className:"text-sm text-red-500",children:i})]})]}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>o(!1),children:r("common.cancel")}),e.jsx(J,{onClick:x,disabled:!!i,children:r("common.confirm")})]})]})]})}function Dx(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 Rh={},Ih=Object.freeze(Object.defineProperty({__proto__:null,default:Rh},Symbol.toStringTag,{value:"Module"})),Rx=So(Ih),Ua=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Eh=()=>{try{const s=ho.box.keyPair(),n=Ua(Ta.encodeBase64(s.secretKey)),a=Ua(Ta.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Mh=()=>{try{return Eh()}catch(s){throw console.error("Error generating key pair:",s),s}},Lh=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("").substring(0,s)},Oh=()=>{const s=Math.floor(Math.random()*8)*2+2;return Lh(s)},Vh=p.object({cipher:p.string().default("aes-128-gcm"),obfs:p.string().default("0"),obfs_settings:p.object({path:p.string().default(""),host:p.string().default("")}).default({})}),Ah=p.object({tls:p.coerce.number().default(0),tls_settings:p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1)}).default({}),network:p.string().default("tcp"),network_settings:p.record(p.any()).default({})}),Fh=p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1),network:p.string().default("tcp"),network_settings:p.record(p.any()).default({})}),zh=p.object({version:p.coerce.number().default(2),alpn:p.string().default("h2"),obfs:p.object({open:p.coerce.boolean().default(!1),type:p.string().default("salamander"),password:p.string().default("")}).default({}),tls:p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1)}).default({}),bandwidth:p.object({up:p.string().default(""),down:p.string().default("")}).default({})}),Uh=p.object({tls:p.coerce.number().default(0),tls_settings:p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1)}).default({}),reality_settings:p.object({server_port:p.coerce.number().default(443),server_name:p.string().default(""),allow_insecure:p.boolean().default(!1),public_key:p.string().default(""),private_key:p.string().default(""),short_id:p.string().default("")}).default({}),network:p.string().default("tcp"),network_settings:p.record(p.any()).default({}),flow:p.string().default("")}),rs={shadowsocks:{schema:Vh,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]},vmess:{schema:Ah,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Fh,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:zh,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Uh,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]}},$h=({serverType:s,value:n,onChange:a})=>{const{t:l}=M("server"),r=s?rs[s]:null,c=r?.schema||p.record(p.any()),o=s?c.parse({}):{},u=ce({resolver:ue(c),defaultValues:o,mode:"onChange"});if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const x=c.parse({});u.reset(x)}}else u.reset(n)},[s,n,a,u,c]),m.useEffect(()=>{const x=u.watch(N=>{a(N)});return()=>x.unsubscribe()},[u,a]),!s||!r)return null;const E={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"cipher",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.shadowsocks.ciphers.map(N=>e.jsx(U,{value:N,children:N},N))})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(xs,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(U,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs_settings.path",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...x})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"obfs_settings.host",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.host"),...x})}),e.jsx(D,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value?.toString(),onValueChange:N=>x.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(U,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value,onCheckedChange:x.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:x})=>e.jsxs(g,{children:[e.jsxs(b,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Ut,{value:u.watch("network_settings"),setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.vmess.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...x,value:x.value||""})})]})}),e.jsx(j,{control:u.control,name:"allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value||!1,onCheckedChange:x.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:x})=>e.jsxs(g,{children:[e.jsxs(b,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Ut,{value:u.watch("network_settings")||{},setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value||"tcp",children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.trojan.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"version",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(W,{value:(x.value||2).toString(),onValueChange:N=>x.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.hysteria.versions.map(N=>e.jsxs(U,{value:N,className:"cursor-pointer",children:["V",N]},N))})})]})})]})}),u.watch("version")==1&&e.jsx(j,{control:u.control,name:"alpn",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value||"h2",onValueChange:x.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.hysteria.alpnOptions.map(N=>e.jsx(U,{value:N,children:N},N))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs.open",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value||!1,onCheckedChange:x.onChange})})})]})}),!!u.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[u.watch("version")=="2"&&e.jsx(j,{control:u.control,name:"obfs.type",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value||"salamander",onValueChange:x.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:e.jsx(U,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs.password",render:({field:x})=>e.jsxs(g,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...x,value:x.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",k=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(v=>N[v%N.length]).join("");u.setValue("obfs.password",k),$.success(l("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(_e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...x,value:x.value||""})})]})}),e.jsx(j,{control:u.control,name:"tls.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value||!1,onCheckedChange:x.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"bandwidth.up",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(u.watch("version")==2?l("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...x,value:x.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(j,{control:u.control,name:"bandwidth.down",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(u.watch("version")==2?l("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...x,value:x.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value?.toString(),onValueChange:N=>x.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(U,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(U,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value,onCheckedChange:x.onChange})})})]})})]}),u.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"reality_settings.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.server_port",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value,onCheckedChange:x.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(j,{control:u.control,name:"reality_settings.private_key",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{...x,className:"pr-9"})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const N=Mh();u.setValue("reality_settings.private_key",N.privateKey),u.setValue("reality_settings.public_key",N.publicKey),$.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(l("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(_e,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(j,{control:u.control,name:"reality_settings.public_key",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(T,{...x})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.short_id",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{...x,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const N=Oh();u.setValue("reality_settings.short_id",N),$.success(l("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(_e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(L,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:x})=>e.jsxs(g,{children:[e.jsxs(b,{children:[l("dynamic_form.vless.network.label"),e.jsx(Ut,{value:u.watch("network_settings"),setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.vless.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})}),e.jsx(j,{control:u.control,name:"flow",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:N=>x.onChange(N==="none"?null:N),value:x.value||"none",children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:rs.vless.flowOptions.map(N=>e.jsx(U,{value:N,children:N},N))})]})})]})})]})};return e.jsx(oe,{children:E[s]?.()})},Hh=p.object({id:p.number().optional().nullable(),code:p.string().optional(),name:p.string().min(1,"form.name.error"),rate:p.string().min(1,"form.rate.error"),tags:p.array(p.string()).default([]),excludes:p.array(p.string()).default([]),ips:p.array(p.string()).default([]),group_ids:p.array(p.string()).default([]),host:p.string().min(1,"form.host.error"),port:p.string().min(1,"form.port.error"),server_port:p.string().min(1,"form.server_port.error"),parent_id:p.string().default("0").nullable(),route_ids:p.array(p.string()).default([]),protocol_settings:p.record(p.any()).default({}).nullable()}),pt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Gh(){const{t:s}=M("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:o,refetch:u}=Mr(),[h,i]=m.useState([]),[d,f]=m.useState([]),[P,E]=m.useState([]),x=ce({resolver:ue(Hh),defaultValues:pt,mode:"onChange"});m.useEffect(()=>{N()},[n]),m.useEffect(()=>{l?.type&&l.type!==c&&o(l.type)},[l,c,o]),m.useEffect(()=>{l?l.type===c&&x.reset({...pt,...l}):x.reset({...pt,protocol_settings:rs[c].schema.parse({})})},[l,x,c]);const N=async()=>{if(!n)return;const[C,I,A]=await Promise.all([Mt(),xr(),pr()]);i(C.data?.map(Z=>({label:Z.name,value:Z.id.toString()}))||[]),f(I.data?.map(Z=>({label:Z.remarks,value:Z.id.toString()}))||[]),E(A.data||[])},k=m.useMemo(()=>P?.filter(C=>(C.parent_id===0||C.parent_id===null)&&C.type===c&&C.id!==x.watch("id")),[c,P,x]),v=()=>e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(is,{align:"start",children:e.jsx(hd,{children:Ps.map(({type:C,label:I})=>e.jsx(xe,{onClick:()=>{o(C),a(!0)},className:"cursor-pointer",children:e.jsx(H,{variant:"outline",className:"text-white",style:{background:ls[C]},children:I})},C))})})]}),w=()=>{a(!1),r(null),x.reset(pt)},S=async()=>{const C=x.getValues();(await $d({...C,type:c})).data&&(w(),$.success(s("form.success")),u())};return e.jsxs(ge,{open:n,onOpenChange:w,children:[v(),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(he,{...x,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:x.control,name:"name",render:({field:C})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:s("form.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.name.placeholder"),...C})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"rate",render:({field:C})=>e.jsxs(g,{className:"flex-[1]",children:[e.jsx(b,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(_,{children:e.jsx(T,{type:"number",min:"0",step:"0.1",...C})})}),e.jsx(D,{})]})})]}),e.jsx(j,{control:x.control,name:"code",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(b,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.code.placeholder"),...C,value:C.value||""})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"tags",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(pa,{value:C.value,onChange:C.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"group_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(b,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Lt,{dialogTrigger:e.jsx(R,{variant:"link",children:s("form.groups.add")}),refetch:N})]}),e.jsx(_,{children:e.jsx(lt,{options:h,onChange:I=>C.onChange(I.map(A=>A.value)),value:h?.filter(I=>C.value.includes(I.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"host",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.host.placeholder"),...C})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{control:x.control,name:"port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(_e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_,{children:e.jsx(T,{placeholder:s("form.port.placeholder"),...C})}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const I=C.value;I&&x.setValue("server_port",I)},children:e.jsx(_e,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(te,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"server_port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(_e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.server_port.placeholder"),...C})}),e.jsx(D,{})]})})]})]}),n&&e.jsx($h,{serverType:c,value:x.watch("protocol_settings"),onChange:C=>x.setValue("protocol_settings",C,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(j,{control:x.control,name:"parent_id",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.parent.label")}),e.jsxs(W,{onValueChange:C.onChange,value:C.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("form.parent.none")}),k?.map(I=>e.jsx(U,{value:I.id.toString(),className:"cursor-pointer",children:I.name},I.id))]})]}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"route_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(lt,{options:d,onChange:I=>C.onChange(I.map(A=>A.value)),value:d?.filter(I=>C.value.includes(I.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(D,{})]})})]}),e.jsxs(Oe,{className:"mt-6",children:[e.jsx(R,{type:"button",variant:"outline",onClick:w,children:s("form.cancel")}),e.jsx(R,{type:"submit",onClick:S,children:s("form.submit")})]})]})]})]})}function $a({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Es,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${c.color}`}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const qh=[{value:ye.Shadowsocks,label:Ps.find(s=>s.type===ye.Shadowsocks)?.label,color:ls[ye.Shadowsocks]},{value:ye.Vmess,label:Ps.find(s=>s.type===ye.Vmess)?.label,color:ls[ye.Vmess]},{value:ye.Trojan,label:Ps.find(s=>s.type===ye.Trojan)?.label,color:ls[ye.Trojan]},{value:ye.Hysteria,label:Ps.find(s=>s.type===ye.Hysteria)?.label,color:ls[ye.Hysteria]},{value:ye.Vless,label:Ps.find(s=>s.type===ye.Vless)?.label,color:ls[ye.Vless]}];function Kh({table:s,saveOrder:n,isSortMode:a,groups:l}){const r=s.getState().columnFilters.length>0,{t:c}=M("server"),o=l.map(u=>({label:u,value:u}));return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!a&&e.jsxs(e.Fragment,{children:[e.jsx(Gh,{}),e.jsx(T,{placeholder:c("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:u=>s.getColumn("name")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx($a,{column:s.getColumn("type"),title:c("toolbar.type"),options:qh}),s.getColumn("groups")&&e.jsx($a,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:o})]}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),a&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const it=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),xt={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"},Bh=s=>{const{t:n}=M("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Dt,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(H,{variant:"outline",className:y("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:ls[a.original.type]},children:[e.jsx(zn,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:r??l}),a.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:a.original.parent?.code||a.original.parent?.id})]}):""]})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:c=>{c.stopPropagation(),wt(r||l.toString())},children:e.jsx(Da,{className:"size-3"})})]})}),e.jsxs(te,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ps.find(c=>c.type===a.original.type)?.label,a.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:200,enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.show")}),cell:({row:a})=>{const[l,r]=m.useState(!!a.getValue("show"));return e.jsx(G,{checked:l,onCheckedChange:async c=>{r(c),qd({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?ls[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:a,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",xt[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",xt[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",xt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",xt[a.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:a.getValue("name")})]})}),e.jsx(te,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${a.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.address")}),cell:({row:a})=>{const l=`${a.original.host}:${a.original.port}`,r=a.original.port!==a.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[a.original.host,":",a.original.port]})}),r&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",a.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(oe,{delayDuration:0,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:c=>{c.stopPropagation(),wt(l)},children:e.jsx(Da,{className:"size-3"})})}),e.jsx(te,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:a})=>e.jsxs(H,{variant:"secondary",className:"font-medium",children:[a.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"groups",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:a})=>{const l=a.getValue("groups")||[];return e.jsx("div",{className:"flex min-w-[300px] max-w-[600px] flex-wrap items-center gap-1.5",children:l.length>0?l.map((r,c)=>e.jsx(H,{variant:"secondary",className:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:r.name},c)):e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})})},enableSorting:!1,size:600,filterFn:(a,l,r)=>{const c=a.getValue(l);return c?r.some(o=>c.includes(o)):!1}},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.type")}),cell:({row:a})=>{const l=a.getValue("type");return e.jsx(H,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:ls[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=Mr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(ys,{modal:!1,children:[e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(_t,{className:"size-4"})})}),e.jsxs(is,{align:"end",className:"w-40",children:[e.jsx(xe,{className:"cursor-pointer",onClick:()=>{c(a.original.type),r(a.original),l(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(po,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(xe,{className:"cursor-pointer",onClick:async()=>{Gd({id:a.original.id}).then(({data:o})=>{o&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(xo,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(at,{}),e.jsx(xe,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:o=>o.preventDefault(),children:e.jsx(Je,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Hd({id:a.original.id}).then(({data:o})=>{o&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(cs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Wh(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[o,u]=m.useState({pageSize:500,pageIndex:0}),[h,i]=m.useState([]),[d,f]=m.useState(!1),[P,E]=m.useState({}),[x,N]=m.useState([]),{refetch:k}=se({queryKey:["nodeList"],queryFn:async()=>{const{data:A}=await pr();return N(A),A}}),v=m.useMemo(()=>{const A=new Set;return x.forEach(Z=>{Z.groups&&Z.groups.forEach(z=>A.add(z.name))}),Array.from(A).sort()},[x]);m.useEffect(()=>{l({"drag-handle":d,show:!d,host:!d,online:!d,rate:!d,groups:!d,type:!1,actions:!d}),E({name:d?2e3:200}),u({pageSize:d?99999:500,pageIndex:0})},[d]);const w=(A,Z)=>{d&&(A.dataTransfer.setData("text/plain",Z.toString()),A.currentTarget.classList.add("opacity-50"))},S=(A,Z)=>{if(!d)return;A.preventDefault(),A.currentTarget.classList.remove("bg-muted");const z=parseInt(A.dataTransfer.getData("text/plain"));if(z===Z)return;const X=[...x],[qs]=X.splice(z,1);X.splice(Z,0,qs),N(X)},C=async()=>{if(!d){f(!0);return}const A=x?.map((Z,z)=>({id:Z.id,order:z+1}));Kd(A).then(()=>{$.success("排序保存成功"),f(!1),k()}).finally(()=>{f(!1)})},I=Ae({data:x||[],columns:Bh(k),state:{sorting:h,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:P,pagination:o},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:i,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:E,onPaginationChange:u,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Dh,{refetch:k,children:e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:I,toolbar:A=>e.jsx(Kh,{table:A,refetch:k,saveOrder:C,isSortMode:d,groups:v}),draggable:d,onDragStart:w,onDragEnd:A=>A.currentTarget.classList.remove("opacity-50"),onDragOver:A=>{A.preventDefault(),A.currentTarget.classList.add("bg-muted")},onDragLeave:A=>A.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!d})})})}function Yh(){const{t:s}=M("server");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Wh,{})})]})]})}const Jh=Object.freeze(Object.defineProperty({__proto__:null,default:Yh},Symbol.toStringTag,{value:"Module"}));function Qh({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=M("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(Lt,{refetch:n}),e.jsx(T,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:y("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]})})}const Zh=s=>{const{t:n}=M("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(H,{variant:"outline",children:a.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:a.getValue("name")})})},{accessorKey:"users_count",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(zn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Lt,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Je,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Wd({id:a.original.id}).then(({data:l})=>{l&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Xh(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),{data:h,refetch:i,isLoading:d}=se({queryKey:["serverGroupList"],queryFn:async()=>{const{data:P}=await Mt();return P}}),f=Ae({data:h||[],columns:Zh(i),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:f,toolbar:P=>e.jsx(Qh,{table:P,refetch:i}),isLoading:d})}function ep(){const{t:s}=M("group");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Xh,{})})]})]})}const sp=Object.freeze(Object.defineProperty({__proto__:null,default:ep},Symbol.toStringTag,{value:"Module"})),tp=s=>p.object({remarks:p.string().min(1,s("form.validation.remarks")),match:p.array(p.string()),action:p.enum(["block","dns"]),action_value:p.string().optional()});function Lr({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=M("route"),c=ce({resolver:ue(tp(r)),defaultValues:a,mode:"onChange"}),[o,u]=m.useState(!1);return e.jsxs(ge,{open:o,onOpenChange:u,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(he,{...c,children:[e.jsx(j,{control:c.control,name:"remarks",render:({field:h})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.remarksPlaceholder"),...h})})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"match",render:({field:h})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(Cs,{className:"min-h-[120px]",placeholder:r("form.matchPlaceholder"),value:h.value.join(` +`).filter(Boolean);i.onChange(f),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(L,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"recaptcha_key",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.key.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.recaptcha.key.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_site_key",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(D,{})]})})]}),e.jsx(j,{control:r.control,name:"register_limit_by_ip_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(L,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"register_limit_count",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.registerLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"register_limit_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(D,{})]})})]}),e.jsx(j,{control:r.control,name:"password_limit_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(L,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"password_limit_count",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"password_limit_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(L,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function uu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(ve,{}),e.jsx(mu,{})]})}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:uu},Symbol.toStringTag,{value:"Module"})),pu=p.object({plan_change_enable:p.boolean().nullable().default(!1),reset_traffic_method:p.coerce.number().nullable().default(0),surplus_enable:p.boolean().nullable().default(!1),new_order_event_id:p.coerce.number().nullable().default(0),renew_order_event_id:p.coerce.number().nullable().default(0),change_order_event_id:p.coerce.number().nullable().default(0),show_info_to_server_enable:p.boolean().nullable().default(!1),show_protocol_to_server_enable:p.boolean().nullable().default(!1),default_remind_expire:p.boolean().nullable().default(!1),default_remind_traffic:p.boolean().nullable().default(!1),subscribe_path:p.string().nullable().default("s")}),xu={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 fu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(pu),defaultValues:xu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","subscribe"],queryFn:()=>us("subscribe")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.subscribe){const i=c?.data?.subscribe;Object.entries(i).forEach(([d,f])=>{r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"plan_change_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(L,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"reset_traffic_method",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(U,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(U,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(U,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(U,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(L,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"surplus_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(L,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"new_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(L,{children:s("subscribe.new_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"renew_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(L,{children:s("renew_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"change_order_event_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:i.onChange,value:i.value?.toString(),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(U,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(L,{children:s("subscribe.change_order_event.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"subscribe_path",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:"subscribe",...i,value:i.value||"",onChange:d=>{i.onChange(d),h(r.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:i.value||"s"})]}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"show_info_to_server_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(L,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"show_protocol_to_server_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(L,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value||!1,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function gu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(ve,{}),e.jsx(fu,{})]})}const ju=Object.freeze(Object.defineProperty({__proto__:null,default:gu},Symbol.toStringTag,{value:"Module"})),bu=p.object({invite_force:p.boolean().default(!1),invite_commission:p.coerce.string().default("0"),invite_gen_limit:p.coerce.string().default("0"),invite_never_expire:p.boolean().default(!1),commission_first_time_enable:p.boolean().default(!1),commission_auto_check_enable:p.boolean().default(!1),commission_withdraw_limit:p.coerce.string().default("0"),commission_withdraw_method:p.array(p.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:p.boolean().default(!1),commission_distribution_enable:p.boolean().default(!1),commission_distribution_l1:p.coerce.number().default(0),commission_distribution_l2:p.coerce.number().default(0),commission_distribution_l3:p.coerce.number().default(0)}),vu={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 yu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(bu),defaultValues:vu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","invite"],queryFn:()=>us("invite")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.invite){const i=c?.data?.invite;Object.entries(i).forEach(([d,f])=>{typeof f=="number"?r.setValue(d,String(f)):r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"invite_force",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(L,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"invite_commission",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.invite_commission.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("invite.invite_commission.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"invite_gen_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.invite_gen_limit.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("invite.invite_gen_limit.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"invite_never_expire",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(L,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_first_time_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(L,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_auto_check_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(L,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_method",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_method.placeholder"),...i,value:Array.isArray(i.value)?i.value.join(","):"",onChange:d=>{const f=d.target.value.split(",").filter(Boolean);i.onChange(f),h(r.getValues())}})}),e.jsx(L,{children:s("invite.commission_withdraw_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"withdraw_close_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(L,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(L,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:d=>{i.onChange(d),h(r.getValues())}})})]})}),r.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"commission_distribution_l1",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:s("invite.commission_distribution.l1")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l2",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:s("invite.commission_distribution.l2")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l3",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:s("invite.commission_distribution.l3")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...i,value:i.value||"",onChange:d=>{const f=d.target.value?Number(d.target.value):0;i.onChange(f),h(r.getValues())}})}),e.jsx(D,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function _u(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ve,{}),e.jsx(yu,{})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"})),wu=p.object({frontend_theme:p.string().nullable(),frontend_theme_sidebar:p.string().nullable(),frontend_theme_header:p.string().nullable(),frontend_theme_color:p.string().nullable(),frontend_background_url:p.string().url().nullable()}),Cu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Su(){const{data:s}=se({queryKey:["settings","frontend"],queryFn:()=>us("frontend")}),n=ce({resolver:ue(wu),defaultValues:Cu,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([r,c])=>{n.setValue(r,c)})}},[s]);function a(l){hs(l).then(({data:r})=>{r&&$.success("更新成功")})}return e.jsx(he,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(j,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:"边栏风格"}),e.jsx(L,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(G,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:"头部风格"}),e.jsx(L,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(G,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(g,{children:[e.jsx(b,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:y(Hs({variant:"outline"}),"w-[200px] appearance-none font-normal"),...l,children:[e.jsx("option",{value:"default",children:"默认"}),e.jsx("option",{value:"black",children:"黑色"}),e.jsx("option",{value:"blackblue",children:"暗蓝色"}),e.jsx("option",{value:"green",children:"奶绿色"})]})}),e.jsx(na,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(L,{children:"主题色"}),e.jsx(D,{})]})}),e.jsx(j,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(g,{children:[e.jsx(b,{children:"背景"}),e.jsx(_,{children:e.jsx(T,{placeholder:"请输入图片地址",...l})}),e.jsx(L,{children:"将会在后台登录页面进行展示。"}),e.jsx(D,{})]})}),e.jsx(R,{type:"submit",children:"保存设置"})]})})}function ku(){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(ve,{}),e.jsx(Su,{})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:ku},Symbol.toStringTag,{value:"Module"})),Tu=p.object({server_pull_interval:p.coerce.number().nullable(),server_push_interval:p.coerce.number().nullable(),server_token:p.string().nullable(),device_limit_mode:p.coerce.number().nullable()}),Du={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Ru(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Tu),defaultValues:Du,mode:"onBlur"}),{data:c}=se({queryKey:["settings","server"],queryFn:()=>us("server")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:d=>{d.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(c?.data.server){const d=c.data.server;Object.entries(d).forEach(([f,P])=>{r.setValue(f,P)}),l.current=d}},[c]);const u=m.useCallback(fe.debounce(async d=>{if(!fe.isEqual(d,l.current)){a(!0);try{await o(d),l.current=d}finally{a(!1)}}},1e3),[o]),h=m.useCallback(d=>{u(d)},[u]);m.useEffect(()=>{const d=r.watch(f=>{h(f)});return()=>d.unsubscribe()},[r.watch,h]);const i=()=>{const d=Math.floor(Math.random()*17)+16,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let P="";for(let E=0;Ee.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.server_token.title")}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:f=>{f.preventDefault(),i()},children:e.jsx(eo,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(te,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(L,{children:s("server.server_token.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:f=>{const P=f.target.value?Number(f.target.value):null;d.onChange(P)}})}),e.jsx(L,{children:s("server.server_pull_interval.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:f=>{const P=f.target.value?Number(f.target.value):null;d.onChange(P)}})}),e.jsx(L,{children:s("server.server_push_interval.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(W,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(U,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(L,{children:s("server.device_limit_mode.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Iu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(ve,{}),e.jsx(Ru,{})]})}const Eu=Object.freeze(Object.defineProperty({__proto__:null,default:Iu},Symbol.toStringTag,{value:"Module"}));function Mu({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Rn,{className:"h-5 w-5 text-destructive"}),e.jsx(je,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Te,{children:l?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:a.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:a.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:a.template_name})]})]}),a.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:a.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(rt,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:a.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:a.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:a.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:a.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:a.config.from.address?`${a.config.from.address}${a.config.from.name?` (${a.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:a.config.username||"未设置"})]})})})]})]})]})})}const Lu=p.object({email_template:p.string().nullable().default("classic"),email_host:p.string().nullable().default(""),email_port:p.coerce.number().nullable().default(465),email_username:p.string().nullable().default(""),email_password:p.string().nullable().default(""),email_encryption:p.string().nullable().default(""),email_from_address:p.string().email().nullable().default(""),remind_mail_enable:p.boolean().nullable().default(!1)});function Ou(){const{t:s}=M("settings"),[n,a]=m.useState(null),[l,r]=m.useState(!1),c=m.useRef(null),[o,u]=m.useState(!1),h=ce({resolver:ue(Lu),defaultValues:{},mode:"onBlur"}),{data:i}=se({queryKey:["settings","email"],queryFn:()=>us("email")}),{data:d}=se({queryKey:["emailTemplate"],queryFn:()=>Mm()}),{mutateAsync:f}=es({mutationFn:hs,onSuccess:k=>{k.data&&$.success(s("common.autoSaved"))}}),{mutate:P,isPending:E}=es({mutationFn:Lm,onMutate:()=>{a(null),r(!1)},onSuccess:k=>{a(k.data),r(!0),k.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(i?.data.email){const k=i.data.email;Object.entries(k).forEach(([v,w])=>{h.setValue(v,w)}),c.current=k}},[i]);const x=m.useCallback(fe.debounce(async k=>{if(!fe.isEqual(k,c.current)){u(!0);try{await f(k),c.current=k}finally{u(!1)}}},1e3),[f]),N=m.useCallback(k=>{x(k)},[x]);return m.useEffect(()=>{const k=h.watch(v=>{N(v)});return()=>k.unsubscribe()},[h.watch,N]),e.jsxs(e.Fragment,{children:[e.jsx(he,{...h,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:h.control,name:"email_host",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_host.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email.email_host.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_port",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_port.title")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:s("common.placeholder"),...k,value:k.value||"",onChange:v=>{const w=v.target.value?Number(v.target.value):null;k.onChange(w)}})}),e.jsx(L,{children:s("email.email_port.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_encryption",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(W,{onValueChange:k.onChange,value:k.value||"none",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(U,{value:"none",children:s("email.email_encryption.none")}),e.jsx(U,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(U,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(L,{children:s("email.email_encryption.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_username",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email.email_username.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email.email_username.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_password",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email_password.title")}),e.jsx(_,{children:e.jsx(T,{type:"password",placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email_password.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_from_address",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email_from.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(L,{children:s("email_from.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"email_template",render:({field:k})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("email_template.title")}),e.jsxs(W,{onValueChange:v=>{k.onChange(v),N(h.getValues())},value:k.value||void 0,children:[e.jsx(_,{children:e.jsx(K,{className:"w-[200px]",children:e.jsx(Y,{placeholder:s("email_template.placeholder")})})}),e.jsx(B,{children:d?.data?.map(v=>e.jsx(U,{value:v,children:v},v))})]}),e.jsx(L,{children:s("email_template.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"remind_mail_enable",render:({field:k})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("remind_mail.title")}),e.jsx(L,{children:s("remind_mail.description")})]}),e.jsx(_,{children:e.jsx(G,{checked:k.value||!1,onCheckedChange:v=>{k.onChange(v),N(h.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{onClick:()=>P(),loading:E,disabled:E,children:s(E?"test.sending":"test.title")})})]})}),o&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Mu,{open:l,onOpenChange:r,result:n})]})}function Vu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(ve,{}),e.jsx(Ou,{})]})}const Au=Object.freeze(Object.defineProperty({__proto__:null,default:Vu},Symbol.toStringTag,{value:"Module"})),Fu=p.object({telegram_bot_enable:p.boolean().nullable(),telegram_bot_token:p.string().nullable(),telegram_discuss_link:p.string().nullable()}),zu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Uu(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Fu),defaultValues:zu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","telegram"],queryFn:()=>us("telegram")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:f=>{f.data&&$.success(s("common.autoSaved"))}}),{mutate:u,isPending:h}=es({mutationFn:Om,onSuccess:f=>{f.data&&$.success(s("telegram.webhook_success"))}});m.useEffect(()=>{if(c?.data.telegram){const f=c.data.telegram;Object.entries(f).forEach(([P,E])=>{r.setValue(P,E)}),l.current=f}},[c]);const i=m.useCallback(fe.debounce(async f=>{if(!fe.isEqual(f,l.current)){a(!0);try{await o(f),l.current=f}finally{a(!1)}}},1e3),[o]),d=m.useCallback(f=>{i(f)},[i]);return m.useEffect(()=>{const f=r.watch(P=>{d(P)});return()=>f.unsubscribe()},[r.watch,d]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"telegram_bot_token",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("telegram.bot_token.placeholder"),...f,value:f.value||""})}),e.jsx(L,{children:s("telegram.bot_token.description")}),e.jsx(D,{})]})}),r.watch("telegram_bot_token")&&e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(R,{loading:h,disabled:h,onClick:()=>u(),children:s(h?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(L,{children:s("telegram.webhook.description")}),e.jsx(D,{})]}),e.jsx(j,{control:r.control,name:"telegram_bot_enable",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(L,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(G,{checked:f.value||!1,onCheckedChange:P=>{f.onChange(P),d(r.getValues())}})}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"telegram_discuss_link",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("telegram.discuss_link.placeholder"),...f,value:f.value||""})}),e.jsx(L,{children:s("telegram.discuss_link.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function $u(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(ve,{}),e.jsx(Uu,{})]})}const Hu=Object.freeze(Object.defineProperty({__proto__:null,default:$u},Symbol.toStringTag,{value:"Module"})),Gu=p.object({windows_version:p.string().nullable(),windows_download_url:p.string().nullable(),macos_version:p.string().nullable(),macos_download_url:p.string().nullable(),android_version:p.string().nullable(),android_download_url:p.string().nullable()}),qu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Ku(){const{t:s}=M("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Gu),defaultValues:qu,mode:"onBlur"}),{data:c}=se({queryKey:["settings","app"],queryFn:()=>us("app")}),{mutateAsync:o}=es({mutationFn:hs,onSuccess:i=>{i.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(c?.data.app){const i=c.data.app;Object.entries(i).forEach(([d,f])=>{r.setValue(d,f)}),l.current=i}},[c]);const u=m.useCallback(fe.debounce(async i=>{if(!fe.isEqual(i,l.current)){a(!0);try{await o(i),l.current=i}finally{a(!1)}}},1e3),[o]),h=m.useCallback(i=>{u(i)},[u]);return m.useEffect(()=>{const i=r.watch(d=>{h(d)});return()=>i.unsubscribe()},[r.watch,h]),e.jsx(he,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"windows_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.windows.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"windows_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.windows.download.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"macos_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.macos.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"macos_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.macos.download.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"android_version",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.android.version.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.android.version.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"android_download_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{className:"text-base",children:s("app.android.download.title")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("common.placeholder"),...i,value:i.value||""})}),e.jsx(L,{children:s("app.android.download.description")}),e.jsx(D,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Bu(){const{t:s}=M("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(ve,{}),e.jsx(Ku,{})]})}const Wu=Object.freeze(Object.defineProperty({__proto__:null,default:Bu},Symbol.toStringTag,{value:"Module"})),da=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:y("w-full caption-bottom text-sm",s),...n})}));da.displayName="Table";const ma=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:y("[&_tr]:border-b",s),...n}));ma.displayName="TableHeader";const ua=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:y("[&_tr:last-child]:border-0",s),...n}));ua.displayName="TableBody";const Yu=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Yu.displayName="TableFooter";const bs=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));bs.displayName="TableRow";const ha=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:y("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));ha.displayName="TableHead";const Us=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:y("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Us.displayName="TableCell";const Ju=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:y("mt-4 text-sm text-muted-foreground",s),...n}));Ju.displayName="TableCaption";function Qu({table:s}){const[n,a]=m.useState("");m.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const l=r=>{const c=parseInt(r);!isNaN(c)&&c>=1&&c<=s.getPageCount()?s.setPageIndex(c-1):a((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex-1 text-sm text-muted-foreground",children:["已选择 ",s.getFilteredSelectedRowModel().rows.length," 项, 共"," ",s.getFilteredRowModel().rows.length," 项"]}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"每页显示"}),e.jsxs(W,{value:`${s.getState().pagination.pageSize}`,onValueChange:r=>{s.setPageSize(Number(r))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(r=>e.jsx(U,{value:`${r}`,children:r},r))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:"第"}),e.jsx(T,{type:"text",value:n,onChange:r=>a(r.target.value),onBlur:r=>l(r.target.value),onKeyDown:r=>{r.key==="Enter"&&l(r.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsxs("span",{children:["页,共 ",s.getPageCount()," 页"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到第一页"}),e.jsx(so,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"上一页"}),e.jsx(Cn,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"下一页"}),e.jsx(aa,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到最后一页"}),e.jsx(to,{className:"h-4 w-4"})]})]})]})]})}function Ye({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:o,onDrop:u,showPagination:h=!0,isLoading:i=!1}){const d=m.useRef(null),f=s.getAllColumns().filter(N=>N.getIsPinned()==="left"),P=s.getAllColumns().filter(N=>N.getIsPinned()==="right"),E=N=>f.slice(0,N).reduce((k,v)=>k+(v.getSize()??0),0),x=N=>P.slice(N+1).reduce((k,v)=>k+(v.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:d,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(da,{children:[e.jsx(ma,{children:s.getHeaderGroups().map(N=>e.jsx(bs,{className:"hover:bg-transparent",children:N.headers.map((k,v)=>{const w=k.column.getIsPinned()==="left",S=k.column.getIsPinned()==="right",C=w?E(f.indexOf(k.column)):void 0,I=S?x(P.indexOf(k.column)):void 0;return e.jsx(ha,{colSpan:k.colSpan,style:{width:k.getSize(),...w&&{left:C},...S&&{right:I}},className:y("h-11 bg-card px-4 text-muted-foreground",(w||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",w&&"before:right-0",S&&"before:left-0"]),children:k.isPlaceholder?null:vt(k.column.columnDef.header,k.getContext())},k.id)})},N.id))}),e.jsx(ua,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((N,k)=>e.jsx(bs,{"data-state":N.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:v=>l?.(v,k),onDragEnd:r,onDragOver:c,onDragLeave:o,onDrop:v=>u?.(v,k),children:N.getVisibleCells().map((v,w)=>{const S=v.column.getIsPinned()==="left",C=v.column.getIsPinned()==="right",I=S?E(f.indexOf(v.column)):void 0,A=C?x(P.indexOf(v.column)):void 0;return e.jsx(Us,{style:{width:v.column.getSize(),...S&&{left:I},...C&&{right:A}},className:y("bg-card",(S||C)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",S&&"before:right-0",C&&"before:left-0"]),children:vt(v.column.columnDef.cell,v.getContext())},v.id)})},N.id)):e.jsx(bs,{children:e.jsx(Us,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:"暂无数据"})})})]})})}),h&&e.jsx(Qu,{table:s})]})}const Zu=s=>p.object({id:p.number().nullable(),name:p.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:p.string().optional().nullable(),notify_domain:p.string().refine(a=>!a||/^https?:\/\/\S+/.test(a),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:p.coerce.number().min(0).optional().nullable(),handling_fee_percent:p.coerce.number().min(0).max(100).optional().nullable(),payment:p.string().min(1,s("form.validation.payment.required")),config:p.record(p.string(),p.string())}),Fa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function vr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Fa}){const{t:r}=M("payment"),[c,o]=m.useState(!1),[u,h]=m.useState(!1),[i,d]=m.useState([]),[f,P]=m.useState([]),E=Zu(r),x=ce({resolver:ue(E),defaultValues:l,mode:"onChange"}),N=x.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:w}=await Zd();d(w)})()},[c]),m.useEffect(()=>{if(!N||!c)return;(async()=>{const w={payment:N,...a==="edit"&&{id:Number(x.getValues("id"))}};Xd(w).then(({data:S})=>{P(S);const C=S.reduce((I,A)=>(A.field_name&&(I[A.field_name]=A.value??""),I),{});x.setValue("config",C)})})()},[N,c,x,a]);const k=async v=>{h(!0);try{(await em(v)).data&&($.success(r("form.messages.success")),x.reset(Fa),s(),o(!1))}finally{h(!1)}};return e.jsxs(ge,{open:c,onOpenChange:o,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(he,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(k),className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"name",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:r("form.fields.name.placeholder"),...v})}),e.jsx(L,{children:r("form.fields.name.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"icon",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.icon.label")}),e.jsx(_,{children:e.jsx(T,{...v,value:v.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(L,{children:r("form.fields.icon.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"notify_domain",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.notify_domain.label")}),e.jsx(_,{children:e.jsx(T,{...v,value:v.value||"",placeholder:r("form.fields.notify_domain.placeholder")})}),e.jsx(L,{children:r("form.fields.notify_domain.description")}),e.jsx(D,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:x.control,name:"handling_fee_percent",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(T,{type:"number",...v,value:v.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"handling_fee_fixed",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(T,{type:"number",...v,value:v.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(D,{})]})})]}),e.jsx(j,{control:x.control,name:"payment",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.payment.label")}),e.jsxs(W,{onValueChange:v.onChange,defaultValue:v.value,children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(B,{children:i.map(w=>e.jsx(U,{value:w,children:w},w))})]}),e.jsx(L,{children:r("form.fields.payment.description")}),e.jsx(D,{})]})}),f.length>0&&e.jsx("div",{className:"space-y-4",children:f.map(v=>e.jsx(j,{control:x.control,name:`config.${v.field_name}`,render:({field:w})=>e.jsxs(g,{children:[e.jsx(b,{children:v.label}),e.jsx(_,{children:e.jsx(T,{...w,value:w.value||""})}),e.jsx(D,{})]})},v.field_name))}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",disabled:u,children:r("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:a,className:l}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(R,{variant:"ghost",size:"default",className:y("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",l),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),a&&e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(Pa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(te,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(qt,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Kt,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ao,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:y("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",l),children:[e.jsx("span",{children:n}),a&&e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(te,{children:a})]})})]})}const Xu=no,eh=ro,sh=lo,yr=m.forwardRef(({className:s,...n},a)=>e.jsx(Mn,{className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:a}));yr.displayName=Mn.displayName;const _r=m.forwardRef(({className:s,...n},a)=>e.jsxs(sh,{children:[e.jsx(yr,{}),e.jsx(Ln,{ref:a,className:y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));_r.displayName=Ln.displayName;const Nr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...n});Nr.displayName="AlertDialogHeader";const wr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});wr.displayName="AlertDialogFooter";const Cr=m.forwardRef(({className:s,...n},a)=>e.jsx(On,{ref:a,className:y("text-lg font-semibold",s),...n}));Cr.displayName=On.displayName;const Sr=m.forwardRef(({className:s,...n},a)=>e.jsx(Vn,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Sr.displayName=Vn.displayName;const kr=m.forwardRef(({className:s,...n},a)=>e.jsx(An,{ref:a,className:y($s(),s),...n}));kr.displayName=An.displayName;const Pr=m.forwardRef(({className:s,...n},a)=>e.jsx(Fn,{ref:a,className:y($s({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Pr.displayName=Fn.displayName;function Je({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:o="default",className:u}){return e.jsxs(Xu,{children:[e.jsx(eh,{asChild:!0,children:n}),e.jsxs(_r,{className:y("sm:max-w-[425px]",u),children:[e.jsxs(Nr,{children:[e.jsx(Cr,{children:a}),e.jsx(Sr,{children:l})]}),e.jsxs(wr,{children:[e.jsx(Pr,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r})}),e.jsx(kr,{asChild:!0,children:e.jsx(R,{variant:o,onClick:s,children:c})})]})]})]})}const Tr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),th=({refetch:s,isSortMode:n=!1})=>{const{t:a}=M("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",children:l.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(G,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await tm({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.name")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:l})=>e.jsx(O,{column:l,title:a("table.columns.payment")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:l})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:l,title:a("table.columns.notify_url")}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{className:"ml-1",children:e.jsx(Tr,{className:"h-4 w-4"})}),e.jsx(te,{children:a("table.columns.notify_url_tooltip")})]})})]}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:l.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:l})=>e.jsx(O,{className:"justify-end",column:l,title:a("table.columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(vr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("table.actions.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await sm({id:l.original.id});r&&s()},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:a("table.actions.delete.title")})]})})]}),size:100}]};function ah({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=M("payment"),c=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:r("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vr,{refetch:n}),e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:o=>s.getColumn("name")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),c&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function nh(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[o,u]=m.useState([]),[h,i]=m.useState({"drag-handle":!1}),[d,f]=m.useState({pageSize:20,pageIndex:0}),{refetch:P}=se({queryKey:["paymentList"],queryFn:async()=>{const{data:v}=await Qd();return u(v?.map(w=>({...w,enable:!!w.enable}))||[]),v}});m.useEffect(()=>{i({"drag-handle":r,actions:!r}),f({pageSize:r?99999:10,pageIndex:0})},[r]);const E=(v,w)=>{r&&(v.dataTransfer.setData("text/plain",w.toString()),v.currentTarget.classList.add("opacity-50"))},x=(v,w)=>{if(!r)return;v.preventDefault(),v.currentTarget.classList.remove("bg-muted");const S=parseInt(v.dataTransfer.getData("text/plain"));if(S===w)return;const C=[...o],[I]=C.splice(S,1);C.splice(w,0,I),u(C)},N=async()=>{r?am({ids:o.map(v=>v.id)}).then(()=>{P(),c(!1),$.success("排序保存成功")}):c(!0)},k=Ae({data:o,columns:th({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:h,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:i,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(Ye,{table:k,toolbar:v=>e.jsx(ah,{table:v,refetch:P,saveOrder:N,isSortMode:r}),draggable:r,onDragStart:E,onDragEnd:v=>v.currentTarget.classList.remove("opacity-50"),onDragOver:v=>{v.preventDefault(),v.currentTarget.classList.add("bg-muted")},onDragLeave:v=>v.currentTarget.classList.remove("bg-muted"),onDrop:x,showPagination:!r})}function rh(){const{t:s}=M("payment");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(nh,{})})]})]})}const lh=Object.freeze(Object.defineProperty({__proto__:null,default:rh},Symbol.toStringTag,{value:"Module"})),ih=(s,n)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(T,{placeholder:s.placeholder,...n});break;case"textarea":a=e.jsx(Cs,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:y($s({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:a=null;break}return a};function oh({themeKey:s,themeInfo:n}){const{t:a}=M("theme"),[l,r]=m.useState(!1),[c,o]=m.useState(!1),[u,h]=m.useState(!1),i=ce({defaultValues:n.configs.reduce((P,E)=>(P[E.field_name]="",P),{})}),d=async()=>{o(!0),Vd(s).then(({data:P})=>{Object.entries(P).forEach(([E,x])=>{i.setValue(E,x)})}).finally(()=>{o(!1)})},f=async P=>{h(!0),Ad(s,P).then(()=>{$.success(a("config.success")),r(!1)}).finally(()=>{h(!1)})};return e.jsxs(ge,{open:l,onOpenChange:P=>{r(P),P?d():i.reset()},children:[e.jsx(Le,{asChild:!0,children:e.jsx(R,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(pe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:a("config.title",{name:n.name})}),e.jsx(Te,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ra,{className:"h-6 w-6 animate-spin"})}):e.jsx(he,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(f),className:"space-y-4",children:[n.configs.map(P=>e.jsx(j,{control:i.control,name:P.field_name,render:({field:E})=>e.jsxs(g,{children:[e.jsx(b,{children:P.label}),e.jsx(_,{children:ih(P,E)}),e.jsx(D,{})]})},P.field_name)),e.jsxs(Oe,{className:"mt-6 gap-2",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(R,{type:"submit",loading:u,children:a("config.save")})]})]})})]})]})}function ch(){const{t:s}=M("theme"),[n,a]=m.useState(null),[l,r]=m.useState(!1),[c,o]=m.useState(!1),[u,h]=m.useState(!1),[i,d]=m.useState(null),f=m.useRef(null),[P,E]=m.useState(0),{data:x,isLoading:N,refetch:k}=se({queryKey:["themeList"],queryFn:async()=>{const{data:z}=await Od();return z}}),v=async z=>{a(z),Ud({frontend_theme:z}).then(()=>{$.success("主题切换成功"),k()}).finally(()=>{a(null)})},w=async z=>{if(!z.name.endsWith(".zip")){$.error(s("upload.error.format"));return}r(!0),Fd(z).then(()=>{$.success("主题上传成功"),o(!1),k()}).finally(()=>{r(!1),f.current&&(f.current.value="")})},S=z=>{z.preventDefault(),z.stopPropagation(),z.type==="dragenter"||z.type==="dragover"?h(!0):z.type==="dragleave"&&h(!1)},C=z=>{z.preventDefault(),z.stopPropagation(),h(!1),z.dataTransfer.files&&z.dataTransfer.files[0]&&w(z.dataTransfer.files[0])},I=()=>{i&&E(z=>z===0?i.images.length-1:z-1)},A=()=>{i&&E(z=>z===i.images.length-1?0:z+1)},Z=(z,X)=>{E(0),d({name:z,images:X})};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(R,{onClick:()=>o(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:N?e.jsxs(e.Fragment,{children:[e.jsx(za,{}),e.jsx(za,{})]}):x?.themes&&Object.entries(x.themes).map(([z,X])=>e.jsx(Ge,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:X.background_url?`url(${X.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:y("relative z-10 h-full transition-colors",X.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!X.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Je,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(z===x?.active){$.error(s("card.delete.error.active"));return}a(z),zd(z).then(()=>{$.success("主题删除成功"),k()}).finally(()=>{a(null)})},children:e.jsx(R,{disabled:n===z,loading:n===z,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(ss,{children:[e.jsx(vs,{children:X.name}),e.jsx(tt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:X.description}),X.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:X.version})})]})})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(X.name,X.images),children:e.jsx(io,{className:"h-4 w-4"})}),e.jsx(oh,{themeKey:z,themeInfo:X}),e.jsx(R,{onClick:()=>v(z),disabled:n===z||z===x.active,loading:n===z,variant:z===x.active?"secondary":"default",children:z===x.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},z))}),e.jsx(ge,{open:c,onOpenChange:o,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsxs(be,{children:[e.jsx(je,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:y("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",u&&"border-primary/50 bg-muted/50"),onDragEnter:S,onDragLeave:S,onDragOver:S,onDrop:C,children:[e.jsx("input",{type:"file",ref:f,className:"hidden",accept:".zip",onChange:z=>{const X=z.target.files?.[0];X&&w(X)}}),l?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(Gt,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>f.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(ge,{open:!!i,onOpenChange:z=>{z||(d(null),E(0))},children:e.jsxs(pe,{className:"max-w-4xl",children:[e.jsxs(be,{children:[e.jsxs(je,{children:[i?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:i&&s("preview.imageCount",{current:P+1,total:i.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:i?.images[P]&&e.jsx("img",{src:i.images[P],alt:`${i.name} 预览图 ${P+1}`,className:"h-full w-full object-contain"})}),i&&i.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:I,children:e.jsx(oo,{className:"h-4 w-4"})}),e.jsx(R,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:A,children:e.jsx(co,{className:"h-4 w-4"})})]})]}),i&&i.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:i.images.map((z,X)=>e.jsx("button",{onClick:()=>E(X),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",P===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:z,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function za(){return e.jsxs(Ge,{children:[e.jsxs(ss,{children:[e.jsx(Ee,{className:"h-6 w-[200px]"}),e.jsx(Ee,{className:"h-4 w-[300px]"})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[e.jsx(Ee,{className:"h-10 w-[100px]"}),e.jsx(Ee,{className:"h-10 w-[100px]"})]})]})}const dh=Object.freeze(Object.defineProperty({__proto__:null,default:ch},Symbol.toStringTag,{value:"Module"})),pa=m.forwardRef(({className:s,value:n,onChange:a,...l},r)=>{const[c,o]=m.useState("");m.useEffect(()=>{if(c.includes(",")){const h=new Set([...n,...c.split(",").map(i=>i.trim())]);a(Array.from(h)),o("")}},[c,a,n]);const u=()=>{if(c){const h=new Set([...n,c]);a(Array.from(h)),o("")}};return e.jsxs("div",{className:y(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(h=>e.jsxs(H,{variant:"secondary",children:[h,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(n.filter(i=>i!==h))},children:e.jsx(Bt,{className:"w-3"})})]},h)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:c,onChange:h=>o(h.target.value),onKeyDown:h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),u()):h.key==="Backspace"&&c.length===0&&n.length>0&&(h.preventDefault(),a(n.slice(0,-1)))},...l,ref:r})]})});pa.displayName="InputTags";const mh=p.object({id:p.number().nullable(),title:p.string().min(1).max(250),content:p.string().min(1),show:p.boolean(),tags:p.array(p.string()),img_url:p.string().nullable()}),uh={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Dr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=uh}){const{t:r}=M("notice"),[c,o]=m.useState(!1),u=ce({resolver:ue(mh),defaultValues:l,mode:"onChange",shouldFocusError:!0}),h=new la({html:!0});return e.jsx(he,{...u,children:e.jsxs(ge,{onOpenChange:o,open:c,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(j,{control:u.control,name:"title",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.fields.title.placeholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"content",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.content.label")}),e.jsx(_,{children:e.jsx(ia,{style:{height:"500px"},value:i.value,renderHTML:d=>h.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"img_url",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...i,value:i.value||""})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"tags",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(pa,{value:i.value,onChange:i.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",onClick:i=>{i.preventDefault(),u.handleSubmit(async d=>{rm(d).then(({data:f})=>{f&&($.success(r("form.buttons.success")),s(),o(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function hh({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=M("notice"),c=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!l&&e.jsx(Dr,{refetch:n}),!l&&e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),c&&!l&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const ph=s=>{const{t:n}=M("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(mo,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(H,{variant:"outline",className:"font-mono",children:a.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(G,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{const{data:l}=await im({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.title")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:a.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Dr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:a.original}),e.jsx(Je,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{lm({id:a.original.id}).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function xh(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),[h,i]=m.useState(!1),[d,f]=m.useState({}),[P,E]=m.useState({pageSize:50,pageIndex:0}),[x,N]=m.useState([]),{refetch:k}=se({queryKey:["notices"],queryFn:async()=>{const{data:I}=await nm();return N(I),I}});m.useEffect(()=>{l({"drag-handle":h,content:!h,created_at:!h,actions:!h}),E({pageSize:h?99999:50,pageIndex:0})},[h]);const v=(I,A)=>{h&&(I.dataTransfer.setData("text/plain",A.toString()),I.currentTarget.classList.add("opacity-50"))},w=(I,A)=>{if(!h)return;I.preventDefault(),I.currentTarget.classList.remove("bg-muted");const Z=parseInt(I.dataTransfer.getData("text/plain"));if(Z===A)return;const z=[...x],[X]=z.splice(Z,1);z.splice(A,0,X),N(z)},S=async()=>{if(!h){i(!0);return}Vm(x.map(I=>I.id)).then(()=>{$.success("排序保存成功"),i(!1),k()}).finally(()=>{i(!1)})},C=Ae({data:x??[],columns:ph(k),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:P},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:f,onPaginationChange:E,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:C,toolbar:I=>e.jsx(hh,{table:I,refetch:k,saveOrder:S,isSortMode:h}),draggable:h,onDragStart:v,onDragEnd:I=>I.currentTarget.classList.remove("opacity-50"),onDragOver:I=>{I.preventDefault(),I.currentTarget.classList.add("bg-muted")},onDragLeave:I=>I.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!h})})}function fh(){const{t:s}=M("notice");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(De,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(xh,{})})]})]})}const gh=Object.freeze(Object.defineProperty({__proto__:null,default:fh},Symbol.toStringTag,{value:"Module"})),jh=p.object({id:p.number().nullable(),language:p.string().max(250),category:p.string().max(250),title:p.string().min(1).max(250),body:p.string().min(1),show:p.boolean()}),bh={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Rr({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=bh}){const{t:r}=M("knowledge"),[c,o]=m.useState(!1),u=ce({resolver:ue(jh),defaultValues:l,mode:"onChange",shouldFocusError:!0}),h=new la({html:!0});return m.useEffect(()=>{c&&l.id&&cm(l.id).then(({data:i})=>{u.reset(i)})},[l.id,u,c]),e.jsxs(ge,{onOpenChange:o,open:c,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(he,{...u,children:[e.jsx(j,{control:u.control,name:"title",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.titlePlaceholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"category",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(T,{placeholder:r("form.categoryPlaceholder"),...i})})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"language",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.language")}),e.jsx(_,{children:e.jsxs(W,{value:i.value,onValueChange:i.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx(U,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(j,{control:u.control,name:"body",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.content")}),e.jsx(_,{children:e.jsx(ia,{style:{height:"500px"},value:i.value,renderHTML:d=>h.render(d),onChange:({text:d})=>{i.onChange(d)}})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(G,{checked:i.value,onCheckedChange:i.onChange})})}),e.jsx(D,{})]})}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{u.handleSubmit(i=>{dm(i).then(({data:d})=>{d&&(u.reset(),$.success(r("messages.operationSuccess")),o(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function vh({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Es,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function yh({table:s,refetch:n,saveOrder:a,isSortMode:l}){const r=s.getState().columnFilters.length>0,{t:c}=M("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{refreshData:n}),e.jsx(T,{placeholder:c("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:o=>s.getColumn("title")?.setFilterValue(o.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(vh,{column:s.getColumn("category"),title:c("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(o=>o.getValue("category")))).map(o=>({label:o,value:o}))}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const _h=({refetch:s,isSortMode:n=!1})=>{const{t:a}=M("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",className:"justify-center",children:l.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(G,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{um({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.title")}),cell:({row:l})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:l.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.category")}),cell:({row:l})=>e.jsx(H,{variant:"secondary",className:"max-w-[180px] truncate",children:l.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:l})=>e.jsx(O,{className:"justify-end",column:l,title:a("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Rr,{refreshData:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("form.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{mm({id:l.original.id}).then(({data:r})=>{r&&($.success(a("messages.operationSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:a("messages.deleteButton")})]})})]}),size:100}]};function Nh(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[o,u]=m.useState([]),[h,i]=m.useState({"drag-handle":!1}),[d,f]=m.useState({pageSize:20,pageIndex:0}),{refetch:P,isLoading:E,data:x}=se({queryKey:["knowledge"],queryFn:async()=>{const{data:S}=await om();return u(S||[]),S}});m.useEffect(()=>{i({"drag-handle":r,actions:!r}),f({pageSize:r?99999:10,pageIndex:0})},[r]);const N=(S,C)=>{r&&(S.dataTransfer.setData("text/plain",C.toString()),S.currentTarget.classList.add("opacity-50"))},k=(S,C)=>{if(!r)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const I=parseInt(S.dataTransfer.getData("text/plain"));if(I===C)return;const A=[...o],[Z]=A.splice(I,1);A.splice(C,0,Z),u(A)},v=async()=>{r?hm({ids:o.map(S=>S.id)}).then(()=>{P(),c(!1),$.success("排序保存成功")}):c(!0)},w=Ae({data:o,columns:_h({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:h,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:i,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:w,toolbar:S=>e.jsx(yh,{table:S,refetch:P,saveOrder:v,isSortMode:r}),draggable:r,onDragStart:N,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!r})}function wh(){const{t:s}=M("knowledge");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Nh,{})})]})]})}const Ch=Object.freeze(Object.defineProperty({__proto__:null,default:wh},Symbol.toStringTag,{value:"Module"}));function Sh(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function zt(s,n){if(s.length===0)return{};if(!n)return{"":s};const a={};return s.forEach(l=>{const r=l[n]||"";a[r]||(a[r]=[]),a[r].push(l)}),a}function kh(s,n){const a=JSON.parse(JSON.stringify(s));for(const[l,r]of Object.entries(a))a[l]=r.filter(c=>!n.find(o=>o.value===c.value));return a}function Ph(s,n){for(const[,a]of Object.entries(s))if(a.some(l=>n.find(r=>r.value===l.value)))return!0;return!1}const Ir=m.forwardRef(({className:s,...n},a)=>uo(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Ir.displayName="CommandEmpty";const lt=m.forwardRef(({value:s,onChange:n,placeholder:a,defaultOptions:l=[],options:r,delay:c,onSearch:o,loadingIndicator:u,emptyIndicator:h,maxSelected:i=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:f,disabled:P,groupBy:E,className:x,badgeClassName:N,selectFirstItem:k=!0,creatable:v=!1,triggerSearchOnFocus:w=!1,commandProps:S,inputProps:C,hideClearAllButton:I=!1},A)=>{const Z=m.useRef(null),[z,X]=m.useState(!1),qs=m.useRef(!1),[va,ya]=m.useState(!1),[ee,Ks]=m.useState(s||[]),[Ss,_a]=m.useState(zt(l,E)),[ps,Ot]=m.useState(""),Bs=Sh(ps,c||500);m.useImperativeHandle(A,()=>({selectedValue:[...ee],input:Z.current,focus:()=>Z.current?.focus()}),[ee]);const mt=m.useCallback(q=>{const ae=ee.filter(Pe=>Pe.value!==q.value);Ks(ae),n?.(ae)},[n,ee]),sl=m.useCallback(q=>{const ae=Z.current;ae&&((q.key==="Delete"||q.key==="Backspace")&&ae.value===""&&ee.length>0&&(ee[ee.length-1].fixed||mt(ee[ee.length-1])),q.key==="Escape"&&ae.blur())},[mt,ee]);m.useEffect(()=>{s&&Ks(s)},[s]),m.useEffect(()=>{if(!r||o)return;const q=zt(r||[],E);JSON.stringify(q)!==JSON.stringify(Ss)&&_a(q)},[l,r,E,o,Ss]),m.useEffect(()=>{const q=async()=>{ya(!0);const Pe=await o?.(Bs);_a(zt(Pe||[],E)),ya(!1)};(async()=>{!o||!z||(w&&await q(),Bs&&await q())})()},[Bs,E,z,w]);const tl=()=>{if(!v||Ph(Ss,[{value:ps,label:ps}])||ee.find(ae=>ae.value===ps))return;const q=e.jsx(Ne,{value:ps,className:"cursor-pointer",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onSelect:ae=>{if(ee.length>=i){d?.(ee.length);return}Ot("");const Pe=[...ee,{value:ae,label:ae}];Ks(Pe),n?.(Pe)},children:`Create "${ps}"`});if(!o&&ps.length>0||o&&Bs.length>0&&!va)return q},al=m.useCallback(()=>{if(h)return o&&!v&&Object.keys(Ss).length===0?e.jsx(Ne,{value:"-",disabled:!0,children:h}):e.jsx(Ir,{children:h})},[v,h,o,Ss]),nl=m.useMemo(()=>kh(Ss,ee),[Ss,ee]),rl=m.useCallback(()=>{if(S?.filter)return S.filter;if(v)return(q,ae)=>q.toLowerCase().includes(ae.toLowerCase())?1:-1},[v,S?.filter]),ll=m.useCallback(()=>{const q=ee.filter(ae=>ae.fixed);Ks(q),n?.(q)},[n,ee]);return e.jsxs(Ns,{...S,onKeyDown:q=>{sl(q),S?.onKeyDown?.(q)},className:y("h-auto overflow-visible bg-transparent",S?.className),shouldFilter:S?.shouldFilter!==void 0?S.shouldFilter:!o,filter:rl(),children:[e.jsx("div",{className:y("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":ee.length!==0,"cursor-text":!P&&ee.length!==0},x),onClick:()=>{P||Z.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(q=>e.jsxs(H,{className:y("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",N),"data-fixed":q.fixed,"data-disabled":P||void 0,children:[q.label,e.jsx("button",{className:y("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(P||q.fixed)&&"hidden"),onKeyDown:ae=>{ae.key==="Enter"&&mt(q)},onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:()=>mt(q),children:e.jsx(Bt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},q.value)),e.jsx(Se.Input,{...C,ref:Z,value:ps,disabled:P,onValueChange:q=>{Ot(q),C?.onValueChange?.(q)},onBlur:q=>{qs.current===!1&&X(!1),C?.onBlur?.(q)},onFocus:q=>{X(!0),w&&o?.(Bs),C?.onFocus?.(q)},placeholder:f&&ee.length!==0?"":a,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":f,"px-3 py-2":ee.length===0,"ml-1":ee.length!==0},C?.className)}),e.jsx("button",{type:"button",onClick:ll,className:y((I||P||ee.length<1||ee.filter(q=>q.fixed).length===ee.length)&&"hidden"),children:e.jsx(Bt,{})})]})}),e.jsx("div",{className:"relative",children:z&&e.jsx(ws,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{qs.current=!1},onMouseEnter:()=>{qs.current=!0},onMouseUp:()=>{Z.current?.focus()},children:va?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[al(),tl(),!k&&e.jsx(Ne,{value:"-",className:"hidden"}),Object.entries(nl).map(([q,ae])=>e.jsx(Me,{heading:q,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ae.map(Pe=>e.jsx(Ne,{value:Pe.value,disabled:Pe.disable,onMouseDown:Ws=>{Ws.preventDefault(),Ws.stopPropagation()},onSelect:()=>{if(ee.length>=i){d?.(ee.length);return}Ot("");const Ws=[...ee,Pe];Ks(Ws),n?.(Ws)},className:y("cursor-pointer",Pe.disable&&"cursor-default text-muted-foreground"),children:Pe.label},Pe.value))})},q))]})})})]})});lt.displayName="MultipleSelector";const Th=s=>p.object({id:p.number().optional(),name:p.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 Lt({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=M("group"),c=ce({resolver:ue(Th(r)),defaultValues:a,mode:"onChange"}),[o,u]=m.useState(!1),[h,i]=m.useState(!1),d=async f=>{i(!0),Bd(f).then(()=>{$.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{i(!1)})};return e.jsxs(ge,{open:o,onOpenChange:u,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(he,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(j,{control:c.control,name:"name",render:({field:f})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.name")}),e.jsx(_,{children:e.jsx(T,{placeholder:r("form.namePlaceholder"),...f,className:"w-full"})}),e.jsx(L,{children:r("form.nameDescription")}),e.jsx(D,{})]})}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(R,{type:"submit",disabled:h||!c.formState.isValid,children:[h&&e.jsx(ra,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Er=m.createContext(void 0);function Dh({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[o,u]=m.useState(ye.Shadowsocks);return e.jsx(Er.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:o,setServerType:u,refetch:n},children:s})}function Mr(){const s=m.useContext(Er);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Ut({dialogTrigger:s,value:n,setValue:a,templateType:l}){const{t:r}=M("server");m.useEffect(()=>{console.log(n)},[n]);const[c,o]=m.useState(!1),[u,h]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[i,d]=m.useState(null),f=v=>{if(!v)return null;try{const w=JSON.parse(v);return typeof w!="object"||w===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},P={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}}},E=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},x=()=>{const v=f(u||"");if(v){$.error(v);return}try{if(!u){a(null),o(!1);return}a(JSON.parse(u)),o(!1)}catch{$.error(r("network_settings.errors.save_failed"))}},N=v=>{h(v),d(f(v))},k=v=>{const w=P[v];if(w){const S=JSON.stringify(w.content,null,2);h(S),d(null)}};return m.useEffect(()=>{c&&console.log(n)},[c,n]),m.useEffect(()=>{c&&n&&Object.keys(n).length>0&&h(JSON.stringify(n,null,2))},[c,n]),e.jsxs(ge,{open:c,onOpenChange:v=>{!v&&c&&x(),o(v)},children:[e.jsx(Le,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:r("network_settings.edit_protocol")})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(je,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[E().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:E().map(v=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>k(v),children:r("network_settings.use_template",{template:P[v].label})},v))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Cs,{className:`min-h-[200px] font-mono text-sm ${i?"border-red-500 focus-visible:ring-red-500":""}`,value:u,placeholder:E().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:v=>N(v.target.value)}),i&&e.jsx("p",{className:"text-sm text-red-500",children:i})]})]}),e.jsxs(Oe,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>o(!1),children:r("common.cancel")}),e.jsx(J,{onClick:x,disabled:!!i,children:r("common.confirm")})]})]})]})}function Dx(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 Rh={},Ih=Object.freeze(Object.defineProperty({__proto__:null,default:Rh},Symbol.toStringTag,{value:"Module"})),Rx=So(Ih),Ua=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Eh=()=>{try{const s=ho.box.keyPair(),n=Ua(Ta.encodeBase64(s.secretKey)),a=Ua(Ta.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Mh=()=>{try{return Eh()}catch(s){throw console.error("Error generating key pair:",s),s}},Lh=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("").substring(0,s)},Oh=()=>{const s=Math.floor(Math.random()*8)*2+2;return Lh(s)},Vh=p.object({cipher:p.string().default("aes-128-gcm"),obfs:p.string().default("0"),obfs_settings:p.object({path:p.string().default(""),host:p.string().default("")}).default({})}),Ah=p.object({tls:p.coerce.number().default(0),tls_settings:p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1)}).default({}),network:p.string().default("tcp"),network_settings:p.record(p.any()).default({})}),Fh=p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1),network:p.string().default("tcp"),network_settings:p.record(p.any()).default({})}),zh=p.object({version:p.coerce.number().default(2),alpn:p.string().default("h2"),obfs:p.object({open:p.coerce.boolean().default(!1),type:p.string().default("salamander"),password:p.string().default("")}).default({}),tls:p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1)}).default({}),bandwidth:p.object({up:p.string().default(""),down:p.string().default("")}).default({})}),Uh=p.object({tls:p.coerce.number().default(0),tls_settings:p.object({server_name:p.string().default(""),allow_insecure:p.boolean().default(!1)}).default({}),reality_settings:p.object({server_port:p.coerce.number().default(443),server_name:p.string().default(""),allow_insecure:p.boolean().default(!1),public_key:p.string().default(""),private_key:p.string().default(""),short_id:p.string().default("")}).default({}),network:p.string().default("tcp"),network_settings:p.record(p.any()).default({}),flow:p.string().default("")}),rs={shadowsocks:{schema:Vh,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]},vmess:{schema:Ah,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Fh,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:zh,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Uh,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]}},$h=({serverType:s,value:n,onChange:a})=>{const{t:l}=M("server"),r=s?rs[s]:null,c=r?.schema||p.record(p.any()),o=s?c.parse({}):{},u=ce({resolver:ue(c),defaultValues:o,mode:"onChange"});if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const x=c.parse({});u.reset(x)}}else u.reset(n)},[s,n,a,u,c]),m.useEffect(()=>{const x=u.watch(N=>{a(N)});return()=>x.unsubscribe()},[u,a]),!s||!r)return null;const E={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"cipher",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.shadowsocks.ciphers.map(N=>e.jsx(U,{value:N,children:N},N))})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(xs,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(U,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs_settings.path",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...x})}),e.jsx(D,{})]})}),e.jsx(j,{control:u.control,name:"obfs_settings.host",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.host"),...x})}),e.jsx(D,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value?.toString(),onValueChange:N=>x.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(U,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value,onCheckedChange:x.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:x})=>e.jsxs(g,{children:[e.jsxs(b,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Ut,{value:u.watch("network_settings"),setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.vmess.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...x,value:x.value||""})})]})}),e.jsx(j,{control:u.control,name:"allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value||!1,onCheckedChange:x.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:x})=>e.jsxs(g,{children:[e.jsxs(b,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Ut,{value:u.watch("network_settings")||{},setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value||"tcp",children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.trojan.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"version",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(W,{value:(x.value||2).toString(),onValueChange:N=>x.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.hysteria.versions.map(N=>e.jsxs(U,{value:N,className:"cursor-pointer",children:["V",N]},N))})})]})})]})}),u.watch("version")==1&&e.jsx(j,{control:u.control,name:"alpn",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value||"h2",onValueChange:x.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.hysteria.alpnOptions.map(N=>e.jsx(U,{value:N,children:N},N))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs.open",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value||!1,onCheckedChange:x.onChange})})})]})}),!!u.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[u.watch("version")=="2"&&e.jsx(j,{control:u.control,name:"obfs.type",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value||"salamander",onValueChange:x.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:e.jsx(U,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs.password",render:({field:x})=>e.jsxs(g,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...x,value:x.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",k=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(v=>N[v%N.length]).join("");u.setValue("obfs.password",k),$.success(l("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(_e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...x,value:x.value||""})})]})}),e.jsx(j,{control:u.control,name:"tls.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value||!1,onCheckedChange:x.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"bandwidth.up",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(u.watch("version")==2?l("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...x,value:x.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(j,{control:u.control,name:"bandwidth.down",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(u.watch("version")==2?l("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...x,value:x.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(W,{value:x.value?.toString(),onValueChange:N=>x.onChange(Number(N)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(U,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(U,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value,onCheckedChange:x.onChange})})})]})})]}),u.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"reality_settings.server_name",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.server_port",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...x})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.allow_insecure",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(G,{checked:x.value,onCheckedChange:x.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(j,{control:u.control,name:"reality_settings.private_key",render:({field:x})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{...x,className:"pr-9"})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const N=Mh();u.setValue("reality_settings.private_key",N.privateKey),u.setValue("reality_settings.public_key",N.publicKey),$.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(l("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(_e,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(j,{control:u.control,name:"reality_settings.public_key",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(T,{...x})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.short_id",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(T,{...x,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const N=Oh();u.setValue("reality_settings.short_id",N),$.success(l("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(_e,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(L,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:x})=>e.jsxs(g,{children:[e.jsxs(b,{children:[l("dynamic_form.vless.network.label"),e.jsx(Ut,{value:u.watch("network_settings"),setValue:N=>u.setValue("network_settings",N),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,value:x.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(xs,{children:rs.vless.networkOptions.map(N=>e.jsx(U,{value:N.value,className:"cursor-pointer",children:N.label},N.value))})})]})})]})}),e.jsx(j,{control:u.control,name:"flow",render:({field:x})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(W,{onValueChange:N=>x.onChange(N==="none"?null:N),value:x.value||"none",children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:rs.vless.flowOptions.map(N=>e.jsx(U,{value:N,children:N},N))})]})})]})})]})};return e.jsx(oe,{children:E[s]?.()})},Hh=p.object({id:p.number().optional().nullable(),code:p.string().optional(),name:p.string().min(1,"form.name.error"),rate:p.string().min(1,"form.rate.error"),tags:p.array(p.string()).default([]),excludes:p.array(p.string()).default([]),ips:p.array(p.string()).default([]),group_ids:p.array(p.string()).default([]),host:p.string().min(1,"form.host.error"),port:p.string().min(1,"form.port.error"),server_port:p.string().min(1,"form.server_port.error"),parent_id:p.string().default("0").nullable(),route_ids:p.array(p.string()).default([]),protocol_settings:p.record(p.any()).default({}).nullable()}),pt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Gh(){const{t:s}=M("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:o,refetch:u}=Mr(),[h,i]=m.useState([]),[d,f]=m.useState([]),[P,E]=m.useState([]),x=ce({resolver:ue(Hh),defaultValues:pt,mode:"onChange"});m.useEffect(()=>{N()},[n]),m.useEffect(()=>{l?.type&&l.type!==c&&o(l.type)},[l,c,o]),m.useEffect(()=>{l?l.type===c&&x.reset({...pt,...l}):x.reset({...pt,protocol_settings:rs[c].schema.parse({})})},[l,x,c]);const N=async()=>{if(!n)return;const[C,I,A]=await Promise.all([Mt(),xr(),pr()]);i(C.data?.map(Z=>({label:Z.name,value:Z.id.toString()}))||[]),f(I.data?.map(Z=>({label:Z.remarks,value:Z.id.toString()}))||[]),E(A.data||[])},k=m.useMemo(()=>P?.filter(C=>(C.parent_id===0||C.parent_id===null)&&C.type===c&&C.id!==x.watch("id")),[c,P,x]),v=()=>e.jsxs(ys,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(is,{align:"start",children:e.jsx(hd,{children:Ps.map(({type:C,label:I})=>e.jsx(xe,{onClick:()=>{o(C),a(!0)},className:"cursor-pointer",children:e.jsx(H,{variant:"outline",className:"text-white",style:{background:ls[C]},children:I})},C))})})]}),w=()=>{a(!1),r(null),x.reset(pt)},S=async()=>{const C=x.getValues();(await $d({...C,type:c})).data&&(w(),$.success(s("form.success")),u())};return e.jsxs(ge,{open:n,onOpenChange:w,children:[v(),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(he,{...x,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:x.control,name:"name",render:({field:C})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:s("form.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.name.placeholder"),...C})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"rate",render:({field:C})=>e.jsxs(g,{className:"flex-[1]",children:[e.jsx(b,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(_,{children:e.jsx(T,{type:"number",min:"0",step:"0.1",...C})})}),e.jsx(D,{})]})})]}),e.jsx(j,{control:x.control,name:"code",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(b,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.code.placeholder"),...C,value:C.value||""})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"tags",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(pa,{value:C.value,onChange:C.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"group_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(b,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Lt,{dialogTrigger:e.jsx(R,{variant:"link",children:s("form.groups.add")}),refetch:N})]}),e.jsx(_,{children:e.jsx(lt,{options:h,onChange:I=>C.onChange(I.map(A=>A.value)),value:h?.filter(I=>C.value.includes(I.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"host",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.host.placeholder"),...C})}),e.jsx(D,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{control:x.control,name:"port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(_e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_,{children:e.jsx(T,{placeholder:s("form.port.placeholder"),...C})}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const I=C.value;I&&x.setValue("server_port",I)},children:e.jsx(_e,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(te,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"server_port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(_e,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(_,{children:e.jsx(T,{placeholder:s("form.server_port.placeholder"),...C})}),e.jsx(D,{})]})})]})]}),n&&e.jsx($h,{serverType:c,value:x.watch("protocol_settings"),onChange:C=>x.setValue("protocol_settings",C,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(j,{control:x.control,name:"parent_id",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.parent.label")}),e.jsxs(W,{onValueChange:C.onChange,value:C.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:s("form.parent.none")}),k?.map(I=>e.jsx(U,{value:I.id.toString(),className:"cursor-pointer",children:I.name},I.id))]})]}),e.jsx(D,{})]})}),e.jsx(j,{control:x.control,name:"route_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsx(b,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(lt,{options:d,onChange:I=>C.onChange(I.map(A=>A.value)),value:d?.filter(I=>C.value.includes(I.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(D,{})]})})]}),e.jsxs(Oe,{className:"mt-6",children:[e.jsx(R,{type:"button",variant:"outline",onClick:w,children:s("form.cancel")}),e.jsx(R,{type:"submit",onClick:S,children:s("form.submit")})]})]})]})]})}function $a({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Es,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${c.color}`}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const qh=[{value:ye.Shadowsocks,label:Ps.find(s=>s.type===ye.Shadowsocks)?.label,color:ls[ye.Shadowsocks]},{value:ye.Vmess,label:Ps.find(s=>s.type===ye.Vmess)?.label,color:ls[ye.Vmess]},{value:ye.Trojan,label:Ps.find(s=>s.type===ye.Trojan)?.label,color:ls[ye.Trojan]},{value:ye.Hysteria,label:Ps.find(s=>s.type===ye.Hysteria)?.label,color:ls[ye.Hysteria]},{value:ye.Vless,label:Ps.find(s=>s.type===ye.Vless)?.label,color:ls[ye.Vless]}];function Kh({table:s,saveOrder:n,isSortMode:a,groups:l}){const r=s.getState().columnFilters.length>0,{t:c}=M("server"),o=l.map(u=>({label:u,value:u}));return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!a&&e.jsxs(e.Fragment,{children:[e.jsx(Gh,{}),e.jsx(T,{placeholder:c("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:u=>s.getColumn("name")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx($a,{column:s.getColumn("type"),title:c("toolbar.type"),options:qh}),s.getColumn("groups")&&e.jsx($a,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:o})]}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]}),a&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const it=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),xt={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"},Bh=s=>{const{t:n}=M("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Dt,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(H,{variant:"outline",className:y("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:ls[a.original.type]},children:[e.jsx(zn,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:r??l}),a.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:a.original.parent?.code||a.original.parent?.id})]}):""]})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:c=>{c.stopPropagation(),wt(r||l.toString())},children:e.jsx(Da,{className:"size-3"})})]})}),e.jsxs(te,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ps.find(c=>c.type===a.original.type)?.label,a.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:200,enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.show")}),cell:({row:a})=>{const[l,r]=m.useState(!!a.getValue("show"));return e.jsx(G,{checked:l,onCheckedChange:async c=>{r(c),qd({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?ls[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:a,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",xt[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",xt[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",xt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",xt[a.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:a.getValue("name")})]})}),e.jsx(te,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${a.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.address")}),cell:({row:a})=>{const l=`${a.original.host}:${a.original.port}`,r=a.original.port!==a.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[a.original.host,":",a.original.port]})}),r&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",a.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(oe,{delayDuration:0,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:c=>{c.stopPropagation(),wt(l)},children:e.jsx(Da,{className:"size-3"})})}),e.jsx(te,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:a})=>e.jsxs(H,{variant:"secondary",className:"font-medium",children:[a.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"groups",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:a})=>{const l=a.getValue("groups")||[];return e.jsx("div",{className:"flex min-w-[300px] max-w-[600px] flex-wrap items-center gap-1.5",children:l.length>0?l.map((r,c)=>e.jsx(H,{variant:"secondary",className:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:r.name},c)):e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})})},enableSorting:!1,size:600,filterFn:(a,l,r)=>{const c=a.getValue(l);return c?r.some(o=>c.includes(o)):!1}},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.type")}),cell:({row:a})=>{const l=a.getValue("type");return e.jsx(H,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:ls[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=Mr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(ys,{modal:!1,children:[e.jsx(_s,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(_t,{className:"size-4"})})}),e.jsxs(is,{align:"end",className:"w-40",children:[e.jsx(xe,{className:"cursor-pointer",onClick:()=>{c(a.original.type),r(a.original),l(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(po,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(xe,{className:"cursor-pointer",onClick:async()=>{Gd({id:a.original.id}).then(({data:o})=>{o&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(xo,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(at,{}),e.jsx(xe,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:o=>o.preventDefault(),children:e.jsx(Je,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Hd({id:a.original.id}).then(({data:o})=>{o&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(cs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Wh(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[o,u]=m.useState({pageSize:500,pageIndex:0}),[h,i]=m.useState([]),[d,f]=m.useState(!1),[P,E]=m.useState({}),[x,N]=m.useState([]),{refetch:k}=se({queryKey:["nodeList"],queryFn:async()=>{const{data:A}=await pr();return N(A),A}}),v=m.useMemo(()=>{const A=new Set;return x.forEach(Z=>{Z.groups&&Z.groups.forEach(z=>A.add(z.name))}),Array.from(A).sort()},[x]);m.useEffect(()=>{l({"drag-handle":d,show:!d,host:!d,online:!d,rate:!d,groups:!d,type:!1,actions:!d}),E({name:d?2e3:200}),u({pageSize:d?99999:500,pageIndex:0})},[d]);const w=(A,Z)=>{d&&(A.dataTransfer.setData("text/plain",Z.toString()),A.currentTarget.classList.add("opacity-50"))},S=(A,Z)=>{if(!d)return;A.preventDefault(),A.currentTarget.classList.remove("bg-muted");const z=parseInt(A.dataTransfer.getData("text/plain"));if(z===Z)return;const X=[...x],[qs]=X.splice(z,1);X.splice(Z,0,qs),N(X)},C=async()=>{if(!d){f(!0);return}const A=x?.map((Z,z)=>({id:Z.id,order:z+1}));Kd(A).then(()=>{$.success("排序保存成功"),f(!1),k()}).finally(()=>{f(!1)})},I=Ae({data:x||[],columns:Bh(k),state:{sorting:h,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:P,pagination:o},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:i,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:E,onPaginationChange:u,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Dh,{refetch:k,children:e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:I,toolbar:A=>e.jsx(Kh,{table:A,refetch:k,saveOrder:C,isSortMode:d,groups:v}),draggable:d,onDragStart:w,onDragEnd:A=>A.currentTarget.classList.remove("opacity-50"),onDragOver:A=>{A.preventDefault(),A.currentTarget.classList.add("bg-muted")},onDragLeave:A=>A.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!d})})})}function Yh(){const{t:s}=M("server");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Wh,{})})]})]})}const Jh=Object.freeze(Object.defineProperty({__proto__:null,default:Yh},Symbol.toStringTag,{value:"Module"}));function Qh({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=M("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(Lt,{refetch:n}),e.jsx(T,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:y("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]})})}const Zh=s=>{const{t:n}=M("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(H,{variant:"outline",children:a.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:a.getValue("name")})})},{accessorKey:"users_count",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(zn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Lt,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Je,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Wd({id:a.original.id}).then(({data:l})=>{l&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Xh(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),{data:h,refetch:i,isLoading:d}=se({queryKey:["serverGroupList"],queryFn:async()=>{const{data:P}=await Mt();return P}}),f=Ae({data:h||[],columns:Zh(i),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:f,toolbar:P=>e.jsx(Qh,{table:P,refetch:i}),isLoading:d})}function ep(){const{t:s}=M("group");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Xh,{})})]})]})}const sp=Object.freeze(Object.defineProperty({__proto__:null,default:ep},Symbol.toStringTag,{value:"Module"})),tp=s=>p.object({remarks:p.string().min(1,s("form.validation.remarks")),match:p.array(p.string()),action:p.enum(["block","dns"]),action_value:p.string().optional()});function Lr({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=M("route"),c=ce({resolver:ue(tp(r)),defaultValues:a,mode:"onChange"}),[o,u]=m.useState(!1);return e.jsxs(ge,{open:o,onOpenChange:u,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(_e,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(he,{...c,children:[e.jsx(j,{control:c.control,name:"remarks",render:({field:h})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.remarksPlaceholder"),...h})})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"match",render:({field:h})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(b,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(Cs,{className:"min-h-[120px]",placeholder:r("form.matchPlaceholder"),value:h.value.join(` `),onChange:i=>{h.onChange(i.target.value.split(` `))}})})}),e.jsx(D,{})]})}),e.jsx(j,{control:c.control,name:"action",render:({field:h})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:h.onChange,defaultValue:h.value,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("form.actionPlaceholder")})}),e.jsxs(B,{children:[e.jsx(U,{value:"block",children:r("actions.block")}),e.jsx(U,{value:"dns",children:r("actions.dns")})]})]})})}),e.jsx(D,{})]})}),c.watch("action")==="dns"&&e.jsx(j,{control:c.control,name:"action_value",render:({field:h})=>e.jsxs(g,{children:[e.jsx(b,{children:r("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(T,{type:"text",placeholder:r("form.dnsPlaceholder"),...h})})})]})}),e.jsxs(Oe,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{Yd(c.getValues()).then(({data:h})=>{h&&(u(!1),s&&s(),toast.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),c.reset())})},children:r("form.submit")})]})]})]})]})}function ap({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=M("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(Lr,{refetch:n}),e.jsx(T,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:r=>s.getColumn("remarks")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]})})}function np({columns:s,data:n,refetch:a}){const[l,r]=m.useState({}),[c,o]=m.useState({}),[u,h]=m.useState([]),[i,d]=m.useState([]),f=Ae({data:n,columns:s,state:{sorting:i,columnVisibility:c,rowSelection:l,columnFilters:u},enableRowSelection:!0,onRowSelectionChange:r,onSortingChange:d,onColumnFiltersChange:h,onColumnVisibilityChange:o,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:f,toolbar:P=>e.jsx(ap,{table:P,refetch:a})})}const rp=s=>{const{t:n}=M("route"),a={block:{icon:fo,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:go,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:l})=>e.jsx(O,{column:l,title:n("columns.id")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(H,{variant:"outline",children:l.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.remarks")}),cell:({row:l})=>{const r=l.original.match?.length||0;return 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:n("columns.matchRules",{count:r})})})},enableHiding:!1,enableSorting:!1},{accessorKey:"action",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.action")}),cell:({row:l})=>{const r=l.getValue("action"),c=a[r]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(H,{variant:a[r]?.variant||"default",className:y("flex items-center gap-1.5 px-3 py-1 capitalize",a[r]?.className),children:[c&&e.jsx(c,{className:"h-3.5 w-3.5"}),n(`actions.${r}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Lr,{defaultValues:l.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Je,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Jd({id:l.original.id}).then(({data:r})=>{r&&($.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function lp(){const{t:s}=M("route"),[n,a]=m.useState([]);function l(){xr().then(({data:r})=>{a(r)})}return m.useEffect(()=>{l()},[]),e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(np,{data:n,columns:rp(l),refetch:l})})]})]})}const ip=Object.freeze(Object.defineProperty({__proto__:null,default:lp},Symbol.toStringTag,{value:"Module"})),Or=m.createContext(void 0);function op({children:s,refreshData:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null);return e.jsx(Or.Provider,{value:{isOpen:a,setIsOpen:l,editingPlan:r,setEditingPlan:c,refreshData:n},children:s})}function xa(){const s=m.useContext(Or);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function cp({table:s,saveOrder:n,isSortMode:a}){const{setIsOpen:l}=xa(),{t:r}=M("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(R,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>l(!0),children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:r("plan.add")})]}),e.jsx(T,{placeholder:r("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:c=>s.getColumn("name")?.setFilterValue(c.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(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:r(a?"plan.sort.save":"plan.sort.edit")})})]})}const Ha={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"}},dp=s=>{const{t:n}=M("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Dt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.id")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(H,{variant:"outline",children:a.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.show")}),cell:({row:a})=>e.jsx(G,{defaultChecked:a.getValue("show"),onCheckedChange:l=>{Ft({id:a.original.id,show:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.sell")}),cell:({row:a})=>e.jsx(G,{defaultChecked:a.getValue("sell"),onCheckedChange:l=>{Ft({id:a.original.id,sell:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:a})=>e.jsx(G,{defaultChecked:a.getValue("renew"),onCheckedChange:l=>{Ft({id:a.original.id,renew:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.name")}),cell:({row:a})=>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:a.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.stats")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(it,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.group")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(H,{variant:"secondary",className:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:a.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.price")}),cell:({row:a})=>{const l=a.getValue("prices"),r=[{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:r.map(({period:c,key:o,unit:u})=>l[o]!=null&&e.jsxs(H,{variant:"secondary",className:y("px-2 py-0.5 font-medium transition-colors text-nowrap",Ha[o].color,Ha[o].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[c," ¥",l[o],u]},o))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("plan.columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingPlan:r}=xa();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{r(a.original),l(!0)},children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(Je,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{xm({id:a.original.id}).then(({data:c})=>{c&&($.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.delete")})]})})]})}}]},mp=p.object({id:p.number().nullable(),group_id:p.union([p.number(),p.string()]).nullable().optional(),name:p.string().min(1).max(250),content:p.string().nullable().optional(),transfer_enable:p.union([p.number().min(0),p.string().min(1)]),prices:p.object({monthly:p.union([p.number(),p.string()]).nullable().optional(),quarterly:p.union([p.number(),p.string()]).nullable().optional(),half_yearly:p.union([p.number(),p.string()]).nullable().optional(),yearly:p.union([p.number(),p.string()]).nullable().optional(),two_yearly:p.union([p.number(),p.string()]).nullable().optional(),three_yearly:p.union([p.number(),p.string()]).nullable().optional(),onetime:p.union([p.number(),p.string()]).nullable().optional(),reset_traffic:p.union([p.number(),p.string()]).nullable().optional()}).default({}),speed_limit:p.union([p.number(),p.string()]).nullable().optional(),capacity_limit:p.union([p.number(),p.string()]).nullable().optional(),device_limit:p.union([p.number(),p.string()]).nullable().optional(),force_update:p.boolean().optional(),reset_traffic_method:p.number().nullable(),users_count:p.number().optional()}),Vr=m.forwardRef(({className:s,...n},a)=>e.jsx(Un,{ref:a,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(jo,{className:y("flex items-center justify-center text-current"),children:e.jsx(Ds,{className:"h-4 w-4"})})}));Vr.displayName=Un.displayName;const ft={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},gt={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}},up=[{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 hp(){const{isOpen:s,setIsOpen:n,editingPlan:a,setEditingPlan:l,refreshData:r}=xa(),[c,o]=m.useState(!1),{t:u}=M("subscribe"),h=ce({resolver:ue(mp),defaultValues:{...ft,...a||{}},mode:"onChange"});m.useEffect(()=>{a?h.reset({...ft,...a}):h.reset(ft)},[a,h]);const i=new la({html:!0}),[d,f]=m.useState();async function P(){Mt().then(({data:N})=>{f(N)})}m.useEffect(()=>{s&&P()},[s]);const E=N=>{if(isNaN(N))return;const k=Object.entries(gt).reduce((v,[w,S])=>{const C=N*S.months*S.discount;return{...v,[w]:C.toFixed(2)}},{});h.setValue("prices",k,{shouldDirty:!0})},x=()=>{n(!1),l(null),h.reset(ft)};return e.jsx(ge,{open:s,onOpenChange:x,children:e.jsxs(pe,{children:[e.jsxs(be,{children:[e.jsx(je,{children:u(a?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Te,{})]}),e.jsxs(he,{...h,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:h.control,name:"name",render:({field:N})=>e.jsxs(g,{children:[e.jsx(b,{children:u("plan.form.name.label")}),e.jsx(_,{children:e.jsx(T,{placeholder:u("plan.form.name.placeholder"),...N})}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"group_id",render:({field:N})=>e.jsxs(g,{children:[e.jsxs(b,{className:"flex items-center justify-between",children:[u("plan.form.group.label"),e.jsx(Lt,{dialogTrigger:e.jsx(R,{variant:"link",children:u("plan.form.group.add")}),refetch:P})]}),e.jsxs(W,{value:N.value?.toString()??"",onValueChange:k=>N.onChange(k?Number(k):null),children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:u("plan.form.group.placeholder")})})}),e.jsx(B,{children:d?.map(k=>e.jsx(U,{value:k.id.toString(),children:k.name},k.id))})]}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"transfer_enable",render:({field:N})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:u("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",min:0,placeholder:u("plan.form.transfer.placeholder"),className:"rounded-r-none",...N})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.transfer.unit")})]}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"speed_limit",render:({field:N})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:u("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",min:0,placeholder:u("plan.form.speed.placeholder"),className:"rounded-r-none",...N,value:N.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.speed.unit")})]}),e.jsx(D,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:u("plan.form.price.title")}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(T,{type:"number",placeholder:u("plan.form.price.base_price"),className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:N=>{const k=parseFloat(N.target.value);E(k)}})]}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const N=Object.keys(gt).reduce((k,v)=>({...k,[v]:""}),{});h.setValue("prices",N,{shouldDirty:!0})},children:u("plan.form.price.clear.button")})}),e.jsx(te,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:u("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(gt).filter(([N])=>!["onetime","reset_traffic"].includes(N)).map(([N,k])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(j,{control:h.control,name:`prices.${N}`,render:({field:v})=>e.jsxs(g,{children:[e.jsxs(b,{className:"text-xs font-medium text-muted-foreground",children:[u(`plan.columns.price_period.${N}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",k.months===1?u("plan.form.price.period.monthly"):u("plan.form.price.period.months",{count:k.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(_,{children:e.jsx(T,{type:"number",placeholder:"0.00",min:0,...v,value:v.value??"",onChange:w=>v.onChange(w.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},N))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(gt).filter(([N])=>["onetime","reset_traffic"].includes(N)).map(([N,k])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(j,{control:h.control,name:`prices.${N}`,render:({field:v})=>e.jsx(g,{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(b,{className:"text-xs font-medium",children:u(`plan.columns.price_period.${N}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:u(N==="onetime"?"plan.form.price.onetime_desc":"plan.form.price.reset_desc")})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:"0.00",min:0,...v,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},N))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(j,{control:h.control,name:"device_limit",render:({field:N})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:u("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",min:0,placeholder:u("plan.form.device.placeholder"),className:"rounded-r-none",...N,value:N.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.device.unit")})]}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"capacity_limit",render:({field:N})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(b,{children:u("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(T,{type:"number",min:0,placeholder:u("plan.form.capacity.placeholder"),className:"rounded-r-none",...N,value:N.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.capacity.unit")})]}),e.jsx(D,{})]})})]}),e.jsx(j,{control:h.control,name:"reset_traffic_method",render:({field:N})=>e.jsxs(g,{children:[e.jsx(b,{children:u("plan.form.reset_method.label")}),e.jsxs(W,{value:N.value?.toString()??"null",onValueChange:k=>N.onChange(k=="null"?null:Number(k)),children:[e.jsx(_,{children:e.jsx(K,{children:e.jsx(Y,{placeholder:u("plan.form.reset_method.placeholder")})})}),e.jsx(B,{children:up.map(k=>e.jsx(U,{value:k.value?.toString()??"null",children:u(`plan.form.reset_method.options.${k.label}`)},k.value))})]}),e.jsx(L,{className:"text-xs",children:u("plan.form.reset_method.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:h.control,name:"content",render:({field:N})=>{const[k,v]=m.useState(!1);return e.jsxs(g,{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u("plan.form.content.label"),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>v(!k),children:k?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(te,{side:"top",children:e.jsx("p",{className:"text-xs",children:u(k?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(oe,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"outline",size:"sm",onClick:()=>{N.onChange(u("plan.form.content.template.content"))},children:u("plan.form.content.template.button")})}),e.jsx(te,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:u("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${k?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(_,{children:e.jsx(ia,{style:{height:"400px"},value:N.value||"",renderHTML:w=>i.render(w),onChange:({text:w})=>N.onChange(w),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:u("plan.form.content.placeholder"),className:"rounded-md border"})})}),k&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:u("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:i.render(N.value||"")}})})]})]}),e.jsx(L,{className:"text-xs",children:u("plan.form.content.description")}),e.jsx(D,{})]})}})]}),e.jsx(Oe,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:a&&e.jsx(j,{control:h.control,name:"force_update",render:({field:N})=>e.jsxs(g,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Vr,{checked:N.value,onCheckedChange:N.onChange})}),e.jsx("div",{className:"",children:e.jsx(b,{className:"text-sm",children:u("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(R,{type:"button",variant:"outline",onClick:x,children:u("plan.form.submit.cancel")}),e.jsx(R,{type:"submit",disabled:c,onClick:()=>{h.handleSubmit(async N=>{o(!0),(await pm(N)).data&&($.success(u(a?"plan.form.submit.success.update":"plan.form.submit.success.add")),x(),r()),o(!1)})()},children:u(c?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function pp(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[o,u]=m.useState([]),[h,i]=m.useState(!1),[d,f]=m.useState({pageSize:20,pageIndex:0}),[P,E]=m.useState([]),{refetch:x}=se({queryKey:["planList"],queryFn:async()=>{const{data:S}=await Ls();return E(S),S}});m.useEffect(()=>{l({"drag-handle":h}),f({pageSize:h?99999:10,pageIndex:0})},[h]);const N=(S,C)=>{h&&(S.dataTransfer.setData("text/plain",C.toString()),S.currentTarget.classList.add("opacity-50"))},k=(S,C)=>{if(!h)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const I=parseInt(S.dataTransfer.getData("text/plain"));if(I===C)return;const A=[...P],[Z]=A.splice(I,1);A.splice(C,0,Z),E(A)},v=async()=>{if(!h){i(!0);return}const S=P?.map(C=>C.id);fm(S).then(()=>{$.success("排序保存成功"),i(!1),x()}).finally(()=>{i(!1)})},w=Ae({data:P||[],columns:dp(x),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:d},enableRowSelection:!0,onPaginationChange:f,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}},pageCount:h?1:void 0});return e.jsx(op,{refreshData:x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ye,{table:w,toolbar:S=>e.jsx(cp,{table:S,refetch:x,saveOrder:v,isSortMode:h}),draggable:h,onDragStart:N,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!h}),e.jsx(hp,{})]})})}function xp(){const{t:s}=M("subscribe");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("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(pp,{})})]})]})}const fp=Object.freeze(Object.defineProperty({__proto__:null,default:xp},Symbol.toStringTag,{value:"Module"})),Fs=[{value:Q.PENDING,label:Ys[Q.PENDING],icon:bo,color:Js[Q.PENDING]},{value:Q.PROCESSING,label:Ys[Q.PROCESSING],icon:$n,color:Js[Q.PROCESSING]},{value:Q.COMPLETED,label:Ys[Q.COMPLETED],icon:Wt,color:Js[Q.COMPLETED]},{value:Q.CANCELLED,label:Ys[Q.CANCELLED],icon:Hn,color:Js[Q.CANCELLED]},{value:Q.DISCOUNTED,label:Ys[Q.DISCOUNTED],icon:Wt,color:Js[Q.DISCOUNTED]}],Zs=[{value:ne.PENDING,label:ut[ne.PENDING],icon:vo,color:ht[ne.PENDING]},{value:ne.PROCESSING,label:ut[ne.PROCESSING],icon:$n,color:ht[ne.PROCESSING]},{value:ne.VALID,label:ut[ne.VALID],icon:Wt,color:ht[ne.VALID]},{value:ne.INVALID,label:ut[ne.INVALID],icon:Hn,color:ht[ne.INVALID]}];function jt({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=s?.getFilterValue(),c=Array.isArray(r)?new Set(r):r!==void 0?new Set([r]):new Set;return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,c?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:c.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:c.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[c.size," selected"]}):a.filter(o=>c.has(o.value)).map(o=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:o.label},o.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Es,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(o=>{const u=c.has(o.value);return e.jsxs(Ne,{onSelect:()=>{const h=new Set(c);u?h.delete(o.value):h.add(o.value);const i=Array.from(h);s?.setFilterValue(i.length?i:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",u?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),o.icon&&e.jsx(o.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${o.color}`}),e.jsx("span",{children:o.label}),l?.get(o.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(o.value)})]},o.value)})}),c.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const gp=p.object({email:p.string().min(1),plan_id:p.number(),period:p.string(),total_amount:p.number()}),jp={email:"",plan_id:0,total_amount:0,period:""};function Ar({refetch:s,trigger:n,defaultValues:a}){const{t:l}=M("order"),[r,c]=m.useState(!1),o=ce({resolver:ue(gp),defaultValues:{...jp,...a},mode:"onChange"}),[u,h]=m.useState([]);return m.useEffect(()=>{r&&Ls().then(({data:i})=>{h(i)})},[r]),e.jsxs(ge,{open:r,onOpenChange:c,children:[e.jsx(Le,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:l("dialog.addOrder")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:l("dialog.assignOrder")}),e.jsx(Te,{})]}),e.jsxs(he,{...o,children:[e.jsx(j,{control:o.control,name:"email",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dialog.fields.userEmail")}),e.jsx(_,{children:e.jsx(T,{placeholder:l("dialog.placeholders.email"),...i})})]})}),e.jsx(j,{control:o.control,name:"plan_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dialog.fields.subscriptionPlan")}),e.jsx(_,{children:e.jsxs(W,{value:i.value?i.value?.toString():void 0,onValueChange:d=>i.onChange(parseInt(d)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dialog.placeholders.plan")})}),e.jsx(B,{children:u.map(d=>e.jsx(U,{value:d.id.toString(),children:d.name},d.id))})]})})]})}),e.jsx(j,{control:o.control,name:"period",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dialog.fields.orderPeriod")}),e.jsx(_,{children:e.jsxs(W,{value:i.value,onValueChange:i.onChange,children:[e.jsx(K,{children:e.jsx(Y,{placeholder:l("dialog.placeholders.period")})}),e.jsx(B,{children:Object.keys(Bm).map(d=>e.jsx(U,{value:d,children:l(`period.${d}`)},d))})]})})]})}),e.jsx(j,{control:o.control,name:"total_amount",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:l("dialog.fields.paymentAmount")}),e.jsx(_,{children:e.jsx(T,{type:"number",placeholder:l("dialog.placeholders.amount"),value:i.value/100,onChange:d=>i.onChange(parseFloat(d.currentTarget.value)*100)})}),e.jsx(D,{})]})}),e.jsxs(Oe,{children:[e.jsx(R,{variant:"outline",onClick:()=>c(!1),children:l("dialog.actions.cancel")}),e.jsx(R,{type:"submit",onClick:()=>{o.handleSubmit(i=>{ym(i).then(({data:d})=>{d&&(s&&s(),o.reset(),c(!1),$.success(l("dialog.messages.addSuccess")))})})()},children:l("dialog.actions.confirm")})]})]})]})]})}function bp({table:s,refetch:n}){const{t:a}=M("order"),l=s.getState().columnFilters.length>0,r=Object.values(He).filter(h=>typeof h=="number").map(h=>({label:a(`type.${He[h]}`),value:h,color:h===He.NEW?"green-500":h===He.RENEWAL?"blue-500":h===He.UPGRADE?"purple-500":"orange-500"})),c=Object.values(de).map(h=>({label:a(`period.${h}`),value:h,color:h===de.MONTH_PRICE?"slate-500":h===de.QUARTER_PRICE?"cyan-500":h===de.HALF_YEAR_PRICE?"indigo-500":h===de.YEAR_PRICE?"violet-500":h===de.TWO_YEAR_PRICE?"fuchsia-500":h===de.THREE_YEAR_PRICE?"pink-500":h===de.ONETIME_PRICE?"rose-500":"orange-500"})),o=Object.values(Q).filter(h=>typeof h=="number").map(h=>({label:a(`status.${Q[h]}`),value:h,icon:h===Q.PENDING?Fs[0].icon:h===Q.PROCESSING?Fs[1].icon:h===Q.COMPLETED?Fs[2].icon:h===Q.CANCELLED?Fs[3].icon:Fs[4].icon,color:h===Q.PENDING?"yellow-500":h===Q.PROCESSING?"blue-500":h===Q.COMPLETED?"green-500":h===Q.CANCELLED?"red-500":"green-500"})),u=Object.values(ne).filter(h=>typeof h=="number").map(h=>({label:a(`commission.${ne[h]}`),value:h,icon:h===ne.PENDING?Zs[0].icon:h===ne.PROCESSING?Zs[1].icon:h===ne.VALID?Zs[2].icon:Zs[3].icon,color:h===ne.PENDING?"yellow-500":h===ne.PROCESSING?"blue-500":h===ne.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ar,{refetch:n}),e.jsx(T,{placeholder:a("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:h=>s.getColumn("trade_no")?.setFilterValue(h.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(jt,{column:s.getColumn("type"),title:a("table.columns.type"),options:r}),s.getColumn("period")&&e.jsx(jt,{column:s.getColumn("period"),title:a("table.columns.period"),options:c}),s.getColumn("status")&&e.jsx(jt,{column:s.getColumn("status"),title:a("table.columns.status"),options:o}),s.getColumn("commission_status")&&e.jsx(jt,{column:s.getColumn("commission_status"),title:a("table.columns.commissionStatus"),options:u})]}),l&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[a("actions.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]})}function ze({label:s,value:n,className:a,valueClassName:l}){return e.jsxs("div",{className:y("flex items-center py-1.5",a),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:y("text-sm",l),children:n||"-"})]})}function vp({status:s}){const{t:n}=M("order"),a={[Q.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[Q.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[Q.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[Q.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[Q.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(H,{variant:"secondary",className:y("font-medium",a[s]),children:n(`status.${Q[s]}`)})}function yp({id:s,trigger:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(),{t:o}=M("order");return m.useEffect(()=>{(async()=>{if(a){const{data:h}=await jm({id:s});c(h)}})()},[a,s]),e.jsxs(ge,{onOpenChange:l,open:a,children:[e.jsx(Le,{asChild:!0,children:n}),e.jsxs(pe,{className:"max-w-xl",children:[e.jsxs(be,{className:"space-y-2",children:[e.jsx(je,{className:"text-lg font-medium",children:o("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:[o("table.columns.tradeNo"),":",r?.trade_no]}),r?.status&&e.jsx(vp,{status:r.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:o("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ze,{label:o("dialog.fields.userEmail"),value:r?.user?.email?e.jsxs(Rs,{to:`/user/manage?email=${r.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[r.user.email,e.jsx(Gn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(ze,{label:o("dialog.fields.orderPeriod"),value:r&&o(`period.${r.period}`)}),e.jsx(ze,{label:o("dialog.fields.subscriptionPlan"),value:r?.plan?.name,valueClassName:"font-medium"}),e.jsx(ze,{label:o("dialog.fields.callbackNo"),value:r?.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:o("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ze,{label:o("dialog.fields.paymentAmount"),value:ks(r?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(ve,{className:"my-2"}),e.jsx(ze,{label:o("dialog.fields.balancePayment"),value:ks(r?.balance_amount||0)}),e.jsx(ze,{label:o("dialog.fields.discountAmount"),value:ks(r?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(ze,{label:o("dialog.fields.refundAmount"),value:ks(r?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(ze,{label:o("dialog.fields.deductionAmount"),value:ks(r?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:o("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ze,{label:o("dialog.fields.createdAt"),value:me(r?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(ze,{label:o("dialog.fields.updatedAt"),value:me(r?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const _p={[He.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[He.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[He.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[He.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Np={[de.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[de.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},wp=s=>Q[s],Cp=s=>ne[s],Sp=s=>He[s],kp=s=>{const{t:n}=M("order");return[{accessorKey:"trade_no",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.tradeNo")}),cell:({row:a})=>{const l=a.original.trade_no,r=l.length>6?`${l.slice(0,3)}...${l.slice(-3)}`:l;return e.jsx("div",{className:"flex items-center",children:e.jsx(yp,{trigger:e.jsxs(J,{variant:"ghost",size:"sm",className:"flex h-8 items-center gap-1.5 px-2 font-medium text-primary transition-colors hover:bg-primary/10 hover:text-primary/80",children:[e.jsx("span",{className:"font-mono",children:r}),e.jsx(Gn,{className:"h-3.5 w-3.5 opacity-70"})]}),id:a.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.type")}),cell:({row:a})=>{const l=a.getValue("type"),r=_p[l];return e.jsx(H,{variant:"secondary",className:y("font-medium transition-colors text-nowrap",r.color,r.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${Sp(l)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.plan")}),cell:({row:a})=>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:a.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.period")}),cell:({row:a})=>{const l=a.getValue("period"),r=Np[l];return e.jsx(H,{variant:"secondary",className:y("font-medium transition-colors text-nowrap",r.color,r.bgColor,"hover:bg-opacity-80"),children:n(`period.${l}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.amount")}),cell:({row:a})=>{const l=a.getValue("total_amount"),r=typeof l=="number"?(l/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",r]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:a})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:a,title:n("table.columns.status")}),e.jsx(oe,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsx(Tr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(te,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:a})=>{const l=Fs.find(r=>r.value===a.getValue("status"));return l?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.icon&&e.jsx(l.icon,{className:`h-4 w-4 text-${l.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${wp(l.value)}`)})]}),l.value===Q.PENDING&&e.jsxs(ys,{modal:!0,children:[e.jsx(_s,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(is,{align:"end",className:"w-[140px]",children:[e.jsx(xe,{className:"cursor-pointer",onClick:async()=>{await bm({trade_no:a.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(xe,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await vm({trade_no:a.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.commission")}),cell:({row:a})=>{const l=a.getValue("commission_balance"),r=l?(l/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:l?`¥${r}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.commissionStatus")}),cell:({row:a})=>{const l=a.original.status,r=a.original.commission_balance,c=Zs.find(o=>o.value===a.getValue("commission_status"));return r==0||!c?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:[c.icon&&e.jsx(c.icon,{className:`h-4 w-4 text-${c.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${Cp(c.value)}`)})]}),c.value===ne.PENDING&&l===Q.COMPLETED&&e.jsxs(ys,{modal:!0,children:[e.jsx(_s,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(is,{align:"end",className:"w-[120px]",children:[e.jsx(xe,{className:"cursor-pointer",onClick:async()=>{await Va({trade_no:a.original.trade_no,commission_status:ne.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(xe,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await Va({trade_no:a.original.trade_no,commission_status:ne.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.createdAt")}),cell:({row:a})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:me(a.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function Pp(){const[s]=qn(),[n,a]=m.useState({}),[l,r]=m.useState({}),[c,o]=m.useState([]),[u,h]=m.useState([]),[i,d]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const k=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([v,w])=>{const S=s.get(v);return S?{id:v,value:w==="number"?parseInt(S):S}:null}).filter(Boolean);k.length>0&&o(k)},[s]);const{refetch:f,data:P,isLoading:E}=se({queryKey:["orderList",i,c,u],queryFn:()=>gm({pageSize:i.pageSize,current:i.pageIndex+1,filter:c,sort:u})}),x=Ae({data:P?.data??[],columns:kp(f),state:{sorting:u,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:i},rowCount:P?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:h,onColumnFiltersChange:o,onColumnVisibilityChange:r,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),onPaginationChange:d,getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:x,toolbar:e.jsx(bp,{table:x,refetch:f}),showPagination:!0})}function Tp(){const{t:s}=M("order");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"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(Pp,{})})]})]})}const Dp=Object.freeze(Object.defineProperty({__proto__:null,default:Tp},Symbol.toStringTag,{value:"Module"}));function Rp({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ns,{children:[e.jsx(Es,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Me,{children:a.map(c=>{const o=r.has(c.value);return e.jsxs(Ne,{onSelect:()=>{o?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ds,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${c.color}`}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Me,{children:e.jsx(Ne,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Ip=p.object({id:p.coerce.number().nullable().optional(),name:p.string().min(1,"请输入优惠券名称"),code:p.string().nullable(),type:p.union([p.string(),p.nativeEnum(js)]),value:p.coerce.number(),started_at:p.coerce.number(),ended_at:p.coerce.number(),limit_use:p.union([p.string(),p.number()]).nullable(),limit_use_with_user:p.union([p.string(),p.number()]).nullable(),generate_count:p.coerce.number().nullable().optional(),limit_plan_ids:p.array(p.number()).default([]).nullable(),limit_period:p.array(p.nativeEnum(de)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),Ga={name:"",code:"",type:js.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:"",limit_use_with_user:"",limit_plan_ids:[],limit_period:[],generate_count:""};function Fr({defaultValues:s,refetch:n,type:a="create",dialogTrigger:l=null,open:r,onOpenChange:c}){const{t:o}=M("coupon"),[u,h]=m.useState(!1),i=r??u,d=c??h,[f,P]=m.useState([]),E=ce({resolver:ue(Ip),defaultValues:s||Ga});m.useEffect(()=>{s&&E.reset(s)},[s,E]),m.useEffect(()=>{Ls().then(({data:v})=>P(v))},[]);const x=v=>{if(!v)return;const w=(S,C)=>{const I=new Date(C*1e3);return S.setHours(I.getHours(),I.getMinutes(),I.getSeconds()),Math.floor(S.getTime()/1e3)};v.from&&E.setValue("started_at",w(v.from,E.watch("started_at"))),v.to&&E.setValue("ended_at",w(v.to,E.watch("ended_at")))},N=async v=>{Nm(v).then(()=>{d(!1),a==="create"&&E.reset(Ga),n()})},k=(v,w)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:w}),e.jsx(T,{type:"datetime-local",step:"1",value:me(E.watch(v),"YYYY-MM-DDTHH:mm:ss"),onChange:S=>{const C=new Date(S.target.value);E.setValue(v,Math.floor(C.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(ge,{open:i,onOpenChange:d,children:[l&&e.jsx(Le,{asChild:!0,children:l}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(je,{children:o(a==="create"?"form.add":"form.edit")})}),e.jsx(he,{...E,children:e.jsxs("form",{onSubmit:E.handleSubmit(N),className:"space-y-4",children:[e.jsx(j,{control:E.control,name:"name",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.name.label")}),e.jsx(T,{placeholder:o("form.name.placeholder"),...v}),e.jsx(D,{})]})}),e.jsx(j,{control:E.control,name:"code",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.code.label")}),e.jsx(T,{placeholder:o("form.code.placeholder"),...v,className:"h-9"}),e.jsx(L,{className:"text-xs",children:o("form.code.description")}),e.jsx(D,{})]})}),e.jsxs(g,{children:[e.jsx(b,{children:o("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(j,{control:E.control,name:"type",render:({field:v})=>e.jsxs(W,{value:v.value.toString(),onValueChange:v.onChange,children:[e.jsx(K,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Y,{placeholder:o("form.type.placeholder")})}),e.jsx(B,{children:Object.entries(Wm).map(([w,S])=>e.jsx(U,{value:w,children:o(`table.toolbar.types.${w}`)},w))})]})}),e.jsx(j,{control:E.control,name:"value",render:({field:v})=>e.jsx(T,{type:"number",placeholder:o("form.value.placeholder"),...v,onChange:w=>v.onChange(w.target.value===""?"":w.target.value),className:"flex-[2] rounded-none border-x-0 text-left"})}),e.jsx("div",{className:"flex min-w-[40px] items-center justify-center rounded-md rounded-l-none border border-l-0 border-input bg-muted/50 px-3 font-medium text-muted-foreground",children:e.jsx("span",{children:E.watch("type")===js.AMOUNT?"¥":"%"})})]})]}),e.jsxs(g,{children:[e.jsx(b,{children:o("form.validity.label")}),e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",className:y("w-full justify-start text-left font-normal",!E.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(ot,{className:"mr-2 h-4 w-4"}),me(E.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",o("form.validity.to")," ",me(E.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(We,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(Os,{mode:"range",selected:{from:new Date(E.watch("started_at")*1e3),to:new Date(E.watch("ended_at")*1e3)},onSelect:x,numberOfMonths:2})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-4",children:[k("started_at",o("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:o("form.validity.to")}),k("ended_at",o("table.validity.endTime"))]})})]})]}),e.jsx(D,{})]}),e.jsx(j,{control:E.control,name:"limit_use",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.limitUse.label")}),e.jsx(T,{type:"number",min:0,placeholder:o("form.limitUse.placeholder"),...v,value:v.value===void 0?"":v.value,onChange:w=>v.onChange(w.target.value===""?"":w.target.value),className:"h-9"}),e.jsx(L,{className:"text-xs",children:o("form.limitUse.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:E.control,name:"limit_use_with_user",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.limitUseWithUser.label")}),e.jsx(T,{type:"number",min:0,placeholder:o("form.limitUseWithUser.placeholder"),...v,value:v.value===void 0?"":v.value,onChange:w=>v.onChange(w.target.value===""?"":w.target.value),className:"h-9"}),e.jsx(L,{className:"text-xs",children:o("form.limitUseWithUser.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:E.control,name:"limit_period",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.limitPeriod.label")}),e.jsx(lt,{options:Object.entries(de).filter(([w])=>isNaN(Number(w))).map(([w,S])=>({label:S,value:w})),onChange:w=>{if(w.length===0){v.onChange([]);return}const S=w.map(C=>de[C.value]);v.onChange(S)},value:(v.value||[]).map(w=>({label:Object.entries(de).find(([S,C])=>C===w)?.[1]||"",value:Object.entries(de).find(([S,C])=>C===w)?.[0]||""})),placeholder:o("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:o("form.limitPeriod.empty")})}),e.jsx(L,{className:"text-xs",children:o("form.limitPeriod.description")}),e.jsx(D,{})]})}),e.jsx(j,{control:E.control,name:"limit_plan_ids",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.limitPlan.label")}),e.jsx(lt,{options:f?.map(w=>({label:w.name,value:w.id.toString()}))||[],onChange:w=>v.onChange(w.map(S=>Number(S.value))),value:(f||[]).filter(w=>(v.value||[]).includes(w.id)).map(w=>({label:w.name,value:w.id.toString()})),placeholder:o("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:o("form.limitPlan.empty")})}),e.jsx(D,{})]})}),a==="create"&&e.jsx(e.Fragment,{children:e.jsx(j,{control:E.control,name:"generate_count",render:({field:v})=>e.jsxs(g,{children:[e.jsx(b,{children:o("form.generateCount.label")}),e.jsx(T,{type:"number",min:0,placeholder:o("form.generateCount.placeholder"),...v,value:v.value===void 0?"":v.value,onChange:w=>v.onChange(w.target.value===""?"":w.target.value),className:"h-9"}),e.jsx(L,{className:"text-xs",children:o("form.generateCount.description")}),e.jsx(D,{})]})})}),e.jsx(Oe,{children:e.jsx(R,{type:"submit",disabled:E.formState.isSubmitting,children:E.formState.isSubmitting?o("form.submit.saving"):o("form.submit.save")})})]})})]})]})}function Ep({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=M("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Fr,{refetch:n,dialogTrigger:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:l("form.add")})]})}),e.jsx(T,{placeholder:l("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(Rp,{column:s.getColumn("type"),title:l("table.toolbar.type"),options:[{value:js.AMOUNT,label:l(`table.toolbar.types.${js.AMOUNT}`)},{value:js.PERCENTAGE,label:l(`table.toolbar.types.${js.PERCENTAGE}`)}]}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("table.toolbar.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]})}const zr=m.createContext(void 0);function Mp({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),o=h=>{c(h),l(!0)},u=()=>{l(!1),c(null)};return e.jsxs(zr.Provider,{value:{isOpen:a,currentCoupon:r,openEdit:o,closeEdit:u},children:[s,r&&e.jsx(Fr,{defaultValues:r,refetch:n,type:"edit",open:a,onOpenChange:l})]})}function Lp(){const s=m.useContext(zr);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Op=s=>{const{t:n}=M("coupon");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(H,{children:a.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx(G,{defaultChecked:a.original.show,onCheckedChange:l=>{Cm({id:a.original.id,show:l}).then(({data:r})=>!r&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:a.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.type")}),cell:({row:a})=>e.jsx(H,{variant:"outline",children:n(`table.toolbar.types.${a.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.code")}),cell:({row:a})=>e.jsx(H,{variant:"secondary",children:a.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.limitUse")}),cell:({row:a})=>e.jsx(H,{variant:"outline",children:a.original.limit_use===null?n("table.validity.unlimited"):a.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.limitUseWithUser")}),cell:({row:a})=>e.jsx(H,{variant:"outline",children:a.original.limit_use_with_user===null?n("table.validity.noLimit"):a.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.validity")}),cell:({row:a})=>{const[l,r]=m.useState(!1),c=Date.now(),o=a.original.started_at*1e3,u=a.original.ended_at*1e3,h=c>u,i=ce.jsx(O,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>{const{openEdit:l}=Lp();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>l(a.original),children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(Je,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{wm({id:a.original.id}).then(({data:r})=>{r&&($.success("删除成功"),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete")})]})})]})}}]};function Vp(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[o,u]=m.useState([]),[h,i]=m.useState({pageIndex:0,pageSize:20}),{refetch:d,data:f}=se({queryKey:["couponList",h,r,o],queryFn:()=>_m({pageSize:h.pageSize,current:h.pageIndex+1,filter:r,sort:o})}),P=Ae({data:f?.data??[],columns:Op(d),state:{sorting:o,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:h},pageCount:Math.ceil((f?.total??0)/h.pageSize),rowCount:f?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onPaginationChange:i,getCoreRowModel:Fe(),getFilteredRowModel:qe(),getPaginationRowModel:Ke(),getSortedRowModel:Be(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Mp,{refetch:d,children:e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:P,toolbar:e.jsx(Ep,{table:P,refetch:d})})})})}function Ap(){const{t:s}=M("coupon");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(De,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ie,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"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(Vp,{})})]})]})}const Fp=Object.freeze(Object.defineProperty({__proto__:null,default:Ap},Symbol.toStringTag,{value:"Module"})),zp=p.object({email_prefix:p.string().optional(),email_suffix:p.string().min(1),password:p.string().optional(),expired_at:p.number().optional().nullable(),plan_id:p.number().nullable(),generate_count:p.number().optional().nullable()}).refine(s=>s.generate_count===null?s.email_prefix!==void 0&&s.email_prefix!=="":!0,{message:"Email prefix is required when generate_count is null",path:["email_prefix"]}),Up={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function $p({refetch:s}){const{t:n}=M("user"),[a,l]=m.useState(!1),r=ce({resolver:ue(zp),defaultValues:Up,mode:"onChange"}),[c,o]=m.useState([]);return m.useEffect(()=>{a&&Ls().then(({data:u})=>{u&&o(u)})},[a]),e.jsxs(ge,{open:a,onOpenChange:l,children:[e.jsx(Le,{asChild:!0,children:e.jsxs(J,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(_e,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(je,{children:n("generate.title")}),e.jsx(Te,{})]}),e.jsxs(he,{...r,children:[e.jsxs(g,{children:[e.jsx(b,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!r.watch("generate_count")&&e.jsx(j,{control:r.control,name:"email_prefix",render:({field:u})=>e.jsx(T,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...u})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${r.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(j,{control:r.control,name:"email_suffix",render:({field:u})=>e.jsx(T,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...u})})]})]}),e.jsx(j,{control:r.control,name:"password",render:({field:u})=>e.jsxs(g,{children:[e.jsx(b,{children:n("generate.form.password")}),e.jsx(T,{placeholder:n("generate.form.password_placeholder"),...u}),e.jsx(D,{})]})}),e.jsx(j,{control:r.control,name:"expired_at",render:({field:u})=>e.jsxs(g,{className:"flex flex-col",children:[e.jsx(b,{children:n("generate.form.expire_time")}),e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsx(_,{children:e.jsxs(J,{variant:"outline",className:y("w-full pl-3 text-left font-normal",!u.value&&"text-muted-foreground"),children:[u.value?me(u.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(ot,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(We,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(_o,{asChild:!0,children:e.jsx(J,{variant:"outline",className:"w-full",onClick:()=>{u.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Os,{mode:"single",selected:u.value?new Date(u.value*1e3):void 0,onSelect:h=>{h&&u.onChange(h?.getTime()/1e3)}})})]})]})]})}),e.jsx(j,{control:r.control,name:"plan_id",render:({field:u})=>e.jsxs(g,{children:[e.jsx(b,{children:n("generate.form.subscription")}),e.jsx(_,{children:e.jsxs(W,{value:u.value?u.value.toString():"null",onValueChange:h=>u.onChange(h==="null"?null:parseInt(h)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(U,{value:"null",children:n("generate.form.subscription_none")}),c.map(h=>e.jsx(U,{value:h.id.toString(),children:h.name},h.id))]})]})})]})}),!r.watch("email_prefix")&&e.jsx(j,{control:r.control,name:"generate_count",render:({field:u})=>e.jsxs(g,{children:[e.jsx(b,{children:n("generate.form.generate_count")}),e.jsx(T,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:u.value||"",onChange:h=>u.onChange(h.target.value?parseInt(h.target.value):null)})]})})]}),e.jsxs(Oe,{children:[e.jsx(J,{variant:"outline",onClick:()=>l(!1),children:n("generate.form.cancel")}),e.jsx(J,{onClick:()=>r.handleSubmit(u=>{Tm(u).then(({data:h})=>{h&&($.success(n("generate.form.success")),r.reset(),s(),l(!1))})})(),children:n("generate.form.submit")})]})]})]})}const Ur=Ba,$r=Wa,Hp=Ya,Hr=m.forwardRef(({className:s,...n},a)=>e.jsx(St,{className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:a}));Hr.displayName=St.displayName;const Gp=Ts("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"}}),fa=m.forwardRef(({side:s="right",className:n,children:a,...l},r)=>e.jsxs(Hp,{children:[e.jsx(Hr,{}),e.jsxs(kt,{ref:r,className:y(Gp({side:s}),n),...l,children:[e.jsxs(ta,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),a]})]}));fa.displayName=kt.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 Gr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Gr.displayName="SheetFooter";const ja=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{ref:a,className:y("text-lg font-semibold text-foreground",s),...n}));ja.displayName=Pt.displayName;const ba=m.forwardRef(({className:s,...n},a)=>e.jsx(Tt,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));ba.displayName=Tt.displayName;function qp({table:s,refetch:n,permissionGroups:a=[],subscriptionPlans:l=[]}){const{t:r}=M("user"),c=s.getState().columnFilters.length>0,[o,u]=m.useState([]),[h,i]=m.useState(!1),d=[{label:r("filter.fields.email"),value:"email",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.id"),value:"id",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:r("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:r("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"},{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"}]},{label:r("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.token"),value:"token",type:"text",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.banned"),value:"banned",type:"select",operators:[{label:r("filter.operators.eq"),value:"eq"}],options:[{label:r("filter.status.normal"),value:"0"},{label:r("filter.status.banned"),value:"1"}]},{label:r("filter.fields.remark"),value:"remark",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.inviter_email"),value:"inviter_email",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:r("filter.operators.eq"),value:"eq"}]}],f=w=>w*1024*1024*1024,P=w=>w/(1024*1024*1024),E=()=>{u([...o,{field:"",operator:"",value:""}])},x=w=>{u(o.filter((S,C)=>C!==w))},N=(w,S,C)=>{const I=[...o];if(I[w]={...I[w],[S]:C},S==="field"){const A=d.find(Z=>Z.value===C);A&&(I[w].operator=A.operators[0].value,I[w].value=A.type==="boolean"?!1:"")}u(I)},k=(w,S)=>{const C=d.find(I=>I.value===w.field);if(!C)return null;switch(C.type){case"text":return e.jsx(T,{placeholder:r("filter.sheet.value"),value:w.value,onChange:I=>N(S,"value",I.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(T,{type:"number",placeholder:r("filter.sheet.value_number",{unit:C.unit}),value:C.unit==="GB"?P(w.value||0):w.value,onChange:I=>{const A=Number(I.target.value);N(S,"value",C.unit==="GB"?f(A):A)}}),C.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:C.unit})]});case"date":return e.jsx(Os,{mode:"single",selected:w.value,onSelect:I=>N(S,"value",I),className:"rounded-md border"});case"select":return e.jsxs(W,{value:w.value,onValueChange:I=>N(S,"value",I),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("filter.sheet.value")})}),e.jsx(B,{children:C.useOptions?l.map(I=>e.jsx(U,{value:I.value.toString(),children:I.label},I.value)):C.options?.map(I=>e.jsx(U,{value:I.value.toString(),children:I.label},I.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(G,{checked:w.value,onCheckedChange:I=>N(S,"value",I)}),e.jsx(Nt,{children:w.value?r("filter.boolean.true"):r("filter.boolean.false")})]});default:return null}},v=()=>{const w=o.filter(S=>S.field&&S.operator&&S.value!=="").map(S=>{const C=d.find(A=>A.value===S.field);let I=S.value;return S.operator==="contains"?{id:S.field,value:I}:(C?.type==="date"&&I instanceof Date&&(I=Math.floor(I.getTime()/1e3)),C?.type==="boolean"&&(I=I?1:0),{id:S.field,value:`${S.operator}:${I}`})});s.setColumnFilters(w),i(!1)};return e.jsx("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($p,{refetch:n}),e.jsx(T,{placeholder:r("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:w=>s.getColumn("email")?.setFilterValue(w.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Ur,{open:h,onOpenChange:i,children:[e.jsx($r,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(No,{className:"mr-2 h-4 w-4"}),r("filter.advanced"),o.length>0&&e.jsx(H,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:o.length})]})}),e.jsxs(fa,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(ga,{children:[e.jsx(ja,{children:r("filter.sheet.title")}),e.jsx(ba,{children:r("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:r("filter.sheet.conditions")}),e.jsx(R,{variant:"outline",size:"sm",onClick:E,children:r("filter.sheet.add")})]}),e.jsx(rt,{className:"h-[calc(100vh-280px)] pr-4",children:e.jsx("div",{className:"space-y-4",children:o.map((w,S)=>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(Nt,{children:r("filter.sheet.condition",{number:S+1})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>x(S),children:e.jsx(Ve,{className:"h-4 w-4"})})]}),e.jsxs(W,{value:w.field,onValueChange:C=>N(S,"field",C),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("filter.sheet.field")})}),e.jsx(B,{children:d.map(C=>e.jsx(U,{value:C.value,children:C.label},C.value))})]}),w.field&&e.jsxs(W,{value:w.operator,onValueChange:C=>N(S,"operator",C),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:r("filter.sheet.operator")})}),e.jsx(B,{children:d.find(C=>C.value===w.field)?.operators.map(C=>e.jsx(U,{value:C.value,children:C.label},C.value))})]}),w.field&&w.operator&&k(w,S)]},S))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(R,{variant:"outline",onClick:()=>{u([]),i(!1)},children:r("filter.sheet.reset")}),e.jsx(R,{onClick:v,children:r("filter.sheet.apply")})]})]})]})]}),c&&e.jsxs(R,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[r("filter.reset"),e.jsx(Ve,{className:"ml-2 h-4 w-4"})]})]})})}const Kp=p.object({id:p.number(),email:p.string().email(),invite_user_email:p.string().email().nullable().optional(),password:p.string().optional().nullable(),balance:p.coerce.number(),commission_balance:p.coerce.number(),u:p.number(),d:p.number(),transfer_enable:p.number(),expired_at:p.number().nullable(),plan_id:p.number().nullable(),banned:p.number(),commission_type:p.number(),commission_rate:p.number().nullable(),discount:p.number().nullable(),speed_limit:p.number().nullable(),device_limit:p.number().nullable(),is_admin:p.number(),is_staff:p.number(),remarks:p.string().nullable()}),qr=m.createContext(void 0);function Bp({children:s,defaultValues:n,open:a,onOpenChange:l}){const[r,c]=m.useState(!1),[o,u]=m.useState(!1),[h,i]=m.useState([]),d=ce({resolver:ue(Kp),defaultValues:n,mode:"onChange"});m.useEffect(()=>{a!==void 0&&c(a)},[a]);const f=P=>{c(P),l?.(P)};return e.jsx(qr.Provider,{value:{form:d,formOpen:r,setFormOpen:f,datePickerOpen:o,setDatePickerOpen:u,planList:h,setPlanList:i},children:s})}function Wp(){const s=m.useContext(qr);if(!s)throw new Error("useUserForm must be used within a UserFormProvider");return s}function Yp({refetch:s}){const{t:n}=M("user"),{form:a,formOpen:l,setFormOpen:r,datePickerOpen:c,setDatePickerOpen:o,planList:u,setPlanList:h}=Wp();return m.useEffect(()=>{l&&Ls().then(({data:i})=>{h(i)})},[l,h]),e.jsxs(he,{...a,children:[e.jsx(j,{control:a.control,name:"email",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.email")}),e.jsx(_,{children:e.jsx(T,{...i,placeholder:n("edit.form.email_placeholder")})}),e.jsx(D,{...i})]})}),e.jsx(j,{control:a.control,name:"invite_user_email",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.inviter_email")}),e.jsx(_,{children:e.jsx(T,{value:i.value||"",onChange:d=>i.onChange(d.target.value?d.target.value:null),placeholder:n("edit.form.inviter_email_placeholder")})}),e.jsx(D,{...i})]})}),e.jsx(j,{control:a.control,name:"password",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.password")}),e.jsx(_,{children:e.jsx(T,{value:i.value||"",onChange:i.onChange,placeholder:n("edit.form.password_placeholder")})}),e.jsx(D,{...i})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(j,{control:a.control,name:"balance",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.balance")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value||"",onChange:i.onChange,placeholder:n("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(D,{...i})]})}),e.jsx(j,{control:a.control,name:"commission_balance",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.commission_balance")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value||"",onChange:i.onChange,placeholder:n("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(D,{...i})]})}),e.jsx(j,{control:a.control,name:"u",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.upload")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{value:i.value/1024/1024/1024||"",onChange:d=>i.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{...i})]})}),e.jsx(j,{control:a.control,name:"d",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.download")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value/1024/1024/1024||"",onChange:d=>i.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{...i})]})})]}),e.jsx(j,{control:a.control,name:"transfer_enable",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.total_traffic")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value/1024/1024/1024||"",onChange:d=>i.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(D,{})]})}),e.jsx(j,{control:a.control,name:"expired_at",render:({field:i})=>e.jsxs(g,{className:"flex flex-col",children:[e.jsx(b,{children:n("edit.form.expire_time")}),e.jsxs(as,{open:c,onOpenChange:o,children:[e.jsx(ns,{asChild:!0,children:e.jsx(_,{children:e.jsxs(R,{type:"button",variant:"outline",className:y("w-full pl-3 text-left font-normal",!i.value&&"text-muted-foreground"),onClick:()=>o(!0),children:[i.value?me(i.value):e.jsx("span",{children:n("edit.form.expire_time_placeholder")}),e.jsx(ot,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(We,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:d=>{d.preventDefault()},onEscapeKeyDown:d=>{d.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(R,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{i.onChange(null),o(!1)},children:n("edit.form.expire_time_permanent")}),e.jsx(R,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;d.setMonth(d.getMonth()+1),d.setHours(23,59,59,999),i.onChange(Math.floor(d.getTime()/1e3)),o(!1)},children:n("edit.form.expire_time_1month")}),e.jsx(R,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;d.setMonth(d.getMonth()+3),d.setHours(23,59,59,999),i.onChange(Math.floor(d.getTime()/1e3)),o(!1)},children:n("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Os,{mode:"single",selected:i.value?new Date(i.value*1e3):void 0,onSelect:d=>{if(d){const f=new Date(i.value?i.value*1e3:Date.now());d.setHours(f.getHours(),f.getMinutes(),f.getSeconds()),i.onChange(Math.floor(d.getTime()/1e3))}},disabled:d=>d{const d=new Date;d.setHours(23,59,59,999),i.onChange(Math.floor(d.getTime()/1e3))},className:"h-6 px-2 text-xs",children:n("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"datetime-local",step:"1",value:me(i.value,"YYYY-MM-DDTHH:mm:ss"),onChange:d=>{const f=new Date(d.target.value);isNaN(f.getTime())||i.onChange(Math.floor(f.getTime()/1e3))},className:"flex-1"}),e.jsx(R,{type:"button",variant:"outline",onClick:()=>o(!1),children:n("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(D,{})]})}),e.jsx(j,{control:a.control,name:"plan_id",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.subscription")}),e.jsx(_,{children:e.jsxs(W,{value:i.value?i.value.toString():"null",onValueChange:d=>i.onChange(d==="null"?null:parseInt(d)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(U,{value:"null",children:n("edit.form.subscription_none")}),u.map(d=>e.jsx(U,{value:d.id.toString(),children:d.name},d.id))]})]})})]})}),e.jsx(j,{control:a.control,name:"banned",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.account_status")}),e.jsx(_,{children:e.jsxs(W,{value:i.value.toString(),onValueChange:d=>i.onChange(parseInt(d)),children:[e.jsx(K,{children:e.jsx(Y,{})}),e.jsxs(B,{children:[e.jsx(U,{value:"1",children:n("columns.status_text.banned")}),e.jsx(U,{value:"0",children:n("columns.status_text.normal")})]})]})})]})}),e.jsx(j,{control:a.control,name:"commission_type",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.commission_type")}),e.jsx(_,{children:e.jsxs(W,{value:i.value.toString(),onValueChange:d=>i.onChange(parseInt(d)),children:[e.jsx(K,{children:e.jsx(Y,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(U,{value:"0",children:n("edit.form.commission_type_system")}),e.jsx(U,{value:"1",children:n("edit.form.commission_type_cycle")}),e.jsx(U,{value:"2",children:n("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(j,{control:a.control,name:"commission_rate",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.commission_rate")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value||"",onChange:d=>i.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(j,{control:a.control,name:"discount",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.discount")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value||"",onChange:d=>i.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(D,{})]})}),e.jsx(j,{control:a.control,name:"speed_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.speed_limit")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value||"",onChange:d=>i.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(D,{})]})}),e.jsx(j,{control:a.control,name:"device_limit",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.device_limit")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(T,{type:"number",value:i.value||"",onChange:d=>i.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(D,{})]})}),e.jsx(j,{control:a.control,name:"is_admin",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(G,{checked:i.value===1,onCheckedChange:d=>i.onChange(d?1:0)})})})]})}),e.jsx(j,{control:a.control,name:"is_staff",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(G,{checked:i.value===1,onCheckedChange:d=>i.onChange(d?1:0)})})})]})}),e.jsx(j,{control:a.control,name:"remarks",render:({field:i})=>e.jsxs(g,{children:[e.jsx(b,{children:n("edit.form.remarks")}),e.jsx(_,{children:e.jsx(Cs,{className:"h-24",value:i.value||"",onChange:d=>i.onChange(d.currentTarget.value??null),placeholder:n("edit.form.remarks_placeholder")})}),e.jsx(D,{})]})}),e.jsxs(Gr,{children:[e.jsx(R,{variant:"outline",onClick:()=>r(!1),children:n("edit.form.cancel")}),e.jsx(R,{type:"submit",onClick:()=>{a.handleSubmit(i=>{km(i).then(({data:d})=>{d&&($.success(n("edit.form.success")),r(!1),s())})})()},children:n("edit.form.submit")})]})]})}function Kr({refetch:s,defaultValues:n,dialogTrigger:a=e.jsxs(R,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),t("edit.button")]})}){const{t:l}=M("user"),[r,c]=m.useState(!1);return e.jsx(Bp,{defaultValues:n,open:r,onOpenChange:c,children:e.jsxs(Ur,{open:r,onOpenChange:c,children:[e.jsx($r,{asChild:!0,children:a}),e.jsxs(fa,{className:"max-w-[90%] space-y-4",children:[e.jsxs(ga,{children:[e.jsx(ja,{children:l("edit.title")}),e.jsx(ba,{})]}),e.jsx(Yp,{refetch:s})]})]})})}const 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:"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"})}),Wr=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"})}),Jp=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"})}),Qp=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"})}),$t=[{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:rd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:Ze(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wr,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:Ze(s.original.d)})]})},{accessorKey:"server_rate",header:"倍率",cell:({row:s})=>{const n=s.original.server_rate;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(H,{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:Ze(n)})}}];function Yr({user_id:s,dialogTrigger:n}){const{t:a}=M(["traffic"]),[l,r]=m.useState(!1),[c,o]=m.useState({pageIndex:0,pageSize:20}),{data:u,isLoading:h}=se({queryKey:["userStats",s,c,l],queryFn:()=>l?Dm({user_id:s,pageSize:c.pageSize,page:c.pageIndex+1}):null}),i=Ae({data:u?.data??[],columns:$t,pageCount:Math.ceil((u?.total??0)/c.pageSize),state:{pagination:c},manualPagination:!0,getCoreRowModel:Fe(),onPaginationChange:o});return e.jsxs(ge,{open:l,onOpenChange:r,children:[e.jsx(Le,{asChild:!0,children:n}),e.jsxs(pe,{className:"sm:max-w-[700px]",children:[e.jsx(be,{children:e.jsx(je,{children:a("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(da,{children:[e.jsx(ma,{children:i.getHeaderGroups().map(d=>e.jsx(bs,{children:d.headers.map(f=>e.jsx(ha,{className:y("h-10 px-2 text-xs",f.id==="total"&&"text-right"),children:f.isPlaceholder?null:vt(f.column.columnDef.header,f.getContext())},f.id))},d.id))}),e.jsx(ua,{children:h?Array.from({length:c.pageSize}).map((d,f)=>e.jsx(bs,{children:Array.from({length:$t.length}).map((P,E)=>e.jsx(Us,{className:"p-2",children:e.jsx(Ee,{className:"h-6 w-full"})},E))},f)):i.getRowModel().rows?.length?i.getRowModel().rows.map(d=>e.jsx(bs,{"data-state":d.getIsSelected()&&"selected",className:"h-10",children:d.getVisibleCells().map(f=>e.jsx(Us,{className:"px-2",children:vt(f.column.columnDef.cell,f.getContext())},f.id))},d.id)):e.jsx(bs,{children:e.jsx(Us,{colSpan:$t.length,className:"h-24 text-center",children:a("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:a("trafficRecord.perPage")}),e.jsxs(W,{value:`${i.getState().pagination.pageSize}`,onValueChange:d=>{i.setPageSize(Number(d))},children:[e.jsx(K,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:i.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50].map(d=>e.jsx(U,{value:`${d}`,children:d},d))})]}),e.jsx("p",{className:"text-sm font-medium",children:a("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:a("trafficRecord.page",{current:i.getState().pagination.pageIndex+1,total:i.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>i.previousPage(),disabled:!i.getCanPreviousPage()||h,children:e.jsx(Jp,{className:"h-4 w-4"})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>i.nextPage(),disabled:!i.getCanNextPage()||h,children:e.jsx(Qp,{className:"h-4 w-4"})})]})]})]})]})]})]})}const Zp=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M5 18h4.24a1 1 0 0 0 .71-.29l6.92-6.93L19.71 8a1 1 0 0 0 0-1.42l-4.24-4.29a1 1 0 0 0-1.42 0l-2.82 2.83l-6.94 6.93a1 1 0 0 0-.29.71V17a1 1 0 0 0 1 1m9.76-13.59l2.83 2.83l-1.42 1.42l-2.83-2.83ZM6 13.17l5.93-5.93l2.83 2.83L8.83 16H6ZM21 20H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2"})}),Xp=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"})}),ex=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"})}),sx=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"})}),tx=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"})}),ax=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"})}),nx=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"})}),rx=(s,n)=>{const{t:a}=M("user");return[{accessorKey:"is_admin",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r)),size:0},{accessorKey:"is_staff",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r)),size:0},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(H,{variant:"outline",children:l.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.email")}),cell:({row:l})=>{const r=l.original.t||0,c=Date.now()/1e3-r<120,o=Math.floor(Date.now()/1e3-r);let u=c?a("columns.online_status.online"):r===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:me(r)});if(!c&&r!==0){const h=Math.floor(o/60),i=Math.floor(h/60),d=Math.floor(i/24);d>0?u+=` `+a("columns.online_status.offline_duration.days",{count:d}):i>0?u+=`