var re=Object.defineProperty,oe=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var W=(e,o,l)=>o in e?re(e,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[o]=l,u=(e,o)=>{for(var l in o||(o={}))A.call(o,l)&&W(e,l,o[l]);if(k)for(var l of k(o))B.call(o,l)&&W(e,l,o[l]);return e},v=(e,o)=>oe(e,le(o));var U=(e,o)=>{var l={};for(var a in e)A.call(e,a)&&o.indexOf(a)<0&&(l[a]=e[a]);if(e!=null&&k)for(var a of k(e))o.indexOf(a)<0&&B.call(e,a)&&(l[a]=e[a]);return l};import{r as P,b as c,j as t,P as h,s as q,R as se,c as ie,i as ce,k as G,l as H,n as de,h as J,d as Q,o as ue,g as K,q as pe,t as he,v as x,w as fe,x as ve,y as ge,z as me,A as be,u as ye,C as ke,D as N,F as we,B as w,E as Ce,G as _e,H as Oe}from"./index.1ca2d13d.js";import{r as Se}from"./logs.480db4a8.js";import{S as C}from"./Select.763fb4e2.js";import{R as xe}from"./rotate-cw.a7721ea7.js";function Ne(e,o){if(e==null)return{};var l=je(e,o),a,n;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&(!Object.prototype.propertyIsEnumerable.call(e,a)||(l[a]=e[a]))}return l}function je(e,o){if(e==null)return{};var l={},a=Object.keys(e),n,r;for(r=0;r=0)&&(l[n]=e[n]);return l}var I=P.exports.forwardRef(function(e,o){var l=e.color,a=l===void 0?"currentColor":l,n=e.size,r=n===void 0?24:n,d=Ne(e,["color","size"]);return c("svg",v(u({ref:o,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},d),{children:[t("polyline",{points:"8 17 12 21 16 17"}),t("line",{x1:"12",y1:"12",x2:"12",y2:"21"}),t("path",{d:"M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29"})]}))});I.propTypes={color:h.string,size:h.oneOfType([h.string,h.number])};I.displayName="DownloadCloud";var Pe=I;function Ie(e,o){if(e==null)return{};var l=ze(e,o),a,n;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&(!Object.prototype.propertyIsEnumerable.call(e,a)||(l[a]=e[a]))}return l}function ze(e,o){if(e==null)return{};var l={},a=Object.keys(e),n,r;for(r=0;r=0)&&(l[n]=e[n]);return l}var z=P.exports.forwardRef(function(e,o){var l=e.color,a=l===void 0?"currentColor":l,n=e.size,r=n===void 0?24:n,d=Ie(e,["color","size"]);return c("svg",v(u({ref:o,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},d),{children:[t("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),t("polyline",{points:"16 17 21 12 16 7"}),t("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}))});z.propTypes={color:h.string,size:h.oneOfType([h.string,h.number])};z.displayName="LogOut";var Le=z;function $e(e,o){if(e==null)return{};var l=Te(e,o),a,n;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&(!Object.prototype.propertyIsEnumerable.call(e,a)||(l[a]=e[a]))}return l}function Te(e,o){if(e==null)return{};var l={},a=Object.keys(e),n,r;for(r=0;r=0)&&(l[n]=e[n]);return l}var L=P.exports.forwardRef(function(e,o){var l=e.color,a=l===void 0?"currentColor":l,n=e.size,r=n===void 0?24:n,d=$e(e,["color","size"]);return c("svg",v(u({ref:o,xmlns:"http://www.w3.org/2000/svg",width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},d),{children:[t("polyline",{points:"3 6 5 6 21 6"}),t("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),t("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),t("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]}))});L.propTypes={color:h.string,size:h.oneOfType([h.string,h.number])};L.displayName="Trash2";var Re=L;const{useState:Ee,useRef:De,useEffect:Fe,useCallback:Me}=se;function Ve(e){return t("input",u({className:q.input},e))}function We(l){var a=l,{value:e}=a,o=U(a,["value"]);const[n,r]=Ee(e),d=De(e);Fe(()=>{d.current!==e&&r(e),d.current=e},[e]);const g=Me(_=>r(_.target.value),[r]);return t("input",u({className:q.input,value:n,onChange:g},o))}const Ae="_root_9juo6_1",Be="_section_9juo6_2",Ue="_wrapSwitch_9juo6_27",Ge="_sep_9juo6_33",He="_label_9juo6_46";var i={root:Ae,section:Be,wrapSwitch:Ue,sep:Ge,label:He};const qe="_fieldset_olb4q_1",Je="_input_olb4q_10",Qe="_cnt_olb4q_10";var j={fieldset:qe,input:Je,cnt:Qe};function Ke({OptionComponent:e,optionPropsList:o,selectedIndex:l,onChange:a}){const n=ie("visually-hidden",j.input),r=d=>{a(d.target.value)};return t("fieldset",{className:j.fieldset,children:o.map((d,g)=>c("label",{children:[t("input",{type:"radio",checked:l===g,name:"selection",value:g,"aria-labelledby":"traffic chart type "+g,onChange:r,className:n}),t("div",{className:j.cnt,children:t(e,u({},d))})]},g))})}const{useMemo:Xe}=J,Ye={plugins:{legend:{display:!1}},scales:{x:{display:!1,type:"category"},y:{display:!1,type:"linear"}}},X=[23e3,35e3,46e3,33e3,9e4,68e3,23e3,45e3],Ze=[184e3,183e3,196e3,182e3,19e4,186e3,182e3,189e3],et=X;function tt({id:e}){const o=ce.read(),l=Xe(()=>({labels:et,datasets:[v(u(u({},G),H[e].up),{data:X}),v(u(u({},G),H[e].down),{data:Ze})]}),[e]),a="chart-"+e;return de(o.Chart,a,l,null,Ye),t("div",{style:{width:80,padding:5},children:t("canvas",{id:a})})}const{useEffect:Y,useState:nt,useCallback:b,useRef:at}=J,rt=[{id:0},{id:1},{id:2},{id:3}],ot=[["debug","Debug"],["info","Info"],["warning","Warning"],["error","Error"],["silent","Silent"]],lt=[{key:"port",label:"Http Port"},{key:"socks-port",label:"Socks5 Port"},{key:"mixed-port",label:"Mixed Port"},{key:"redir-port",label:"Redir Port"},{key:"mitm-port",label:"MITM Port"}],st=[["zh","\u4E2D\u6587"],["en","English"]],it=[["direct","Direct"],["rule","Rule"],["script","Script"],["global","Global"]],ct=[["gVisor","gVisor"],["System","System"]],dt=e=>({configs:ue(e),apiConfig:K(e)}),ut=e=>({selectedChartStyleIndex:Ce(e),latencyTestUrl:_e(e),apiConfig:K(e)}),pt=Q(ut)(ft);var kt=Q(dt)(ht);function ht({dispatch:e,configs:o,apiConfig:l}){return Y(()=>{e(pe(l))},[e,l]),t(pt,{configs:o})}function ft({dispatch:e,configs:o,selectedChartStyleIndex:l,latencyTestUrl:a,apiConfig:n}){var F,M;const[r,d]=nt(o),g=at(o);Y(()=>{g.current!==o&&d(o),g.current=o},[o]);const _=b(()=>{e(he("apiConfig"))},[e]),O=b((s,p)=>{d(v(u({},r),{[s]:p}))},[r]),$=b((s,p)=>{const m=v(u({},r.tun),{[s]:p});d(v(u({},r),{tun:u({},m)}))},[r]),y=b(({name:s,value:p})=>{switch(s){case"mode":case"log-level":case"allow-lan":case"sniffing":O(s,p),e(x(n,{[s]:p})),s==="log-level"&&Se(v(u({},n),{logLevel:p}));break;case"mitm-port":case"redir-port":case"socks-port":case"mixed-port":case"port":if(p!==""){const m=parseInt(p,10);if(m<0||m>65535)return}O(s,p);break;case"enable":case"stack":$(s,p),e(x(n,{tun:{[s]:p}}));break;default:return}},[n,e,O,$]),Z=b(s=>y(s.target),[y]),{selectChartStyleIndex:ee,updateAppConfig:T}=fe(),R=b(s=>{const p=s.target,{name:m,value:V}=p;switch(m){case"port":case"socks-port":case"mixed-port":case"redir-port":case"mitm-port":{const S=parseInt(V,10);if(S<0||S>65535)return;e(x(n,{[m]:S}));break}case"latencyTestUrl":{T(m,V);break}default:throw new Error(`unknown input name ${m}`)}},[n,e,T]),te=b(()=>{e(ve(n))},[n,e]),ne=b(()=>{e(ge(n))},[n,e]),ae=b(()=>{e(me(n))},[n,e]),{data:E}=be(["/version",n],()=>Oe("/version",n)),{t:f,i18n:D}=ye();return c("div",{children:[t(ke,{title:f("Config")}),c("div",{className:i.root,children:[lt.map(s=>r[s.key]!==void 0?c("div",{children:[t("div",{className:i.label,children:s.label}),t(Ve,{name:s.key,value:r[s.key],onChange:Z,onBlur:R})]},s.key):null),c("div",{children:[t("div",{className:i.label,children:"Mode"}),t(C,{options:it,selected:r.mode,onChange:s=>y({name:"mode",value:s.target.value})})]}),c("div",{children:[t("div",{className:i.label,children:"Log Level"}),t(C,{options:ot,selected:r["log-level"],onChange:s=>y({name:"log-level",value:s.target.value})})]}),c("div",{children:[t("div",{className:i.label,children:f("allow_lan")}),t("div",{className:i.wrapSwitch,children:t(N,{name:"allow-lan",checked:r["allow-lan"],onChange:s=>y({name:"allow-lan",value:s})})})]}),E.meta&&c("div",{children:[t("div",{className:i.label,children:f("tls_sniffing")}),t("div",{className:i.wrapSwitch,children:t(N,{name:"sniffing",checked:r.sniffing,onChange:s=>y({name:"sniffing",value:s})})})]})]}),t("div",{className:i.sep,children:t("div",{})}),E.meta&&c(we,{children:[c("div",{className:i.section,children:[c("div",{children:[t("div",{className:i.label,children:f("enable_tun_device")}),t("div",{className:i.wrapSwitch,children:t(N,{checked:(F=r.tun)==null?void 0:F.enable,onChange:s=>y({name:"enable",value:s})})})]}),c("div",{children:[t("div",{className:i.label,children:"TUN IP Stack"}),t(C,{options:ct,selected:(M=r.tun)==null?void 0:M.stack,onChange:s=>y({name:"stack",value:s.target.value})})]})]}),t("div",{className:i.sep,children:t("div",{})}),c("div",{className:i.section,children:[c("div",{children:[t("div",{className:i.label,children:"Reload"}),t(w,{start:t(xe,{size:16}),label:f("reload_config_file"),onClick:te})]}),c("div",{children:[t("div",{className:i.label,children:"GEO Databases"}),t(w,{start:t(Pe,{size:16}),label:f("update_geo_databases_file"),onClick:ne})]}),c("div",{children:[t("div",{className:i.label,children:"FakeIP"}),t(w,{start:t(Re,{size:16}),label:f("flush_fake_ip_pool"),onClick:ae})]})]}),t("div",{className:i.sep,children:t("div",{})})]}),c("div",{className:i.section,children:[c("div",{children:[t("div",{className:i.label,children:f("latency_test_url")}),t(We,{name:"latencyTestUrl",type:"text",value:a,onBlur:R})]}),c("div",{children:[t("div",{className:i.label,children:f("lang")}),t("div",{children:t(C,{options:st,selected:D.language,onChange:s=>D.changeLanguage(s.target.value)})})]}),c("div",{children:[t("div",{className:i.label,children:f("chart_style")}),t(Ke,{OptionComponent:tt,optionPropsList:rt,selectedIndex:l,onChange:ee})]}),c("div",{children:[t("div",{className:i.label,children:"Action"}),t(w,{start:t(Le,{size:16}),label:"Switch backend",onClick:_})]})]})]})}export{kt as default};