text: var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,s=(t,a,r)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r,o=(e,t)=>{for(var a in t||(t={}))l.call(t,a)&&s(e,a,t[a]);if(r)for(var a of r(t))n.call(t,a)&&s(e,a,t[a]);return e},c=(e,r)=>t(e,a(r));import{R as i,g as p,r as d,l as m,L as u,j as v}from"./vendor.422da9ba.js";import{r as g}from"./logs.3e1868e7.js";import{S as f}from"./Select.ea969293.js";import{s as x,b as E,d as y,e as b,u as h,c as C,h as _,o as k,i as w,j as N,C as j,k as O,B as P,l as S,g as I,n as L,q as A}from"./index.e54f6767.js";const{useState:R,useRef:T,useEffect:U,useCallback:D}=i;function M(e){return i.createElement("input",o({className:x.input},e))}function B(e){var t=e,{value:a}=t,s=((e,t)=>{var a={};for(var s in e)l.call(e,s)&&t.indexOf(s)<0&&(a[s]=e[s]);if(null!=e&&r)for(var s of r(e))t.indexOf(s)<0&&n.call(e,s)&&(a[s]=e[s]);return a})(t,["value"]);const[c,p]=R(a),d=T(a);U((()=>{d.current!==a&&p(a),d.current=a}),[a]);const m=D((e=>p(e.target.value)),[p]);return i.createElement("input",o({className:x.input,value:c,onChange:m},s))}var z="_root_1tdl3_1",G="_section_1tdl3_2",q="_wrapSwitch_1tdl3_26",H="_sep_1tdl3_32",K="_label_1tdl3_45";var W="_fieldset_1ghjp_1",$="_input_1ghjp_9",F="_cnt_1ghjp_9";function J({OptionComponent:e,optionPropsList:t,selectedIndex:a,onChange:r}){const l=p("visually-hidden",$),n=e=>{r(e.target.value)};return i.createElement("fieldset",{className:W},t.map(((t,r)=>i.createElement("label",{key:r},i.createElement("input",{type:"radio",checked:a===r,name:"selection",value:r,"aria-labelledby":"traffic chart type "+r,onChange:n,className:l}),i.createElement("div",{className:F},i.createElement(e,o({},t)))))))}const Q={legend:{display:!1},scales:{xAxes:[{display:!1}],yAxes:[{display:!1}]}},V=[23e3,35e3,46e3,33e3,9e4,68e3,23e3,45e3],X=[184e3,183e3,196e3,182e3,19e4,186e3,182e3,189e3],Y=V;function Z({id:e}){const t=E.read(),a=d.exports.useMemo((()=>({labels:Y,datasets:[c(o(o({},y),b[e].up),{data:V}),c(o(o({},y),b[e].down),{data:X})]})),[e]),r="chart-"+e;return h(t,r,a,null,Q),i.createElement("div",{style:{width:100,padding:5}},i.createElement("canvas",{id:r}))}const{useEffect:ee,useState:te,useCallback:ae,useRef:re,useMemo:le}=v,ne=[{id:0},{id:1},{id:2},{id:3}],se=[["debug","Debug"],["warning","Warning"],["info","Info"],["error","Error"],["silent","Silent"]],oe=[{key:"port",label:"HTTP Proxy Port"},{key:"socks-port",label:"SOCKS5 Proxy Port"},{key:"mixed-port",label:"Mixed Port"},{key:"redir-port",label:"Redir Port"}],ce=[["zh","中文"],["en","English"]],ie=[["Global","Global"],["Rule","Rule"],["Direct","Direct"]],pe=C((e=>({selectedChartStyleIndex:L(e),latencyTestUrl:A(e),apiConfig:I(e)})))((function({dispatch:e,configs:t,selectedChartStyleIndex:a,latencyTestUrl:r,apiConfig:l}){const[n,s]=te(t),i=re(t);ee((()=>{i.current!==t&&s(t),i.current=t}),[t]);const p=ae((()=>{e(k("apiConfig"))}),[e]),v=ae(((e,t)=>{s(c(o({},n),{[e]:t}))}),[n]),x=ae((t=>{const a=t;v("allow-lan",a),e(w(l,{"allow-lan":a}))}),[l,e,v]),E=ae((({name:t,value:a})=>{switch(t){case"mode":case"log-level":v(t,a),e(w(l,{[t]:a})),"log-level"===t&&g(c(o({},l),{logLevel:a}));break;case"redir-port":case"socks-port":case"mixed-port":case"port":if(""!==a){const e=parseInt(a,10);if(e<0||e>65535)return}v(t,a);break;default:return}}),[l,e,v]),y=ae((e=>E(e.target)),[E]),{selectChartStyleIndex:b,updateAppConfig:h}=N(),C=ae((t=>{const a=t.target,{name:r,value:n}=a;switch(r){case"port":case"socks-port":case"mixed-port":case"redir-port":{const t=parseInt(n,10);if(t<0||t>65535)return;e(w(l,{[r]:t}));break}case"latencyTestUrl":h(r,n);break;default:throw new Error(`unknown input name ${r}`)}}),[l,e,h]),_=le((()=>{const e=n.mode;return"string"==typeof e&&e[0].toUpperCase()+e.slice(1)}),[n.mode]),{t:S,i18n:I}=m();return d.exports.createElement("div",null,d.exports.createElement(j,{title:S("Config")}),d.exports.createElement("div",{className:z},oe.map((e=>void 0!==n[e.key]?d.exports.createElement("div",{key:e.key},d.exports.createElement("div",{className:K},e.label),d.exports.createElement(M,{name:e.key,value:n[e.key],onChange:y,onBlur:C})):null)),d.exports.createElement("div",null,d.exports.createElement("div",{className:K},"Mode"),d.exports.createElement(f,{options:ie,selected:_,onChange:e=>E({name:"mode",value:e.target.value})})),d.exports.createElement("div",null,d.exports.createElement("div",{className:K},"Log Level"),d.exports.createElement(f,{options:se,selected:n["log-level"],onChange:e=>E({name:"log-level",value:e.target.value})})),d.exports.createElement("div",null,d.exports.createElement("div",{className:K},"Allow LAN"),d.exports.createElement("div",{className:q},d.exports.createElement(O,{name:"allow-lan",checked:n["allow-lan"],onChange:x})))),d.exports.createElement("div",{className:H},d.exports.createElement("div",null)),d.exports.createElement("div",{className:G},d.exports.createElement("div",null,d.exports.createElement("div",{className:K},S("latency_test_url")),d.exports.createElement(B,{name:"latencyTestUrl",type:"text",value:r,onBlur:C})),d.exports.createElement("div",null,d.exports.createElement("div",{className:K},S("lang")),d.exports.createElement("div",null,d.exports.createElement(f,{options:ce,selected:I.language,onChange:e=>I.changeLanguage(e.target.value)}))),d.exports.createElement("div",null,d.exports.createElement("div",{className:K},S("chart_style")),d.exports.createElement(J,{OptionComponent:Z,optionPropsList:ne,selectedIndex:a,onChange:b})),d.exports.createElement("div",null,d.exports.createElement("div",{className:K},"Action"),d.exports.createElement(P,{start:d.exports.createElement(u,{size:16}),label:"Switch backend",onClick:p}))))}));var de=C((e=>({configs:S(e),apiConfig:I(e)})))((function({dispatch:e,configs:t,apiConfig:a}){return ee((()=>{e(_(a))}),[e,a]),d.exports.createElement(pe,{configs:t})}));export default de;
  