/*
测试脚本
需要crypto-js.js依赖
*/

const jsname = '中青极速提现'
const $ = Env(jsname)
let logDebug = 0
const notifyFlag = process.env.zqnotify || 1; 	//0为关闭通知,1为打开通知,默认为0
const CryptoJS = require('crypto-js')

const notify = $.isNode() ? require('./sendNotify') : '';


let notifyStr=''
let userCookie = ($.isNode() ? process.env.zqkdFastCookie : $.getdata('zqkdFastCookie')) || '';
let userCookieArr = []
let cash = ($.isNode() ? process.env.zqkdCash : $.getdata('zqkdCash')) || '1';	//提现额度
let zqkdCashtype = ($.isNode() ? process.env.zqkdFastCashtype : $.getdata('zqkdFastCashtype')) || 'alipay';	//提现类型,微信wechat和支付宝alipay
let withdraw_auto=process.env.zqkd_withdraw_auto||1	//是否打开自动提现,默认关闭
let zqkdCashtypeArr=[]

let tmpCk=''
let userIdx=''

!(async () => {

    if(!(await checkEnv())) {
            return
    }
	for (userIdx = 0; userIdx < userCookieArr.length; userIdx++) {
		tmpCk = userCookieArr[userIdx]		
		await getBalance(userIdx)
		await $.wait(500)
		await payMethodList(userIdx)
		//break
	}
	await showmsg()
	
	
})()
    .catch((e) => {
        $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
    })
    .finally(() => {
        $.done();
    })
	


async function checkEnv() {
    if(userCookie) {
        if(userCookie.indexOf('@') > -1) {
            let userCookies = userCookie.split('@')
            for(let i=0; i<userCookies.length; i++) {
                userCookieArr.push(replaceCookie(userCookies[i]))
            }
        }else if (userCookie.indexOf('\n') > -1) {
			console.log('cookie使用回车符分割')
            let userCookies = userCookie.split('\n')
            for(let i=0; i<userCookies.length; i++) {
                userCookieArr.push(replaceCookie(userCookies[i]))
            }
		}else {
            userCookieArr.push(replaceCookie(userCookie))
        }
    } else {
        console.log('未找到userCookie')
        return false
    }
    if(zqkdCashtype) {
        if(zqkdCashtype.indexOf('@') > -1) {
            let zqkdCashtypes = zqkdCashtype.split('@')
            for(let i=0; i<zqkdCashtypes.length; i++) {
                zqkdCashtypeP = zqkdCashtypes[i]
                zqkdCashtypeArr.push(zqkdCashtypeP)
            }
        } else {
            zqkdCashtypeP = zqkdCashtype
            zqkdCashtypeArr.push(zqkdCashtypeP)
        }
    } else {
        console.log('未设置zqkdCashtype,默认提现到WECHAT')
        //return false
    }	
    if(userCookieArr.length == 0) {
        console.log('未找到有效的userCookie')
        return false
    }
    
    console.log(`共找到${userCookieArr.length}个用户`)
    return true
}
function replaceCookie(userCookieItem) {
    let replaceItem = ''
    let zqkey = ''
    let zqkey_id = ''
	let params =UrlParamHash(userCookieItem)
    
    replaceItem = `uid=${params['uid']}&token=${params['token']}&token_id=${params['token_id']}`
    
    return replaceItem
}

//通知
async function showmsg() {
    
    notifyBody = jsname + "运行通知\n"+"\n================\n" + notifyStr
    
    if (notifyFlag != 1) {
        console.log(notifyBody);
    }

    if (notifyFlag == 1) {
        //$.msg(notifyBody);
		console.log(notifyBody);
        if($.isNode()){await notify.sendNotify($.name, notifyBody );}
    }
}

