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