small-package/luci-app-openclash/root/usr/share/openclash/dashboard/assets/index.d65730af.js

3 lines
50 KiB
JavaScript

var nt=Object.defineProperty,st=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var $e=(e,t,n)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))at.call(t,n)&&$e(e,n,t[n]);if(Fe)for(var n of Fe(t))rt.call(t,n)&&$e(e,n,t[n]);return e},k=(e,t)=>st(e,ot(t));import{j as c,c as v,a as s,r as d,f as Le,E as Ie,R as le,b as it,d as G,e as ye,u as Be,g as lt,h as R,i as Te,k as xe,Z as V,l as ct,m as ge,n as ut,o as ve,p as dt,q as mt,s as ht,t as te,v as pt,F as ce,A as ft,w as yt,x as xt,N as gt,S as vt,y as Re,z as wt,H as Ct}from"./vendor.fda3e1c9.js";const bt=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const r of a)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const r={};return a.integrity&&(r.integrity=a.integrity),a.referrerpolicy&&(r.referrerPolicy=a.referrerpolicy),a.crossorigin==="use-credentials"?r.credentials="include":a.crossorigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(a){if(a.ep)return;a.ep=!0;const r=n(a);fetch(a.href,r)}};bt();function Y(){return navigator.userAgent==="ClashX Runtime"}let E=null;class Nt{constructor(t){this.instance=null,window.WebViewJavascriptBridge!=null&&(this.instance=window.WebViewJavascriptBridge),this.initBridge(n=>{this.instance=n,t()})}initBridge(t){if(!Y())return t==null?void 0:t(null);if(window.WebViewJavascriptBridge!=null)return t(window.WebViewJavascriptBridge);if(window.WVJBCallbacks!=null)return window.WVJBCallbacks.push(t);window.WVJBCallbacks=[t];const n=document.createElement("iframe");n.style.display="none",n.src="https://__bridge_loaded__",document.documentElement.appendChild(n),setTimeout(()=>document.documentElement.removeChild(n),0)}async callHandler(t,n){return await new Promise(o=>{var a;(a=this.instance)==null||a.callHandler(t,n,o)})}async ping(){return await this.callHandler("ping")}async readConfigString(){return await this.callHandler("readConfigString")}async getPasteboard(){return await this.callHandler("getPasteboard")}async getAPIInfo(){return await this.callHandler("apiInfo")}async setPasteboard(t){return await this.callHandler("setPasteboard",t)}async writeConfigWithString(t){return await this.callHandler("writeConfigWithString",t)}async setSystemProxy(t){return await this.callHandler("setSystemProxy",t)}async getStartAtLogin(){return await this.callHandler("getStartAtLogin")}async getProxyDelay(t){return await this.callHandler("speedTest",t)}async setStartAtLogin(t){return await this.callHandler("setStartAtLogin",t)}async isSystemProxySet(){return await this.callHandler("isSystemProxySet")}}function Pt(e){if(E!=null){e();return}E=new Nt(e)}function W(e){const{title:t,children:n,className:o,style:a}=e;return c("header",{className:v("header",o),style:a,children:[s("h1",{className:"md:text-xl",children:t}),s("div",{className:"flex flex-auto items-center justify-end",children:n})]})}function M(e){const{type:t,size:n=14,className:o,style:a}=e,r=v("clash-iconfont",`icon-${t}`,o),i=P({fontSize:n},a),l=k(P({},e),{className:r,style:i});return s("i",P({},l))}function j(){}function Et(e,t){const n=[],o=[];for(const a of e)t(a)?n.push(a):o.push(a);return[n,o]}function H(e){const t=["B","KB","MB","GB","TB"];let n=0;for(;~~(e/1024)&&n<t.length;)e/=1024,n++;return`${n===0?e:e.toFixed(2)} ${t[n]}`}function we(e){const{className:t,checked:n=!1,disabled:o=!1,onChange:a=j}=e,r=v("switch",{checked:n,disabled:o},t);function i(){o||a(!n)}return s("div",{className:r,onClick:i,children:s(M,{className:"switch-icon font-bold",type:"check",size:20})})}const U=d.exports.forwardRef((e,t)=>{const{className:n,style:o,children:a}=e;return s("div",{className:v("card",n),style:o,ref:t,children:a})});function Me(e){const{options:t,value:n,onSelect:o}=e;return s("div",{className:"button-select",children:t.map(a=>s("button",{value:a.value,className:v("button-select-options",{actived:n===a.value}),onClick:()=>o==null?void 0:o(a.value),children:a.label},a.value))})}const St={SideBar:{Proxies:"Proxies",Overview:"Overview",Logs:"Logs",Rules:"Rules",Settings:"Setting",Connections:"Connections",Version:"Version"},Settings:{title:"Settings",labels:{startAtLogin:"Start at login",language:"language",setAsSystemProxy:"Set as system proxy",allowConnectFromLan:"Allow connect from Lan",proxyMode:"Mode",socks5ProxyPort:"Socks5 proxy port",httpProxyPort:"HTTP proxy port",mixedProxyPort:"Mixed proxy port",externalController:"External controller"},values:{cn:"\u4E2D\u6587",en:"English",global:"Global",rules:"Rules",direct:"Direct",script:"Script"},versionString:"Current ClashX is the latest version\uFF1A{{version}}",checkUpdate:"Check Update",externalControllerSetting:{title:"External Controller",note:"Please note that modifying this configuration will only configure Dashboard. Will not modify your Clash configuration file. Please make sure that the external controller address matches the address in the Clash configuration file, otherwise, Dashboard will not be able to connect to Clash.",host:"Host",port:"Port",secret:"Secret"}},Logs:{title:"Logs"},Rules:{title:"Rules",providerTitle:"Providers",providerUpdateTime:"Last updated at",ruleCount:"Rule count"},Connections:{title:"Connections",keepClosed:"Keep closed connections",total:{text:"total",upload:"upload",download:"download"},closeAll:{title:"Warning",content:"This would close all connections"},filter:{all:"All"},columns:{host:"Host",network:"Network",type:"Type",chains:"Chains",rule:"Rule",time:"Time",speed:"Speed",upload:"Upload",download:"Download",sourceIP:"Source IP"},info:{title:"Connection",id:"ID",host:"Host",hostEmpty:"Empty",dstIP:"IP",dstIPEmpty:"Empty",srcIP:"Source",upload:"Upload",download:"Download",network:"Network",inbound:"Inbound",rule:"Rule",chains:"Chains",status:"Status",opening:"Open",closed:"Closed",closeConnection:"Close"}},Proxies:{title:"Proxies",editDialog:{title:"Edit Proxy",color:"Color",name:"Name",type:"Type",server:"Server",port:"Port",password:"Password",cipher:"Cipher",obfs:"Obfs","obfs-host":"Obfs-host",uuid:"UUID",alterId:"AlterId",tls:"TLS"},groupTitle:"Policy Group",providerTitle:"Providers",providerUpdateTime:"Last updated at",expandText:"Expand",collapseText:"Collapse",speedTestText:"Speed Test",breakConnectionsText:"Close connections which include the group"},Modal:{ok:"Ok",cancel:"Cancel"}},kt={SideBar:{Proxies:"\u4EE3\u7406",Overview:"\u603B\u89C8",Logs:"\u65E5\u5FD7",Rules:"\u89C4\u5219",Settings:"\u8BBE\u7F6E",Connections:"\u8FDE\u63A5",Version:"\u7248\u672C"},Settings:{title:"\u8BBE\u7F6E",labels:{startAtLogin:"\u5F00\u673A\u65F6\u542F\u52A8",language:"\u8BED\u8A00",setAsSystemProxy:"\u8BBE\u7F6E\u4E3A\u7CFB\u7EDF\u4EE3\u7406",allowConnectFromLan:"\u5141\u8BB8\u6765\u81EA\u5C40\u57DF\u7F51\u7684\u8FDE\u63A5",proxyMode:"\u4EE3\u7406\u6A21\u5F0F",socks5ProxyPort:"Socks5 \u4EE3\u7406\u7AEF\u53E3",httpProxyPort:"HTTP \u4EE3\u7406\u7AEF\u53E3",mixedProxyPort:"\u6DF7\u5408\u4EE3\u7406\u7AEF\u53E3",externalController:"\u5916\u90E8\u63A7\u5236\u8BBE\u7F6E"},values:{cn:"\u4E2D\u6587",en:"English",global:"\u5168\u5C40",rules:"\u89C4\u5219",direct:"\u76F4\u8FDE",script:"\u811A\u672C"},versionString:"\u5F53\u524D ClashX \u5DF2\u662F\u6700\u65B0\u7248\u672C\uFF1A{{version}}",checkUpdate:"\u68C0\u67E5\u66F4\u65B0",externalControllerSetting:{title:"\u7F16\u8F91\u5916\u90E8\u63A7\u5236\u8BBE\u7F6E",note:"\u8BF7\u6CE8\u610F\uFF0C\u4FEE\u6539\u8BE5\u914D\u7F6E\u9879\u5E76\u4E0D\u4F1A\u4FEE\u6539\u4F60\u7684 Clash \u914D\u7F6E\u6587\u4EF6\uFF0C\u8BF7\u786E\u8BA4\u4FEE\u6539\u540E\u7684\u5916\u90E8\u63A7\u5236\u5730\u5740\u548C Clash \u914D\u7F6E\u6587\u4EF6\u5185\u7684\u5730\u5740\u4E00\u81F4\uFF0C\u5426\u5219\u4F1A\u5BFC\u81F4 Dashboard \u65E0\u6CD5\u8FDE\u63A5\u3002",host:"Host",port:"\u7AEF\u53E3",secret:"\u5BC6\u94A5"}},Logs:{title:"\u65E5\u5FD7"},Rules:{title:"\u89C4\u5219",providerTitle:"\u89C4\u5219\u96C6",providerUpdateTime:"\u6700\u540E\u66F4\u65B0\u4E8E",ruleCount:"\u89C4\u5219\u6761\u6570"},Connections:{title:"\u8FDE\u63A5",keepClosed:"\u4FDD\u7559\u5173\u95ED\u8FDE\u63A5",total:{text:"\u603B\u91CF",upload:"\u4E0A\u4F20",download:"\u4E0B\u8F7D"},closeAll:{title:"\u8B66\u544A",content:"\u5C06\u4F1A\u5173\u95ED\u6240\u6709\u8FDE\u63A5"},filter:{all:"\u5168\u90E8"},columns:{host:"\u57DF\u540D",network:"\u7F51\u7EDC",type:"\u7C7B\u578B",chains:"\u8282\u70B9\u94FE",rule:"\u89C4\u5219",time:"\u8FDE\u63A5\u65F6\u95F4",speed:"\u901F\u7387",upload:"\u4E0A\u4F20",download:"\u4E0B\u8F7D",sourceIP:"\u6765\u6E90 IP"},info:{title:"\u8FDE\u63A5\u4FE1\u606F",id:"ID",host:"\u57DF\u540D",hostEmpty:"\u7A7A",dstIP:"IP",dstIPEmpty:"\u7A7A",srcIP:"\u6765\u6E90",upload:"\u4E0A\u4F20",download:"\u4E0B\u8F7D",network:"\u7F51\u7EDC",inbound:"\u5165\u53E3",rule:"\u89C4\u5219",chains:"\u4EE3\u7406",status:"\u72B6\u6001",opening:"\u8FDE\u63A5\u4E2D",closed:"\u5DF2\u5173\u95ED",closeConnection:"\u5173\u95ED\u8FDE\u63A5"}},Proxies:{title:"\u4EE3\u7406",editDialog:{title:"\u7F16\u8F91\u4EE3\u7406",color:"\u989C\u8272",name:"\u540D\u5B57",type:"\u7C7B\u578B",server:"\u670D\u52A1\u5668",port:"\u7AEF\u53E3",password:"\u5BC6\u7801",cipher:"\u52A0\u5BC6\u65B9\u5F0F",obfs:"Obfs","obfs-host":"Obfs-host",uuid:"UUID",alterId:"AlterId",tls:"TLS"},groupTitle:"\u7B56\u7565\u7EC4",providerTitle:"\u4EE3\u7406\u96C6",providerUpdateTime:"\u6700\u540E\u66F4\u65B0\u4E8E",expandText:"\u5C55\u5F00",collapseText:"\u6536\u8D77",speedTestText:"\u6D4B\u901F",breakConnectionsText:"\u5207\u6362\u65F6\u6253\u65AD\u5305\u542B\u7B56\u7565\u7EC4\u7684\u8FDE\u63A5"},Modal:{ok:"\u786E \u5B9A",cancel:"\u53D6 \u6D88"}},He={en_US:St,zh_CN:kt},Dt=Object.keys(He);function At(){for(const e of window.navigator.languages){if(e.includes("zh"))return"zh_CN";if(e.includes("us"))return"en_US"}return"en_US"}function Ce(e){return d.exports.useMemo(()=>{function n(o,a){if(typeof o=="string")e(r=>{const i=o,l=a;r[i]=l});else if(typeof o=="function"){const r=o;e(i=>r(i))}else typeof o=="object"&&e(r=>Le(r,i=>{const l=o;for(const u of Object.keys(l)){const f=u;i[f]=l[f]}}))}return n},[e])}class Ue{constructor(t){this.EE=new Ie,this.innerBuffer=[],this.isClose=!1,this.config=Object.assign({bufferLength:0,retryInterval:5e3,headers:{}},t),this.config.useWebsocket?this.websocketLoop():this.loop()}websocketLoop(){var o;const t=new URL(this.config.url);t.protocol=t.protocol==="http:"?"ws:":"wss:",t.searchParams.set("token",(o=this.config.token)!=null?o:"");const n=new WebSocket(t.toString());n.addEventListener("message",a=>{const r=JSON.parse(a.data);this.EE.emit("data",[r]),this.config.bufferLength>0&&(this.innerBuffer.push(r),this.innerBuffer.length>this.config.bufferLength&&this.innerBuffer.splice(0,this.innerBuffer.length-this.config.bufferLength))}),n.addEventListener("close",()=>setTimeout(this.websocketLoop,this.config.retryInterval)),n.addEventListener("error",a=>{this.EE.emit("error",a),setTimeout(this.websocketLoop,this.config.retryInterval)})}async loop(){const t=await le.fromPromise(fetch(this.config.url,{mode:"cors",headers:this.config.token?{Authorization:`Bearer ${this.config.token}`}:{}}),a=>a);if(t.isErr()){this.retry(t.error);return}else if(t.value.body==null){this.retry(new Error("fetch body error"));return}const n=t.value.body.getReader(),o=new TextDecoder;for(;!this.isClose;){const a=await le.fromPromise(n==null?void 0:n.read(),l=>l);if(a.isErr()){this.retry(a.error);break}const i=o.decode(a.value.value).trim().split(`
`).map(l=>JSON.parse(l));this.EE.emit("data",i),this.config.bufferLength>0&&(this.innerBuffer.push(...i),this.innerBuffer.length>this.config.bufferLength&&this.innerBuffer.splice(0,this.innerBuffer.length-this.config.bufferLength))}}retry(t){this.isClose||(this.EE.emit("error",t),window.setTimeout(()=>{this.loop()},this.config.retryInterval))}subscribe(t,n){this.EE.addListener(t,n)}unsubscribe(t,n){this.EE.removeListener(t,n)}buffer(){return this.innerBuffer.slice()}destory(){this.EE.removeAllListeners(),this.isClose=!0}}class Ft{constructor(t,n){this.axiosClient=it.create({baseURL:t,headers:n?{Authorization:`Bearer ${n}`}:{}})}async getConfig(){return await this.axiosClient.get("configs")}async updateConfig(t){return await this.axiosClient.patch("configs",t)}async getRules(){return await this.axiosClient.get("rules")}async getProxyProviders(){const t=await this.axiosClient.get("providers/proxies",{validateStatus(n){return n>=200&&n<300||n===404}});return t.status===404&&(t.data={providers:{}}),t}async getRuleProviders(){return await this.axiosClient.get("providers/rules")}async updateProvider(t){return await this.axiosClient.put(`providers/proxies/${encodeURIComponent(t)}`)}async updateRuleProvider(t){return await this.axiosClient.put(`providers/rules/${encodeURIComponent(t)}`)}async healthCheckProvider(t){return await this.axiosClient.get(`providers/proxies/${encodeURIComponent(t)}/healthcheck`)}async getProxies(){return await this.axiosClient.get("proxies")}async getProxy(t){return await this.axiosClient.get(`proxies/${encodeURIComponent(t)}`)}async getVersion(){return await this.axiosClient.get("version")}async getProxyDelay(t){return await this.axiosClient.get(`proxies/${encodeURIComponent(t)}/delay`,{params:{timeout:5e3,url:"http://www.gstatic.com/generate_204"}})}async closeAllConnections(){return await this.axiosClient.delete("connections")}async closeConnection(t){return await this.axiosClient.delete(`connections/${t}`)}async getConnections(){return await this.axiosClient.get("connections")}async changeProxySelected(t,n){return await this.axiosClient.put(`proxies/${encodeURIComponent(t)}`,{name:n})}}const $t=G(async()=>{if(!Y())return null;const e=await E.getAPIInfo();return{hostname:e.host,port:e.port,secret:e.secret,protocol:"http:"}}),Oe=ye("externalControllers",[]);function ne(){var f,h,p,y,x,N,F,$,I,A,S,B,J,X,_;const e=Be($t),t=lt(),n=Be(Oe);if(e!=null)return e;let o;{const O=document.querySelector('meta[name="external-controller"]');((f=O==null?void 0:O.content)==null?void 0:f.match(/^https?:/))!=null&&(o=new URL(O.content))}const a=new URLSearchParams(t.search),r=(x=(y=(p=a.get("host"))!=null?p:(h=n==null?void 0:n[0])==null?void 0:h.hostname)!=null?y:o==null?void 0:o.hostname)!=null?x:"127.0.0.1",i=(I=($=(F=a.get("port"))!=null?F:(N=n==null?void 0:n[0])==null?void 0:N.port)!=null?$:o==null?void 0:o.port)!=null?I:"9090",l=(J=(B=(S=a.get("secret"))!=null?S:(A=n==null?void 0:n[0])==null?void 0:A.secret)!=null?B:o==null?void 0:o.username)!=null?J:"",u=((X=a.get("protocol"))!=null?X:r==="127.0.0.1")?"http:":(_=o==null?void 0:o.protocol)!=null?_:window.location.protocol;return{hostname:r,port:i,secret:l,protocol:u}}const Lt=G({key:"",instance:null});function L(){const{hostname:e,port:t,secret:n,protocol:o}=ne(),[a,r]=R(Lt),i=`${o}//${e}:${t}?secret=${n}`;if(a.key===i)return a.instance;const l=new Ft(`${o}//${e}:${t}`,n);return r({key:i,instance:l}),l}const be=G(!0),It=ye("language",void 0);function D(){const[e,t]=R(It),n=d.exports.useMemo(()=>e!=null?e:At(),[e]),o=d.exports.useCallback(function(a){function r(i){return ct(He[n][a],i)}return{t:r}},[n]);return{lang:n,locales:Dt,setLang:t,translation:o}}const ze=G({version:"",premium:!1});function ue(){const[e,t]=R(ze),n=L(),o=xe(be);return V([n],async function(){const a=await le.fromPromise(n.getVersion(),r=>r);o(a.isOk()),t(a.isErr()?{version:"",premium:!1}:{version:a.value.data.version,premium:!!a.value.data.premium})}),e}function We(){const[{premium:e}]=R(ze),t=L(),{data:n,mutate:o}=V(["/providers/rule",t,e],async()=>{if(!e)return[];const a=await t.getRuleProviders();return Object.keys(a.data.providers).map(r=>a.data.providers[r])});return{providers:n!=null?n:[],update:o}}const Bt=ye("profile",{breakConnections:!1});function je(){const[e,t]=R(Bt),n=d.exports.useCallback(o=>{t(Le(e,o))},[e,t]);return{data:e,set:Ce(n)}}const _e=G([]);function Ge(){const[e,t]=R(_e),n=L(),{data:o,mutate:a}=V(["/providers/proxy",n],async()=>{const r=await n.getProxyProviders();return Object.keys(r.data.providers).map(i=>r.data.providers[i]).filter(i=>i.name!=="default").filter(i=>i.vehicleType!=="Compatible")});return d.exports.useEffect(()=>{t(o!=null?o:[])},[o,t]),{providers:e,update:a}}function Ne(){const e=L(),{data:t,mutate:n}=V(["/config",e],async()=>{var r;const a=(await e.getConfig()).data;return{port:a.port,socksPort:a["socks-port"],mixedPort:(r=a["mixed-port"])!=null?r:0,redirPort:a["redir-port"],mode:a.mode.toLowerCase(),logLevel:a["log-level"],allowLan:a["allow-lan"]}});return{general:t!=null?t:{},update:n}}const Ve=Te({proxies:[],groups:[],global:{name:"GLOBAL",type:"Selector",now:"",history:[],all:[]}});function de(){const[e,t]=R(Ve),n=Ce(t),o=L(),{mutate:a}=V(["/proxies",o],async()=>{const i=await o.getProxies(),l=i.data.proxies.GLOBAL;l.name="GLOBAL";const u=new Set(["Selector","URLTest","Fallback","LoadBalance"]),f=new Set(["DIRECT","REJECT","GLOBAL"]),h=l.all.filter(x=>!f.has(x)).map(x=>k(P({},i.data.proxies[x]),{name:x})),[p,y]=Et(h,x=>!u.has(x.type));n({proxies:p,groups:y,global:l})}),r=d.exports.useCallback((i,l)=>{n(u=>{i==="GLOBAL"&&(u.global.now=l);for(const f of u.groups)f.name===i&&(f.now=l)})},[n]);return{proxies:e.proxies,groups:e.groups,global:e.global,update:a,markProxySelected:r,set:n}}const Tt=G(e=>{const t=e(Ve),n=e(_e),o=new Map;for(const a of t.proxies)o.set(a.name,a);for(const a of n)for(const r of a.proxies)o.set(r.name,r);return o});function Je(){const{data:e,mutate:t}=V("/clashx",async()=>{var a,r;if(!Y())return{isClashX:!1,startAtLogin:!1,systemProxy:!1};const n=(a=await(E==null?void 0:E.getStartAtLogin()))!=null?a:!1,o=(r=await(E==null?void 0:E.isSystemProxySet()))!=null?r:!1;return{startAtLogin:n,systemProxy:o,isClashX:!0}});return{data:e,update:t}}const Rt=Te([]);function Mt(){const[e,t]=R(Rt),n=Ce(t),o=L();async function a(){const r=await o.getRules();n(r.data.rules)}return{rules:e,update:a}}const Ht=G({key:"",instance:null});function Xe(){var h,p;const e=ne(),{general:t}=Ne(),n=ue(),[o,a]=R(Ht);if(!n.version||!t.logLevel)return null;const r=!!n.version||!0,i=`${e.protocol}//${e.hostname}:${e.port}/logs?level=${(h=t.logLevel)!=null?h:""}&useWebsocket=${r}&secret=${e.secret}`;if(o.key===i)return o.instance;const l=o.instance,u=`${e.protocol}//${e.hostname}:${e.port}/logs?level=${(p=t.logLevel)!=null?p:""}`,f=new Ue({url:u,bufferLength:200,token:e.secret,useWebsocket:r});return a({key:i,instance:f}),l!=null&&l.destory(),f}function Ut(){const e=ne(),t=ue(),n=!!t.version||!0,o=`${e.protocol}//${e.hostname}:${e.port}/connections`;return d.exports.useMemo(()=>t.version?new Ue({url:o,bufferLength:200,token:e.secret,useWebsocket:n}):null,[e.secret,o,n,t.version])}function Ot(e){const{className:t,data:n,onClick:o,select:a,canClick:r,errSet:i,rowHeight:l}=e,{translation:u}=D(),{t:f}=u("Proxies"),[h,p]=d.exports.useState(!1),[y,x]=d.exports.useState(!1),N=d.exports.useRef(null);d.exports.useLayoutEffect(()=>{var S,B;x(((B=(S=N==null?void 0:N.current)==null?void 0:S.offsetHeight)!=null?B:0)>30)},[]);const F=h?"auto":l,$=r?o:j;function I(){p(!h)}const A=n.map(S=>{const B=v({"tags-selected":a===S,"cursor-pointer":r,error:i==null?void 0:i.has(S)});return s("li",{className:B,onClick:()=>$(S),children:S},S)});return c("div",{className:v("flex items-start overflow-y-hidden",t),style:{height:F},children:[s("ul",{ref:N,className:v("tags",{expand:h}),children:A}),y&&s("span",{className:"h-7 px-5 select-none cursor-pointer leading-7",onClick:I,children:f(h?"collapseText":"expandText")})]})}function q(e){const{className:t,style:n,value:o="",align:a="center",inside:r=!1,autoFocus:i=!1,type:l="text",disabled:u=!1,onChange:f=j,onBlur:h=j}=e,p=v("input",`text-${a}`,{"focus:shadow-none":r},t);return s("input",{disabled:u,className:p,style:n,value:o,autoFocus:i,type:l,onChange:y=>f(y.target.value,y),onBlur:h})}function Ye(e){const{show:t=!0,title:n="Modal",size:o="small",footer:a=!0,onOk:r=j,onClose:i=j,bodyClassName:l,bodyStyle:u,className:f,style:h,children:p}=e,{translation:y}=D(),{t:x}=y("Modal"),N=d.exports.useRef(document.createElement("div")),F=d.exports.useRef(null);d.exports.useLayoutEffect(()=>{const A=N.current;return document.body.appendChild(A),()=>{document.body.removeChild(A)}},[]);function $(A){A.target===F.current&&i()}const I=s("div",{className:v("modal-mask",{"modal-show":t}),ref:F,onMouseDown:$,children:c("div",{className:v("modal",`modal-${o}`,f),style:h,children:[s("div",{className:"modal-title",children:n}),s("div",{className:v("modal-body",l),style:u,children:p}),a&&c("div",{className:"footer",children:[s(Pe,{onClick:()=>i(),children:x("cancel")}),s(Pe,{type:"primary",onClick:()=>r(),children:x("ok")})]})]})});return ge.exports.createPortal(I,N.current)}const zt={success:"check",info:"info",warning:"info",error:"close"};function Wt(e){const{message:t="",type:n="info",inside:o=!1,children:a,className:r,style:i}=e,l=v("alert",`alert-${o?"note":"box"}-${n}`,r);return c("div",{className:l,style:i,children:[s("span",{className:"alert-icon",children:s(M,{type:zt[n],size:26})}),t?s("p",{className:"alert-message",children:t}):s("div",{className:"alert-message",children:a})]})}function Pe(e){const{type:t="normal",onClick:n=j,children:o,className:a,style:r,disiabled:i}=e,l=v("button",`button-${t}`,a,{"button-disabled":i});return s("button",{className:l,style:r,onClick:n,disabled:i,children:o})}function me(e){const[t,n]=ut(e),o=d.exports.useMemo(()=>{function a(r,i){typeof r=="string"?n(l=>{const u=r,f=i;l[u]=f}):typeof r=="function"?n(r):typeof r=="object"&&n(l=>{const u=r;for(const f of Object.keys(u)){const h=f;l[h]=u[h]}})}return a},[n]);return[t,o]}function jt(e,t=0){if(e.length<2)throw new Error("List requires at least two elements");const[n,o]=d.exports.useState(t);function a(){o((n+1)%e.length)}return{current:d.exports.useMemo(()=>e[n],[e,n]),next:a}}function Ee(e=!1){const[t,n]=d.exports.useState(e);function o(){n(!1)}function a(){n(!0)}return{visible:t,hide:o,show:a}}function qe(e){const{className:t,checked:n=!1,onChange:o=j}=e,a=v("checkbox",{checked:n},t);function r(){o(!n)}return c("div",{className:a,onClick:r,children:[s(M,{className:"checkbox-icon",type:"check",size:18}),s("div",{children:e.children})]})}function he(e){const{color:t,className:n,style:o}=e,a=v("tag",n),r=P({color:t},o),i=k(P({},e),{className:a,style:r});return s("span",k(P({},i),{children:e.children}))}function _t(e){const t=v("spinner",e.className);return c("div",{className:t,children:[s("div",{className:"spinner-circle",children:s("div",{className:"spinner-inner"})}),s("div",{className:"spinner-circle",children:s("div",{className:"spinner-inner"})}),s("div",{className:"spinner-circle",children:s("div",{className:"spinner-inner"})}),s("div",{className:"spinner-circle",children:s("div",{className:"spinner-inner"})}),s("div",{className:"spinner-circle",children:s("div",{className:"spinner-inner"})})]})}function Ke(e){const t=v("loading","visible",e.className);return e.visible?s("div",{className:t,children:s(_t,{className:e.spinnerClassName})}):null}function Gt(e){var a,r,i;const t=d.exports.useRef(document.createElement("div"));d.exports.useLayoutEffect(()=>{const l=t.current;return document.body.appendChild(l),()=>{document.body.removeChild(l)}},[]);const n="absolute h-full right-0 transition-transform transform translate-x-full duration-100 pointer-events-auto",o=s("div",{className:v(e.className,"absolute inset-0 pointer-events-none z-9999"),children:s(U,{className:v(n,{"translate-x-0":e.visible}),style:{width:(a=e.width)!=null?a:400},children:e.children})});return ge.exports.createPortal(o,(i=(r=e.containerRef)==null?void 0:r.current)!=null?i:t.current)}ve.extend(dt);function Se(e,t){const n=t==="en_US"?"en":"zh-cn";return ve().locale(n).from(e)}var ke;(function(e){e.Domain="Domain",e.DomainSuffix="DomainSuffix",e.DomainKeyword="DomainKeyword",e.GeoIP="GeoIP",e.IPCIDR="IPCIDR",e.SrcIPCIDR="SrcIPCIDR",e.SrcPort="SrcPort",e.DstPort="DstPort",e.MATCH="MATCH",e.RuleSet="RuleSet"})(ke||(ke={}));function Vt(e){const{translation:t}=D(),n=d.exports.useMemo(()=>t("Connections").t,[t]),{className:o,style:a}=e,r=v("flex flex-wrap px-1",o);function i(l){var u;(u=e.onChange)==null||u.call(e,l)}return c("div",{className:r,style:a,children:[s("div",{className:v("connections-devices-item pt-2 mb-2",{selected:e.selected===""}),onClick:()=>i(""),children:n("filter.all")}),e.devices.map(l=>c("div",{className:v("connections-devices-item pt-2 mb-2",{selected:e.selected===l.label}),onClick:()=>i(l.label),children:[l.label," (",l.number,")"]},l.label))]})}function Jt(e){var o,a,r,i,l,u,f,h,p,y,x;const{translation:t}=D(),n=d.exports.useMemo(()=>t("Connections").t,[t]);return c("div",{className:v(e.className,"text-sm flex flex-col"),children:[c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.id")}),s("span",{className:"font-mono",children:e.connection.id})]}),c("div",{className:"flex justify-between my-3",children:[c("div",{className:"flex flex-1",children:[s("span",{className:"w-16 font-bold",children:n("info.network")}),s("span",{className:"font-mono",children:(o=e.connection.metadata)==null?void 0:o.network})]}),c("div",{className:"flex flex-1",children:[s("span",{className:"w-16 font-bold",children:n("info.inbound")}),s("span",{className:"font-mono",children:(a=e.connection.metadata)==null?void 0:a.type})]})]}),c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.host")}),s("span",{className:"font-mono flex-1 break-all",children:((r=e.connection.metadata)==null?void 0:r.host)?`${e.connection.metadata.host}:${(i=e.connection.metadata)==null?void 0:i.destinationPort}`:n("info.hostEmpty")})]}),c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.dstIP")}),s("span",{className:"font-mono",children:((l=e.connection.metadata)==null?void 0:l.destinationIP)?`${e.connection.metadata.destinationIP}:${(u=e.connection.metadata)==null?void 0:u.destinationPort}`:n("info.hostEmpty")})]}),c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.srcIP")}),s("span",{className:"font-mono",children:`${(f=e.connection.metadata)==null?void 0:f.sourceIP}:${(h=e.connection.metadata)==null?void 0:h.sourcePort}`})]}),c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.rule")}),s("span",{className:"font-mono",children:e.connection.rule&&`${e.connection.rule}${e.connection.rulePayload&&`(${e.connection.rulePayload})`}`})]}),c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.chains")}),s("span",{className:"font-mono flex-1 break-all",children:(p=e.connection.chains)==null?void 0:p.slice().reverse().join(" / ")})]}),c("div",{className:"flex justify-between my-3",children:[c("div",{className:"flex flex-1",children:[s("span",{className:"w-16 font-bold",children:n("info.upload")}),s("span",{className:"font-mono",children:H((y=e.connection.upload)!=null?y:0)})]}),c("div",{className:"flex flex-1",children:[s("span",{className:"w-16 font-bold",children:n("info.download")}),s("span",{className:"font-mono",children:H((x=e.connection.download)!=null?x:0)})]})]}),c("div",{className:"flex my-3",children:[s("span",{className:"w-16 font-bold",children:n("info.status")}),s("span",{className:"font-mono",children:e.connection.completed?s("span",{className:"text-red",children:n("info.closed")}):s("span",{className:"text-green",children:n("info.opening")})})]})]})}class Xt{constructor(){this.connections=new Map,this.saveDisconnection=!1}appendToSet(t){var o;const n=t.reduce((a,r)=>a.set(r.id,r),new Map);for(const a of this.connections.keys())if(!n.has(a))if(!this.saveDisconnection)this.connections.delete(a);else{const r=this.connections.get(a);r!=null&&(r.completed=!0,r.uploadSpeed=0,r.downloadSpeed=0)}for(const a of n.keys()){if(!this.connections.has(a)){this.connections.set(a,k(P({},n.get(a)),{uploadSpeed:0,downloadSpeed:0}));continue}const r=this.connections.get(a),i=n.get(a);(o=this.connections)==null||o.set(a,k(P({},i),{uploadSpeed:i.upload-r.upload,downloadSpeed:i.download-r.download}))}}toggleSave(){var t,n;if(this.saveDisconnection){this.saveDisconnection=!1;for(const o of this.connections.keys())((n=(t=this.connections)==null?void 0:t.get(o))==null?void 0:n.completed)&&this.connections.delete(o)}else this.saveDisconnection=!0;return this.saveDisconnection}getConnections(){return[...this.connections.values()]}}function Yt(){const e=d.exports.useMemo(()=>new Xt,[]),t=d.exports.useRef(!0),[n,o]=d.exports.useState([]),[a,r]=d.exports.useState(!1),i=d.exports.useCallback(function(u){e.appendToSet(u),t.current&&o(e.getConnections()),t.current=!t.current},[e]),l=d.exports.useCallback(function(){const u=e.toggleSave();r(u),u||o(e.getConnections()),t.current=!0},[e]);return{connections:n,feed:i,toggleSave:l,save:a}}var g;(function(e){e.Host="host",e.Network="network",e.Type="type",e.Chains="chains",e.Rule="rule",e.Speed="speed",e.Upload="upload",e.Download="download",e.SourceIP="sourceIP",e.Time="time"})(g||(g={}));const qt=new Set([g.Network,g.Type,g.Rule,g.Speed,g.Upload,g.Download,g.SourceIP,g.Time]);function Kt(e,t){switch(!0){case(e===0&&t===0):return"-";case(e!==0&&t!==0):return`\u2191 ${H(e)}/s \u2193 ${H(t)}/s`;case e!==0:return`\u2191 ${H(e)}/s`;default:return`\u2193 ${H(t)}/s`}}function Zt(){const{translation:e,lang:t}=D(),n=d.exports.useMemo(()=>e("Connections").t,[e]),o=Ut(),a=L(),r=d.exports.useRef(null),[i,l]=me({uploadTotal:0,downloadTotal:0}),{visible:u,show:f,hide:h}=Ee();function p(){a.closeAllConnections().finally(()=>h())}const{connections:y,feed:x,save:N,toggleSave:F}=Yt(),$=d.exports.useMemo(()=>y.map(m=>({id:m.id,host:`${m.metadata.host||m.metadata.destinationIP}:${m.metadata.destinationPort}`,chains:m.chains.slice().reverse().join(" / "),rule:m.rule===ke.RuleSet?`${m.rule}(${m.rulePayload})`:m.rule,time:new Date(m.start).getTime(),upload:m.upload,download:m.download,sourceIP:m.metadata.sourceIP,type:m.metadata.type,network:m.metadata.network.toUpperCase(),speed:{upload:m.uploadSpeed,download:m.downloadSpeed},completed:!!m.completed,original:m})),[y]),I=d.exports.useMemo(()=>{const m=mt(y,"metadata.sourceIP");return Object.keys(m).map(b=>({label:b,number:m[b].length})).sort((b,C)=>b.label.localeCompare(C.label))},[y]),A=d.exports.useRef(null),{x:S}=ht(A),B=d.exports.useMemo(()=>[{Header:n(`columns.${g.Host}`),accessor:g.Host,minWidth:260,width:260},{Header:n(`columns.${g.Network}`),accessor:g.Network,minWidth:80,width:80},{Header:n(`columns.${g.Type}`),accessor:g.Type,minWidth:120,width:120},{Header:n(`columns.${g.Chains}`),accessor:g.Chains,minWidth:200,width:200},{Header:n(`columns.${g.Rule}`),accessor:g.Rule,minWidth:140,width:140},{id:g.Speed,Header:n(`columns.${g.Speed}`),accessor(m){return[m.speed.upload,m.speed.download]},sortType(m,b){const C=m.original.speed,ee=b.original.speed;return C.download===ee.download?C.upload-ee.upload:C.download-ee.download},minWidth:200,width:200,sortDescFirst:!0},{Header:n(`columns.${g.Upload}`),accessor:g.Upload,minWidth:100,width:100,sortDescFirst:!0},{Header:n(`columns.${g.Download}`),accessor:g.Download,minWidth:100,width:100,sortDescFirst:!0},{Header:n(`columns.${g.SourceIP}`),accessor:g.SourceIP,minWidth:140,width:140,filter:"equals"},{Header:n(`columns.${g.Time}`),accessor:g.Time,minWidth:120,width:120,sortType(m,b){return b.original.time-m.original.time}}],[n]);d.exports.useLayoutEffect(()=>{function m(b){for(const C of b)l({uploadTotal:C.uploadTotal,downloadTotal:C.downloadTotal}),x(C.connections)}return o==null||o.subscribe("data",m),()=>{o==null||o.unsubscribe("data",m),o==null||o.destory()}},[o,x,l]);const{getTableProps:J,getTableBodyProps:X,headerGroups:_,rows:O,prepareRow:pe,setFilter:K}=te.exports.useTable({columns:B,data:$,autoResetSortBy:!1,autoResetFilters:!1,initialState:{sortBy:[{id:g.Time,desc:!1}]}},te.exports.useResizeColumns,te.exports.useBlockLayout,te.exports.useFilters,te.exports.useSortBy),Z=d.exports.useMemo(()=>_[0],[_]),z=d.exports.useCallback(function(m){switch(m.column.id){case g.Speed:return Kt(m.value[0],m.value[1]);case g.Upload:case g.Download:return H(m.value);case g.Time:return Se(new Date(m.value),t);default:return m.value}},[t]),[fe,oe]=d.exports.useState("");function ae(m){oe(m),K==null||K(g.SourceIP,m||void 0)}const[T,w]=me({visible:!1,selectedID:"",connection:{}});function re(m){w({visible:!0,selectedID:m})}function ie(){w(m=>{m.connection.completed=!0}),a.closeConnection(T.selectedID)}const Q=pt(T.connection);return d.exports.useEffect(()=>{var b;const m=(b=$.find(C=>C.id===T.selectedID))==null?void 0:b.original;m?w(C=>{C.connection=m,T.selectedID===Q.current.id&&(C.connection.completed=Q.current.completed)}):Object.keys(Q.current).length!==0&&!Q.current.completed&&w(C=>{C.connection.completed=!0})},[$,T.selectedID,Q,w]),c("div",{className:"page",children:[c(W,{title:n("title"),children:[s("span",{className:"connections-filter flex-1 cursor-default",children:`(${n("total.text")}: ${n("total.upload")} ${H(i.uploadTotal)} ${n("total.download")} ${H(i.downloadTotal)})`}),s(qe,{className:"connections-filter",checked:N,onChange:F,children:n("keepClosed")}),s(M,{className:"connections-filter dangerous",onClick:f,type:"close-all",size:20})]}),I.length>1&&s(Vt,{devices:I,selected:fe,onChange:ae}),s(U,{ref:r,className:"connections-card relative",children:c("div",k(P({},J()),{className:"flex flex-col w-full flex-1 overflow-auto",style:{flexBasis:0},ref:A,children:[s("div",k(P({},Z.getHeaderGroupProps()),{className:"connections-header",children:Z.headers.map((m,b)=>{const C=m,ee=C.id;return d.exports.createElement("div",k(P({},C.getHeaderProps()),{className:v("connections-th",{resizing:C.isResizing,fixed:S>0&&C.id===g.Host}),key:ee}),c("div",k(P({},C.getSortByToggleProps()),{children:[m.render("Header"),C.isSorted?C.isSortedDesc?" \u2193":" \u2191":null]})),b!==Z.headers.length-1&&s("div",k(P({},C.getResizerProps()),{className:"connections-resizer"})))})})),s("div",k(P({},X()),{className:"flex-1",children:O.map(m=>(pe(m),d.exports.createElement("div",k(P({},m.getRowProps()),{className:"connections-item cursor-default select-none",key:m.original.id,onClick:()=>re(m.original.id)}),m.cells.map(b=>{const C=v("connections-block",{"text-center":qt.has(b.column.id),completed:m.original.completed},{fixed:S>0&&b.column.id===g.Host});return d.exports.createElement("div",k(P({},b.getCellProps()),{className:C,key:b.column.id}),z(b))}))))}))]}))}),s(Ye,{title:n("closeAll.title"),show:u,onClose:h,onOk:p,children:n("closeAll.content")}),c(Gt,{containerRef:r,visible:T.visible,width:450,children:[c("div",{className:"flex justify-between items-center h-8",children:[s("span",{className:"pl-3 font-bold",children:n("info.title")}),s(M,{type:"close",size:16,className:"cursor-pointer",onClick:()=>w("visible",!1)})]}),s(Jt,{className:"px-5 mt-3",connection:T.connection}),s("div",{className:"flex justify-end mt-3 pr-3",children:s(Pe,{type:"danger",disiabled:T.connection.completed,onClick:()=>ie(),children:n("info.closeConnection")})})]})]})}function Qt(){const{translation:e}=D(),{t}=e("Settings"),{hostname:n,port:o,secret:a}=ne(),[r,i]=R(be),[l,u]=me({hostname:"",port:"",secret:""});d.exports.useEffect(()=>{u({hostname:n,port:o,secret:a})},[n,o,a,u]);const f=xe(Oe);function h(){const{hostname:p,port:y,secret:x}=l;f([{hostname:p,port:y,secret:x}])}return c(Ye,{show:!r,title:t("externalControllerSetting.title"),bodyClassName:"external-controller",onClose:()=>i(!0),onOk:h,children:[s(Wt,{type:"info",inside:!0,children:s("p",{children:t("externalControllerSetting.note")})}),c("div",{className:"flex items-center",children:[s("span",{className:"md:my-3 w-14 my-1 font-bold",children:t("externalControllerSetting.host")}),s(q,{className:"md:my-3 flex-1 my-1",align:"left",inside:!0,value:l.hostname,onChange:p=>u("hostname",p)})]}),c("div",{className:"flex items-center",children:[s("div",{className:"md:my-3 w-14 my-1 font-bold",children:t("externalControllerSetting.port")}),s(q,{className:"md:my-3 w-14 my-1 flex-1",align:"left",inside:!0,value:l.port,onChange:p=>u("port",p)})]}),c("div",{className:"flex items-center",children:[s("div",{className:"md:my-3 w-14 my-1 font-bold",children:t("externalControllerSetting.secret")}),s(q,{className:"md:my-3 w-14 my-1 flex-1",align:"left",inside:!0,value:l.secret,onChange:p=>u("secret",p)})]})]})}function en(){const e=d.exports.useRef(null),t=d.exports.useRef([]),[n,o]=d.exports.useState([]),{translation:a}=D(),{t:r}=a("Logs"),i=Xe();return d.exports.useLayoutEffect(()=>{const l=e.current;l!=null&&(l.scrollTop=l.scrollHeight)}),d.exports.useEffect(()=>{function l(u){t.current=t.current.slice().concat(u.map(f=>k(P({},f),{time:new Date}))),o(t.current)}return i!=null&&(i.subscribe("data",l),t.current=i.buffer(),o(t.current)),()=>i==null?void 0:i.unsubscribe("data",l)},[i]),c("div",{className:"page",children:[s(W,{title:r("title")}),s(U,{className:"flex flex-col flex-1 mt-2.5 md:mt-4",children:s("ul",{className:"logs-panel",ref:e,children:n.map((l,u)=>c("li",{className:"leading-5 inline-block",children:[s("span",{className:"mr-4 text-gray-400 text-opacity-90",children:ve(l.time).format("YYYY-MM-DD HH:mm:ss")}),c("span",{children:["[",l.type,"] ",l.payload]})]},u))})})]})}var se;(function(e){e.SPEED_NOTIFY="speed-notify"})(se||(se={}));class tn{constructor(){this.EE=new Ie}notifySpeedTest(){this.EE.emit(se.SPEED_NOTIFY)}subscribe(t,n){this.EE.addListener(t,n)}unsubscribe(t,n){this.EE.removeListener(t,n)}}var De=new tn;const Ze={"#909399":0,"#00c520":260,"#ff9a28":600,"#ff3e5e":1/0};function Qe(e){const{config:t,className:n}=e,{set:o}=de(),a=L(),r=d.exports.useCallback(async p=>{var x;if(Y())return(x=await(E==null?void 0:E.getProxyDelay(p)))!=null?x:0;const{data:{delay:y}}=await a.getProxyDelay(p);return y},[a]),i=d.exports.useCallback(async function(){const p=await le.fromPromise(r(t.name),x=>x),y=p.isErr()?0:p.value;o(x=>{const N=x.proxies.find(F=>F.name===t.name);N!=null&&N.history.push({time:Date.now().toString(),delay:y})})},[t.name,r,o]),l=d.exports.useMemo(()=>{var p;return((p=t.history)==null?void 0:p.length)?t.history.slice(-1)[0].delay:0},[t]);d.exports.useLayoutEffect(()=>{const p=()=>{i()};return De.subscribe(se.SPEED_NOTIFY,p),()=>De.unsubscribe(se.SPEED_NOTIFY,p)},[i]);const u=d.exports.useMemo(()=>l===0,[l]),f=d.exports.useMemo(()=>Object.keys(Ze).find(p=>l<=Ze[p]),[l]),h=u?void 0:f;return c("div",{className:v("proxy-item",{"proxy-error":u},n),children:[s("span",{className:"proxy-type",style:{backgroundColor:h},children:t.type}),s("p",{className:"proxy-name",children:t.name}),s("p",{className:"proxy-delay",children:l===0?"-":`${l}ms`})]})}function nn(e){const{markProxySelected:t}=de(),[n]=R(Tt),{data:o}=je(),a=L(),{config:r}=e;async function i(f){if(await a.changeProxySelected(e.config.name,f),t(e.config.name,f),o.breakConnections){const h=[],p=await a.getConnections();for(const y of p.data.connections)y.chains.includes(e.config.name)&&h.push(y.id);await Promise.all(h.map(y=>a.closeConnection(y)))}}const l=d.exports.useMemo(()=>{var h;const f=new Set;for(const p of r.all){const y=(h=n.get(p))==null?void 0:h.history;(y==null?void 0:y.length)&&y.slice(-1)[0].delay===0&&f.add(p)}return f},[r.all,n]),u=r.type==="Selector";return c("div",{className:"proxy-group",children:[c("div",{className:"w-full h-10 mt-4 flex items-center justify-between md:h-15 md:mt-0 md:w-auto",children:[s("span",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap px-5 h-6 w-35 md:w-30",children:r.name}),s(he,{className:"mr-5 md:mr-0",children:r.type})]}),s("div",{className:"py-2 md:py-4 flex-1",children:s(Ot,{className:"ml-5 md:ml-8",data:r.all,onClick:i,errSet:l,select:r.now,canClick:u,rowHeight:30})})]})}function sn(e){const{update:t}=Ge(),{translation:n,lang:o}=D(),a=L(),{provider:r}=e,{t:i}=n("Proxies"),{visible:l,hide:u,show:f}=Ee();function h(){f(),a.healthCheckProvider(r.name).then(async()=>await t()).finally(()=>u())}function p(){f(),a.updateProvider(r.name).then(async()=>await t()).finally(()=>u())}const y=d.exports.useMemo(()=>r.proxies.slice().sort((x,N)=>-1*Ae(x,N)),[r.proxies]);return c(U,{className:"proxy-provider",children:[s(Ke,{visible:l}),c("div",{className:"flex justify-between flex-col md:flex-row md:items-center",children:[c("div",{className:"flex items-center",children:[s("span",{className:"mr-6",children:r.name}),s(he,{children:r.vehicleType})]}),c("div",{className:"flex items-center pt-3 md:pt-0",children:[r.updatedAt&&s("span",{className:"text-sm",children:`${i("providerUpdateTime")}: ${Se(new Date(r.updatedAt),o)}`}),s(M,{className:"pl-5 cursor-pointer text-red",type:"healthcheck",size:18,onClick:h}),s(M,{className:"pl-5 cursor-pointer",type:"update",size:18,onClick:p})]})]}),s("ul",{className:"proxies-list",children:y.map(x=>s("li",{children:s(Qe,{className:"proxy-provider-item",config:x})},x.name))})]})}var et;(function(e){e[e.None=0]="None",e[e.Asc=1]="Asc",e[e.Desc=2]="Desc"})(et||(et={}));const on={[0]:"sort",[1]:"sort-ascending",[2]:"sort-descending"};function Ae(e,t){const n=e.history.length>0?e.history.slice(-1)[0].delay:0;return((t.history.length>0?t.history.slice(-1)[0].delay:0)||Number.MAX_SAFE_INTEGER)-(n||Number.MAX_SAFE_INTEGER)}function an(){const{groups:e,global:t}=de(),{data:n,set:o}=je(),{general:a}=Ne(),{translation:r}=D(),{t:i}=r("Proxies"),l=d.exports.useMemo(()=>a.mode==="global"?[t]:e,[a,e,t]);return s(ce,{children:l.length!==0&&c("div",{className:"flex flex-col",children:[s(W,{title:i("groupTitle"),children:s(qe,{className:"text-primary-600 text-sm text-shadow-primary cursor-pointer",checked:n.breakConnections,onChange:u=>o("breakConnections",u),children:i("breakConnectionsText")})}),s(U,{className:"my-2.5 md:my-4 p-0",children:s("ul",{className:"list-none",children:l.map(u=>s("li",{className:"proxies-group-item",children:s(nn,{config:u})},u.name))})})]})})}function rn(){const{providers:e}=Ge(),{translation:t}=D(),{t:n}=t("Proxies");return s(ce,{children:e.length!==0&&c("div",{className:"flex flex-col",children:[s(W,{title:n("providerTitle")}),s("ul",{className:"list-none",children:e.map(o=>s("li",{className:"my-2.5 md:my-4",children:s(sn,{provider:o})},o.name))})]})})}function ln(){const{proxies:e}=de(),{translation:t}=D(),{t:n}=t("Proxies");function o(){De.notifySpeedTest()}const{current:a,next:r}=jt([1,2,0]),i=d.exports.useMemo(()=>{switch(a){case 2:return e.slice().sort((u,f)=>Ae(u,f));case 1:return e.slice().sort((u,f)=>-1*Ae(u,f));default:return e.slice()}},[a,e]),l=r;return s(ce,{children:i.length!==0&&c("div",{className:"flex flex-col",children:[c(W,{title:n("title"),children:[s(M,{className:"ml-3",type:on[a],onClick:l,size:20}),s(M,{className:"ml-3",type:"speed",size:20}),s("span",{className:"proxies-speed-test",onClick:o,children:n("speedTestText")})]}),s("ul",{className:"proxies-list",children:i.map(u=>s("li",{children:s(Qe,{config:u})},u.name))})]})})}function cn(){return c("div",{className:"page",children:[s(an,{}),s(rn,{}),s(ln,{})]})}function un(e){const{update:t}=We(),{translation:n,lang:o}=D(),a=L(),{provider:r}=e,{t:i}=n("Rules"),{visible:l,hide:u,show:f}=Ee();function h(){f(),a.updateRuleProvider(r.name).then(async()=>await t()).finally(()=>u())}const p=v("rule-provider-icon",{"rule-provider-loading":l});return s("div",{className:"rule-provider",children:c("div",{className:"rule-provider-header",children:[c("div",{className:"rule-provider-header-part",children:[s("span",{className:"rule-provider-name",children:r.name}),s(he,{children:r.vehicleType}),s(he,{className:"rule-provider-behavior",children:r.behavior}),s("span",{className:"rule-provider-update",children:`${i("ruleCount")}: ${r.ruleCount}`})]}),c("div",{className:"rule-provider-header-part",children:[r.updatedAt&&s("span",{className:"rule-provider-update",children:`${i("providerUpdateTime")}: ${Se(new Date(r.updatedAt),o)}`}),s(M,{className:p,type:"update",size:18,onClick:h})]})]})})}function dn(){const{providers:e}=We(),{translation:t}=D(),{t:n}=t("Rules");return s(ce,{children:e.length!==0&&c("div",{className:"flex flex-col",children:[s(W,{title:n("providerTitle")}),s(U,{className:"rounded shadow-primary p-0 divide-y mt-4",children:e.map(o=>s(un,{provider:o},o.name))})]})})}function mn(){const{rules:e,update:t}=Mt(),{translation:n}=D(),{t:o}=n("Rules");V("rules",t);function a({index:r,style:i}){const l=e[r];return s("li",{className:"rule-item",style:i,children:c("div",{className:"py-1 flex",children:[s("div",{className:"rule-type w-40 text-center",children:l.type}),s("div",{className:"payload flex-1 text-center",children:l.payload}),s("div",{className:"rule-proxy w-40 text-center",children:l.proxy})]})})}return c("div",{className:"page",children:[s(dn,{}),s(W,{className:"not-first:mt-7.5",title:o("title")}),s(U,{className:"flex flex-col flex-1 mt-2.5 md:mt-4 p-0 focus:outline-none",children:s(ft,{className:"min-h-120",children:({height:r,width:i})=>s(yt,{height:r,width:i,itemCount:e.length,itemSize:50,children:a})})})]})}const hn=[{label:"\u4E2D\u6587",value:"zh_CN"},{label:"English",value:"en_US"}];function pn(){var oe,ae,T;const{premium:e}=ue(),{data:t,update:n}=Je(),{general:o,update:a}=Ne(),r=xe(be),i=ne(),{translation:l,setLang:u,lang:f}=D(),{t:h}=l("Settings"),p=L(),[y,x]=me({socks5ProxyPort:7891,httpProxyPort:7890,mixedProxyPort:0});d.exports.useEffect(()=>{var w,re,ie;x("socks5ProxyPort",(w=o==null?void 0:o.socksPort)!=null?w:0),x("httpProxyPort",(re=o==null?void 0:o.port)!=null?re:0),x("mixedProxyPort",(ie=o==null?void 0:o.mixedPort)!=null?ie:0)},[o,x]);async function N(w){await p.updateConfig({mode:w}),await a()}async function F(w){await(E==null?void 0:E.setStartAtLogin(w)),await n()}async function $(w){await(E==null?void 0:E.setSystemProxy(w)),await n()}function I(w){u(w)}async function A(){await p.updateConfig({port:y.httpProxyPort}),await a()}async function S(){await p.updateConfig({"socks-port":y.socks5ProxyPort}),await a()}async function B(){await p.updateConfig({"mixed-port":y.mixedProxyPort}),await a()}async function J(w){await p.updateConfig({"allow-lan":w}),await a()}const{hostname:X,port:_}=i,{allowLan:O,mode:pe}=o,K=(oe=t==null?void 0:t.startAtLogin)!=null?oe:!1,Z=(ae=t==null?void 0:t.systemProxy)!=null?ae:!1,z=(T=t==null?void 0:t.isClashX)!=null?T:!1,fe=d.exports.useMemo(()=>{const w=[{label:h("values.global"),value:"Global"},{label:h("values.rules"),value:"Rule"},{label:h("values.direct"),value:"Direct"}];return e&&w.push({label:h("values.script"),value:"Script"}),w},[h,e]);return c("div",{className:"page",children:[s(W,{title:h("title")}),c(U,{className:"settings-card",children:[c("div",{className:"flex flex-wrap",children:[c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.startAtLogin")}),s(we,{disabled:!(t==null?void 0:t.isClashX),checked:K,onChange:F})]}),c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.language")}),s(Me,{options:hn,value:f,onSelect:w=>I(w)})]})]}),c("div",{className:"flex flex-wrap",children:[c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.setAsSystemProxy")}),s(we,{disabled:!z,checked:Z,onChange:$})]}),c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.allowConnectFromLan")}),s(we,{checked:O,onChange:J})]})]})]}),c(U,{className:"settings-card",children:[c("div",{className:"flex flex-wrap",children:[c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.proxyMode")}),s(Me,{options:fe,value:xt(pe),onSelect:N})]}),c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.socks5ProxyPort")}),s(q,{className:"w-28",disabled:z,value:y.socks5ProxyPort,onChange:w=>x("socks5ProxyPort",+w),onBlur:S})]})]}),c("div",{className:"flex flex-wrap",children:[c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.httpProxyPort")}),s(q,{className:"w-28",disabled:z,value:y.httpProxyPort,onChange:w=>x("httpProxyPort",+w),onBlur:A})]}),c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.mixedProxyPort")}),s(q,{className:"w-28",disabled:z,value:y.mixedProxyPort,onChange:w=>x("mixedProxyPort",+w),onBlur:B})]})]}),c("div",{className:"flex flex-wrap",children:[c("div",{className:"w-full flex md:w-1/2 items-center justify-between px-8 py-3",children:[s("span",{className:"label font-bold",children:h("labels.externalController")}),s("span",{className:v({"modify-btn":!z},"external-controller"),onClick:()=>!z&&r(!1),children:`${X}:${_}`})]}),s("div",{className:"w-1/2 px-8"})]})]})]})}var fn="./assets/logo.b453e72f.png";function yn(e){const{routes:t}=e,{translation:n}=D(),{version:o,premium:a}=ue(),{data:r}=Je(),{t:i}=n("SideBar"),l=t.map(({path:u,name:f,exact:h,noMobile:p})=>s("li",{className:v("item",{"no-mobile":p}),children:s(gt,{to:u,activeClassName:"active",exact:!!h,children:i(f)})},f));return c("div",{className:"sidebar",children:[s("img",{src:fn,alt:"logo",className:"sidebar-logo"}),s("ul",{className:"sidebar-menu",children:l}),c("div",{className:"sidebar-version",children:[c("span",{className:"sidebar-version-label",children:["Clash",(r==null?void 0:r.isClashX)&&"X"," ",i("Version")]}),s("span",{className:"sidebar-version-text",children:o}),a&&s("span",{className:"sidebar-version-label",children:"Premium"})]})]})}function xn(){Xe();const e=[{path:"/proxies",name:"Proxies",component:cn},{path:"/logs",name:"Logs",component:en},{path:"/rules",name:"Rules",component:mn,noMobile:!0},{path:"/connections",name:"Connections",component:Zt,noMobile:!0},{path:"/settings",name:"Settings",component:pn}];return c("div",{className:v("app",{"not-clashx":!Y()}),children:[s(yn,{routes:e}),s("div",{className:"page-container",children:c(vt,{children:[s(Re,{exact:!0,path:"/",component:()=>s(wt,{to:"/proxies"})}),e.map(t=>s(Re,{exact:!1,path:t.path,component:t.component},t.path))]})}),s(Qt,{})]})}function tt(){const e=document.getElementById("root"),t=s(Ct,{children:s(d.exports.Suspense,{fallback:s(Ke,{visible:!0}),children:s(xn,{})})});ge.exports.render(t,e)}Y()?Pt(()=>tt()):tt();