async function getBalance(userIdx) {
    let caller = printCaller()
    let tmpCk = userCookieArr[userIdx]
	let money=0
    tmpCk = 'is_add_desktop=1&'+tmpCk+'&app_version=2.3.2&openudid=7dd446db27986d33&channel=c6001&device_id=37649193&device_model=OD105&device_brand=SMARTISAN&resolution=1080*1920&os_version=24&is_wxaccount=1&active_channel=c6001&access=wifi'
	let url = 'https://user.youth.cn/v1/user/userinfo.json?' + tmpCk
	//console.log(url)
    let urlObject = PopulateGetUrl(url)
    await HttpGet(urlObject,caller)
    let result = httpResult;
    if(!result) return
    //console.log(`${JSON.stringify(result)}\n`);
    if(result.error_code == 0) {
		let nowscore=Math.round(result.items.score/100)/100
		if (userIdx>0)logAndNotify(`-----------------------\n`)
        logAndNotify(`账户${userIdx+1} ${result.items.nickname}: `)
        logAndNotify(`【青豆总数】:${Math.round(result.items.score/100)/100}`)
        logAndNotify(`【今日收益】:${Math.round(result.items.today_score/100)/100}`)
		let zqstatus=result.items.user_status<1?'黑号':'正常'
		if(result.items.user_status<1)
		{
			logAndNotify(`【黑号CK】:${tmpCk}`)
		}
		logAndNotify(`【账号状态】:${zqstatus}`)
		if (nowscore>=5) money=5
		else if (nowscore>=1) money=1
		else if (nowscore>=0.3) money=0.3
		let tmpstr=await mkurl(money)
		let tmpstr2=await mkurl(0.3)
		//if (userIdx==0)tmpstr2=''
		if (money>0.3) {
			console.log(`用户${userIdx+1}开始尝试提现${money}`)
			await withdraw(userIdx,tmpstr,money)
			await $.wait(2000)
			console.log(`用户${userIdx+1}开始尝试提现0.3`)
			await withdraw(userIdx,tmpstr2,0.3)
		}else await withdraw(userIdx,tmpstr2,0.3)
    } else {
        console.log(`查询今日收益失败:${result.msg}`)
    }	
}
async function mkurl(money){
	let tmpCk = userCookieArr[userIdx]
	let params =UrlParamHash(tmpCk)
	let tmpstr=`access=wifi&active_channel=c6001&add_desktop=1&app_version=2.3.2&channel=c6001&device_brand=SMARTISAN&device_id=37649193&device_model=OD105&is_login=1&is_wxaccount=1&money=${money}&openudid=7dd446db27986d33&os_version=24&resolution=1080*1920&token_id=${params['token_id']}&type=2&uid=${params['uid']}`
	//let params2=UrlParamHash(tmpstr)
	//console.log(params2)
	//let tmpstr2=getKeySort(getObjectKey(params2));
	//let tmpstr3=getKeyValueSortStr(tmpstr2)
	//console.log(tmpstr3)
	let fakesign=await encodeStr(tmpstr)
	let newstr='token_id='+params["token_id"]+'&sign='+fakesign+'&active_channel=c6001&token='+params["token"]+'&add_desktop=1&money='+money+'&is_login=1&is_wxaccount=1&app_version=2.3.2&openudid=7dd446db27986d33&device_id=37649193&device_model=OD105&resolution=1080*1920&uid='+params["uid"]+'&os_version=24&device_brand=SMARTISAN&access=wifi&type=2&channel=c6001'
	return newstr	
}
function encodeStr(str) {
	let Str1 = 'jdvylqcGGHHJZrfw0o2DgAbsmBCCGUapF1YChc'
	//replacedStr = decodeURIComponent(str)
	//replacedStr = replacedStr.replace(/\&/g, '')
	replacedStr = str.replace(/\&/g, '')
	replacedStr += Str1
	md5Str = CryptoJS.MD5(replacedStr).toString()
	return md5Str
}

