ddan-js 2.6.22 → 2.6.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import e from"zlib";import t from"node:crypto";import r from"net";import{SocksClient as n}from"socks";var s={gbkLength:function(e){let t=0;if(!e)return 0;for(let r=0;r<e.length;r++)e.charCodeAt(r)>127||94===e.charCodeAt(r)?t+=2:t++;return t},gbkCut:function(e,t){if(!e||t<=0)return"";let r=0,n=0;for(let s=0;s<e.length&&(e.charCodeAt(s)>127||94===e.charCodeAt(s)?r+=2:r++,!(r>t));s++)n=s;return e.substr(0,n+1)}};const i="0123456789",o="abcdefghijklmnopqrstuvwxyz",a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var c={keyNumber:i,keyLower:o,keyUpper:a,keyChars:i+o+a};const l=(e=0,t=0)=>{const r=c.keyChars.split(""),n=[];let s;if(t=t||r.length,e)for(s=0;s<e;s++)n[s]=r[0|Math.random()*t];else{let e;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",s=0;s<36;s++)n[s]||(e=0|16*Math.random(),n[s]=r[19==s?3&e|8:e])}return n.join("")};class u{__map;__tagList;__eventId="";constructor(){this.__map=new Map,this.__tagList=[],this.__eventId=l()}clear(){return this.__map.clear(),this}on(e,t,r=""){if(!e||!t)return this;let n=this.__map.get(e);return n||(n=new Set,this.__map.set(e,n)),n.add(t),r&&this.__tagList.push({name:e,listener:t,tag:r}),this}emit(e,...t){if(!e)return this;const r=this.__map.get(e);if(!r)return this;return[...r].forEach((e=>e&&e(...t))),this}off(e,t){if(!e||!t)return this;this.__tagList=this.__tagList.filter((r=>r.name!==e||r.listener!==t));const r=this.__map.get(e);return r?(r.delete(t),r.size<=0&&this.__map.delete(e),this):this}remove(e){return e?(this.__tagList=this.__tagList.filter((t=>t.name!==e)),this.__map.delete(e),this):this}removeByTag(e){if(!e)return this;return this.__tagList.filter((t=>t.tag===e)).forEach((e=>{this.off(e.name,e.listener)})),this.__tagList=this.__tagList.filter((t=>t.tag!==e)),this}once(e,t){const r=(...n)=>{t(...n),this.off(e,r)};return this.on(e,r),this}has(e){return this.__map.has(e)}}class h{_loopTimer;_event=new u;started=!1;interval=0;constructor(e=0){this.interval=e||500}start(){return this.started||(this.stop(),this._loopTimer=setInterval((()=>{this._handleLoop()}),this.interval),this.started=!0),this}stop(){return this._loopTimer?(clearInterval(this._loopTimer),this._loopTimer=0,this.started=!1,this):this}restart(){return this.stop(),this.start(),this}on(e){return this._event.on("frame",e),this}off(e){return e?(this._event.off("frame",e),this):this}_handleLoop(){this._event.emit("frame")}}var f={oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};class d{date;timestamp=0;yyyy=0;yy="";M=0;MM="";d=0;dd="";h=0;hh="";m=0;mm="";s=0;ss="";S=0;SS="";SSS="";constructor(e){if(!e)return;const t="string"==typeof e||"number"==typeof e?new Date(e):e;t&&(this.date=t,this.timestamp=t.getTime(),this.toDate())}toDate(){return this.date?(this.yyyy=this.date.getFullYear(),this.yy=`${this.yyyy}`.substr(2),this.M=this.date.getMonth()+1,this.MM=(this.M<10?"0":"")+this.M,this.d=this.date.getDate(),this.dd=(this.d<10?"0":"")+this.d,this.h=this.date.getHours(),this.hh=(this.h<10?"0":"")+this.h,this.m=this.date.getMinutes(),this.mm=(this.m<10?"0":"")+this.m,this.s=this.date.getSeconds(),this.ss=(this.s<10?"0":"")+this.s,this.S=this.date.getMilliseconds(),this.SS=(this.S<10?"0":"")+this.S,this.SSS=this.S.toString().padStart(3,"0"),this):this}toCountdown(e=""){const t={countdown:0,timestamp:0,seconds:0,d:0,dd:"",h:0,hh:"",m:0,mm:"",s:0,ss:"",S:0,SS:"",SSS:"",desc:""};if(!this.timestamp)return t;t.timestamp=this.timestamp,t.countdown=Math.max(t.timestamp-Date.now(),0),t.seconds=Math.floor(t.countdown/f.oneSecond);let r=t.countdown;t.d=Math.floor(r/f.oneDay),t.dd=(t.d<10?"0":"")+t.d,r%=f.oneDay,t.h=Math.floor(r/f.oneHour),t.hh=(t.h<10?"0":"")+t.h,r%=f.oneHour,t.m=Math.floor(r/f.oneMinute),t.mm=(t.m<10?"0":"")+t.m,r%=f.oneMinute,t.s=Math.floor(r/f.oneSecond),t.ss=(t.s<10?"0":"")+t.s,r%=f.oneSecond,t.S=r,t.SS=(t.S<10?"0":"")+t.S,t.SSS=t.S.toString().padStart(3,"0");let n=e;return n||(n=t.countdown>f.oneHour?"hh:mm:ss":t.countdown>f.oneMinute?"mm:ss":"ss"),t.desc=n.replace(/\bdd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>t[e])),t}add(e=0){return e?(this.timestamp=this.timestamp+e,this.date=new Date(this.timestamp),this.toDate(),this):this}format(e="yyyy-MM-dd hh:mm:ss"){return e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>this[e]))}static get timezoneOffset(){return(new Date).getTimezoneOffset()/60}static getLocalTime(e=0){const t=new Date,r=t.getTime(),n=6e4*t.getTimezoneOffset();return new Date(r+n+36e5*e)}}const p=(e,t="yyyy-MM-dd hh:mm:ss")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;return r?g(r).format(t):""},g=e=>{const t="string"==typeof e||"number"==typeof e?new Date(e):e;return new d(t||0)};function y({year:e=0,month:t=0,date:r=0,hour:n=0,minute:s=0,second:i=0}){const o=`${e||"yyyy"}/${t||"MM"}/${r||"dd"} ${n}:${s}:${i}`;return new Date(p(Date.now(),o)).getTime()}var m={...f,now:function(){return g(new Date)},isToday:e=>e&&(new Date).toDateString()===new Date(e).toDateString(),parseTimestamp:y,todayZero:()=>y({}),format:p,countdown:(e,t="")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;if(!r)return"";return g(r).toCountdown(t)},dtime:g,loopFrame:(e=500)=>new h(e),getTimezoneOffset:()=>d.timezoneOffset,getLocalTime:d.getLocalTime};const w="object"==typeof global&&null!==global&&global.Object===Object&&global,b="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis,v="object"==typeof self&&null!==self&&self.Object===Object&&self,_=b||w||v||Function("return this")(),x=_.Symbol,{toString:k,hasOwnProperty:S,propertyIsEnumerable:A}=Object.prototype,$=x?x.toStringTag:void 0;function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":$&&$ in Object(e)?function(e){const t=S.call(e,$),r=e[$];let n=!1;try{e[$]=void 0,n=!0}catch(e){}const s=k.call(e);return n&&(t?e[$]=r:delete e[$]),s}(e):k.call(e)}var O={getTag:C,getType:function(e){return(C(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:k,hasOwnProperty:S,propertyIsEnumerable:A};const E="object"==typeof exports&&null!==exports&&!exports.nodeType&&exports,j=E&&"object"==typeof module&&null!==module&&!module.nodeType&&module,q=j&&j.exports===E&&w.process,L=(()=>{try{const e=j&&j.require&&j.require("util").types;return e||q&&q.binding&&q.binding("util")}catch(e){}})();var P="[object Function]",T="[object GeneratorFunction]",F="[object AsyncFunction]",M=9007199254740991;const R=/^(?:0|[1-9]\d*)$/,B=_?.Buffer?.isBuffer,D=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,U=L&&L.isTypedArray;function I(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function z(e){return null!=e&&"object"==typeof e}const K=Array.isArray;function N(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=M}(e.length)&&!V(e)}function H(e){return z(e)&&N(e)}function V(e){var t=I(e)?O.getTag(e):"";return t===P||t===T||t===F}function W(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)}function Z(e){return H(e)&&O.hasOwnProperty.call(e,"callee")&&(!O.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==O.toString.call(e))}const G="undefined"!=typeof window&&void 0!==window.document,J="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,Y=U?e=>U(e):e=>z(e)&&D.test(O.getTag(e)),Q="function"==typeof B?B:()=>!1;var X={is:function(e,t){return O.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===O.getTag(e)},isString:function(e){return"string"==typeof e||!K(e)&&z(e)&&"[object String]"==O.getTag(e)},isObject:I,isObjectLike:z,isPlainObject:function(e){if(!z(e)||"[object Object]"!=O.getTag(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},isSymbol:function(e){return"symbol"==typeof e||z(e)&&"[object Symbol]"===O.getTag(e)},isFunction:V,isArray:K,isArrayLikeObject:H,isIndex:function(e,t){return!!(t=null==t?M:t)&&("number"==typeof e||R.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:N,isPrototype:W,isArguments:Z,isPromise:function(e){return"[object Promise]"===(I(e)?O.getTag(e):"")},isBrowser:G,isNode:J,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer,isEmpty:e=>{if(null==e)return!0;if(N(e)&&(Array.isArray(e)||"string"==typeof e||"function"==typeof e.splice||Q(e)||Y(e)||Z(e)))return!e.length;const t=O.getTag(e);if("[object Map]"===t||"[object Set]"===t)return!e.size;if(W(e))return!Object.keys(e).length;for(const t in e)if(O.hasOwnProperty.call(e,t))return!1;return!0}};const ee=NaN,te=/^\s+|\s+$/g,re=/^[-+]0x[0-9a-f]+$/i,ne=/^0b[01]+$/i,se=/^0o[0-7]+$/i,ie=parseInt,oe=1/0,ae=17976931348623157e292;function ce(e){if("number"==typeof e)return e;if(X.isSymbol(e))return ee;if(X.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=X.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(te,"");const t=ne.test(e);return t||se.test(e)?ie(e.slice(2),t?2:8):re.test(e)?ee:+e}function le(e){return e?(e=ce(e))===oe||e===-oe?(e<0?-1:1)*ae:e==e?e:0:0===e?e:0}var ue={toNumber:ce,toFinite:le,toInteger:function(e){var t=le(e),r=t%1;return t==t?r?t-r:t:0}};const he="Expected a function",fe=Math.max,de=Math.min;function pe(e,t=300,r={}){let n,s,i,o,a,c,l=0,u=!1,h=!1,f=!0;if("function"!=typeof e)throw new TypeError(he);function d(t){const r=n,i=s;return n=s=void 0,l=t,o=e.apply(i,r),o}function p(e){const r=e-c;return void 0===c||r>=t||r<0||h&&e-l>=i}function g(){const e=Date.now();if(p(e))return y(e);a=setTimeout(g,function(e){const r=t-(e-c);return h?de(r,i-(e-l)):r}(e))}function y(e){return a=void 0,f&&n?d(e):(n=s=void 0,o)}function m(...e){const r=Date.now(),i=p(r);if(n=e,s=this,c=r,i){if(void 0===a)return function(e){return l=e,a=setTimeout(g,t),u?d(e):o}(c);if(h)return a=setTimeout(g,t),d(c)}return void 0===a&&(a=setTimeout(g,t)),o}return t=ue.toNumber(t)||0,X.isObject(r)&&(u=!!r.leading,h="maxWait"in r,i=h?fe(ue.toNumber(r.maxWait)||0,t):i,f="trailing"in r?!!r.trailing:f),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=s=a=void 0},m.flush=function(){return void 0===a?o:y(Date.now())},m.pending=function(){return void 0!==a},m}class ge{__list=[];constructor(e){this.push(e)}push(e){return e&&this.__list.push(e),this}clear(){return this.__list=[],this}_exec(e,t){let r;if(X.isFunction(e))r=e(t);else{if(X.isPromise(e))return e.then((e=>({...t,...e})));r=e}return X.isPromise(r)?r:Promise.resolve({...r,...t})}run(e){try{return this.__list.reduce(((e,t)=>e.then((e=>this._exec(t,e)))),Promise.resolve(e)).then((e=>[void 0,e])).catch((e=>[e,void 0]))}catch(e){return Promise.reject([e,void 0])}}}async function ye(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const me=e=>{try{let t;return t=X.isFunction(e)?e():e,ye(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var we={to:ye,go:e=>me(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:me};class be{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var ve={singleton:function(){class e{static __instance__;constructor(){}static get Instance(){return e.__instance__||(e.__instance__=new this),e.__instance__}static get I(){return this.Instance}}return e},getset:function(e){const t=new be;return void 0!==e&&t.set(e),t}};class _e{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return we.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class xe{__list=[];__count=0;__max=1;constructor(e=1){this.__count=0,this.__max=e>0?e:1,this.clear()}push(e,t){const r=new _e(e,t);return this.__list.push(r),this._step(),this}clear(){return this.__list=[],this.__count=0,this}_step(){if(this.__list.length<=0)return;if(this.__count>=this.__max)return;const e=this.__list.shift();e?(this.__count+=1,e?.run().finally((()=>{try{this.__count>0&&(this.__count-=1),this._step()}catch(e){console.error("[ddan] pipepine step finally",e)}}))):this._step()}async whenAll(){for(;;){if(this.__count<=0)break;await we.delay(100),this._step()}return this.clear()}}class ke extends(ve.singleton()){__lockedMap=new Map;pipeline=new xe;constructor(){super()}lock(e,t){if(!e||!t)return;const r=we.safeRun(t);return this.__lockedMap.set(e,r),r}unlock(e){e&&this.__lockedMap.has(e)&&this.__lockedMap.delete(e)}async exec(e,t){if(!e||!t)return we.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return we.safeRun(e);const s=await n;return this.unlock(t),s}}var Se={...we,sleep:we.delay,run:async function(e,t=0){if(t<=0)return we.safeRun(e);const r=t>0?Date.now():0,n=await we.safeRun(e),s=Date.now()-r;return s<t&&await we.delay(t-s),n},exec:(e,t="")=>ke.I.exec(e,t),debounce:pe,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return X.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),pe(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new ge(e),mutex:function(e){var t=null;return async function(...r){if((t=this||t||{}).__ddMutex)return!1;t.__ddMutex=!0;try{e&&await Promise.resolve(e.apply(this,r))}catch(e){console.log(e)}finally{t.__ddMutex=!1}}},polling:async function(e={}){const{func:t,interval:r=100,times:n=1e3}=e;let s=n;const i=r<1?100:r;do{if(!t)break;const[e,r]=await we.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await we.delay(i)}while(-1===n||s>0)},pipe:(e,t)=>ke.I.pipeline.push(e,t),pipeline:(e=1)=>new xe(e),safeTask:(e,t)=>new _e(e,t)};function Ae(e){return Math.floor(Math.random()*e)}function $e(e,t=10){return+parseFloat(Number(e).toExponential(t))}const Ce=180/Math.PI;var Oe={random:Ae,randomRange:function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},lerp:function(e,t,r){return e*(1-r)+t*r},randoms:function(e,t=1,r=!1){const n=[];for(;;){if(n.length>=t)break;if(!r&&n.length>=e)break;const s=Ae(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:$e,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=$e(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*Ce},degree2radian:function(e){return e/Ce},formatMemory:function(e){let t=e;const r={g:0,m:0,kb:0,b:0,desc:""};return t>=1<<30&&(r.g=Math.floor(t/(1<<30)),t%=1<<30),t>=1<<20&&(r.m=Math.floor(t/(1<<20)),t%=1<<20),t>=1024&&(r.kb=Math.floor(t/1024),t%=1024),r.b=t,r.desc=e>=1<<30?(e/(1<<30)).toFixed(2)+"G":e>=1<<20?(e/(1<<20)).toFixed(2)+"M":e>=1024?(e/1024).toFixed(2)+"KB":e+"B",r}};function Ee(e){return e!=e}function je(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,s=Array(n);++r<n;)s[r]=t(e[r],r,e);return s}(t,(function(t){return e[t]}))}var qe,Le,Pe=(qe=Object.keys,Le=Object,function(e){return qe(Le(e))}),Te=Math.max;function Fe(e,t){var r=X.isArray(e)||X.isArguments(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,s=!!n;for(var i in e)!t&&!O.hasOwnProperty.call(e,i)||s&&("length"==i||X.isIndex(i,n))||r.push(i);return r}function Me(e,t,r){const{length:n}=e;return r=void 0===r?n:r,!t&&r>=n?e:function(e,t,r){let n=null==e?0:e.length;if(!n)return[];(t=null==t?0:t)<0&&(t=-t>n?0:n+t),(r=(r=void 0===r?n:r)>n?n:r)<0&&(r+=n),n=t>r?0:r-t>>>0,t>>>=0;let s=-1;const i=new Array(n);for(;++s<n;)i[s]=e[s+t];return i}(e,t,r)}const Re=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function Be(e){return Re.test(e)}const De="\\ud800-\\udfff",Ue=`[${De}]`,Ie="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ze="\\ud83c[\\udffb-\\udfff]",Ke=`[^${De}]`,Ne="(?:\\ud83c[\\udde6-\\uddff]){2}",He="[\\ud800-\\udbff][\\udc00-\\udfff]",Ve=`${`(?:${Ie}|${ze})`}?`,We="[\\ufe0e\\ufe0f]?",Ze=We+Ve+`(?:\\u200d(?:${[Ke,Ne,He].join("|")})${We+Ve})*`,Ge=`(?:${[`${Ke}${Ie}?`,Ie,Ne,He,Ue].join("|")})`,Je=RegExp(`${ze}(?=${ze})|${Ge+Ze}`,"g");function Ye(e){return Be(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.split("")}(e)}function Qe(e){return t=>{if(!t)return"";const r=Be(t)?Ye(t):void 0,n=r?r[0]:t[0],s=r?Me(r,1).join(""):t.slice(1);return n[e]()+s}}const Xe="\\ud800-\\udfff",et="\\u2700-\\u27bf",tt="a-z\\xdf-\\xf6\\xf8-\\xff",rt="A-Z\\xc0-\\xd6\\xd8-\\xde",nt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",st="['’]",it=`[${nt}]`,ot=`[${et}]`,at=`[${tt}]`,ct=`[^${Xe}${nt+"\\d"+et+tt+rt}]`,lt="(?:\\ud83c[\\udde6-\\uddff]){2}",ut="[\\ud800-\\udbff][\\udc00-\\udfff]",ht=`[${rt}]`,ft=`(?:${at}|${ct})`,dt=`(?:${ht}|${ct})`,pt=`(?:${st}(?:d|ll|m|re|s|t|ve))?`,gt=`(?:${st}(?:D|LL|M|RE|S|T|VE))?`,yt="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",mt="[\\ufe0e\\ufe0f]?",wt=mt+yt+`(?:\\u200d(?:${[`[^${Xe}]`,lt,ut].join("|")})${mt+yt})*`,bt=`(?:${[ot,lt,ut].join("|")})${wt}`,vt=RegExp([`${ht}?${at}+${pt}(?=${[it,ht,"$"].join("|")})`,`${dt}+${gt}(?=${[it,ht+ft,"$"].join("|")})`,`${ht}?${ft}+${pt}`,`${ht}+${gt}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",bt].join("|"),"g");const _t=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),xt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function kt(e,t){if(void 0===t){const t=_t(e)?function(e){return e.match(vt)}(e):function(e){return e.match(xt)}(e);return t||[]}return e.match(t)||[]}function St(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:St(e)))}`;if(X.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const At=Qe("toUpperCase"),$t=Qe("toLowerCase");var Ct={toString:St,startCase:e=>kt(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+At(t)),""),snakeCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?At(t):t))),""),upperCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:At,lowerCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:$t,splitOnFirst:(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===e||""===t)return[];const r=e.indexOf(t);return-1===r?[]:[e.slice(0,r),e.slice(r+t.length)]},parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{let n=e;return e&&"string"==typeof e?(t&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?n=Number(e):!r||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(n="true"===e.toLowerCase()),n):n},replace:(e,t)=>{if(!e)return e;if(!t)return e;let r=e;return((Array.isArray(t)?t:[t])||[]).forEach((e=>{e.key&&e.value&&(r=r.replace(new RegExp(e.key,e.flag||""),e.value))})),r}};const Ot=e=>{if(!e)return e;if("object"!=typeof e)return e;const t=Array.isArray(e)?[]:{};for(const r in e)e.hasOwnProperty(r)&&(t[r]=Ot(e[r]));return t};const Et=(e,t,r={})=>{const n=e||{},{ignoreUndefined:s=!0,cover:i=!1}=r;if(!t)return n;for(const o in t){if(!t.hasOwnProperty(o))continue;const a=t[o];"object"!=typeof a||"object"!=typeof e[o]||i?s&&void 0===a||r.ignoreNull&&null===a||r.ignoreZero&&0===a||r.ignoreEmptyArray&&Array.isArray(a)&&a.length<=0||r.ignoreEmptyString&&"string"==typeof a&&""===a.trim()||(n[o]=a):n[o]=jt(e[o],a,r)}return n},jt=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?Et(e,t,r):Et({...e},t,r),n},qt=(e,t,r={})=>Et({...e},t,{cover:!0,...r}),Lt=(e,t,r,n,s=!1)=>{if(!e||!t||!r)return;let i=e[t];null!==i&&"object"==typeof i&&s&&Object.keys(i).forEach((e=>{Lt(i,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:o=>{r.call(n,o,i),i=o,s&&Lt(e,t,r,n,s)},get:()=>i})};var Pt={copy:(e,t={})=>{if(void 0===e)return;const r=JSON.parse(JSON.stringify(e));if("object"!=typeof r)return r;if(Array.isArray(r))return r;const{fields:n=[],camel:s=!1,pure:i=!0}=t;if((!n||n.length<=0)&&!s)return r;const o={};for(const e in r){if(!r.hasOwnProperty(e))continue;const a=s?i&&e.startsWith("_")?e:Ct.camelCase(e):e;if(n.length>0&&!n.includes(e)&&!n.includes(a))continue;const c=r[e];t.ignoreNull&&null===c||(t.ignoreZero&&0===c||t.ignoreEmptyArray&&Array.isArray(c)&&c.length<=0||t.ignoreEmptyString&&"string"==typeof c&&""===c.trim()||(o[a]=c))}return o},clone:Ot,merge:jt,isEmpty:e=>0!==e&&(!e||"object"==typeof e&&(Array.isArray(e)?!e.length:Object.keys(e).length<=0)),parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{if(!e&&"object"!=typeof e)return e;for(const[n,s]of Object.entries(e))if("object"==typeof s&&null!==s)for(const[e,n]of Object.entries(s))s[e]=Ct.parseValue(n,{number:t,boolean:r});else e[n]=Ct.parseValue(s,{number:t,boolean:r});return e},cloneClass:function(e){return e?"object"!=typeof e?e:Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e)):e},combine:qt,combines:(e,t={})=>{let r={};if(!e||e.length<=0)return r;const{ignoreUndefined:n=!0,ignoreNull:s=!0,ignoreZero:i=!0,ignoreEmptyArray:o=!0,ignoreEmptyString:a=!0,cover:c=!0}=t;return e.forEach((e=>r=qt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:i,ignoreEmptyArray:o,ignoreEmptyString:a,cover:c}))),r},observe:Lt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var Tt={...X,...O,...Pt,...ve,includes:function(e,t,r,n){e=X.isArrayLike(e)?e:function(e){return e?je(e,function(e){return X.isArrayLike(e)?Fe(e):function(e){if(!X.isPrototype(e))return Pe(e);var t=[];for(var r in Object(e))O.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?ue.toInteger(r):0;var s=e.length;return r<0&&(r=Te(s+r,0)),X.isString(e)?r<=s&&e.indexOf(t,r)>-1:!!s&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var s=e.length,i=r+(n?1:-1);n?i--:++i<s;)if(t(e[i],i,e))return i;return-1}(e,Ee,r);for(var n=r-1,s=e.length;++n<s;)if(e[n]===t)return n;return-1}(e,t,r)>-1},forof:(e,t)=>{if(!e)return;let r;if(X.isObject(e)&&(r=X.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var Ft={groupBy:function(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})},first:function(e){if(!e)return;return e.length<=0?void 0:e[0]},last:function(e){if(!e)return;const t=e.length;return t<=0?void 0:e[t-1]},toList:function(e){return Array.isArray(e)?e:e?[e]:[]}};var Mt={...Ft,stepAction:function(e,t,r=100){if(!X.isFunction(t))return;if(!X.isArray(e)||e.length<=0)return;let n=0;for(;e.length>n;){let s=r+n,i=e.slice(n,s);t&&t(i),n=s}},skip:function(e,t){if(!X.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!X.isArray(e)||e.length<=0)return[];const n=r||0;if(n>=e.length)return[];const s=t+n;return e.slice(n,e.length<s?e.length:s)||[]},distinct:function(e){return!X.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return Oe.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!X.isObject(e))return;const s=e[t];(X.isString(s)&&""!==s||X.isNumber(s))&&(n[s]=e[r])})),n):n}};const Rt="[object Object]",Bt="[object Array]",Dt=e=>Object.prototype.toString.call(e),Ut=(e,t,r=!1)=>{if(e===t)return;const n=Dt(e);if(n===Dt(t))if(n===Bt&&e.length>=t.length)for(let r=0;r<t.length;r++)Ut(e[r],t[r]);else if(n===Rt&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?Ut(e[n],t[n]):e[n]=null},It=(e,t,r,n="",s=!1)=>{if(e===t)return;const i=Dt(e),o=Dt(t);if(i===Bt&&o===i&&e.length>=t.length)for(let s=0;s<e.length;s++)It(e[s],t[s],r,`${n}[${s}]`);else if(i===Rt&&o===i&&(s||Object.keys(e).length>=Object.keys(t).length)){const s=Object.keys(e);for(let i of s){const s=e[i],o=t[i],a=Dt(s),c=Dt(o);if(s!==o)if(a===Bt&&c===a&&s.length>=o.length)for(let e=0;e<s.length;e++)It(s[e],o[e],r,`${n?n+".":""}${i}[${e}]`);else if(a===Rt&&c===a&&Object.keys(s).length>=Object.keys(o).length)for(let e in s)It(s[e],o[e],r,`${n?n+".":""}${i}.${e}`);else r[`${n?n+".":""}${i}`]=s}}else r[n]=e};class zt{list=[];constructor(){this.invoke=this.invoke.bind(this)}use(e){this.list=this.list.concat(e)}invoke(e){return this.list.reduce(((e,t)=>e.then((e=>t(e)))),Promise.resolve(e)).catch((e=>"REFETCH"===e.sig?Promise.resolve(e.result):Promise.reject(e)))}}class Kt{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new zt,response:new zt};constructor(e){const{reqConfig:t={},requestEncrypt:r,responseDecrypt:n,handleError:s,api:i}=e;this.reqConfig=t,this.handleEncrypt=r,this.handleDecrypt=n,this.handleError=s,this.handleRequest=i}static blockId="blockid";static requestLock={};lockR(e,t){Kt.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Kt.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}_fetch(e,t){let r=e;return t&&this.handleEncrypt&&(r=this.handleEncrypt(e)),new Promise(((e,n)=>{this.handleRequest({...r,success:r=>{let n=r;t&&this.handleDecrypt&&(n=this.handleDecrypt(r)),e(n)},fail:e=>{n(e)}})}))}async request(e,t){const r=Pt.copy(this.reqConfig[e]),{config:n,...s}=await this.interceptors.request.invoke({url:r.url,data:t||{},header:{"content-type":"application/json"},method:r.method?r.method:"POST",responseType:"text",config:r});let i;try{if("block"===n.model)this.lockR(Kt.blockId,(()=>this._fetch(s,n.hasEncrypt))),i=await Kt.requestLock[Kt.blockId].request;else if(Kt.requestLock[Kt.blockId]&&Kt.requestLock[Kt.blockId].lock&&await Kt.requestLock[Kt.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Kt.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),i=await Kt.requestLock[e].request,this.unlockR(e)}else i=await this._fetch(s,n.hasEncrypt)}catch(e){this.handleError&&this.handleError(e)}return this.interceptors.response.invoke({res:i,config:r,reqId:this.getIdFromReq(s),refetch:()=>({sig:"REFETCH",result:this.request(e,t||{})})})}}const Nt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Ht={diff:function(e,t){const r={};return(e=>{if(Dt(e)===Rt)for(let t in e)if(/\w+\.\w+/g.test(t)&&-1===t.indexOf("[")){const r=t.split(".");let n=e,s=r.length;for(let e=0;e<s-1;e++){const t=r[e];Dt(n[t])!==Rt&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),Ut(e,t,!0),It(e,t,r,"",!0),r},promixify:Nt,run:(e,t={})=>e?Se.run(Nt(e)(t)):Se.run(e),formatList:(e,t,r)=>(e||[]).reduce(((e,n,s)=>({...e,[`${r}[${t+s}]`]:n})),{}),ruleValidator:(e,t)=>!!t&&(!Array.isArray(t)||!(t.length<=0)&&t.every((e=>!!e))),Http:Kt,setWatcher:e=>{let t=e.data,r=e.watch;Object.keys(r).forEach((n=>{let s=t,i=n.split(".");for(let e=0;e<i.length-1;e++)s=s[i[e]];let o=i[i.length-1],a=r[n].handler||r[n],c=r[n].deep;Pt.observe(s,o,a,e,c)}))}};const Vt=function(e,{sep:t="&",eq:r="=",max:n=1e3,multiple:s=!0,uri:i=!0,parseNumber:o=!1,parseBoolean:a=!1}={}){t=t||"&",r=r||"=";const c={};if("string"!=typeof e||0===e.length)return c;const l=/\+/g,u=n||1e3;let h=(e=e.split(t)).length;u>0&&h>u&&(h=u);for(let t=0;t<h;++t){let n,o,a,u,h=e[t].replace(l,"%20"),f=h.indexOf(r);f>=0?(n=h.substr(0,f),o=h.substr(f+1)):(n=h,o=""),a=i?decodeURIComponent(n):n,u=i?decodeURIComponent(o):o,O.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(u):c[a]=[c[a],u]:c[a]=u}return Pt.parseValue(c,{number:o,boolean:a}),c},Wt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Zt=function(e,t=!0){return t?encodeURIComponent(e):e},Gt=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},Jt=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,Yt=e=>{const t=(e||"").replace(/\\/g,"/").split("?")[0],r=t.match(/[\/]?([\w\_\-]+)[.]?[\w]*[?]?$/),n=r?r[1]:"",s=t.lastIndexOf("/")+1,i=t.substring(s),o=i.lastIndexOf("."),a=i.substring(0,o)||"",c=o>=0?i.substring(o):"";return{route:t.substring(0,s)||"",page:n,name:i,withoutExtension:a,extname:c}},Qt=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(Jt);if(!r||r.length<4)return t;const n=r[3]||"",s=e.split("?");return t.url=s[0],t.origin=r[0],t.protocol=`${r[1]}:`,t.host=`${r[2]}${n?":"+n:""}`,t.port=n,t.query=s.length>1?s[1]:"",t};var Xt={parse:Vt,stringify:function(e,{sep:t="&",eq:r="=",name:n=null,uri:s=!0,cleanZero:i=!1,cleanNull:o=!1,cleanWhitespace:a=!1}={}){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){const c=Zt(Wt(n),s)+r,l=e[n];return Array.isArray(l)?l.map((function(e){return c+Zt(Wt(e),s)})).join(t):Gt(l,{cleanZero:i,cleanNull:o,cleanWhitespace:a})?"":c+Zt(Wt(l),s)})).filter(Boolean).join(t):n?Zt(Wt(n),s)+r+Zt(Wt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=Qt(e),{origin:r="",url:n="",query:s=""}=t,i=Yt(n),o=Vt(s,{multiple:!0,uri:!1});return{...t,...i,pathname:n.substring(n.indexOf(r||"")+r.length),params:o}},parsePath:Yt,parseHost:Qt,join:(...e)=>{let t=[];return e.forEach((e=>{const r=e.trim().replace(/^\/*(.*?)\/*$/,"$1");r.length<=0||(/^(\w+):\/\//.test(r)?t=[r]:t.push(r))})),t.join("/")}};const er=/%[sdj%]/g;let tr=()=>{};function rr(e){if(!e||!e.length)return null;const t={};return e.forEach((e=>{const r=e.field;t[r]=t[r]||[],t[r].push(e)})),t}function nr(e,...t){let r=0;const n=t.length;if("function"==typeof e)return e.apply(null,t);if("string"==typeof e){return e.replace(er,(e=>{if("%%"===e)return"%";if(r>=n)return e;switch(e){case"%s":return String(t[r++]);case"%d":return Number(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch(e){return"[Circular]"}break;default:return e}}))}return e}function sr(e,t){return null==e||(!("array"!==t||!Array.isArray(e)||e.length)||!(!function(e){return"string"===e||"url"===e||"hex"===e||"email"===e||"date"===e||"pattern"===e}(t)||"string"!=typeof e||e))}function ir(e,t,r){let n=0;const s=e.length;!function i(o){if(o&&o.length)return void r(o);const a=n;n+=1,a<s?t(e[a],i):r([])}([])}"undefined"!=typeof process&&process.env&&"production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&"undefined"!=typeof document&&(tr=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class or extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function ar(e,t,r,n,s){if(t.first){const t=new Promise(((t,i)=>{const o=function(e){const t=[];return Object.keys(e).forEach((r=>{t.push(...e[r]||[])})),t}(e);ir(o,r,(e=>(n(e),e.length?i(new or(e,rr(e))):t(s))))}));return t.catch((e=>e)),t}const i=!0===t.firstFields?Object.keys(e):t.firstFields||[],o=Object.keys(e),a=o.length;let c=0;const l=[],u=new Promise(((t,u)=>{const h=e=>{if(l.push.apply(l,e),c++,c===a)return n(l),l.length?u(new or(l,rr(l))):t(s)};o.length||(n(l),t(s)),o.forEach((t=>{const n=e[t];-1!==i.indexOf(t)?ir(n,r,h):function(e,t,r){const n=[];let s=0;const i=e.length;function o(e){n.push(...e||[]),s++,s===i&&r(n)}e.forEach((e=>{t(e,o)}))}(n,r,h)}))}));return u.catch((e=>e)),u}function cr(e,t){return r=>{let n;return n=e.fullFields?function(e,t){let r=e;for(let e=0;e<t.length;e++){if(null==r)return r;r=r[t[e]]}return r}(t,e.fullFields):t[r.field||e.fullField],function(e){return!(!e||void 0===e.message)}(r)?(r.field=r.field||e.fullField,r.fieldValue=n,r):{message:"function"==typeof r?r():r,fieldValue:n,field:r.field||e.fullField}}}function lr(e,t){if(t)for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];"object"==typeof n&&"object"==typeof e[r]?e[r]={...e[r],...n}:e[r]=n}return e}const ur=(e,t,r,n,s,i)=>{!e.required||r.hasOwnProperty(e.field||"")&&!sr(t,i||e.type)||n.push(nr(s.messages.required,e.fullField))};let hr;const fr=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,dr=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,pr={integer:e=>pr.number(e)&&parseInt(e,10)===e,float:e=>pr.number(e)&&!pr.integer(e),array:e=>Array.isArray(e),regexp(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch(e){return!1}},date:e=>"function"==typeof e.getTime&&"function"==typeof e.getMonth&&"function"==typeof e.getYear&&!isNaN(e.getTime()),number:e=>!isNaN(e)&&"number"==typeof e,object:e=>"object"==typeof e&&!pr.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(fr),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(hr)return hr;const e="[a-fA-F\\d:]",t=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${e})|(?<=${e})(?=\\s|$))`:"",r="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",n="[a-fA-F\\d]{1,4}",s=`\n(?:\n(?:${n}:){7}(?:${n}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${n}:){6}(?:${r}|:${n}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${n}:){5}(?::${r}|(?::${n}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${n}:){4}(?:(?::${n}){0,1}:${r}|(?::${n}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${n}:){3}(?:(?::${n}){0,2}:${r}|(?::${n}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${n}:){2}(?:(?::${n}){0,3}:${r}|(?::${n}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${n}:){1}(?:(?::${n}){0,4}:${r}|(?::${n}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${n}){0,5}:${r}|(?::${n}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),i=new RegExp(`(?:^${r}$)|(?:^${s}$)`),o=new RegExp(`^${r}$`),a=new RegExp(`^${s}$`),c=e=>e&&e.exact?i:new RegExp(`(?:${t(e)}${r}${t(e)})|(?:${t(e)}${s}${t(e)})`,"g");c.v4=e=>e&&e.exact?o:new RegExp(`${t(e)}${r}${t(e)}`,"g"),c.v6=e=>e&&e.exact?a:new RegExp(`${t(e)}${s}${t(e)}`,"g");const l=c.v4().source,u=c.v6().source;return hr=new RegExp(`(?:^(?:(?:(?:[a-z]+:)?//)|www\\.)(?:\\S+(?::\\S*)?@)?(?:localhost|${l}|${u}|(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#][^\\s"]*)?$)`,"i"),hr})()),hex:e=>"string"==typeof e&&!!e.match(dr)},gr="enum";var yr={required:ur,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(nr(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void ur(e,t,r,n,s);const i=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(i)>-1?pr[i](t)||n.push(nr(s.messages.types[i],e.fullField,e.type)):i&&typeof t!==e.type&&n.push(nr(s.messages.types[i],e.fullField,e.type))},range:(e,t,r,n,s)=>{const i="number"==typeof e.len,o="number"==typeof e.min,a="number"==typeof e.max,c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;let l=t,u="";const h="number"==typeof t,f="string"==typeof t,d=Array.isArray(t);if(h?u="number":f?u="string":d&&(u="array"),!u)return!1;d&&(l=t.length),f&&(l=t.replace(c,"_").length),i?l!==e.len&&n.push(nr(s.messages[u].len,e.fullField,e.len)):o&&!a&&l<e.min?n.push(nr(s.messages[u].min,e.fullField,e.min)):a&&!o&&l>e.max?n.push(nr(s.messages[u].max,e.fullField,e.max)):o&&a&&(l<e.min||l>e.max)&&n.push(nr(s.messages[u].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[gr]=Array.isArray(e[gr])?e[gr]:[],-1===e[gr].indexOf(t)&&n.push(nr(s.messages[gr],e.fullField,e[gr].join(", ")))},pattern:(e,t,r,n,s)=>{if(e.pattern)if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||n.push(nr(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(nr(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const mr=(e,t,r,n,s)=>{const i=e.type,o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t,i)&&!e.required)return r();yr.required(e,t,n,o,s,i),sr(t,i)||yr.type(e,t,n,o,s)}r(o)};var wr={string:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(sr(t,"string")&&!e.required)return r();yr.required(e,t,n,i,s,"string"),sr(t,"string")||(yr.type(e,t,n,i,s),yr.range(e,t,n,i,s),yr.pattern(e,t,n,i,s),!0===e.whitespace&&yr.whitespace(e,t,n,i,s))}r(i)},method:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&yr.type(e,t,n,i,s)}r(i)},number:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(""===t&&(t=void 0),sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&(yr.type(e,t,n,i,s),yr.range(e,t,n,i,s))}r(i)},boolean:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&yr.type(e,t,n,i,s)}r(i)},regexp:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),sr(t)||yr.type(e,t,n,i,s)}r(i)},integer:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&(yr.type(e,t,n,i,s),yr.range(e,t,n,i,s))}r(i)},float:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&(yr.type(e,t,n,i,s),yr.range(e,t,n,i,s))}r(i)},array:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(null==t&&!e.required)return r();yr.required(e,t,n,i,s,"array"),null!=t&&(yr.type(e,t,n,i,s),yr.range(e,t,n,i,s))}r(i)},object:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&yr.type(e,t,n,i,s)}r(i)},enum:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s),void 0!==t&&yr.enum(e,t,n,i,s)}r(i)},pattern:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t,"string")&&!e.required)return r();yr.required(e,t,n,i,s),sr(t,"string")||yr.pattern(e,t,n,i,s)}r(i)},date:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t,"date")&&!e.required)return r();if(yr.required(e,t,n,i,s),!sr(t,"date")){let r;r=t instanceof Date?t:new Date(t),yr.type(e,r,n,i,s),r&&yr.range(e,r.getTime(),n,i,s)}}r(i)},url:mr,hex:mr,email:mr,required:(e,t,r,n,s)=>{const i=[],o=Array.isArray(t)?"array":typeof t;yr.required(e,t,n,i,s,o),r(i)},any:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,i,s)}r(i)}};function br(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone(){const e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}const vr=br();class _r{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");wr[e]=t};static warning=tr;static messages=vr;static validators=wr;rules={};_messages=vr;constructor(e){this.define(e)}define(e){if(!e)throw new Error("Cannot configure a schema with no rules");if("object"!=typeof e||Array.isArray(e))throw new Error("Rules must be an object");this.rules={},Object.keys(e).forEach((t=>{const r=e[t];this.rules[t]=Array.isArray(r)?r:[r]}))}messages(e){return e&&(this._messages=lr(br(),e)),this._messages}validate(e,t={},r=(()=>{})){let n=e,s=t,i=r;if("function"==typeof s&&(i=s,s={}),!this.rules||0===Object.keys(this.rules).length)return i&&i(null,n),Promise.resolve(n);if(s.messages){let e=this.messages();e===vr&&(e=br()),lr(e,s.messages),s.messages=e}else s.messages=this.messages();const o={};(s.keys||Object.keys(this.rules)).forEach((t=>{const r=this.rules[t];let s=n[t];r.forEach((r=>{let i=r;"function"==typeof i.transform&&(n===e&&(n={...n}),s=n[t]=i.transform(s)),i="function"==typeof i?{validator:i}:{...i},i.validator=this.getValidationMethod(i),i.validator&&(i.field=t,i.fullField=i.fullField||t,i.type=this.getType(i),o[t]=o[t]||[],o[t].push({rule:i,value:s,source:n,field:t}))}))}));const a={};return ar(o,s,((e,t)=>{const r=e.rule;let i,o=!("object"!==r.type&&"array"!==r.type||"object"!=typeof r.fields&&"object"!=typeof r.defaultField);function c(e,t){return{...t,fullField:`${r.fullField}.${e}`,fullFields:r.fullFields?[...r.fullFields,e]:[e]}}function l(i=[]){let l=Array.isArray(i)?i:[i];!0===s.suppressWarning&&l.length&&_r.warning("async-validator:",l),l.length&&void 0!==r.message&&(l=[].concat(r.message));let u=l.map(cr(r,n));if(s.first&&u.length)return a[r.field]=1,t(u);if(o){if(r.required&&!e.value)return void 0!==r.message?u=[].concat(r.message).map(cr(r,n)):s.error&&(u=[s.error(r,nr(s.messages.required,r.field))]),t(u);let i={};r.defaultField&&Object.keys(e.value).map((e=>{i[e]=r.defaultField})),i={...i,...e.rule.fields};const o={};Object.keys(i).forEach((e=>{const t=i[e],r=Array.isArray(t)?t:[t];o[e]=r.map(c.bind(null,e))}));const a=new _r(o);a.messages(s.messages),e.rule.options&&(e.rule.options.messages=s.messages,e.rule.options.error=s.error),a.validate(e.value,e.rule.options||s,(e=>{const r=[];u&&u.length&&r.push(...u),e&&e.length&&r.push(...e),t(r.length?r:null)}))}else t(u)}if(o=o&&(r.required||!r.required&&e.value),r.field=e.field,r.asyncValidator)i=r.asyncValidator(r,e.value,l,e.source,s);else if(r.validator){try{i=r.validator(r,e.value,l,e.source,s)}catch(e){console.error?.(e),s.suppressValidatorError||setTimeout((()=>{throw e}),0),l(e.message)}!0===i?l():!1===i?l("function"==typeof r.message?r.message(r.fullField||r.field):r.message||`${r.fullField||r.field} fails`):i instanceof Array?l(i):i instanceof Error&&l(i.message)}i&&i.then&&i.then((()=>l()),(e=>l(e)))}),(e=>{!function(e){let t=[],r={};for(let r=0;r<e.length;r++)s=e[r],Array.isArray(s)?t=t.concat(...s):t.push(s);var s;t.length?(r=rr(t),i(t,r)):i(null,n)}(e)}),n)}getType(e){if(void 0===e.type&&e.pattern instanceof RegExp&&(e.type="pattern"),"function"!=typeof e.validator&&e.type&&!wr.hasOwnProperty(e.type))throw new Error(nr("Unknown rule type %s",e.type));return e.type||"string"}getValidationMethod(e){if("function"==typeof e.validator)return e.validator;const t=Object.keys(e),r=t.indexOf("message");return-1!==r&&t.splice(r,1),1===t.length&&"required"===t[0]?wr.required:wr[this.getType(e)]||void 0}}function xr(e){return new _r(e)}var kr={validateId:function(e){return!!e&&(!(e.length<6)&&!!/^[A-Za-z0-9_-]+$/.test(e))},validatePhone:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)},validator:xr,validate:function(e,t,r={},n=(()=>{})){return Se.run(xr(e).validate(t,r,n))},isChinese:function(e){return!!e&&!!/^[\u4E00-\u9FA5]+$/.test(e)},isNumber:function(e){return!!e&&!!/^[0-9]+$/.test(e)},isFloat:function(e){return!!e&&!!/^(\-|\+)?\d+(\.\d+)?$/.test(e)},isPhoneNumber:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)}};var Sr={pattern:{num:"0-9",zh:"一-龥",en:"A-Za-z"},regex:(e,t)=>new RegExp(e,t),entire:{chinese:/^[\u4E00-\u9FA5]+$/,real:/^(\-|\+)?\d+(\.\d+)?$/,cssReal:/^(\-|\+)?\d*(\.)?\d+$/,id:/^[A-Za-z0-9]+$/,yyyyMMdd:/^(\d{4})-?(\d{2})-?(\d{2})$/}};var Ar={toUtf8:e=>{if(!e)return"";const t=e.replace(/\r\n/g,"\n");let r="";for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r+=String.fromCharCode(n):n>127&&n<2048?(r+=String.fromCharCode(n>>6|192),r+=String.fromCharCode(63&n|128)):(r+=String.fromCharCode(n>>12|224),r+=String.fromCharCode(n>>6&63|128),r+=String.fromCharCode(63&n|128))}return r},fromUtf8:e=>{let t="",r=0;if(!e)return"";let n=0,s=0,i=0;for(;r<e.length;)n=e.charCodeAt(r),n<128?(t+=String.fromCharCode(n),r++):n>191&&n<224?(s=e.charCodeAt(r+1),t+=String.fromCharCode((31&n)<<6|63&s),r+=2):(s=e.charCodeAt(r+1),i=e.charCodeAt(r+2),t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),r+=3);return t},toUtf8Bytes:e=>{if(!e)return new Uint8Array;const t=e.replace(/\r\n/g,"\n"),r=[];for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r.push(n):n<2048?(r.push(n>>6|192),r.push(63&n|128)):(r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128))}return new Uint8Array(r)},fromUtf8Bytes:e=>{let t="",r=0;if(!e||e.length<=0)return"";for(;r<e.length;){let n=e[r];if(n<128)t+=String.fromCharCode(n),r++;else if(n>191&&n<224){const s=e[r+1];t+=String.fromCharCode((31&n)<<6|63&s),r+=2}else{const s=e[r+1],i=e[r+2];t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),r+=3}}return t}};const $r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var Cr={toBase64:(e="")=>{let t,r,n,s,i,o,a,c="",l=0;for(e=Ar.toUtf8(e);l<e.length;)t=e.charCodeAt(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l++),s=t>>2,i=(3&t)<<4|r>>4,o=(15&r)<<2|n>>6,a=63&n,isNaN(r)?o=a=64:isNaN(n)&&(a=64),c=c+$r.charAt(s)+$r.charAt(i)+$r.charAt(o)+$r.charAt(a);return c},fromBase64:(e="")=>{let t,r,n,s,i,o,a,c="",l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=$r.indexOf(e.charAt(l++)),i=$r.indexOf(e.charAt(l++)),o=$r.indexOf(e.charAt(l++)),a=$r.indexOf(e.charAt(l++)),t=s<<2|i>>4,r=(15&i)<<4|o>>2,n=(3&o)<<6|a,c+=String.fromCharCode(t),64!=o&&(c+=String.fromCharCode(r)),64!=a&&(c+=String.fromCharCode(n));return c=Ar.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,i,o,a,c="",l=0;if(!e||!X.isArrayLike(e)||!X.isUint8Array(e))return"";for(;l<e.length;)t=e[l++],r=e[l++],n=e[l++],s=t>>2,i=(3&t)<<4|r>>4,o=(15&r)<<2|n>>6,a=63&n,isNaN(r)?o=a=64:isNaN(n)&&(a=64),c=c+$r.charAt(s)+$r.charAt(i)+$r.charAt(o)+$r.charAt(a);return c},base64ToBytes:(e="")=>{let t,r,n,s,i,o,a,c=[],l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=$r.indexOf(e.charAt(l++)),i=$r.indexOf(e.charAt(l++)),o=$r.indexOf(e.charAt(l++)),a=$r.indexOf(e.charAt(l++)),t=s<<2|i>>4,r=(15&i)<<4|o>>2,n=(3&o)<<6|a,c.push(t),64!=o&&c.push(r),64!=a&&c.push(n);return new Uint8Array(c)}};const Or=e=>Cr.toBase64(e);var Er={encode:Or,decode:e=>Cr.fromBase64(e),encodeByOss:e=>Or(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var jr={...c,base64:Er,uuid:l,guid:(e,t=!1,r="")=>{const n=l(e||32);return t?m.now().format("yyyyMMddhhmmss")+r+n:n},getHexString:e=>{const t=c.keyChars;let r="";const n=t.length;for(let s=0;s<e;s++)r+=t.charAt(Math.floor(Math.random()*n));return r}};const qr=e=>{if(!e)return"";if(!Tt.isObject(e))return"";let t="";return Tt.forof(e,((e,r)=>{r&&(t+=`${Ct.kebabCase(e)}:${r};`)})),t},Lr=["display","position","top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","fontSize","textAlign","fontFamily","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius","background","backgroundImage","backgroundRepeat","backgroundSize","backgroundPosition","color","overflow","opacity","flexDirection","justifyContent","alignItems","flexWrap","alignContent","alignSelf","flex","flexBasis","flexFlow","flexShrink","pointerEvents"],Pr=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],Tr=(e,t="px")=>e&&t?"0"===e?e:kr.isFloat(e.toString())?`${e}${t}`:e:e;var Fr={stringify:qr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=Xt.parse(e,{sep:";",eq:":",uri:!1}),s={};return Tt.forof(n,((e,n)=>{if(!n)return;const i=t?r&&e.startsWith("_")?e:Ct.camelCase(e):e;kr.isFloat(n)||n.length>=2&&n.startsWith(".")&&kr.isNumber(n.substr(1))?s[i]=+n:s[i]=n})),s},fixValue:Tr,style:(e,t="px")=>{if(!e)return"";const r=Tt.copy(e,{fields:Lr});Tt.forof(r,((e,n)=>{(Pr.includes(e)||Pr.includes(Ct.camelCase(e)))&&(r[e]=Tr(n,t))}));return qr(r)},commonFields:Lr};const Mr=(e,t="",r=!1)=>{try{if(!e)return;const n=Xt.parseUrl(e),s=t||n.name;if(!t||!r||!n.origin||n.origin===window.location.origin)((e,t)=>{try{const r=document.createElement("a");r.style.display="none",r.href=e,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}catch(t){console.error(`[ddan] _downloadUrl ${e}`,t)}})(e,s);else{const t=n.params;t.t=Date.now();const r=`${n.url}?${Xt.stringify(t,{uri:!1})}`,i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="blob",i.onload=function(){Rr(i.response,s)},i.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},i.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},Rr=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;Mr(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},Br=e=>{try{const t=document.createElement("textarea");document.body.appendChild(t),t.style.position="fixed",t.style.clip="rect(0 0 0 0)",t.style.top="10px",t.style.opacity="0",t.value=e??"",t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}catch(e){return console.error("[ddan] copyText",e),!1}},Dr=(e,t="denied")=>new Promise((r=>{const n=navigator?.permissions;if(!n||!n.query)return r(t);const s={name:e};n.query(s).then((e=>r(e.state))).catch((()=>r(t)))})),Ur=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Ir={dataURLtoFile:(e,t)=>{let r=e.split(","),n=r[0].match(/:(.*?);/)[1],s=window.atob(r[1]),i=s.length,o=new Uint8Array(i);for(;i--;)o[i]=s.charCodeAt(i);return new File([o],t,{type:n})},dataURLtoBlob:e=>{let t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=window.atob(t[1]),s=n.length,i=new Uint8Array(s);for(;s--;)i[s]=n.charCodeAt(s);return new Blob([i],{type:r})},blobToFile:(e,t)=>(e.lastModifiedDate=new Date,e.name=t,e),readAsDataURL:(e,t)=>{var r=new FileReader;r.readAsDataURL(e),r.onloadend=function(e){t&&t(e.target?.result)}},downloadUrl:Mr,download:(e,t="")=>{e&&("string"!=typeof e?Rr(e,t):Mr(e,t))},downloadFile:Rr,downloadImage:e=>{try{if(!e)return;const t=e.match(/\/(\w+.\w+)$/)[1],r=new Image;r.onload=()=>{let e=document.createElement("canvas");e.width=r.width,e.height=r.height;let n=e.getContext("2d");n&&n.drawImage(r,0,0,r.width,r.height);let s=e.toDataURL();Mr(s,t)},r.src=e,r.setAttribute("crossOrigin","Anonymous")}catch(e){console.error("[ddan] downloadImage",e)}return Promise.resolve()},watermark:(e,{width:t=400,height:r=300,angle:n=0,fillStyle:s="rgba(0, 0, 0, 0.2)",font:i="16px Arial",textAlign:o="left",textBaseline:a="middle"}={})=>{try{if(!e)return"";const c=document.createElement("canvas");c.width=t,c.height=r;const l=c.getContext("2d");return l?(n&&l.rotate(n*Math.PI/180),s&&(l.fillStyle=s),i&&(l.font=i),o&&(l.textAlign=o),a&&(l.textBaseline=a),l.fillText(e,c.width/10,c.height/2),`url(${c.toDataURL()})`):""}catch(e){return console.error("[ddan] watermark",e),""}},copyText:(e,t=!1)=>new Promise((r=>{!t&&navigator.clipboard?Dr("clipboard-write").then((t=>{Ur(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(Br(e)))):r(Br(e))})).catch((()=>{r(Br(e))})):r(Br(e))})),queryPermission:Dr,isAllowed:Ur,legacyCopy:Br};var zr={ossImage:(e,t={})=>{if(!e)return e;const r=Xt.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=Mt.toList(t.domain||""),n=e.match(/^http[s]?:\/\/([\w.]+)[\w\W]+/)[1]||"";if(!n||!r.includes(n))return e}const n=[];return t.webp&&!r.endsWith(".gif")&&n.push("format,webp"),t.resize&&n.push(`resize,s_${t.resize}`),t.interlace&&(n.push("interlace,1"),!n.every((e=>!e.startsWith("format")))||r.endsWith(".gif")||r.endsWith(".jpg")||n.push("format,jpg")),n.length<=0?e:`${r}?x-oss-process=image/${n.join("/")}`},ossSnapshot:(e,t={})=>{if(!e)return e;const r=Xt.parseUrl(e).url,n=["snapshot"],{m:s="fast",f:i="jpg"}=t;return(t.t||0===t.t)&&n.push(`t_${t.t}`),t.w&&n.push(`w_${t.w}`),t.h&&n.push(`h_${t.h}`),s&&n.push(`m_${s}`),i&&n.push(`f_${i}`),t.ar&&n.push(`ar_${t.ar}`),`${r}?x-oss-process=video/${n.join(",")}`},ossBase64:e=>Cr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Kr={...Ar,...Cr,str2Hex:e=>{let t="";for(let r=0;r<e.length;r++)t+=e.charCodeAt(r).toString(16).padStart(2,"0");return t},hex2Str:e=>{let t="";for(let r=0;r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},str2ab:(e="",t=!1)=>{if(t)return Cr.base64ToBytes(e).buffer;{const t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0,n=e.length;t<n;t++)r[t]=e.charCodeAt(t);return t}},ab2str:(e,t=!1)=>{const r=new Uint8Array(e);return t?Cr.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!X.isArrayLike(e))return"";return e.reduce(((e,t)=>e+String.fromCharCode(t)),"")},strToBytes:(e="")=>{const t=e,r=new Uint8Array(t.length);for(let e=0,n=t.length;e<n;e++)r[e]=t.charCodeAt(e);return r},utf8ToBase64:e=>X.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>X.isBrowser?atob(e):Buffer.from(e,"base64").toString("utf-8"),getRandomBytes:e=>{const t=new Uint8Array(e);for(let r=0;r<e;r++)t[r]=Oe.random(256);return t},textEncode:e=>Ar.toUtf8Bytes(e),textDecode:e=>Ar.fromUtf8Bytes(new Uint8Array(e))};const Nr=({url:e,options:t})=>{const r={"Content-Type":"application/json; charset=utf-8",...t.headers||{}};return t.headers=r,new Promise(((r,n)=>{fetch(e,t).then((e=>{r(e.json())})).catch((e=>{n(e)}))}))};function Hr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Vr(e){const{url:t="",host:r,options:n}=e,s=e;if(t.startsWith("http://")||t.startsWith("https://")||(s.url=(r||"")+t),"GET"===n.method.toUpperCase()&&n.body){const e=JSON.parse(n.body);if(Tt.isPlainObject(e)){const r=Xt.stringify(e),n=-1===t.indexOf("?")?"?":"&";s.url=`${s.url||""}${n}${r}`,delete s.options.body}}return n&&n.plugins&&delete s.options?.plugins,n&&n.model&&delete s.options?.model,s}class Wr{host="";reqConfig={};handleError;interceptors={request:new zt,response:new zt};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Vr),this.interceptors.response.use(e.handleResponse||Hr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Wr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Wr.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}async fetch(e,t){const r=Tt.copy(this.reqConfig[e])||{},n={host:this.host,url:r.url||"",options:{...r||{},body:JSON.stringify({...t||{}})}};try{const s=await this.interceptors.request.invoke(n);let i;if(delete s.options.plugins,"block"===r.model)this.lockR(Wr.blockId,(()=>Nr(s))),i=await Wr.requestLock[Wr.blockId].request;else if(Wr.requestLock[Wr.blockId]&&Wr.requestLock[Wr.blockId].lock&&await Wr.requestLock[Wr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Wr.requestLock[e]||this.lockR(e,(()=>Nr(s))),i=await Wr.requestLock[e].request,this.unlockR(e)}else i=await Nr(s);return this.interceptors.response.invoke({response:i,config:r,refetch:()=>({sig:"REFETCH",result:this.fetch(e,t)})})}catch(e){return this.handleError&&this.handleError(e),Promise.reject(e)}}}const Zr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},Gr=e=>(...t)=>{const r=console[e];Zr.overrode?r(...t):Jr(r,e,...t)},Jr=(e,t,...r)=>{const n=m.format(new Date,Zr.format),s=Zr.tag?`[${t}]`:"";s&&n?e.apply(console,[`${n} ${s}`,...r]):n?e.apply(console,[`${n}`,...r]):s?e.apply(console,[`${s}`,...r]):e.apply(console,[...r])};var Yr={override:()=>{if(Zr.overrode)return;Zr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{Jr(t,e,...r)}}))},log:Gr("log"),info:Gr("info"),warn:Gr("warn"),error:Gr("error"),config:({tag:e=Zr.tag,format:t=Zr.format}={})=>{Zr.tag=e,Zr.format=t}};var Qr={getDataURL:e=>{const t={contentType:"",dataUrl:""};return we.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Kr.ab2str(e,!0),t))))},getArrayBuffer:async e=>we.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>we.to(fetch(e).then((e=>e.json()))),download:(e,t={})=>new Promise((r=>fetch(e).then((async e=>{if(!e.ok||200!==e.status)throw new Error(e.statusText);const n=+(e.headers.get("content-length")||""),s=e.body?.getReader();let i=0;const o=[];for(;;){const{done:e,value:r}=await s.read();if(e)break;o.push(r),i+=r.length;const a=Oe.float(100*i/n,{digits:2});t?.progress&&t?.progress(a,i,n)}const a=new Uint8Array(i);let c=0;for(const e of o)a.set(e,c),c+=e.length;t?.success&&t?.success(a),r(a)})).catch((e=>{t?.fail&&t?.fail(e),r(void 0)}))))};const Xr=new class{__defStyle="vertical-align: middle; mask-position: 50% 50%; mask-repeat: no-repeat; mask-size: 100%; -webkit-mask-position: 50% 50%; -webkit-mask-repeat: no-repeat; -webkit-mask-size: 100%; background-color: currentColor;";__map={back:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M609.408 149.376L277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"/></svg>',right:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"/></svg>',home:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13 19.8h3.8v-7h3.303L12 4.697 3.897 12.8H7.2v7H11V17h2v2.8zm5 .2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-6H3.414a1 1 0 0 1-.707-1.707l8.586-8.586a1 1 0 0 1 1.414 0l8.586 8.586A1 1 0 0 1 20.586 14H18v6z" fill-rule="evenodd" fill-opacity=".9"/></svg>',close:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M764.288 214.592L512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"/></svg>',close_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M466.752 512l-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',close_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"/></svg>',warning:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M928.99 755.83L574.6 203.25c-12.89-20.16-36.76-32.58-62.6-32.58s-49.71 12.43-62.6 32.58L95.01 755.83c-12.91 20.12-12.9 44.91.01 65.03 12.92 20.12 36.78 32.51 62.59 32.49h708.78c25.82.01 49.68-12.37 62.59-32.49 12.91-20.12 12.92-44.91.01-65.03zM554.67 768h-85.33v-85.33h85.33V768zm0-426.67v298.66h-85.33V341.32l85.33.01z" fill="currentColor"/></svg>',play:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024A512 512 0 1 1 512 0a512 512 0 0 1 0 1024zm3.008-92.992a416 416 0 1 0 0-832 416 416 0 0 0 0 832zM383.232 287.616l384 224.896-384 223.104v-448z" fill="currentColor"/></svg>',lock:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M224 448a32 32 0 0 0-32 32v384a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V480a32 32 0 0 0-32-32H224zm0-64h576a96 96 0 0 1 96 96v384a96 96 0 0 1-96 96H224a96 96 0 0 1-96-96V480a96 96 0 0 1 96-96z"/><path fill="currentColor" d="M512 544a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V576a32 32 0 0 1 32-32zm192-160v-64a192 192 0 1 0-384 0v64h384zM512 64a256 256 0 0 1 256 256v128H256V320A256 256 0 0 1 512 64z"/></svg>',lock_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M467.2 713.92v115.968a44.8 44.8 0 0 0 89.6 0V713.92c26.752-14.72 44.8-42.304 44.8-73.92 0-47.104-40.128-85.312-89.6-85.312-49.472 0-89.6 38.208-89.6 85.312 0 31.616 18.048 59.136 44.8 73.92zM64 384h896v640H64V384zm268.8 0h358.4V256c0-94.272-80.256-170.688-179.2-170.688-98.944 0-179.2 76.416-179.2 170.688v128zM512 0c148.48 0 268.8 114.56 268.8 256v128H243.2V256C243.2 114.56 363.52 0 512 0z" fill="currentColor"/></svg>',plus:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"/></svg>',plus_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M352 480h320a32 32 0 1 1 0 64H352a32 32 0 0 1 0-64z"/><path fill="currentColor" d="M480 672V352a32 32 0 1 1 64 0v320a32 32 0 0 1-64 0z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',plus_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-38.4 409.6H326.4a38.4 38.4 0 1 0 0 76.8h147.2v147.2a38.4 38.4 0 0 0 76.8 0V550.4h147.2a38.4 38.4 0 0 0 0-76.8H550.4V326.4a38.4 38.4 0 1 0-76.8 0v147.2z"/></svg>',star:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 747.84l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72L512 747.84zM313.6 924.48a70.4 70.4 0 0 1-102.144-74.24l37.888-220.928L88.96 472.96A70.4 70.4 0 0 1 128 352.896l221.76-32.256 99.2-200.96a70.4 70.4 0 0 1 126.208 0l99.2 200.96 221.824 32.256a70.4 70.4 0 0 1 39.04 120.064L774.72 629.376l37.888 220.928a70.4 70.4 0 0 1-102.144 74.24L512 820.096l-198.4 104.32z"/></svg>',star_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M283.84 867.84L512 747.776l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72z"/></svg>',share:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M679.872 348.8l-301.76 188.608a127.808 127.808 0 0 1 5.12 52.16l279.936 104.96a128 128 0 1 1-22.464 59.904l-279.872-104.96a128 128 0 1 1-16.64-166.272l301.696-188.608a128 128 0 1 1 33.92 54.272z"/></svg>',love:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M171.712 571.648l.352.32 287.904 252.8a64 64 0 0 0 82.912 1.344l296.832-244.544a215.584 215.584 0 1 0-301.824-300.576L512 316.672l-25.888-35.616a215.584 215.584 0 1 0-314.4 290.624zM32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512l-295.36 243.392a128 128 0 0 1-165.888-2.592L129.984 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>',love_fill:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952L130.016 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>'};getBase64=e=>{const t=this.getSVG(e);return t?.url||""};getSVG=e=>{if(!e)return;const t=this.__map[e];if(!t)return;return{url:this.toBase64(t),escape:this.toEscape(t)}};toBase64=e=>{if(!e)return"";const t=this._tiny(e);return`data:image/svg+xml;base64,${Er.encode(t)}`};_tiny=e=>e?e.replace(/<!--(.*)-->/g,"").replace(/[\r\n]/g," ").replace(/"/g,"'"):"";toEscape=e=>{if(!e)return"";return`data:image/svg+xml,${this._tiny(e).replace(/%/g,"%25").replace(/&/g,"%26").replace(/#/g,"%23").replace(/{/g,"%7B").replace(/}/g,"%7D").replace(/</g,"%3C").replace(/>/g,"%3E")}`};getStyle(e,t={}){if(!e)return"";const r=this.__map[e];return r?this.toStyle(r,t):""}toStyle(e,t={}){if(!e)return"";const r=this.toBase64(e);return r?this.getStyleByUrl(r,t):""}getStyleByUrl(e,t={}){if(!e)return"";const{key:r="mask-image",gradientValue:n="radial-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",gradient:s=!1,defStyle:i=this.__defStyle}=t,o=s&&n?`${n}, url("${e}")`:`url("${e}")`;return`${r}:${o};-webkit-${r}:${o};${i}`}},en=(e,t,r)=>({key:e,fields:t,storage:r});class tn{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=Se.debounce((e=>{if(this.key&&this.storage)try{const{setItem:t,setStorageSync:r}=this.storage;if(r)return r(this.key,e);if(t)return t(this.key,JSON.stringify(e))}catch(e){console.error("persit save ",e)}}));read(){if(this.key&&this.storage)try{const{getItem:e,getStorageSync:t}=this.storage;if(t)return t(this.key);if(e){const t=e(this.key);return JSON.parse(t)}}catch(e){return void console.error("persit read ",e)}}handleSave(e,t){if(!this.fields.includes(t)||!e)return;const r=Pt.copy(e,{fields:this.fields});this.save(r)}}class rn extends u{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!X.isFunction(n))return;const[,s]=await Se.run(n({...r,commit:r.commit.bind(r),query:r.query.bind(r),dispatch:r.dispatch.bind(r)},t));return s}async query(e){const t=Reflect.get(this,e);let r;if(null!=t&&""!==t)r=Pt.copy(t);else{const[,t]=await Se.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){X.isObject(t)&&(t=Pt.copy(t)),this[e]=t}}const nn=(e,t)=>{const r=Object.assign(new rn,e||{});r.__persist=new tn(t||r.persist);const n=r.__persist.read(),s=n?Object.assign(r,n):r;return new Proxy(s,{get:(e,t,r)=>{const n=Reflect.get(e.getters,t);return X.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(X.isFunction(s)&&!s(e,r))return!0;const i=Reflect.set(e,t,r,n);return i&&(e.emit(t.toString(),r),e?.__persist?.handleSave(e,t.toString())),i},has:(e,t)=>Reflect.has(e,t)})};class sn{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=Xt.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const i=Xt.stringify(s,{uri:!1});this.list.push(`${e}?${i}`)}_parseHost(e){e&&!this.host&&/^http[s]?:\/\/([\w.]+)/.test(e)&&(this.host=e.replace(/^http[s]?:\/\/([\w.]+)[\w\W]+/,"$1"))}image(e,t={}){if(!e||!e.includes(this.host))return;if(this.list.length<=0)return;const r={g:"nw",...t},n=e.replace(/^http[s]?:\/\/[\w.]+\/([\w-.,_/?%&=]+)$/,"$1"),s=jr.base64.encodeByOss(n),i=Xt.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=jr.base64.encodeByOss(e),i=Xt.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}result(){return this.list.join("")}}const on=(e,t)=>new sn(e,t);class an{__list=[];constructor(){this.clear()}add(e){const t=Se.run(e);return this.__list.push(t),this}clear(){return this.__list=[],this}wait(){const e=this.__list;return this.clear(),Promise.allSettled(e)}}const cn=new class{state=nn(new rn);frame=new h;cache=new Map;cacheTime=new Map;setCache=(e,t)=>null!=t&&(!!e&&(this.cache.set(e,t),this.cacheTime.set(e,Date.now()),!0));hasCache=e=>{if(!e)return!1;this.cache.has(e)};getCache=e=>{if(e)return this.cache.get(e)};getCacheTime=e=>e&&this.cacheTime.get(e)||0;removeCache=e=>{e&&(this.cache.delete(e),this.cacheTime.delete(e))};cacheId=e=>`_${e}_cache_`;timesRecord=(e,t={})=>{if(!e)return;const{mode:r="running",cycle:n="day"}=t||{},s=this.cacheId(r),i=this.getCache(s)||{},o=Date.now(),a=i[e],c={time:o,count:1,cycle:n};return a&&("day"!==n||m.isToday(a.time||0))&&(c.count=1+(a.count||0)),i[e]=c,this.setCache(s,i),i};timesValid=(e,t={})=>{if(!e)return!1;const{max:r=1,interval:n=0,mode:s="running",cycle:i="day"}=t||{},o=this.cacheId(s);let a=this.getCache(o);if(!a)return!0;const c=a[e];if(!c)return!0;if("day"===i&&!m.isToday(c.time||0))return!0;if(r<=(c.count||0))return!1;return!(Date.now()-(c.time||0)<n)};timesClean=(e="running")=>{const t=this.cacheId(e),r=this.getCache(t);if(!r)return;const n=Tt.copy(r);Tt.forof(n,((e,t)=>{"day"!==t.cycle&&void 0!==t.cycle||m.isToday(t.time||0)||delete r[e]})),this.setCache(t,r)};parallel=()=>new an};class ln{id="";start=0;end=0;cost=0;name="";type="";desc="";timeStartDesc="";timeEndDesc="";isDone=!1;flag=0;constructor(){this.id=l(),this.start=Date.now(),this.timeStartDesc=m.format(this.start,"hh:mm:ss.SSS")}get time(){return this.flag?this.end:this.start}get timeDesc(){return this.flag?this.timeEndDesc:this.timeStartDesc}done=(e=Date.now())=>{this.start&&(this.end=e,this.cost=this.end-this.start,this.timeEndDesc=m.format(this.end,"hh:mm:ss.SSS"),this.isDone=!0)}}const un=new class{__map=new Map;__trackList=[];opened=!0;clear(){return this.__map.clear(),this.__trackList=[],this}add(e,{desc:t="",type:r=""}={}){if(!e||!this.opened)return"";const n=new ln;return n.name=e,n.type=r,n.desc=t,this.__trackList.push(n),n.id}done(e){if(!e||!this.opened)return;const t=this.__trackList.find((t=>t.id===e));if(!t||t.isDone)return;t.done();const r=Pt.cloneClass(t);r.id=this._endId(e),r.flag=1,r.desc=`${t.desc} | end`,this.__trackList.push(r)}getTrack(e){return this.__trackList.find((t=>t.id===e))}getLine(e){if(!e||e.endsWith("-end"))return[];const t=this.__trackList.findIndex((t=>t.id===e));if(t<0)return[];const r=this._endId(e),n=this.__trackList.findIndex((e=>e.id===r)),s=n<0?this.__trackList.length-t:n-t+1;return Mt.take(this.__trackList,s,t)}getList(e,t=""){if(!e)return[];const r=this.__trackList.filter((t=>t.name===e));if(r.length<=0)return[];if(!t)return r;const n=this._endId(t);return this.__trackList.filter((e=>e.id===t||e.id===n))}get list(){return this.__trackList}get size(){return this.__trackList.length}_endId=e=>`${e}-end`;report(e){const t=this.list;if(!t||t.length<=0)return;const r=t[0].time;t.forEach((t=>e&&e(t,r)))}},hn=e=>{try{const t=Kr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},fn=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var dn={generateKeys:async()=>{try{const e=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),t=await window.crypto.subtle.exportKey("spki",e.publicKey),r=hn(t),n=fn(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),i=hn(s);return{publicKey:r,publicKeyPem:n,privateKey:i,privateKeyPem:fn(i,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:fn,format_pem_content:hn,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Kr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Kr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Kr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Kr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["decrypt"]),s=await window.crypto.subtle.decrypt({name:"RSA-OAEP"},n,r);return(new TextDecoder).decode(s)}catch(e){return console.error("decrypt failed:",e),""}}};var pn={brotliCompress:function(t,r=e.constants.BROTLI_DEFAULT_QUALITY){try{if(!t)return"";const n=Buffer.from(t,"utf-8");return e.brotliCompressSync(n,{params:{[e.constants.BROTLI_PARAM_QUALITY]:r}}).toString("base64")}catch(e){return t||""}},brotliDecompress:function(t){try{if(!t)return"";const r=Buffer.from(t,"base64");return e.brotliDecompressSync(r).toString("utf-8")}catch(e){return t||""}}};const gn=t?.webcrypto?.subtle;var yn={...pn,Ecdh:class{publicKey="";privateKey="";sharedSecret;iv;_curve;_algorithm;_ecdh;constructor(e="prime256v1",t="aes-256-gcm"){this._curve=e,this._algorithm=t,this.generateKey()}generateKey(){const e=t.createECDH(this._curve);e.generateKeys(),this.publicKey=e.getPublicKey("base64"),this.privateKey=e.getPrivateKey("base64"),this._ecdh=e}deriveSharedSecret(e,t){if(e)return this.sharedSecret=this._ecdh.computeSecret(e,"base64").toString("base64"),this.iv=t,this}encode(e){if(!this.sharedSecret||!this.iv)return{text:"",authTag:"",iv:""};const r=t.createCipheriv("aes-256-gcm",Kr.base64ToBytes(this.sharedSecret),Kr.base64ToBytes(this.iv));return{text:r.update(e,"utf8","base64")+r.final("base64"),authTag:r.getAuthTag().toString("base64"),iv:this.iv}}decode(e,r,n){if(!(e&&this.sharedSecret&&n&&r))return"";const s=t.createDecipheriv("aes-256-gcm",Kr.base64ToBytes(this.sharedSecret),Kr.base64ToBytes(n));s.setAuthTag(Kr.base64ToBytes(r));return s.update(e,"base64","utf8")+s.final("utf8")}},EcdhSpki:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await gn.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await gn.exportKey("spki",e);return Kr.ab2str(t,!0)}async importSpkiKey(e){const t=Kr.base64ToBytes(e);return await gn.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await gn.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Kr.textEncode(e),r=await gn.encrypt({name:"AES-GCM",iv:Kr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Kr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Kr.str2ab(e,!0),n=await gn.decrypt({name:"AES-GCM",iv:Kr.base64ToBytes(t)},this.__sharedSecret,r);return Kr.textDecode(n)}},Socks5:class{upstreamProxy;server=null;clientSockets=new Set;allowedDomains;connectionPool={};__debug=!1;__uuid;constructor(e,t=[],r=!1){this.upstreamProxy=e,this.allowedDomains=new Set(t),this.__debug=r,this.__uuid=l()}get id(){return this.__uuid}validateProxyConfig(e=this.upstreamProxy){const{ipaddress:t,port:r,userId:n,password:s}=e||{};return t&&"string"==typeof t?r&&"number"==typeof r?n&&"string"==typeof n?s&&"string"==typeof s?"":"无效的上游代理密码":"无效的上游代理用户名":"无效的上游代理端口":"无效的上游代理 IP 地址"}async start(e=9968){if(this.validateProxyConfig())return 0;if(this.server)return console.log("[socks] server is already running"),0;const t=await this.findAvailablePort(e);return t?(this.server=r.createServer((e=>this.handleSocksConnection(e))),this.server.listen(t,(()=>{this.__debug&&console.log(`[socks] server is running on port ${t}`)})),this.server.on("error",(e=>{console.error("[socks] server error:",e),this.close()})),t):t}setUpstreamProxy(e){return!!e&&(!this.validateProxyConfig(e)&&(this.upstreamProxy=e,!0))}setAllowedDomains(e=[]){this.allowedDomains=new Set(e)}async findAvailablePort(e,t=200){let n=e,s=0;for(;s<t;)try{return await new Promise(((e,t)=>{const s=r.createServer();s.unref(),s.on("error",t),s.listen(n,(()=>{s.close((()=>e()))}))})),n}catch{s++,n++}return console.warn("[socks] findAvailablePort failed"),0}async handleSocksConnection(e){this.clientSockets.add(e),e.on("close",(()=>{this.clientSockets.delete(e),e?.destroy()}));try{await this.performHandshake(e);const t=await this.parseClientRequest(e);if(this.__debug&&console.log("[socks] handle connection",t.addr),this.isAllowedDomain(t.addr)){const r=await this.connectToUpstreamProxy(t);this.setupDataForwarding(e,r)}else{const r=await this.connectToLocal(t);this.setupDataForwarding(e,r)}}catch(t){console.error("[socks] connection failed:",t),e.end(new Uint8Array([5,1]))}}performHandshake(e){return new Promise(((t,r)=>{e.once("data",(n=>{if(5!==n[0])return r(new Error("Unsupported SOCKS version"));e.write(new Uint8Array([5,0])),t()}))}))}parseClientRequest(e){return new Promise(((t,r)=>{e.once("data",(e=>{let n,s;if(1!==e[1])return r(new Error("Unsupported command"));if(1===e[3])n=e.slice(4,8).join("."),s=e.readUInt16BE(8);else{if(3!==e[3])return r(new Error("Unsupported address type"));{const t=e[4];n=e.slice(5,5+t).toString(),s=e.readUInt16BE(5+t)}}t({addr:n,port:s})}))}))}async connectToUpstreamProxy(e){const t=`${e.addr}:${e.port}`;if(this.connectionPool[t]&&!this.connectionPool[t].destroyed)return this.connectionPool[t];const r={proxy:{...this.upstreamProxy,type:5},command:"connect",destination:{host:e.addr,port:e.port}};try{const{socket:e}=await n.createConnection(r);return this.connectionPool[t]=e,e.on("close",(()=>{delete this.connectionPool[t]})),e}catch(e){throw new Error("Failed to connect to upstream proxy: "+e)}}connectToLocal(e){return new Promise(((t,n)=>{const s=r.createConnection(e.port,e.addr,(()=>{t(s)}));s.on("error",(e=>{n(e)}))}))}setupDataForwarding(e,t){e.write(new Uint8Array([5,0,0,1,0,0,0,0,0,0])),e.pipe(t),t.pipe(e),e.on("close",(()=>{t.end()})),t.on("close",(()=>{e.end()})),e.on("error",(e=>{this.__debug&&console.error("[socks] client socket error:",e),t.end()})),t.on("error",(t=>{this.__debug&&console.error("[socks] target socket error:",t),e.end()}))}isAllowedDomain(e){for(const t of this.allowedDomains){if("*"===t)return!0;if(e.includes(t))return!0}return!1}close(){this.server&&(console.log("[socks] closing SOCKS5 proxy server..."),this.server.close((e=>{e&&console.error("[socks] closing the server failed:",e)})),this.clientSockets.forEach((e=>e.destroy())),Object.values(this.connectionPool).forEach((e=>e.destroy())),this.server=null)}}};var mn={Ecdh:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await window.crypto.subtle.exportKey("spki",e);return Kr.ab2str(t,!0)}async importSpkiKey(e){const t=Kr.base64ToBytes(e);return await window.crypto.subtle.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await window.crypto.subtle.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Kr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Kr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Kr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Kr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Kr.base64ToBytes(t)},this.__sharedSecret,r);return Kr.textDecode(n)}}};const wn={gbk:s,math:Oe,list:Mt,string:Ct,time:m,obj:Pt,rule:kr,regex:Sr,...Kr,...jr,...Tt,Event:u},bn={...Kr,...jr,...Se},vn={mini:Ht,css:Fr,qs:Xt,icon:Xr,html:Ir},_n={cdn:zr,watermark:on},xn={Store:rn,storeRef:nn,Persist:tn,persistConfig:en},kn=cn,Sn=un,An=Yr,$n={fetch:Qr,Http:Wr,css:Fr,qs:Xt,icon:Xr,html:Ir,rsa:dn,...mn},Cn={...yn};var On={gbk:s,time:m,hook:Se,math:Oe,util:Tt,list:Mt,string:Ct,obj:Pt,crypto:jr,mini:Ht,qs:Xt,css:Fr,cdn:zr,html:Ir,icon:Xr,rule:kr,regex:Sr,convert:Kr,Event:u,Http:Wr,Store:rn,storeRef:nn,Persist:tn,persistConfig:en,watermark:on,joker:cn,tracker:un,logger:Yr,fetch:Qr,rsa:dn};export{_n as dCdn,bn as dHook,kn as dJoker,An as dLogger,vn as dMini,Cn as dNode,xn as dStore,Sn as dTracker,wn as dUtil,$n as dWeb,On as default};
1
+ import e from"zlib";import t from"node:crypto";import r from"net";import{SocksClient as n}from"socks";var s={gbkLength:function(e){let t=0;if(!e)return 0;for(let r=0;r<e.length;r++)e.charCodeAt(r)>127||94===e.charCodeAt(r)?t+=2:t++;return t},gbkCut:function(e,t){if(!e||t<=0)return"";let r=0,n=0;for(let s=0;s<e.length&&(e.charCodeAt(s)>127||94===e.charCodeAt(s)?r+=2:r++,!(r>t));s++)n=s;return e.substr(0,n+1)}};const o="0123456789",i="abcdefghijklmnopqrstuvwxyz",a="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var c={keyNumber:o,keyLower:i,keyUpper:a,keyChars:o+i+a};const l=(e=0,t=0)=>{const r=c.keyChars.split(""),n=[];let s;if(t=t||r.length,e)for(s=0;s<e;s++)n[s]=r[0|Math.random()*t];else{let e;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",s=0;s<36;s++)n[s]||(e=0|16*Math.random(),n[s]=r[19==s?3&e|8:e])}return n.join("")};class u{__map;__tagList;__eventId="";constructor(){this.__map=new Map,this.__tagList=[],this.__eventId=l()}clear(){return this.__map.clear(),this}on(e,t,r=""){if(!e||!t)return this;let n=this.__map.get(e);return n||(n=new Set,this.__map.set(e,n)),n.add(t),r&&this.__tagList.push({name:e,listener:t,tag:r}),this}emit(e,...t){if(!e)return this;const r=this.__map.get(e);if(!r)return this;return[...r].forEach((e=>e&&e(...t))),this}off(e,t){if(!e||!t)return this;this.__tagList=this.__tagList.filter((r=>r.name!==e||r.listener!==t));const r=this.__map.get(e);return r?(r.delete(t),r.size<=0&&this.__map.delete(e),this):this}remove(e){return e?(this.__tagList=this.__tagList.filter((t=>t.name!==e)),this.__map.delete(e),this):this}removeByTag(e){if(!e)return this;return this.__tagList.filter((t=>t.tag===e)).forEach((e=>{this.off(e.name,e.listener)})),this.__tagList=this.__tagList.filter((t=>t.tag!==e)),this}once(e,t){const r=(...n)=>{t(...n),this.off(e,r)};return this.on(e,r),this}has(e){return this.__map.has(e)}}class h{_loopTimer;_event=new u;started=!1;interval=0;constructor(e=0){this.interval=e||500}start(){return this.started||(this.stop(),this._loopTimer=setInterval((()=>{this._handleLoop()}),this.interval),this.started=!0),this}stop(){return this._loopTimer?(clearInterval(this._loopTimer),this._loopTimer=0,this.started=!1,this):this}restart(){return this.stop(),this.start(),this}on(e){return this._event.on("frame",e),this}off(e){return e?(this._event.off("frame",e),this):this}_handleLoop(){this._event.emit("frame")}}var d={oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};class f{date;timestamp=0;yyyy=0;yy="";M=0;MM="";d=0;dd="";h=0;hh="";m=0;mm="";s=0;ss="";S=0;SS="";SSS="";constructor(e){if(!e)return;const t="string"==typeof e||"number"==typeof e?new Date(e):e;t&&(this.date=t,this.timestamp=t.getTime(),this.toDate())}toDate(){return this.date?(this.yyyy=this.date.getFullYear(),this.yy=`${this.yyyy}`.substr(2),this.M=this.date.getMonth()+1,this.MM=(this.M<10?"0":"")+this.M,this.d=this.date.getDate(),this.dd=(this.d<10?"0":"")+this.d,this.h=this.date.getHours(),this.hh=(this.h<10?"0":"")+this.h,this.m=this.date.getMinutes(),this.mm=(this.m<10?"0":"")+this.m,this.s=this.date.getSeconds(),this.ss=(this.s<10?"0":"")+this.s,this.S=this.date.getMilliseconds(),this.SS=(this.S<10?"0":"")+this.S,this.SSS=this.S.toString().padStart(3,"0"),this):this}toCountdown(e=""){const t={countdown:0,timestamp:0,seconds:0,d:0,dd:"",h:0,hh:"",m:0,mm:"",s:0,ss:"",S:0,SS:"",SSS:"",desc:""};if(!this.timestamp)return t;t.timestamp=this.timestamp,t.countdown=Math.max(t.timestamp-Date.now(),0),t.seconds=Math.floor(t.countdown/d.oneSecond);let r=t.countdown;t.d=Math.floor(r/d.oneDay),t.dd=(t.d<10?"0":"")+t.d,r%=d.oneDay,t.h=Math.floor(r/d.oneHour),t.hh=(t.h<10?"0":"")+t.h,r%=d.oneHour,t.m=Math.floor(r/d.oneMinute),t.mm=(t.m<10?"0":"")+t.m,r%=d.oneMinute,t.s=Math.floor(r/d.oneSecond),t.ss=(t.s<10?"0":"")+t.s,r%=d.oneSecond,t.S=r,t.SS=(t.S<10?"0":"")+t.S,t.SSS=t.S.toString().padStart(3,"0");let n=e;return n||(n=t.countdown>d.oneHour?"hh:mm:ss":t.countdown>d.oneMinute?"mm:ss":"ss"),t.desc=n.replace(/\bdd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>t[e])),t}add(e=0){return e?(this.timestamp=this.timestamp+e,this.date=new Date(this.timestamp),this.toDate(),this):this}format(e="yyyy-MM-dd hh:mm:ss"){return e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>this[e]))}static get timezoneOffset(){return(new Date).getTimezoneOffset()/60}static getLocalTime(e=0){const t=new Date,r=t.getTime(),n=6e4*t.getTimezoneOffset();return new Date(r+n+36e5*e)}}const p=(e,t="yyyy-MM-dd hh:mm:ss")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;return r?g(r).format(t):""},g=e=>{const t="string"==typeof e||"number"==typeof e?new Date(e):e;return new f(t||0)};function y({year:e=0,month:t=0,date:r=0,hour:n=0,minute:s=0,second:o=0}){const i=`${e||"yyyy"}/${t||"MM"}/${r||"dd"} ${n}:${s}:${o}`;return new Date(p(Date.now(),i)).getTime()}var m={...d,now:function(){return g(new Date)},isToday:e=>e&&(new Date).toDateString()===new Date(e).toDateString(),parseTimestamp:y,todayZero:()=>y({}),format:p,countdown:(e,t="")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;if(!r)return"";return g(r).toCountdown(t)},dtime:g,loopFrame:(e=500)=>new h(e),getTimezoneOffset:()=>f.timezoneOffset,getLocalTime:f.getLocalTime};const w="object"==typeof global&&null!==global&&global.Object===Object&&global,b="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis,v="object"==typeof self&&null!==self&&self.Object===Object&&self,_=b||w||v||Function("return this")(),x=_.Symbol,{toString:k,hasOwnProperty:S,propertyIsEnumerable:$}=Object.prototype,A=x?x.toStringTag:void 0;function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":A&&A in Object(e)?function(e){const t=S.call(e,A),r=e[A];let n=!1;try{e[A]=void 0,n=!0}catch(e){}const s=k.call(e);return n&&(t?e[A]=r:delete e[A]),s}(e):k.call(e)}var O={getTag:C,getType:function(e){return(C(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:k,hasOwnProperty:S,propertyIsEnumerable:$};const E="object"==typeof exports&&null!==exports&&!exports.nodeType&&exports,j=E&&"object"==typeof module&&null!==module&&!module.nodeType&&module,q=j&&j.exports===E&&w.process,P=(()=>{try{const e=j&&j.require&&j.require("util").types;return e||q&&q.binding&&q.binding("util")}catch(e){}})();var L="[object Function]",T="[object GeneratorFunction]",F="[object AsyncFunction]",M=9007199254740991;const R=/^(?:0|[1-9]\d*)$/,D=_?.Buffer?.isBuffer,B=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,U=P&&P.isTypedArray;function I(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function z(e){return null!=e&&"object"==typeof e}const K=Array.isArray;function N(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=M}(e.length)&&!V(e)}function H(e){return z(e)&&N(e)}function V(e){var t=I(e)?O.getTag(e):"";return t===L||t===T||t===F}function W(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)}function Z(e){return H(e)&&O.hasOwnProperty.call(e,"callee")&&(!O.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==O.toString.call(e))}const G="undefined"!=typeof window&&void 0!==window.document,J="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,Y=U?e=>U(e):e=>z(e)&&B.test(O.getTag(e)),Q="function"==typeof D?D:()=>!1;var X={is:function(e,t){return O.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===O.getTag(e)},isString:function(e){return"string"==typeof e||!K(e)&&z(e)&&"[object String]"==O.getTag(e)},isObject:I,isObjectLike:z,isPlainObject:function(e){if(!z(e)||"[object Object]"!=O.getTag(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},isSymbol:function(e){return"symbol"==typeof e||z(e)&&"[object Symbol]"===O.getTag(e)},isFunction:V,isArray:K,isArrayLikeObject:H,isIndex:function(e,t){return!!(t=null==t?M:t)&&("number"==typeof e||R.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:N,isPrototype:W,isArguments:Z,isPromise:function(e){return"[object Promise]"===(I(e)?O.getTag(e):"")},isBrowser:G,isNode:J,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer,isEmpty:e=>{if(null==e)return!0;if(N(e)&&(Array.isArray(e)||"string"==typeof e||"function"==typeof e.splice||Q(e)||Y(e)||Z(e)))return!e.length;const t=O.getTag(e);if("[object Map]"===t||"[object Set]"===t)return!e.size;if(W(e))return!Object.keys(e).length;for(const t in e)if(O.hasOwnProperty.call(e,t))return!1;return!0}};const ee=NaN,te=/^\s+|\s+$/g,re=/^[-+]0x[0-9a-f]+$/i,ne=/^0b[01]+$/i,se=/^0o[0-7]+$/i,oe=parseInt,ie=1/0,ae=17976931348623157e292;function ce(e){if("number"==typeof e)return e;if(X.isSymbol(e))return ee;if(X.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=X.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(te,"");const t=ne.test(e);return t||se.test(e)?oe(e.slice(2),t?2:8):re.test(e)?ee:+e}function le(e){return e?(e=ce(e))===ie||e===-ie?(e<0?-1:1)*ae:e==e?e:0:0===e?e:0}var ue={toNumber:ce,toFinite:le,toInteger:function(e){var t=le(e),r=t%1;return t==t?r?t-r:t:0}};const he="Expected a function",de=Math.max,fe=Math.min;function pe(e,t=300,r={}){let n,s,o,i,a,c,l=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError(he);function f(t){const r=n,o=s;return n=s=void 0,l=t,i=e.apply(o,r),i}function p(e){const r=e-c;return void 0===c||r>=t||r<0||h&&e-l>=o}function g(){const e=Date.now();if(p(e))return y(e);a=setTimeout(g,function(e){const r=t-(e-c);return h?fe(r,o-(e-l)):r}(e))}function y(e){return a=void 0,d&&n?f(e):(n=s=void 0,i)}function m(...e){const r=Date.now(),o=p(r);if(n=e,s=this,c=r,o){if(void 0===a)return function(e){return l=e,a=setTimeout(g,t),u?f(e):i}(c);if(h)return a=setTimeout(g,t),f(c)}return void 0===a&&(a=setTimeout(g,t)),i}return t=ue.toNumber(t)||0,X.isObject(r)&&(u=!!r.leading,h="maxWait"in r,o=h?de(ue.toNumber(r.maxWait)||0,t):o,d="trailing"in r?!!r.trailing:d),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=s=a=void 0},m.flush=function(){return void 0===a?i:y(Date.now())},m.pending=function(){return void 0!==a},m}class ge{__list=[];constructor(e){this.push(e)}push(e){return e&&this.__list.push(e),this}clear(){return this.__list=[],this}_exec(e,t){let r;if(X.isFunction(e))r=e(t);else{if(X.isPromise(e))return e.then((e=>({...t,...e})));r=e}return X.isPromise(r)?r:Promise.resolve({...r,...t})}run(e){try{return this.__list.reduce(((e,t)=>e.then((e=>this._exec(t,e)))),Promise.resolve(e)).then((e=>[void 0,e])).catch((e=>[e,void 0]))}catch(e){return Promise.reject([e,void 0])}}}async function ye(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const me=e=>{try{let t;return t=X.isFunction(e)?e():e,ye(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var we={to:ye,go:e=>me(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:me};class be{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var ve={singleton:function(){class e{static __instance__;constructor(){}static get Instance(){return e.__instance__||(e.__instance__=new this),e.__instance__}static get I(){return this.Instance}}return e},getset:function(e){const t=new be;return void 0!==e&&t.set(e),t}};class _e{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return we.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class xe{__list=[];__count=0;__max=1;constructor(e=1){this.__count=0,this.__max=e>0?e:1,this.clear()}push(e,t){const r=new _e(e,t);return this.__list.push(r),this._step(),this}clear(){return this.__list=[],this.__count=0,this}_step(){if(this.__list.length<=0)return;if(this.__count>=this.__max)return;const e=this.__list.shift();e?(this.__count+=1,e?.run().finally((()=>{try{this.__count>0&&(this.__count-=1),this._step()}catch(e){console.error("[ddan] pipepine step finally",e)}}))):this._step()}async whenAll(){for(;;){if(this.__count<=0)break;await we.delay(100),this._step()}return this.clear()}}class ke extends(ve.singleton()){__lockedMap=new Map;pipeline=new xe;constructor(){super()}lock(e,t){if(!e||!t)return;const r=we.safeRun(t);return this.__lockedMap.set(e,r),r}unlock(e){e&&this.__lockedMap.has(e)&&this.__lockedMap.delete(e)}async exec(e,t){if(!e||!t)return we.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return we.safeRun(e);const s=await n;return this.unlock(t),s}}var Se={...we,sleep:we.delay,run:async function(e,t=0){if(t<=0)return we.safeRun(e);const r=t>0?Date.now():0,n=await we.safeRun(e),s=Date.now()-r;return s<t&&await we.delay(t-s),n},exec:(e,t="")=>ke.I.exec(e,t),debounce:pe,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return X.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),pe(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new ge(e),mutex:function(e){var t=null;return async function(...r){if((t=this||t||{}).__ddMutex)return!1;t.__ddMutex=!0;try{e&&await Promise.resolve(e.apply(this,r))}catch(e){console.log(e)}finally{t.__ddMutex=!1}}},polling:async function(e={}){const{func:t,interval:r=100,times:n=1e3}=e;let s=n;const o=r<1?100:r;do{if(!t)break;const[e,r]=await we.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await we.delay(o)}while(-1===n||s>0)},pipe:(e,t)=>ke.I.pipeline.push(e,t),pipeline:(e=1)=>new xe(e),safeTask:(e,t)=>new _e(e,t)};function $e(e){return Math.floor(Math.random()*e)}function Ae(e,t=10){return+parseFloat(Number(e).toExponential(t))}const Ce=180/Math.PI;var Oe={random:$e,randomRange:function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},lerp:function(e,t,r){return e*(1-r)+t*r},randoms:function(e,t=1,r=!1){const n=[];for(;;){if(n.length>=t)break;if(!r&&n.length>=e)break;const s=$e(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:Ae,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=Ae(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*Ce},degree2radian:function(e){return e/Ce},formatMemory:function(e){let t=e;const r={g:0,m:0,kb:0,b:0,desc:""};return t>=1<<30&&(r.g=Math.floor(t/(1<<30)),t%=1<<30),t>=1<<20&&(r.m=Math.floor(t/(1<<20)),t%=1<<20),t>=1024&&(r.kb=Math.floor(t/1024),t%=1024),r.b=t,r.desc=e>=1<<30?(e/(1<<30)).toFixed(2)+"G":e>=1<<20?(e/(1<<20)).toFixed(2)+"M":e>=1024?(e/1024).toFixed(2)+"KB":e+"B",r}};function Ee(e){return e!=e}function je(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,s=Array(n);++r<n;)s[r]=t(e[r],r,e);return s}(t,(function(t){return e[t]}))}var qe,Pe,Le=(qe=Object.keys,Pe=Object,function(e){return qe(Pe(e))}),Te=Math.max;function Fe(e,t){var r=X.isArray(e)||X.isArguments(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,s=!!n;for(var o in e)!t&&!O.hasOwnProperty.call(e,o)||s&&("length"==o||X.isIndex(o,n))||r.push(o);return r}function Me(e,t,r){const{length:n}=e;return r=void 0===r?n:r,!t&&r>=n?e:function(e,t,r){let n=null==e?0:e.length;if(!n)return[];(t=null==t?0:t)<0&&(t=-t>n?0:n+t),(r=(r=void 0===r?n:r)>n?n:r)<0&&(r+=n),n=t>r?0:r-t>>>0,t>>>=0;let s=-1;const o=new Array(n);for(;++s<n;)o[s]=e[s+t];return o}(e,t,r)}const Re=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function De(e){return Re.test(e)}const Be="\\ud800-\\udfff",Ue=`[${Be}]`,Ie="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ze="\\ud83c[\\udffb-\\udfff]",Ke=`[^${Be}]`,Ne="(?:\\ud83c[\\udde6-\\uddff]){2}",He="[\\ud800-\\udbff][\\udc00-\\udfff]",Ve=`${`(?:${Ie}|${ze})`}?`,We="[\\ufe0e\\ufe0f]?",Ze=We+Ve+`(?:\\u200d(?:${[Ke,Ne,He].join("|")})${We+Ve})*`,Ge=`(?:${[`${Ke}${Ie}?`,Ie,Ne,He,Ue].join("|")})`,Je=RegExp(`${ze}(?=${ze})|${Ge+Ze}`,"g");function Ye(e){return De(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.split("")}(e)}function Qe(e){return t=>{if(!t)return"";const r=De(t)?Ye(t):void 0,n=r?r[0]:t[0],s=r?Me(r,1).join(""):t.slice(1);return n[e]()+s}}const Xe="\\ud800-\\udfff",et="\\u2700-\\u27bf",tt="a-z\\xdf-\\xf6\\xf8-\\xff",rt="A-Z\\xc0-\\xd6\\xd8-\\xde",nt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",st="['’]",ot=`[${nt}]`,it=`[${et}]`,at=`[${tt}]`,ct=`[^${Xe}${nt+"\\d"+et+tt+rt}]`,lt="(?:\\ud83c[\\udde6-\\uddff]){2}",ut="[\\ud800-\\udbff][\\udc00-\\udfff]",ht=`[${rt}]`,dt=`(?:${at}|${ct})`,ft=`(?:${ht}|${ct})`,pt=`(?:${st}(?:d|ll|m|re|s|t|ve))?`,gt=`(?:${st}(?:D|LL|M|RE|S|T|VE))?`,yt="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",mt="[\\ufe0e\\ufe0f]?",wt=mt+yt+`(?:\\u200d(?:${[`[^${Xe}]`,lt,ut].join("|")})${mt+yt})*`,bt=`(?:${[it,lt,ut].join("|")})${wt}`,vt=RegExp([`${ht}?${at}+${pt}(?=${[ot,ht,"$"].join("|")})`,`${ft}+${gt}(?=${[ot,ht+dt,"$"].join("|")})`,`${ht}?${dt}+${pt}`,`${ht}+${gt}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",bt].join("|"),"g");const _t=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),xt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function kt(e,t){if(void 0===t){const t=_t(e)?function(e){return e.match(vt)}(e):function(e){return e.match(xt)}(e);return t||[]}return e.match(t)||[]}function St(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:St(e)))}`;if(X.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const $t=Qe("toUpperCase"),At=Qe("toLowerCase");var Ct={toString:St,startCase:e=>kt(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+$t(t)),""),snakeCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?$t(t):t))),""),upperCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:$t,lowerCase:e=>kt(St(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:At,splitOnFirst:(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===e||""===t)return[];const r=e.indexOf(t);return-1===r?[]:[e.slice(0,r),e.slice(r+t.length)]},parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{let n=e;return e&&"string"==typeof e?(t&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?n=Number(e):!r||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(n="true"===e.toLowerCase()),n):n},replace:(e,t)=>{if(!e)return e;if(!t)return e;let r=e;return((Array.isArray(t)?t:[t])||[]).forEach((e=>{e.key&&e.value&&(r=r.replace(new RegExp(e.key,e.flag||""),e.value))})),r}};const Ot=e=>{if(!e)return e;if("object"!=typeof e)return e;const t=Array.isArray(e)?[]:{};for(const r in e)e.hasOwnProperty(r)&&(t[r]=Ot(e[r]));return t};const Et=(e,t,r={})=>{const n=e||{},{ignoreUndefined:s=!0,cover:o=!1}=r;if(!t)return n;for(const i in t){if(!t.hasOwnProperty(i))continue;const a=t[i];"object"!=typeof a||"object"!=typeof e[i]||o?s&&void 0===a||r.ignoreNull&&null===a||r.ignoreZero&&0===a||r.ignoreEmptyArray&&Array.isArray(a)&&a.length<=0||r.ignoreEmptyString&&"string"==typeof a&&""===a.trim()||(n[i]=a):n[i]=jt(e[i],a,r)}return n},jt=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?Et(e,t,r):Et({...e},t,r),n},qt=(e,t,r={})=>Et({...e},t,{cover:!0,...r}),Pt=(e,t,r,n,s=!1)=>{if(!e||!t||!r)return;let o=e[t];null!==o&&"object"==typeof o&&s&&Object.keys(o).forEach((e=>{Pt(o,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:i=>{r.call(n,i,o),o=i,s&&Pt(e,t,r,n,s)},get:()=>o})};var Lt={copy:(e,t={})=>{if(void 0===e)return;const r=JSON.parse(JSON.stringify(e));if("object"!=typeof r)return r;if(Array.isArray(r))return r;const{fields:n=[],camel:s=!1,pure:o=!0}=t;if((!n||n.length<=0)&&!s)return r;const i={};for(const e in r){if(!r.hasOwnProperty(e))continue;const a=s?o&&e.startsWith("_")?e:Ct.camelCase(e):e;if(n.length>0&&!n.includes(e)&&!n.includes(a))continue;const c=r[e];t.ignoreNull&&null===c||(t.ignoreZero&&0===c||t.ignoreEmptyArray&&Array.isArray(c)&&c.length<=0||t.ignoreEmptyString&&"string"==typeof c&&""===c.trim()||(i[a]=c))}return i},clone:Ot,merge:jt,isEmpty:e=>0!==e&&(!e||"object"==typeof e&&(Array.isArray(e)?!e.length:Object.keys(e).length<=0)),parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{if(!e&&"object"!=typeof e)return e;for(const[n,s]of Object.entries(e))if("object"==typeof s&&null!==s)for(const[e,n]of Object.entries(s))s[e]=Ct.parseValue(n,{number:t,boolean:r});else e[n]=Ct.parseValue(s,{number:t,boolean:r});return e},cloneClass:function(e){return e?"object"!=typeof e?e:Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e)):e},combine:qt,combines:(e,t={})=>{let r={};if(!e||e.length<=0)return r;const{ignoreUndefined:n=!0,ignoreNull:s=!0,ignoreZero:o=!0,ignoreEmptyArray:i=!0,ignoreEmptyString:a=!0,cover:c=!0}=t;return e.forEach((e=>r=qt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:o,ignoreEmptyArray:i,ignoreEmptyString:a,cover:c}))),r},observe:Pt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var Tt={...X,...O,...Lt,...ve,includes:function(e,t,r,n){e=X.isArrayLike(e)?e:function(e){return e?je(e,function(e){return X.isArrayLike(e)?Fe(e):function(e){if(!X.isPrototype(e))return Le(e);var t=[];for(var r in Object(e))O.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?ue.toInteger(r):0;var s=e.length;return r<0&&(r=Te(s+r,0)),X.isString(e)?r<=s&&e.indexOf(t,r)>-1:!!s&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var s=e.length,o=r+(n?1:-1);n?o--:++o<s;)if(t(e[o],o,e))return o;return-1}(e,Ee,r);for(var n=r-1,s=e.length;++n<s;)if(e[n]===t)return n;return-1}(e,t,r)>-1},forof:(e,t)=>{if(!e)return;let r;if(X.isObject(e)&&(r=X.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var Ft={groupBy:function(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})},first:function(e){if(!e)return;return e.length<=0?void 0:e[0]},last:function(e){if(!e)return;const t=e.length;return t<=0?void 0:e[t-1]},toList:function(e){return Array.isArray(e)?e:e?[e]:[]}};var Mt={...Ft,stepAction:function(e,t,r=100){if(!X.isFunction(t))return;if(!X.isArray(e)||e.length<=0)return;let n=0;for(;e.length>n;){let s=r+n,o=e.slice(n,s);t&&t(o),n=s}},skip:function(e,t){if(!X.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!X.isArray(e)||e.length<=0)return[];const n=r||0;if(n>=e.length)return[];const s=t+n;return e.slice(n,e.length<s?e.length:s)||[]},distinct:function(e){return!X.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return Oe.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!X.isObject(e))return;const s=e[t];(X.isString(s)&&""!==s||X.isNumber(s))&&(n[s]=e[r])})),n):n}};const Rt="[object Object]",Dt="[object Array]",Bt=e=>Object.prototype.toString.call(e),Ut=(e,t,r=!1)=>{if(e===t)return;const n=Bt(e);if(n===Bt(t))if(n===Dt&&e.length>=t.length)for(let r=0;r<t.length;r++)Ut(e[r],t[r]);else if(n===Rt&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?Ut(e[n],t[n]):e[n]=null},It=(e,t,r,n="",s=!1)=>{if(e===t)return;const o=Bt(e),i=Bt(t);if(o===Dt&&i===o&&e.length>=t.length)for(let s=0;s<e.length;s++)It(e[s],t[s],r,`${n}[${s}]`);else if(o===Rt&&i===o&&(s||Object.keys(e).length>=Object.keys(t).length)){const s=Object.keys(e);for(let o of s){const s=e[o],i=t[o],a=Bt(s),c=Bt(i);if(s!==i)if(a===Dt&&c===a&&s.length>=i.length)for(let e=0;e<s.length;e++)It(s[e],i[e],r,`${n?n+".":""}${o}[${e}]`);else if(a===Rt&&c===a&&Object.keys(s).length>=Object.keys(i).length)for(let e in s)It(s[e],i[e],r,`${n?n+".":""}${o}.${e}`);else r[`${n?n+".":""}${o}`]=s}}else r[n]=e};class zt{list=[];constructor(){this.invoke=this.invoke.bind(this)}use(e){this.list=this.list.concat(e)}invoke(e){return this.list.reduce(((e,t)=>e.then((e=>t(e)))),Promise.resolve(e)).catch((e=>"REFETCH"===e.sig?Promise.resolve(e.result):Promise.reject(e)))}}class Kt{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new zt,response:new zt};constructor(e){const{reqConfig:t={},requestEncrypt:r,responseDecrypt:n,handleError:s,api:o}=e;this.reqConfig=t,this.handleEncrypt=r,this.handleDecrypt=n,this.handleError=s,this.handleRequest=o}static blockId="blockid";static requestLock={};lockR(e,t){Kt.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Kt.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}_fetch(e,t){let r=e;return t&&this.handleEncrypt&&(r=this.handleEncrypt(e)),new Promise(((e,n)=>{this.handleRequest({...r,success:r=>{let n=r;t&&this.handleDecrypt&&(n=this.handleDecrypt(r)),e(n)},fail:e=>{n(e)}})}))}async request(e,t){const r=Lt.copy(this.reqConfig[e]),{config:n,...s}=await this.interceptors.request.invoke({url:r.url,data:t||{},header:{"content-type":"application/json"},method:r.method?r.method:"POST",responseType:"text",config:r});let o;try{if("block"===n.model)this.lockR(Kt.blockId,(()=>this._fetch(s,n.hasEncrypt))),o=await Kt.requestLock[Kt.blockId].request;else if(Kt.requestLock[Kt.blockId]&&Kt.requestLock[Kt.blockId].lock&&await Kt.requestLock[Kt.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Kt.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),o=await Kt.requestLock[e].request,this.unlockR(e)}else o=await this._fetch(s,n.hasEncrypt)}catch(e){this.handleError&&this.handleError(e)}return this.interceptors.response.invoke({res:o,config:r,reqId:this.getIdFromReq(s),refetch:()=>({sig:"REFETCH",result:this.request(e,t||{})})})}}const Nt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Ht={diff:function(e,t){const r={};return(e=>{if(Bt(e)===Rt)for(let t in e)if(/\w+\.\w+/g.test(t)&&-1===t.indexOf("[")){const r=t.split(".");let n=e,s=r.length;for(let e=0;e<s-1;e++){const t=r[e];Bt(n[t])!==Rt&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),Ut(e,t,!0),It(e,t,r,"",!0),r},promixify:Nt,run:(e,t={})=>e?Se.run(Nt(e)(t)):Se.run(e),formatList:(e,t,r)=>(e||[]).reduce(((e,n,s)=>({...e,[`${r}[${t+s}]`]:n})),{}),ruleValidator:(e,t)=>!!t&&(!Array.isArray(t)||!(t.length<=0)&&t.every((e=>!!e))),Http:Kt,setWatcher:e=>{let t=e.data,r=e.watch;Object.keys(r).forEach((n=>{let s=t,o=n.split(".");for(let e=0;e<o.length-1;e++)s=s[o[e]];let i=o[o.length-1],a=r[n].handler||r[n],c=r[n].deep;Lt.observe(s,i,a,e,c)}))}};const Vt=function(e,{sep:t="&",eq:r="=",max:n=1e3,multiple:s=!0,uri:o=!0,parseNumber:i=!1,parseBoolean:a=!1}={}){t=t||"&",r=r||"=";const c={};if("string"!=typeof e||0===e.length)return c;const l=/\+/g,u=n||1e3;let h=(e=e.split(t)).length;u>0&&h>u&&(h=u);for(let t=0;t<h;++t){let n,i,a,u,h=e[t].replace(l,"%20"),d=h.indexOf(r);d>=0?(n=h.substr(0,d),i=h.substr(d+1)):(n=h,i=""),a=o?decodeURIComponent(n):n,u=o?decodeURIComponent(i):i,O.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(u):c[a]=[c[a],u]:c[a]=u}return Lt.parseValue(c,{number:i,boolean:a}),c},Wt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Zt=function(e,t=!0){return t?encodeURIComponent(e):e},Gt=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},Jt=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,Yt=e=>{const t=(e||"").replace(/\\/g,"/").split("?")[0],r=t.match(/[\/]?([\w\_\-]+)[.]?[\w]*[?]?$/),n=r?r[1]:"",s=t.lastIndexOf("/")+1,o=t.substring(s),i=o.lastIndexOf("."),a=o.substring(0,i)||"",c=i>=0?o.substring(i):"";return{route:t.substring(0,s)||"",page:n,name:o,withoutExtension:a,extname:c}},Qt=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(Jt);if(!r||r.length<4)return t;const n=r[3]||"",s=e.split("?");return t.url=s[0],t.origin=r[0],t.protocol=`${r[1]}:`,t.host=`${r[2]}${n?":"+n:""}`,t.port=n,t.query=s.length>1?s[1]:"",t};var Xt={parse:Vt,stringify:function(e,{sep:t="&",eq:r="=",name:n=null,uri:s=!0,cleanZero:o=!1,cleanNull:i=!1,cleanWhitespace:a=!1}={}){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){const c=Zt(Wt(n),s)+r,l=e[n];return Array.isArray(l)?l.map((function(e){return c+Zt(Wt(e),s)})).join(t):Gt(l,{cleanZero:o,cleanNull:i,cleanWhitespace:a})?"":c+Zt(Wt(l),s)})).filter(Boolean).join(t):n?Zt(Wt(n),s)+r+Zt(Wt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=Qt(e),{origin:r="",url:n="",query:s=""}=t,o=Yt(n),i=Vt(s,{multiple:!0,uri:!1});return{...t,...o,pathname:n.substring(n.indexOf(r||"")+r.length),params:i}},parsePath:Yt,parseHost:Qt,join:(...e)=>{let t=[];return e.forEach((e=>{const r=e.trim().replace(/^\/*(.*?)\/*$/,"$1");r.length<=0||(/^(\w+):\/\//.test(r)?t=[r]:t.push(r))})),t.join("/")}};const er=/%[sdj%]/g;let tr=()=>{};function rr(e){if(!e||!e.length)return null;const t={};return e.forEach((e=>{const r=e.field;t[r]=t[r]||[],t[r].push(e)})),t}function nr(e,...t){let r=0;const n=t.length;if("function"==typeof e)return e.apply(null,t);if("string"==typeof e){return e.replace(er,(e=>{if("%%"===e)return"%";if(r>=n)return e;switch(e){case"%s":return String(t[r++]);case"%d":return Number(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch(e){return"[Circular]"}break;default:return e}}))}return e}function sr(e,t){return null==e||(!("array"!==t||!Array.isArray(e)||e.length)||!(!function(e){return"string"===e||"url"===e||"hex"===e||"email"===e||"date"===e||"pattern"===e}(t)||"string"!=typeof e||e))}function or(e,t,r){let n=0;const s=e.length;!function o(i){if(i&&i.length)return void r(i);const a=n;n+=1,a<s?t(e[a],o):r([])}([])}"undefined"!=typeof process&&process.env&&"production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&"undefined"!=typeof document&&(tr=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class ir extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function ar(e,t,r,n,s){if(t.first){const t=new Promise(((t,o)=>{const i=function(e){const t=[];return Object.keys(e).forEach((r=>{t.push(...e[r]||[])})),t}(e);or(i,r,(e=>(n(e),e.length?o(new ir(e,rr(e))):t(s))))}));return t.catch((e=>e)),t}const o=!0===t.firstFields?Object.keys(e):t.firstFields||[],i=Object.keys(e),a=i.length;let c=0;const l=[],u=new Promise(((t,u)=>{const h=e=>{if(l.push.apply(l,e),c++,c===a)return n(l),l.length?u(new ir(l,rr(l))):t(s)};i.length||(n(l),t(s)),i.forEach((t=>{const n=e[t];-1!==o.indexOf(t)?or(n,r,h):function(e,t,r){const n=[];let s=0;const o=e.length;function i(e){n.push(...e||[]),s++,s===o&&r(n)}e.forEach((e=>{t(e,i)}))}(n,r,h)}))}));return u.catch((e=>e)),u}function cr(e,t){return r=>{let n;return n=e.fullFields?function(e,t){let r=e;for(let e=0;e<t.length;e++){if(null==r)return r;r=r[t[e]]}return r}(t,e.fullFields):t[r.field||e.fullField],function(e){return!(!e||void 0===e.message)}(r)?(r.field=r.field||e.fullField,r.fieldValue=n,r):{message:"function"==typeof r?r():r,fieldValue:n,field:r.field||e.fullField}}}function lr(e,t){if(t)for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];"object"==typeof n&&"object"==typeof e[r]?e[r]={...e[r],...n}:e[r]=n}return e}const ur=(e,t,r,n,s,o)=>{!e.required||r.hasOwnProperty(e.field||"")&&!sr(t,o||e.type)||n.push(nr(s.messages.required,e.fullField))};let hr;const dr=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,fr=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,pr={integer:e=>pr.number(e)&&parseInt(e,10)===e,float:e=>pr.number(e)&&!pr.integer(e),array:e=>Array.isArray(e),regexp(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch(e){return!1}},date:e=>"function"==typeof e.getTime&&"function"==typeof e.getMonth&&"function"==typeof e.getYear&&!isNaN(e.getTime()),number:e=>!isNaN(e)&&"number"==typeof e,object:e=>"object"==typeof e&&!pr.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(dr),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(hr)return hr;const e="[a-fA-F\\d:]",t=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${e})|(?<=${e})(?=\\s|$))`:"",r="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",n="[a-fA-F\\d]{1,4}",s=`\n(?:\n(?:${n}:){7}(?:${n}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${n}:){6}(?:${r}|:${n}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${n}:){5}(?::${r}|(?::${n}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${n}:){4}(?:(?::${n}){0,1}:${r}|(?::${n}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${n}:){3}(?:(?::${n}){0,2}:${r}|(?::${n}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${n}:){2}(?:(?::${n}){0,3}:${r}|(?::${n}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${n}:){1}(?:(?::${n}){0,4}:${r}|(?::${n}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${n}){0,5}:${r}|(?::${n}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),o=new RegExp(`(?:^${r}$)|(?:^${s}$)`),i=new RegExp(`^${r}$`),a=new RegExp(`^${s}$`),c=e=>e&&e.exact?o:new RegExp(`(?:${t(e)}${r}${t(e)})|(?:${t(e)}${s}${t(e)})`,"g");c.v4=e=>e&&e.exact?i:new RegExp(`${t(e)}${r}${t(e)}`,"g"),c.v6=e=>e&&e.exact?a:new RegExp(`${t(e)}${s}${t(e)}`,"g");const l=c.v4().source,u=c.v6().source;return hr=new RegExp(`(?:^(?:(?:(?:[a-z]+:)?//)|www\\.)(?:\\S+(?::\\S*)?@)?(?:localhost|${l}|${u}|(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#][^\\s"]*)?$)`,"i"),hr})()),hex:e=>"string"==typeof e&&!!e.match(fr)},gr="enum";var yr={required:ur,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(nr(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void ur(e,t,r,n,s);const o=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(o)>-1?pr[o](t)||n.push(nr(s.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&n.push(nr(s.messages.types[o],e.fullField,e.type))},range:(e,t,r,n,s)=>{const o="number"==typeof e.len,i="number"==typeof e.min,a="number"==typeof e.max,c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;let l=t,u="";const h="number"==typeof t,d="string"==typeof t,f=Array.isArray(t);if(h?u="number":d?u="string":f&&(u="array"),!u)return!1;f&&(l=t.length),d&&(l=t.replace(c,"_").length),o?l!==e.len&&n.push(nr(s.messages[u].len,e.fullField,e.len)):i&&!a&&l<e.min?n.push(nr(s.messages[u].min,e.fullField,e.min)):a&&!i&&l>e.max?n.push(nr(s.messages[u].max,e.fullField,e.max)):i&&a&&(l<e.min||l>e.max)&&n.push(nr(s.messages[u].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[gr]=Array.isArray(e[gr])?e[gr]:[],-1===e[gr].indexOf(t)&&n.push(nr(s.messages[gr],e.fullField,e[gr].join(", ")))},pattern:(e,t,r,n,s)=>{if(e.pattern)if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||n.push(nr(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(nr(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const mr=(e,t,r,n,s)=>{const o=e.type,i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t,o)&&!e.required)return r();yr.required(e,t,n,i,s,o),sr(t,o)||yr.type(e,t,n,i,s)}r(i)};var wr={string:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(sr(t,"string")&&!e.required)return r();yr.required(e,t,n,o,s,"string"),sr(t,"string")||(yr.type(e,t,n,o,s),yr.range(e,t,n,o,s),yr.pattern(e,t,n,o,s),!0===e.whitespace&&yr.whitespace(e,t,n,o,s))}r(o)},method:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&yr.type(e,t,n,o,s)}r(o)},number:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(""===t&&(t=void 0),sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&(yr.type(e,t,n,o,s),yr.range(e,t,n,o,s))}r(o)},boolean:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&yr.type(e,t,n,o,s)}r(o)},regexp:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),sr(t)||yr.type(e,t,n,o,s)}r(o)},integer:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&(yr.type(e,t,n,o,s),yr.range(e,t,n,o,s))}r(o)},float:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&(yr.type(e,t,n,o,s),yr.range(e,t,n,o,s))}r(o)},array:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(null==t&&!e.required)return r();yr.required(e,t,n,o,s,"array"),null!=t&&(yr.type(e,t,n,o,s),yr.range(e,t,n,o,s))}r(o)},object:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&yr.type(e,t,n,o,s)}r(o)},enum:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s),void 0!==t&&yr.enum(e,t,n,o,s)}r(o)},pattern:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t,"string")&&!e.required)return r();yr.required(e,t,n,o,s),sr(t,"string")||yr.pattern(e,t,n,o,s)}r(o)},date:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t,"date")&&!e.required)return r();if(yr.required(e,t,n,o,s),!sr(t,"date")){let r;r=t instanceof Date?t:new Date(t),yr.type(e,r,n,o,s),r&&yr.range(e,r.getTime(),n,o,s)}}r(o)},url:mr,hex:mr,email:mr,required:(e,t,r,n,s)=>{const o=[],i=Array.isArray(t)?"array":typeof t;yr.required(e,t,n,o,s,i),r(o)},any:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(sr(t)&&!e.required)return r();yr.required(e,t,n,o,s)}r(o)}};function br(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone(){const e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}const vr=br();class _r{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");wr[e]=t};static warning=tr;static messages=vr;static validators=wr;rules={};_messages=vr;constructor(e){this.define(e)}define(e){if(!e)throw new Error("Cannot configure a schema with no rules");if("object"!=typeof e||Array.isArray(e))throw new Error("Rules must be an object");this.rules={},Object.keys(e).forEach((t=>{const r=e[t];this.rules[t]=Array.isArray(r)?r:[r]}))}messages(e){return e&&(this._messages=lr(br(),e)),this._messages}validate(e,t={},r=(()=>{})){let n=e,s=t,o=r;if("function"==typeof s&&(o=s,s={}),!this.rules||0===Object.keys(this.rules).length)return o&&o(null,n),Promise.resolve(n);if(s.messages){let e=this.messages();e===vr&&(e=br()),lr(e,s.messages),s.messages=e}else s.messages=this.messages();const i={};(s.keys||Object.keys(this.rules)).forEach((t=>{const r=this.rules[t];let s=n[t];r.forEach((r=>{let o=r;"function"==typeof o.transform&&(n===e&&(n={...n}),s=n[t]=o.transform(s)),o="function"==typeof o?{validator:o}:{...o},o.validator=this.getValidationMethod(o),o.validator&&(o.field=t,o.fullField=o.fullField||t,o.type=this.getType(o),i[t]=i[t]||[],i[t].push({rule:o,value:s,source:n,field:t}))}))}));const a={};return ar(i,s,((e,t)=>{const r=e.rule;let o,i=!("object"!==r.type&&"array"!==r.type||"object"!=typeof r.fields&&"object"!=typeof r.defaultField);function c(e,t){return{...t,fullField:`${r.fullField}.${e}`,fullFields:r.fullFields?[...r.fullFields,e]:[e]}}function l(o=[]){let l=Array.isArray(o)?o:[o];!0===s.suppressWarning&&l.length&&_r.warning("async-validator:",l),l.length&&void 0!==r.message&&(l=[].concat(r.message));let u=l.map(cr(r,n));if(s.first&&u.length)return a[r.field]=1,t(u);if(i){if(r.required&&!e.value)return void 0!==r.message?u=[].concat(r.message).map(cr(r,n)):s.error&&(u=[s.error(r,nr(s.messages.required,r.field))]),t(u);let o={};r.defaultField&&Object.keys(e.value).map((e=>{o[e]=r.defaultField})),o={...o,...e.rule.fields};const i={};Object.keys(o).forEach((e=>{const t=o[e],r=Array.isArray(t)?t:[t];i[e]=r.map(c.bind(null,e))}));const a=new _r(i);a.messages(s.messages),e.rule.options&&(e.rule.options.messages=s.messages,e.rule.options.error=s.error),a.validate(e.value,e.rule.options||s,(e=>{const r=[];u&&u.length&&r.push(...u),e&&e.length&&r.push(...e),t(r.length?r:null)}))}else t(u)}if(i=i&&(r.required||!r.required&&e.value),r.field=e.field,r.asyncValidator)o=r.asyncValidator(r,e.value,l,e.source,s);else if(r.validator){try{o=r.validator(r,e.value,l,e.source,s)}catch(e){console.error?.(e),s.suppressValidatorError||setTimeout((()=>{throw e}),0),l(e.message)}!0===o?l():!1===o?l("function"==typeof r.message?r.message(r.fullField||r.field):r.message||`${r.fullField||r.field} fails`):o instanceof Array?l(o):o instanceof Error&&l(o.message)}o&&o.then&&o.then((()=>l()),(e=>l(e)))}),(e=>{!function(e){let t=[],r={};for(let r=0;r<e.length;r++)s=e[r],Array.isArray(s)?t=t.concat(...s):t.push(s);var s;t.length?(r=rr(t),o(t,r)):o(null,n)}(e)}),n)}getType(e){if(void 0===e.type&&e.pattern instanceof RegExp&&(e.type="pattern"),"function"!=typeof e.validator&&e.type&&!wr.hasOwnProperty(e.type))throw new Error(nr("Unknown rule type %s",e.type));return e.type||"string"}getValidationMethod(e){if("function"==typeof e.validator)return e.validator;const t=Object.keys(e),r=t.indexOf("message");return-1!==r&&t.splice(r,1),1===t.length&&"required"===t[0]?wr.required:wr[this.getType(e)]||void 0}}function xr(e){return new _r(e)}var kr={validateId:function(e){return!!e&&(!(e.length<6)&&!!/^[A-Za-z0-9_-]+$/.test(e))},validatePhone:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)},validator:xr,validate:function(e,t,r={},n=(()=>{})){return Se.run(xr(e).validate(t,r,n))},isChinese:function(e){return!!e&&!!/^[\u4E00-\u9FA5]+$/.test(e)},isNumber:function(e){return!!e&&!!/^[0-9]+$/.test(e)},isFloat:function(e){return!!e&&!!/^(\-|\+)?\d+(\.\d+)?$/.test(e)},isPhoneNumber:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)}};var Sr={pattern:{num:"0-9",zh:"一-龥",en:"A-Za-z"},regex:(e,t)=>new RegExp(e,t),entire:{chinese:/^[\u4E00-\u9FA5]+$/,real:/^(\-|\+)?\d+(\.\d+)?$/,cssReal:/^(\-|\+)?\d*(\.)?\d+$/,id:/^[A-Za-z0-9]+$/,yyyyMMdd:/^(\d{4})-?(\d{2})-?(\d{2})$/}};var $r={toUtf8:e=>{if(!e)return"";const t=e.replace(/\r\n/g,"\n");let r="";for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r+=String.fromCharCode(n):n>127&&n<2048?(r+=String.fromCharCode(n>>6|192),r+=String.fromCharCode(63&n|128)):(r+=String.fromCharCode(n>>12|224),r+=String.fromCharCode(n>>6&63|128),r+=String.fromCharCode(63&n|128))}return r},fromUtf8:e=>{let t="",r=0;if(!e)return"";let n=0,s=0,o=0;for(;r<e.length;)n=e.charCodeAt(r),n<128?(t+=String.fromCharCode(n),r++):n>191&&n<224?(s=e.charCodeAt(r+1),t+=String.fromCharCode((31&n)<<6|63&s),r+=2):(s=e.charCodeAt(r+1),o=e.charCodeAt(r+2),t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&o),r+=3);return t},toUtf8Bytes:e=>{if(!e)return new Uint8Array;const t=e.replace(/\r\n/g,"\n"),r=[];for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r.push(n):n<2048?(r.push(n>>6|192),r.push(63&n|128)):(r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128))}return new Uint8Array(r)},fromUtf8Bytes:e=>{let t="",r=0;if(!e||e.length<=0)return"";for(;r<e.length;){let n=e[r];if(n<128)t+=String.fromCharCode(n),r++;else if(n>191&&n<224){const s=e[r+1];t+=String.fromCharCode((31&n)<<6|63&s),r+=2}else{const s=e[r+1],o=e[r+2];t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&o),r+=3}}return t}};const Ar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var Cr={toBase64:(e="")=>{let t,r,n,s,o,i,a,c="",l=0;for(e=$r.toUtf8(e);l<e.length;)t=e.charCodeAt(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l++),s=t>>2,o=(3&t)<<4|r>>4,i=(15&r)<<2|n>>6,a=63&n,isNaN(r)?i=a=64:isNaN(n)&&(a=64),c=c+Ar.charAt(s)+Ar.charAt(o)+Ar.charAt(i)+Ar.charAt(a);return c},fromBase64:(e="")=>{let t,r,n,s,o,i,a,c="",l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=Ar.indexOf(e.charAt(l++)),o=Ar.indexOf(e.charAt(l++)),i=Ar.indexOf(e.charAt(l++)),a=Ar.indexOf(e.charAt(l++)),t=s<<2|o>>4,r=(15&o)<<4|i>>2,n=(3&i)<<6|a,c+=String.fromCharCode(t),64!=i&&(c+=String.fromCharCode(r)),64!=a&&(c+=String.fromCharCode(n));return c=$r.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,o,i,a,c="",l=0;if(!e||!X.isArrayLike(e)||!X.isUint8Array(e))return"";for(;l<e.length;)t=e[l++],r=e[l++],n=e[l++],s=t>>2,o=(3&t)<<4|r>>4,i=(15&r)<<2|n>>6,a=63&n,isNaN(r)?i=a=64:isNaN(n)&&(a=64),c=c+Ar.charAt(s)+Ar.charAt(o)+Ar.charAt(i)+Ar.charAt(a);return c},base64ToBytes:(e="")=>{let t,r,n,s,o,i,a,c=[],l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=Ar.indexOf(e.charAt(l++)),o=Ar.indexOf(e.charAt(l++)),i=Ar.indexOf(e.charAt(l++)),a=Ar.indexOf(e.charAt(l++)),t=s<<2|o>>4,r=(15&o)<<4|i>>2,n=(3&i)<<6|a,c.push(t),64!=i&&c.push(r),64!=a&&c.push(n);return new Uint8Array(c)}};const Or=e=>Cr.toBase64(e);var Er={encode:Or,decode:e=>Cr.fromBase64(e),encodeByOss:e=>Or(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var jr={...c,base64:Er,uuid:l,guid:(e,t=!1,r="")=>{const n=l(e||32);return t?m.now().format("yyyyMMddhhmmss")+r+n:n},getHexString:e=>{const t=c.keyChars;let r="";const n=t.length;for(let s=0;s<e;s++)r+=t.charAt(Math.floor(Math.random()*n));return r}};const qr=e=>{if(!e)return"";if(!Tt.isObject(e))return"";let t="";return Tt.forof(e,((e,r)=>{r&&(t+=`${Ct.kebabCase(e)}:${r};`)})),t},Pr=["display","position","top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","fontSize","textAlign","fontFamily","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius","background","backgroundImage","backgroundRepeat","backgroundSize","backgroundPosition","color","overflow","opacity","flexDirection","justifyContent","alignItems","flexWrap","alignContent","alignSelf","flex","flexBasis","flexFlow","flexShrink","pointerEvents"],Lr=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],Tr=(e,t="px")=>e&&t?"0"===e?e:kr.isFloat(e.toString())?`${e}${t}`:e:e;var Fr={stringify:qr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=Xt.parse(e,{sep:";",eq:":",uri:!1}),s={};return Tt.forof(n,((e,n)=>{if(!n)return;const o=t?r&&e.startsWith("_")?e:Ct.camelCase(e):e;kr.isFloat(n)||n.length>=2&&n.startsWith(".")&&kr.isNumber(n.substr(1))?s[o]=+n:s[o]=n})),s},fixValue:Tr,style:(e,t="px")=>{if(!e)return"";const r=Tt.copy(e,{fields:Pr});Tt.forof(r,((e,n)=>{(Lr.includes(e)||Lr.includes(Ct.camelCase(e)))&&(r[e]=Tr(n,t))}));return qr(r)},commonFields:Pr};const Mr=(e,t="",r=!1)=>{try{if(!e)return;const n=Xt.parseUrl(e),s=t||n.name;if(!t||!r||!n.origin||n.origin===window.location.origin)((e,t)=>{try{const r=document.createElement("a");r.style.display="none",r.href=e,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}catch(t){console.error(`[ddan] _downloadUrl ${e}`,t)}})(e,s);else{const t=n.params;t.t=Date.now();const r=`${n.url}?${Xt.stringify(t,{uri:!1})}`,o=new XMLHttpRequest;o.open("GET",r,!0),o.responseType="blob",o.onload=function(){Rr(o.response,s)},o.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},o.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},Rr=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;Mr(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},Dr=e=>{try{const t=document.createElement("textarea");document.body.appendChild(t),t.style.position="fixed",t.style.clip="rect(0 0 0 0)",t.style.top="10px",t.style.opacity="0",t.value=e??"",t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}catch(e){return console.error("[ddan] copyText",e),!1}},Br=(e,t="denied")=>new Promise((r=>{const n=navigator?.permissions;if(!n||!n.query)return r(t);const s={name:e};n.query(s).then((e=>r(e.state))).catch((()=>r(t)))})),Ur=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Ir={dataURLtoFile:(e,t)=>{let r=e.split(","),n=r[0].match(/:(.*?);/)[1],s=window.atob(r[1]),o=s.length,i=new Uint8Array(o);for(;o--;)i[o]=s.charCodeAt(o);return new File([i],t,{type:n})},dataURLtoBlob:e=>{let t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=window.atob(t[1]),s=n.length,o=new Uint8Array(s);for(;s--;)o[s]=n.charCodeAt(s);return new Blob([o],{type:r})},blobToFile:(e,t)=>(e.lastModifiedDate=new Date,e.name=t,e),readAsDataURL:(e,t)=>{var r=new FileReader;r.readAsDataURL(e),r.onloadend=function(e){t&&t(e.target?.result)}},downloadUrl:Mr,download:(e,t="")=>{e&&("string"!=typeof e?Rr(e,t):Mr(e,t))},downloadFile:Rr,downloadImage:e=>{try{if(!e)return;const t=e.match(/\/(\w+.\w+)$/)[1],r=new Image;r.onload=()=>{let e=document.createElement("canvas");e.width=r.width,e.height=r.height;let n=e.getContext("2d");n&&n.drawImage(r,0,0,r.width,r.height);let s=e.toDataURL();Mr(s,t)},r.src=e,r.setAttribute("crossOrigin","Anonymous")}catch(e){console.error("[ddan] downloadImage",e)}return Promise.resolve()},watermark:(e,{width:t=400,height:r=300,angle:n=0,fillStyle:s="rgba(0, 0, 0, 0.2)",font:o="16px Arial",textAlign:i="left",textBaseline:a="middle"}={})=>{try{if(!e)return"";const c=document.createElement("canvas");c.width=t,c.height=r;const l=c.getContext("2d");return l?(n&&l.rotate(n*Math.PI/180),s&&(l.fillStyle=s),o&&(l.font=o),i&&(l.textAlign=i),a&&(l.textBaseline=a),l.fillText(e,c.width/10,c.height/2),`url(${c.toDataURL()})`):""}catch(e){return console.error("[ddan] watermark",e),""}},copyText:(e,t=!1)=>new Promise((r=>{!t&&navigator.clipboard?Br("clipboard-write").then((t=>{Ur(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(Dr(e)))):r(Dr(e))})).catch((()=>{r(Dr(e))})):r(Dr(e))})),queryPermission:Br,isAllowed:Ur,legacyCopy:Dr};var zr={ossImage:(e,t={})=>{if(!e)return e;const r=Xt.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=Mt.toList(t.domain||""),n=e.match(/^http[s]?:\/\/([\w.]+)[\w\W]+/)[1]||"";if(!n||!r.includes(n))return e}const n=[];return t.webp&&!r.endsWith(".gif")&&n.push("format,webp"),t.resize&&n.push(`resize,s_${t.resize}`),t.interlace&&(n.push("interlace,1"),!n.every((e=>!e.startsWith("format")))||r.endsWith(".gif")||r.endsWith(".jpg")||n.push("format,jpg")),n.length<=0?e:`${r}?x-oss-process=image/${n.join("/")}`},ossSnapshot:(e,t={})=>{if(!e)return e;const r=Xt.parseUrl(e).url,n=["snapshot"],{m:s="fast",f:o="jpg"}=t;return(t.t||0===t.t)&&n.push(`t_${t.t}`),t.w&&n.push(`w_${t.w}`),t.h&&n.push(`h_${t.h}`),s&&n.push(`m_${s}`),o&&n.push(`f_${o}`),t.ar&&n.push(`ar_${t.ar}`),`${r}?x-oss-process=video/${n.join(",")}`},ossBase64:e=>Cr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Kr={...$r,...Cr,str2Hex:e=>{let t="";for(let r=0;r<e.length;r++)t+=e.charCodeAt(r).toString(16).padStart(2,"0");return t},hex2Str:e=>{let t="";for(let r=0;r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},str2ab:(e="",t=!1)=>{if(t)return Cr.base64ToBytes(e).buffer;{const t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0,n=e.length;t<n;t++)r[t]=e.charCodeAt(t);return t}},ab2str:(e,t=!1)=>{const r=new Uint8Array(e);return t?Cr.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!X.isArrayLike(e))return"";return e.reduce(((e,t)=>e+String.fromCharCode(t)),"")},strToBytes:(e="")=>{const t=e,r=new Uint8Array(t.length);for(let e=0,n=t.length;e<n;e++)r[e]=t.charCodeAt(e);return r},utf8ToBase64:e=>X.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>X.isBrowser?atob(e):Buffer.from(e,"base64").toString("utf-8"),getRandomBytes:e=>{const t=new Uint8Array(e);for(let r=0;r<e;r++)t[r]=Oe.random(256);return t},textEncode:e=>$r.toUtf8Bytes(e),textDecode:e=>$r.fromUtf8Bytes(new Uint8Array(e))};const Nr=({url:e,options:t})=>{const r={"Content-Type":"application/json; charset=utf-8",...t.headers||{}};return t.headers=r,new Promise(((r,n)=>{fetch(e,t).then((e=>{r(e.json())})).catch((e=>{n(e)}))}))};function Hr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Vr(e){const{url:t="",host:r,options:n}=e,s=e;if(t.startsWith("http://")||t.startsWith("https://")||(s.url=(r||"")+t),"GET"===n.method.toUpperCase()&&n.body){const e=JSON.parse(n.body);if(Tt.isPlainObject(e)){const r=Xt.stringify(e),n=-1===t.indexOf("?")?"?":"&";s.url=`${s.url||""}${n}${r}`,delete s.options.body}}return n&&n.plugins&&delete s.options?.plugins,n&&n.model&&delete s.options?.model,s}class Wr{host="";reqConfig={};handleError;interceptors={request:new zt,response:new zt};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Vr),this.interceptors.response.use(e.handleResponse||Hr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Wr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Wr.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}async fetch(e,t){const r=Tt.copy(this.reqConfig[e])||{},n={host:this.host,url:r.url||"",options:{...r||{},body:JSON.stringify({...t||{}})}};try{const s=await this.interceptors.request.invoke(n);let o;if(delete s.options.plugins,"block"===r.model)this.lockR(Wr.blockId,(()=>Nr(s))),o=await Wr.requestLock[Wr.blockId].request;else if(Wr.requestLock[Wr.blockId]&&Wr.requestLock[Wr.blockId].lock&&await Wr.requestLock[Wr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Wr.requestLock[e]||this.lockR(e,(()=>Nr(s))),o=await Wr.requestLock[e].request,this.unlockR(e)}else o=await Nr(s);return this.interceptors.response.invoke({response:o,config:r,refetch:()=>({sig:"REFETCH",result:this.fetch(e,t)})})}catch(e){return this.handleError&&this.handleError(e),Promise.reject(e)}}}const Zr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},Gr=e=>(...t)=>{const r=console[e];Zr.overrode?r(...t):Jr(r,e,...t)},Jr=(e,t,...r)=>{const n=m.format(new Date,Zr.format),s=Zr.tag?`[${t}]`:"";s&&n?e.apply(console,[`${n} ${s}`,...r]):n?e.apply(console,[`${n}`,...r]):s?e.apply(console,[`${s}`,...r]):e.apply(console,[...r])};var Yr={override:()=>{if(Zr.overrode)return;Zr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{Jr(t,e,...r)}}))},log:Gr("log"),info:Gr("info"),warn:Gr("warn"),error:Gr("error"),config:({tag:e=Zr.tag,format:t=Zr.format}={})=>{Zr.tag=e,Zr.format=t}};var Qr={getDataURL:e=>{const t={contentType:"",dataUrl:""};return we.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Kr.ab2str(e,!0),t))))},getArrayBuffer:async e=>we.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>we.to(fetch(e).then((e=>e.json()))),download:(e,t={})=>new Promise((r=>fetch(e).then((async e=>{if(!e.ok||200!==e.status)throw new Error(e.statusText);const n=+(e.headers.get("content-length")||""),s=e.body?.getReader();let o=0;const i=[];for(;;){const{done:e,value:r}=await s.read();if(e)break;i.push(r),o+=r.length;const a=Oe.float(100*o/n,{digits:2});t?.progress&&t?.progress(a,o,n)}const a=new Uint8Array(o);let c=0;for(const e of i)a.set(e,c),c+=e.length;t?.success&&t?.success(a),r(a)})).catch((e=>{t?.fail&&t?.fail(e),r(void 0)}))))};const Xr=new class{__defStyle="vertical-align: middle; mask-position: 50% 50%; mask-repeat: no-repeat; mask-size: 100%; -webkit-mask-position: 50% 50%; -webkit-mask-repeat: no-repeat; -webkit-mask-size: 100%; background-color: currentColor;";__map={back:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M609.408 149.376L277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"/></svg>',right:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"/></svg>',home:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13 19.8h3.8v-7h3.303L12 4.697 3.897 12.8H7.2v7H11V17h2v2.8zm5 .2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-6H3.414a1 1 0 0 1-.707-1.707l8.586-8.586a1 1 0 0 1 1.414 0l8.586 8.586A1 1 0 0 1 20.586 14H18v6z" fill-rule="evenodd" fill-opacity=".9"/></svg>',close:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M764.288 214.592L512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"/></svg>',close_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M466.752 512l-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',close_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"/></svg>',warning:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M928.99 755.83L574.6 203.25c-12.89-20.16-36.76-32.58-62.6-32.58s-49.71 12.43-62.6 32.58L95.01 755.83c-12.91 20.12-12.9 44.91.01 65.03 12.92 20.12 36.78 32.51 62.59 32.49h708.78c25.82.01 49.68-12.37 62.59-32.49 12.91-20.12 12.92-44.91.01-65.03zM554.67 768h-85.33v-85.33h85.33V768zm0-426.67v298.66h-85.33V341.32l85.33.01z" fill="currentColor"/></svg>',play:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024A512 512 0 1 1 512 0a512 512 0 0 1 0 1024zm3.008-92.992a416 416 0 1 0 0-832 416 416 0 0 0 0 832zM383.232 287.616l384 224.896-384 223.104v-448z" fill="currentColor"/></svg>',lock:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M224 448a32 32 0 0 0-32 32v384a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V480a32 32 0 0 0-32-32H224zm0-64h576a96 96 0 0 1 96 96v384a96 96 0 0 1-96 96H224a96 96 0 0 1-96-96V480a96 96 0 0 1 96-96z"/><path fill="currentColor" d="M512 544a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V576a32 32 0 0 1 32-32zm192-160v-64a192 192 0 1 0-384 0v64h384zM512 64a256 256 0 0 1 256 256v128H256V320A256 256 0 0 1 512 64z"/></svg>',lock_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M467.2 713.92v115.968a44.8 44.8 0 0 0 89.6 0V713.92c26.752-14.72 44.8-42.304 44.8-73.92 0-47.104-40.128-85.312-89.6-85.312-49.472 0-89.6 38.208-89.6 85.312 0 31.616 18.048 59.136 44.8 73.92zM64 384h896v640H64V384zm268.8 0h358.4V256c0-94.272-80.256-170.688-179.2-170.688-98.944 0-179.2 76.416-179.2 170.688v128zM512 0c148.48 0 268.8 114.56 268.8 256v128H243.2V256C243.2 114.56 363.52 0 512 0z" fill="currentColor"/></svg>',plus:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"/></svg>',plus_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M352 480h320a32 32 0 1 1 0 64H352a32 32 0 0 1 0-64z"/><path fill="currentColor" d="M480 672V352a32 32 0 1 1 64 0v320a32 32 0 0 1-64 0z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',plus_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-38.4 409.6H326.4a38.4 38.4 0 1 0 0 76.8h147.2v147.2a38.4 38.4 0 0 0 76.8 0V550.4h147.2a38.4 38.4 0 0 0 0-76.8H550.4V326.4a38.4 38.4 0 1 0-76.8 0v147.2z"/></svg>',star:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 747.84l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72L512 747.84zM313.6 924.48a70.4 70.4 0 0 1-102.144-74.24l37.888-220.928L88.96 472.96A70.4 70.4 0 0 1 128 352.896l221.76-32.256 99.2-200.96a70.4 70.4 0 0 1 126.208 0l99.2 200.96 221.824 32.256a70.4 70.4 0 0 1 39.04 120.064L774.72 629.376l37.888 220.928a70.4 70.4 0 0 1-102.144 74.24L512 820.096l-198.4 104.32z"/></svg>',star_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M283.84 867.84L512 747.776l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72z"/></svg>',share:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M679.872 348.8l-301.76 188.608a127.808 127.808 0 0 1 5.12 52.16l279.936 104.96a128 128 0 1 1-22.464 59.904l-279.872-104.96a128 128 0 1 1-16.64-166.272l301.696-188.608a128 128 0 1 1 33.92 54.272z"/></svg>',love:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M171.712 571.648l.352.32 287.904 252.8a64 64 0 0 0 82.912 1.344l296.832-244.544a215.584 215.584 0 1 0-301.824-300.576L512 316.672l-25.888-35.616a215.584 215.584 0 1 0-314.4 290.624zM32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512l-295.36 243.392a128 128 0 0 1-165.888-2.592L129.984 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>',love_fill:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952L130.016 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>'};getBase64=e=>{const t=this.getSVG(e);return t?.url||""};getSVG=e=>{if(!e)return;const t=this.__map[e];if(!t)return;return{url:this.toBase64(t),escape:this.toEscape(t)}};toBase64=e=>{if(!e)return"";const t=this._tiny(e);return`data:image/svg+xml;base64,${Er.encode(t)}`};_tiny=e=>e?e.replace(/<!--(.*)-->/g,"").replace(/[\r\n]/g," ").replace(/"/g,"'"):"";toEscape=e=>{if(!e)return"";return`data:image/svg+xml,${this._tiny(e).replace(/%/g,"%25").replace(/&/g,"%26").replace(/#/g,"%23").replace(/{/g,"%7B").replace(/}/g,"%7D").replace(/</g,"%3C").replace(/>/g,"%3E")}`};getStyle(e,t={}){if(!e)return"";const r=this.__map[e];return r?this.toStyle(r,t):""}toStyle(e,t={}){if(!e)return"";const r=this.toBase64(e);return r?this.getStyleByUrl(r,t):""}getStyleByUrl(e,t={}){if(!e)return"";const{key:r="mask-image",gradientValue:n="radial-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",gradient:s=!1,defStyle:o=this.__defStyle}=t,i=s&&n?`${n}, url("${e}")`:`url("${e}")`;return`${r}:${i};-webkit-${r}:${i};${o}`}},en=(e,t,r)=>({key:e,fields:t,storage:r});class tn{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=Se.debounce((e=>{if(this.key&&this.storage)try{const{setItem:t,setStorageSync:r}=this.storage;if(r)return r(this.key,e);if(t)return t(this.key,JSON.stringify(e))}catch(e){console.error("persit save ",e)}}));read(){if(this.key&&this.storage)try{const{getItem:e,getStorageSync:t}=this.storage;if(t)return t(this.key);if(e){const t=e(this.key);return JSON.parse(t)}}catch(e){return void console.error("persit read ",e)}}handleSave(e,t){if(!this.fields.includes(t)||!e)return;const r=Lt.copy(e,{fields:this.fields});this.save(r)}}class rn extends u{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!X.isFunction(n))return;const[,s]=await Se.run(n({...r,commit:r.commit.bind(r),query:r.query.bind(r),dispatch:r.dispatch.bind(r)},t));return s}async query(e){const t=Reflect.get(this,e);let r;if(null!=t&&""!==t)r=Lt.copy(t);else{const[,t]=await Se.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){X.isObject(t)&&(t=Lt.copy(t)),this[e]=t}}const nn=(e,t)=>{const r=Object.assign(new rn,e||{});r.__persist=new tn(t||r.persist);const n=r.__persist.read(),s=n?Object.assign(r,n):r;return new Proxy(s,{get:(e,t,r)=>{const n=Reflect.get(e.getters,t);return X.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(X.isFunction(s)&&!s(e,r))return!0;const o=Reflect.set(e,t,r,n);return o&&(e.emit(t.toString(),r),e?.__persist?.handleSave(e,t.toString())),o},has:(e,t)=>Reflect.has(e,t)})};class sn{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=Xt.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const o=Xt.stringify(s,{uri:!1});this.list.push(`${e}?${o}`)}_parseHost(e){e&&!this.host&&/^http[s]?:\/\/([\w.]+)/.test(e)&&(this.host=e.replace(/^http[s]?:\/\/([\w.]+)[\w\W]+/,"$1"))}image(e,t={}){if(!e||!e.includes(this.host))return;if(this.list.length<=0)return;const r={g:"nw",...t},n=e.replace(/^http[s]?:\/\/[\w.]+\/([\w-.,_/?%&=]+)$/,"$1"),s=jr.base64.encodeByOss(n),o=Xt.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${o}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=jr.base64.encodeByOss(e),o=Xt.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${o}`)}result(){return this.list.join("")}}const on=(e,t)=>new sn(e,t);class an{__list=[];constructor(){this.clear()}add(e){const t=Se.run(e);return this.__list.push(t),this}clear(){return this.__list=[],this}wait(){const e=this.__list;return this.clear(),Promise.allSettled(e)}}const cn=new class{state=nn(new rn);frame=new h;cache=new Map;cacheTime=new Map;setCache=(e,t)=>null!=t&&(!!e&&(this.cache.set(e,t),this.cacheTime.set(e,Date.now()),!0));hasCache=e=>{if(!e)return!1;this.cache.has(e)};getCache=e=>{if(e)return this.cache.get(e)};getCacheTime=e=>e&&this.cacheTime.get(e)||0;removeCache=e=>{e&&(this.cache.delete(e),this.cacheTime.delete(e))};cacheId=e=>`_${e}_cache_`;timesRecord=(e,t={})=>{if(!e)return;const{mode:r="running",cycle:n="day"}=t||{},s=this.cacheId(r),o=this.getCache(s)||{},i=Date.now(),a=o[e],c={time:i,count:1,cycle:n};return a&&("day"!==n||m.isToday(a.time||0))&&(c.count=1+(a.count||0)),o[e]=c,this.setCache(s,o),o};timesValid=(e,t={})=>{if(!e)return!1;const{max:r=1,interval:n=0,mode:s="running",cycle:o="day"}=t||{},i=this.cacheId(s);let a=this.getCache(i);if(!a)return!0;const c=a[e];if(!c)return!0;if("day"===o&&!m.isToday(c.time||0))return!0;if(r<=(c.count||0))return!1;return!(Date.now()-(c.time||0)<n)};timesClean=(e="running")=>{const t=this.cacheId(e),r=this.getCache(t);if(!r)return;const n=Tt.copy(r);Tt.forof(n,((e,t)=>{"day"!==t.cycle&&void 0!==t.cycle||m.isToday(t.time||0)||delete r[e]})),this.setCache(t,r)};parallel=()=>new an};class ln{id="";start=0;end=0;cost=0;name="";type="";desc="";timeStartDesc="";timeEndDesc="";isDone=!1;flag=0;constructor(){this.id=l(),this.start=Date.now(),this.timeStartDesc=m.format(this.start,"hh:mm:ss.SSS")}get time(){return this.flag?this.end:this.start}get timeDesc(){return this.flag?this.timeEndDesc:this.timeStartDesc}done=(e=Date.now())=>{this.start&&(this.end=e,this.cost=this.end-this.start,this.timeEndDesc=m.format(this.end,"hh:mm:ss.SSS"),this.isDone=!0)}}const un=new class{__map=new Map;__trackList=[];opened=!0;clear(){return this.__map.clear(),this.__trackList=[],this}add(e,{desc:t="",type:r=""}={}){if(!e||!this.opened)return"";const n=new ln;return n.name=e,n.type=r,n.desc=t,this.__trackList.push(n),n.id}done(e){if(!e||!this.opened)return;const t=this.__trackList.find((t=>t.id===e));if(!t||t.isDone)return;t.done();const r=Lt.cloneClass(t);r.id=this._endId(e),r.flag=1,r.desc=`${t.desc} | end`,this.__trackList.push(r)}getTrack(e){return this.__trackList.find((t=>t.id===e))}getLine(e){if(!e||e.endsWith("-end"))return[];const t=this.__trackList.findIndex((t=>t.id===e));if(t<0)return[];const r=this._endId(e),n=this.__trackList.findIndex((e=>e.id===r)),s=n<0?this.__trackList.length-t:n-t+1;return Mt.take(this.__trackList,s,t)}getList(e,t=""){if(!e)return[];const r=this.__trackList.filter((t=>t.name===e));if(r.length<=0)return[];if(!t)return r;const n=this._endId(t);return this.__trackList.filter((e=>e.id===t||e.id===n))}get list(){return this.__trackList}get size(){return this.__trackList.length}_endId=e=>`${e}-end`;report(e){const t=this.list;if(!t||t.length<=0)return;const r=t[0].time;t.forEach((t=>e&&e(t,r)))}},hn=e=>{try{const t=Kr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},dn=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var fn={generateKeys:async()=>{try{const e=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),t=await window.crypto.subtle.exportKey("spki",e.publicKey),r=hn(t),n=dn(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),o=hn(s);return{publicKey:r,publicKeyPem:n,privateKey:o,privateKeyPem:dn(o,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:dn,format_pem_content:hn,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Kr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Kr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Kr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Kr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["decrypt"]),s=await window.crypto.subtle.decrypt({name:"RSA-OAEP"},n,r);return(new TextDecoder).decode(s)}catch(e){return console.error("decrypt failed:",e),""}}};var pn={brotliCompress:function(t,r=e.constants.BROTLI_DEFAULT_QUALITY){try{if(!t)return"";const n=Buffer.from(t,"utf-8");return e.brotliCompressSync(n,{params:{[e.constants.BROTLI_PARAM_QUALITY]:r}}).toString("base64")}catch(e){return t||""}},brotliDecompress:function(t){try{if(!t)return"";const r=Buffer.from(t,"base64");return e.brotliDecompressSync(r).toString("utf-8")}catch(e){return t||""}}};const gn=t?.webcrypto?.subtle;var yn={...pn,Ecdh:class{publicKey="";privateKey="";sharedSecret;iv;_curve;_algorithm;_ecdh;constructor(e="prime256v1",t="aes-256-gcm"){this._curve=e,this._algorithm=t,this.generateKey()}generateKey(){const e=t.createECDH(this._curve);e.generateKeys(),this.publicKey=e.getPublicKey("base64"),this.privateKey=e.getPrivateKey("base64"),this._ecdh=e}deriveSharedSecret(e,t){if(e)return this.sharedSecret=this._ecdh.computeSecret(e,"base64").toString("base64"),this.iv=t,this}encode(e){if(!this.sharedSecret||!this.iv)return{text:"",authTag:"",iv:""};const r=t.createCipheriv("aes-256-gcm",Kr.base64ToBytes(this.sharedSecret),Kr.base64ToBytes(this.iv));return{text:r.update(e,"utf8","base64")+r.final("base64"),authTag:r.getAuthTag().toString("base64"),iv:this.iv}}decode(e,r,n){if(!(e&&this.sharedSecret&&n&&r))return"";const s=t.createDecipheriv("aes-256-gcm",Kr.base64ToBytes(this.sharedSecret),Kr.base64ToBytes(n));s.setAuthTag(Kr.base64ToBytes(r));return s.update(e,"base64","utf8")+s.final("utf8")}},EcdhSpki:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await gn.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await gn.exportKey("spki",e);return Kr.ab2str(t,!0)}async importSpkiKey(e){const t=Kr.base64ToBytes(e);return await gn.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await gn.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Kr.textEncode(e),r=await gn.encrypt({name:"AES-GCM",iv:Kr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Kr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Kr.str2ab(e,!0),n=await gn.decrypt({name:"AES-GCM",iv:Kr.base64ToBytes(t)},this.__sharedSecret,r);return Kr.textDecode(n)}},Socks5:class{upstreamProxy;server=null;clientSockets=new Set;allowedDomains;connectionPool={};systemProxy=null;useSystemProxy=!1;__debug=!1;__uuid;constructor(e,t=[],r=!1){this.upstreamProxy=e,this.allowedDomains=new Set(t),this.__debug=r,this.__uuid=l()}get id(){return this.__uuid}validateProxyConfig(e=this.upstreamProxy){const{ipaddress:t,port:r,userId:n,password:s}=e||{};return t&&"string"==typeof t?r&&"number"==typeof r?n&&"string"==typeof n?s&&"string"==typeof s?"":"无效的上游代理密码":"无效的上游代理用户名":"无效的上游代理端口":"无效的上游代理 IP 地址"}async start(e=9968){if(this.validateProxyConfig())return 0;if(this.server)return console.log("[socks] server is already running"),0;const t=await this.findAvailablePort(e);return t?(this.server=r.createServer((e=>this.handleSocksConnection(e))),this.server.listen(t,(()=>{this.__debug&&console.log(`[socks] server is running on port ${t}`)})),this.server.on("error",(e=>{console.error("[socks] server error:",e),this.close()})),t):t}setUpstreamProxy(e){return!!e&&(!this.validateProxyConfig(e)&&(this.upstreamProxy=e,!0))}setSystemProxy(e,t){this.useSystemProxy=e,e&&t&&t.ipaddress&&t.port&&(this.systemProxy=t)}setAllowedDomains(e=[]){this.allowedDomains=new Set(e)}async findAvailablePort(e,t=200){let n=e,s=0;for(;s<t;)try{return await new Promise(((e,t)=>{const s=r.createServer();s.unref(),s.on("error",t),s.listen(n,(()=>{s.close((()=>e()))}))})),n}catch{s++,n++}return console.warn("[socks] findAvailablePort failed"),0}async handleSocksConnection(e){this.clientSockets.add(e),e.on("close",(()=>{this.clientSockets.delete(e),e?.destroy()}));try{await this.performHandshake(e);const t=await this.parseClientRequest(e);if(this.isAllowedDomain(t.addr)){this.__debug&&console.log("[socks] handle connection upstream",t.addr);const r=await this.connectToUpstreamProxy(t);this.setupDataForwarding(e,r)}else if(this.useSystemProxy&&this.systemProxy){this.__debug&&console.log("[socks] handle connection system",t.addr);const r=await this.connectToSystemProxy(t);this.setupDataForwarding(e,r)}else{this.__debug&&console.log("[socks] handle connection local",t.addr);const r=await this.connectToLocal(t);this.setupDataForwarding(e,r)}}catch(t){console.error("[socks] connection failed:",t),e.end(new Uint8Array([5,1]))}}performHandshake(e){return new Promise(((t,r)=>{e.once("data",(n=>{if(5!==n[0])return r(new Error("Unsupported SOCKS version"));e.write(new Uint8Array([5,0])),t()}))}))}parseClientRequest(e){return new Promise(((t,r)=>{e.once("data",(e=>{let n,s;if(1!==e[1])return r(new Error("Unsupported command"));if(1===e[3])n=e.slice(4,8).join("."),s=e.readUInt16BE(8);else{if(3!==e[3])return r(new Error("Unsupported address type"));{const t=e[4];n=e.slice(5,5+t).toString(),s=e.readUInt16BE(5+t)}}t({addr:n,port:s})}))}))}getPoolConnection(e){if(e)return this.connectionPool[e]&&!this.connectionPool[e].destroyed?this.connectionPool[e]:void 0}async connectToUpstreamProxy(e){const t=`${e.addr}:${e.port}`,r=this.getPoolConnection(t);if(r)return r;const s={proxy:{...this.upstreamProxy,type:5},command:"connect",destination:{host:e.addr,port:e.port}};try{const{socket:e}=await n.createConnection(s);return this.connectionPool[t]=e,e.on("close",(()=>{delete this.connectionPool[t]})),e}catch(e){throw new Error("Failed to connect to upstream proxy: "+e)}}async connectToSystemProxy(e){const t=`${e.addr}:${e.port}`,r=this.getPoolConnection(t);if(r)return r;const s={proxy:{...this.systemProxy,type:5},command:"connect",destination:{host:e.addr,port:e.port}};try{const{socket:e}=await n.createConnection(s);return this.connectionPool[t]=e,e.on("close",(()=>{delete this.connectionPool[t]})),e}catch(e){throw new Error("Failed to connect to upstream proxy: "+e)}}async connectToLocal(e){const t=`${e.addr}:${e.port}`,n=this.getPoolConnection(t);return n||new Promise(((t,n)=>{const s=r.createConnection(e.port,e.addr,(()=>{t(s)}));s.on("error",(e=>{n(e)}))}))}setupDataForwarding(e,t){e.write(new Uint8Array([5,0,0,1,0,0,0,0,0,0])),e.pipe(t),t.pipe(e),e.on("close",(()=>{this.__debug&&console.error("[socks] client socket close",t?.remoteAddress),t.end()})),t.on("close",(()=>{this.__debug&&console.error("[socks] target socket close",t?.remoteAddress),e.end()})),e.on("error",(e=>{this.__debug&&console.error("[socks] client socket error:",e),t.end()})),t.on("error",(t=>{this.__debug&&console.error("[socks] target socket error:",t),e.end()}))}isAllowedDomain(e){for(const t of this.allowedDomains){if("*"===t)return!0;if(e.includes(t))return!0}return!1}close(){this.server&&(console.log("[socks] closing SOCKS5 proxy server..."),this.server.close((e=>{e&&console.error("[socks] closing the server failed:",e)})),this.clientSockets.forEach((e=>e.destroy())),Object.values(this.connectionPool).forEach((e=>e.destroy())),this.server=null)}}};var mn={Ecdh:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await window.crypto.subtle.exportKey("spki",e);return Kr.ab2str(t,!0)}async importSpkiKey(e){const t=Kr.base64ToBytes(e);return await window.crypto.subtle.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await window.crypto.subtle.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Kr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Kr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Kr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Kr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Kr.base64ToBytes(t)},this.__sharedSecret,r);return Kr.textDecode(n)}}};const wn={gbk:s,math:Oe,list:Mt,string:Ct,time:m,obj:Lt,rule:kr,regex:Sr,...Kr,...jr,...Tt,Event:u},bn={...Kr,...jr,...Se},vn={mini:Ht,css:Fr,qs:Xt,icon:Xr,html:Ir},_n={cdn:zr,watermark:on},xn={Store:rn,storeRef:nn,Persist:tn,persistConfig:en},kn=cn,Sn=un,$n=Yr,An={fetch:Qr,Http:Wr,css:Fr,qs:Xt,icon:Xr,html:Ir,rsa:fn,...mn},Cn={...yn};var On={gbk:s,time:m,hook:Se,math:Oe,util:Tt,list:Mt,string:Ct,obj:Lt,crypto:jr,mini:Ht,qs:Xt,css:Fr,cdn:zr,html:Ir,icon:Xr,rule:kr,regex:Sr,convert:Kr,Event:u,Http:Wr,Store:rn,storeRef:nn,Persist:tn,persistConfig:en,watermark:on,joker:cn,tracker:un,logger:Yr,fetch:Qr,rsa:fn};export{_n as dCdn,bn as dHook,kn as dJoker,$n as dLogger,vn as dMini,Cn as dNode,xn as dStore,Sn as dTracker,wn as dUtil,An as dWeb,On as default};
package/bin/ddan-js.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("zlib"),require("node:crypto"),require("net"),require("socks")):"function"==typeof define&&define.amd?define(["exports","zlib","node:crypto","net","socks"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ddan={},e.zlib,e.crypto$1,e.net,e.socks)}(this,(function(e,t,r,n,s){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(t),a=i(r),c=i(n);var l={gbkLength:function(e){let t=0;if(!e)return 0;for(let r=0;r<e.length;r++)e.charCodeAt(r)>127||94===e.charCodeAt(r)?t+=2:t++;return t},gbkCut:function(e,t){if(!e||t<=0)return"";let r=0,n=0;for(let s=0;s<e.length&&(e.charCodeAt(s)>127||94===e.charCodeAt(s)?r+=2:r++,!(r>t));s++)n=s;return e.substr(0,n+1)}};const u="0123456789",d="abcdefghijklmnopqrstuvwxyz",h="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var f={keyNumber:u,keyLower:d,keyUpper:h,keyChars:u+d+h};const p=(e=0,t=0)=>{const r=f.keyChars.split(""),n=[];let s;if(t=t||r.length,e)for(s=0;s<e;s++)n[s]=r[0|Math.random()*t];else{let e;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",s=0;s<36;s++)n[s]||(e=0|16*Math.random(),n[s]=r[19==s?3&e|8:e])}return n.join("")};class g{__map;__tagList;__eventId="";constructor(){this.__map=new Map,this.__tagList=[],this.__eventId=p()}clear(){return this.__map.clear(),this}on(e,t,r=""){if(!e||!t)return this;let n=this.__map.get(e);return n||(n=new Set,this.__map.set(e,n)),n.add(t),r&&this.__tagList.push({name:e,listener:t,tag:r}),this}emit(e,...t){if(!e)return this;const r=this.__map.get(e);if(!r)return this;return[...r].forEach((e=>e&&e(...t))),this}off(e,t){if(!e||!t)return this;this.__tagList=this.__tagList.filter((r=>r.name!==e||r.listener!==t));const r=this.__map.get(e);return r?(r.delete(t),r.size<=0&&this.__map.delete(e),this):this}remove(e){return e?(this.__tagList=this.__tagList.filter((t=>t.name!==e)),this.__map.delete(e),this):this}removeByTag(e){if(!e)return this;return this.__tagList.filter((t=>t.tag===e)).forEach((e=>{this.off(e.name,e.listener)})),this.__tagList=this.__tagList.filter((t=>t.tag!==e)),this}once(e,t){const r=(...n)=>{t(...n),this.off(e,r)};return this.on(e,r),this}has(e){return this.__map.has(e)}}class y{_loopTimer;_event=new g;started=!1;interval=0;constructor(e=0){this.interval=e||500}start(){return this.started||(this.stop(),this._loopTimer=setInterval((()=>{this._handleLoop()}),this.interval),this.started=!0),this}stop(){return this._loopTimer?(clearInterval(this._loopTimer),this._loopTimer=0,this.started=!1,this):this}restart(){return this.stop(),this.start(),this}on(e){return this._event.on("frame",e),this}off(e){return e?(this._event.off("frame",e),this):this}_handleLoop(){this._event.emit("frame")}}var m={oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};class w{date;timestamp=0;yyyy=0;yy="";M=0;MM="";d=0;dd="";h=0;hh="";m=0;mm="";s=0;ss="";S=0;SS="";SSS="";constructor(e){if(!e)return;const t="string"==typeof e||"number"==typeof e?new Date(e):e;t&&(this.date=t,this.timestamp=t.getTime(),this.toDate())}toDate(){return this.date?(this.yyyy=this.date.getFullYear(),this.yy=`${this.yyyy}`.substr(2),this.M=this.date.getMonth()+1,this.MM=(this.M<10?"0":"")+this.M,this.d=this.date.getDate(),this.dd=(this.d<10?"0":"")+this.d,this.h=this.date.getHours(),this.hh=(this.h<10?"0":"")+this.h,this.m=this.date.getMinutes(),this.mm=(this.m<10?"0":"")+this.m,this.s=this.date.getSeconds(),this.ss=(this.s<10?"0":"")+this.s,this.S=this.date.getMilliseconds(),this.SS=(this.S<10?"0":"")+this.S,this.SSS=this.S.toString().padStart(3,"0"),this):this}toCountdown(e=""){const t={countdown:0,timestamp:0,seconds:0,d:0,dd:"",h:0,hh:"",m:0,mm:"",s:0,ss:"",S:0,SS:"",SSS:"",desc:""};if(!this.timestamp)return t;t.timestamp=this.timestamp,t.countdown=Math.max(t.timestamp-Date.now(),0),t.seconds=Math.floor(t.countdown/m.oneSecond);let r=t.countdown;t.d=Math.floor(r/m.oneDay),t.dd=(t.d<10?"0":"")+t.d,r%=m.oneDay,t.h=Math.floor(r/m.oneHour),t.hh=(t.h<10?"0":"")+t.h,r%=m.oneHour,t.m=Math.floor(r/m.oneMinute),t.mm=(t.m<10?"0":"")+t.m,r%=m.oneMinute,t.s=Math.floor(r/m.oneSecond),t.ss=(t.s<10?"0":"")+t.s,r%=m.oneSecond,t.S=r,t.SS=(t.S<10?"0":"")+t.S,t.SSS=t.S.toString().padStart(3,"0");let n=e;return n||(n=t.countdown>m.oneHour?"hh:mm:ss":t.countdown>m.oneMinute?"mm:ss":"ss"),t.desc=n.replace(/\bdd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>t[e])),t}add(e=0){return e?(this.timestamp=this.timestamp+e,this.date=new Date(this.timestamp),this.toDate(),this):this}format(e="yyyy-MM-dd hh:mm:ss"){return e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>this[e]))}static get timezoneOffset(){return(new Date).getTimezoneOffset()/60}static getLocalTime(e=0){const t=new Date,r=t.getTime(),n=6e4*t.getTimezoneOffset();return new Date(r+n+36e5*e)}}const b=(e,t="yyyy-MM-dd hh:mm:ss")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;return r?v(r).format(t):""},v=e=>{const t="string"==typeof e||"number"==typeof e?new Date(e):e;return new w(t||0)};function _({year:e=0,month:t=0,date:r=0,hour:n=0,minute:s=0,second:i=0}){const o=`${e||"yyyy"}/${t||"MM"}/${r||"dd"} ${n}:${s}:${i}`;return new Date(b(Date.now(),o)).getTime()}var x={...m,now:function(){return v(new Date)},isToday:e=>e&&(new Date).toDateString()===new Date(e).toDateString(),parseTimestamp:_,todayZero:()=>_({}),format:b,countdown:(e,t="")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;if(!r)return"";return v(r).toCountdown(t)},dtime:v,loopFrame:(e=500)=>new y(e),getTimezoneOffset:()=>w.timezoneOffset,getLocalTime:w.getLocalTime};const k="object"==typeof global&&null!==global&&global.Object===Object&&global,S="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis,$="object"==typeof self&&null!==self&&self.Object===Object&&self,A=S||k||$||Function("return this")(),C=A.Symbol,{toString:O,hasOwnProperty:j,propertyIsEnumerable:E}=Object.prototype,q=C?C.toStringTag:void 0;function L(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":q&&q in Object(e)?function(e){const t=j.call(e,q),r=e[q];let n=!1;try{e[q]=void 0,n=!0}catch(e){}const s=O.call(e);return n&&(t?e[q]=r:delete e[q]),s}(e):O.call(e)}var P={getTag:L,getType:function(e){return(L(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:O,hasOwnProperty:j,propertyIsEnumerable:E};const T="object"==typeof e&&null!==e&&!e.nodeType&&e,F=T&&"object"==typeof module&&null!==module&&!module.nodeType&&module,M=F&&F.exports===T&&k.process,R=(()=>{try{const e=F&&F.require&&F.require("util").types;return e||M&&M.binding&&M.binding("util")}catch(e){}})();var B="[object Function]",D="[object GeneratorFunction]",U="[object AsyncFunction]",I=9007199254740991;const z=/^(?:0|[1-9]\d*)$/,N=A?.Buffer?.isBuffer,K=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,H=R&&R.isTypedArray;function V(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function W(e){return null!=e&&"object"==typeof e}const Z=Array.isArray;function G(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=I}(e.length)&&!Y(e)}function J(e){return W(e)&&G(e)}function Y(e){var t=V(e)?P.getTag(e):"";return t===B||t===D||t===U}function Q(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)}function X(e){return J(e)&&P.hasOwnProperty.call(e,"callee")&&(!P.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==P.toString.call(e))}const ee="undefined"!=typeof window&&void 0!==window.document,te="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,re=H?e=>H(e):e=>W(e)&&K.test(P.getTag(e)),ne="function"==typeof N?N:()=>!1;var se={is:function(e,t){return P.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===P.getTag(e)},isString:function(e){return"string"==typeof e||!Z(e)&&W(e)&&"[object String]"==P.getTag(e)},isObject:V,isObjectLike:W,isPlainObject:function(e){if(!W(e)||"[object Object]"!=P.getTag(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},isSymbol:function(e){return"symbol"==typeof e||W(e)&&"[object Symbol]"===P.getTag(e)},isFunction:Y,isArray:Z,isArrayLikeObject:J,isIndex:function(e,t){return!!(t=null==t?I:t)&&("number"==typeof e||z.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:G,isPrototype:Q,isArguments:X,isPromise:function(e){return"[object Promise]"===(V(e)?P.getTag(e):"")},isBrowser:ee,isNode:te,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer,isEmpty:e=>{if(null==e)return!0;if(G(e)&&(Array.isArray(e)||"string"==typeof e||"function"==typeof e.splice||ne(e)||re(e)||X(e)))return!e.length;const t=P.getTag(e);if("[object Map]"===t||"[object Set]"===t)return!e.size;if(Q(e))return!Object.keys(e).length;for(const t in e)if(P.hasOwnProperty.call(e,t))return!1;return!0}};const ie=NaN,oe=/^\s+|\s+$/g,ae=/^[-+]0x[0-9a-f]+$/i,ce=/^0b[01]+$/i,le=/^0o[0-7]+$/i,ue=parseInt,de=1/0,he=17976931348623157e292;function fe(e){if("number"==typeof e)return e;if(se.isSymbol(e))return ie;if(se.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=se.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(oe,"");const t=ce.test(e);return t||le.test(e)?ue(e.slice(2),t?2:8):ae.test(e)?ie:+e}function pe(e){return e?(e=fe(e))===de||e===-de?(e<0?-1:1)*he:e==e?e:0:0===e?e:0}var ge={toNumber:fe,toFinite:pe,toInteger:function(e){var t=pe(e),r=t%1;return t==t?r?t-r:t:0}};const ye="Expected a function",me=Math.max,we=Math.min;function be(e,t=300,r={}){let n,s,i,o,a,c,l=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError(ye);function f(t){const r=n,i=s;return n=s=void 0,l=t,o=e.apply(i,r),o}function p(e){const r=e-c;return void 0===c||r>=t||r<0||d&&e-l>=i}function g(){const e=Date.now();if(p(e))return y(e);a=setTimeout(g,function(e){const r=t-(e-c);return d?we(r,i-(e-l)):r}(e))}function y(e){return a=void 0,h&&n?f(e):(n=s=void 0,o)}function m(...e){const r=Date.now(),i=p(r);if(n=e,s=this,c=r,i){if(void 0===a)return function(e){return l=e,a=setTimeout(g,t),u?f(e):o}(c);if(d)return a=setTimeout(g,t),f(c)}return void 0===a&&(a=setTimeout(g,t)),o}return t=ge.toNumber(t)||0,se.isObject(r)&&(u=!!r.leading,d="maxWait"in r,i=d?me(ge.toNumber(r.maxWait)||0,t):i,h="trailing"in r?!!r.trailing:h),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=s=a=void 0},m.flush=function(){return void 0===a?o:y(Date.now())},m.pending=function(){return void 0!==a},m}class ve{__list=[];constructor(e){this.push(e)}push(e){return e&&this.__list.push(e),this}clear(){return this.__list=[],this}_exec(e,t){let r;if(se.isFunction(e))r=e(t);else{if(se.isPromise(e))return e.then((e=>({...t,...e})));r=e}return se.isPromise(r)?r:Promise.resolve({...r,...t})}run(e){try{return this.__list.reduce(((e,t)=>e.then((e=>this._exec(t,e)))),Promise.resolve(e)).then((e=>[void 0,e])).catch((e=>[e,void 0]))}catch(e){return Promise.reject([e,void 0])}}}async function _e(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const xe=e=>{try{let t;return t=se.isFunction(e)?e():e,_e(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var ke={to:_e,go:e=>xe(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:xe};class Se{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var $e={singleton:function(){class e{static __instance__;constructor(){}static get Instance(){return e.__instance__||(e.__instance__=new this),e.__instance__}static get I(){return this.Instance}}return e},getset:function(e){const t=new Se;return void 0!==e&&t.set(e),t}};class Ae{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return ke.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class Ce{__list=[];__count=0;__max=1;constructor(e=1){this.__count=0,this.__max=e>0?e:1,this.clear()}push(e,t){const r=new Ae(e,t);return this.__list.push(r),this._step(),this}clear(){return this.__list=[],this.__count=0,this}_step(){if(this.__list.length<=0)return;if(this.__count>=this.__max)return;const e=this.__list.shift();e?(this.__count+=1,e?.run().finally((()=>{try{this.__count>0&&(this.__count-=1),this._step()}catch(e){console.error("[ddan] pipepine step finally",e)}}))):this._step()}async whenAll(){for(;;){if(this.__count<=0)break;await ke.delay(100),this._step()}return this.clear()}}class Oe extends($e.singleton()){__lockedMap=new Map;pipeline=new Ce;constructor(){super()}lock(e,t){if(!e||!t)return;const r=ke.safeRun(t);return this.__lockedMap.set(e,r),r}unlock(e){e&&this.__lockedMap.has(e)&&this.__lockedMap.delete(e)}async exec(e,t){if(!e||!t)return ke.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return ke.safeRun(e);const s=await n;return this.unlock(t),s}}var je={...ke,sleep:ke.delay,run:async function(e,t=0){if(t<=0)return ke.safeRun(e);const r=t>0?Date.now():0,n=await ke.safeRun(e),s=Date.now()-r;return s<t&&await ke.delay(t-s),n},exec:(e,t="")=>Oe.I.exec(e,t),debounce:be,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return se.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),be(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new ve(e),mutex:function(e){var t=null;return async function(...r){if((t=this||t||{}).__ddMutex)return!1;t.__ddMutex=!0;try{e&&await Promise.resolve(e.apply(this,r))}catch(e){console.log(e)}finally{t.__ddMutex=!1}}},polling:async function(e={}){const{func:t,interval:r=100,times:n=1e3}=e;let s=n;const i=r<1?100:r;do{if(!t)break;const[e,r]=await ke.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await ke.delay(i)}while(-1===n||s>0)},pipe:(e,t)=>Oe.I.pipeline.push(e,t),pipeline:(e=1)=>new Ce(e),safeTask:(e,t)=>new Ae(e,t)};function Ee(e){return Math.floor(Math.random()*e)}function qe(e,t=10){return+parseFloat(Number(e).toExponential(t))}const Le=180/Math.PI;var Pe={random:Ee,randomRange:function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},lerp:function(e,t,r){return e*(1-r)+t*r},randoms:function(e,t=1,r=!1){const n=[];for(;;){if(n.length>=t)break;if(!r&&n.length>=e)break;const s=Ee(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:qe,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=qe(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*Le},degree2radian:function(e){return e/Le},formatMemory:function(e){let t=e;const r={g:0,m:0,kb:0,b:0,desc:""};return t>=1<<30&&(r.g=Math.floor(t/(1<<30)),t%=1<<30),t>=1<<20&&(r.m=Math.floor(t/(1<<20)),t%=1<<20),t>=1024&&(r.kb=Math.floor(t/1024),t%=1024),r.b=t,r.desc=e>=1<<30?(e/(1<<30)).toFixed(2)+"G":e>=1<<20?(e/(1<<20)).toFixed(2)+"M":e>=1024?(e/1024).toFixed(2)+"KB":e+"B",r}};function Te(e){return e!=e}function Fe(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,s=Array(n);++r<n;)s[r]=t(e[r],r,e);return s}(t,(function(t){return e[t]}))}var Me,Re,Be=(Me=Object.keys,Re=Object,function(e){return Me(Re(e))}),De=Math.max;function Ue(e,t){var r=se.isArray(e)||se.isArguments(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,s=!!n;for(var i in e)!t&&!P.hasOwnProperty.call(e,i)||s&&("length"==i||se.isIndex(i,n))||r.push(i);return r}function Ie(e,t,r){const{length:n}=e;return r=void 0===r?n:r,!t&&r>=n?e:function(e,t,r){let n=null==e?0:e.length;if(!n)return[];(t=null==t?0:t)<0&&(t=-t>n?0:n+t),(r=(r=void 0===r?n:r)>n?n:r)<0&&(r+=n),n=t>r?0:r-t>>>0,t>>>=0;let s=-1;const i=new Array(n);for(;++s<n;)i[s]=e[s+t];return i}(e,t,r)}const ze=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function Ne(e){return ze.test(e)}const Ke="\\ud800-\\udfff",He=`[${Ke}]`,Ve="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",We="\\ud83c[\\udffb-\\udfff]",Ze=`[^${Ke}]`,Ge="(?:\\ud83c[\\udde6-\\uddff]){2}",Je="[\\ud800-\\udbff][\\udc00-\\udfff]",Ye=`${`(?:${Ve}|${We})`}?`,Qe="[\\ufe0e\\ufe0f]?",Xe=Qe+Ye+`(?:\\u200d(?:${[Ze,Ge,Je].join("|")})${Qe+Ye})*`,et=`(?:${[`${Ze}${Ve}?`,Ve,Ge,Je,He].join("|")})`,tt=RegExp(`${We}(?=${We})|${et+Xe}`,"g");function rt(e){return Ne(e)?function(e){return e.match(tt)||[]}(e):function(e){return e.split("")}(e)}function nt(e){return t=>{if(!t)return"";const r=Ne(t)?rt(t):void 0,n=r?r[0]:t[0],s=r?Ie(r,1).join(""):t.slice(1);return n[e]()+s}}const st="\\ud800-\\udfff",it="\\u2700-\\u27bf",ot="a-z\\xdf-\\xf6\\xf8-\\xff",at="A-Z\\xc0-\\xd6\\xd8-\\xde",ct="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",lt="['’]",ut=`[${ct}]`,dt=`[${it}]`,ht=`[${ot}]`,ft=`[^${st}${ct+"\\d"+it+ot+at}]`,pt="(?:\\ud83c[\\udde6-\\uddff]){2}",gt="[\\ud800-\\udbff][\\udc00-\\udfff]",yt=`[${at}]`,mt=`(?:${ht}|${ft})`,wt=`(?:${yt}|${ft})`,bt=`(?:${lt}(?:d|ll|m|re|s|t|ve))?`,vt=`(?:${lt}(?:D|LL|M|RE|S|T|VE))?`,_t="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",xt="[\\ufe0e\\ufe0f]?",kt=xt+_t+`(?:\\u200d(?:${[`[^${st}]`,pt,gt].join("|")})${xt+_t})*`,St=`(?:${[dt,pt,gt].join("|")})${kt}`,$t=RegExp([`${yt}?${ht}+${bt}(?=${[ut,yt,"$"].join("|")})`,`${wt}+${vt}(?=${[ut,yt+mt,"$"].join("|")})`,`${yt}?${mt}+${bt}`,`${yt}+${vt}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",St].join("|"),"g");const At=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),Ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ot(e,t){if(void 0===t){const t=At(e)?function(e){return e.match($t)}(e):function(e){return e.match(Ct)}(e);return t||[]}return e.match(t)||[]}function jt(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:jt(e)))}`;if(se.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const Et=nt("toUpperCase"),qt=nt("toLowerCase");var Lt={toString:jt,startCase:e=>Ot(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+Et(t)),""),snakeCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?Et(t):t))),""),upperCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:Et,lowerCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:qt,splitOnFirst:(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===e||""===t)return[];const r=e.indexOf(t);return-1===r?[]:[e.slice(0,r),e.slice(r+t.length)]},parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{let n=e;return e&&"string"==typeof e?(t&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?n=Number(e):!r||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(n="true"===e.toLowerCase()),n):n},replace:(e,t)=>{if(!e)return e;if(!t)return e;let r=e;return((Array.isArray(t)?t:[t])||[]).forEach((e=>{e.key&&e.value&&(r=r.replace(new RegExp(e.key,e.flag||""),e.value))})),r}};const Pt=e=>{if(!e)return e;if("object"!=typeof e)return e;const t=Array.isArray(e)?[]:{};for(const r in e)e.hasOwnProperty(r)&&(t[r]=Pt(e[r]));return t};const Tt=(e,t,r={})=>{const n=e||{},{ignoreUndefined:s=!0,cover:i=!1}=r;if(!t)return n;for(const o in t){if(!t.hasOwnProperty(o))continue;const a=t[o];"object"!=typeof a||"object"!=typeof e[o]||i?s&&void 0===a||r.ignoreNull&&null===a||r.ignoreZero&&0===a||r.ignoreEmptyArray&&Array.isArray(a)&&a.length<=0||r.ignoreEmptyString&&"string"==typeof a&&""===a.trim()||(n[o]=a):n[o]=Ft(e[o],a,r)}return n},Ft=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?Tt(e,t,r):Tt({...e},t,r),n},Mt=(e,t,r={})=>Tt({...e},t,{cover:!0,...r}),Rt=(e,t,r,n,s=!1)=>{if(!e||!t||!r)return;let i=e[t];null!==i&&"object"==typeof i&&s&&Object.keys(i).forEach((e=>{Rt(i,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:o=>{r.call(n,o,i),i=o,s&&Rt(e,t,r,n,s)},get:()=>i})};var Bt={copy:(e,t={})=>{if(void 0===e)return;const r=JSON.parse(JSON.stringify(e));if("object"!=typeof r)return r;if(Array.isArray(r))return r;const{fields:n=[],camel:s=!1,pure:i=!0}=t;if((!n||n.length<=0)&&!s)return r;const o={};for(const e in r){if(!r.hasOwnProperty(e))continue;const a=s?i&&e.startsWith("_")?e:Lt.camelCase(e):e;if(n.length>0&&!n.includes(e)&&!n.includes(a))continue;const c=r[e];t.ignoreNull&&null===c||(t.ignoreZero&&0===c||t.ignoreEmptyArray&&Array.isArray(c)&&c.length<=0||t.ignoreEmptyString&&"string"==typeof c&&""===c.trim()||(o[a]=c))}return o},clone:Pt,merge:Ft,isEmpty:e=>0!==e&&(!e||"object"==typeof e&&(Array.isArray(e)?!e.length:Object.keys(e).length<=0)),parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{if(!e&&"object"!=typeof e)return e;for(const[n,s]of Object.entries(e))if("object"==typeof s&&null!==s)for(const[e,n]of Object.entries(s))s[e]=Lt.parseValue(n,{number:t,boolean:r});else e[n]=Lt.parseValue(s,{number:t,boolean:r});return e},cloneClass:function(e){return e?"object"!=typeof e?e:Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e)):e},combine:Mt,combines:(e,t={})=>{let r={};if(!e||e.length<=0)return r;const{ignoreUndefined:n=!0,ignoreNull:s=!0,ignoreZero:i=!0,ignoreEmptyArray:o=!0,ignoreEmptyString:a=!0,cover:c=!0}=t;return e.forEach((e=>r=Mt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:i,ignoreEmptyArray:o,ignoreEmptyString:a,cover:c}))),r},observe:Rt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var Dt={...se,...P,...Bt,...$e,includes:function(e,t,r,n){e=se.isArrayLike(e)?e:function(e){return e?Fe(e,function(e){return se.isArrayLike(e)?Ue(e):function(e){if(!se.isPrototype(e))return Be(e);var t=[];for(var r in Object(e))P.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?ge.toInteger(r):0;var s=e.length;return r<0&&(r=De(s+r,0)),se.isString(e)?r<=s&&e.indexOf(t,r)>-1:!!s&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var s=e.length,i=r+(n?1:-1);n?i--:++i<s;)if(t(e[i],i,e))return i;return-1}(e,Te,r);for(var n=r-1,s=e.length;++n<s;)if(e[n]===t)return n;return-1}(e,t,r)>-1},forof:(e,t)=>{if(!e)return;let r;if(se.isObject(e)&&(r=se.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var Ut={groupBy:function(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})},first:function(e){if(!e)return;return e.length<=0?void 0:e[0]},last:function(e){if(!e)return;const t=e.length;return t<=0?void 0:e[t-1]},toList:function(e){return Array.isArray(e)?e:e?[e]:[]}};var It={...Ut,stepAction:function(e,t,r=100){if(!se.isFunction(t))return;if(!se.isArray(e)||e.length<=0)return;let n=0;for(;e.length>n;){let s=r+n,i=e.slice(n,s);t&&t(i),n=s}},skip:function(e,t){if(!se.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!se.isArray(e)||e.length<=0)return[];const n=r||0;if(n>=e.length)return[];const s=t+n;return e.slice(n,e.length<s?e.length:s)||[]},distinct:function(e){return!se.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return Pe.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!se.isObject(e))return;const s=e[t];(se.isString(s)&&""!==s||se.isNumber(s))&&(n[s]=e[r])})),n):n}};const zt="[object Object]",Nt="[object Array]",Kt=e=>Object.prototype.toString.call(e),Ht=(e,t,r=!1)=>{if(e===t)return;const n=Kt(e);if(n===Kt(t))if(n===Nt&&e.length>=t.length)for(let r=0;r<t.length;r++)Ht(e[r],t[r]);else if(n===zt&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?Ht(e[n],t[n]):e[n]=null},Vt=(e,t,r,n="",s=!1)=>{if(e===t)return;const i=Kt(e),o=Kt(t);if(i===Nt&&o===i&&e.length>=t.length)for(let s=0;s<e.length;s++)Vt(e[s],t[s],r,`${n}[${s}]`);else if(i===zt&&o===i&&(s||Object.keys(e).length>=Object.keys(t).length)){const s=Object.keys(e);for(let i of s){const s=e[i],o=t[i],a=Kt(s),c=Kt(o);if(s!==o)if(a===Nt&&c===a&&s.length>=o.length)for(let e=0;e<s.length;e++)Vt(s[e],o[e],r,`${n?n+".":""}${i}[${e}]`);else if(a===zt&&c===a&&Object.keys(s).length>=Object.keys(o).length)for(let e in s)Vt(s[e],o[e],r,`${n?n+".":""}${i}.${e}`);else r[`${n?n+".":""}${i}`]=s}}else r[n]=e};class Wt{list=[];constructor(){this.invoke=this.invoke.bind(this)}use(e){this.list=this.list.concat(e)}invoke(e){return this.list.reduce(((e,t)=>e.then((e=>t(e)))),Promise.resolve(e)).catch((e=>"REFETCH"===e.sig?Promise.resolve(e.result):Promise.reject(e)))}}class Zt{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new Wt,response:new Wt};constructor(e){const{reqConfig:t={},requestEncrypt:r,responseDecrypt:n,handleError:s,api:i}=e;this.reqConfig=t,this.handleEncrypt=r,this.handleDecrypt=n,this.handleError=s,this.handleRequest=i}static blockId="blockid";static requestLock={};lockR(e,t){Zt.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Zt.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}_fetch(e,t){let r=e;return t&&this.handleEncrypt&&(r=this.handleEncrypt(e)),new Promise(((e,n)=>{this.handleRequest({...r,success:r=>{let n=r;t&&this.handleDecrypt&&(n=this.handleDecrypt(r)),e(n)},fail:e=>{n(e)}})}))}async request(e,t){const r=Bt.copy(this.reqConfig[e]),{config:n,...s}=await this.interceptors.request.invoke({url:r.url,data:t||{},header:{"content-type":"application/json"},method:r.method?r.method:"POST",responseType:"text",config:r});let i;try{if("block"===n.model)this.lockR(Zt.blockId,(()=>this._fetch(s,n.hasEncrypt))),i=await Zt.requestLock[Zt.blockId].request;else if(Zt.requestLock[Zt.blockId]&&Zt.requestLock[Zt.blockId].lock&&await Zt.requestLock[Zt.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Zt.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),i=await Zt.requestLock[e].request,this.unlockR(e)}else i=await this._fetch(s,n.hasEncrypt)}catch(e){this.handleError&&this.handleError(e)}return this.interceptors.response.invoke({res:i,config:r,reqId:this.getIdFromReq(s),refetch:()=>({sig:"REFETCH",result:this.request(e,t||{})})})}}const Gt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Jt={diff:function(e,t){const r={};return(e=>{if(Kt(e)===zt)for(let t in e)if(/\w+\.\w+/g.test(t)&&-1===t.indexOf("[")){const r=t.split(".");let n=e,s=r.length;for(let e=0;e<s-1;e++){const t=r[e];Kt(n[t])!==zt&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),Ht(e,t,!0),Vt(e,t,r,"",!0),r},promixify:Gt,run:(e,t={})=>e?je.run(Gt(e)(t)):je.run(e),formatList:(e,t,r)=>(e||[]).reduce(((e,n,s)=>({...e,[`${r}[${t+s}]`]:n})),{}),ruleValidator:(e,t)=>!!t&&(!Array.isArray(t)||!(t.length<=0)&&t.every((e=>!!e))),Http:Zt,setWatcher:e=>{let t=e.data,r=e.watch;Object.keys(r).forEach((n=>{let s=t,i=n.split(".");for(let e=0;e<i.length-1;e++)s=s[i[e]];let o=i[i.length-1],a=r[n].handler||r[n],c=r[n].deep;Bt.observe(s,o,a,e,c)}))}};const Yt=function(e,{sep:t="&",eq:r="=",max:n=1e3,multiple:s=!0,uri:i=!0,parseNumber:o=!1,parseBoolean:a=!1}={}){t=t||"&",r=r||"=";const c={};if("string"!=typeof e||0===e.length)return c;const l=/\+/g,u=n||1e3;let d=(e=e.split(t)).length;u>0&&d>u&&(d=u);for(let t=0;t<d;++t){let n,o,a,u,d=e[t].replace(l,"%20"),h=d.indexOf(r);h>=0?(n=d.substr(0,h),o=d.substr(h+1)):(n=d,o=""),a=i?decodeURIComponent(n):n,u=i?decodeURIComponent(o):o,P.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(u):c[a]=[c[a],u]:c[a]=u}return Bt.parseValue(c,{number:o,boolean:a}),c},Qt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Xt=function(e,t=!0){return t?encodeURIComponent(e):e},er=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},tr=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,rr=e=>{const t=(e||"").replace(/\\/g,"/").split("?")[0],r=t.match(/[\/]?([\w\_\-]+)[.]?[\w]*[?]?$/),n=r?r[1]:"",s=t.lastIndexOf("/")+1,i=t.substring(s),o=i.lastIndexOf("."),a=i.substring(0,o)||"",c=o>=0?i.substring(o):"";return{route:t.substring(0,s)||"",page:n,name:i,withoutExtension:a,extname:c}},nr=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(tr);if(!r||r.length<4)return t;const n=r[3]||"",s=e.split("?");return t.url=s[0],t.origin=r[0],t.protocol=`${r[1]}:`,t.host=`${r[2]}${n?":"+n:""}`,t.port=n,t.query=s.length>1?s[1]:"",t};var sr={parse:Yt,stringify:function(e,{sep:t="&",eq:r="=",name:n=null,uri:s=!0,cleanZero:i=!1,cleanNull:o=!1,cleanWhitespace:a=!1}={}){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){const c=Xt(Qt(n),s)+r,l=e[n];return Array.isArray(l)?l.map((function(e){return c+Xt(Qt(e),s)})).join(t):er(l,{cleanZero:i,cleanNull:o,cleanWhitespace:a})?"":c+Xt(Qt(l),s)})).filter(Boolean).join(t):n?Xt(Qt(n),s)+r+Xt(Qt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=nr(e),{origin:r="",url:n="",query:s=""}=t,i=rr(n),o=Yt(s,{multiple:!0,uri:!1});return{...t,...i,pathname:n.substring(n.indexOf(r||"")+r.length),params:o}},parsePath:rr,parseHost:nr,join:(...e)=>{let t=[];return e.forEach((e=>{const r=e.trim().replace(/^\/*(.*?)\/*$/,"$1");r.length<=0||(/^(\w+):\/\//.test(r)?t=[r]:t.push(r))})),t.join("/")}};const ir=/%[sdj%]/g;let or=()=>{};function ar(e){if(!e||!e.length)return null;const t={};return e.forEach((e=>{const r=e.field;t[r]=t[r]||[],t[r].push(e)})),t}function cr(e,...t){let r=0;const n=t.length;if("function"==typeof e)return e.apply(null,t);if("string"==typeof e){return e.replace(ir,(e=>{if("%%"===e)return"%";if(r>=n)return e;switch(e){case"%s":return String(t[r++]);case"%d":return Number(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch(e){return"[Circular]"}break;default:return e}}))}return e}function lr(e,t){return null==e||(!("array"!==t||!Array.isArray(e)||e.length)||!(!function(e){return"string"===e||"url"===e||"hex"===e||"email"===e||"date"===e||"pattern"===e}(t)||"string"!=typeof e||e))}function ur(e,t,r){let n=0;const s=e.length;!function i(o){if(o&&o.length)return void r(o);const a=n;n+=1,a<s?t(e[a],i):r([])}([])}"undefined"!=typeof process&&process.env&&"production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&"undefined"!=typeof document&&(or=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class dr extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function hr(e,t,r,n,s){if(t.first){const t=new Promise(((t,i)=>{const o=function(e){const t=[];return Object.keys(e).forEach((r=>{t.push(...e[r]||[])})),t}(e);ur(o,r,(e=>(n(e),e.length?i(new dr(e,ar(e))):t(s))))}));return t.catch((e=>e)),t}const i=!0===t.firstFields?Object.keys(e):t.firstFields||[],o=Object.keys(e),a=o.length;let c=0;const l=[],u=new Promise(((t,u)=>{const d=e=>{if(l.push.apply(l,e),c++,c===a)return n(l),l.length?u(new dr(l,ar(l))):t(s)};o.length||(n(l),t(s)),o.forEach((t=>{const n=e[t];-1!==i.indexOf(t)?ur(n,r,d):function(e,t,r){const n=[];let s=0;const i=e.length;function o(e){n.push(...e||[]),s++,s===i&&r(n)}e.forEach((e=>{t(e,o)}))}(n,r,d)}))}));return u.catch((e=>e)),u}function fr(e,t){return r=>{let n;return n=e.fullFields?function(e,t){let r=e;for(let e=0;e<t.length;e++){if(null==r)return r;r=r[t[e]]}return r}(t,e.fullFields):t[r.field||e.fullField],function(e){return!(!e||void 0===e.message)}(r)?(r.field=r.field||e.fullField,r.fieldValue=n,r):{message:"function"==typeof r?r():r,fieldValue:n,field:r.field||e.fullField}}}function pr(e,t){if(t)for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];"object"==typeof n&&"object"==typeof e[r]?e[r]={...e[r],...n}:e[r]=n}return e}const gr=(e,t,r,n,s,i)=>{!e.required||r.hasOwnProperty(e.field||"")&&!lr(t,i||e.type)||n.push(cr(s.messages.required,e.fullField))};let yr;const mr=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,wr=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,br={integer:e=>br.number(e)&&parseInt(e,10)===e,float:e=>br.number(e)&&!br.integer(e),array:e=>Array.isArray(e),regexp(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch(e){return!1}},date:e=>"function"==typeof e.getTime&&"function"==typeof e.getMonth&&"function"==typeof e.getYear&&!isNaN(e.getTime()),number:e=>!isNaN(e)&&"number"==typeof e,object:e=>"object"==typeof e&&!br.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(mr),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(yr)return yr;const e="[a-fA-F\\d:]",t=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${e})|(?<=${e})(?=\\s|$))`:"",r="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",n="[a-fA-F\\d]{1,4}",s=`\n(?:\n(?:${n}:){7}(?:${n}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${n}:){6}(?:${r}|:${n}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${n}:){5}(?::${r}|(?::${n}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${n}:){4}(?:(?::${n}){0,1}:${r}|(?::${n}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${n}:){3}(?:(?::${n}){0,2}:${r}|(?::${n}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${n}:){2}(?:(?::${n}){0,3}:${r}|(?::${n}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${n}:){1}(?:(?::${n}){0,4}:${r}|(?::${n}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${n}){0,5}:${r}|(?::${n}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),i=new RegExp(`(?:^${r}$)|(?:^${s}$)`),o=new RegExp(`^${r}$`),a=new RegExp(`^${s}$`),c=e=>e&&e.exact?i:new RegExp(`(?:${t(e)}${r}${t(e)})|(?:${t(e)}${s}${t(e)})`,"g");c.v4=e=>e&&e.exact?o:new RegExp(`${t(e)}${r}${t(e)}`,"g"),c.v6=e=>e&&e.exact?a:new RegExp(`${t(e)}${s}${t(e)}`,"g");const l=c.v4().source,u=c.v6().source;return yr=new RegExp(`(?:^(?:(?:(?:[a-z]+:)?//)|www\\.)(?:\\S+(?::\\S*)?@)?(?:localhost|${l}|${u}|(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#][^\\s"]*)?$)`,"i"),yr})()),hex:e=>"string"==typeof e&&!!e.match(wr)},vr="enum";var _r={required:gr,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(cr(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void gr(e,t,r,n,s);const i=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(i)>-1?br[i](t)||n.push(cr(s.messages.types[i],e.fullField,e.type)):i&&typeof t!==e.type&&n.push(cr(s.messages.types[i],e.fullField,e.type))},range:(e,t,r,n,s)=>{const i="number"==typeof e.len,o="number"==typeof e.min,a="number"==typeof e.max,c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;let l=t,u="";const d="number"==typeof t,h="string"==typeof t,f=Array.isArray(t);if(d?u="number":h?u="string":f&&(u="array"),!u)return!1;f&&(l=t.length),h&&(l=t.replace(c,"_").length),i?l!==e.len&&n.push(cr(s.messages[u].len,e.fullField,e.len)):o&&!a&&l<e.min?n.push(cr(s.messages[u].min,e.fullField,e.min)):a&&!o&&l>e.max?n.push(cr(s.messages[u].max,e.fullField,e.max)):o&&a&&(l<e.min||l>e.max)&&n.push(cr(s.messages[u].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[vr]=Array.isArray(e[vr])?e[vr]:[],-1===e[vr].indexOf(t)&&n.push(cr(s.messages[vr],e.fullField,e[vr].join(", ")))},pattern:(e,t,r,n,s)=>{if(e.pattern)if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||n.push(cr(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(cr(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const xr=(e,t,r,n,s)=>{const i=e.type,o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t,i)&&!e.required)return r();_r.required(e,t,n,o,s,i),lr(t,i)||_r.type(e,t,n,o,s)}r(o)};var kr={string:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(lr(t,"string")&&!e.required)return r();_r.required(e,t,n,i,s,"string"),lr(t,"string")||(_r.type(e,t,n,i,s),_r.range(e,t,n,i,s),_r.pattern(e,t,n,i,s),!0===e.whitespace&&_r.whitespace(e,t,n,i,s))}r(i)},method:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&_r.type(e,t,n,i,s)}r(i)},number:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(""===t&&(t=void 0),lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&(_r.type(e,t,n,i,s),_r.range(e,t,n,i,s))}r(i)},boolean:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&_r.type(e,t,n,i,s)}r(i)},regexp:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),lr(t)||_r.type(e,t,n,i,s)}r(i)},integer:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&(_r.type(e,t,n,i,s),_r.range(e,t,n,i,s))}r(i)},float:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&(_r.type(e,t,n,i,s),_r.range(e,t,n,i,s))}r(i)},array:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(null==t&&!e.required)return r();_r.required(e,t,n,i,s,"array"),null!=t&&(_r.type(e,t,n,i,s),_r.range(e,t,n,i,s))}r(i)},object:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&_r.type(e,t,n,i,s)}r(i)},enum:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s),void 0!==t&&_r.enum(e,t,n,i,s)}r(i)},pattern:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t,"string")&&!e.required)return r();_r.required(e,t,n,i,s),lr(t,"string")||_r.pattern(e,t,n,i,s)}r(i)},date:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t,"date")&&!e.required)return r();if(_r.required(e,t,n,i,s),!lr(t,"date")){let r;r=t instanceof Date?t:new Date(t),_r.type(e,r,n,i,s),r&&_r.range(e,r.getTime(),n,i,s)}}r(i)},url:xr,hex:xr,email:xr,required:(e,t,r,n,s)=>{const i=[],o=Array.isArray(t)?"array":typeof t;_r.required(e,t,n,i,s,o),r(i)},any:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,i,s)}r(i)}};function Sr(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone(){const e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}const $r=Sr();class Ar{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");kr[e]=t};static warning=or;static messages=$r;static validators=kr;rules={};_messages=$r;constructor(e){this.define(e)}define(e){if(!e)throw new Error("Cannot configure a schema with no rules");if("object"!=typeof e||Array.isArray(e))throw new Error("Rules must be an object");this.rules={},Object.keys(e).forEach((t=>{const r=e[t];this.rules[t]=Array.isArray(r)?r:[r]}))}messages(e){return e&&(this._messages=pr(Sr(),e)),this._messages}validate(e,t={},r=(()=>{})){let n=e,s=t,i=r;if("function"==typeof s&&(i=s,s={}),!this.rules||0===Object.keys(this.rules).length)return i&&i(null,n),Promise.resolve(n);if(s.messages){let e=this.messages();e===$r&&(e=Sr()),pr(e,s.messages),s.messages=e}else s.messages=this.messages();const o={};(s.keys||Object.keys(this.rules)).forEach((t=>{const r=this.rules[t];let s=n[t];r.forEach((r=>{let i=r;"function"==typeof i.transform&&(n===e&&(n={...n}),s=n[t]=i.transform(s)),i="function"==typeof i?{validator:i}:{...i},i.validator=this.getValidationMethod(i),i.validator&&(i.field=t,i.fullField=i.fullField||t,i.type=this.getType(i),o[t]=o[t]||[],o[t].push({rule:i,value:s,source:n,field:t}))}))}));const a={};return hr(o,s,((e,t)=>{const r=e.rule;let i,o=!("object"!==r.type&&"array"!==r.type||"object"!=typeof r.fields&&"object"!=typeof r.defaultField);function c(e,t){return{...t,fullField:`${r.fullField}.${e}`,fullFields:r.fullFields?[...r.fullFields,e]:[e]}}function l(i=[]){let l=Array.isArray(i)?i:[i];!0===s.suppressWarning&&l.length&&Ar.warning("async-validator:",l),l.length&&void 0!==r.message&&(l=[].concat(r.message));let u=l.map(fr(r,n));if(s.first&&u.length)return a[r.field]=1,t(u);if(o){if(r.required&&!e.value)return void 0!==r.message?u=[].concat(r.message).map(fr(r,n)):s.error&&(u=[s.error(r,cr(s.messages.required,r.field))]),t(u);let i={};r.defaultField&&Object.keys(e.value).map((e=>{i[e]=r.defaultField})),i={...i,...e.rule.fields};const o={};Object.keys(i).forEach((e=>{const t=i[e],r=Array.isArray(t)?t:[t];o[e]=r.map(c.bind(null,e))}));const a=new Ar(o);a.messages(s.messages),e.rule.options&&(e.rule.options.messages=s.messages,e.rule.options.error=s.error),a.validate(e.value,e.rule.options||s,(e=>{const r=[];u&&u.length&&r.push(...u),e&&e.length&&r.push(...e),t(r.length?r:null)}))}else t(u)}if(o=o&&(r.required||!r.required&&e.value),r.field=e.field,r.asyncValidator)i=r.asyncValidator(r,e.value,l,e.source,s);else if(r.validator){try{i=r.validator(r,e.value,l,e.source,s)}catch(e){console.error?.(e),s.suppressValidatorError||setTimeout((()=>{throw e}),0),l(e.message)}!0===i?l():!1===i?l("function"==typeof r.message?r.message(r.fullField||r.field):r.message||`${r.fullField||r.field} fails`):i instanceof Array?l(i):i instanceof Error&&l(i.message)}i&&i.then&&i.then((()=>l()),(e=>l(e)))}),(e=>{!function(e){let t=[],r={};for(let r=0;r<e.length;r++)s=e[r],Array.isArray(s)?t=t.concat(...s):t.push(s);var s;t.length?(r=ar(t),i(t,r)):i(null,n)}(e)}),n)}getType(e){if(void 0===e.type&&e.pattern instanceof RegExp&&(e.type="pattern"),"function"!=typeof e.validator&&e.type&&!kr.hasOwnProperty(e.type))throw new Error(cr("Unknown rule type %s",e.type));return e.type||"string"}getValidationMethod(e){if("function"==typeof e.validator)return e.validator;const t=Object.keys(e),r=t.indexOf("message");return-1!==r&&t.splice(r,1),1===t.length&&"required"===t[0]?kr.required:kr[this.getType(e)]||void 0}}function Cr(e){return new Ar(e)}var Or={validateId:function(e){return!!e&&(!(e.length<6)&&!!/^[A-Za-z0-9_-]+$/.test(e))},validatePhone:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)},validator:Cr,validate:function(e,t,r={},n=(()=>{})){return je.run(Cr(e).validate(t,r,n))},isChinese:function(e){return!!e&&!!/^[\u4E00-\u9FA5]+$/.test(e)},isNumber:function(e){return!!e&&!!/^[0-9]+$/.test(e)},isFloat:function(e){return!!e&&!!/^(\-|\+)?\d+(\.\d+)?$/.test(e)},isPhoneNumber:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)}};var jr={pattern:{num:"0-9",zh:"一-龥",en:"A-Za-z"},regex:(e,t)=>new RegExp(e,t),entire:{chinese:/^[\u4E00-\u9FA5]+$/,real:/^(\-|\+)?\d+(\.\d+)?$/,cssReal:/^(\-|\+)?\d*(\.)?\d+$/,id:/^[A-Za-z0-9]+$/,yyyyMMdd:/^(\d{4})-?(\d{2})-?(\d{2})$/}};var Er={toUtf8:e=>{if(!e)return"";const t=e.replace(/\r\n/g,"\n");let r="";for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r+=String.fromCharCode(n):n>127&&n<2048?(r+=String.fromCharCode(n>>6|192),r+=String.fromCharCode(63&n|128)):(r+=String.fromCharCode(n>>12|224),r+=String.fromCharCode(n>>6&63|128),r+=String.fromCharCode(63&n|128))}return r},fromUtf8:e=>{let t="",r=0;if(!e)return"";let n=0,s=0,i=0;for(;r<e.length;)n=e.charCodeAt(r),n<128?(t+=String.fromCharCode(n),r++):n>191&&n<224?(s=e.charCodeAt(r+1),t+=String.fromCharCode((31&n)<<6|63&s),r+=2):(s=e.charCodeAt(r+1),i=e.charCodeAt(r+2),t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),r+=3);return t},toUtf8Bytes:e=>{if(!e)return new Uint8Array;const t=e.replace(/\r\n/g,"\n"),r=[];for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r.push(n):n<2048?(r.push(n>>6|192),r.push(63&n|128)):(r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128))}return new Uint8Array(r)},fromUtf8Bytes:e=>{let t="",r=0;if(!e||e.length<=0)return"";for(;r<e.length;){let n=e[r];if(n<128)t+=String.fromCharCode(n),r++;else if(n>191&&n<224){const s=e[r+1];t+=String.fromCharCode((31&n)<<6|63&s),r+=2}else{const s=e[r+1],i=e[r+2];t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&i),r+=3}}return t}};const qr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var Lr={toBase64:(e="")=>{let t,r,n,s,i,o,a,c="",l=0;for(e=Er.toUtf8(e);l<e.length;)t=e.charCodeAt(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l++),s=t>>2,i=(3&t)<<4|r>>4,o=(15&r)<<2|n>>6,a=63&n,isNaN(r)?o=a=64:isNaN(n)&&(a=64),c=c+qr.charAt(s)+qr.charAt(i)+qr.charAt(o)+qr.charAt(a);return c},fromBase64:(e="")=>{let t,r,n,s,i,o,a,c="",l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=qr.indexOf(e.charAt(l++)),i=qr.indexOf(e.charAt(l++)),o=qr.indexOf(e.charAt(l++)),a=qr.indexOf(e.charAt(l++)),t=s<<2|i>>4,r=(15&i)<<4|o>>2,n=(3&o)<<6|a,c+=String.fromCharCode(t),64!=o&&(c+=String.fromCharCode(r)),64!=a&&(c+=String.fromCharCode(n));return c=Er.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,i,o,a,c="",l=0;if(!e||!se.isArrayLike(e)||!se.isUint8Array(e))return"";for(;l<e.length;)t=e[l++],r=e[l++],n=e[l++],s=t>>2,i=(3&t)<<4|r>>4,o=(15&r)<<2|n>>6,a=63&n,isNaN(r)?o=a=64:isNaN(n)&&(a=64),c=c+qr.charAt(s)+qr.charAt(i)+qr.charAt(o)+qr.charAt(a);return c},base64ToBytes:(e="")=>{let t,r,n,s,i,o,a,c=[],l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=qr.indexOf(e.charAt(l++)),i=qr.indexOf(e.charAt(l++)),o=qr.indexOf(e.charAt(l++)),a=qr.indexOf(e.charAt(l++)),t=s<<2|i>>4,r=(15&i)<<4|o>>2,n=(3&o)<<6|a,c.push(t),64!=o&&c.push(r),64!=a&&c.push(n);return new Uint8Array(c)}};const Pr=e=>Lr.toBase64(e);var Tr={encode:Pr,decode:e=>Lr.fromBase64(e),encodeByOss:e=>Pr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Fr={...f,base64:Tr,uuid:p,guid:(e,t=!1,r="")=>{const n=p(e||32);return t?x.now().format("yyyyMMddhhmmss")+r+n:n},getHexString:e=>{const t=f.keyChars;let r="";const n=t.length;for(let s=0;s<e;s++)r+=t.charAt(Math.floor(Math.random()*n));return r}};const Mr=e=>{if(!e)return"";if(!Dt.isObject(e))return"";let t="";return Dt.forof(e,((e,r)=>{r&&(t+=`${Lt.kebabCase(e)}:${r};`)})),t},Rr=["display","position","top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","fontSize","textAlign","fontFamily","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius","background","backgroundImage","backgroundRepeat","backgroundSize","backgroundPosition","color","overflow","opacity","flexDirection","justifyContent","alignItems","flexWrap","alignContent","alignSelf","flex","flexBasis","flexFlow","flexShrink","pointerEvents"],Br=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],Dr=(e,t="px")=>e&&t?"0"===e?e:Or.isFloat(e.toString())?`${e}${t}`:e:e;var Ur={stringify:Mr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=sr.parse(e,{sep:";",eq:":",uri:!1}),s={};return Dt.forof(n,((e,n)=>{if(!n)return;const i=t?r&&e.startsWith("_")?e:Lt.camelCase(e):e;Or.isFloat(n)||n.length>=2&&n.startsWith(".")&&Or.isNumber(n.substr(1))?s[i]=+n:s[i]=n})),s},fixValue:Dr,style:(e,t="px")=>{if(!e)return"";const r=Dt.copy(e,{fields:Rr});Dt.forof(r,((e,n)=>{(Br.includes(e)||Br.includes(Lt.camelCase(e)))&&(r[e]=Dr(n,t))}));return Mr(r)},commonFields:Rr};const Ir=(e,t="",r=!1)=>{try{if(!e)return;const n=sr.parseUrl(e),s=t||n.name;if(!t||!r||!n.origin||n.origin===window.location.origin)((e,t)=>{try{const r=document.createElement("a");r.style.display="none",r.href=e,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}catch(t){console.error(`[ddan] _downloadUrl ${e}`,t)}})(e,s);else{const t=n.params;t.t=Date.now();const r=`${n.url}?${sr.stringify(t,{uri:!1})}`,i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="blob",i.onload=function(){zr(i.response,s)},i.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},i.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},zr=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;Ir(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},Nr=e=>{try{const t=document.createElement("textarea");document.body.appendChild(t),t.style.position="fixed",t.style.clip="rect(0 0 0 0)",t.style.top="10px",t.style.opacity="0",t.value=e??"",t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}catch(e){return console.error("[ddan] copyText",e),!1}},Kr=(e,t="denied")=>new Promise((r=>{const n=navigator?.permissions;if(!n||!n.query)return r(t);const s={name:e};n.query(s).then((e=>r(e.state))).catch((()=>r(t)))})),Hr=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Vr={dataURLtoFile:(e,t)=>{let r=e.split(","),n=r[0].match(/:(.*?);/)[1],s=window.atob(r[1]),i=s.length,o=new Uint8Array(i);for(;i--;)o[i]=s.charCodeAt(i);return new File([o],t,{type:n})},dataURLtoBlob:e=>{let t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=window.atob(t[1]),s=n.length,i=new Uint8Array(s);for(;s--;)i[s]=n.charCodeAt(s);return new Blob([i],{type:r})},blobToFile:(e,t)=>(e.lastModifiedDate=new Date,e.name=t,e),readAsDataURL:(e,t)=>{var r=new FileReader;r.readAsDataURL(e),r.onloadend=function(e){t&&t(e.target?.result)}},downloadUrl:Ir,download:(e,t="")=>{e&&("string"!=typeof e?zr(e,t):Ir(e,t))},downloadFile:zr,downloadImage:e=>{try{if(!e)return;const t=e.match(/\/(\w+.\w+)$/)[1],r=new Image;r.onload=()=>{let e=document.createElement("canvas");e.width=r.width,e.height=r.height;let n=e.getContext("2d");n&&n.drawImage(r,0,0,r.width,r.height);let s=e.toDataURL();Ir(s,t)},r.src=e,r.setAttribute("crossOrigin","Anonymous")}catch(e){console.error("[ddan] downloadImage",e)}return Promise.resolve()},watermark:(e,{width:t=400,height:r=300,angle:n=0,fillStyle:s="rgba(0, 0, 0, 0.2)",font:i="16px Arial",textAlign:o="left",textBaseline:a="middle"}={})=>{try{if(!e)return"";const c=document.createElement("canvas");c.width=t,c.height=r;const l=c.getContext("2d");return l?(n&&l.rotate(n*Math.PI/180),s&&(l.fillStyle=s),i&&(l.font=i),o&&(l.textAlign=o),a&&(l.textBaseline=a),l.fillText(e,c.width/10,c.height/2),`url(${c.toDataURL()})`):""}catch(e){return console.error("[ddan] watermark",e),""}},copyText:(e,t=!1)=>new Promise((r=>{!t&&navigator.clipboard?Kr("clipboard-write").then((t=>{Hr(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(Nr(e)))):r(Nr(e))})).catch((()=>{r(Nr(e))})):r(Nr(e))})),queryPermission:Kr,isAllowed:Hr,legacyCopy:Nr};var Wr={ossImage:(e,t={})=>{if(!e)return e;const r=sr.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=It.toList(t.domain||""),n=e.match(/^http[s]?:\/\/([\w.]+)[\w\W]+/)[1]||"";if(!n||!r.includes(n))return e}const n=[];return t.webp&&!r.endsWith(".gif")&&n.push("format,webp"),t.resize&&n.push(`resize,s_${t.resize}`),t.interlace&&(n.push("interlace,1"),!n.every((e=>!e.startsWith("format")))||r.endsWith(".gif")||r.endsWith(".jpg")||n.push("format,jpg")),n.length<=0?e:`${r}?x-oss-process=image/${n.join("/")}`},ossSnapshot:(e,t={})=>{if(!e)return e;const r=sr.parseUrl(e).url,n=["snapshot"],{m:s="fast",f:i="jpg"}=t;return(t.t||0===t.t)&&n.push(`t_${t.t}`),t.w&&n.push(`w_${t.w}`),t.h&&n.push(`h_${t.h}`),s&&n.push(`m_${s}`),i&&n.push(`f_${i}`),t.ar&&n.push(`ar_${t.ar}`),`${r}?x-oss-process=video/${n.join(",")}`},ossBase64:e=>Lr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Zr={...Er,...Lr,str2Hex:e=>{let t="";for(let r=0;r<e.length;r++)t+=e.charCodeAt(r).toString(16).padStart(2,"0");return t},hex2Str:e=>{let t="";for(let r=0;r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},str2ab:(e="",t=!1)=>{if(t)return Lr.base64ToBytes(e).buffer;{const t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0,n=e.length;t<n;t++)r[t]=e.charCodeAt(t);return t}},ab2str:(e,t=!1)=>{const r=new Uint8Array(e);return t?Lr.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!se.isArrayLike(e))return"";return e.reduce(((e,t)=>e+String.fromCharCode(t)),"")},strToBytes:(e="")=>{const t=e,r=new Uint8Array(t.length);for(let e=0,n=t.length;e<n;e++)r[e]=t.charCodeAt(e);return r},utf8ToBase64:e=>se.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>se.isBrowser?atob(e):Buffer.from(e,"base64").toString("utf-8"),getRandomBytes:e=>{const t=new Uint8Array(e);for(let r=0;r<e;r++)t[r]=Pe.random(256);return t},textEncode:e=>Er.toUtf8Bytes(e),textDecode:e=>Er.fromUtf8Bytes(new Uint8Array(e))};const Gr=({url:e,options:t})=>{const r={"Content-Type":"application/json; charset=utf-8",...t.headers||{}};return t.headers=r,new Promise(((r,n)=>{fetch(e,t).then((e=>{r(e.json())})).catch((e=>{n(e)}))}))};function Jr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Yr(e){const{url:t="",host:r,options:n}=e,s=e;if(t.startsWith("http://")||t.startsWith("https://")||(s.url=(r||"")+t),"GET"===n.method.toUpperCase()&&n.body){const e=JSON.parse(n.body);if(Dt.isPlainObject(e)){const r=sr.stringify(e),n=-1===t.indexOf("?")?"?":"&";s.url=`${s.url||""}${n}${r}`,delete s.options.body}}return n&&n.plugins&&delete s.options?.plugins,n&&n.model&&delete s.options?.model,s}class Qr{host="";reqConfig={};handleError;interceptors={request:new Wt,response:new Wt};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Yr),this.interceptors.response.use(e.handleResponse||Jr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Qr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Qr.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}async fetch(e,t){const r=Dt.copy(this.reqConfig[e])||{},n={host:this.host,url:r.url||"",options:{...r||{},body:JSON.stringify({...t||{}})}};try{const s=await this.interceptors.request.invoke(n);let i;if(delete s.options.plugins,"block"===r.model)this.lockR(Qr.blockId,(()=>Gr(s))),i=await Qr.requestLock[Qr.blockId].request;else if(Qr.requestLock[Qr.blockId]&&Qr.requestLock[Qr.blockId].lock&&await Qr.requestLock[Qr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Qr.requestLock[e]||this.lockR(e,(()=>Gr(s))),i=await Qr.requestLock[e].request,this.unlockR(e)}else i=await Gr(s);return this.interceptors.response.invoke({response:i,config:r,refetch:()=>({sig:"REFETCH",result:this.fetch(e,t)})})}catch(e){return this.handleError&&this.handleError(e),Promise.reject(e)}}}const Xr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},en=e=>(...t)=>{const r=console[e];Xr.overrode?r(...t):tn(r,e,...t)},tn=(e,t,...r)=>{const n=x.format(new Date,Xr.format),s=Xr.tag?`[${t}]`:"";s&&n?e.apply(console,[`${n} ${s}`,...r]):n?e.apply(console,[`${n}`,...r]):s?e.apply(console,[`${s}`,...r]):e.apply(console,[...r])};var rn={override:()=>{if(Xr.overrode)return;Xr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{tn(t,e,...r)}}))},log:en("log"),info:en("info"),warn:en("warn"),error:en("error"),config:({tag:e=Xr.tag,format:t=Xr.format}={})=>{Xr.tag=e,Xr.format=t}};var nn={getDataURL:e=>{const t={contentType:"",dataUrl:""};return ke.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Zr.ab2str(e,!0),t))))},getArrayBuffer:async e=>ke.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>ke.to(fetch(e).then((e=>e.json()))),download:(e,t={})=>new Promise((r=>fetch(e).then((async e=>{if(!e.ok||200!==e.status)throw new Error(e.statusText);const n=+(e.headers.get("content-length")||""),s=e.body?.getReader();let i=0;const o=[];for(;;){const{done:e,value:r}=await s.read();if(e)break;o.push(r),i+=r.length;const a=Pe.float(100*i/n,{digits:2});t?.progress&&t?.progress(a,i,n)}const a=new Uint8Array(i);let c=0;for(const e of o)a.set(e,c),c+=e.length;t?.success&&t?.success(a),r(a)})).catch((e=>{t?.fail&&t?.fail(e),r(void 0)}))))};const sn=new class{__defStyle="vertical-align: middle; mask-position: 50% 50%; mask-repeat: no-repeat; mask-size: 100%; -webkit-mask-position: 50% 50%; -webkit-mask-repeat: no-repeat; -webkit-mask-size: 100%; background-color: currentColor;";__map={back:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M609.408 149.376L277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"/></svg>',right:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"/></svg>',home:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13 19.8h3.8v-7h3.303L12 4.697 3.897 12.8H7.2v7H11V17h2v2.8zm5 .2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-6H3.414a1 1 0 0 1-.707-1.707l8.586-8.586a1 1 0 0 1 1.414 0l8.586 8.586A1 1 0 0 1 20.586 14H18v6z" fill-rule="evenodd" fill-opacity=".9"/></svg>',close:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M764.288 214.592L512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"/></svg>',close_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M466.752 512l-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',close_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"/></svg>',warning:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M928.99 755.83L574.6 203.25c-12.89-20.16-36.76-32.58-62.6-32.58s-49.71 12.43-62.6 32.58L95.01 755.83c-12.91 20.12-12.9 44.91.01 65.03 12.92 20.12 36.78 32.51 62.59 32.49h708.78c25.82.01 49.68-12.37 62.59-32.49 12.91-20.12 12.92-44.91.01-65.03zM554.67 768h-85.33v-85.33h85.33V768zm0-426.67v298.66h-85.33V341.32l85.33.01z" fill="currentColor"/></svg>',play:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024A512 512 0 1 1 512 0a512 512 0 0 1 0 1024zm3.008-92.992a416 416 0 1 0 0-832 416 416 0 0 0 0 832zM383.232 287.616l384 224.896-384 223.104v-448z" fill="currentColor"/></svg>',lock:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M224 448a32 32 0 0 0-32 32v384a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V480a32 32 0 0 0-32-32H224zm0-64h576a96 96 0 0 1 96 96v384a96 96 0 0 1-96 96H224a96 96 0 0 1-96-96V480a96 96 0 0 1 96-96z"/><path fill="currentColor" d="M512 544a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V576a32 32 0 0 1 32-32zm192-160v-64a192 192 0 1 0-384 0v64h384zM512 64a256 256 0 0 1 256 256v128H256V320A256 256 0 0 1 512 64z"/></svg>',lock_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M467.2 713.92v115.968a44.8 44.8 0 0 0 89.6 0V713.92c26.752-14.72 44.8-42.304 44.8-73.92 0-47.104-40.128-85.312-89.6-85.312-49.472 0-89.6 38.208-89.6 85.312 0 31.616 18.048 59.136 44.8 73.92zM64 384h896v640H64V384zm268.8 0h358.4V256c0-94.272-80.256-170.688-179.2-170.688-98.944 0-179.2 76.416-179.2 170.688v128zM512 0c148.48 0 268.8 114.56 268.8 256v128H243.2V256C243.2 114.56 363.52 0 512 0z" fill="currentColor"/></svg>',plus:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"/></svg>',plus_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M352 480h320a32 32 0 1 1 0 64H352a32 32 0 0 1 0-64z"/><path fill="currentColor" d="M480 672V352a32 32 0 1 1 64 0v320a32 32 0 0 1-64 0z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',plus_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-38.4 409.6H326.4a38.4 38.4 0 1 0 0 76.8h147.2v147.2a38.4 38.4 0 0 0 76.8 0V550.4h147.2a38.4 38.4 0 0 0 0-76.8H550.4V326.4a38.4 38.4 0 1 0-76.8 0v147.2z"/></svg>',star:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 747.84l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72L512 747.84zM313.6 924.48a70.4 70.4 0 0 1-102.144-74.24l37.888-220.928L88.96 472.96A70.4 70.4 0 0 1 128 352.896l221.76-32.256 99.2-200.96a70.4 70.4 0 0 1 126.208 0l99.2 200.96 221.824 32.256a70.4 70.4 0 0 1 39.04 120.064L774.72 629.376l37.888 220.928a70.4 70.4 0 0 1-102.144 74.24L512 820.096l-198.4 104.32z"/></svg>',star_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M283.84 867.84L512 747.776l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72z"/></svg>',share:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M679.872 348.8l-301.76 188.608a127.808 127.808 0 0 1 5.12 52.16l279.936 104.96a128 128 0 1 1-22.464 59.904l-279.872-104.96a128 128 0 1 1-16.64-166.272l301.696-188.608a128 128 0 1 1 33.92 54.272z"/></svg>',love:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M171.712 571.648l.352.32 287.904 252.8a64 64 0 0 0 82.912 1.344l296.832-244.544a215.584 215.584 0 1 0-301.824-300.576L512 316.672l-25.888-35.616a215.584 215.584 0 1 0-314.4 290.624zM32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512l-295.36 243.392a128 128 0 0 1-165.888-2.592L129.984 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>',love_fill:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952L130.016 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>'};getBase64=e=>{const t=this.getSVG(e);return t?.url||""};getSVG=e=>{if(!e)return;const t=this.__map[e];if(!t)return;return{url:this.toBase64(t),escape:this.toEscape(t)}};toBase64=e=>{if(!e)return"";const t=this._tiny(e);return`data:image/svg+xml;base64,${Tr.encode(t)}`};_tiny=e=>e?e.replace(/<!--(.*)-->/g,"").replace(/[\r\n]/g," ").replace(/"/g,"'"):"";toEscape=e=>{if(!e)return"";return`data:image/svg+xml,${this._tiny(e).replace(/%/g,"%25").replace(/&/g,"%26").replace(/#/g,"%23").replace(/{/g,"%7B").replace(/}/g,"%7D").replace(/</g,"%3C").replace(/>/g,"%3E")}`};getStyle(e,t={}){if(!e)return"";const r=this.__map[e];return r?this.toStyle(r,t):""}toStyle(e,t={}){if(!e)return"";const r=this.toBase64(e);return r?this.getStyleByUrl(r,t):""}getStyleByUrl(e,t={}){if(!e)return"";const{key:r="mask-image",gradientValue:n="radial-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",gradient:s=!1,defStyle:i=this.__defStyle}=t,o=s&&n?`${n}, url("${e}")`:`url("${e}")`;return`${r}:${o};-webkit-${r}:${o};${i}`}},on=(e,t,r)=>({key:e,fields:t,storage:r});class an{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=je.debounce((e=>{if(this.key&&this.storage)try{const{setItem:t,setStorageSync:r}=this.storage;if(r)return r(this.key,e);if(t)return t(this.key,JSON.stringify(e))}catch(e){console.error("persit save ",e)}}));read(){if(this.key&&this.storage)try{const{getItem:e,getStorageSync:t}=this.storage;if(t)return t(this.key);if(e){const t=e(this.key);return JSON.parse(t)}}catch(e){return void console.error("persit read ",e)}}handleSave(e,t){if(!this.fields.includes(t)||!e)return;const r=Bt.copy(e,{fields:this.fields});this.save(r)}}class cn extends g{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!se.isFunction(n))return;const[,s]=await je.run(n({...r,commit:r.commit.bind(r),query:r.query.bind(r),dispatch:r.dispatch.bind(r)},t));return s}async query(e){const t=Reflect.get(this,e);let r;if(null!=t&&""!==t)r=Bt.copy(t);else{const[,t]=await je.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){se.isObject(t)&&(t=Bt.copy(t)),this[e]=t}}const ln=(e,t)=>{const r=Object.assign(new cn,e||{});r.__persist=new an(t||r.persist);const n=r.__persist.read(),s=n?Object.assign(r,n):r;return new Proxy(s,{get:(e,t,r)=>{const n=Reflect.get(e.getters,t);return se.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(se.isFunction(s)&&!s(e,r))return!0;const i=Reflect.set(e,t,r,n);return i&&(e.emit(t.toString(),r),e?.__persist?.handleSave(e,t.toString())),i},has:(e,t)=>Reflect.has(e,t)})};class un{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=sr.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const i=sr.stringify(s,{uri:!1});this.list.push(`${e}?${i}`)}_parseHost(e){e&&!this.host&&/^http[s]?:\/\/([\w.]+)/.test(e)&&(this.host=e.replace(/^http[s]?:\/\/([\w.]+)[\w\W]+/,"$1"))}image(e,t={}){if(!e||!e.includes(this.host))return;if(this.list.length<=0)return;const r={g:"nw",...t},n=e.replace(/^http[s]?:\/\/[\w.]+\/([\w-.,_/?%&=]+)$/,"$1"),s=Fr.base64.encodeByOss(n),i=sr.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=Fr.base64.encodeByOss(e),i=sr.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}result(){return this.list.join("")}}const dn=(e,t)=>new un(e,t);class hn{__list=[];constructor(){this.clear()}add(e){const t=je.run(e);return this.__list.push(t),this}clear(){return this.__list=[],this}wait(){const e=this.__list;return this.clear(),Promise.allSettled(e)}}const fn=new class{state=ln(new cn);frame=new y;cache=new Map;cacheTime=new Map;setCache=(e,t)=>null!=t&&(!!e&&(this.cache.set(e,t),this.cacheTime.set(e,Date.now()),!0));hasCache=e=>{if(!e)return!1;this.cache.has(e)};getCache=e=>{if(e)return this.cache.get(e)};getCacheTime=e=>e&&this.cacheTime.get(e)||0;removeCache=e=>{e&&(this.cache.delete(e),this.cacheTime.delete(e))};cacheId=e=>`_${e}_cache_`;timesRecord=(e,t={})=>{if(!e)return;const{mode:r="running",cycle:n="day"}=t||{},s=this.cacheId(r),i=this.getCache(s)||{},o=Date.now(),a=i[e],c={time:o,count:1,cycle:n};return a&&("day"!==n||x.isToday(a.time||0))&&(c.count=1+(a.count||0)),i[e]=c,this.setCache(s,i),i};timesValid=(e,t={})=>{if(!e)return!1;const{max:r=1,interval:n=0,mode:s="running",cycle:i="day"}=t||{},o=this.cacheId(s);let a=this.getCache(o);if(!a)return!0;const c=a[e];if(!c)return!0;if("day"===i&&!x.isToday(c.time||0))return!0;if(r<=(c.count||0))return!1;return!(Date.now()-(c.time||0)<n)};timesClean=(e="running")=>{const t=this.cacheId(e),r=this.getCache(t);if(!r)return;const n=Dt.copy(r);Dt.forof(n,((e,t)=>{"day"!==t.cycle&&void 0!==t.cycle||x.isToday(t.time||0)||delete r[e]})),this.setCache(t,r)};parallel=()=>new hn};class pn{id="";start=0;end=0;cost=0;name="";type="";desc="";timeStartDesc="";timeEndDesc="";isDone=!1;flag=0;constructor(){this.id=p(),this.start=Date.now(),this.timeStartDesc=x.format(this.start,"hh:mm:ss.SSS")}get time(){return this.flag?this.end:this.start}get timeDesc(){return this.flag?this.timeEndDesc:this.timeStartDesc}done=(e=Date.now())=>{this.start&&(this.end=e,this.cost=this.end-this.start,this.timeEndDesc=x.format(this.end,"hh:mm:ss.SSS"),this.isDone=!0)}}const gn=new class{__map=new Map;__trackList=[];opened=!0;clear(){return this.__map.clear(),this.__trackList=[],this}add(e,{desc:t="",type:r=""}={}){if(!e||!this.opened)return"";const n=new pn;return n.name=e,n.type=r,n.desc=t,this.__trackList.push(n),n.id}done(e){if(!e||!this.opened)return;const t=this.__trackList.find((t=>t.id===e));if(!t||t.isDone)return;t.done();const r=Bt.cloneClass(t);r.id=this._endId(e),r.flag=1,r.desc=`${t.desc} | end`,this.__trackList.push(r)}getTrack(e){return this.__trackList.find((t=>t.id===e))}getLine(e){if(!e||e.endsWith("-end"))return[];const t=this.__trackList.findIndex((t=>t.id===e));if(t<0)return[];const r=this._endId(e),n=this.__trackList.findIndex((e=>e.id===r)),s=n<0?this.__trackList.length-t:n-t+1;return It.take(this.__trackList,s,t)}getList(e,t=""){if(!e)return[];const r=this.__trackList.filter((t=>t.name===e));if(r.length<=0)return[];if(!t)return r;const n=this._endId(t);return this.__trackList.filter((e=>e.id===t||e.id===n))}get list(){return this.__trackList}get size(){return this.__trackList.length}_endId=e=>`${e}-end`;report(e){const t=this.list;if(!t||t.length<=0)return;const r=t[0].time;t.forEach((t=>e&&e(t,r)))}},yn=e=>{try{const t=Zr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},mn=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var wn={generateKeys:async()=>{try{const e=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),t=await window.crypto.subtle.exportKey("spki",e.publicKey),r=yn(t),n=mn(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),i=yn(s);return{publicKey:r,publicKeyPem:n,privateKey:i,privateKeyPem:mn(i,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:mn,format_pem_content:yn,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Zr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Zr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Zr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Zr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["decrypt"]),s=await window.crypto.subtle.decrypt({name:"RSA-OAEP"},n,r);return(new TextDecoder).decode(s)}catch(e){return console.error("decrypt failed:",e),""}}};var bn={brotliCompress:function(e,t=o.default.constants.BROTLI_DEFAULT_QUALITY){try{if(!e)return"";const r=Buffer.from(e,"utf-8");return o.default.brotliCompressSync(r,{params:{[o.default.constants.BROTLI_PARAM_QUALITY]:t}}).toString("base64")}catch(t){return e||""}},brotliDecompress:function(e){try{if(!e)return"";const t=Buffer.from(e,"base64");return o.default.brotliDecompressSync(t).toString("utf-8")}catch(t){return e||""}}};const vn=a.default?.webcrypto?.subtle;var _n={...bn,Ecdh:class{publicKey="";privateKey="";sharedSecret;iv;_curve;_algorithm;_ecdh;constructor(e="prime256v1",t="aes-256-gcm"){this._curve=e,this._algorithm=t,this.generateKey()}generateKey(){const e=a.default.createECDH(this._curve);e.generateKeys(),this.publicKey=e.getPublicKey("base64"),this.privateKey=e.getPrivateKey("base64"),this._ecdh=e}deriveSharedSecret(e,t){if(e)return this.sharedSecret=this._ecdh.computeSecret(e,"base64").toString("base64"),this.iv=t,this}encode(e){if(!this.sharedSecret||!this.iv)return{text:"",authTag:"",iv:""};const t=a.default.createCipheriv("aes-256-gcm",Zr.base64ToBytes(this.sharedSecret),Zr.base64ToBytes(this.iv));return{text:t.update(e,"utf8","base64")+t.final("base64"),authTag:t.getAuthTag().toString("base64"),iv:this.iv}}decode(e,t,r){if(!(e&&this.sharedSecret&&r&&t))return"";const n=a.default.createDecipheriv("aes-256-gcm",Zr.base64ToBytes(this.sharedSecret),Zr.base64ToBytes(r));n.setAuthTag(Zr.base64ToBytes(t));return n.update(e,"base64","utf8")+n.final("utf8")}},EcdhSpki:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await vn.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await vn.exportKey("spki",e);return Zr.ab2str(t,!0)}async importSpkiKey(e){const t=Zr.base64ToBytes(e);return await vn.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await vn.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Zr.textEncode(e),r=await vn.encrypt({name:"AES-GCM",iv:Zr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Zr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Zr.str2ab(e,!0),n=await vn.decrypt({name:"AES-GCM",iv:Zr.base64ToBytes(t)},this.__sharedSecret,r);return Zr.textDecode(n)}},Socks5:class{upstreamProxy;server=null;clientSockets=new Set;allowedDomains;connectionPool={};__debug=!1;__uuid;constructor(e,t=[],r=!1){this.upstreamProxy=e,this.allowedDomains=new Set(t),this.__debug=r,this.__uuid=p()}get id(){return this.__uuid}validateProxyConfig(e=this.upstreamProxy){const{ipaddress:t,port:r,userId:n,password:s}=e||{};return t&&"string"==typeof t?r&&"number"==typeof r?n&&"string"==typeof n?s&&"string"==typeof s?"":"无效的上游代理密码":"无效的上游代理用户名":"无效的上游代理端口":"无效的上游代理 IP 地址"}async start(e=9968){if(this.validateProxyConfig())return 0;if(this.server)return console.log("[socks] server is already running"),0;const t=await this.findAvailablePort(e);return t?(this.server=c.default.createServer((e=>this.handleSocksConnection(e))),this.server.listen(t,(()=>{this.__debug&&console.log(`[socks] server is running on port ${t}`)})),this.server.on("error",(e=>{console.error("[socks] server error:",e),this.close()})),t):t}setUpstreamProxy(e){return!!e&&(!this.validateProxyConfig(e)&&(this.upstreamProxy=e,!0))}setAllowedDomains(e=[]){this.allowedDomains=new Set(e)}async findAvailablePort(e,t=200){let r=e,n=0;for(;n<t;)try{return await new Promise(((e,t)=>{const n=c.default.createServer();n.unref(),n.on("error",t),n.listen(r,(()=>{n.close((()=>e()))}))})),r}catch{n++,r++}return console.warn("[socks] findAvailablePort failed"),0}async handleSocksConnection(e){this.clientSockets.add(e),e.on("close",(()=>{this.clientSockets.delete(e),e?.destroy()}));try{await this.performHandshake(e);const t=await this.parseClientRequest(e);if(this.__debug&&console.log("[socks] handle connection",t.addr),this.isAllowedDomain(t.addr)){const r=await this.connectToUpstreamProxy(t);this.setupDataForwarding(e,r)}else{const r=await this.connectToLocal(t);this.setupDataForwarding(e,r)}}catch(t){console.error("[socks] connection failed:",t),e.end(new Uint8Array([5,1]))}}performHandshake(e){return new Promise(((t,r)=>{e.once("data",(n=>{if(5!==n[0])return r(new Error("Unsupported SOCKS version"));e.write(new Uint8Array([5,0])),t()}))}))}parseClientRequest(e){return new Promise(((t,r)=>{e.once("data",(e=>{let n,s;if(1!==e[1])return r(new Error("Unsupported command"));if(1===e[3])n=e.slice(4,8).join("."),s=e.readUInt16BE(8);else{if(3!==e[3])return r(new Error("Unsupported address type"));{const t=e[4];n=e.slice(5,5+t).toString(),s=e.readUInt16BE(5+t)}}t({addr:n,port:s})}))}))}async connectToUpstreamProxy(e){const t=`${e.addr}:${e.port}`;if(this.connectionPool[t]&&!this.connectionPool[t].destroyed)return this.connectionPool[t];const r={proxy:{...this.upstreamProxy,type:5},command:"connect",destination:{host:e.addr,port:e.port}};try{const{socket:e}=await s.SocksClient.createConnection(r);return this.connectionPool[t]=e,e.on("close",(()=>{delete this.connectionPool[t]})),e}catch(e){throw new Error("Failed to connect to upstream proxy: "+e)}}connectToLocal(e){return new Promise(((t,r)=>{const n=c.default.createConnection(e.port,e.addr,(()=>{t(n)}));n.on("error",(e=>{r(e)}))}))}setupDataForwarding(e,t){e.write(new Uint8Array([5,0,0,1,0,0,0,0,0,0])),e.pipe(t),t.pipe(e),e.on("close",(()=>{t.end()})),t.on("close",(()=>{e.end()})),e.on("error",(e=>{this.__debug&&console.error("[socks] client socket error:",e),t.end()})),t.on("error",(t=>{this.__debug&&console.error("[socks] target socket error:",t),e.end()}))}isAllowedDomain(e){for(const t of this.allowedDomains){if("*"===t)return!0;if(e.includes(t))return!0}return!1}close(){this.server&&(console.log("[socks] closing SOCKS5 proxy server..."),this.server.close((e=>{e&&console.error("[socks] closing the server failed:",e)})),this.clientSockets.forEach((e=>e.destroy())),Object.values(this.connectionPool).forEach((e=>e.destroy())),this.server=null)}}};var xn={Ecdh:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await window.crypto.subtle.exportKey("spki",e);return Zr.ab2str(t,!0)}async importSpkiKey(e){const t=Zr.base64ToBytes(e);return await window.crypto.subtle.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await window.crypto.subtle.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Zr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Zr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Zr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Zr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Zr.base64ToBytes(t)},this.__sharedSecret,r);return Zr.textDecode(n)}}};const kn={gbk:l,math:Pe,list:It,string:Lt,time:x,obj:Bt,rule:Or,regex:jr,...Zr,...Fr,...Dt,Event:g},Sn={...Zr,...Fr,...je},$n={mini:Jt,css:Ur,qs:sr,icon:sn,html:Vr},An={cdn:Wr,watermark:dn},Cn={Store:cn,storeRef:ln,Persist:an,persistConfig:on},On=fn,jn=gn,En=rn,qn={fetch:nn,Http:Qr,css:Ur,qs:sr,icon:sn,html:Vr,rsa:wn,...xn},Ln={..._n};var Pn={gbk:l,time:x,hook:je,math:Pe,util:Dt,list:It,string:Lt,obj:Bt,crypto:Fr,mini:Jt,qs:sr,css:Ur,cdn:Wr,html:Vr,icon:sn,rule:Or,regex:jr,convert:Zr,Event:g,Http:Qr,Store:cn,storeRef:ln,Persist:an,persistConfig:on,watermark:dn,joker:fn,tracker:gn,logger:rn,fetch:nn,rsa:wn};e.dCdn=An,e.dHook=Sn,e.dJoker=On,e.dLogger=En,e.dMini=$n,e.dNode=Ln,e.dStore=Cn,e.dTracker=jn,e.dUtil=kn,e.dWeb=qn,e.default=Pn,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("zlib"),require("node:crypto"),require("net"),require("socks")):"function"==typeof define&&define.amd?define(["exports","zlib","node:crypto","net","socks"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ddan={},e.zlib,e.crypto$1,e.net,e.socks)}(this,(function(e,t,r,n,s){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(t),a=o(r),c=o(n);var l={gbkLength:function(e){let t=0;if(!e)return 0;for(let r=0;r<e.length;r++)e.charCodeAt(r)>127||94===e.charCodeAt(r)?t+=2:t++;return t},gbkCut:function(e,t){if(!e||t<=0)return"";let r=0,n=0;for(let s=0;s<e.length&&(e.charCodeAt(s)>127||94===e.charCodeAt(s)?r+=2:r++,!(r>t));s++)n=s;return e.substr(0,n+1)}};const u="0123456789",d="abcdefghijklmnopqrstuvwxyz",h="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var f={keyNumber:u,keyLower:d,keyUpper:h,keyChars:u+d+h};const p=(e=0,t=0)=>{const r=f.keyChars.split(""),n=[];let s;if(t=t||r.length,e)for(s=0;s<e;s++)n[s]=r[0|Math.random()*t];else{let e;for(n[8]=n[13]=n[18]=n[23]="-",n[14]="4",s=0;s<36;s++)n[s]||(e=0|16*Math.random(),n[s]=r[19==s?3&e|8:e])}return n.join("")};class g{__map;__tagList;__eventId="";constructor(){this.__map=new Map,this.__tagList=[],this.__eventId=p()}clear(){return this.__map.clear(),this}on(e,t,r=""){if(!e||!t)return this;let n=this.__map.get(e);return n||(n=new Set,this.__map.set(e,n)),n.add(t),r&&this.__tagList.push({name:e,listener:t,tag:r}),this}emit(e,...t){if(!e)return this;const r=this.__map.get(e);if(!r)return this;return[...r].forEach((e=>e&&e(...t))),this}off(e,t){if(!e||!t)return this;this.__tagList=this.__tagList.filter((r=>r.name!==e||r.listener!==t));const r=this.__map.get(e);return r?(r.delete(t),r.size<=0&&this.__map.delete(e),this):this}remove(e){return e?(this.__tagList=this.__tagList.filter((t=>t.name!==e)),this.__map.delete(e),this):this}removeByTag(e){if(!e)return this;return this.__tagList.filter((t=>t.tag===e)).forEach((e=>{this.off(e.name,e.listener)})),this.__tagList=this.__tagList.filter((t=>t.tag!==e)),this}once(e,t){const r=(...n)=>{t(...n),this.off(e,r)};return this.on(e,r),this}has(e){return this.__map.has(e)}}class y{_loopTimer;_event=new g;started=!1;interval=0;constructor(e=0){this.interval=e||500}start(){return this.started||(this.stop(),this._loopTimer=setInterval((()=>{this._handleLoop()}),this.interval),this.started=!0),this}stop(){return this._loopTimer?(clearInterval(this._loopTimer),this._loopTimer=0,this.started=!1,this):this}restart(){return this.stop(),this.start(),this}on(e){return this._event.on("frame",e),this}off(e){return e?(this._event.off("frame",e),this):this}_handleLoop(){this._event.emit("frame")}}var m={oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};class w{date;timestamp=0;yyyy=0;yy="";M=0;MM="";d=0;dd="";h=0;hh="";m=0;mm="";s=0;ss="";S=0;SS="";SSS="";constructor(e){if(!e)return;const t="string"==typeof e||"number"==typeof e?new Date(e):e;t&&(this.date=t,this.timestamp=t.getTime(),this.toDate())}toDate(){return this.date?(this.yyyy=this.date.getFullYear(),this.yy=`${this.yyyy}`.substr(2),this.M=this.date.getMonth()+1,this.MM=(this.M<10?"0":"")+this.M,this.d=this.date.getDate(),this.dd=(this.d<10?"0":"")+this.d,this.h=this.date.getHours(),this.hh=(this.h<10?"0":"")+this.h,this.m=this.date.getMinutes(),this.mm=(this.m<10?"0":"")+this.m,this.s=this.date.getSeconds(),this.ss=(this.s<10?"0":"")+this.s,this.S=this.date.getMilliseconds(),this.SS=(this.S<10?"0":"")+this.S,this.SSS=this.S.toString().padStart(3,"0"),this):this}toCountdown(e=""){const t={countdown:0,timestamp:0,seconds:0,d:0,dd:"",h:0,hh:"",m:0,mm:"",s:0,ss:"",S:0,SS:"",SSS:"",desc:""};if(!this.timestamp)return t;t.timestamp=this.timestamp,t.countdown=Math.max(t.timestamp-Date.now(),0),t.seconds=Math.floor(t.countdown/m.oneSecond);let r=t.countdown;t.d=Math.floor(r/m.oneDay),t.dd=(t.d<10?"0":"")+t.d,r%=m.oneDay,t.h=Math.floor(r/m.oneHour),t.hh=(t.h<10?"0":"")+t.h,r%=m.oneHour,t.m=Math.floor(r/m.oneMinute),t.mm=(t.m<10?"0":"")+t.m,r%=m.oneMinute,t.s=Math.floor(r/m.oneSecond),t.ss=(t.s<10?"0":"")+t.s,r%=m.oneSecond,t.S=r,t.SS=(t.S<10?"0":"")+t.S,t.SSS=t.S.toString().padStart(3,"0");let n=e;return n||(n=t.countdown>m.oneHour?"hh:mm:ss":t.countdown>m.oneMinute?"mm:ss":"ss"),t.desc=n.replace(/\bdd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>t[e])),t}add(e=0){return e?(this.timestamp=this.timestamp+e,this.date=new Date(this.timestamp),this.toDate(),this):this}format(e="yyyy-MM-dd hh:mm:ss"){return e.replace(/\byyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S\b/g,(e=>this[e]))}static get timezoneOffset(){return(new Date).getTimezoneOffset()/60}static getLocalTime(e=0){const t=new Date,r=t.getTime(),n=6e4*t.getTimezoneOffset();return new Date(r+n+36e5*e)}}const b=(e,t="yyyy-MM-dd hh:mm:ss")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;return r?v(r).format(t):""},v=e=>{const t="string"==typeof e||"number"==typeof e?new Date(e):e;return new w(t||0)};function _({year:e=0,month:t=0,date:r=0,hour:n=0,minute:s=0,second:o=0}){const i=`${e||"yyyy"}/${t||"MM"}/${r||"dd"} ${n}:${s}:${o}`;return new Date(b(Date.now(),i)).getTime()}var x={...m,now:function(){return v(new Date)},isToday:e=>e&&(new Date).toDateString()===new Date(e).toDateString(),parseTimestamp:_,todayZero:()=>_({}),format:b,countdown:(e,t="")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;if(!r)return"";return v(r).toCountdown(t)},dtime:v,loopFrame:(e=500)=>new y(e),getTimezoneOffset:()=>w.timezoneOffset,getLocalTime:w.getLocalTime};const k="object"==typeof global&&null!==global&&global.Object===Object&&global,S="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis,$="object"==typeof self&&null!==self&&self.Object===Object&&self,A=S||k||$||Function("return this")(),C=A.Symbol,{toString:O,hasOwnProperty:j,propertyIsEnumerable:E}=Object.prototype,q=C?C.toStringTag:void 0;function P(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":q&&q in Object(e)?function(e){const t=j.call(e,q),r=e[q];let n=!1;try{e[q]=void 0,n=!0}catch(e){}const s=O.call(e);return n&&(t?e[q]=r:delete e[q]),s}(e):O.call(e)}var L={getTag:P,getType:function(e){return(P(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:O,hasOwnProperty:j,propertyIsEnumerable:E};const T="object"==typeof e&&null!==e&&!e.nodeType&&e,F=T&&"object"==typeof module&&null!==module&&!module.nodeType&&module,M=F&&F.exports===T&&k.process,R=(()=>{try{const e=F&&F.require&&F.require("util").types;return e||M&&M.binding&&M.binding("util")}catch(e){}})();var D="[object Function]",B="[object GeneratorFunction]",U="[object AsyncFunction]",I=9007199254740991;const z=/^(?:0|[1-9]\d*)$/,N=A?.Buffer?.isBuffer,K=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,H=R&&R.isTypedArray;function V(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function W(e){return null!=e&&"object"==typeof e}const Z=Array.isArray;function G(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=I}(e.length)&&!Y(e)}function J(e){return W(e)&&G(e)}function Y(e){var t=V(e)?L.getTag(e):"";return t===D||t===B||t===U}function Q(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)}function X(e){return J(e)&&L.hasOwnProperty.call(e,"callee")&&(!L.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==L.toString.call(e))}const ee="undefined"!=typeof window&&void 0!==window.document,te="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,re=H?e=>H(e):e=>W(e)&&K.test(L.getTag(e)),ne="function"==typeof N?N:()=>!1;var se={is:function(e,t){return L.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===L.getTag(e)},isString:function(e){return"string"==typeof e||!Z(e)&&W(e)&&"[object String]"==L.getTag(e)},isObject:V,isObjectLike:W,isPlainObject:function(e){if(!W(e)||"[object Object]"!=L.getTag(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t},isSymbol:function(e){return"symbol"==typeof e||W(e)&&"[object Symbol]"===L.getTag(e)},isFunction:Y,isArray:Z,isArrayLikeObject:J,isIndex:function(e,t){return!!(t=null==t?I:t)&&("number"==typeof e||z.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:G,isPrototype:Q,isArguments:X,isPromise:function(e){return"[object Promise]"===(V(e)?L.getTag(e):"")},isBrowser:ee,isNode:te,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer,isEmpty:e=>{if(null==e)return!0;if(G(e)&&(Array.isArray(e)||"string"==typeof e||"function"==typeof e.splice||ne(e)||re(e)||X(e)))return!e.length;const t=L.getTag(e);if("[object Map]"===t||"[object Set]"===t)return!e.size;if(Q(e))return!Object.keys(e).length;for(const t in e)if(L.hasOwnProperty.call(e,t))return!1;return!0}};const oe=NaN,ie=/^\s+|\s+$/g,ae=/^[-+]0x[0-9a-f]+$/i,ce=/^0b[01]+$/i,le=/^0o[0-7]+$/i,ue=parseInt,de=1/0,he=17976931348623157e292;function fe(e){if("number"==typeof e)return e;if(se.isSymbol(e))return oe;if(se.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=se.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(ie,"");const t=ce.test(e);return t||le.test(e)?ue(e.slice(2),t?2:8):ae.test(e)?oe:+e}function pe(e){return e?(e=fe(e))===de||e===-de?(e<0?-1:1)*he:e==e?e:0:0===e?e:0}var ge={toNumber:fe,toFinite:pe,toInteger:function(e){var t=pe(e),r=t%1;return t==t?r?t-r:t:0}};const ye="Expected a function",me=Math.max,we=Math.min;function be(e,t=300,r={}){let n,s,o,i,a,c,l=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError(ye);function f(t){const r=n,o=s;return n=s=void 0,l=t,i=e.apply(o,r),i}function p(e){const r=e-c;return void 0===c||r>=t||r<0||d&&e-l>=o}function g(){const e=Date.now();if(p(e))return y(e);a=setTimeout(g,function(e){const r=t-(e-c);return d?we(r,o-(e-l)):r}(e))}function y(e){return a=void 0,h&&n?f(e):(n=s=void 0,i)}function m(...e){const r=Date.now(),o=p(r);if(n=e,s=this,c=r,o){if(void 0===a)return function(e){return l=e,a=setTimeout(g,t),u?f(e):i}(c);if(d)return a=setTimeout(g,t),f(c)}return void 0===a&&(a=setTimeout(g,t)),i}return t=ge.toNumber(t)||0,se.isObject(r)&&(u=!!r.leading,d="maxWait"in r,o=d?me(ge.toNumber(r.maxWait)||0,t):o,h="trailing"in r?!!r.trailing:h),m.cancel=function(){void 0!==a&&clearTimeout(a),l=0,n=c=s=a=void 0},m.flush=function(){return void 0===a?i:y(Date.now())},m.pending=function(){return void 0!==a},m}class ve{__list=[];constructor(e){this.push(e)}push(e){return e&&this.__list.push(e),this}clear(){return this.__list=[],this}_exec(e,t){let r;if(se.isFunction(e))r=e(t);else{if(se.isPromise(e))return e.then((e=>({...t,...e})));r=e}return se.isPromise(r)?r:Promise.resolve({...r,...t})}run(e){try{return this.__list.reduce(((e,t)=>e.then((e=>this._exec(t,e)))),Promise.resolve(e)).then((e=>[void 0,e])).catch((e=>[e,void 0]))}catch(e){return Promise.reject([e,void 0])}}}async function _e(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const xe=e=>{try{let t;return t=se.isFunction(e)?e():e,_e(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var ke={to:_e,go:e=>xe(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:xe};class Se{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var $e={singleton:function(){class e{static __instance__;constructor(){}static get Instance(){return e.__instance__||(e.__instance__=new this),e.__instance__}static get I(){return this.Instance}}return e},getset:function(e){const t=new Se;return void 0!==e&&t.set(e),t}};class Ae{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return ke.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class Ce{__list=[];__count=0;__max=1;constructor(e=1){this.__count=0,this.__max=e>0?e:1,this.clear()}push(e,t){const r=new Ae(e,t);return this.__list.push(r),this._step(),this}clear(){return this.__list=[],this.__count=0,this}_step(){if(this.__list.length<=0)return;if(this.__count>=this.__max)return;const e=this.__list.shift();e?(this.__count+=1,e?.run().finally((()=>{try{this.__count>0&&(this.__count-=1),this._step()}catch(e){console.error("[ddan] pipepine step finally",e)}}))):this._step()}async whenAll(){for(;;){if(this.__count<=0)break;await ke.delay(100),this._step()}return this.clear()}}class Oe extends($e.singleton()){__lockedMap=new Map;pipeline=new Ce;constructor(){super()}lock(e,t){if(!e||!t)return;const r=ke.safeRun(t);return this.__lockedMap.set(e,r),r}unlock(e){e&&this.__lockedMap.has(e)&&this.__lockedMap.delete(e)}async exec(e,t){if(!e||!t)return ke.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return ke.safeRun(e);const s=await n;return this.unlock(t),s}}var je={...ke,sleep:ke.delay,run:async function(e,t=0){if(t<=0)return ke.safeRun(e);const r=t>0?Date.now():0,n=await ke.safeRun(e),s=Date.now()-r;return s<t&&await ke.delay(t-s),n},exec:(e,t="")=>Oe.I.exec(e,t),debounce:be,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return se.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),be(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new ve(e),mutex:function(e){var t=null;return async function(...r){if((t=this||t||{}).__ddMutex)return!1;t.__ddMutex=!0;try{e&&await Promise.resolve(e.apply(this,r))}catch(e){console.log(e)}finally{t.__ddMutex=!1}}},polling:async function(e={}){const{func:t,interval:r=100,times:n=1e3}=e;let s=n;const o=r<1?100:r;do{if(!t)break;const[e,r]=await ke.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await ke.delay(o)}while(-1===n||s>0)},pipe:(e,t)=>Oe.I.pipeline.push(e,t),pipeline:(e=1)=>new Ce(e),safeTask:(e,t)=>new Ae(e,t)};function Ee(e){return Math.floor(Math.random()*e)}function qe(e,t=10){return+parseFloat(Number(e).toExponential(t))}const Pe=180/Math.PI;var Le={random:Ee,randomRange:function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},lerp:function(e,t,r){return e*(1-r)+t*r},randoms:function(e,t=1,r=!1){const n=[];for(;;){if(n.length>=t)break;if(!r&&n.length>=e)break;const s=Ee(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:qe,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=qe(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*Pe},degree2radian:function(e){return e/Pe},formatMemory:function(e){let t=e;const r={g:0,m:0,kb:0,b:0,desc:""};return t>=1<<30&&(r.g=Math.floor(t/(1<<30)),t%=1<<30),t>=1<<20&&(r.m=Math.floor(t/(1<<20)),t%=1<<20),t>=1024&&(r.kb=Math.floor(t/1024),t%=1024),r.b=t,r.desc=e>=1<<30?(e/(1<<30)).toFixed(2)+"G":e>=1<<20?(e/(1<<20)).toFixed(2)+"M":e>=1024?(e/1024).toFixed(2)+"KB":e+"B",r}};function Te(e){return e!=e}function Fe(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,s=Array(n);++r<n;)s[r]=t(e[r],r,e);return s}(t,(function(t){return e[t]}))}var Me,Re,De=(Me=Object.keys,Re=Object,function(e){return Me(Re(e))}),Be=Math.max;function Ue(e,t){var r=se.isArray(e)||se.isArguments(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,s=!!n;for(var o in e)!t&&!L.hasOwnProperty.call(e,o)||s&&("length"==o||se.isIndex(o,n))||r.push(o);return r}function Ie(e,t,r){const{length:n}=e;return r=void 0===r?n:r,!t&&r>=n?e:function(e,t,r){let n=null==e?0:e.length;if(!n)return[];(t=null==t?0:t)<0&&(t=-t>n?0:n+t),(r=(r=void 0===r?n:r)>n?n:r)<0&&(r+=n),n=t>r?0:r-t>>>0,t>>>=0;let s=-1;const o=new Array(n);for(;++s<n;)o[s]=e[s+t];return o}(e,t,r)}const ze=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function Ne(e){return ze.test(e)}const Ke="\\ud800-\\udfff",He=`[${Ke}]`,Ve="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",We="\\ud83c[\\udffb-\\udfff]",Ze=`[^${Ke}]`,Ge="(?:\\ud83c[\\udde6-\\uddff]){2}",Je="[\\ud800-\\udbff][\\udc00-\\udfff]",Ye=`${`(?:${Ve}|${We})`}?`,Qe="[\\ufe0e\\ufe0f]?",Xe=Qe+Ye+`(?:\\u200d(?:${[Ze,Ge,Je].join("|")})${Qe+Ye})*`,et=`(?:${[`${Ze}${Ve}?`,Ve,Ge,Je,He].join("|")})`,tt=RegExp(`${We}(?=${We})|${et+Xe}`,"g");function rt(e){return Ne(e)?function(e){return e.match(tt)||[]}(e):function(e){return e.split("")}(e)}function nt(e){return t=>{if(!t)return"";const r=Ne(t)?rt(t):void 0,n=r?r[0]:t[0],s=r?Ie(r,1).join(""):t.slice(1);return n[e]()+s}}const st="\\ud800-\\udfff",ot="\\u2700-\\u27bf",it="a-z\\xdf-\\xf6\\xf8-\\xff",at="A-Z\\xc0-\\xd6\\xd8-\\xde",ct="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",lt="['’]",ut=`[${ct}]`,dt=`[${ot}]`,ht=`[${it}]`,ft=`[^${st}${ct+"\\d"+ot+it+at}]`,pt="(?:\\ud83c[\\udde6-\\uddff]){2}",gt="[\\ud800-\\udbff][\\udc00-\\udfff]",yt=`[${at}]`,mt=`(?:${ht}|${ft})`,wt=`(?:${yt}|${ft})`,bt=`(?:${lt}(?:d|ll|m|re|s|t|ve))?`,vt=`(?:${lt}(?:D|LL|M|RE|S|T|VE))?`,_t="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",xt="[\\ufe0e\\ufe0f]?",kt=xt+_t+`(?:\\u200d(?:${[`[^${st}]`,pt,gt].join("|")})${xt+_t})*`,St=`(?:${[dt,pt,gt].join("|")})${kt}`,$t=RegExp([`${yt}?${ht}+${bt}(?=${[ut,yt,"$"].join("|")})`,`${wt}+${vt}(?=${[ut,yt+mt,"$"].join("|")})`,`${yt}?${mt}+${bt}`,`${yt}+${vt}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",St].join("|"),"g");const At=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),Ct=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ot(e,t){if(void 0===t){const t=At(e)?function(e){return e.match($t)}(e):function(e){return e.match(Ct)}(e);return t||[]}return e.match(t)||[]}function jt(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:jt(e)))}`;if(se.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const Et=nt("toUpperCase"),qt=nt("toLowerCase");var Pt={toString:jt,startCase:e=>Ot(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+Et(t)),""),snakeCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?Et(t):t))),""),upperCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:Et,lowerCase:e=>Ot(jt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:qt,splitOnFirst:(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===e||""===t)return[];const r=e.indexOf(t);return-1===r?[]:[e.slice(0,r),e.slice(r+t.length)]},parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{let n=e;return e&&"string"==typeof e?(t&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?n=Number(e):!r||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(n="true"===e.toLowerCase()),n):n},replace:(e,t)=>{if(!e)return e;if(!t)return e;let r=e;return((Array.isArray(t)?t:[t])||[]).forEach((e=>{e.key&&e.value&&(r=r.replace(new RegExp(e.key,e.flag||""),e.value))})),r}};const Lt=e=>{if(!e)return e;if("object"!=typeof e)return e;const t=Array.isArray(e)?[]:{};for(const r in e)e.hasOwnProperty(r)&&(t[r]=Lt(e[r]));return t};const Tt=(e,t,r={})=>{const n=e||{},{ignoreUndefined:s=!0,cover:o=!1}=r;if(!t)return n;for(const i in t){if(!t.hasOwnProperty(i))continue;const a=t[i];"object"!=typeof a||"object"!=typeof e[i]||o?s&&void 0===a||r.ignoreNull&&null===a||r.ignoreZero&&0===a||r.ignoreEmptyArray&&Array.isArray(a)&&a.length<=0||r.ignoreEmptyString&&"string"==typeof a&&""===a.trim()||(n[i]=a):n[i]=Ft(e[i],a,r)}return n},Ft=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?Tt(e,t,r):Tt({...e},t,r),n},Mt=(e,t,r={})=>Tt({...e},t,{cover:!0,...r}),Rt=(e,t,r,n,s=!1)=>{if(!e||!t||!r)return;let o=e[t];null!==o&&"object"==typeof o&&s&&Object.keys(o).forEach((e=>{Rt(o,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:i=>{r.call(n,i,o),o=i,s&&Rt(e,t,r,n,s)},get:()=>o})};var Dt={copy:(e,t={})=>{if(void 0===e)return;const r=JSON.parse(JSON.stringify(e));if("object"!=typeof r)return r;if(Array.isArray(r))return r;const{fields:n=[],camel:s=!1,pure:o=!0}=t;if((!n||n.length<=0)&&!s)return r;const i={};for(const e in r){if(!r.hasOwnProperty(e))continue;const a=s?o&&e.startsWith("_")?e:Pt.camelCase(e):e;if(n.length>0&&!n.includes(e)&&!n.includes(a))continue;const c=r[e];t.ignoreNull&&null===c||(t.ignoreZero&&0===c||t.ignoreEmptyArray&&Array.isArray(c)&&c.length<=0||t.ignoreEmptyString&&"string"==typeof c&&""===c.trim()||(i[a]=c))}return i},clone:Lt,merge:Ft,isEmpty:e=>0!==e&&(!e||"object"==typeof e&&(Array.isArray(e)?!e.length:Object.keys(e).length<=0)),parseValue:(e,{number:t=!1,boolean:r=!1}={})=>{if(!e&&"object"!=typeof e)return e;for(const[n,s]of Object.entries(e))if("object"==typeof s&&null!==s)for(const[e,n]of Object.entries(s))s[e]=Pt.parseValue(n,{number:t,boolean:r});else e[n]=Pt.parseValue(s,{number:t,boolean:r});return e},cloneClass:function(e){return e?"object"!=typeof e?e:Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e)):e},combine:Mt,combines:(e,t={})=>{let r={};if(!e||e.length<=0)return r;const{ignoreUndefined:n=!0,ignoreNull:s=!0,ignoreZero:o=!0,ignoreEmptyArray:i=!0,ignoreEmptyString:a=!0,cover:c=!0}=t;return e.forEach((e=>r=Mt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:o,ignoreEmptyArray:i,ignoreEmptyString:a,cover:c}))),r},observe:Rt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var Bt={...se,...L,...Dt,...$e,includes:function(e,t,r,n){e=se.isArrayLike(e)?e:function(e){return e?Fe(e,function(e){return se.isArrayLike(e)?Ue(e):function(e){if(!se.isPrototype(e))return De(e);var t=[];for(var r in Object(e))L.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?ge.toInteger(r):0;var s=e.length;return r<0&&(r=Be(s+r,0)),se.isString(e)?r<=s&&e.indexOf(t,r)>-1:!!s&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var s=e.length,o=r+(n?1:-1);n?o--:++o<s;)if(t(e[o],o,e))return o;return-1}(e,Te,r);for(var n=r-1,s=e.length;++n<s;)if(e[n]===t)return n;return-1}(e,t,r)>-1},forof:(e,t)=>{if(!e)return;let r;if(se.isObject(e)&&(r=se.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var Ut={groupBy:function(e,t){return e.reduce(((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e)),{})},first:function(e){if(!e)return;return e.length<=0?void 0:e[0]},last:function(e){if(!e)return;const t=e.length;return t<=0?void 0:e[t-1]},toList:function(e){return Array.isArray(e)?e:e?[e]:[]}};var It={...Ut,stepAction:function(e,t,r=100){if(!se.isFunction(t))return;if(!se.isArray(e)||e.length<=0)return;let n=0;for(;e.length>n;){let s=r+n,o=e.slice(n,s);t&&t(o),n=s}},skip:function(e,t){if(!se.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!se.isArray(e)||e.length<=0)return[];const n=r||0;if(n>=e.length)return[];const s=t+n;return e.slice(n,e.length<s?e.length:s)||[]},distinct:function(e){return!se.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return Le.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!se.isObject(e))return;const s=e[t];(se.isString(s)&&""!==s||se.isNumber(s))&&(n[s]=e[r])})),n):n}};const zt="[object Object]",Nt="[object Array]",Kt=e=>Object.prototype.toString.call(e),Ht=(e,t,r=!1)=>{if(e===t)return;const n=Kt(e);if(n===Kt(t))if(n===Nt&&e.length>=t.length)for(let r=0;r<t.length;r++)Ht(e[r],t[r]);else if(n===zt&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?Ht(e[n],t[n]):e[n]=null},Vt=(e,t,r,n="",s=!1)=>{if(e===t)return;const o=Kt(e),i=Kt(t);if(o===Nt&&i===o&&e.length>=t.length)for(let s=0;s<e.length;s++)Vt(e[s],t[s],r,`${n}[${s}]`);else if(o===zt&&i===o&&(s||Object.keys(e).length>=Object.keys(t).length)){const s=Object.keys(e);for(let o of s){const s=e[o],i=t[o],a=Kt(s),c=Kt(i);if(s!==i)if(a===Nt&&c===a&&s.length>=i.length)for(let e=0;e<s.length;e++)Vt(s[e],i[e],r,`${n?n+".":""}${o}[${e}]`);else if(a===zt&&c===a&&Object.keys(s).length>=Object.keys(i).length)for(let e in s)Vt(s[e],i[e],r,`${n?n+".":""}${o}.${e}`);else r[`${n?n+".":""}${o}`]=s}}else r[n]=e};class Wt{list=[];constructor(){this.invoke=this.invoke.bind(this)}use(e){this.list=this.list.concat(e)}invoke(e){return this.list.reduce(((e,t)=>e.then((e=>t(e)))),Promise.resolve(e)).catch((e=>"REFETCH"===e.sig?Promise.resolve(e.result):Promise.reject(e)))}}class Zt{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new Wt,response:new Wt};constructor(e){const{reqConfig:t={},requestEncrypt:r,responseDecrypt:n,handleError:s,api:o}=e;this.reqConfig=t,this.handleEncrypt=r,this.handleDecrypt=n,this.handleError=s,this.handleRequest=o}static blockId="blockid";static requestLock={};lockR(e,t){Zt.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Zt.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}_fetch(e,t){let r=e;return t&&this.handleEncrypt&&(r=this.handleEncrypt(e)),new Promise(((e,n)=>{this.handleRequest({...r,success:r=>{let n=r;t&&this.handleDecrypt&&(n=this.handleDecrypt(r)),e(n)},fail:e=>{n(e)}})}))}async request(e,t){const r=Dt.copy(this.reqConfig[e]),{config:n,...s}=await this.interceptors.request.invoke({url:r.url,data:t||{},header:{"content-type":"application/json"},method:r.method?r.method:"POST",responseType:"text",config:r});let o;try{if("block"===n.model)this.lockR(Zt.blockId,(()=>this._fetch(s,n.hasEncrypt))),o=await Zt.requestLock[Zt.blockId].request;else if(Zt.requestLock[Zt.blockId]&&Zt.requestLock[Zt.blockId].lock&&await Zt.requestLock[Zt.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Zt.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),o=await Zt.requestLock[e].request,this.unlockR(e)}else o=await this._fetch(s,n.hasEncrypt)}catch(e){this.handleError&&this.handleError(e)}return this.interceptors.response.invoke({res:o,config:r,reqId:this.getIdFromReq(s),refetch:()=>({sig:"REFETCH",result:this.request(e,t||{})})})}}const Gt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Jt={diff:function(e,t){const r={};return(e=>{if(Kt(e)===zt)for(let t in e)if(/\w+\.\w+/g.test(t)&&-1===t.indexOf("[")){const r=t.split(".");let n=e,s=r.length;for(let e=0;e<s-1;e++){const t=r[e];Kt(n[t])!==zt&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),Ht(e,t,!0),Vt(e,t,r,"",!0),r},promixify:Gt,run:(e,t={})=>e?je.run(Gt(e)(t)):je.run(e),formatList:(e,t,r)=>(e||[]).reduce(((e,n,s)=>({...e,[`${r}[${t+s}]`]:n})),{}),ruleValidator:(e,t)=>!!t&&(!Array.isArray(t)||!(t.length<=0)&&t.every((e=>!!e))),Http:Zt,setWatcher:e=>{let t=e.data,r=e.watch;Object.keys(r).forEach((n=>{let s=t,o=n.split(".");for(let e=0;e<o.length-1;e++)s=s[o[e]];let i=o[o.length-1],a=r[n].handler||r[n],c=r[n].deep;Dt.observe(s,i,a,e,c)}))}};const Yt=function(e,{sep:t="&",eq:r="=",max:n=1e3,multiple:s=!0,uri:o=!0,parseNumber:i=!1,parseBoolean:a=!1}={}){t=t||"&",r=r||"=";const c={};if("string"!=typeof e||0===e.length)return c;const l=/\+/g,u=n||1e3;let d=(e=e.split(t)).length;u>0&&d>u&&(d=u);for(let t=0;t<d;++t){let n,i,a,u,d=e[t].replace(l,"%20"),h=d.indexOf(r);h>=0?(n=d.substr(0,h),i=d.substr(h+1)):(n=d,i=""),a=o?decodeURIComponent(n):n,u=o?decodeURIComponent(i):i,L.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(u):c[a]=[c[a],u]:c[a]=u}return Dt.parseValue(c,{number:i,boolean:a}),c},Qt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Xt=function(e,t=!0){return t?encodeURIComponent(e):e},er=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},tr=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,rr=e=>{const t=(e||"").replace(/\\/g,"/").split("?")[0],r=t.match(/[\/]?([\w\_\-]+)[.]?[\w]*[?]?$/),n=r?r[1]:"",s=t.lastIndexOf("/")+1,o=t.substring(s),i=o.lastIndexOf("."),a=o.substring(0,i)||"",c=i>=0?o.substring(i):"";return{route:t.substring(0,s)||"",page:n,name:o,withoutExtension:a,extname:c}},nr=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(tr);if(!r||r.length<4)return t;const n=r[3]||"",s=e.split("?");return t.url=s[0],t.origin=r[0],t.protocol=`${r[1]}:`,t.host=`${r[2]}${n?":"+n:""}`,t.port=n,t.query=s.length>1?s[1]:"",t};var sr={parse:Yt,stringify:function(e,{sep:t="&",eq:r="=",name:n=null,uri:s=!0,cleanZero:o=!1,cleanNull:i=!1,cleanWhitespace:a=!1}={}){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map((function(n){const c=Xt(Qt(n),s)+r,l=e[n];return Array.isArray(l)?l.map((function(e){return c+Xt(Qt(e),s)})).join(t):er(l,{cleanZero:o,cleanNull:i,cleanWhitespace:a})?"":c+Xt(Qt(l),s)})).filter(Boolean).join(t):n?Xt(Qt(n),s)+r+Xt(Qt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=nr(e),{origin:r="",url:n="",query:s=""}=t,o=rr(n),i=Yt(s,{multiple:!0,uri:!1});return{...t,...o,pathname:n.substring(n.indexOf(r||"")+r.length),params:i}},parsePath:rr,parseHost:nr,join:(...e)=>{let t=[];return e.forEach((e=>{const r=e.trim().replace(/^\/*(.*?)\/*$/,"$1");r.length<=0||(/^(\w+):\/\//.test(r)?t=[r]:t.push(r))})),t.join("/")}};const or=/%[sdj%]/g;let ir=()=>{};function ar(e){if(!e||!e.length)return null;const t={};return e.forEach((e=>{const r=e.field;t[r]=t[r]||[],t[r].push(e)})),t}function cr(e,...t){let r=0;const n=t.length;if("function"==typeof e)return e.apply(null,t);if("string"==typeof e){return e.replace(or,(e=>{if("%%"===e)return"%";if(r>=n)return e;switch(e){case"%s":return String(t[r++]);case"%d":return Number(t[r++]);case"%j":try{return JSON.stringify(t[r++])}catch(e){return"[Circular]"}break;default:return e}}))}return e}function lr(e,t){return null==e||(!("array"!==t||!Array.isArray(e)||e.length)||!(!function(e){return"string"===e||"url"===e||"hex"===e||"email"===e||"date"===e||"pattern"===e}(t)||"string"!=typeof e||e))}function ur(e,t,r){let n=0;const s=e.length;!function o(i){if(i&&i.length)return void r(i);const a=n;n+=1,a<s?t(e[a],o):r([])}([])}"undefined"!=typeof process&&process.env&&"production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&"undefined"!=typeof document&&(ir=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class dr extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function hr(e,t,r,n,s){if(t.first){const t=new Promise(((t,o)=>{const i=function(e){const t=[];return Object.keys(e).forEach((r=>{t.push(...e[r]||[])})),t}(e);ur(i,r,(e=>(n(e),e.length?o(new dr(e,ar(e))):t(s))))}));return t.catch((e=>e)),t}const o=!0===t.firstFields?Object.keys(e):t.firstFields||[],i=Object.keys(e),a=i.length;let c=0;const l=[],u=new Promise(((t,u)=>{const d=e=>{if(l.push.apply(l,e),c++,c===a)return n(l),l.length?u(new dr(l,ar(l))):t(s)};i.length||(n(l),t(s)),i.forEach((t=>{const n=e[t];-1!==o.indexOf(t)?ur(n,r,d):function(e,t,r){const n=[];let s=0;const o=e.length;function i(e){n.push(...e||[]),s++,s===o&&r(n)}e.forEach((e=>{t(e,i)}))}(n,r,d)}))}));return u.catch((e=>e)),u}function fr(e,t){return r=>{let n;return n=e.fullFields?function(e,t){let r=e;for(let e=0;e<t.length;e++){if(null==r)return r;r=r[t[e]]}return r}(t,e.fullFields):t[r.field||e.fullField],function(e){return!(!e||void 0===e.message)}(r)?(r.field=r.field||e.fullField,r.fieldValue=n,r):{message:"function"==typeof r?r():r,fieldValue:n,field:r.field||e.fullField}}}function pr(e,t){if(t)for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];"object"==typeof n&&"object"==typeof e[r]?e[r]={...e[r],...n}:e[r]=n}return e}const gr=(e,t,r,n,s,o)=>{!e.required||r.hasOwnProperty(e.field||"")&&!lr(t,o||e.type)||n.push(cr(s.messages.required,e.fullField))};let yr;const mr=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,wr=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,br={integer:e=>br.number(e)&&parseInt(e,10)===e,float:e=>br.number(e)&&!br.integer(e),array:e=>Array.isArray(e),regexp(e){if(e instanceof RegExp)return!0;try{return!!new RegExp(e)}catch(e){return!1}},date:e=>"function"==typeof e.getTime&&"function"==typeof e.getMonth&&"function"==typeof e.getYear&&!isNaN(e.getTime()),number:e=>!isNaN(e)&&"number"==typeof e,object:e=>"object"==typeof e&&!br.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(mr),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(yr)return yr;const e="[a-fA-F\\d:]",t=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${e})|(?<=${e})(?=\\s|$))`:"",r="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",n="[a-fA-F\\d]{1,4}",s=`\n(?:\n(?:${n}:){7}(?:${n}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${n}:){6}(?:${r}|:${n}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${n}:){5}(?::${r}|(?::${n}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${n}:){4}(?:(?::${n}){0,1}:${r}|(?::${n}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${n}:){3}(?:(?::${n}){0,2}:${r}|(?::${n}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${n}:){2}(?:(?::${n}){0,3}:${r}|(?::${n}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${n}:){1}(?:(?::${n}){0,4}:${r}|(?::${n}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${n}){0,5}:${r}|(?::${n}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),o=new RegExp(`(?:^${r}$)|(?:^${s}$)`),i=new RegExp(`^${r}$`),a=new RegExp(`^${s}$`),c=e=>e&&e.exact?o:new RegExp(`(?:${t(e)}${r}${t(e)})|(?:${t(e)}${s}${t(e)})`,"g");c.v4=e=>e&&e.exact?i:new RegExp(`${t(e)}${r}${t(e)}`,"g"),c.v6=e=>e&&e.exact?a:new RegExp(`${t(e)}${s}${t(e)}`,"g");const l=c.v4().source,u=c.v6().source;return yr=new RegExp(`(?:^(?:(?:(?:[a-z]+:)?//)|www\\.)(?:\\S+(?::\\S*)?@)?(?:localhost|${l}|${u}|(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:[/?#][^\\s"]*)?$)`,"i"),yr})()),hex:e=>"string"==typeof e&&!!e.match(wr)},vr="enum";var _r={required:gr,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(cr(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void gr(e,t,r,n,s);const o=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(o)>-1?br[o](t)||n.push(cr(s.messages.types[o],e.fullField,e.type)):o&&typeof t!==e.type&&n.push(cr(s.messages.types[o],e.fullField,e.type))},range:(e,t,r,n,s)=>{const o="number"==typeof e.len,i="number"==typeof e.min,a="number"==typeof e.max,c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;let l=t,u="";const d="number"==typeof t,h="string"==typeof t,f=Array.isArray(t);if(d?u="number":h?u="string":f&&(u="array"),!u)return!1;f&&(l=t.length),h&&(l=t.replace(c,"_").length),o?l!==e.len&&n.push(cr(s.messages[u].len,e.fullField,e.len)):i&&!a&&l<e.min?n.push(cr(s.messages[u].min,e.fullField,e.min)):a&&!i&&l>e.max?n.push(cr(s.messages[u].max,e.fullField,e.max)):i&&a&&(l<e.min||l>e.max)&&n.push(cr(s.messages[u].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[vr]=Array.isArray(e[vr])?e[vr]:[],-1===e[vr].indexOf(t)&&n.push(cr(s.messages[vr],e.fullField,e[vr].join(", ")))},pattern:(e,t,r,n,s)=>{if(e.pattern)if(e.pattern instanceof RegExp)e.pattern.lastIndex=0,e.pattern.test(t)||n.push(cr(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(cr(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const xr=(e,t,r,n,s)=>{const o=e.type,i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t,o)&&!e.required)return r();_r.required(e,t,n,i,s,o),lr(t,o)||_r.type(e,t,n,i,s)}r(i)};var kr={string:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(lr(t,"string")&&!e.required)return r();_r.required(e,t,n,o,s,"string"),lr(t,"string")||(_r.type(e,t,n,o,s),_r.range(e,t,n,o,s),_r.pattern(e,t,n,o,s),!0===e.whitespace&&_r.whitespace(e,t,n,o,s))}r(o)},method:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&_r.type(e,t,n,o,s)}r(o)},number:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(""===t&&(t=void 0),lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&(_r.type(e,t,n,o,s),_r.range(e,t,n,o,s))}r(o)},boolean:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&_r.type(e,t,n,o,s)}r(o)},regexp:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),lr(t)||_r.type(e,t,n,o,s)}r(o)},integer:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&(_r.type(e,t,n,o,s),_r.range(e,t,n,o,s))}r(o)},float:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&(_r.type(e,t,n,o,s),_r.range(e,t,n,o,s))}r(o)},array:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(null==t&&!e.required)return r();_r.required(e,t,n,o,s,"array"),null!=t&&(_r.type(e,t,n,o,s),_r.range(e,t,n,o,s))}r(o)},object:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&_r.type(e,t,n,o,s)}r(o)},enum:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s),void 0!==t&&_r.enum(e,t,n,o,s)}r(o)},pattern:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t,"string")&&!e.required)return r();_r.required(e,t,n,o,s),lr(t,"string")||_r.pattern(e,t,n,o,s)}r(o)},date:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t,"date")&&!e.required)return r();if(_r.required(e,t,n,o,s),!lr(t,"date")){let r;r=t instanceof Date?t:new Date(t),_r.type(e,r,n,o,s),r&&_r.range(e,r.getTime(),n,o,s)}}r(o)},url:xr,hex:xr,email:xr,required:(e,t,r,n,s)=>{const o=[],i=Array.isArray(t)?"array":typeof t;_r.required(e,t,n,o,s,i),r(o)},any:(e,t,r,n,s)=>{const o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(lr(t)&&!e.required)return r();_r.required(e,t,n,o,s)}r(o)}};function Sr(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone(){const e=JSON.parse(JSON.stringify(this));return e.clone=this.clone,e}}}const $r=Sr();class Ar{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");kr[e]=t};static warning=ir;static messages=$r;static validators=kr;rules={};_messages=$r;constructor(e){this.define(e)}define(e){if(!e)throw new Error("Cannot configure a schema with no rules");if("object"!=typeof e||Array.isArray(e))throw new Error("Rules must be an object");this.rules={},Object.keys(e).forEach((t=>{const r=e[t];this.rules[t]=Array.isArray(r)?r:[r]}))}messages(e){return e&&(this._messages=pr(Sr(),e)),this._messages}validate(e,t={},r=(()=>{})){let n=e,s=t,o=r;if("function"==typeof s&&(o=s,s={}),!this.rules||0===Object.keys(this.rules).length)return o&&o(null,n),Promise.resolve(n);if(s.messages){let e=this.messages();e===$r&&(e=Sr()),pr(e,s.messages),s.messages=e}else s.messages=this.messages();const i={};(s.keys||Object.keys(this.rules)).forEach((t=>{const r=this.rules[t];let s=n[t];r.forEach((r=>{let o=r;"function"==typeof o.transform&&(n===e&&(n={...n}),s=n[t]=o.transform(s)),o="function"==typeof o?{validator:o}:{...o},o.validator=this.getValidationMethod(o),o.validator&&(o.field=t,o.fullField=o.fullField||t,o.type=this.getType(o),i[t]=i[t]||[],i[t].push({rule:o,value:s,source:n,field:t}))}))}));const a={};return hr(i,s,((e,t)=>{const r=e.rule;let o,i=!("object"!==r.type&&"array"!==r.type||"object"!=typeof r.fields&&"object"!=typeof r.defaultField);function c(e,t){return{...t,fullField:`${r.fullField}.${e}`,fullFields:r.fullFields?[...r.fullFields,e]:[e]}}function l(o=[]){let l=Array.isArray(o)?o:[o];!0===s.suppressWarning&&l.length&&Ar.warning("async-validator:",l),l.length&&void 0!==r.message&&(l=[].concat(r.message));let u=l.map(fr(r,n));if(s.first&&u.length)return a[r.field]=1,t(u);if(i){if(r.required&&!e.value)return void 0!==r.message?u=[].concat(r.message).map(fr(r,n)):s.error&&(u=[s.error(r,cr(s.messages.required,r.field))]),t(u);let o={};r.defaultField&&Object.keys(e.value).map((e=>{o[e]=r.defaultField})),o={...o,...e.rule.fields};const i={};Object.keys(o).forEach((e=>{const t=o[e],r=Array.isArray(t)?t:[t];i[e]=r.map(c.bind(null,e))}));const a=new Ar(i);a.messages(s.messages),e.rule.options&&(e.rule.options.messages=s.messages,e.rule.options.error=s.error),a.validate(e.value,e.rule.options||s,(e=>{const r=[];u&&u.length&&r.push(...u),e&&e.length&&r.push(...e),t(r.length?r:null)}))}else t(u)}if(i=i&&(r.required||!r.required&&e.value),r.field=e.field,r.asyncValidator)o=r.asyncValidator(r,e.value,l,e.source,s);else if(r.validator){try{o=r.validator(r,e.value,l,e.source,s)}catch(e){console.error?.(e),s.suppressValidatorError||setTimeout((()=>{throw e}),0),l(e.message)}!0===o?l():!1===o?l("function"==typeof r.message?r.message(r.fullField||r.field):r.message||`${r.fullField||r.field} fails`):o instanceof Array?l(o):o instanceof Error&&l(o.message)}o&&o.then&&o.then((()=>l()),(e=>l(e)))}),(e=>{!function(e){let t=[],r={};for(let r=0;r<e.length;r++)s=e[r],Array.isArray(s)?t=t.concat(...s):t.push(s);var s;t.length?(r=ar(t),o(t,r)):o(null,n)}(e)}),n)}getType(e){if(void 0===e.type&&e.pattern instanceof RegExp&&(e.type="pattern"),"function"!=typeof e.validator&&e.type&&!kr.hasOwnProperty(e.type))throw new Error(cr("Unknown rule type %s",e.type));return e.type||"string"}getValidationMethod(e){if("function"==typeof e.validator)return e.validator;const t=Object.keys(e),r=t.indexOf("message");return-1!==r&&t.splice(r,1),1===t.length&&"required"===t[0]?kr.required:kr[this.getType(e)]||void 0}}function Cr(e){return new Ar(e)}var Or={validateId:function(e){return!!e&&(!(e.length<6)&&!!/^[A-Za-z0-9_-]+$/.test(e))},validatePhone:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)},validator:Cr,validate:function(e,t,r={},n=(()=>{})){return je.run(Cr(e).validate(t,r,n))},isChinese:function(e){return!!e&&!!/^[\u4E00-\u9FA5]+$/.test(e)},isNumber:function(e){return!!e&&!!/^[0-9]+$/.test(e)},isFloat:function(e){return!!e&&!!/^(\-|\+)?\d+(\.\d+)?$/.test(e)},isPhoneNumber:function(e){return!!e&&!!/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e)}};var jr={pattern:{num:"0-9",zh:"一-龥",en:"A-Za-z"},regex:(e,t)=>new RegExp(e,t),entire:{chinese:/^[\u4E00-\u9FA5]+$/,real:/^(\-|\+)?\d+(\.\d+)?$/,cssReal:/^(\-|\+)?\d*(\.)?\d+$/,id:/^[A-Za-z0-9]+$/,yyyyMMdd:/^(\d{4})-?(\d{2})-?(\d{2})$/}};var Er={toUtf8:e=>{if(!e)return"";const t=e.replace(/\r\n/g,"\n");let r="";for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r+=String.fromCharCode(n):n>127&&n<2048?(r+=String.fromCharCode(n>>6|192),r+=String.fromCharCode(63&n|128)):(r+=String.fromCharCode(n>>12|224),r+=String.fromCharCode(n>>6&63|128),r+=String.fromCharCode(63&n|128))}return r},fromUtf8:e=>{let t="",r=0;if(!e)return"";let n=0,s=0,o=0;for(;r<e.length;)n=e.charCodeAt(r),n<128?(t+=String.fromCharCode(n),r++):n>191&&n<224?(s=e.charCodeAt(r+1),t+=String.fromCharCode((31&n)<<6|63&s),r+=2):(s=e.charCodeAt(r+1),o=e.charCodeAt(r+2),t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&o),r+=3);return t},toUtf8Bytes:e=>{if(!e)return new Uint8Array;const t=e.replace(/\r\n/g,"\n"),r=[];for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);n<128?r.push(n):n<2048?(r.push(n>>6|192),r.push(63&n|128)):(r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128))}return new Uint8Array(r)},fromUtf8Bytes:e=>{let t="",r=0;if(!e||e.length<=0)return"";for(;r<e.length;){let n=e[r];if(n<128)t+=String.fromCharCode(n),r++;else if(n>191&&n<224){const s=e[r+1];t+=String.fromCharCode((31&n)<<6|63&s),r+=2}else{const s=e[r+1],o=e[r+2];t+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&o),r+=3}}return t}};const qr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var Pr={toBase64:(e="")=>{let t,r,n,s,o,i,a,c="",l=0;for(e=Er.toUtf8(e);l<e.length;)t=e.charCodeAt(l++),r=e.charCodeAt(l++),n=e.charCodeAt(l++),s=t>>2,o=(3&t)<<4|r>>4,i=(15&r)<<2|n>>6,a=63&n,isNaN(r)?i=a=64:isNaN(n)&&(a=64),c=c+qr.charAt(s)+qr.charAt(o)+qr.charAt(i)+qr.charAt(a);return c},fromBase64:(e="")=>{let t,r,n,s,o,i,a,c="",l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=qr.indexOf(e.charAt(l++)),o=qr.indexOf(e.charAt(l++)),i=qr.indexOf(e.charAt(l++)),a=qr.indexOf(e.charAt(l++)),t=s<<2|o>>4,r=(15&o)<<4|i>>2,n=(3&i)<<6|a,c+=String.fromCharCode(t),64!=i&&(c+=String.fromCharCode(r)),64!=a&&(c+=String.fromCharCode(n));return c=Er.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,o,i,a,c="",l=0;if(!e||!se.isArrayLike(e)||!se.isUint8Array(e))return"";for(;l<e.length;)t=e[l++],r=e[l++],n=e[l++],s=t>>2,o=(3&t)<<4|r>>4,i=(15&r)<<2|n>>6,a=63&n,isNaN(r)?i=a=64:isNaN(n)&&(a=64),c=c+qr.charAt(s)+qr.charAt(o)+qr.charAt(i)+qr.charAt(a);return c},base64ToBytes:(e="")=>{let t,r,n,s,o,i,a,c=[],l=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<e.length;)s=qr.indexOf(e.charAt(l++)),o=qr.indexOf(e.charAt(l++)),i=qr.indexOf(e.charAt(l++)),a=qr.indexOf(e.charAt(l++)),t=s<<2|o>>4,r=(15&o)<<4|i>>2,n=(3&i)<<6|a,c.push(t),64!=i&&c.push(r),64!=a&&c.push(n);return new Uint8Array(c)}};const Lr=e=>Pr.toBase64(e);var Tr={encode:Lr,decode:e=>Pr.fromBase64(e),encodeByOss:e=>Lr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Fr={...f,base64:Tr,uuid:p,guid:(e,t=!1,r="")=>{const n=p(e||32);return t?x.now().format("yyyyMMddhhmmss")+r+n:n},getHexString:e=>{const t=f.keyChars;let r="";const n=t.length;for(let s=0;s<e;s++)r+=t.charAt(Math.floor(Math.random()*n));return r}};const Mr=e=>{if(!e)return"";if(!Bt.isObject(e))return"";let t="";return Bt.forof(e,((e,r)=>{r&&(t+=`${Pt.kebabCase(e)}:${r};`)})),t},Rr=["display","position","top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","fontSize","textAlign","fontFamily","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius","background","backgroundImage","backgroundRepeat","backgroundSize","backgroundPosition","color","overflow","opacity","flexDirection","justifyContent","alignItems","flexWrap","alignContent","alignSelf","flex","flexBasis","flexFlow","flexShrink","pointerEvents"],Dr=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],Br=(e,t="px")=>e&&t?"0"===e?e:Or.isFloat(e.toString())?`${e}${t}`:e:e;var Ur={stringify:Mr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=sr.parse(e,{sep:";",eq:":",uri:!1}),s={};return Bt.forof(n,((e,n)=>{if(!n)return;const o=t?r&&e.startsWith("_")?e:Pt.camelCase(e):e;Or.isFloat(n)||n.length>=2&&n.startsWith(".")&&Or.isNumber(n.substr(1))?s[o]=+n:s[o]=n})),s},fixValue:Br,style:(e,t="px")=>{if(!e)return"";const r=Bt.copy(e,{fields:Rr});Bt.forof(r,((e,n)=>{(Dr.includes(e)||Dr.includes(Pt.camelCase(e)))&&(r[e]=Br(n,t))}));return Mr(r)},commonFields:Rr};const Ir=(e,t="",r=!1)=>{try{if(!e)return;const n=sr.parseUrl(e),s=t||n.name;if(!t||!r||!n.origin||n.origin===window.location.origin)((e,t)=>{try{const r=document.createElement("a");r.style.display="none",r.href=e,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}catch(t){console.error(`[ddan] _downloadUrl ${e}`,t)}})(e,s);else{const t=n.params;t.t=Date.now();const r=`${n.url}?${sr.stringify(t,{uri:!1})}`,o=new XMLHttpRequest;o.open("GET",r,!0),o.responseType="blob",o.onload=function(){zr(o.response,s)},o.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},o.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},zr=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;Ir(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},Nr=e=>{try{const t=document.createElement("textarea");document.body.appendChild(t),t.style.position="fixed",t.style.clip="rect(0 0 0 0)",t.style.top="10px",t.style.opacity="0",t.value=e??"",t.select();const r=document.execCommand("copy");return document.body.removeChild(t),r}catch(e){return console.error("[ddan] copyText",e),!1}},Kr=(e,t="denied")=>new Promise((r=>{const n=navigator?.permissions;if(!n||!n.query)return r(t);const s={name:e};n.query(s).then((e=>r(e.state))).catch((()=>r(t)))})),Hr=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Vr={dataURLtoFile:(e,t)=>{let r=e.split(","),n=r[0].match(/:(.*?);/)[1],s=window.atob(r[1]),o=s.length,i=new Uint8Array(o);for(;o--;)i[o]=s.charCodeAt(o);return new File([i],t,{type:n})},dataURLtoBlob:e=>{let t=e.split(","),r=t[0].match(/:(.*?);/)[1],n=window.atob(t[1]),s=n.length,o=new Uint8Array(s);for(;s--;)o[s]=n.charCodeAt(s);return new Blob([o],{type:r})},blobToFile:(e,t)=>(e.lastModifiedDate=new Date,e.name=t,e),readAsDataURL:(e,t)=>{var r=new FileReader;r.readAsDataURL(e),r.onloadend=function(e){t&&t(e.target?.result)}},downloadUrl:Ir,download:(e,t="")=>{e&&("string"!=typeof e?zr(e,t):Ir(e,t))},downloadFile:zr,downloadImage:e=>{try{if(!e)return;const t=e.match(/\/(\w+.\w+)$/)[1],r=new Image;r.onload=()=>{let e=document.createElement("canvas");e.width=r.width,e.height=r.height;let n=e.getContext("2d");n&&n.drawImage(r,0,0,r.width,r.height);let s=e.toDataURL();Ir(s,t)},r.src=e,r.setAttribute("crossOrigin","Anonymous")}catch(e){console.error("[ddan] downloadImage",e)}return Promise.resolve()},watermark:(e,{width:t=400,height:r=300,angle:n=0,fillStyle:s="rgba(0, 0, 0, 0.2)",font:o="16px Arial",textAlign:i="left",textBaseline:a="middle"}={})=>{try{if(!e)return"";const c=document.createElement("canvas");c.width=t,c.height=r;const l=c.getContext("2d");return l?(n&&l.rotate(n*Math.PI/180),s&&(l.fillStyle=s),o&&(l.font=o),i&&(l.textAlign=i),a&&(l.textBaseline=a),l.fillText(e,c.width/10,c.height/2),`url(${c.toDataURL()})`):""}catch(e){return console.error("[ddan] watermark",e),""}},copyText:(e,t=!1)=>new Promise((r=>{!t&&navigator.clipboard?Kr("clipboard-write").then((t=>{Hr(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(Nr(e)))):r(Nr(e))})).catch((()=>{r(Nr(e))})):r(Nr(e))})),queryPermission:Kr,isAllowed:Hr,legacyCopy:Nr};var Wr={ossImage:(e,t={})=>{if(!e)return e;const r=sr.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=It.toList(t.domain||""),n=e.match(/^http[s]?:\/\/([\w.]+)[\w\W]+/)[1]||"";if(!n||!r.includes(n))return e}const n=[];return t.webp&&!r.endsWith(".gif")&&n.push("format,webp"),t.resize&&n.push(`resize,s_${t.resize}`),t.interlace&&(n.push("interlace,1"),!n.every((e=>!e.startsWith("format")))||r.endsWith(".gif")||r.endsWith(".jpg")||n.push("format,jpg")),n.length<=0?e:`${r}?x-oss-process=image/${n.join("/")}`},ossSnapshot:(e,t={})=>{if(!e)return e;const r=sr.parseUrl(e).url,n=["snapshot"],{m:s="fast",f:o="jpg"}=t;return(t.t||0===t.t)&&n.push(`t_${t.t}`),t.w&&n.push(`w_${t.w}`),t.h&&n.push(`h_${t.h}`),s&&n.push(`m_${s}`),o&&n.push(`f_${o}`),t.ar&&n.push(`ar_${t.ar}`),`${r}?x-oss-process=video/${n.join(",")}`},ossBase64:e=>Pr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Zr={...Er,...Pr,str2Hex:e=>{let t="";for(let r=0;r<e.length;r++)t+=e.charCodeAt(r).toString(16).padStart(2,"0");return t},hex2Str:e=>{let t="";for(let r=0;r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},str2ab:(e="",t=!1)=>{if(t)return Pr.base64ToBytes(e).buffer;{const t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0,n=e.length;t<n;t++)r[t]=e.charCodeAt(t);return t}},ab2str:(e,t=!1)=>{const r=new Uint8Array(e);return t?Pr.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!se.isArrayLike(e))return"";return e.reduce(((e,t)=>e+String.fromCharCode(t)),"")},strToBytes:(e="")=>{const t=e,r=new Uint8Array(t.length);for(let e=0,n=t.length;e<n;e++)r[e]=t.charCodeAt(e);return r},utf8ToBase64:e=>se.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>se.isBrowser?atob(e):Buffer.from(e,"base64").toString("utf-8"),getRandomBytes:e=>{const t=new Uint8Array(e);for(let r=0;r<e;r++)t[r]=Le.random(256);return t},textEncode:e=>Er.toUtf8Bytes(e),textDecode:e=>Er.fromUtf8Bytes(new Uint8Array(e))};const Gr=({url:e,options:t})=>{const r={"Content-Type":"application/json; charset=utf-8",...t.headers||{}};return t.headers=r,new Promise(((r,n)=>{fetch(e,t).then((e=>{r(e.json())})).catch((e=>{n(e)}))}))};function Jr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Yr(e){const{url:t="",host:r,options:n}=e,s=e;if(t.startsWith("http://")||t.startsWith("https://")||(s.url=(r||"")+t),"GET"===n.method.toUpperCase()&&n.body){const e=JSON.parse(n.body);if(Bt.isPlainObject(e)){const r=sr.stringify(e),n=-1===t.indexOf("?")?"?":"&";s.url=`${s.url||""}${n}${r}`,delete s.options.body}}return n&&n.plugins&&delete s.options?.plugins,n&&n.model&&delete s.options?.model,s}class Qr{host="";reqConfig={};handleError;interceptors={request:new Wt,response:new Wt};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Yr),this.interceptors.response.use(e.handleResponse||Jr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Qr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Qr.requestLock[e]}getIdFromReq(e){const{url:t,data:r={}}=e;return t+JSON.stringify(r)}getIdFromReqUrl(e){return e.url||""}async fetch(e,t){const r=Bt.copy(this.reqConfig[e])||{},n={host:this.host,url:r.url||"",options:{...r||{},body:JSON.stringify({...t||{}})}};try{const s=await this.interceptors.request.invoke(n);let o;if(delete s.options.plugins,"block"===r.model)this.lockR(Qr.blockId,(()=>Gr(s))),o=await Qr.requestLock[Qr.blockId].request;else if(Qr.requestLock[Qr.blockId]&&Qr.requestLock[Qr.blockId].lock&&await Qr.requestLock[Qr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Qr.requestLock[e]||this.lockR(e,(()=>Gr(s))),o=await Qr.requestLock[e].request,this.unlockR(e)}else o=await Gr(s);return this.interceptors.response.invoke({response:o,config:r,refetch:()=>({sig:"REFETCH",result:this.fetch(e,t)})})}catch(e){return this.handleError&&this.handleError(e),Promise.reject(e)}}}const Xr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},en=e=>(...t)=>{const r=console[e];Xr.overrode?r(...t):tn(r,e,...t)},tn=(e,t,...r)=>{const n=x.format(new Date,Xr.format),s=Xr.tag?`[${t}]`:"";s&&n?e.apply(console,[`${n} ${s}`,...r]):n?e.apply(console,[`${n}`,...r]):s?e.apply(console,[`${s}`,...r]):e.apply(console,[...r])};var rn={override:()=>{if(Xr.overrode)return;Xr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{tn(t,e,...r)}}))},log:en("log"),info:en("info"),warn:en("warn"),error:en("error"),config:({tag:e=Xr.tag,format:t=Xr.format}={})=>{Xr.tag=e,Xr.format=t}};var nn={getDataURL:e=>{const t={contentType:"",dataUrl:""};return ke.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Zr.ab2str(e,!0),t))))},getArrayBuffer:async e=>ke.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>ke.to(fetch(e).then((e=>e.json()))),download:(e,t={})=>new Promise((r=>fetch(e).then((async e=>{if(!e.ok||200!==e.status)throw new Error(e.statusText);const n=+(e.headers.get("content-length")||""),s=e.body?.getReader();let o=0;const i=[];for(;;){const{done:e,value:r}=await s.read();if(e)break;i.push(r),o+=r.length;const a=Le.float(100*o/n,{digits:2});t?.progress&&t?.progress(a,o,n)}const a=new Uint8Array(o);let c=0;for(const e of i)a.set(e,c),c+=e.length;t?.success&&t?.success(a),r(a)})).catch((e=>{t?.fail&&t?.fail(e),r(void 0)}))))};const sn=new class{__defStyle="vertical-align: middle; mask-position: 50% 50%; mask-repeat: no-repeat; mask-size: 100%; -webkit-mask-position: 50% 50%; -webkit-mask-repeat: no-repeat; -webkit-mask-size: 100%; background-color: currentColor;";__map={back:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M609.408 149.376L277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"/></svg>',right:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"/></svg>',home:'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13 19.8h3.8v-7h3.303L12 4.697 3.897 12.8H7.2v7H11V17h2v2.8zm5 .2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-6H3.414a1 1 0 0 1-.707-1.707l8.586-8.586a1 1 0 0 1 1.414 0l8.586 8.586A1 1 0 0 1 20.586 14H18v6z" fill-rule="evenodd" fill-opacity=".9"/></svg>',close:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M764.288 214.592L512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"/></svg>',close_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M466.752 512l-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',close_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"/></svg>',warning:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M928.99 755.83L574.6 203.25c-12.89-20.16-36.76-32.58-62.6-32.58s-49.71 12.43-62.6 32.58L95.01 755.83c-12.91 20.12-12.9 44.91.01 65.03 12.92 20.12 36.78 32.51 62.59 32.49h708.78c25.82.01 49.68-12.37 62.59-32.49 12.91-20.12 12.92-44.91.01-65.03zM554.67 768h-85.33v-85.33h85.33V768zm0-426.67v298.66h-85.33V341.32l85.33.01z" fill="currentColor"/></svg>',play:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024A512 512 0 1 1 512 0a512 512 0 0 1 0 1024zm3.008-92.992a416 416 0 1 0 0-832 416 416 0 0 0 0 832zM383.232 287.616l384 224.896-384 223.104v-448z" fill="currentColor"/></svg>',lock:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M224 448a32 32 0 0 0-32 32v384a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V480a32 32 0 0 0-32-32H224zm0-64h576a96 96 0 0 1 96 96v384a96 96 0 0 1-96 96H224a96 96 0 0 1-96-96V480a96 96 0 0 1 96-96z"/><path fill="currentColor" d="M512 544a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V576a32 32 0 0 1 32-32zm192-160v-64a192 192 0 1 0-384 0v64h384zM512 64a256 256 0 0 1 256 256v128H256V320A256 256 0 0 1 512 64z"/></svg>',lock_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M467.2 713.92v115.968a44.8 44.8 0 0 0 89.6 0V713.92c26.752-14.72 44.8-42.304 44.8-73.92 0-47.104-40.128-85.312-89.6-85.312-49.472 0-89.6 38.208-89.6 85.312 0 31.616 18.048 59.136 44.8 73.92zM64 384h896v640H64V384zm268.8 0h358.4V256c0-94.272-80.256-170.688-179.2-170.688-98.944 0-179.2 76.416-179.2 170.688v128zM512 0c148.48 0 268.8 114.56 268.8 256v128H243.2V256C243.2 114.56 363.52 0 512 0z" fill="currentColor"/></svg>',plus:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"/></svg>',plus_circle:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M352 480h320a32 32 0 1 1 0 64H352a32 32 0 0 1 0-64z"/><path fill="currentColor" d="M480 672V352a32 32 0 1 1 64 0v320a32 32 0 0 1-64 0z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',plus_circle_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-38.4 409.6H326.4a38.4 38.4 0 1 0 0 76.8h147.2v147.2a38.4 38.4 0 0 0 76.8 0V550.4h147.2a38.4 38.4 0 0 0 0-76.8H550.4V326.4a38.4 38.4 0 1 0-76.8 0v147.2z"/></svg>',star:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 747.84l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72L512 747.84zM313.6 924.48a70.4 70.4 0 0 1-102.144-74.24l37.888-220.928L88.96 472.96A70.4 70.4 0 0 1 128 352.896l221.76-32.256 99.2-200.96a70.4 70.4 0 0 1 126.208 0l99.2 200.96 221.824 32.256a70.4 70.4 0 0 1 39.04 120.064L774.72 629.376l37.888 220.928a70.4 70.4 0 0 1-102.144 74.24L512 820.096l-198.4 104.32z"/></svg>',star_fill:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M283.84 867.84L512 747.776l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72z"/></svg>',share:'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M679.872 348.8l-301.76 188.608a127.808 127.808 0 0 1 5.12 52.16l279.936 104.96a128 128 0 1 1-22.464 59.904l-279.872-104.96a128 128 0 1 1-16.64-166.272l301.696-188.608a128 128 0 1 1 33.92 54.272z"/></svg>',love:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M171.712 571.648l.352.32 287.904 252.8a64 64 0 0 0 82.912 1.344l296.832-244.544a215.584 215.584 0 1 0-301.824-300.576L512 316.672l-25.888-35.616a215.584 215.584 0 1 0-314.4 290.624zM32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512l-295.36 243.392a128 128 0 0 1-165.888-2.592L129.984 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>',love_fill:'<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952L130.016 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>'};getBase64=e=>{const t=this.getSVG(e);return t?.url||""};getSVG=e=>{if(!e)return;const t=this.__map[e];if(!t)return;return{url:this.toBase64(t),escape:this.toEscape(t)}};toBase64=e=>{if(!e)return"";const t=this._tiny(e);return`data:image/svg+xml;base64,${Tr.encode(t)}`};_tiny=e=>e?e.replace(/<!--(.*)-->/g,"").replace(/[\r\n]/g," ").replace(/"/g,"'"):"";toEscape=e=>{if(!e)return"";return`data:image/svg+xml,${this._tiny(e).replace(/%/g,"%25").replace(/&/g,"%26").replace(/#/g,"%23").replace(/{/g,"%7B").replace(/}/g,"%7D").replace(/</g,"%3C").replace(/>/g,"%3E")}`};getStyle(e,t={}){if(!e)return"";const r=this.__map[e];return r?this.toStyle(r,t):""}toStyle(e,t={}){if(!e)return"";const r=this.toBase64(e);return r?this.getStyleByUrl(r,t):""}getStyleByUrl(e,t={}){if(!e)return"";const{key:r="mask-image",gradientValue:n="radial-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",gradient:s=!1,defStyle:o=this.__defStyle}=t,i=s&&n?`${n}, url("${e}")`:`url("${e}")`;return`${r}:${i};-webkit-${r}:${i};${o}`}},on=(e,t,r)=>({key:e,fields:t,storage:r});class an{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=je.debounce((e=>{if(this.key&&this.storage)try{const{setItem:t,setStorageSync:r}=this.storage;if(r)return r(this.key,e);if(t)return t(this.key,JSON.stringify(e))}catch(e){console.error("persit save ",e)}}));read(){if(this.key&&this.storage)try{const{getItem:e,getStorageSync:t}=this.storage;if(t)return t(this.key);if(e){const t=e(this.key);return JSON.parse(t)}}catch(e){return void console.error("persit read ",e)}}handleSave(e,t){if(!this.fields.includes(t)||!e)return;const r=Dt.copy(e,{fields:this.fields});this.save(r)}}class cn extends g{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!se.isFunction(n))return;const[,s]=await je.run(n({...r,commit:r.commit.bind(r),query:r.query.bind(r),dispatch:r.dispatch.bind(r)},t));return s}async query(e){const t=Reflect.get(this,e);let r;if(null!=t&&""!==t)r=Dt.copy(t);else{const[,t]=await je.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){se.isObject(t)&&(t=Dt.copy(t)),this[e]=t}}const ln=(e,t)=>{const r=Object.assign(new cn,e||{});r.__persist=new an(t||r.persist);const n=r.__persist.read(),s=n?Object.assign(r,n):r;return new Proxy(s,{get:(e,t,r)=>{const n=Reflect.get(e.getters,t);return se.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(se.isFunction(s)&&!s(e,r))return!0;const o=Reflect.set(e,t,r,n);return o&&(e.emit(t.toString(),r),e?.__persist?.handleSave(e,t.toString())),o},has:(e,t)=>Reflect.has(e,t)})};class un{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=sr.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const o=sr.stringify(s,{uri:!1});this.list.push(`${e}?${o}`)}_parseHost(e){e&&!this.host&&/^http[s]?:\/\/([\w.]+)/.test(e)&&(this.host=e.replace(/^http[s]?:\/\/([\w.]+)[\w\W]+/,"$1"))}image(e,t={}){if(!e||!e.includes(this.host))return;if(this.list.length<=0)return;const r={g:"nw",...t},n=e.replace(/^http[s]?:\/\/[\w.]+\/([\w-.,_/?%&=]+)$/,"$1"),s=Fr.base64.encodeByOss(n),o=sr.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${o}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=Fr.base64.encodeByOss(e),o=sr.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${o}`)}result(){return this.list.join("")}}const dn=(e,t)=>new un(e,t);class hn{__list=[];constructor(){this.clear()}add(e){const t=je.run(e);return this.__list.push(t),this}clear(){return this.__list=[],this}wait(){const e=this.__list;return this.clear(),Promise.allSettled(e)}}const fn=new class{state=ln(new cn);frame=new y;cache=new Map;cacheTime=new Map;setCache=(e,t)=>null!=t&&(!!e&&(this.cache.set(e,t),this.cacheTime.set(e,Date.now()),!0));hasCache=e=>{if(!e)return!1;this.cache.has(e)};getCache=e=>{if(e)return this.cache.get(e)};getCacheTime=e=>e&&this.cacheTime.get(e)||0;removeCache=e=>{e&&(this.cache.delete(e),this.cacheTime.delete(e))};cacheId=e=>`_${e}_cache_`;timesRecord=(e,t={})=>{if(!e)return;const{mode:r="running",cycle:n="day"}=t||{},s=this.cacheId(r),o=this.getCache(s)||{},i=Date.now(),a=o[e],c={time:i,count:1,cycle:n};return a&&("day"!==n||x.isToday(a.time||0))&&(c.count=1+(a.count||0)),o[e]=c,this.setCache(s,o),o};timesValid=(e,t={})=>{if(!e)return!1;const{max:r=1,interval:n=0,mode:s="running",cycle:o="day"}=t||{},i=this.cacheId(s);let a=this.getCache(i);if(!a)return!0;const c=a[e];if(!c)return!0;if("day"===o&&!x.isToday(c.time||0))return!0;if(r<=(c.count||0))return!1;return!(Date.now()-(c.time||0)<n)};timesClean=(e="running")=>{const t=this.cacheId(e),r=this.getCache(t);if(!r)return;const n=Bt.copy(r);Bt.forof(n,((e,t)=>{"day"!==t.cycle&&void 0!==t.cycle||x.isToday(t.time||0)||delete r[e]})),this.setCache(t,r)};parallel=()=>new hn};class pn{id="";start=0;end=0;cost=0;name="";type="";desc="";timeStartDesc="";timeEndDesc="";isDone=!1;flag=0;constructor(){this.id=p(),this.start=Date.now(),this.timeStartDesc=x.format(this.start,"hh:mm:ss.SSS")}get time(){return this.flag?this.end:this.start}get timeDesc(){return this.flag?this.timeEndDesc:this.timeStartDesc}done=(e=Date.now())=>{this.start&&(this.end=e,this.cost=this.end-this.start,this.timeEndDesc=x.format(this.end,"hh:mm:ss.SSS"),this.isDone=!0)}}const gn=new class{__map=new Map;__trackList=[];opened=!0;clear(){return this.__map.clear(),this.__trackList=[],this}add(e,{desc:t="",type:r=""}={}){if(!e||!this.opened)return"";const n=new pn;return n.name=e,n.type=r,n.desc=t,this.__trackList.push(n),n.id}done(e){if(!e||!this.opened)return;const t=this.__trackList.find((t=>t.id===e));if(!t||t.isDone)return;t.done();const r=Dt.cloneClass(t);r.id=this._endId(e),r.flag=1,r.desc=`${t.desc} | end`,this.__trackList.push(r)}getTrack(e){return this.__trackList.find((t=>t.id===e))}getLine(e){if(!e||e.endsWith("-end"))return[];const t=this.__trackList.findIndex((t=>t.id===e));if(t<0)return[];const r=this._endId(e),n=this.__trackList.findIndex((e=>e.id===r)),s=n<0?this.__trackList.length-t:n-t+1;return It.take(this.__trackList,s,t)}getList(e,t=""){if(!e)return[];const r=this.__trackList.filter((t=>t.name===e));if(r.length<=0)return[];if(!t)return r;const n=this._endId(t);return this.__trackList.filter((e=>e.id===t||e.id===n))}get list(){return this.__trackList}get size(){return this.__trackList.length}_endId=e=>`${e}-end`;report(e){const t=this.list;if(!t||t.length<=0)return;const r=t[0].time;t.forEach((t=>e&&e(t,r)))}},yn=e=>{try{const t=Zr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},mn=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var wn={generateKeys:async()=>{try{const e=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),t=await window.crypto.subtle.exportKey("spki",e.publicKey),r=yn(t),n=mn(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),o=yn(s);return{publicKey:r,publicKeyPem:n,privateKey:o,privateKeyPem:mn(o,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:mn,format_pem_content:yn,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Zr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Zr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Zr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Zr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["decrypt"]),s=await window.crypto.subtle.decrypt({name:"RSA-OAEP"},n,r);return(new TextDecoder).decode(s)}catch(e){return console.error("decrypt failed:",e),""}}};var bn={brotliCompress:function(e,t=i.default.constants.BROTLI_DEFAULT_QUALITY){try{if(!e)return"";const r=Buffer.from(e,"utf-8");return i.default.brotliCompressSync(r,{params:{[i.default.constants.BROTLI_PARAM_QUALITY]:t}}).toString("base64")}catch(t){return e||""}},brotliDecompress:function(e){try{if(!e)return"";const t=Buffer.from(e,"base64");return i.default.brotliDecompressSync(t).toString("utf-8")}catch(t){return e||""}}};const vn=a.default?.webcrypto?.subtle;var _n={...bn,Ecdh:class{publicKey="";privateKey="";sharedSecret;iv;_curve;_algorithm;_ecdh;constructor(e="prime256v1",t="aes-256-gcm"){this._curve=e,this._algorithm=t,this.generateKey()}generateKey(){const e=a.default.createECDH(this._curve);e.generateKeys(),this.publicKey=e.getPublicKey("base64"),this.privateKey=e.getPrivateKey("base64"),this._ecdh=e}deriveSharedSecret(e,t){if(e)return this.sharedSecret=this._ecdh.computeSecret(e,"base64").toString("base64"),this.iv=t,this}encode(e){if(!this.sharedSecret||!this.iv)return{text:"",authTag:"",iv:""};const t=a.default.createCipheriv("aes-256-gcm",Zr.base64ToBytes(this.sharedSecret),Zr.base64ToBytes(this.iv));return{text:t.update(e,"utf8","base64")+t.final("base64"),authTag:t.getAuthTag().toString("base64"),iv:this.iv}}decode(e,t,r){if(!(e&&this.sharedSecret&&r&&t))return"";const n=a.default.createDecipheriv("aes-256-gcm",Zr.base64ToBytes(this.sharedSecret),Zr.base64ToBytes(r));n.setAuthTag(Zr.base64ToBytes(t));return n.update(e,"base64","utf8")+n.final("utf8")}},EcdhSpki:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await vn.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await vn.exportKey("spki",e);return Zr.ab2str(t,!0)}async importSpkiKey(e){const t=Zr.base64ToBytes(e);return await vn.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await vn.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Zr.textEncode(e),r=await vn.encrypt({name:"AES-GCM",iv:Zr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Zr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Zr.str2ab(e,!0),n=await vn.decrypt({name:"AES-GCM",iv:Zr.base64ToBytes(t)},this.__sharedSecret,r);return Zr.textDecode(n)}},Socks5:class{upstreamProxy;server=null;clientSockets=new Set;allowedDomains;connectionPool={};systemProxy=null;useSystemProxy=!1;__debug=!1;__uuid;constructor(e,t=[],r=!1){this.upstreamProxy=e,this.allowedDomains=new Set(t),this.__debug=r,this.__uuid=p()}get id(){return this.__uuid}validateProxyConfig(e=this.upstreamProxy){const{ipaddress:t,port:r,userId:n,password:s}=e||{};return t&&"string"==typeof t?r&&"number"==typeof r?n&&"string"==typeof n?s&&"string"==typeof s?"":"无效的上游代理密码":"无效的上游代理用户名":"无效的上游代理端口":"无效的上游代理 IP 地址"}async start(e=9968){if(this.validateProxyConfig())return 0;if(this.server)return console.log("[socks] server is already running"),0;const t=await this.findAvailablePort(e);return t?(this.server=c.default.createServer((e=>this.handleSocksConnection(e))),this.server.listen(t,(()=>{this.__debug&&console.log(`[socks] server is running on port ${t}`)})),this.server.on("error",(e=>{console.error("[socks] server error:",e),this.close()})),t):t}setUpstreamProxy(e){return!!e&&(!this.validateProxyConfig(e)&&(this.upstreamProxy=e,!0))}setSystemProxy(e,t){this.useSystemProxy=e,e&&t&&t.ipaddress&&t.port&&(this.systemProxy=t)}setAllowedDomains(e=[]){this.allowedDomains=new Set(e)}async findAvailablePort(e,t=200){let r=e,n=0;for(;n<t;)try{return await new Promise(((e,t)=>{const n=c.default.createServer();n.unref(),n.on("error",t),n.listen(r,(()=>{n.close((()=>e()))}))})),r}catch{n++,r++}return console.warn("[socks] findAvailablePort failed"),0}async handleSocksConnection(e){this.clientSockets.add(e),e.on("close",(()=>{this.clientSockets.delete(e),e?.destroy()}));try{await this.performHandshake(e);const t=await this.parseClientRequest(e);if(this.isAllowedDomain(t.addr)){this.__debug&&console.log("[socks] handle connection upstream",t.addr);const r=await this.connectToUpstreamProxy(t);this.setupDataForwarding(e,r)}else if(this.useSystemProxy&&this.systemProxy){this.__debug&&console.log("[socks] handle connection system",t.addr);const r=await this.connectToSystemProxy(t);this.setupDataForwarding(e,r)}else{this.__debug&&console.log("[socks] handle connection local",t.addr);const r=await this.connectToLocal(t);this.setupDataForwarding(e,r)}}catch(t){console.error("[socks] connection failed:",t),e.end(new Uint8Array([5,1]))}}performHandshake(e){return new Promise(((t,r)=>{e.once("data",(n=>{if(5!==n[0])return r(new Error("Unsupported SOCKS version"));e.write(new Uint8Array([5,0])),t()}))}))}parseClientRequest(e){return new Promise(((t,r)=>{e.once("data",(e=>{let n,s;if(1!==e[1])return r(new Error("Unsupported command"));if(1===e[3])n=e.slice(4,8).join("."),s=e.readUInt16BE(8);else{if(3!==e[3])return r(new Error("Unsupported address type"));{const t=e[4];n=e.slice(5,5+t).toString(),s=e.readUInt16BE(5+t)}}t({addr:n,port:s})}))}))}getPoolConnection(e){if(e)return this.connectionPool[e]&&!this.connectionPool[e].destroyed?this.connectionPool[e]:void 0}async connectToUpstreamProxy(e){const t=`${e.addr}:${e.port}`,r=this.getPoolConnection(t);if(r)return r;const n={proxy:{...this.upstreamProxy,type:5},command:"connect",destination:{host:e.addr,port:e.port}};try{const{socket:e}=await s.SocksClient.createConnection(n);return this.connectionPool[t]=e,e.on("close",(()=>{delete this.connectionPool[t]})),e}catch(e){throw new Error("Failed to connect to upstream proxy: "+e)}}async connectToSystemProxy(e){const t=`${e.addr}:${e.port}`,r=this.getPoolConnection(t);if(r)return r;const n={proxy:{...this.systemProxy,type:5},command:"connect",destination:{host:e.addr,port:e.port}};try{const{socket:e}=await s.SocksClient.createConnection(n);return this.connectionPool[t]=e,e.on("close",(()=>{delete this.connectionPool[t]})),e}catch(e){throw new Error("Failed to connect to upstream proxy: "+e)}}async connectToLocal(e){const t=`${e.addr}:${e.port}`,r=this.getPoolConnection(t);return r||new Promise(((t,r)=>{const n=c.default.createConnection(e.port,e.addr,(()=>{t(n)}));n.on("error",(e=>{r(e)}))}))}setupDataForwarding(e,t){e.write(new Uint8Array([5,0,0,1,0,0,0,0,0,0])),e.pipe(t),t.pipe(e),e.on("close",(()=>{this.__debug&&console.error("[socks] client socket close",t?.remoteAddress),t.end()})),t.on("close",(()=>{this.__debug&&console.error("[socks] target socket close",t?.remoteAddress),e.end()})),e.on("error",(e=>{this.__debug&&console.error("[socks] client socket error:",e),t.end()})),t.on("error",(t=>{this.__debug&&console.error("[socks] target socket error:",t),e.end()}))}isAllowedDomain(e){for(const t of this.allowedDomains){if("*"===t)return!0;if(e.includes(t))return!0}return!1}close(){this.server&&(console.log("[socks] closing SOCKS5 proxy server..."),this.server.close((e=>{e&&console.error("[socks] closing the server failed:",e)})),this.clientSockets.forEach((e=>e.destroy())),Object.values(this.connectionPool).forEach((e=>e.destroy())),this.server=null)}}};var xn={Ecdh:class{publicKey="";iv="";__keyPair;__sharedSecret;__curve;constructor(e="P-256"){this.__curve=e}async generateKeys(e){const t=await window.crypto.subtle.generateKey({name:"ECDH",namedCurve:this.__curve},!0,["deriveKey","deriveBits"]);return this.__keyPair=t,this.publicKey=await this.exportSpkiKey(t.publicKey),this.iv=e,this}async exportSpkiKey(e){const t=await window.crypto.subtle.exportKey("spki",e);return Zr.ab2str(t,!0)}async importSpkiKey(e){const t=Zr.base64ToBytes(e);return await window.crypto.subtle.importKey("spki",t,{name:"ECDH",namedCurve:this.__curve},!0,[])}async deriveSharedSecret(e){if(!this.__keyPair)return this;const t=await this.importSpkiKey(e),r=await window.crypto.subtle.deriveKey({name:"ECDH",public:t},this.__keyPair.privateKey,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]);return this.__sharedSecret=r,this}async encode(e){if(!this.__sharedSecret||!this.iv)return{text:"",iv:""};const t=Zr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Zr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Zr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Zr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Zr.base64ToBytes(t)},this.__sharedSecret,r);return Zr.textDecode(n)}}};const kn={gbk:l,math:Le,list:It,string:Pt,time:x,obj:Dt,rule:Or,regex:jr,...Zr,...Fr,...Bt,Event:g},Sn={...Zr,...Fr,...je},$n={mini:Jt,css:Ur,qs:sr,icon:sn,html:Vr},An={cdn:Wr,watermark:dn},Cn={Store:cn,storeRef:ln,Persist:an,persistConfig:on},On=fn,jn=gn,En=rn,qn={fetch:nn,Http:Qr,css:Ur,qs:sr,icon:sn,html:Vr,rsa:wn,...xn},Pn={..._n};var Ln={gbk:l,time:x,hook:je,math:Le,util:Bt,list:It,string:Pt,obj:Dt,crypto:Fr,mini:Jt,qs:sr,css:Ur,cdn:Wr,html:Vr,icon:sn,rule:Or,regex:jr,convert:Zr,Event:g,Http:Qr,Store:cn,storeRef:ln,Persist:an,persistConfig:on,watermark:dn,joker:fn,tracker:gn,logger:rn,fetch:nn,rsa:wn};e.dCdn=An,e.dHook=Sn,e.dJoker=On,e.dLogger=En,e.dMini=$n,e.dNode=Pn,e.dStore=Cn,e.dTracker=jn,e.dUtil=kn,e.dWeb=qn,e.default=Ln,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -10,6 +10,8 @@ class Socks5 {
10
10
  clientSockets = new Set();
11
11
  allowedDomains;
12
12
  connectionPool = {};
13
+ systemProxy = null;
14
+ useSystemProxy = false;
13
15
  __debug = false;
14
16
  __uuid;
15
17
  constructor(upstreamProxy, allowedDomains = [], debug = false) {
@@ -65,6 +67,12 @@ class Socks5 {
65
67
  this.upstreamProxy = upstreamProxy;
66
68
  return true;
67
69
  }
70
+ setSystemProxy(use, config) {
71
+ this.useSystemProxy = use;
72
+ if (use && config && config.ipaddress && config.port) {
73
+ this.systemProxy = config;
74
+ }
75
+ }
68
76
  setAllowedDomains(allowedDomains = []) {
69
77
  this.allowedDomains = new Set(allowedDomains);
70
78
  }
@@ -101,14 +109,21 @@ class Socks5 {
101
109
  try {
102
110
  await this.performHandshake(clientSocket);
103
111
  const destination = await this.parseClientRequest(clientSocket);
104
- this.__debug && console.log(`[socks] handle connection`, destination.addr);
105
112
  if (this.isAllowedDomain(destination.addr)) {
106
- // 允许的域名,走上游代理
113
+ this.__debug && console.log(`[socks] handle connection upstream`, destination.addr);
114
+ // 走上游代理
107
115
  const upstreamSocket = await this.connectToUpstreamProxy(destination);
108
116
  this.setupDataForwarding(clientSocket, upstreamSocket);
109
117
  }
118
+ else if (this.useSystemProxy && this.systemProxy) {
119
+ this.__debug && console.log(`[socks] handle connection system`, destination.addr);
120
+ // 走系统代理
121
+ const systemSocket = await this.connectToSystemProxy(destination);
122
+ this.setupDataForwarding(clientSocket, systemSocket);
123
+ }
110
124
  else {
111
- // 不允许的域名,走本地连接
125
+ this.__debug && console.log(`[socks] handle connection local`, destination.addr);
126
+ // 本地连接
112
127
  const localSocket = await this.connectToLocal(destination);
113
128
  this.setupDataForwarding(clientSocket, localSocket);
114
129
  }
@@ -155,13 +170,21 @@ class Socks5 {
155
170
  });
156
171
  });
157
172
  }
173
+ getPoolConnection(key) {
174
+ if (!key)
175
+ return undefined;
176
+ // 如果已有连接在池中,复用
177
+ if (this.connectionPool[key] && !this.connectionPool[key].destroyed) {
178
+ return this.connectionPool[key];
179
+ }
180
+ return undefined;
181
+ }
158
182
  // 上游代理连接
159
183
  async connectToUpstreamProxy(destination) {
160
184
  const destKey = `${destination.addr}:${destination.port}`;
161
- // 如果已有连接在池中,复用
162
- if (this.connectionPool[destKey] && !this.connectionPool[destKey].destroyed) {
163
- return this.connectionPool[destKey];
164
- }
185
+ const cacheConnection = this.getPoolConnection(destKey);
186
+ if (cacheConnection)
187
+ return cacheConnection;
165
188
  const options = {
166
189
  proxy: { ...this.upstreamProxy, type: 5 },
167
190
  command: 'connect',
@@ -182,8 +205,38 @@ class Socks5 {
182
205
  throw new Error('Failed to connect to upstream proxy: ' + err);
183
206
  }
184
207
  }
208
+ // 上游代理连接
209
+ async connectToSystemProxy(destination) {
210
+ const destKey = `${destination.addr}:${destination.port}`;
211
+ const cacheConnection = this.getPoolConnection(destKey);
212
+ if (cacheConnection)
213
+ return cacheConnection;
214
+ const options = {
215
+ proxy: { ...this.systemProxy, type: 5 },
216
+ command: 'connect',
217
+ destination: {
218
+ host: destination.addr,
219
+ port: destination.port,
220
+ },
221
+ };
222
+ try {
223
+ const { socket: upstreamSocket } = await socks_1.SocksClient.createConnection(options);
224
+ this.connectionPool[destKey] = upstreamSocket;
225
+ upstreamSocket.on('close', () => {
226
+ delete this.connectionPool[destKey];
227
+ });
228
+ return upstreamSocket;
229
+ }
230
+ catch (err) {
231
+ throw new Error('Failed to connect to upstream proxy: ' + err);
232
+ }
233
+ }
185
234
  // 本地连接
186
- connectToLocal(destination) {
235
+ async connectToLocal(destination) {
236
+ const destKey = `${destination.addr}:${destination.port}`;
237
+ const cacheConnection = this.getPoolConnection(destKey);
238
+ if (cacheConnection)
239
+ return cacheConnection;
187
240
  return new Promise((resolve, reject) => {
188
241
  const localSocket = net_1.default.createConnection(destination.port, destination.addr, () => {
189
242
  resolve(localSocket);
@@ -198,9 +251,11 @@ class Socks5 {
198
251
  clientSocket.pipe(targetSocket);
199
252
  targetSocket.pipe(clientSocket);
200
253
  clientSocket.on('close', () => {
254
+ this.__debug && console.error('[socks] client socket close', targetSocket?.remoteAddress);
201
255
  targetSocket.end();
202
256
  });
203
257
  targetSocket.on('close', () => {
258
+ this.__debug && console.error('[socks] target socket close', targetSocket?.remoteAddress);
204
259
  clientSocket.end();
205
260
  });
206
261
  clientSocket.on('error', (err) => {
@@ -2,8 +2,8 @@ interface IProxyConfig {
2
2
  ipaddress: string;
3
3
  port: number;
4
4
  type?: 5;
5
- userId: string;
6
- password: string;
5
+ userId?: string;
6
+ password?: string;
7
7
  }
8
8
  export declare class Socks5 {
9
9
  private upstreamProxy;
@@ -11,6 +11,8 @@ export declare class Socks5 {
11
11
  private clientSockets;
12
12
  private allowedDomains;
13
13
  private connectionPool;
14
+ private systemProxy;
15
+ private useSystemProxy;
14
16
  __debug: boolean;
15
17
  __uuid: string;
16
18
  constructor(upstreamProxy: IProxyConfig, allowedDomains?: string[], debug?: boolean);
@@ -18,12 +20,15 @@ export declare class Socks5 {
18
20
  validateProxyConfig(proxyConfig?: IProxyConfig): "" | "无效的上游代理 IP 地址" | "无效的上游代理端口" | "无效的上游代理用户名" | "无效的上游代理密码";
19
21
  start(startPort?: number): Promise<number>;
20
22
  setUpstreamProxy(upstreamProxy: IProxyConfig): boolean;
23
+ setSystemProxy(use: boolean, config?: IProxyConfig): void;
21
24
  setAllowedDomains(allowedDomains?: string[]): void;
22
25
  private findAvailablePort;
23
26
  private handleSocksConnection;
24
27
  private performHandshake;
25
28
  private parseClientRequest;
29
+ private getPoolConnection;
26
30
  private connectToUpstreamProxy;
31
+ private connectToSystemProxy;
27
32
  private connectToLocal;
28
33
  private setupDataForwarding;
29
34
  private isAllowedDomain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "2.6.22",
3
+ "version": "2.6.24",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",