import{ar as Be,as as Ae,at as ve,N as Re,au as je,d as Se,av as He,C as ie,P as Te,u as ne,f as e,t as m,i as n,ad as M,aw as Fe,ax as ze,G as me,ay as We,az as Ye,F as B,aA as Ve,aB as Ke,aC as Xe,aD as Qe,aE as K,aF as Ze,aG as qe,h as y,aH as Je,aI as Ge,aJ as et,aK as ae,aL as Ne,aM as Le,aN as te,aO as re,aP as ce,aQ as tt,T as rt,E as $,aR as nt,aS as fe,S as P,aT as de,aU as D,aV as Ue,$ as X,_ as Ee,ab as Ie,H as oe,L as st,Y as lt,aW as it,K as at,b as ct,A as ot,U as dt,V as ut,B as q,a2 as gt,aX as ht,aY as be,aZ as pe,a_ as vt,a$ as xe,q as mt}from"./index-CtVw7BLk.js";import{D as ft}from"./DocumentTitle-D9yyEXNP.js";import{f as bt}from"./time-CVcUxeVU.js";import{I as ye}from"./IconReload-CmNrVSiK.js";function $e(s){const r={...s},l={...s},i={},o=c=>{let u=i[c];if(!u){if(!He())return r[c];i[c]=u=ie(r[c],{internal:!0}),delete r[c]}return u[0]()};for(const c in s)Object.defineProperty(l,c,{get:()=>o(c),enumerable:!0});const a=(c,u)=>{const d=i[c];if(d)return d[1](u);c in r&&(r[c]=ve(u,r[c]))};return[l,(c,u)=>{if(Be(c)){const d=Ae(()=>Object.entries(ve(c,l)));Re(()=>{for(const[S,p]of d)a(S,()=>p)})}else a(c,u);return l}]}function pt(s,r){if(je.context){const[l,i]=$e(s);return Se(()=>i(r())),[l,i]}return $e(r())}/**
 * @license @tabler/icons-solidjs v3.34.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var we=Te("outline","brand-speedtest","IconBrandSpeedtest",[["path",{d:"M5.636 19.364a9 9 0 1 1 12.728 0"}],["path",{d:"M16 9l-4 4"}]]);/**
 * @license @tabler/icons-solidjs v3.34.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var xt=Te("outline","chevron-right","IconChevronRight",[["path",{d:"M9 6l6 6l-6 6"}]]),yt=m('<div class="flex flex-col gap-4"><div><div class="flex w-full justify-center"><input class=toggle type=checkbox></div></div><div class="flex flex-col"><input class=input></div><div><input type=number class=input></div><div><select class=select></select></div><div><div class="flex w-full justify-center"><input class=toggle type=checkbox></div></div><div><div class="flex w-full justify-center"><input class=toggle type=checkbox></div></div><div><select class=select></select></div><div><input type=number class=input><input type=number class=input>'),$t=m('<option class="flex items-center gap-2">'),wt=m("<option>");const _t=s=>{const[r]=ne();return e(rt,{ref:l=>s.ref?.(l),get icon(){return e(tt,{size:24})},get title(){return r("proxiesSettings")},get children(){var l=yt(),i=l.firstChild,o=i.firstChild,a=o.firstChild,c=i.nextSibling,u=c.firstChild,d=c.nextSibling,S=d.firstChild,p=d.nextSibling,w=p.firstChild,T=p.nextSibling,k=T.firstChild,x=k.firstChild,N=T.nextSibling,O=N.firstChild,_=O.firstChild,E=N.nextSibling,A=E.firstChild,Q=E.nextSibling,z=Q.firstChild,Z=z.nextSibling;return n(i,e(M,{withDivider:!0,get children(){return r("autoCloseConns")}}),o),a.addEventListener("change",g=>Fe(g.target.checked)),n(c,e(M,{withDivider:!0,get children(){return r("urlForLatencyTest")}}),u),u.addEventListener("change",g=>ze(g.target.value)),n(d,e(M,{withDivider:!0,get children(){return[me(()=>r("latencyTestTimeoutDuration"))," (",me(()=>r("ms")),")"]}}),S),S.addEventListener("change",g=>We(Number(g.target.value))),n(p,e(M,{withDivider:!0,get children(){return r("proxiesSorting")}}),w),w.addEventListener("change",g=>Ye(g.target.value)),n(w,e(B,{get each(){return Object.values(Ve)},children:g=>(()=>{var I=$t();return I.value=g,n(I,()=>r(g)),I})()})),n(T,e(M,{withDivider:!0,get children(){return r("hideUnavailableProxies")}}),k),x.addEventListener("change",g=>Ke(g.target.checked)),n(N,e(M,{withDivider:!0,get children(){return r("renderInTwoColumns")}}),O),_.addEventListener("change",g=>Xe(g.target.checked)),n(E,e(M,{withDivider:!0,get children(){return r("proxiesPreviewType")}}),A),A.addEventListener("change",g=>Qe(g.target.value)),n(A,e(B,{get each(){return Object.values(K)},children:g=>(()=>{var I=wt();return I.value=g,n(I,()=>r(g)),I})()})),n(Q,e(M,{withDivider:!0,get children(){return r("iconHeight")}}),z),z.addEventListener("change",g=>Ze(Number(g.target.value))),n(Q,e(M,{withDivider:!0,get children(){return r("iconMarginRight")}}),Z),Z.addEventListener("change",g=>qe(Number(g.target.value))),y(()=>a.checked=Je()),y(()=>u.value=Ge()),y(()=>S.value=et()),y(()=>w.value=ae()),y(()=>x.checked=Ne()),y(()=>_.checked=Le()),y(()=>A.value=te()),y(()=>z.value=re()),y(()=>Z.value=ce()),l}})},_e=s=>{const r=()=>te()===K.OFF,l=$(()=>s.proxyNameList.length<=10),i=$(()=>{const a=te();return a===K.BAR||a===K.Auto&&!l()}),o=$(()=>{const a=te();return a===K.DOTS||a===K.Auto&&l()});return e(P,{get when(){return!r()},get children(){return e(nt,{get children(){return[e(fe,{get when(){return i()},get children(){return e(Pt,{get proxyNameList(){return s.proxyNameList},get testUrl(){return s.testUrl},get now(){return s.now}})}}),e(fe,{get when(){return o()},get children(){return e(Lt,{get proxyNameList(){return s.proxyNameList},get testUrl(){return s.testUrl},get now(){return s.now}})}})]}})}})};var Ct=m('<div class="flex items-center gap-2"><div class="my-1 flex flex-1 items-center justify-center overflow-hidden rounded-2xl [&amp;>*]:h-2"><div class=bg-green-600></div><div class=bg-yellow-500></div><div class=bg-red-500></div><div class=bg-neutral>');const Pt=s=>{const{getLatencyByName:r}=de(),l=$(()=>s.proxyNameList.map(d=>r(d,s.testUrl))),i=$(()=>l().length),o=$(()=>l().filter(d=>d>D().NOT_CONNECTED&&d<=D().MEDIUM).length),a=$(()=>l().filter(d=>d>D().MEDIUM&&d<=D().HIGH).length),c=$(()=>l().filter(d=>d>D().HIGH).length),u=$(()=>l().filter(d=>d===D().NOT_CONNECTED).length);return(()=>{var d=Ct(),S=d.firstChild,p=S.firstChild,w=p.nextSibling,T=w.nextSibling,k=T.nextSibling;return n(d,e(P,{get when(){return s.now},get children(){return e(Ue,{get proxyName(){return s.now},get testUrl(){return s.testUrl}})}}),null),y(x=>{var N=`${o()*100/i()}%`,O=`${a()*100/i()}%`,_=`${c()*100/i()}%`,E=`${u()*100/i()}%`;return N!==x.e&&((x.e=N)!=null?p.style.setProperty("width",N):p.style.removeProperty("width")),O!==x.t&&((x.t=O)!=null?w.style.setProperty("width",O):w.style.removeProperty("width")),_!==x.a&&((x.a=_)!=null?T.style.setProperty("width",_):T.style.removeProperty("width")),E!==x.o&&((x.o=E)!=null?k.style.setProperty("width",E):k.style.removeProperty("width")),x},{e:void 0,t:void 0,a:void 0,o:void 0}),d})()};var St=m("<div>"),Tt=m('<div class="flex items-center gap-2"><div class="flex flex-1 flex-wrap items-center gap-1">');const Nt=s=>{let r=s.selected?"bg-white border-4 border-green-600":"bg-green-600";return typeof s.latency!="number"||s.latency===D().NOT_CONNECTED?r=s.selected?"bg-white border-4 border-neutral":"bg-neutral":s.latency>D().HIGH?r=s.selected?"bg-white border-4 border-red-500":"bg-red-500":s.latency>D().MEDIUM&&(r=s.selected?"bg-white border-4 border-yellow-500":"bg-yellow-500"),(()=>{var l=St();return y(i=>{var o=X("h-4 w-4 rounded-full",r),a=s.name;return o!==i.e&&Ee(l,i.e=o),a!==i.t&&Ie(l,"title",i.t=a),i},{e:void 0,t:void 0}),l})()},Lt=s=>{const{getLatencyByName:r}=de();return(()=>{var l=Tt(),i=l.firstChild;return n(i,e(B,{get each(){return s.proxyNameList.map(o=>[o,r(o,s.testUrl)])},children:([o,a])=>e(Nt,{name:o,latency:a,get selected(){return s.now===o}})})),n(l,e(P,{get when(){return s.now},get children(){return e(Ue,{get proxyName(){return s.now},get testUrl(){return s.testUrl}})}}),null),l})()};var Ut=m('<div class="flex items-center gap-2 pt-1"><progress class=progress max=100></progress><div class="badge badge-sm badge-secondary">%'),Et=m('<div class="flex flex-wrap items-center justify-between"><div class="text-sm text-slate-500"> / </div><div class="text-sm text-slate-500">: ');const It=s=>{const{Download:r=0,Upload:l=0,Total:i=0,Expire:o=0}=s,a=oe(i,{units:"iec"}),c=oe(r+l,{units:"iec"}),u=Math.min(st.toFinite(((r+l)/i*100).toFixed(1)),999);return{total:a,used:c,percentage:u,expirePrefix:()=>{const[p]=ne();return p("expire")},expireStr:()=>{const[p]=ne();return o===0?p("noExpire"):lt(o*1e3).format("YYYY-MM-DD")}}},Mt=s=>{if(!s.subscriptionInfo)return;const r=It(s.subscriptionInfo);return[(()=>{var l=Ut(),i=l.firstChild,o=i.nextSibling,a=o.firstChild;return n(o,()=>r.percentage,a),y(()=>i.value=r.percentage),l})(),(()=>{var l=Et(),i=l.firstChild,o=i.firstChild,a=i.nextSibling,c=a.firstChild;return n(i,()=>`${r.used}`,o),n(i,()=>`${r.total}`,null),n(a,()=>r.expirePrefix(),c),n(a,()=>r.expireStr(),null),l})()]},Dt={width:0,height:0};function Ce(){return{width:window.innerWidth,height:window.innerHeight}}function kt(){const[s,r]=pt(Dt,Ce);return it(window,"resize",()=>r(Ce())),s}var Ot=m("<div class=mb-2>"),Bt=m('<div class="flex gap-2"><div class=flex-1></div><div class=flex-1>'),At=m('<div class="grid grid-cols-1 place-items-start gap-2">');const Pe=s=>{const r=kt(),l=$(()=>r.width>480);return()=>{const i=at(()=>s.children),o=a=>i()?.filter((c,u)=>u%2===a).map(c=>(()=>{var u=Ot();return n(u,c),u})());return Le()&&l()?(()=>{var a=Bt(),c=a.firstChild,u=c.nextSibling;return n(c,()=>o(0)),n(u,()=>o(1)),a})():(()=>{var a=At();return n(a,i),a})()}};var Rt=m('<div class="flex h-full flex-col gap-2"><div class="flex items-center gap-2"><div class="tabs tabs-sm gap-2 tabs-box"></div><div class=ml-auto></div></div><div class="flex-1 overflow-y-auto">'),jt=m('<button><span></span><div class="badge badge-sm">'),Ht=m("<div>"),Ft=m("<span class=whitespace-nowrap>"),zt=m('<div class=space-y-2><div class="flex items-center justify-between pr-8"><div class="flex items-center"><span></span><div class="ml-2 badge badge-sm"></div></div></div><div class="flex flex-wrap items-center justify-between gap-2"><div class="badge badge-sm badge-primary"><span class=font-bold></span></div><div class="badge badge-sm badge-secondary">/s'),Wt=m("<img>"),Yt=m('<div class="flex items-center justify-between pr-8"><div class="flex flex-wrap items-center gap-1"><span class="line-clamp-1 break-all"></span><div class="badge badge-sm"></div><div class="badge badge-sm"></div></div><div class="flex items-center gap-2">'),Vt=m('<div class="flex flex-col gap-2"><div class="text-sm text-slate-500"> ');const qt=()=>{const s=ct();if(!ot())return s("/setup",{replace:!0}),null;let r;const[l]=ne(),{fetchProxies:i,proxies:o,selectProxyInGroup:a,proxyProviders:c,updateProviderByProviderName:u,updateAllProvider:d,proxyGroupLatencyTest:S,proxyProviderLatencyTest:p,proxyGroupLatencyTestingMap:w,proxyProviderLatencyTestingMap:T,isAllProviderUpdating:k,updatingMap:x}=de(),N=$(()=>o().filter(f=>!f.hidden)),{speedGroupByName:O}=dt(),[_,E]=ut(ie({}),{name:"collapsedMap",storage:localStorage}),A=(f,C)=>{E(G=>({...G,[f]:C}))};Se(i);const Q=async(f,C)=>{f.stopPropagation(),S(C)},z=f=>f.replace("<svg",~f.indexOf("xmlns")?"<svg":'<svg xmlns="http://www.w3.org/2000/svg"').replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/\{/g,"%7B").replace(/\}/g,"%7D").replace(/</g,"%3C").replace(/>/g,"%3E"),Z=(f,C)=>{f.stopPropagation(),p(C)},g=(f,C)=>{f.stopPropagation(),u(C)},I=async f=>{f.stopPropagation(),d()},[J,Me]=ie("proxies"),De=()=>[{type:"proxies",name:l("proxies"),count:N().length},{type:"proxyProviders",name:l("proxyProviders"),count:c().length}];return[e(ft,{get children(){return l("proxies")}}),(()=>{var f=Rt(),C=f.firstChild,G=C.firstChild,ue=G.nextSibling,ge=C.nextSibling;return n(G,e(B,{get each(){return De()},children:t=>(()=>{var L=jt(),W=L.firstChild,h=W.nextSibling;return L.$$click=()=>Me(t.type),n(W,()=>t.name),n(h,()=>t.count),y(()=>Ee(L,X(J()===t.type&&"bg-primary !text-neutral","sm:tab-md tab gap-2 px-2"))),L})()})),n(C,e(P,{get when(){return J()==="proxyProviders"},get children(){return e(q,{class:"btn btn-circle btn-sm",get disabled(){return k()},onClick:t=>I(t),get icon(){return e(ye,{get class(){return X(k()&&"animate-spin text-success")}})}})}}),ue),n(ue,e(q,{class:"btn-circle btn-sm btn-primary",onClick:()=>r?.showModal(),get icon(){return e(gt,{})}})),n(ge,e(P,{get when(){return J()==="proxies"},get children(){return e(Pe,{get children(){return e(B,{get each(){return N()},children:t=>{const L=$(()=>vt({proxyNames:xe({proxyNames:t.all??[],orderingType:ae(),testUrl:t.testUrl||null}),enabled:Ne(),testUrl:t.testUrl||null})),W=(()=>{var h=zt(),U=h.firstChild,R=U.firstChild,Y=R.firstChild,se=Y.nextSibling,ee=U.nextSibling,j=ee.firstChild,ke=j.firstChild,he=j.nextSibling,Oe=he.firstChild;return n(R,e(P,{get when(){return t.icon},get children(){return e(P,{get when(){return t.icon.startsWith("data:image/svg+xml")},get fallback(){return(()=>{var v=Wt();return y(b=>{var V=t.icon,H=`${re()}px`,F=`${ce()}px`;return V!==b.e&&Ie(v,"src",b.e=V),H!==b.t&&((b.t=H)!=null?v.style.setProperty("height",H):v.style.removeProperty("height")),F!==b.a&&((b.a=F)!=null?v.style.setProperty("margin-right",F):v.style.removeProperty("margin-right")),b},{e:void 0,t:void 0,a:void 0}),v})()},get children(){var v=Ht();return v.style.setProperty("color","oklch(var(--p) / var(--tw-bg-opacity))"),v.style.setProperty("background-color","currentColor"),v.style.setProperty("mask-size","100% 100%"),y(b=>{var V=`${re()}px`,H=`${re()}px`,F=`${ce()}px`,le=`url("${z(t.icon)}")`;return V!==b.e&&((b.e=V)!=null?v.style.setProperty("height",V):v.style.removeProperty("height")),H!==b.t&&((b.t=H)!=null?v.style.setProperty("width",H):v.style.removeProperty("width")),F!==b.a&&((b.a=F)!=null?v.style.setProperty("margin-right",F):v.style.removeProperty("margin-right")),le!==b.o&&((b.o=le)!=null?v.style.setProperty("mask-image",le):v.style.removeProperty("mask-image")),b},{e:void 0,t:void 0,a:void 0,o:void 0}),v}})}}),Y),n(Y,()=>t.name),n(se,()=>t.all?.length),n(U,e(q,{class:"btn-circle btn-sm",get disabled(){return w()[t.name]},onClick:v=>Q(v,t.name),get icon(){return e(we,{get class(){return X(w()[t.name]&&"animate-pulse text-success")}})}}),null),n(ke,()=>ht(t.type)),n(j,e(P,{get when(){return t.now?.length>0},get children(){return[e(xt,{size:18}),(()=>{var v=Ft();return n(v,()=>t.now),v})()]}}),null),n(he,()=>oe(O()[t.name]??0).toString(),Oe),n(h,e(P,{get when(){return!_()[t.name]},get children(){return e(_e,{get proxyNameList(){return L()},get now(){return t.now},get testUrl(){return t.testUrl||null}})}}),null),h})();return e(be,{get isOpen(){return _()[t.name]},title:W,onCollapse:h=>A(t.name,h),get children(){return e(B,{get each(){return L()},children:h=>e(pe,{proxyName:h,get testUrl(){return t.testUrl||null},get timeout(){return t.timeout??null},get isSelected(){return t.now===h},onClick:()=>void a(t,h)})})}})}})}})}}),null),n(ge,e(P,{get when(){return J()==="proxyProviders"},get children(){return e(Pe,{get children(){return e(B,{get each(){return c()},children:t=>{const L=$(()=>xe({orderingType:ae(),proxyNames:t.proxies.map(h=>h.name)??[],testUrl:t.testUrl})),W=[(()=>{var h=Yt(),U=h.firstChild,R=U.firstChild,Y=R.nextSibling,se=Y.nextSibling,ee=U.nextSibling;return n(R,()=>t.name),n(Y,()=>t.proxies.length),n(se,()=>t.vehicleType),n(ee,e(q,{class:"btn btn-circle btn-sm",get disabled(){return x()[t.name]},onClick:j=>g(j,t.name),get icon(){return e(ye,{get class(){return X(x()[t.name]&&"animate-spin text-success")}})}}),null),n(ee,e(q,{class:"btn btn-circle btn-sm",get disabled(){return T()[t.name]},onClick:j=>Z(j,t.name),get icon(){return e(we,{get class(){return X(T()[t.name]&&"animate-pulse text-success")}})}}),null),h})(),e(Mt,{get subscriptionInfo(){return t.subscriptionInfo}}),(()=>{var h=Vt(),U=h.firstChild,R=U.firstChild;return n(U,()=>l("updated"),R),n(U,()=>bt(t.updatedAt),null),n(h,e(P,{get when(){return!_()[t.name]},get children(){return e(_e,{get proxyNameList(){return L()},get testUrl(){return t.testUrl}})}}),null),h})()];return e(be,{get isOpen(){return _()[t.name]},title:W,onCollapse:h=>A(t.name,h),get children(){return e(B,{get each(){return L()},children:h=>e(pe,{proxyName:h,get testUrl(){return t.testUrl},get timeout(){return t.timeout??null}})})}})}})}})}}),null),n(f,e(_t,{ref:t=>r=t}),null),f})()]};mt(["click"]);export{qt as default};