//提现
async function withdraw(userIdx,withdrawbody,money) {
    let caller = printCaller()
	let paymodel=zqkdCashtypeArr[userIdx]
	if (!paymodel) paymodel='alipay'
	console.log('提现到:'+paymodel)
    let url = 'https://user.youth.cn/v1/Withdraw/wechat.json'

	if (paymodel=='alipay') url = 'https://user.youth.cn/FastApi/Alipay/withdraw.json'
    let urlObject = PopulatePostUrl(url,withdrawbody)
    await HttpPost(urlObject,caller)
    let result = httpResult;
    if(!result) return
    if(result.success == true) {
		otherts=true;
		logAndNotify(`用户${userIdx+1} 提现:${money} - ${result.message}🎉`);
    } else {
        logAndNotify(`用户${userIdx+1}提现${money}失败:${result.message}`)
    }
}
async function payMethodList(userIdx) {
    let caller = printCaller()
    let tmpCk = userCookieArr[userIdx]
	let money=0
	let url = 'https://user.youth.cn/FastApi/Withdraw/payMethodList.json?' + tmpCk
    let urlObject = PopulateGetUrl(url)
    await HttpGet(urlObject,caller)
    let result = httpResult;
    if(!result) return
	if (result.error_code==0){
		if (result.items&&result.items.wechat.username)
			logAndNotify(`[账号${userIdx+1}]绑定微信:${result.items.wechat.username}-${result.items.wechat.nickname}`)
		if (result.items&&result.items.alipay.username)
			logAndNotify(`[账号${userIdx+1}]绑定支付宝:${result.items.alipay.username}-${result.items.alipay.account}`)
	}
}
function logAndNotify(str) {
	console.log(str)
    notifyStr += str
    notifyStr += '\n'
}
 
/**
 * 传入对象 ,返回对象的属性数组
 */
function getObjectKey(obj){
	return Object.keys(obj);
}
 
/**
 * 传入数组
 * 按字母顺序,升序
 * 冒泡排序
 */
function getKeySort(strArr){
	var count = 0;
	var compareInt = 0;
	for (var i = 0; i < strArr.length; i++) {
		for (var j = 0; j < strArr.length - 1 - i; j++) {
			/*if(strArr [j].substring(0,1) > strArr[j + 1].substring(0,1)){
				var temp = strArr[j + 1];
				strArr[j + 1] = strArr[j];
				strArr[j] = temp;
			}
			if(strArr [j].substring(0,1) == strArr[j + 1].substring(0,1)){
				if(strArr [j].substring(1,2) > strArr[j + 1].substring(1,2)){
					var temp = strArr[j + 1];
					strArr[j + 1] = strArr[j];
					strArr[j] = temp;
				}
			}*/
			compareToIndexValue(strArr,compareInt,j);
			count ++ ;
		}	
	}
	/*console.log("遍历次数:"+count);*/
	/*console.log(strArr);*/
	return strArr;
}
 
/**
 *  根据首字母 排序,如果首字母相同则根据第二个字母排序...直到排出大小
 */
function compareToIndexValue(arr,int,arrIndex){
	if(arr[arrIndex].substring(int,int+1) == arr[arrIndex + 1].substring(int,int+1)) compareToIndexValue(arr,int+1,arrIndex);//如果第一位相等,则继续比较第二个字符
	else if(arr[arrIndex].substring(int,int+1) > arr[arrIndex + 1].substring(int,int+1)) {
		var temp = arr[arrIndex + 1];
		arr[arrIndex + 1] = arr[arrIndex];
		arr[arrIndex] = temp
	}/*else if(arr[arrIndex].substring(int,int+1) < arr[arrIndex + 1].substring(int,int+1)) return;*/
	return;
}
 
/**
 * 输入排序过后的key=value 值数组,用  "&" 字符拼接为字符串
 */
