"Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/smzdm 9.9.6 rv:93.4 (iPhone13,4; iOS 14.5; zh_CN)/iphone_smzdmapp/9.9.6/wkwebview/jsbv_1.0.0",
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/smzdm 9.9.0 rv:91 (iPhone 11 Pro Max; iOS 14.2; zh_CN)/iphone_smzdmapp/9.9.0/wkwebview/jsbv_1.0.0",
functionMagicData(i,f){letu={fs:undefined,data:{}};if(i.isNode){u.fs=require("fs");try{u.fs.accessSync("./magic.json",u.fs.constants.R_OK|u.fs.constants.W_OK)}catch(e){u.fs.writeFileSync("./magic.json","{}",{encoding:"utf8"})}u.data=require("./magic.json")}consto=(e,t)=>{if(typeoft==="object"){returnfalse}else{returne===t}};consta=e=>{if(e==="true"){returntrue}elseif(e==="false"){returnfalse}elseif(typeofe==="undefined"){returnnull}else{returne}};constc=(e,t,r,s)=>{if(r){try{if(typeofe==="string")e=JSON.parse(e);if(e["magic_session"]===true){e=e[r]}else{e=null}}catch{e=null}}if(typeofe==="string"&&e!=="null"){try{e=JSON.parse(e)}catch{}}if(s===false&&!!e&&e["magic_session"]===true){e=null}if((e===null||typeofe==="undefined")&&t!==null&&typeoft!=="undefined"){e=t}e=a(e);returne};constl=t=>{if(typeoft==="string"){lete={};try{e=JSON.parse(t);constr=typeofe;if(r!=="object"||einstanceofArray||r==="bool"||e===null){e={}}}catch{}returne}elseif(tinstanceofArray||t===null||typeoft==="undefined"||t!==t||typeoft==="boolean"){return{}}else{returnt}};consty=(e,t=null,r="",s=false,n=null)=>{letl=n||u.data;if(!!l&&typeofl[e]!=="undefined"&&l[e]!==null){val=l[e]}else{val=!!r?{}:null}val=c(val,t,r,s);returnval};constd=(e,t=null,r="",s=false,n=null)=>{letl="";if(n||i.isNode){l=y(e,t,r,s,n)}else{if(i.isSurgeLike){l=$persistentStore.read(e)}elseif(i.isQuanX){l=$prefs.valueForKey(e)}l=c(l,t,r,s)}f.debug(`READ DATA [${e}]${!!r?`[${r}]`:""} <${typeofl}>\n${JSON.stringify(l)}`);returnl};constp=(t,r,s="",e=null)=>{letn=e||u.data;n=l(n);if(!!s){lete=l(n[t]);e["magic_session"]=true;e[s]=r;n[t]=e}else{n[t]=r}if(e!==null){e=n}returnn};constg=(e,t,r="",s=null)=>{if(typeoft==="undefined"||t!==t){returnfalse}if(!i.isNode&&(typeoft==="boolean"||typeoft==="number")){t=String(t)}letn="";if(s||i.isNode){n=p(e,t,r,s)}else{if(!r){n=t}else{if(i.isSurgeLike){n=!!$persistentStore.read(e)?$persistentStore.read(e):n}elseif(i.isQuanX){n=!!$prefs.valueForKey(e)?$prefs.valueForKey(e):n}n=l(n);n["magic_session"]=true;n[r]=t}}if(!!n&&typeofn==="object"){n=JSON.stringify(n,null,4)}f.debug(`WRITE DATA [${e}]${r?`[${r}]`:""} <${typeoft}>\n${JSON.stringify(t)}`);if(!s){if(i.isSurgeLike){return$persistentStore.write(n,e)}elseif(i.isQuanX){return$prefs.setValueForKey(n,e)}elseif(i.isNode){try{u.fs.writeFileSync("./magic.json",n);returntrue}catch(e){f.error(e);returnfalse}}}returntrue};conste=(t,r,s,n=o,l=null)=>{r=a(r);conste=d(t,null,s,false,l);if(n(e,r)===true){returnfalse}else{consti=g(t,r,s,l);lete=d(t,null,s,false,l);if(n===o&&typeofe==="object"){returni}returnn(r,e)}};constS=(e,t,r)=>{lets=r||u.data;s=l(s);if(!!t){obj=l(s[e]);deleteobj[t];s[e]=obj}else{deletes[e]}if(!!r){r=s}returns};constt=(e,t="",r=null)=>{lets={};if(r||i.isNode){s=S(e,t,r);if(!r){u.fs.writeFileSync("./magic.json",JSON.stringify(s,null,4))}else{r=s}}else{if(!t){if(i.isStorm){return$persistentStore.remove(e)}elseif(i.isSurgeLike){return$persistentStore.write(null,e)}elseif(i.isQuanX){return$prefs.removeValueForKey(e)}}else{if(i.isSurgeLike){s=$persistentStore.read(e)}elseif(i.isQuanX){s=$prefs.valueForKey(e)}s=l(s);deletes[t];constn=JSON.stringify(s,null,4);g(e,n)}}f.debug(`DELETE KEY [${e}]${!!t?`[${t}]`:""}`)};constr=(e,t=null)=>{letr=[];lets=d(e,null,null,true,t);s=l(s);if(s["magic_session"]!==true){r=[]}else{r=Object.keys(s).filter(e=>e!=="magic_session")}f.debug(`READ ALL SESSIONS [${e}] <${typeofr}>\n${JSON.stringify(r,null,4)}`);returnr};return{read:d,write:g,del:t,update:e,allSessions:r,defaultValueComparator:o,convertToObject:l}}
functionMagicHttp(l,u){constt="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1";constr="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59";letf;if(l.isNode){consta=require("axios");f=a.create()}classe{constructor(e=true){this.handlers=[];this.isRequest=e}use(e,t,r){this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:false,runWhen:r?r.runWhen:null});returnthis.handlers.length-1}eject(e){if(this.handlers[e]){this.handlers[e]=null}}forEach(t){this.handlers.forEach(e=>{if(e!==null){t(e)}})}}functionn(e){letr={...e};if(!!r.params){if(!l.isNode){lete=Object.keys(r.params).map(e=>{constt=encodeURIComponent(e);r.url=r.url.replace(newRegExp(`${e}=[^&]*`,"ig"),"");r.url=r.url.replace(newRegExp(`${t}=[^&]*`,"ig"),"");return`${t}=${encodeURIComponent(r.params[e])}`}).join("&");if(r.url.indexOf("?")<0)r.url+="?";if(!/(&|\?)$/g.test(r.url)){r.url+="&"}r.url+=e;deleter.params;u.debug(`Params to QueryString: ${r.url}`)}}returnr}constd=(e,t)=>{letr=typeoft==="object"?{headers:{},...t}:{url:t,headers:{}};if(!r.method){r["method"]=e}r=n(r);if(r["rewrite"]===true){if(l.isSurge){r.headers["X-Surge-Skip-Scripting"]=false;deleter["rewrite"]}elseif(l.isQuanX){r["hints"]=false;deleter["rewrite"]}}if(l.isSurge){if(r["method"]!=="GET"&&typeofr.headers["Content-Type"]==="string"&&r.headers["Content-Type"].indexOf("application/json")>=0&&r.bodyinstanceofArray){r.body=JSON.stringify(r.body);u.debug(`Convert Array object to String: ${r.body}`)}}elseif(l.isQuanX){if(r.hasOwnProperty("body")&&typeofr["body"]!=="string")r["body"]=JSON.stringify(r["body"]);r["method"]=e}elseif(l.isNode){if(e==="POST"||e==="PUT"||e==="PATCH"||e==="DELETE"){r.data=r.data||r.body}elseif(e==="GET"){r.params=r.params||r.body}deleter.body}returnr};consth=(t,r=null)=>{if(t){lete={...t,config:t.config||r,status:t.statusCode||t.status,body:t.body||t.data||"",headers:t.headers||t.header};if(typeofe.body==="string"){try{e.body=JSON.parse(e.body)}catch{}}deletet.data;returne}else{lete={config:r,status:null,body:"",headers:{}};returne}};consto=n=>{if(!!n){deleten["Content-Length"];lete=newSet(["Accept","Accept-CH","Accept-Charset","Accept-Features","Accept-Encoding","Accept-Language","Accept-Ranges","Access-Control-Allow-Credentials","Access-Control-Allow-Origin","Access-Control-Allow-Methods","Access-Control-Allow-Headers","Access-Control-Max-Age","Access-Control-Expose-Headers","Access-Control-Request-Method","Access-Control-Request-Headers","Age","Allow","Alternates","Authorization","Cache-Control","Connection","Content-Encoding","Content-Language","ontent-Length","Content-Location","Content-Range","Content-Security-Policy","Content-Type","Cookie","DNT","Date","ETag","Expect","Expires","From","Host","If-Match","If-Modified-Since","If-None-Match","If-Range","If-Unmodified-Since","Last-Event-ID","Last-Modified","Link","Location","Max-Forwards","Negotiate","Origin","Pragma","Proxy-Authenticate","Proxy-Authorization","Range","Referer","Retry-After","Sec-Websocket-Extensions","Sec-Websocket-Key","Sec-Websocket-Origin","Sec-Websocket-Protocol","Sec-Websocket-Version","Server","Set-Cookie","Set-Cookie2","Strict-Transport-Security","TCN","TE","Trailer","Transfer-Encoding","Upgrade","User-Agent","Variant-Vary","Vary","Via","Warning","WWW-Authenticate","X-Content-Duration","X-Content-Security-Policy","X-DNSPrefetch-Control","X-Frame-Options","X-Requested-With"]);for(letrofObject.keys(n)){if(!e.has(r)){for(lettofe){lete=r.replace(newRegExp(t,"ig"),t);if(r!==e){n[e]=n[r];deleten[r];break}}}}if(!n["User-Agent"]){if(l.isNode){n["User-Agent"]=r}else{n["User-Agent"]=t}}returnn}returnn};constp=(t,r=null)=>{if(!!t&&t.status>=400){u.debug(`Raise exception when status code is ${t.status}`);lete={name:"RequestException",message:`Request failed with status code ${t.status}`,config:r||t.config,response:t};returne}};consts={request:newe,response:newe(false)}
// prettier-ignore
functionMagicNotification(r,f,l){lets=null;letu=null;constc=typeofMagicHttp==="function"?MagicHttp(f,l):undefined;conste=t=>{try{lete=t.replace(/\/+$/g,"");s=`${/^https?:\/\/([^/]*)/.exec(e)[0]}/push`;u=/\/([^\/]+)\/?$/.exec(e)[1]}catch(e){l.error(`Bark url error: ${e}.`)}};functiont(e=r,t="",i="",o=""){constn=i=>{try{lett={};if(typeofi==="string"){if(f.isLoon)t={openUrl:i};elseif(f.isQuanX)t={"open-url":i};elseif(f.isSurge)t={url:i}}elseif(typeofi==="object"){if(f.isLoon){t["openUrl"]=!!i["open-url"]?i["open-url"]:"";t["mediaUrl"]=!!i["media-url"]?i["media-url"]:""}elseif(f.isQuanX){t=!!i["open-url"]||!!i["media-url"]?i:{}}elseif(f.isSurge){lete=i["open-url"]||i["openUrl"];t=e?{url:e}:{}}}returnt}catch(e){l.error(`Failed to convert notification option, ${e}`)}returni};o=n(o);if(arguments.length==1){e=r;t="",i=arguments[0]}l.notify(`title:${e}\nsubTitle:${t}\nbody:${i}\noptions:${typeofo==="object"?JSON.stringify(o):o}`);if(f.isSurge){$notification.post(e,t,i,o)}elseif(f.isLoon){if(!!o)$notification.post(e,t,i,o);else$notification.post(e,t,i)}elseif(f.isQuanX){$notify(e,t,i,o)}if(s&&u&&typeofc!=="undefined"){p(e,t,i)}}functioni(e=r,t="",i="",o=""){if(l.level==="DEBUG"){if(arguments.length==1){e=r;t="",i=arguments[0]}this.notify(e,t,i,o)}}functionp(e=r,t="",i="",o=""){if(typeofc==="undefined"||typeofc.post==="undefined"){throw"Bark notification needs to import MagicHttp module."}letn={url:s,headers:{"Content-Type":"application/json; charset=utf-8"},body:{title:e,body:t?`${t}\n${i}`:i,device_key:u}};c.post(n).catch(e=>{l.error(`Bark notify error: ${e}`)})}return{post:t,debug:i,bark:p,setBark:e}}
// prettier-ignore
functionMagicUtils(r,h){conste=(o,i=5,l=0,a=null)=>{return(...e)=>{returnnewPromise((s,r)=>{functionn(...t){Promise.resolve().then(()=>o.apply(this,t)).then(e=>{if(typeofa==="function"){Promise.resolve().then(()=>a(e)).then(()=>{s(e)}).catch(e=>{if(i>=1){if(l>0)setTimeout(()=>n.apply(this,t),l);elsen.apply(this,t)}else{r(e)}i--})}else{s(e)}}).catch(e=>{h.error(e);if(i>=1&&l>0){setTimeout(()=>n.apply(this,t),l)}elseif(i>=1){n.apply(this,t)}else{r(e)}i--})}n.apply(this,e)})}};constt=(e,t="yyyy-MM-dd hh:mm:ss")=>{lets={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};if(/(y+)/.test(t))t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length));for(leteins)if(newRegExp("("+e+")").test(t))t=t.replace(RegExp.$1,RegExp.$1.length==1?s[e]:("00"+s[e]).substr((""+s[e]).length));returnt};consts=()=>{returnt(newDate,"yyyy-MM-dd hh:mm:ss")};constn=()=>{returnt(newDate,"yyyy-MM-dd")};consto=t=>{returnnewPromise(e=>setTimeout(e,t))};consti=(e,t=null)=>{if(r.isNode){consts=require("assert");if(t)s(e,t);elses(e)}else{if(e!==true){lete=`AssertionError: ${t||"The expression evaluated to a falsy value"}`;h.error(e)}}};return{retry:e,formatTime:t,now:s,today:n,sleep:o,assert:i}}