clash_for_linux/dashboard/public/assets/Rules.70e6962f.js

2 lines
7.7 KiB
JavaScript
Raw Normal View History

import{ah as S,ai as E,aj as k,ak as b,al as B,am as R,r as m,an as T,ao as O,G as y,ap as q,aq as _,V as A,b as d,j as a,U as F,B as U,u as x,e as j,h as L,C as z,i as D}from"./index.171f553a.js";import{a as Q,V}from"./index.esm.e4dd1508.js";import{R as P,T as W}from"./TextFitler.61537a57.js";import{f as H}from"./index.92e2d967.js";import{F as G,p as J}from"./Fab.ef67ff10.js";import{u as K}from"./useRemainingViewPortHeight.7395542b.js";import"./debounce.c2d20996.js";class X extends S{constructor(e,t){super(),this.client=e,this.setOptions(t),this.bindMethods(),this.updateResult()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.client.defaultMutationOptions(e),E(t,this.options)||this.client.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.currentMutation,observer:this})}onUnsubscribe(){if(!this.listeners.length){var e;(e=this.currentMutation)==null||e.removeObserver(this)}}onMutationUpdate(e){this.updateResult();const t={listeners:!0};e.type==="success"?t.onSuccess=!0:e.type==="error"&&(t.onError=!0),this.notify(t)}getCurrentResult(){return this.currentResult}reset(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})}mutate(e,t){return this.mutateOptions=t,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,{...this.options,variables:typeof e<"u"?e:this.options.variables}),this.currentMutation.addObserver(this),this.currentMutation.execute()}updateResult(){const e=this.currentMutation?this.currentMutation.state:k(),t={...e,isLoading:e.status==="loading",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset};this.currentResult=t}notify(e){b.batch(()=>{if(this.mutateOptions){if(e.onSuccess){var t,r,n,i;(t=(r=this.mutateOptions).onSuccess)==null||t.call(r,this.currentResult.data,this.currentResult.variables,this.currentResult.context),(n=(i=this.mutateOptions).onSettled)==null||n.call(i,this.currentResult.data,null,this.currentResult.variables,this.currentResult.context)}else if(e.onError){var o,u,l,c;(o=(u=this.mutateOptions).onError)==null||o.call(u,this.currentResult.error,this.currentResult.variables,this.currentResult.context),(l=(c=this.mutateOptions).onSettled)==null||l.call(c,void 0,this.currentResult.error,this.currentResult.variables,this.currentResult.context)}}e.listeners&&this.listeners.forEach(p=>{p(this.currentResult)})})}}function w(s,e,t){const r=B(s,e,t),n=R({context:r.context}),[i]=m.exports.useState(()=>new X(n,r));m.exports.useEffect(()=>{i.setOptions(r)},[i,r]);const o=T(m.exports.useCallback(l=>i.subscribe(b.batchCalls(l)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),u=m.exports.useCallback((l,c)=>{i.mutate(l,c).catch(Y)},[i]);if(o.error&&O(i.options.useErrorBoundary,[o.error]))throw o.error;return{...o,mutate:u,mutateAsync:o.mutate}}function Y(){}function Z(s){const e=s.providers,t=Object.keys(e),r={};for(let n=0;n<t.length;n++){const i=t[n];r[i]={...e[i],idx:n}}return{byName:r,names:t}}async function $(s,e){const{url:t,init:r}=y(e);let n={providers:{}};try{const i=await fetch(t+s,r);i.ok&&(n=await i.json())}catch(i){console.log("failed to GET /providers/rules",i)}return Z(n)}async function C({name:s,apiConfig:e}){const{url:t,init:r}=y(e);try{return(await fetch(t+`/providers/rules/${s}`,{method:"PUT",...r})).ok}catch(n){return console.log("failed to PUT /providers/rules/:name",n),!1}}async function ee({names:s,apiConfig:e}){for(let t=0;t<s.length;t++)await C({name:s[t],apiConfig:e})}var te=function(s,e,t,r,n,i,o,u){if(!s){var l;if(e===void 0)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[t,r,n,i,o,u],p=0;l=new Error(e.replace(/%s/g,function(){return c[p++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}},se=te;function re(s){return se(s.rules&&s.rules.length>=0,"there is no valid rules list in the rul