function getKeyValueSortStr(strArr){
	var longStr = "";
	for (var str in strArr) {
		longStr += strArr[str] + "&";
	}
	return longStr.substring(0,longStr.length - 1);//移除最后一个 & 符号
}
////////////////////////////////////////////////////////////////////
function PopulatePostUrl(url,reqBody){
    let rndtime = Math.floor(new Date().getTime()/1000)
    let urlObject = {
        url: url,
        headers: {
            'User-Agent': 'Mozilla/5.0 (Linux; Android 7.1.2; OD105 Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36 hap/1.5/smartisan com.miui.hybrid/1.5.0.2 com.youth.kandianquickapp/2.3.2 ({"packageName":"com.miui.home","type":"shortcut","extra":{"original":{"packageName":"com.tencent.mm","type":"url","extra":{}},"scene":"api"}})',
            'Host' : 'user.youth.cn',
            'Connection' : 'keep-alive',
        },
        body: reqBody
    }
    return urlObject;
}

function PopulateGetUrl(url){
    let rndtime = Math.floor(new Date().getTime()/1000)
    let urlObject = {
        url: url,
        headers: {
            'User-Agent': 'Mozilla/5.0 (Linux; Android 7.1.2; OD105 Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/64.0.3282.137 Mobile Safari/537.36 hap/1.5/smartisan com.miui.hybrid/1.5.0.2 com.youth.kandianquickapp/2.3.2 ({"packageName":"com.miui.home","type":"shortcut","extra":{"original":{"packageName":"com.tencent.mm","type":"url","extra":{}},"scene":"api"}})',
            'Host' : 'user.youth.cn',
            'Connection' : 'keep-alive',
        }
    }
    return urlObject;
}


async function HttpPost(url,caller) {
    httpResult = null
    return new Promise((resolve) => {
        $.post(url, async (err, resp, data) => {
            try {
                if (err) {
                    console.log(caller + ": post请求失败");
                    console.log(JSON.stringify(err));
                    $.logErr(err);
                } else {
                    if (safeGet(data)) {
                        httpResult = JSON.parse(data,caller);
                        if(logDebug) console.log(httpResult);
                    }
                }
            } catch (e) {
                $.logErr(e, resp);
            } finally {
                resolve();
            }
        });
    });
}

async function HttpGet(url,caller) {
    httpResult = null
    return new Promise((resolve) => {
        $.get(url, async (err, resp, data) => {
            try {
                if (err) {
                    console.log(caller + ": get请求失败");
                    console.log(JSON.stringify(err));
                    $.logErr(err);
                } else {
                    if (safeGet(data,caller)) {
                        httpResult = JSON.parse(data);
                        if(logDebug) console.log(httpResult);
                    }
                }
            } catch (e) {
                $.logErr(e, resp);
            } finally {
                resolve();
            }
        });
    });
}

function safeGet(data,caller) {
    try {
        if (typeof JSON.parse(data) == "object") {
            return true;
        } else {
            console.log(`Function ${caller}: 未知错误`);
            console.log(data)
        }
    } catch (e) {
        console.log(e);
        console.log(`Function ${caller}: 服务器访问数据为空,请检查自身设备网络情况`);
        return false;
    }
}

function printCaller(){
    return (new Error()).stack.split("\n")[2].trim().split(" ")[1]
}
//要写入的文件   要写入的内容       a追加|w写入(默认)|r(读取)  回调函数
function writelog(filename,model,content){
	//console.log('模式:'+model);
	fs.writeFile(filename,content,{flag:`${model}`},function (err) {
    if(err){
        return console.log(err);
    }else {
        console.log(`写入${filename}成功,模式为:${model}`);
    }
	})
}
//检查文件是否存在
function check_file_exist(filename){
	try { 
		fs.accessSync(filename, fs.constants.R_OK); 
		return true;
	} catch (err) { 
		console.error(`检测文件${filename}不存在`); 
		return false;
	}
}

function randomNum(minNum, maxNum) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * minNum + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
            break;
        default:
            return 0;
            break;
    }
}
function UrlParamHash(url) {
    var params = [], h;
	//var hash = url.slice(url.indexOf("?") + 1).split('&');

    var hash = url.split('&');
    for (var i = 0; i < hash.length; i++) {
        h = hash[i].split("=");
        params.push(h[0]);
        params[h[0]] = h[1];
    }
    return params;
}
// prettier-ignore
function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)}