small-package/luci-app-openclash/root/usr/share/openclash/dashboard/assets/index.65038aa0.js

3 lines
52 KiB
JavaScript
Raw Normal View History

2021-10-02 09:00:13 +08:00
var et=Object.defineProperty,tt=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable;var Ae=(t,n,s)=>n in t?et(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,b=(t,n)=>{for(var s in n||(n={}))st.call(n,s)&&Ae(t,s,n[s]);if(Fe)for(var s of Fe(n))ot.call(n,s)&&Ae(t,s,n[s]);return t},D=(t,n)=>tt(t,nt(n));import{R as e,c as x,r as m,f as fe,E as $e,a as le,b as at,d as _,e as he,u as Le,g as rt,h as T,i as Ie,j as Ee,Z as G,k as lt,l as ye,m as ct,n as xe,o as it,p as ut,q as mt,s as ee,t as dt,A as pt,F as ft,v as ht,N as Et,S as yt,w as Be,x as xt,H as gt}from"./vendor.ca041cc5.js";const vt=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const r of o)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function s(o){const r={};return o.integrity&&(r.integrity=o.integrity),o.referrerpolicy&&(r.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?r.credentials="include":o.crossorigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function a(o){if(o.ep)return;o.ep=!0;const r=s(o);fetch(o.href,r)}};vt();function X(){return navigator.userAgent==="ClashX Runtime"}let N=null;class wt{constructor(n){this.instance=null,window.WebViewJavascriptBridge!=null&&(this.instance=window.WebViewJavascriptBridge),this.initBridge(s=>{this.instance=s,n()})}initBridge(n){if(!X())return n==null?void 0:n(null);if(window.WebViewJavascriptBridge!=null)return n(window.WebViewJavascriptBridge);if(window.WVJBCallbacks!=null)return window.WVJBCallbacks.push(n);window.WVJBCallbacks=[n];const s=document.createElement("iframe");s.style.display="none",s.src="https://__bridge_loaded__",document.documentElement.appendChild(s),setTimeout(()=>document.documentElement.removeChild(s),0)}async callHandler(n,s){return await new Promise(a=>{var o;(o=this.instance)==null||o.callHandler(n,s,a)})}async ping(){return await this.callHandler("ping")}async readConfigString(){return await this.callHandler("readConfigString")}async getPasteboard(){return await this.callHandler("getPasteboard")}async getAPIInfo(){return await this.callHandler("apiInfo")}async setPasteboard(n){return await this.callHandler("setPasteboard",n)}async writeConfigWithString(n){return await this.callHandler("writeConfigWithString",n)}async setSystemProxy(n){return await this.callHandler("setSystemProxy",n)}async getStartAtLogin(){return await this.callHandler("getStartAtLogin")}async getProxyDelay(n){return await this.callHandler("speedTest",n)}async setStartAtLogin(n){return await this.callHandler("setStartAtLogin",n)}async isSystemProxySet(){return await this.callHandler("isSystemProxySet")}}function Ct(t){if(N!=null){t();return}N=new wt(t)}function z(t){const{title:n,children:s,className:a,style:o}=t;return e.createElement("header",{className:x("header",a),style:o},e.createElement("h1",{className:"md:text-xl"},n),e.createElement("div",{className:"flex flex-auto items-center justify-end"},s))}function R(t){const{type:n,size:s=14,className:a,style:o}=t,r=x("clash-iconfont",`icon-${n}`,a),l=b({fontSize:s},o),c=D(b({},t),{className:r,style:l});return e.createElement("i",b({},c))}function W(){}function bt(t,n){const s=[],a=[];for(const o of t)n(o)?s.push(o):a.push(o);return[s,a]}function M(t){const n=["B","KB","MB","GB","TB"];let s=0;for(;~~(t/1024)&&s<n.length;)t/=1024,s++;return`${s===0?t:t.toFixed(2)} ${n[s]}`}function ge(t){const{className:n,checked:s=!1,disabled:a=!1,onChange:o=W}=t,r=x("switch",{checked:s,disabled:a},n);function l(){a||o(!s)}return e.createElement("div",{className:r,onClick:l},e.createElement(R,{className:"switch-icon font-bold",type:"check",size:20}))}const H=m.exports.forwardRef((t,n)=>{const{className:s,style:a,children:o}=t;return e.createElement
`).map(c=>JSON.parse(c));this.EE.emit("data",l),this.config.bufferLength>0&&(this.innerBuffer.push(...l),this.innerBuffer.length>this.config.bufferLength&&this.innerBuffer.splice(0,this.innerBuffer.length-this.config.bufferLength))}}retry(n){this.isClose||(this.EE.emit("error",n),window.setTimeout(()=>{this.loop()},this.config.retryInterval))}subscribe(n,s){this.EE.addListener(n,s)}unsubscribe(n,s){this.EE.removeListener(n,s)}buffer(){return this.innerBuffer.slice()}destory(){this.EE.removeAllListeners(),this.isClose=!0}}class Dt{constructor(n,s){this.axiosClient=at.create({baseURL:n,headers:s?{Authorization:`Bearer ${s}`}:{}})}async getConfig(){return await this.axiosClient.get("configs")}async updateConfig(n){return await this.axiosClient.patch("configs",n)}async getRules(){return await this.axiosClient.get("rules")}async getProxyProviders(){const n=await this.axiosClient.get("providers/proxies",{validateStatus(s){return s>=200&&s<300||s===404}});return n.status===404&&(n.data={providers:{}}),n}async getRuleProviders(){return await this.axiosClient.get("providers/rules")}async updateProvider(n){return await this.axiosClient.put(`providers/proxies/${encodeURIComponent(n)}`)}async updateRuleProvider(n){return await this.axiosClient.put(`providers/rules/${encodeURIComponent(n)}`)}async healthCheckProvider(n){return await this.axiosClient.get(`providers/proxies/${encodeURIComponent(n)}/healthcheck`)}async getProxies(){return await this.axiosClient.get("proxies")}async getProxy(n){return await this.axiosClient.get(`proxies/${encodeURIComponent(n)}`)}async getVersion(){return await this.axiosClient.get("version")}async getProxyDelay(n){return await this.axiosClient.get(`proxies/${encodeURIComponent(n)}/delay`,{params:{timeout:5e3,url:"http://www.gstatic.com/generate_204"}})}async closeAllConnections(){return await this.axiosClient.delete("connections")}async closeConnection(n){return await this.axiosClient.delete(`connections/${n}`)}async getConnections(){return await this.axiosClient.get("connections")}async changeProxySelected(n,s){return await this.axiosClient.put(`proxies/${encodeURIComponent(n)}`,{name:s})}}const Ft=_(async()=>{if(!X())return null;const t=await N.getAPIInfo();return{hostname:t.host,port:t.port,secret:t.secret,protocol:"http:"}}),He=he("externalControllers",[]);function te(){var f,d,p,h,E,C,F,A,L,k,P,I,V,J,j;const t=Le(Ft),n=rt(),s=Le(He);if(t!=null)return t;let a;{const U=document.querySelector('meta[name="external-controller"]');((f=U==null?void 0:U.content)==null?void 0:f.match(/^https?:/))!=null&&(a=new URL(U.content))}const o=new URLSearchParams(n.search),r=(E=(h=(p=o.get("host"))!=null?p:(d=s==null?void 0:s[0])==null?void 0:d.hostname)!=null?h:a==null?void 0:a.hostname)!=null?E:"127.0.0.1",l=(L=(A=(F=o.get("port"))!=null?F:(C=s==null?void 0:s[0])==null?void 0:C.port)!=null?A:a==null?void 0:a.port)!=null?L:"9090",c=(V=(I=(P=o.get("secret"))!=null?P:(k=s==null?void 0:s[0])==null?void 0:k.secret)!=null?I:a==null?void 0:a.username)!=null?V:"",i=((J=o.get("protocol"))!=null?J:r==="127.0.0.1")?"http:":(j=a==null?void 0:a.protocol)!=null?j:window.location.protocol;return{hostname:r,port:l,secret:c,protocol:i}}const At=_({key:"",instance:null});function $(){const{hostname:t,port:n,secret:s,protocol:a}=te(),[o,r]=T(At),l=`${a}//${t}:${n}?secret=${s}`;if(o.key===l)return o.instance;const c=new Dt(`${a}//${t}:${n}`,s);return r({key:l,instance:c}),c}const we=_(!0),$t=he("language",void 0);function S(){const[t,n]=T($t),s=m.exports.useMemo(()=>t!=null?t:kt(),[t]),a=m.exports.useCallback(function(o){function r(l){return lt(Re[s][o],l)}return{t:r}},[s]);return{lang:s,locales:St,setLang:n,translation:a}}const Ue=_({version:"",premium:!1});function ce(){const[t,n]=T(Ue),s=$(),a=Ee(we);return G([s],async function(){const o=await le.fromPromise(s.getVersion(),r=>r);a(o.isOk()),n(o.isErr()?{version:"",premium:!1}:{version:o.value.data.version,premium:!!o.value.data.premium})}),t}function Oe(){const[{premium:t}]=T(Ue),n=$(),{data:s,mutate:a}=G(["/providers/rule",n,t],async()=>{if(!t)return[];const o=await n.getRuleProv