metacubexd/assets/Proxies-DgzLrzio.js
2024-09-14 16:15:03 +00:00

2 lines
11 KiB
JavaScript

import{u as Z,f as e,au as be,i as t,ai as A,av as pe,aw as $e,D as b,ax as _e,ay as ye,az as we,F,aA as Ce,aB as Pe,aC as Se,aD as Te,aE as H,g as x,aF as Le,aG as Ee,aH as Ne,aI as Ie,aJ as G,aK as he,aL as ee,aM as J,P as De,t as h,aN as Me,aO as le,S as Y,aP as I,aQ as me,aR as ne,a0 as B,$ as q,ag as ke,H as te,E as Oe,W as Ae,b as Be,y as Fe,Q as Ue,R as je,A as ie,o as Re,B as W,aS as ae,a5 as He,aT as Ye,aU as ce,aV as oe,aW as de,aX as ue,l as ze}from"./index-DWMGWNy8.js";import{f as Qe}from"./global-BCvoRSag.js";var We=h('<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 class="flex flex-col"><input 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">'),Xe=h('<option class="flex items-center gap-2">'),Ke=h("<option>");const Ve=l=>{const[r]=Z();return e(De,{ref:n=>{var i;return(i=l.ref)==null?void 0:i.call(l,n)},get icon(){return e(be,{size:24})},get title(){return r("proxiesSettings")},get children(){var n=We(),i=n.firstChild,c=i.firstChild,u=c.firstChild,m=i.nextSibling,L=m.firstChild,d=m.nextSibling,D=d.firstChild,p=d.nextSibling,C=p.firstChild,P=p.nextSibling,S=P.firstChild,g=P.nextSibling,E=g.firstChild,M=E.firstChild,$=g.nextSibling,k=$.firstChild,z=k.firstChild,X=$.nextSibling,U=X.firstChild;return t(i,e(A,{withDivider:!0,get children(){return r("autoCloseConns")}}),c),u.addEventListener("change",o=>pe(o.target.checked)),t(m,e(A,{withDivider:!0,get children(){return r("urlForLatencyTest")}}),L),L.addEventListener("change",o=>$e(o.target.value)),t(d,e(A,{withDivider:!0,get children(){return[b(()=>r("latencyTestTimeoutDuration"))," (",b(()=>r("ms")),")"]}}),D),D.addEventListener("change",o=>_e(Number(o.target.value))),t(p,e(A,{withDivider:!0,get children(){return r("urlForIPv6SupportTest")}}),C),C.addEventListener("change",o=>{var _;return ye((_=o.target.value)==null?void 0:_.trim())}),t(P,e(A,{withDivider:!0,get children(){return r("proxiesSorting")}}),S),S.addEventListener("change",o=>we(o.target.value)),t(S,e(F,{get each(){return Object.values(Ce)},children:o=>(()=>{var _=Xe();return _.value=o,t(_,()=>r(o)),_})()})),t(g,e(A,{withDivider:!0,get children(){return r("hideUnAvailableProxies")}}),E),M.addEventListener("change",o=>Pe(o.target.checked)),t($,e(A,{withDivider:!0,get children(){return r("renderInTwoColumns")}}),k),z.addEventListener("change",o=>Se(o.target.checked)),t(X,e(A,{withDivider:!0,get children(){return r("proxiesPreviewType")}}),U),U.addEventListener("change",o=>Te(o.target.value)),t(U,e(F,{get each(){return Object.values(H)},children:o=>(()=>{var _=Ke();return _.value=o,t(_,()=>r(o)),_})()})),x(()=>u.checked=Le()),x(()=>L.value=Ee()),x(()=>D.value=Ne()),x(()=>C.value=Ie()),x(()=>S.value=G()),x(()=>M.checked=he()),x(()=>z.checked=ee()),x(()=>U.value=J()),n}})},ge=l=>{const r=()=>J()===H.OFF,n=b(()=>l.proxyNameList.length<=10),i=b(()=>{const u=J();return u===H.BAR||u===H.Auto&&!n()}),c=b(()=>{const u=J();return u===H.DOTS||u===H.Auto&&n()});return e(Y,{get when(){return!r()},get children(){return e(Me,{get children(){return[e(le,{get when(){return i()},get children(){return e(qe,{get proxyNameList(){return l.proxyNameList},get now(){return l.now}})}}),e(le,{get when(){return c()},get children(){return e(tt,{get proxyNameList(){return l.proxyNameList},get now(){return l.now}})}})]}})}})};var Je=h('<div class="flex items-center gap-2 py-2"><div class="my-1 flex flex-1 items-center justify-center overflow-hidden rounded-2xl [&amp;>*]:h-2"><div class=bg-success></div><div class=bg-warning></div><div class=bg-error></div><div class=bg-neutral>');const qe=l=>{const{getLatencyByName:r}=ne(),n=b(()=>l.proxyNameList.map(d=>r(d))),i=b(()=>n().length),c=b(()=>n().filter(d=>d>I().NOT_CONNECTED&&d<=I().MEDIUM).length),u=b(()=>n().filter(d=>d>I().MEDIUM&&d<=I().HIGH).length),m=b(()=>n().filter(d=>d>I().HIGH).length),L=b(()=>n().filter(d=>d===I().NOT_CONNECTED).length);return(()=>{var d=Je(),D=d.firstChild,p=D.firstChild,C=p.nextSibling,P=C.nextSibling,S=P.nextSibling;return t(d,e(me,{get name(){return l.now}}),null),x(g=>{var E=`${c()*100/i()}%`,M=`${u()*100/i()}%`,$=`${m()*100/i()}%`,k=`${L()*100/i()}%`;return E!==g.e&&((g.e=E)!=null?p.style.setProperty("width",E):p.style.removeProperty("width")),M!==g.t&&((g.t=M)!=null?C.style.setProperty("width",M):C.style.removeProperty("width")),$!==g.a&&((g.a=$)!=null?P.style.setProperty("width",$):P.style.removeProperty("width")),k!==g.o&&((g.o=k)!=null?S.style.setProperty("width",k):S.style.removeProperty("width")),g},{e:void 0,t:void 0,a:void 0,o:void 0}),d})()};var Ze=h("<div>"),Ge=h('<div class="flex items-center gap-2 py-2"><div class="flex flex-1 flex-wrap items-center gap-1">');const et=l=>{let r=l.selected?"bg-white border-4 border-success":"bg-success";return typeof l.latency!="number"||l.latency===I().NOT_CONNECTED?r=l.selected?"bg-white border-4 border-neutral":"bg-neutral":l.latency>I().HIGH?r=l.selected?"bg-white border-4 border-error":"bg-error":l.latency>I().MEDIUM&&(r=l.selected?"bg-white border-4 border-warning":"bg-warning"),(()=>{var n=Ze();return x(i=>{var c=B("h-4 w-4 rounded-full",r),u=l.name;return c!==i.e&&q(n,i.e=c),u!==i.t&&ke(n,"title",i.t=u),i},{e:void 0,t:void 0}),n})()},tt=l=>{const{getLatencyByName:r}=ne();return(()=>{var n=Ge(),i=n.firstChild;return t(i,e(F,{get each(){return l.proxyNameList.map(c=>[c,r(c)])},children:([c,u])=>{const m=l.now===c;return e(et,{name:c,latency:u,selected:m})}})),t(n,e(me,{get name(){return l.now}}),null),n})()};var nt=h("<progress class=progress max=100>"),rt=h('<div class="text-sm text-slate-500"> / <!> ( <!>% )'),st=h('<div class="text-sm text-slate-500">: ');const lt=l=>{const{Download:r=0,Upload:n=0,Total:i=0,Expire:c=0}=l,u=te(i,{units:"iec"}),m=te(r+n,{units:"iec"}),L=Oe.toFinite(((r+n)/i*100).toFixed(2));return{total:u,used:m,percentage:L,expirePrefix:()=>{const[p]=Z();return p("expire")},expireStr:()=>{const[p]=Z();return c===0?p("noExpire"):Ae(c*1e3).format("YYYY-MM-DD")}}},it=l=>{if(!l.subscriptionInfo)return;const r=lt(l.subscriptionInfo);return[(()=>{var n=nt();return x(()=>n.value=r.percentage),n})(),(()=>{var n=rt(),i=n.firstChild,c=i.nextSibling,u=c.nextSibling,m=u.nextSibling;return m.nextSibling,t(n,()=>`${r.used}`,i),t(n,()=>`${r.total}`,c),t(n,()=>r.percentage,m),n})(),(()=>{var n=st(),i=n.firstChild;return t(n,()=>r.expirePrefix(),i),t(n,()=>r.expireStr(),null),n})()]};var ve=h("<div>"),at=h('<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">'),ct=h('<button><span></span><div class="badge badge-sm">'),ot=h('<div class="flex items-center justify-between pr-8"><div class="flex items-center gap-2"><span></span><div class="badge badge-sm">'),dt=h('<div class="flex items-center justify-between text-sm text-slate-500"><span> </span><span>/s'),ut=h('<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">'),gt=h('<div class="text-sm text-slate-500"> :: <!> ');const mt=()=>{const l=Be();if(!Fe())return l("/setup",{replace:!0}),null;let r;const[n]=Z(),{fetchProxies:i,proxies:c,selectProxyInGroup:u,proxyProviders:m,updateProviderByProviderName:L,updateAllProvider:d,proxyGroupLatencyTest:D,proxyProviderLatencyTest:p,proxyGroupLatencyTestingMap:C,proxyProviderLatencyTestingMap:P,isAllProviderUpdating:S,updatingMap:g}=ne(),E=b(()=>c().filter(f=>!f.hidden)),{speedGroupByName:M}=Ue(),[$,k]=je(ie({}),{name:"collapsedMap",storage:localStorage}),z=(f,w)=>{k(V=>({...V,[f]:w}))};Re(i);const X=async(f,w)=>{f.stopPropagation(),D(w)},U=(f,w)=>{f.stopPropagation(),p(w)},o=(f,w)=>{f.stopPropagation(),L(w)},_=async f=>{f.stopPropagation(),d()},[K,fe]=ie("proxies"),xe=()=>[{type:"proxies",name:n("proxies"),count:E().length},{type:"proxyProviders",name:n("proxyProviders"),count:m().length}];return(()=>{var f=at(),w=f.firstChild,V=w.firstChild,re=V.nextSibling,se=w.nextSibling;return t(V,e(F,{get each(){return xe()},children:v=>(()=>{var s=ct(),O=s.firstChild,Q=O.nextSibling;return s.$$click=()=>fe(v.type),t(O,()=>v.name),t(Q,()=>v.count),x(()=>q(s,B(K()===v.type&&"tab-active","tab-sm sm:tab-md tab gap-2 px-2"))),s})()})),t(w,e(Y,{get when(){return K()==="proxyProviders"},get children(){return e(W,{class:"btn btn-circle btn-sm",get disabled(){return S()},onClick:v=>_(v),get icon(){return e(ae,{get class(){return B(S()&&"animate-spin text-success")}})}})}}),re),t(re,e(W,{class:"btn-circle btn-primary btn-sm",onClick:()=>r==null?void 0:r.showModal(),get icon(){return e(He,{})}})),t(se,e(Y,{get when(){return K()==="proxies"},get children(){var v=ve();return t(v,e(F,{get each(){return E()},children:s=>{const O=b(()=>Ye(ce(s.all??[],G()),he())),Q=[(()=>{var a=ot(),y=a.firstChild,T=y.firstChild,j=T.nextSibling;return t(T,()=>s.name),t(j,()=>{var N;return(N=s.all)==null?void 0:N.length}),t(a,e(W,{class:"btn-circle btn-sm",get disabled(){return C()[s.name]},onClick:N=>X(N,s.name),get icon(){return e(oe,{get class(){return B(C()[s.name]&&"animate-pulse text-success")}})}}),null),a})(),(()=>{var a=dt(),y=a.firstChild,T=y.firstChild,j=y.nextSibling,N=j.firstChild;return t(y,()=>s.type,T),t(y,()=>{var R;return((R=s.now)==null?void 0:R.length)>0&&` :: ${s.now}`},null),t(j,()=>te(M()[s.name]??0).toString(),N),a})(),e(Y,{get when(){return!$()[s.name]},get children(){return e(ge,{get proxyNameList(){return O()},get now(){return s.now}})}})];return e(de,{get isOpen(){return $()[s.name]},title:Q,onCollapse:a=>z(s.name,a),get children(){return e(F,{get each(){return O()},children:a=>e(ue,{proxyName:a,get isSelected(){return s.now===a},onClick:()=>void u(s,a)})})}})}})),x(()=>q(v,B("grid grid-cols-1 place-items-start gap-2",ee()?"sm:grid-cols-2":"sm:grid-cols-1"))),v}}),null),t(se,e(Y,{get when(){return K()==="proxyProviders"},get children(){var v=ve();return t(v,e(F,{get each(){return m()},children:s=>{const O=b(()=>ce(s.proxies.map(a=>a.name)??[],G())),Q=[(()=>{var a=ut(),y=a.firstChild,T=y.firstChild,j=T.nextSibling,N=y.nextSibling;return t(T,()=>s.name),t(j,()=>s.proxies.length),t(N,e(W,{class:"btn btn-circle btn-sm",get disabled(){return g()[s.name]},onClick:R=>o(R,s.name),get icon(){return e(ae,{get class(){return B(g()[s.name]&&"animate-spin text-success")}})}}),null),t(N,e(W,{class:"btn btn-circle btn-sm",get disabled(){return P()[s.name]},onClick:R=>U(R,s.name),get icon(){return e(oe,{get class(){return B(P()[s.name]&&"animate-pulse text-success")}})}}),null),a})(),e(it,{get subscriptionInfo(){return s.subscriptionInfo}}),(()=>{var a=gt(),y=a.firstChild,T=y.nextSibling;return T.nextSibling,t(a,()=>s.vehicleType,y),t(a,()=>n("updated"),T),t(a,()=>Qe(s.updatedAt),null),a})(),e(Y,{get when(){return!$()[s.name]},get children(){return e(ge,{get proxyNameList(){return O()}})}})];return e(de,{get isOpen(){return $()[s.name]},title:Q,onCollapse:a=>z(s.name,a),get children(){return e(F,{get each(){return O()},children:a=>e(ue,{proxyName:a})})}})}})),x(()=>q(v,B("grid grid-cols-1 place-items-start gap-2",ee()?"sm:grid-cols-2":"sm:grid-cols-1"))),v}}),null),t(f,e(Ve,{ref:v=>r=v}),null),f})()};ze(["click"]);export{mt as default};