ddan-js 2.6.17 → 2.6.18
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.
- package/bin/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/modules/node/index.js +2 -1
- package/bin/lib/modules/node/sockServer.js +224 -0
- package/bin/types/index.d.ts +1 -0
- package/bin/types/modules/node/index.d.ts +2 -0
- package/bin/types/modules/node/sockServer.d.ts +28 -0
- package/package.json +4 -1
package/bin/ddan-js.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"zlib";import t from"node:crypto";var r={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 n="0123456789",s="abcdefghijklmnopqrstuvwxyz",i="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var o={keyNumber:n,keyLower:s,keyUpper:i,keyChars:n+s+i};const a=(e=0,t=0)=>{const r=o.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 c{__map;__tagList;__eventId="";constructor(){this.__map=new Map,this.__tagList=[],this.__eventId=a()}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 u{_loopTimer;_event=new c;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 l={oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};class h{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/l.oneSecond);let r=t.countdown;t.d=Math.floor(r/l.oneDay),t.dd=(t.d<10?"0":"")+t.d,r%=l.oneDay,t.h=Math.floor(r/l.oneHour),t.hh=(t.h<10?"0":"")+t.h,r%=l.oneHour,t.m=Math.floor(r/l.oneMinute),t.mm=(t.m<10?"0":"")+t.m,r%=l.oneMinute,t.s=Math.floor(r/l.oneSecond),t.ss=(t.s<10?"0":"")+t.s,r%=l.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>l.oneHour?"hh:mm:ss":t.countdown>l.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 f=(e,t="yyyy-MM-dd hh:mm:ss")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;return r?d(r).format(t):""},d=e=>{const t="string"==typeof e||"number"==typeof e?new Date(e):e;return new h(t||0)};function p({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(f(Date.now(),o)).getTime()}var g={...l,now:function(){return d(new Date)},isToday:e=>e&&(new Date).toDateString()===new Date(e).toDateString(),parseTimestamp:p,todayZero:()=>p({}),format:f,countdown:(e,t="")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;if(!r)return"";return d(r).toCountdown(t)},dtime:d,loopFrame:(e=500)=>new u(e),getTimezoneOffset:()=>h.timezoneOffset,getLocalTime:h.getLocalTime},y="object"==typeof global&&global&&global.Object===Object&&global,m="object"==typeof self&&self&&self.Object===Object&&self;const w=(y||m||Function("return this")()).Symbol,{toString:b,hasOwnProperty:v,propertyIsEnumerable:_}=Object.prototype,x=w?w.toStringTag:void 0;function S(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":x&&x in Object(e)?function(e){const t=v.call(e,x),r=e[x];let n=!1;try{e[x]=void 0,n=!0}catch(e){}const s=b.call(e);return n&&(t?e[x]=r:delete e[x]),s}(e):b.call(e)}var k={getTag:S,getType:function(e){return(S(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:b,hasOwnProperty:v,propertyIsEnumerable:_},$="[object Function]",A="[object GeneratorFunction]",C="[object AsyncFunction]",O=9007199254740991;const q=/^(?:0|[1-9]\d*)$/;function E(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function j(e){return null!=e&&"object"==typeof e}const L=Array.isArray;function T(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=O}(e.length)&&!M(e)}function F(e){return j(e)&&T(e)}function M(e){var t=E(e)?k.getTag(e):"";return t===$||t===A||t===C}const R="undefined"!=typeof window&&void 0!==window.document,P="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;var B={is:function(e,t){return k.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===k.getTag(e)},isString:function(e){return"string"==typeof e||!L(e)&&j(e)&&"[object String]"==k.getTag(e)},isObject:E,isObjectLike:j,isPlainObject:function(e){if(!j(e)||"[object Object]"!=k.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||j(e)&&"[object Symbol]"===k.getTag(e)},isFunction:M,isArray:L,isArrayLikeObject:F,isIndex:function(e,t){return!!(t=null==t?O:t)&&("number"==typeof e||q.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:T,isPrototype:function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)},isArguments:function(e){return F(e)&&k.hasOwnProperty.call(e,"callee")&&(!k.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==k.toString.call(e))},isPromise:function(e){return"[object Promise]"===(E(e)?k.getTag(e):"")},isBrowser:R,isNode:P,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer};const D=NaN,I=/^\s+|\s+$/g,z=/^[-+]0x[0-9a-f]+$/i,U=/^0b[01]+$/i,N=/^0o[0-7]+$/i,K=parseInt,H=1/0,V=17976931348623157e292;function W(e){if("number"==typeof e)return e;if(B.isSymbol(e))return D;if(B.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=B.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(I,"");const t=U.test(e);return t||N.test(e)?K(e.slice(2),t?2:8):z.test(e)?D:+e}function Z(e){return e?(e=W(e))===H||e===-H?(e<0?-1:1)*V:e==e?e:0:0===e?e:0}var G={toNumber:W,toFinite:Z,toInteger:function(e){var t=Z(e),r=t%1;return t==t?r?t-r:t:0}};const J="Expected a function",Y=Math.max,Q=Math.min;function X(e,t=300,r={}){let n,s,i,o,a,c,u=0,l=!1,h=!1,f=!0;if("function"!=typeof e)throw new TypeError(J);function d(t){const r=n,i=s;return n=s=void 0,u=t,o=e.apply(i,r),o}function p(e){const r=e-c;return void 0===c||r>=t||r<0||h&&e-u>=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?Q(r,i-(e-u)):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 u=e,a=setTimeout(g,t),l?d(e):o}(c);if(h)return a=setTimeout(g,t),d(c)}return void 0===a&&(a=setTimeout(g,t)),o}return t=G.toNumber(t)||0,B.isObject(r)&&(l=!!r.leading,h="maxWait"in r,i=h?Y(G.toNumber(r.maxWait)||0,t):i,f="trailing"in r?!!r.trailing:f),m.cancel=function(){void 0!==a&&clearTimeout(a),u=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 ee{__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(B.isFunction(e))r=e(t);else{if(B.isPromise(e))return e.then((e=>({...t,...e})));r=e}return B.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 te(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const re=e=>{try{let t;return t=B.isFunction(e)?e():e,te(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var ne={to:te,go:e=>re(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:re};class se{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var ie={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 oe{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return ne.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class ae{__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 oe(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 ne.delay(100),this._step()}return this.clear()}}class ce extends(ie.singleton()){__lockedMap=new Map;pipeline=new ae;constructor(){super()}lock(e,t){if(!e||!t)return;const r=ne.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 ne.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return ne.safeRun(e);const s=await n;return this.unlock(t),s}}var ue={...ne,sleep:ne.delay,run:async function(e,t=0){if(t<=0)return ne.safeRun(e);const r=t>0?Date.now():0,n=await ne.safeRun(e),s=Date.now()-r;return s<t&&await ne.delay(t-s),n},exec:(e,t="")=>ce.I.exec(e,t),debounce:X,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return B.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),X(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new ee(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 ne.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await ne.delay(i)}while(-1===n||s>0)},pipe:(e,t)=>ce.I.pipeline.push(e,t),pipeline:(e=1)=>new ae(e),safeTask:(e,t)=>new oe(e,t)};function le(e){return Math.floor(Math.random()*e)}function he(e,t=10){return+parseFloat(Number(e).toExponential(t))}const fe=180/Math.PI;var de={random:le,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=le(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:he,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=he(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*fe},degree2radian:function(e){return e/fe},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 pe(e){return e!=e}function ge(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 ye,me,we=(ye=Object.keys,me=Object,function(e){return ye(me(e))}),be=Math.max;function ve(e,t){var r=B.isArray(e)||B.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&&!k.hasOwnProperty.call(e,i)||s&&("length"==i||B.isIndex(i,n))||r.push(i);return r}function _e(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 xe=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function Se(e){return xe.test(e)}const ke="\\ud800-\\udfff",$e=`[${ke}]`,Ae="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Ce="\\ud83c[\\udffb-\\udfff]",Oe=`[^${ke}]`,qe="(?:\\ud83c[\\udde6-\\uddff]){2}",Ee="[\\ud800-\\udbff][\\udc00-\\udfff]",je=`${`(?:${Ae}|${Ce})`}?`,Le="[\\ufe0e\\ufe0f]?",Te=Le+je+`(?:\\u200d(?:${[Oe,qe,Ee].join("|")})${Le+je})*`,Fe=`(?:${[`${Oe}${Ae}?`,Ae,qe,Ee,$e].join("|")})`,Me=RegExp(`${Ce}(?=${Ce})|${Fe+Te}`,"g");function Re(e){return Se(e)?function(e){return e.match(Me)||[]}(e):function(e){return e.split("")}(e)}function Pe(e){return t=>{if(!t)return"";const r=Se(t)?Re(t):void 0,n=r?r[0]:t[0],s=r?_e(r,1).join(""):t.slice(1);return n[e]()+s}}const Be="\\ud800-\\udfff",De="\\u2700-\\u27bf",Ie="a-z\\xdf-\\xf6\\xf8-\\xff",ze="A-Z\\xc0-\\xd6\\xd8-\\xde",Ue="\\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",Ne="['’]",Ke=`[${Ue}]`,He=`[${De}]`,Ve=`[${Ie}]`,We=`[^${Be}${Ue+"\\d"+De+Ie+ze}]`,Ze="(?:\\ud83c[\\udde6-\\uddff]){2}",Ge="[\\ud800-\\udbff][\\udc00-\\udfff]",Je=`[${ze}]`,Ye=`(?:${Ve}|${We})`,Qe=`(?:${Je}|${We})`,Xe=`(?:${Ne}(?:d|ll|m|re|s|t|ve))?`,et=`(?:${Ne}(?:D|LL|M|RE|S|T|VE))?`,tt="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",rt="[\\ufe0e\\ufe0f]?",nt=rt+tt+`(?:\\u200d(?:${[`[^${Be}]`,Ze,Ge].join("|")})${rt+tt})*`,st=`(?:${[He,Ze,Ge].join("|")})${nt}`,it=RegExp([`${Je}?${Ve}+${Xe}(?=${[Ke,Je,"$"].join("|")})`,`${Qe}+${et}(?=${[Ke,Je+Ye,"$"].join("|")})`,`${Je}?${Ye}+${Xe}`,`${Je}+${et}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",st].join("|"),"g");const ot=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 ]/),at=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ct(e,t){if(void 0===t){const t=ot(e)?function(e){return e.match(it)}(e):function(e){return e.match(at)}(e);return t||[]}return e.match(t)||[]}function ut(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:ut(e)))}`;if(B.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const lt=Pe("toUpperCase"),ht=Pe("toLowerCase");var ft={toString:ut,startCase:e=>ct(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+lt(t)),""),snakeCase:e=>ct(ut(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>ct(ut(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>ct(ut(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?lt(t):t))),""),upperCase:e=>ct(ut(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:lt,lowerCase:e=>ct(ut(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:ht,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 dt=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]=dt(e[r]));return t};const pt=(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]=gt(e[o],a,r)}return n},gt=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?pt(e,t,r):pt({...e},t,r),n},yt=(e,t,r={})=>pt({...e},t,{cover:!0,...r}),mt=(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=>{mt(i,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:o=>{r.call(n,o,i),i=o,s&&mt(e,t,r,n,s)},get:()=>i})};var wt={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:ft.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:dt,merge:gt,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]=ft.parseValue(n,{number:t,boolean:r});else e[n]=ft.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:yt,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=yt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:i,ignoreEmptyArray:o,ignoreEmptyString:a,cover:c}))),r},observe:mt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var bt={...B,...k,...wt,...ie,includes:function(e,t,r,n){e=B.isArrayLike(e)?e:function(e){return e?ge(e,function(e){return B.isArrayLike(e)?ve(e):function(e){if(!B.isPrototype(e))return we(e);var t=[];for(var r in Object(e))k.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?G.toInteger(r):0;var s=e.length;return r<0&&(r=be(s+r,0)),B.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,pe,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(B.isObject(e)&&(r=B.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var vt={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 _t={...vt,stepAction:function(e,t,r=100){if(!B.isFunction(t))return;if(!B.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(!B.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!B.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!B.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return de.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!B.isObject(e))return;const s=e[t];(B.isString(s)&&""!==s||B.isNumber(s))&&(n[s]=e[r])})),n):n}};const xt="[object Object]",St="[object Array]",kt=e=>Object.prototype.toString.call(e),$t=(e,t,r=!1)=>{if(e===t)return;const n=kt(e);if(n===kt(t))if(n===St&&e.length>=t.length)for(let r=0;r<t.length;r++)$t(e[r],t[r]);else if(n===xt&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?$t(e[n],t[n]):e[n]=null},At=(e,t,r,n="",s=!1)=>{if(e===t)return;const i=kt(e),o=kt(t);if(i===St&&o===i&&e.length>=t.length)for(let s=0;s<e.length;s++)At(e[s],t[s],r,`${n}[${s}]`);else if(i===xt&&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===St&&c===a&&s.length>=o.length)for(let e=0;e<s.length;e++)At(s[e],o[e],r,`${n?n+".":""}${i}[${e}]`);else if(a===xt&&c===a&&Object.keys(s).length>=Object.keys(o).length)for(let e in s)At(s[e],o[e],r,`${n?n+".":""}${i}.${e}`);else r[`${n?n+".":""}${i}`]=s}}else r[n]=e};class Ct{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 Ot{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new Ct,response:new Ct};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){Ot.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Ot.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=wt.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(Ot.blockId,(()=>this._fetch(s,n.hasEncrypt))),i=await Ot.requestLock[Ot.blockId].request;else if(Ot.requestLock[Ot.blockId]&&Ot.requestLock[Ot.blockId].lock&&await Ot.requestLock[Ot.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Ot.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),i=await Ot.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 qt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Et={diff:function(e,t){const r={};return(e=>{if(kt(e)===xt)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])!==xt&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),$t(e,t,!0),At(e,t,r,"",!0),r},promixify:qt,run:(e,t={})=>e?ue.run(qt(e)(t)):ue.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:Ot,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;wt.observe(s,o,a,e,c)}))}};const jt=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 u=/\+/g,l=n||1e3;let h=(e=e.split(t)).length;l>0&&h>l&&(h=l);for(let t=0;t<h;++t){let n,o,a,l,h=e[t].replace(u,"%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,l=i?decodeURIComponent(o):o,k.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(l):c[a]=[c[a],l]:c[a]=l}return wt.parseValue(c,{number:o,boolean:a}),c},Lt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Tt=function(e,t=!0){return t?encodeURIComponent(e):e},Ft=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},Mt=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,Rt=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}},Pt=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(Mt);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 Bt={parse:jt,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=Tt(Lt(n),s)+r,u=e[n];return Array.isArray(u)?u.map((function(e){return c+Tt(Lt(e),s)})).join(t):Ft(u,{cleanZero:i,cleanNull:o,cleanWhitespace:a})?"":c+Tt(Lt(u),s)})).filter(Boolean).join(t):n?Tt(Lt(n),s)+r+Tt(Lt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=Pt(e),{origin:r="",url:n="",query:s=""}=t,i=Rt(n),o=jt(s,{multiple:!0,uri:!1});return{...t,...i,pathname:n.substring(n.indexOf(r||"")+r.length),params:o}},parsePath:Rt,parseHost:Pt,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 Dt=/%[sdj%]/g;let It=()=>{};function zt(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 Ut(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(Dt,(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 Nt(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 Kt(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&&(It=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class Ht extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function Vt(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);Kt(o,r,(e=>(n(e),e.length?i(new Ht(e,zt(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 u=[],l=new Promise(((t,l)=>{const h=e=>{if(u.push.apply(u,e),c++,c===a)return n(u),u.length?l(new Ht(u,zt(u))):t(s)};o.length||(n(u),t(s)),o.forEach((t=>{const n=e[t];-1!==i.indexOf(t)?Kt(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 l.catch((e=>e)),l}function Wt(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 Zt(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 Gt=(e,t,r,n,s,i)=>{!e.required||r.hasOwnProperty(e.field||"")&&!Nt(t,i||e.type)||n.push(Ut(s.messages.required,e.fullField))};let Jt;const Yt=/^(([^<>()\[\]\\.,;:\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,}))$/,Qt=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,Xt={integer:e=>Xt.number(e)&&parseInt(e,10)===e,float:e=>Xt.number(e)&&!Xt.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&&!Xt.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(Yt),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(Jt)return Jt;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 u=c.v4().source,l=c.v6().source;return Jt=new RegExp(`(?:^(?:(?:(?:[a-z]+:)?//)|www\\.)(?:\\S+(?::\\S*)?@)?(?:localhost|${u}|${l}|(?:(?:[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"),Jt})()),hex:e=>"string"==typeof e&&!!e.match(Qt)},er="enum";var tr={required:Gt,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(Ut(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void Gt(e,t,r,n,s);const i=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(i)>-1?Xt[i](t)||n.push(Ut(s.messages.types[i],e.fullField,e.type)):i&&typeof t!==e.type&&n.push(Ut(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 u=t,l="";const h="number"==typeof t,f="string"==typeof t,d=Array.isArray(t);if(h?l="number":f?l="string":d&&(l="array"),!l)return!1;d&&(u=t.length),f&&(u=t.replace(c,"_").length),i?u!==e.len&&n.push(Ut(s.messages[l].len,e.fullField,e.len)):o&&!a&&u<e.min?n.push(Ut(s.messages[l].min,e.fullField,e.min)):a&&!o&&u>e.max?n.push(Ut(s.messages[l].max,e.fullField,e.max)):o&&a&&(u<e.min||u>e.max)&&n.push(Ut(s.messages[l].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[er]=Array.isArray(e[er])?e[er]:[],-1===e[er].indexOf(t)&&n.push(Ut(s.messages[er],e.fullField,e[er].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(Ut(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(Ut(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const rr=(e,t,r,n,s)=>{const i=e.type,o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(Nt(t,i)&&!e.required)return r();tr.required(e,t,n,o,s,i),Nt(t,i)||tr.type(e,t,n,o,s)}r(o)};var nr={string:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(Nt(t,"string")&&!e.required)return r();tr.required(e,t,n,i,s,"string"),Nt(t,"string")||(tr.type(e,t,n,i,s),tr.range(e,t,n,i,s),tr.pattern(e,t,n,i,s),!0===e.whitespace&&tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&tr.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),Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&(tr.type(e,t,n,i,s),tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),Nt(t)||tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&(tr.type(e,t,n,i,s),tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&(tr.type(e,t,n,i,s),tr.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();tr.required(e,t,n,i,s,"array"),null!=t&&(tr.type(e,t,n,i,s),tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&tr.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(Nt(t)&&!e.required)return r();tr.required(e,t,n,i,s),void 0!==t&&tr.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(Nt(t,"string")&&!e.required)return r();tr.required(e,t,n,i,s),Nt(t,"string")||tr.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(Nt(t,"date")&&!e.required)return r();if(tr.required(e,t,n,i,s),!Nt(t,"date")){let r;r=t instanceof Date?t:new Date(t),tr.type(e,r,n,i,s),r&&tr.range(e,r.getTime(),n,i,s)}}r(i)},url:rr,hex:rr,email:rr,required:(e,t,r,n,s)=>{const i=[],o=Array.isArray(t)?"array":typeof t;tr.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(Nt(t)&&!e.required)return r();tr.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 ir=sr();class or{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");nr[e]=t};static warning=It;static messages=ir;static validators=nr;rules={};_messages=ir;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=Zt(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===ir&&(e=sr()),Zt(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 Vt(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 u(i=[]){let u=Array.isArray(i)?i:[i];!0===s.suppressWarning&&u.length&&or.warning("async-validator:",u),u.length&&void 0!==r.message&&(u=[].concat(r.message));let l=u.map(Wt(r,n));if(s.first&&l.length)return a[r.field]=1,t(l);if(o){if(r.required&&!e.value)return void 0!==r.message?l=[].concat(r.message).map(Wt(r,n)):s.error&&(l=[s.error(r,Ut(s.messages.required,r.field))]),t(l);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 or(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=[];l&&l.length&&r.push(...l),e&&e.length&&r.push(...e),t(r.length?r:null)}))}else t(l)}if(o=o&&(r.required||!r.required&&e.value),r.field=e.field,r.asyncValidator)i=r.asyncValidator(r,e.value,u,e.source,s);else if(r.validator){try{i=r.validator(r,e.value,u,e.source,s)}catch(e){console.error?.(e),s.suppressValidatorError||setTimeout((()=>{throw e}),0),u(e.message)}!0===i?u():!1===i?u("function"==typeof r.message?r.message(r.fullField||r.field):r.message||`${r.fullField||r.field} fails`):i instanceof Array?u(i):i instanceof Error&&u(i.message)}i&&i.then&&i.then((()=>u()),(e=>u(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=zt(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&&!nr.hasOwnProperty(e.type))throw new Error(Ut("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]?nr.required:nr[this.getType(e)]||void 0}}function ar(e){return new or(e)}var cr={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:ar,validate:function(e,t,r={},n=(()=>{})){return ue.run(ar(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 ur={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 lr={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 hr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var fr={toBase64:(e="")=>{let t,r,n,s,i,o,a,c="",u=0;for(e=lr.toUtf8(e);u<e.length;)t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),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+hr.charAt(s)+hr.charAt(i)+hr.charAt(o)+hr.charAt(a);return c},fromBase64:(e="")=>{let t,r,n,s,i,o,a,c="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)s=hr.indexOf(e.charAt(u++)),i=hr.indexOf(e.charAt(u++)),o=hr.indexOf(e.charAt(u++)),a=hr.indexOf(e.charAt(u++)),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=lr.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,i,o,a,c="",u=0;if(!e||!B.isArrayLike(e)||!B.isUint8Array(e))return"";for(;u<e.length;)t=e[u++],r=e[u++],n=e[u++],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+hr.charAt(s)+hr.charAt(i)+hr.charAt(o)+hr.charAt(a);return c},base64ToBytes:(e="")=>{let t,r,n,s,i,o,a,c=[],u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)s=hr.indexOf(e.charAt(u++)),i=hr.indexOf(e.charAt(u++)),o=hr.indexOf(e.charAt(u++)),a=hr.indexOf(e.charAt(u++)),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 dr=e=>fr.toBase64(e);var pr={encode:dr,decode:e=>fr.fromBase64(e),encodeByOss:e=>dr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var gr={...o,base64:pr,uuid:a,guid:(e,t=!1,r="")=>{const n=a(e||32);return t?g.now().format("yyyyMMddhhmmss")+r+n:n},getHexString:e=>{const t=o.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 yr=e=>{if(!e)return"";if(!bt.isObject(e))return"";let t="";return bt.forof(e,((e,r)=>{r&&(t+=`${ft.kebabCase(e)}:${r};`)})),t},mr=["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"],wr=["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:cr.isFloat(e.toString())?`${e}${t}`:e:e;var vr={stringify:yr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=Bt.parse(e,{sep:";",eq:":",uri:!1}),s={};return bt.forof(n,((e,n)=>{if(!n)return;const i=t?r&&e.startsWith("_")?e:ft.camelCase(e):e;cr.isFloat(n)||n.length>=2&&n.startsWith(".")&&cr.isNumber(n.substr(1))?s[i]=+n:s[i]=n})),s},fixValue:br,style:(e,t="px")=>{if(!e)return"";const r=bt.copy(e,{fields:mr});bt.forof(r,((e,n)=>{(wr.includes(e)||wr.includes(ft.camelCase(e)))&&(r[e]=br(n,t))}));return yr(r)},commonFields:mr};const _r=(e,t="",r=!1)=>{try{if(!e)return;const n=Bt.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}?${Bt.stringify(t,{uri:!1})}`,i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="blob",i.onload=function(){xr(i.response,s)},i.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},i.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},xr=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;_r(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},Sr=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)))})),$r=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Ar={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:_r,download:(e,t="")=>{e&&("string"!=typeof e?xr(e,t):_r(e,t))},downloadFile:xr,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();_r(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 u=c.getContext("2d");return u?(n&&u.rotate(n*Math.PI/180),s&&(u.fillStyle=s),i&&(u.font=i),o&&(u.textAlign=o),a&&(u.textBaseline=a),u.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=>{$r(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(Sr(e)))):r(Sr(e))})).catch((()=>{r(Sr(e))})):r(Sr(e))})),queryPermission:kr,isAllowed:$r,legacyCopy:Sr};var Cr={ossImage:(e,t={})=>{if(!e)return e;const r=Bt.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=_t.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=Bt.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=>fr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Or={...lr,...fr,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 fr.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?fr.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!B.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=>B.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>B.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]=de.random(256);return t},textEncode:e=>lr.toUtf8Bytes(e),textDecode:e=>lr.fromUtf8Bytes(new Uint8Array(e))};const qr=({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 Er(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function jr(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=Bt.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 Lr{host="";reqConfig={};handleError;interceptors={request:new Ct,response:new Ct};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(jr),this.interceptors.response.use(e.handleResponse||Er),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Lr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Lr.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 i;if(delete s.options.plugins,"block"===r.model)this.lockR(Lr.blockId,(()=>qr(s))),i=await Lr.requestLock[Lr.blockId].request;else if(Lr.requestLock[Lr.blockId]&&Lr.requestLock[Lr.blockId].lock&&await Lr.requestLock[Lr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Lr.requestLock[e]||this.lockR(e,(()=>qr(s))),i=await Lr.requestLock[e].request,this.unlockR(e)}else i=await qr(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 Tr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},Fr=e=>(...t)=>{const r=console[e];Tr.overrode?r(...t):Mr(r,e,...t)},Mr=(e,t,...r)=>{const n=g.format(new Date,Tr.format),s=Tr.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 Rr={override:()=>{if(Tr.overrode)return;Tr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{Mr(t,e,...r)}}))},log:Fr("log"),info:Fr("info"),warn:Fr("warn"),error:Fr("error"),config:({tag:e=Tr.tag,format:t=Tr.format}={})=>{Tr.tag=e,Tr.format=t}};var Pr={getDataURL:e=>{const t={contentType:"",dataUrl:""};return ne.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Or.ab2str(e,!0),t))))},getArrayBuffer:async e=>ne.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>ne.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=de.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 Br=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,${pr.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}`}},Dr=(e,t,r)=>({key:e,fields:t,storage:r});class Ir{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=ue.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=wt.copy(e,{fields:this.fields});this.save(r)}}class zr extends c{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!B.isFunction(n))return;const[,s]=await ue.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=wt.copy(t);else{const[,t]=await ue.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){B.isObject(t)&&(t=wt.copy(t)),this[e]=t}}const Ur=(e,t)=>{const r=Object.assign(new zr,e||{});r.__persist=new Ir(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 B.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(B.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 Nr{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=Bt.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const i=Bt.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=gr.base64.encodeByOss(n),i=Bt.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=gr.base64.encodeByOss(e),i=Bt.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}result(){return this.list.join("")}}const Kr=(e,t)=>new Nr(e,t);class Hr{__list=[];constructor(){this.clear()}add(e){const t=ue.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 Vr=new class{state=Ur(new zr);frame=new u;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||g.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&&!g.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||g.isToday(t.time||0)||delete r[e]})),this.setCache(t,r)};parallel=()=>new Hr};class Wr{id="";start=0;end=0;cost=0;name="";type="";desc="";timeStartDesc="";timeEndDesc="";isDone=!1;flag=0;constructor(){this.id=a(),this.start=Date.now(),this.timeStartDesc=g.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=g.format(this.end,"hh:mm:ss.SSS"),this.isDone=!0)}}const Zr=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 Wr;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=wt.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 _t.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)))}},Gr=e=>{try{const t=Or.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},Jr=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var Yr={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=Gr(t),n=Jr(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),i=Gr(s);return{publicKey:r,publicKeyPem:n,privateKey:i,privateKeyPem:Jr(i,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:Jr,format_pem_content:Gr,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Or.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Or.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Or.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Or.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 Qr={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 Xr=t?.webcrypto?.subtle;var en={...Qr,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",Or.base64ToBytes(this.sharedSecret),Or.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",Or.base64ToBytes(this.sharedSecret),Or.base64ToBytes(n));s.setAuthTag(Or.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 Xr.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 Xr.exportKey("spki",e);return Or.ab2str(t,!0)}async importSpkiKey(e){const t=Or.base64ToBytes(e);return await Xr.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 Xr.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=Or.textEncode(e),r=await Xr.encrypt({name:"AES-GCM",iv:Or.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Or.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Or.str2ab(e,!0),n=await Xr.decrypt({name:"AES-GCM",iv:Or.base64ToBytes(t)},this.__sharedSecret,r);return Or.textDecode(n)}}};var tn={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 Or.ab2str(t,!0)}async importSpkiKey(e){const t=Or.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=Or.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Or.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Or.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Or.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Or.base64ToBytes(t)},this.__sharedSecret,r);return Or.textDecode(n)}}};const rn={gbk:r,math:de,list:_t,string:ft,time:g,obj:wt,rule:cr,regex:ur,...Or,...gr,...bt,Event:c},nn={...Or,...gr,...ue},sn={mini:Et,css:vr,qs:Bt,icon:Br,html:Ar},on={cdn:Cr,watermark:Kr},an={Store:zr,storeRef:Ur,Persist:Ir,persistConfig:Dr},cn=Vr,un=Zr,ln=Rr,hn={fetch:Pr,Http:Lr,css:vr,qs:Bt,icon:Br,html:Ar,rsa:Yr,...tn},fn={...en};var dn={gbk:r,time:g,hook:ue,math:de,util:bt,list:_t,string:ft,obj:wt,crypto:gr,mini:Et,qs:Bt,css:vr,cdn:Cr,html:Ar,icon:Br,rule:cr,regex:ur,convert:Or,Event:c,Http:Lr,Store:zr,storeRef:Ur,Persist:Ir,persistConfig:Dr,watermark:Kr,joker:Vr,tracker:Zr,logger:Rr,fetch:Pr,rsa:Yr};export{on as dCdn,nn as dHook,cn as dJoker,ln as dLogger,sn as dMini,fn as dNode,an as dStore,un as dTracker,rn as dUtil,hn as dWeb,dn 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 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},w="object"==typeof global&&global&&global.Object===Object&&global,b="object"==typeof self&&self&&self.Object===Object&&self;const v=(w||b||Function("return this")()).Symbol,{toString:_,hasOwnProperty:x,propertyIsEnumerable:S}=Object.prototype,k=v?v.toStringTag:void 0;function $(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":k&&k in Object(e)?function(e){const t=x.call(e,k),r=e[k];let n=!1;try{e[k]=void 0,n=!0}catch(e){}const s=_.call(e);return n&&(t?e[k]=r:delete e[k]),s}(e):_.call(e)}var A={getTag:$,getType:function(e){return($(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:_,hasOwnProperty:x,propertyIsEnumerable:S},C="[object Function]",O="[object GeneratorFunction]",E="[object AsyncFunction]",q=9007199254740991;const j=/^(?:0|[1-9]\d*)$/;function L(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function P(e){return null!=e&&"object"==typeof e}const T=Array.isArray;function F(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=q}(e.length)&&!M(e)}function R(e){return P(e)&&F(e)}function M(e){var t=L(e)?A.getTag(e):"";return t===C||t===O||t===E}const B="undefined"!=typeof window&&void 0!==window.document,D="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;var I={is:function(e,t){return A.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===A.getTag(e)},isString:function(e){return"string"==typeof e||!T(e)&&P(e)&&"[object String]"==A.getTag(e)},isObject:L,isObjectLike:P,isPlainObject:function(e){if(!P(e)||"[object Object]"!=A.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||P(e)&&"[object Symbol]"===A.getTag(e)},isFunction:M,isArray:T,isArrayLikeObject:R,isIndex:function(e,t){return!!(t=null==t?q:t)&&("number"==typeof e||j.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:F,isPrototype:function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)},isArguments:function(e){return R(e)&&A.hasOwnProperty.call(e,"callee")&&(!A.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==A.toString.call(e))},isPromise:function(e){return"[object Promise]"===(L(e)?A.getTag(e):"")},isBrowser:B,isNode:D,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer};const U=NaN,z=/^\s+|\s+$/g,K=/^[-+]0x[0-9a-f]+$/i,N=/^0b[01]+$/i,H=/^0o[0-7]+$/i,V=parseInt,W=1/0,Z=17976931348623157e292;function G(e){if("number"==typeof e)return e;if(I.isSymbol(e))return U;if(I.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=I.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(z,"");const t=N.test(e);return t||H.test(e)?V(e.slice(2),t?2:8):K.test(e)?U:+e}function J(e){return e?(e=G(e))===W||e===-W?(e<0?-1:1)*Z:e==e?e:0:0===e?e:0}var Y={toNumber:G,toFinite:J,toInteger:function(e){var t=J(e),r=t%1;return t==t?r?t-r:t:0}};const Q="Expected a function",X=Math.max,ee=Math.min;function te(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(Q);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?ee(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=Y.toNumber(t)||0,I.isObject(r)&&(u=!!r.leading,h="maxWait"in r,i=h?X(Y.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 re{__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(I.isFunction(e))r=e(t);else{if(I.isPromise(e))return e.then((e=>({...t,...e})));r=e}return I.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 ne(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const se=e=>{try{let t;return t=I.isFunction(e)?e():e,ne(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var ie={to:ne,go:e=>se(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:se};class oe{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var ae={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 oe;return void 0!==e&&t.set(e),t}};class ce{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return ie.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class le{__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 ce(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 ie.delay(100),this._step()}return this.clear()}}class ue extends(ae.singleton()){__lockedMap=new Map;pipeline=new le;constructor(){super()}lock(e,t){if(!e||!t)return;const r=ie.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 ie.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return ie.safeRun(e);const s=await n;return this.unlock(t),s}}var he={...ie,sleep:ie.delay,run:async function(e,t=0){if(t<=0)return ie.safeRun(e);const r=t>0?Date.now():0,n=await ie.safeRun(e),s=Date.now()-r;return s<t&&await ie.delay(t-s),n},exec:(e,t="")=>ue.I.exec(e,t),debounce:te,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return I.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),te(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new re(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 ie.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await ie.delay(i)}while(-1===n||s>0)},pipe:(e,t)=>ue.I.pipeline.push(e,t),pipeline:(e=1)=>new le(e),safeTask:(e,t)=>new ce(e,t)};function fe(e){return Math.floor(Math.random()*e)}function de(e,t=10){return+parseFloat(Number(e).toExponential(t))}const pe=180/Math.PI;var ge={random:fe,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=fe(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:de,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=de(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 ye(e){return e!=e}function me(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 we,be,ve=(we=Object.keys,be=Object,function(e){return we(be(e))}),_e=Math.max;function xe(e,t){var r=I.isArray(e)||I.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&&!A.hasOwnProperty.call(e,i)||s&&("length"==i||I.isIndex(i,n))||r.push(i);return r}function Se(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 ke=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function $e(e){return ke.test(e)}const Ae="\\ud800-\\udfff",Ce=`[${Ae}]`,Oe="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Ee="\\ud83c[\\udffb-\\udfff]",qe=`[^${Ae}]`,je="(?:\\ud83c[\\udde6-\\uddff]){2}",Le="[\\ud800-\\udbff][\\udc00-\\udfff]",Pe=`${`(?:${Oe}|${Ee})`}?`,Te="[\\ufe0e\\ufe0f]?",Fe=Te+Pe+`(?:\\u200d(?:${[qe,je,Le].join("|")})${Te+Pe})*`,Re=`(?:${[`${qe}${Oe}?`,Oe,je,Le,Ce].join("|")})`,Me=RegExp(`${Ee}(?=${Ee})|${Re+Fe}`,"g");function Be(e){return $e(e)?function(e){return e.match(Me)||[]}(e):function(e){return e.split("")}(e)}function De(e){return t=>{if(!t)return"";const r=$e(t)?Be(t):void 0,n=r?r[0]:t[0],s=r?Se(r,1).join(""):t.slice(1);return n[e]()+s}}const Ie="\\ud800-\\udfff",Ue="\\u2700-\\u27bf",ze="a-z\\xdf-\\xf6\\xf8-\\xff",Ke="A-Z\\xc0-\\xd6\\xd8-\\xde",Ne="\\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",He="['’]",Ve=`[${Ne}]`,We=`[${Ue}]`,Ze=`[${ze}]`,Ge=`[^${Ie}${Ne+"\\d"+Ue+ze+Ke}]`,Je="(?:\\ud83c[\\udde6-\\uddff]){2}",Ye="[\\ud800-\\udbff][\\udc00-\\udfff]",Qe=`[${Ke}]`,Xe=`(?:${Ze}|${Ge})`,et=`(?:${Qe}|${Ge})`,tt=`(?:${He}(?:d|ll|m|re|s|t|ve))?`,rt=`(?:${He}(?:D|LL|M|RE|S|T|VE))?`,nt="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",st="[\\ufe0e\\ufe0f]?",it=st+nt+`(?:\\u200d(?:${[`[^${Ie}]`,Je,Ye].join("|")})${st+nt})*`,ot=`(?:${[We,Je,Ye].join("|")})${it}`,at=RegExp([`${Qe}?${Ze}+${tt}(?=${[Ve,Qe,"$"].join("|")})`,`${et}+${rt}(?=${[Ve,Qe+Xe,"$"].join("|")})`,`${Qe}?${Xe}+${tt}`,`${Qe}+${rt}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",ot].join("|"),"g");const ct=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 ]/),lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ut(e,t){if(void 0===t){const t=ct(e)?function(e){return e.match(at)}(e):function(e){return e.match(lt)}(e);return t||[]}return e.match(t)||[]}function ht(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:ht(e)))}`;if(I.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const ft=De("toUpperCase"),dt=De("toLowerCase");var pt={toString:ht,startCase:e=>ut(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+ft(t)),""),snakeCase:e=>ut(ht(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>ut(ht(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>ut(ht(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?ft(t):t))),""),upperCase:e=>ut(ht(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:ft,lowerCase:e=>ut(ht(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:dt,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 gt=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]=gt(e[r]));return t};const yt=(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]=mt(e[o],a,r)}return n},mt=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?yt(e,t,r):yt({...e},t,r),n},wt=(e,t,r={})=>yt({...e},t,{cover:!0,...r}),bt=(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=>{bt(i,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:o=>{r.call(n,o,i),i=o,s&&bt(e,t,r,n,s)},get:()=>i})};var vt={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: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()||(o[a]=c))}return o},clone:gt,merge:mt,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:wt,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=wt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:i,ignoreEmptyArray:o,ignoreEmptyString:a,cover:c}))),r},observe:bt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var _t={...I,...A,...vt,...ae,includes:function(e,t,r,n){e=I.isArrayLike(e)?e:function(e){return e?me(e,function(e){return I.isArrayLike(e)?xe(e):function(e){if(!I.isPrototype(e))return ve(e);var t=[];for(var r in Object(e))A.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?Y.toInteger(r):0;var s=e.length;return r<0&&(r=_e(s+r,0)),I.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,ye,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(I.isObject(e)&&(r=I.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var xt={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 St={...xt,stepAction:function(e,t,r=100){if(!I.isFunction(t))return;if(!I.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(!I.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!I.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!I.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return ge.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!I.isObject(e))return;const s=e[t];(I.isString(s)&&""!==s||I.isNumber(s))&&(n[s]=e[r])})),n):n}};const kt="[object Object]",$t="[object Array]",At=e=>Object.prototype.toString.call(e),Ct=(e,t,r=!1)=>{if(e===t)return;const n=At(e);if(n===At(t))if(n===$t&&e.length>=t.length)for(let r=0;r<t.length;r++)Ct(e[r],t[r]);else if(n===kt&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?Ct(e[n],t[n]):e[n]=null},Ot=(e,t,r,n="",s=!1)=>{if(e===t)return;const i=At(e),o=At(t);if(i===$t&&o===i&&e.length>=t.length)for(let s=0;s<e.length;s++)Ot(e[s],t[s],r,`${n}[${s}]`);else if(i===kt&&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=At(s),c=At(o);if(s!==o)if(a===$t&&c===a&&s.length>=o.length)for(let e=0;e<s.length;e++)Ot(s[e],o[e],r,`${n?n+".":""}${i}[${e}]`);else if(a===kt&&c===a&&Object.keys(s).length>=Object.keys(o).length)for(let e in s)Ot(s[e],o[e],r,`${n?n+".":""}${i}.${e}`);else r[`${n?n+".":""}${i}`]=s}}else r[n]=e};class Et{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 qt{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new Et,response:new Et};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){qt.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete qt.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=vt.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(qt.blockId,(()=>this._fetch(s,n.hasEncrypt))),i=await qt.requestLock[qt.blockId].request;else if(qt.requestLock[qt.blockId]&&qt.requestLock[qt.blockId].lock&&await qt.requestLock[qt.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),qt.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),i=await qt.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 jt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Lt={diff:function(e,t){const r={};return(e=>{if(At(e)===kt)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];At(n[t])!==kt&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),Ct(e,t,!0),Ot(e,t,r,"",!0),r},promixify:jt,run:(e,t={})=>e?he.run(jt(e)(t)):he.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:qt,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;vt.observe(s,o,a,e,c)}))}};const Pt=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,A.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(u):c[a]=[c[a],u]:c[a]=u}return vt.parseValue(c,{number:o,boolean:a}),c},Tt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Ft=function(e,t=!0){return t?encodeURIComponent(e):e},Rt=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},Mt=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,Bt=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}},Dt=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(Mt);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 It={parse:Pt,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=Ft(Tt(n),s)+r,l=e[n];return Array.isArray(l)?l.map((function(e){return c+Ft(Tt(e),s)})).join(t):Rt(l,{cleanZero:i,cleanNull:o,cleanWhitespace:a})?"":c+Ft(Tt(l),s)})).filter(Boolean).join(t):n?Ft(Tt(n),s)+r+Ft(Tt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=Dt(e),{origin:r="",url:n="",query:s=""}=t,i=Bt(n),o=Pt(s,{multiple:!0,uri:!1});return{...t,...i,pathname:n.substring(n.indexOf(r||"")+r.length),params:o}},parsePath:Bt,parseHost:Dt,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 Ut=/%[sdj%]/g;let zt=()=>{};function Kt(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 Nt(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(Ut,(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 Ht(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 Vt(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&&(zt=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class Wt extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function Zt(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);Vt(o,r,(e=>(n(e),e.length?i(new Wt(e,Kt(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 Wt(l,Kt(l))):t(s)};o.length||(n(l),t(s)),o.forEach((t=>{const n=e[t];-1!==i.indexOf(t)?Vt(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 Gt(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 Jt(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 Yt=(e,t,r,n,s,i)=>{!e.required||r.hasOwnProperty(e.field||"")&&!Ht(t,i||e.type)||n.push(Nt(s.messages.required,e.fullField))};let Qt;const Xt=/^(([^<>()\[\]\\.,;:\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,}))$/,er=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,tr={integer:e=>tr.number(e)&&parseInt(e,10)===e,float:e=>tr.number(e)&&!tr.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&&!tr.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(Xt),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(Qt)return Qt;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 Qt=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"),Qt})()),hex:e=>"string"==typeof e&&!!e.match(er)},rr="enum";var nr={required:Yt,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(Nt(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void Yt(e,t,r,n,s);const i=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(i)>-1?tr[i](t)||n.push(Nt(s.messages.types[i],e.fullField,e.type)):i&&typeof t!==e.type&&n.push(Nt(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(Nt(s.messages[u].len,e.fullField,e.len)):o&&!a&&l<e.min?n.push(Nt(s.messages[u].min,e.fullField,e.min)):a&&!o&&l>e.max?n.push(Nt(s.messages[u].max,e.fullField,e.max)):o&&a&&(l<e.min||l>e.max)&&n.push(Nt(s.messages[u].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[rr]=Array.isArray(e[rr])?e[rr]:[],-1===e[rr].indexOf(t)&&n.push(Nt(s.messages[rr],e.fullField,e[rr].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(Nt(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(Nt(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const sr=(e,t,r,n,s)=>{const i=e.type,o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(Ht(t,i)&&!e.required)return r();nr.required(e,t,n,o,s,i),Ht(t,i)||nr.type(e,t,n,o,s)}r(o)};var ir={string:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(Ht(t,"string")&&!e.required)return r();nr.required(e,t,n,i,s,"string"),Ht(t,"string")||(nr.type(e,t,n,i,s),nr.range(e,t,n,i,s),nr.pattern(e,t,n,i,s),!0===e.whitespace&&nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&nr.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),Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&(nr.type(e,t,n,i,s),nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),Ht(t)||nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&(nr.type(e,t,n,i,s),nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&(nr.type(e,t,n,i,s),nr.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();nr.required(e,t,n,i,s,"array"),null!=t&&(nr.type(e,t,n,i,s),nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s),void 0!==t&&nr.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(Ht(t,"string")&&!e.required)return r();nr.required(e,t,n,i,s),Ht(t,"string")||nr.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(Ht(t,"date")&&!e.required)return r();if(nr.required(e,t,n,i,s),!Ht(t,"date")){let r;r=t instanceof Date?t:new Date(t),nr.type(e,r,n,i,s),r&&nr.range(e,r.getTime(),n,i,s)}}r(i)},url:sr,hex:sr,email:sr,required:(e,t,r,n,s)=>{const i=[],o=Array.isArray(t)?"array":typeof t;nr.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(Ht(t)&&!e.required)return r();nr.required(e,t,n,i,s)}r(i)}};function or(){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 ar=or();class cr{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");ir[e]=t};static warning=zt;static messages=ar;static validators=ir;rules={};_messages=ar;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=Jt(or(),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===ar&&(e=or()),Jt(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 Zt(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&&cr.warning("async-validator:",l),l.length&&void 0!==r.message&&(l=[].concat(r.message));let u=l.map(Gt(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(Gt(r,n)):s.error&&(u=[s.error(r,Nt(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 cr(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=Kt(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&&!ir.hasOwnProperty(e.type))throw new Error(Nt("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]?ir.required:ir[this.getType(e)]||void 0}}function lr(e){return new cr(e)}var ur={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:lr,validate:function(e,t,r={},n=(()=>{})){return he.run(lr(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 hr={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 fr={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 dr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var pr={toBase64:(e="")=>{let t,r,n,s,i,o,a,c="",l=0;for(e=fr.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+dr.charAt(s)+dr.charAt(i)+dr.charAt(o)+dr.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=dr.indexOf(e.charAt(l++)),i=dr.indexOf(e.charAt(l++)),o=dr.indexOf(e.charAt(l++)),a=dr.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=fr.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,i,o,a,c="",l=0;if(!e||!I.isArrayLike(e)||!I.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+dr.charAt(s)+dr.charAt(i)+dr.charAt(o)+dr.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=dr.indexOf(e.charAt(l++)),i=dr.indexOf(e.charAt(l++)),o=dr.indexOf(e.charAt(l++)),a=dr.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 gr=e=>pr.toBase64(e);var yr={encode:gr,decode:e=>pr.fromBase64(e),encodeByOss:e=>gr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var mr={...c,base64:yr,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 wr=e=>{if(!e)return"";if(!_t.isObject(e))return"";let t="";return _t.forof(e,((e,r)=>{r&&(t+=`${pt.kebabCase(e)}:${r};`)})),t},br=["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"],vr=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],_r=(e,t="px")=>e&&t?"0"===e?e:ur.isFloat(e.toString())?`${e}${t}`:e:e;var xr={stringify:wr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=It.parse(e,{sep:";",eq:":",uri:!1}),s={};return _t.forof(n,((e,n)=>{if(!n)return;const i=t?r&&e.startsWith("_")?e:pt.camelCase(e):e;ur.isFloat(n)||n.length>=2&&n.startsWith(".")&&ur.isNumber(n.substr(1))?s[i]=+n:s[i]=n})),s},fixValue:_r,style:(e,t="px")=>{if(!e)return"";const r=_t.copy(e,{fields:br});_t.forof(r,((e,n)=>{(vr.includes(e)||vr.includes(pt.camelCase(e)))&&(r[e]=_r(n,t))}));return wr(r)},commonFields:br};const Sr=(e,t="",r=!1)=>{try{if(!e)return;const n=It.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}?${It.stringify(t,{uri:!1})}`,i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="blob",i.onload=function(){kr(i.response,s)},i.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},i.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},kr=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;Sr(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},$r=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}},Ar=(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)))})),Cr=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Or={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:Sr,download:(e,t="")=>{e&&("string"!=typeof e?kr(e,t):Sr(e,t))},downloadFile:kr,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();Sr(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?Ar("clipboard-write").then((t=>{Cr(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r($r(e)))):r($r(e))})).catch((()=>{r($r(e))})):r($r(e))})),queryPermission:Ar,isAllowed:Cr,legacyCopy:$r};var Er={ossImage:(e,t={})=>{if(!e)return e;const r=It.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=St.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=It.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=>pr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var qr={...fr,...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||!I.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=>I.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>I.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]=ge.random(256);return t},textEncode:e=>fr.toUtf8Bytes(e),textDecode:e=>fr.fromUtf8Bytes(new Uint8Array(e))};const jr=({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 Lr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Pr(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(_t.isPlainObject(e)){const r=It.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 Tr{host="";reqConfig={};handleError;interceptors={request:new Et,response:new Et};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Pr),this.interceptors.response.use(e.handleResponse||Lr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Tr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Tr.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=_t.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(Tr.blockId,(()=>jr(s))),i=await Tr.requestLock[Tr.blockId].request;else if(Tr.requestLock[Tr.blockId]&&Tr.requestLock[Tr.blockId].lock&&await Tr.requestLock[Tr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Tr.requestLock[e]||this.lockR(e,(()=>jr(s))),i=await Tr.requestLock[e].request,this.unlockR(e)}else i=await jr(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 Fr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},Rr=e=>(...t)=>{const r=console[e];Fr.overrode?r(...t):Mr(r,e,...t)},Mr=(e,t,...r)=>{const n=m.format(new Date,Fr.format),s=Fr.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 Br={override:()=>{if(Fr.overrode)return;Fr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{Mr(t,e,...r)}}))},log:Rr("log"),info:Rr("info"),warn:Rr("warn"),error:Rr("error"),config:({tag:e=Fr.tag,format:t=Fr.format}={})=>{Fr.tag=e,Fr.format=t}};var Dr={getDataURL:e=>{const t={contentType:"",dataUrl:""};return ie.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+qr.ab2str(e,!0),t))))},getArrayBuffer:async e=>ie.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>ie.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=ge.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 Ir=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,${yr.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}`}},Ur=(e,t,r)=>({key:e,fields:t,storage:r});class zr{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=he.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=vt.copy(e,{fields:this.fields});this.save(r)}}class Kr extends u{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!I.isFunction(n))return;const[,s]=await he.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=vt.copy(t);else{const[,t]=await he.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){I.isObject(t)&&(t=vt.copy(t)),this[e]=t}}const Nr=(e,t)=>{const r=Object.assign(new Kr,e||{});r.__persist=new zr(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 I.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(I.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 Hr{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=It.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const i=It.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=mr.base64.encodeByOss(n),i=It.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=mr.base64.encodeByOss(e),i=It.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}result(){return this.list.join("")}}const Vr=(e,t)=>new Hr(e,t);class Wr{__list=[];constructor(){this.clear()}add(e){const t=he.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 Zr=new class{state=Nr(new Kr);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=_t.copy(r);_t.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 Wr};class Gr{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 Jr=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 Gr;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=vt.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 St.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)))}},Yr=e=>{try{const t=qr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},Qr=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var Xr={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=Yr(t),n=Qr(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),i=Yr(s);return{publicKey:r,publicKeyPem:n,privateKey:i,privateKeyPem:Qr(i,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:Qr,format_pem_content:Yr,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",qr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return qr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=qr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",qr.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 en={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 tn=t?.webcrypto?.subtle;var rn={...en,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",qr.base64ToBytes(this.sharedSecret),qr.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",qr.base64ToBytes(this.sharedSecret),qr.base64ToBytes(n));s.setAuthTag(qr.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 tn.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 tn.exportKey("spki",e);return qr.ab2str(t,!0)}async importSpkiKey(e){const t=qr.base64ToBytes(e);return await tn.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 tn.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=qr.textEncode(e),r=await tn.encrypt({name:"AES-GCM",iv:qr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=qr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=qr.str2ab(e,!0),n=await tn.decrypt({name:"AES-GCM",iv:qr.base64ToBytes(t)},this.__sharedSecret,r);return qr.textDecode(n)}},SockServer:class{upstreamProxy;server=null;clientSockets=new Set;allowedDomains;connectionPool={};__debug=!1;constructor(e,t=[],r=!1){this.upstreamProxy=e,this.allowedDomains=new Set(t),this.__debug=!1}validateProxyConfig(e){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.server)return console.log("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(`SOCKS5 proxy server is running on port ${t}`)})),this.server.on("error",(e=>{console.error("SOCKS5 proxy server error:",e),this.close()})),t):t}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("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("SockServer handleSocksConnection",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("Error handling SOCKS connection:",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 console.log(`Reusing connection for ${t}`),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=>{console.error("Client socket error:",e),t.end()})),t.on("error",(t=>{console.error("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("Closing SOCKS5 proxy server..."),this.server.close((e=>{e&&console.error("Error closing the server:",e)})),this.clientSockets.forEach((e=>e.destroy())),Object.values(this.connectionPool).forEach((e=>e.destroy())),this.server=null)}}};var nn={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 qr.ab2str(t,!0)}async importSpkiKey(e){const t=qr.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=qr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:qr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=qr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=qr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:qr.base64ToBytes(t)},this.__sharedSecret,r);return qr.textDecode(n)}}};const sn={gbk:s,math:ge,list:St,string:pt,time:m,obj:vt,rule:ur,regex:hr,...qr,...mr,..._t,Event:u},on={...qr,...mr,...he},an={mini:Lt,css:xr,qs:It,icon:Ir,html:Or},cn={cdn:Er,watermark:Vr},ln={Store:Kr,storeRef:Nr,Persist:zr,persistConfig:Ur},un=Zr,hn=Jr,fn=Br,dn={fetch:Dr,Http:Tr,css:xr,qs:It,icon:Ir,html:Or,rsa:Xr,...nn},pn={...rn};var gn={gbk:s,time:m,hook:he,math:ge,util:_t,list:St,string:pt,obj:vt,crypto:mr,mini:Lt,qs:It,css:xr,cdn:Er,html:Or,icon:Ir,rule:ur,regex:hr,convert:qr,Event:u,Http:Tr,Store:Kr,storeRef:Nr,Persist:zr,persistConfig:Ur,watermark:Vr,joker:Zr,tracker:Jr,logger:Br,fetch:Dr,rsa:Xr};export{cn as dCdn,on as dHook,un as dJoker,fn as dLogger,an as dMini,pn as dNode,ln as dStore,hn as dTracker,sn as dUtil,dn as dWeb,gn 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")):"function"==typeof define&&define.amd?define(["exports","zlib","node:crypto"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ddan={},e.zlib,e.crypto$1)}(this,(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(t),i=n(r);var o={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 a="0123456789",c="abcdefghijklmnopqrstuvwxyz",u="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var l={keyNumber:a,keyLower:c,keyUpper:u,keyChars:a+c+u};const f=(e=0,t=0)=>{const r=l.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 h{__map;__tagList;__eventId="";constructor(){this.__map=new Map,this.__tagList=[],this.__eventId=f()}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 d{_loopTimer;_event=new h;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 p={oneDay:864e5,oneHour:36e5,oneMinute:6e4,oneSecond:1e3};class g{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/p.oneSecond);let r=t.countdown;t.d=Math.floor(r/p.oneDay),t.dd=(t.d<10?"0":"")+t.d,r%=p.oneDay,t.h=Math.floor(r/p.oneHour),t.hh=(t.h<10?"0":"")+t.h,r%=p.oneHour,t.m=Math.floor(r/p.oneMinute),t.mm=(t.m<10?"0":"")+t.m,r%=p.oneMinute,t.s=Math.floor(r/p.oneSecond),t.ss=(t.s<10?"0":"")+t.s,r%=p.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>p.oneHour?"hh:mm:ss":t.countdown>p.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 y=(e,t="yyyy-MM-dd hh:mm:ss")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;return r?m(r).format(t):""},m=e=>{const t="string"==typeof e||"number"==typeof e?new Date(e):e;return new g(t||0)};function w({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(y(Date.now(),o)).getTime()}var b={...p,now:function(){return m(new Date)},isToday:e=>e&&(new Date).toDateString()===new Date(e).toDateString(),parseTimestamp:w,todayZero:()=>w({}),format:y,countdown:(e,t="")=>{const r="string"==typeof e||"number"==typeof e?new Date(e):e;if(!r)return"";return m(r).toCountdown(t)},dtime:m,loopFrame:(e=500)=>new d(e),getTimezoneOffset:()=>g.timezoneOffset,getLocalTime:g.getLocalTime},v="object"==typeof global&&global&&global.Object===Object&&global,_="object"==typeof self&&self&&self.Object===Object&&self;const x=(v||_||Function("return this")()).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:$},q="[object Function]",j="[object GeneratorFunction]",E="[object AsyncFunction]",L=9007199254740991;const T=/^(?:0|[1-9]\d*)$/;function M(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function F(e){return null!=e&&"object"==typeof e}const R=Array.isArray;function P(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=L}(e.length)&&!D(e)}function B(e){return F(e)&&P(e)}function D(e){var t=M(e)?O.getTag(e):"";return t===q||t===j||t===E}const I="undefined"!=typeof window&&void 0!==window.document,z="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;var U={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||!R(e)&&F(e)&&"[object String]"==O.getTag(e)},isObject:M,isObjectLike:F,isPlainObject:function(e){if(!F(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||F(e)&&"[object Symbol]"===O.getTag(e)},isFunction:D,isArray:R,isArrayLikeObject:B,isIndex:function(e,t){return!!(t=null==t?L:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:P,isPrototype:function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)},isArguments:function(e){return B(e)&&O.hasOwnProperty.call(e,"callee")&&(!O.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==O.toString.call(e))},isPromise:function(e){return"[object Promise]"===(M(e)?O.getTag(e):"")},isBrowser:I,isNode:z,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer};const N=NaN,K=/^\s+|\s+$/g,H=/^[-+]0x[0-9a-f]+$/i,V=/^0b[01]+$/i,W=/^0o[0-7]+$/i,Z=parseInt,G=1/0,J=17976931348623157e292;function Y(e){if("number"==typeof e)return e;if(U.isSymbol(e))return N;if(U.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=U.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(K,"");const t=V.test(e);return t||W.test(e)?Z(e.slice(2),t?2:8):H.test(e)?N:+e}function Q(e){return e?(e=Y(e))===G||e===-G?(e<0?-1:1)*J:e==e?e:0:0===e?e:0}var X={toNumber:Y,toFinite:Q,toInteger:function(e){var t=Q(e),r=t%1;return t==t?r?t-r:t:0}};const ee="Expected a function",te=Math.max,re=Math.min;function ne(e,t=300,r={}){let n,s,i,o,a,c,u=0,l=!1,f=!1,h=!0;if("function"!=typeof e)throw new TypeError(ee);function d(t){const r=n,i=s;return n=s=void 0,u=t,o=e.apply(i,r),o}function p(e){const r=e-c;return void 0===c||r>=t||r<0||f&&e-u>=i}function g(){const e=Date.now();if(p(e))return y(e);a=setTimeout(g,function(e){const r=t-(e-c);return f?re(r,i-(e-u)):r}(e))}function y(e){return a=void 0,h&&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 u=e,a=setTimeout(g,t),l?d(e):o}(c);if(f)return a=setTimeout(g,t),d(c)}return void 0===a&&(a=setTimeout(g,t)),o}return t=X.toNumber(t)||0,U.isObject(r)&&(l=!!r.leading,f="maxWait"in r,i=f?te(X.toNumber(r.maxWait)||0,t):i,h="trailing"in r?!!r.trailing:h),m.cancel=function(){void 0!==a&&clearTimeout(a),u=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 se{__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(U.isFunction(e))r=e(t);else{if(U.isPromise(e))return e.then((e=>({...t,...e})));r=e}return U.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 ie(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const oe=e=>{try{let t;return t=U.isFunction(e)?e():e,ie(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var ae={to:ie,go:e=>oe(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:oe};class ce{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var ue={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 ce;return void 0!==e&&t.set(e),t}};class le{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return ae.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class fe{__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 le(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 ae.delay(100),this._step()}return this.clear()}}class he extends(ue.singleton()){__lockedMap=new Map;pipeline=new fe;constructor(){super()}lock(e,t){if(!e||!t)return;const r=ae.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 ae.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return ae.safeRun(e);const s=await n;return this.unlock(t),s}}var de={...ae,sleep:ae.delay,run:async function(e,t=0){if(t<=0)return ae.safeRun(e);const r=t>0?Date.now():0,n=await ae.safeRun(e),s=Date.now()-r;return s<t&&await ae.delay(t-s),n},exec:(e,t="")=>he.I.exec(e,t),debounce:ne,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return U.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),ne(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new se(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 ae.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await ae.delay(i)}while(-1===n||s>0)},pipe:(e,t)=>he.I.pipeline.push(e,t),pipeline:(e=1)=>new fe(e),safeTask:(e,t)=>new le(e,t)};function pe(e){return Math.floor(Math.random()*e)}function ge(e,t=10){return+parseFloat(Number(e).toExponential(t))}const ye=180/Math.PI;var me={random:pe,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=pe(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:ge,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=ge(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*ye},degree2radian:function(e){return e/ye},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 we(e){return e!=e}function be(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 ve,_e,xe=(ve=Object.keys,_e=Object,function(e){return ve(_e(e))}),ke=Math.max;function Se(e,t){var r=U.isArray(e)||U.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||U.isIndex(i,n))||r.push(i);return r}function $e(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 Ae=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function Ce(e){return Ae.test(e)}const Oe="\\ud800-\\udfff",qe=`[${Oe}]`,je="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Ee="\\ud83c[\\udffb-\\udfff]",Le=`[^${Oe}]`,Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Me="[\\ud800-\\udbff][\\udc00-\\udfff]",Fe=`${`(?:${je}|${Ee})`}?`,Re="[\\ufe0e\\ufe0f]?",Pe=Re+Fe+`(?:\\u200d(?:${[Le,Te,Me].join("|")})${Re+Fe})*`,Be=`(?:${[`${Le}${je}?`,je,Te,Me,qe].join("|")})`,De=RegExp(`${Ee}(?=${Ee})|${Be+Pe}`,"g");function Ie(e){return Ce(e)?function(e){return e.match(De)||[]}(e):function(e){return e.split("")}(e)}function ze(e){return t=>{if(!t)return"";const r=Ce(t)?Ie(t):void 0,n=r?r[0]:t[0],s=r?$e(r,1).join(""):t.slice(1);return n[e]()+s}}const Ue="\\ud800-\\udfff",Ne="\\u2700-\\u27bf",Ke="a-z\\xdf-\\xf6\\xf8-\\xff",He="A-Z\\xc0-\\xd6\\xd8-\\xde",Ve="\\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",We="['’]",Ze=`[${Ve}]`,Ge=`[${Ne}]`,Je=`[${Ke}]`,Ye=`[^${Ue}${Ve+"\\d"+Ne+Ke+He}]`,Qe="(?:\\ud83c[\\udde6-\\uddff]){2}",Xe="[\\ud800-\\udbff][\\udc00-\\udfff]",et=`[${He}]`,tt=`(?:${Je}|${Ye})`,rt=`(?:${et}|${Ye})`,nt=`(?:${We}(?:d|ll|m|re|s|t|ve))?`,st=`(?:${We}(?:D|LL|M|RE|S|T|VE))?`,it="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",ot="[\\ufe0e\\ufe0f]?",at=ot+it+`(?:\\u200d(?:${[`[^${Ue}]`,Qe,Xe].join("|")})${ot+it})*`,ct=`(?:${[Ge,Qe,Xe].join("|")})${at}`,ut=RegExp([`${et}?${Je}+${nt}(?=${[Ze,et,"$"].join("|")})`,`${rt}+${st}(?=${[Ze,et+tt,"$"].join("|")})`,`${et}?${tt}+${nt}`,`${et}+${st}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",ct].join("|"),"g");const lt=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 ]/),ft=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ht(e,t){if(void 0===t){const t=lt(e)?function(e){return e.match(ut)}(e):function(e){return e.match(ft)}(e);return t||[]}return e.match(t)||[]}function dt(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:dt(e)))}`;if(U.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const pt=ze("toUpperCase"),gt=ze("toLowerCase");var yt={toString:dt,startCase:e=>ht(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+pt(t)),""),snakeCase:e=>ht(dt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>ht(dt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>ht(dt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?pt(t):t))),""),upperCase:e=>ht(dt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:pt,lowerCase:e=>ht(dt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:gt,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 mt=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]=mt(e[r]));return t};const wt=(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]=bt(e[o],a,r)}return n},bt=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?wt(e,t,r):wt({...e},t,r),n},vt=(e,t,r={})=>wt({...e},t,{cover:!0,...r}),_t=(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=>{_t(i,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:o=>{r.call(n,o,i),i=o,s&&_t(e,t,r,n,s)},get:()=>i})};var xt={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:yt.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:mt,merge:bt,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]=yt.parseValue(n,{number:t,boolean:r});else e[n]=yt.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:vt,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=vt(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:i,ignoreEmptyArray:o,ignoreEmptyString:a,cover:c}))),r},observe:_t,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var kt={...U,...O,...xt,...ue,includes:function(e,t,r,n){e=U.isArrayLike(e)?e:function(e){return e?be(e,function(e){return U.isArrayLike(e)?Se(e):function(e){if(!U.isPrototype(e))return xe(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?X.toInteger(r):0;var s=e.length;return r<0&&(r=ke(s+r,0)),U.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,we,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(U.isObject(e)&&(r=U.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var St={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 $t={...St,stepAction:function(e,t,r=100){if(!U.isFunction(t))return;if(!U.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(!U.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!U.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!U.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return me.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!U.isObject(e))return;const s=e[t];(U.isString(s)&&""!==s||U.isNumber(s))&&(n[s]=e[r])})),n):n}};const At="[object Object]",Ct="[object Array]",Ot=e=>Object.prototype.toString.call(e),qt=(e,t,r=!1)=>{if(e===t)return;const n=Ot(e);if(n===Ot(t))if(n===Ct&&e.length>=t.length)for(let r=0;r<t.length;r++)qt(e[r],t[r]);else if(n===At&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?qt(e[n],t[n]):e[n]=null},jt=(e,t,r,n="",s=!1)=>{if(e===t)return;const i=Ot(e),o=Ot(t);if(i===Ct&&o===i&&e.length>=t.length)for(let s=0;s<e.length;s++)jt(e[s],t[s],r,`${n}[${s}]`);else if(i===At&&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=Ot(s),c=Ot(o);if(s!==o)if(a===Ct&&c===a&&s.length>=o.length)for(let e=0;e<s.length;e++)jt(s[e],o[e],r,`${n?n+".":""}${i}[${e}]`);else if(a===At&&c===a&&Object.keys(s).length>=Object.keys(o).length)for(let e in s)jt(s[e],o[e],r,`${n?n+".":""}${i}.${e}`);else r[`${n?n+".":""}${i}`]=s}}else r[n]=e};class Et{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 Lt{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new Et,response:new Et};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){Lt.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Lt.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=xt.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(Lt.blockId,(()=>this._fetch(s,n.hasEncrypt))),i=await Lt.requestLock[Lt.blockId].request;else if(Lt.requestLock[Lt.blockId]&&Lt.requestLock[Lt.blockId].lock&&await Lt.requestLock[Lt.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Lt.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),i=await Lt.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 Tt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Mt={diff:function(e,t){const r={};return(e=>{if(Ot(e)===At)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];Ot(n[t])!==At&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),qt(e,t,!0),jt(e,t,r,"",!0),r},promixify:Tt,run:(e,t={})=>e?de.run(Tt(e)(t)):de.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:Lt,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;xt.observe(s,o,a,e,c)}))}};const Ft=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 u=/\+/g,l=n||1e3;let f=(e=e.split(t)).length;l>0&&f>l&&(f=l);for(let t=0;t<f;++t){let n,o,a,l,f=e[t].replace(u,"%20"),h=f.indexOf(r);h>=0?(n=f.substr(0,h),o=f.substr(h+1)):(n=f,o=""),a=i?decodeURIComponent(n):n,l=i?decodeURIComponent(o):o,O.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(l):c[a]=[c[a],l]:c[a]=l}return xt.parseValue(c,{number:o,boolean:a}),c},Rt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},Pt=function(e,t=!0){return t?encodeURIComponent(e):e},Bt=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},Dt=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,It=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}},zt=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(Dt);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 Ut={parse:Ft,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=Pt(Rt(n),s)+r,u=e[n];return Array.isArray(u)?u.map((function(e){return c+Pt(Rt(e),s)})).join(t):Bt(u,{cleanZero:i,cleanNull:o,cleanWhitespace:a})?"":c+Pt(Rt(u),s)})).filter(Boolean).join(t):n?Pt(Rt(n),s)+r+Pt(Rt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=zt(e),{origin:r="",url:n="",query:s=""}=t,i=It(n),o=Ft(s,{multiple:!0,uri:!1});return{...t,...i,pathname:n.substring(n.indexOf(r||"")+r.length),params:o}},parsePath:It,parseHost:zt,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 Nt=/%[sdj%]/g;let Kt=()=>{};function Ht(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 Vt(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(Nt,(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 Wt(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 Zt(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&&(Kt=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class Gt extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function Jt(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);Zt(o,r,(e=>(n(e),e.length?i(new Gt(e,Ht(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 u=[],l=new Promise(((t,l)=>{const f=e=>{if(u.push.apply(u,e),c++,c===a)return n(u),u.length?l(new Gt(u,Ht(u))):t(s)};o.length||(n(u),t(s)),o.forEach((t=>{const n=e[t];-1!==i.indexOf(t)?Zt(n,r,f):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,f)}))}));return l.catch((e=>e)),l}function Yt(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 Qt(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 Xt=(e,t,r,n,s,i)=>{!e.required||r.hasOwnProperty(e.field||"")&&!Wt(t,i||e.type)||n.push(Vt(s.messages.required,e.fullField))};let er;const tr=/^(([^<>()\[\]\\.,;:\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,}))$/,rr=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,nr={integer:e=>nr.number(e)&&parseInt(e,10)===e,float:e=>nr.number(e)&&!nr.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&&!nr.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(tr),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(er)return er;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 u=c.v4().source,l=c.v6().source;return er=new RegExp(`(?:^(?:(?:(?:[a-z]+:)?//)|www\\.)(?:\\S+(?::\\S*)?@)?(?:localhost|${u}|${l}|(?:(?:[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"),er})()),hex:e=>"string"==typeof e&&!!e.match(rr)},sr="enum";var ir={required:Xt,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(Vt(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void Xt(e,t,r,n,s);const i=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(i)>-1?nr[i](t)||n.push(Vt(s.messages.types[i],e.fullField,e.type)):i&&typeof t!==e.type&&n.push(Vt(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 u=t,l="";const f="number"==typeof t,h="string"==typeof t,d=Array.isArray(t);if(f?l="number":h?l="string":d&&(l="array"),!l)return!1;d&&(u=t.length),h&&(u=t.replace(c,"_").length),i?u!==e.len&&n.push(Vt(s.messages[l].len,e.fullField,e.len)):o&&!a&&u<e.min?n.push(Vt(s.messages[l].min,e.fullField,e.min)):a&&!o&&u>e.max?n.push(Vt(s.messages[l].max,e.fullField,e.max)):o&&a&&(u<e.min||u>e.max)&&n.push(Vt(s.messages[l].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[sr]=Array.isArray(e[sr])?e[sr]:[],-1===e[sr].indexOf(t)&&n.push(Vt(s.messages[sr],e.fullField,e[sr].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(Vt(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(Vt(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const or=(e,t,r,n,s)=>{const i=e.type,o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(Wt(t,i)&&!e.required)return r();ir.required(e,t,n,o,s,i),Wt(t,i)||ir.type(e,t,n,o,s)}r(o)};var ar={string:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(Wt(t,"string")&&!e.required)return r();ir.required(e,t,n,i,s,"string"),Wt(t,"string")||(ir.type(e,t,n,i,s),ir.range(e,t,n,i,s),ir.pattern(e,t,n,i,s),!0===e.whitespace&&ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&ir.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),Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&(ir.type(e,t,n,i,s),ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),Wt(t)||ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&(ir.type(e,t,n,i,s),ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&(ir.type(e,t,n,i,s),ir.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();ir.required(e,t,n,i,s,"array"),null!=t&&(ir.type(e,t,n,i,s),ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s),void 0!==t&&ir.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(Wt(t,"string")&&!e.required)return r();ir.required(e,t,n,i,s),Wt(t,"string")||ir.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(Wt(t,"date")&&!e.required)return r();if(ir.required(e,t,n,i,s),!Wt(t,"date")){let r;r=t instanceof Date?t:new Date(t),ir.type(e,r,n,i,s),r&&ir.range(e,r.getTime(),n,i,s)}}r(i)},url:or,hex:or,email:or,required:(e,t,r,n,s)=>{const i=[],o=Array.isArray(t)?"array":typeof t;ir.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(Wt(t)&&!e.required)return r();ir.required(e,t,n,i,s)}r(i)}};function cr(){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 ur=cr();class lr{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");ar[e]=t};static warning=Kt;static messages=ur;static validators=ar;rules={};_messages=ur;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=Qt(cr(),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===ur&&(e=cr()),Qt(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 Jt(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 u(i=[]){let u=Array.isArray(i)?i:[i];!0===s.suppressWarning&&u.length&&lr.warning("async-validator:",u),u.length&&void 0!==r.message&&(u=[].concat(r.message));let l=u.map(Yt(r,n));if(s.first&&l.length)return a[r.field]=1,t(l);if(o){if(r.required&&!e.value)return void 0!==r.message?l=[].concat(r.message).map(Yt(r,n)):s.error&&(l=[s.error(r,Vt(s.messages.required,r.field))]),t(l);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 lr(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=[];l&&l.length&&r.push(...l),e&&e.length&&r.push(...e),t(r.length?r:null)}))}else t(l)}if(o=o&&(r.required||!r.required&&e.value),r.field=e.field,r.asyncValidator)i=r.asyncValidator(r,e.value,u,e.source,s);else if(r.validator){try{i=r.validator(r,e.value,u,e.source,s)}catch(e){console.error?.(e),s.suppressValidatorError||setTimeout((()=>{throw e}),0),u(e.message)}!0===i?u():!1===i?u("function"==typeof r.message?r.message(r.fullField||r.field):r.message||`${r.fullField||r.field} fails`):i instanceof Array?u(i):i instanceof Error&&u(i.message)}i&&i.then&&i.then((()=>u()),(e=>u(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=Ht(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&&!ar.hasOwnProperty(e.type))throw new Error(Vt("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]?ar.required:ar[this.getType(e)]||void 0}}function fr(e){return new lr(e)}var hr={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:fr,validate:function(e,t,r={},n=(()=>{})){return de.run(fr(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 dr={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 pr={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 gr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var yr={toBase64:(e="")=>{let t,r,n,s,i,o,a,c="",u=0;for(e=pr.toUtf8(e);u<e.length;)t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),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+gr.charAt(s)+gr.charAt(i)+gr.charAt(o)+gr.charAt(a);return c},fromBase64:(e="")=>{let t,r,n,s,i,o,a,c="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)s=gr.indexOf(e.charAt(u++)),i=gr.indexOf(e.charAt(u++)),o=gr.indexOf(e.charAt(u++)),a=gr.indexOf(e.charAt(u++)),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=pr.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,i,o,a,c="",u=0;if(!e||!U.isArrayLike(e)||!U.isUint8Array(e))return"";for(;u<e.length;)t=e[u++],r=e[u++],n=e[u++],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+gr.charAt(s)+gr.charAt(i)+gr.charAt(o)+gr.charAt(a);return c},base64ToBytes:(e="")=>{let t,r,n,s,i,o,a,c=[],u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u<e.length;)s=gr.indexOf(e.charAt(u++)),i=gr.indexOf(e.charAt(u++)),o=gr.indexOf(e.charAt(u++)),a=gr.indexOf(e.charAt(u++)),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 mr=e=>yr.toBase64(e);var wr={encode:mr,decode:e=>yr.fromBase64(e),encodeByOss:e=>mr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var br={...l,base64:wr,uuid:f,guid:(e,t=!1,r="")=>{const n=f(e||32);return t?b.now().format("yyyyMMddhhmmss")+r+n:n},getHexString:e=>{const t=l.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 vr=e=>{if(!e)return"";if(!kt.isObject(e))return"";let t="";return kt.forof(e,((e,r)=>{r&&(t+=`${yt.kebabCase(e)}:${r};`)})),t},_r=["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"],xr=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],kr=(e,t="px")=>e&&t?"0"===e?e:hr.isFloat(e.toString())?`${e}${t}`:e:e;var Sr={stringify:vr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=Ut.parse(e,{sep:";",eq:":",uri:!1}),s={};return kt.forof(n,((e,n)=>{if(!n)return;const i=t?r&&e.startsWith("_")?e:yt.camelCase(e):e;hr.isFloat(n)||n.length>=2&&n.startsWith(".")&&hr.isNumber(n.substr(1))?s[i]=+n:s[i]=n})),s},fixValue:kr,style:(e,t="px")=>{if(!e)return"";const r=kt.copy(e,{fields:_r});kt.forof(r,((e,n)=>{(xr.includes(e)||xr.includes(yt.camelCase(e)))&&(r[e]=kr(n,t))}));return vr(r)},commonFields:_r};const $r=(e,t="",r=!1)=>{try{if(!e)return;const n=Ut.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}?${Ut.stringify(t,{uri:!1})}`,i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="blob",i.onload=function(){Ar(i.response,s)},i.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},i.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},Ar=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;$r(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},Cr=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}},Or=(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)))})),qr=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var jr={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:$r,download:(e,t="")=>{e&&("string"!=typeof e?Ar(e,t):$r(e,t))},downloadFile:Ar,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();$r(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 u=c.getContext("2d");return u?(n&&u.rotate(n*Math.PI/180),s&&(u.fillStyle=s),i&&(u.font=i),o&&(u.textAlign=o),a&&(u.textBaseline=a),u.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?Or("clipboard-write").then((t=>{qr(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(Cr(e)))):r(Cr(e))})).catch((()=>{r(Cr(e))})):r(Cr(e))})),queryPermission:Or,isAllowed:qr,legacyCopy:Cr};var Er={ossImage:(e,t={})=>{if(!e)return e;const r=Ut.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=$t.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=Ut.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=>yr.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Lr={...pr,...yr,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 yr.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?yr.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!U.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=>U.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>U.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]=me.random(256);return t},textEncode:e=>pr.toUtf8Bytes(e),textDecode:e=>pr.fromUtf8Bytes(new Uint8Array(e))};const Tr=({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 Mr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Fr(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(kt.isPlainObject(e)){const r=Ut.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 Rr{host="";reqConfig={};handleError;interceptors={request:new Et,response:new Et};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Fr),this.interceptors.response.use(e.handleResponse||Mr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Rr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Rr.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=kt.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(Rr.blockId,(()=>Tr(s))),i=await Rr.requestLock[Rr.blockId].request;else if(Rr.requestLock[Rr.blockId]&&Rr.requestLock[Rr.blockId].lock&&await Rr.requestLock[Rr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Rr.requestLock[e]||this.lockR(e,(()=>Tr(s))),i=await Rr.requestLock[e].request,this.unlockR(e)}else i=await Tr(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 Pr={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},Br=e=>(...t)=>{const r=console[e];Pr.overrode?r(...t):Dr(r,e,...t)},Dr=(e,t,...r)=>{const n=b.format(new Date,Pr.format),s=Pr.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 Ir={override:()=>{if(Pr.overrode)return;Pr.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{Dr(t,e,...r)}}))},log:Br("log"),info:Br("info"),warn:Br("warn"),error:Br("error"),config:({tag:e=Pr.tag,format:t=Pr.format}={})=>{Pr.tag=e,Pr.format=t}};var zr={getDataURL:e=>{const t={contentType:"",dataUrl:""};return ae.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Lr.ab2str(e,!0),t))))},getArrayBuffer:async e=>ae.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>ae.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=me.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 Ur=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,${wr.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}`}},Nr=(e,t,r)=>({key:e,fields:t,storage:r});class Kr{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=de.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=xt.copy(e,{fields:this.fields});this.save(r)}}class Hr extends h{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!U.isFunction(n))return;const[,s]=await de.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=xt.copy(t);else{const[,t]=await de.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){U.isObject(t)&&(t=xt.copy(t)),this[e]=t}}const Vr=(e,t)=>{const r=Object.assign(new Hr,e||{});r.__persist=new Kr(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 U.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(U.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 Wr{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=Ut.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const i=Ut.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=br.base64.encodeByOss(n),i=Ut.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=br.base64.encodeByOss(e),i=Ut.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}result(){return this.list.join("")}}const Zr=(e,t)=>new Wr(e,t);class Gr{__list=[];constructor(){this.clear()}add(e){const t=de.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 Jr=new class{state=Vr(new Hr);frame=new d;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||b.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&&!b.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=kt.copy(r);kt.forof(n,((e,t)=>{"day"!==t.cycle&&void 0!==t.cycle||b.isToday(t.time||0)||delete r[e]})),this.setCache(t,r)};parallel=()=>new Gr};class Yr{id="";start=0;end=0;cost=0;name="";type="";desc="";timeStartDesc="";timeEndDesc="";isDone=!1;flag=0;constructor(){this.id=f(),this.start=Date.now(),this.timeStartDesc=b.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=b.format(this.end,"hh:mm:ss.SSS"),this.isDone=!0)}}const Qr=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 Yr;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=xt.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 $t.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)))}},Xr=e=>{try{const t=Lr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},en=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var tn={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=Xr(t),n=en(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),i=Xr(s);return{publicKey:r,publicKeyPem:n,privateKey:i,privateKeyPem:en(i,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:en,format_pem_content:Xr,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Lr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Lr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Lr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Lr.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 rn={brotliCompress:function(e,t=s.default.constants.BROTLI_DEFAULT_QUALITY){try{if(!e)return"";const r=Buffer.from(e,"utf-8");return s.default.brotliCompressSync(r,{params:{[s.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 s.default.brotliDecompressSync(t).toString("utf-8")}catch(t){return e||""}}};const nn=i.default?.webcrypto?.subtle;var sn={...rn,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=i.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=i.default.createCipheriv("aes-256-gcm",Lr.base64ToBytes(this.sharedSecret),Lr.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=i.default.createDecipheriv("aes-256-gcm",Lr.base64ToBytes(this.sharedSecret),Lr.base64ToBytes(r));n.setAuthTag(Lr.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 nn.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 nn.exportKey("spki",e);return Lr.ab2str(t,!0)}async importSpkiKey(e){const t=Lr.base64ToBytes(e);return await nn.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 nn.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=Lr.textEncode(e),r=await nn.encrypt({name:"AES-GCM",iv:Lr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Lr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Lr.str2ab(e,!0),n=await nn.decrypt({name:"AES-GCM",iv:Lr.base64ToBytes(t)},this.__sharedSecret,r);return Lr.textDecode(n)}}};var on={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 Lr.ab2str(t,!0)}async importSpkiKey(e){const t=Lr.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=Lr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Lr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Lr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Lr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Lr.base64ToBytes(t)},this.__sharedSecret,r);return Lr.textDecode(n)}}};const an={gbk:o,math:me,list:$t,string:yt,time:b,obj:xt,rule:hr,regex:dr,...Lr,...br,...kt,Event:h},cn={...Lr,...br,...de},un={mini:Mt,css:Sr,qs:Ut,icon:Ur,html:jr},ln={cdn:Er,watermark:Zr},fn={Store:Hr,storeRef:Vr,Persist:Kr,persistConfig:Nr},hn=Jr,dn=Qr,pn=Ir,gn={fetch:zr,Http:Rr,css:Sr,qs:Ut,icon:Ur,html:jr,rsa:tn,...on},yn={...sn};var mn={gbk:o,time:b,hook:de,math:me,util:kt,list:$t,string:yt,obj:xt,crypto:br,mini:Mt,qs:Ut,css:Sr,cdn:Er,html:jr,icon:Ur,rule:hr,regex:dr,convert:Lr,Event:h,Http:Rr,Store:Hr,storeRef:Vr,Persist:Kr,persistConfig:Nr,watermark:Zr,joker:Jr,tracker:Qr,logger:Ir,fetch:zr,rsa:tn};e.dCdn=ln,e.dHook=cn,e.dJoker=hn,e.dLogger=pn,e.dMini=un,e.dNode=yn,e.dStore=fn,e.dTracker=dn,e.dUtil=an,e.dWeb=gn,e.default=mn,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 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",h="abcdefghijklmnopqrstuvwxyz",d="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var f={keyNumber:u,keyLower:h,keyUpper:d,keyChars:u+h+d};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},S="object"==typeof global&&global&&global.Object===Object&&global,k="object"==typeof self&&self&&self.Object===Object&&self;const $=(S||k||Function("return this")()).Symbol,{toString:A,hasOwnProperty:C,propertyIsEnumerable:O}=Object.prototype,E=$?$.toStringTag:void 0;function q(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":E&&E in Object(e)?function(e){const t=C.call(e,E),r=e[E];let n=!1;try{e[E]=void 0,n=!0}catch(e){}const s=A.call(e);return n&&(t?e[E]=r:delete e[E]),s}(e):A.call(e)}var j={getTag:q,getType:function(e){return(q(e).match(/\w+/g)||["object","Undefined"])[1]||""},toString:A,hasOwnProperty:C,propertyIsEnumerable:O},L="[object Function]",P="[object GeneratorFunction]",T="[object AsyncFunction]",F=9007199254740991;const M=/^(?:0|[1-9]\d*)$/;function R(e){const t=typeof e;return null!=e&&("object"==t||"function"==t)}function B(e){return null!=e&&"object"==typeof e}const D=Array.isArray;function I(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=F}(e.length)&&!z(e)}function U(e){return B(e)&&I(e)}function z(e){var t=R(e)?j.getTag(e):"";return t===L||t===P||t===T}const K="undefined"!=typeof window&&void 0!==window.document,N="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;var H={is:function(e,t){return j.getTag(e)===`[object ${t}]`},isNumber:function(e){return"[object Number]"===j.getTag(e)},isString:function(e){return"string"==typeof e||!D(e)&&B(e)&&"[object String]"==j.getTag(e)},isObject:R,isObjectLike:B,isPlainObject:function(e){if(!B(e)||"[object Object]"!=j.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||B(e)&&"[object Symbol]"===j.getTag(e)},isFunction:z,isArray:D,isArrayLikeObject:U,isIndex:function(e,t){return!!(t=null==t?F:t)&&("number"==typeof e||M.test(e))&&e>-1&&e%1==0&&e<t},isArrayLike:I,isPrototype:function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Object.prototype)},isArguments:function(e){return U(e)&&j.hasOwnProperty.call(e,"callee")&&(!j.propertyIsEnumerable.call(e,"callee")||"[object Arguments]"==j.toString.call(e))},isPromise:function(e){return"[object Promise]"===(R(e)?j.getTag(e):"")},isBrowser:K,isNode:N,isBlobOrBuffer:e=>e instanceof Blob||e instanceof ArrayBuffer,isUint8Array:e=>e instanceof Uint8Array,isArrayBuffer:e=>e instanceof ArrayBuffer};const V=NaN,W=/^\s+|\s+$/g,Z=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,J=/^0o[0-7]+$/i,Y=parseInt,Q=1/0,X=17976931348623157e292;function ee(e){if("number"==typeof e)return e;if(H.isSymbol(e))return V;if(H.isObject(e)){const t="function"==typeof e.valueOf?e.valueOf():e;e=H.isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(W,"");const t=G.test(e);return t||J.test(e)?Y(e.slice(2),t?2:8):Z.test(e)?V:+e}function te(e){return e?(e=ee(e))===Q||e===-Q?(e<0?-1:1)*X:e==e?e:0:0===e?e:0}var re={toNumber:ee,toFinite:te,toInteger:function(e){var t=te(e),r=t%1;return t==t?r?t-r:t:0}};const ne="Expected a function",se=Math.max,ie=Math.min;function oe(e,t=300,r={}){let n,s,i,o,a,c,l=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError(ne);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||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?ie(r,i-(e-l)):r}(e))}function y(e){return a=void 0,d&&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(h)return a=setTimeout(g,t),f(c)}return void 0===a&&(a=setTimeout(g,t)),o}return t=re.toNumber(t)||0,H.isObject(r)&&(u=!!r.leading,h="maxWait"in r,i=h?se(re.toNumber(r.maxWait)||0,t):i,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?o:y(Date.now())},m.pending=function(){return void 0!==a},m}class ae{__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(H.isFunction(e))r=e(t);else{if(H.isPromise(e))return e.then((e=>({...t,...e})));r=e}return H.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 ce(e,t){return e.then((e=>[null,e])).catch((e=>(t&&Object.assign(e,t),[e,void 0])))}const le=e=>{try{let t;return t=H.isFunction(e)?e():e,ce(Promise.resolve(t))}catch(e){return Promise.resolve([e,void 0])}};var ue={to:ce,go:e=>le(e),delay:(e=1e3)=>new Promise((t=>setTimeout(t,e))),safeRun:le};class he{__value=void 0;set(e){this.__value=e}get(){return this.__value}}var de={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 he;return void 0!==e&&t.set(e),t}};class fe{_func;_callback;constructor(e,t){this._func=e,this._callback=t}async run(){return ue.safeRun(this._func).then((e=>{try{this._callback&&this._callback(e)}catch(e){console.log("[ddan] task",e)}finally{return e}}))}}class pe{__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 fe(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 ue.delay(100),this._step()}return this.clear()}}class ge extends(de.singleton()){__lockedMap=new Map;pipeline=new pe;constructor(){super()}lock(e,t){if(!e||!t)return;const r=ue.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 ue.safeRun(e);const r=this.__lockedMap.get(t);if(r)return r;const n=this.lock(t,e);if(!n)return ue.safeRun(e);const s=await n;return this.unlock(t),s}}var ye={...ue,sleep:ue.delay,run:async function(e,t=0){if(t<=0)return ue.safeRun(e);const r=t>0?Date.now():0,n=await ue.safeRun(e),s=Date.now()-r;return s<t&&await ue.delay(t-s),n},exec:(e,t="")=>ge.I.exec(e,t),debounce:oe,throttle:function(e,t=300,r={}){let n=!0,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return H.isObject(r)&&(n=r.leading?!!r.leading:n,s=r.trailing?!!r.trailing:s),oe(e,t,{leading:n,maxWait:t,trailing:s})},task:e=>new ae(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 ue.to(Promise.resolve(t()));if(e||!1===r)break;s>0&&s--,0!==s&&await ue.delay(i)}while(-1===n||s>0)},pipe:(e,t)=>ge.I.pipeline.push(e,t),pipeline:(e=1)=>new pe(e),safeTask:(e,t)=>new fe(e,t)};function me(e){return Math.floor(Math.random()*e)}function we(e,t=10){return+parseFloat(Number(e).toExponential(t))}const be=180/Math.PI;var ve={random:me,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=me(e);r?n.push(s):n.includes(s)||n.push(s)}return n},strip:we,float:function(e,{digits:t=2,fixed:r=!1}={}){const n=we(e).toFixed(t);return r||!t?+n:+n.replace(/(\.[1-9]?)0+$/,"$1").replace(/\.$/,"")},radian2degree:function(e){return e*be},degree2radian:function(e){return e/be},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 _e(e){return e!=e}function xe(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 Se,ke,$e=(Se=Object.keys,ke=Object,function(e){return Se(ke(e))}),Ae=Math.max;function Ce(e,t){var r=H.isArray(e)||H.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&&!j.hasOwnProperty.call(e,i)||s&&("length"==i||H.isIndex(i,n))||r.push(i);return r}function Oe(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 Ee=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff\\ufe0e\\ufe0f]");function qe(e){return Ee.test(e)}const je="\\ud800-\\udfff",Le=`[${je}]`,Pe="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Te="\\ud83c[\\udffb-\\udfff]",Fe=`[^${je}]`,Me="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",Be=`${`(?:${Pe}|${Te})`}?`,De="[\\ufe0e\\ufe0f]?",Ie=De+Be+`(?:\\u200d(?:${[Fe,Me,Re].join("|")})${De+Be})*`,Ue=`(?:${[`${Fe}${Pe}?`,Pe,Me,Re,Le].join("|")})`,ze=RegExp(`${Te}(?=${Te})|${Ue+Ie}`,"g");function Ke(e){return qe(e)?function(e){return e.match(ze)||[]}(e):function(e){return e.split("")}(e)}function Ne(e){return t=>{if(!t)return"";const r=qe(t)?Ke(t):void 0,n=r?r[0]:t[0],s=r?Oe(r,1).join(""):t.slice(1);return n[e]()+s}}const He="\\ud800-\\udfff",Ve="\\u2700-\\u27bf",We="a-z\\xdf-\\xf6\\xf8-\\xff",Ze="A-Z\\xc0-\\xd6\\xd8-\\xde",Ge="\\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",Je="['’]",Ye=`[${Ge}]`,Qe=`[${Ve}]`,Xe=`[${We}]`,et=`[^${He}${Ge+"\\d"+Ve+We+Ze}]`,tt="(?:\\ud83c[\\udde6-\\uddff]){2}",rt="[\\ud800-\\udbff][\\udc00-\\udfff]",nt=`[${Ze}]`,st=`(?:${Xe}|${et})`,it=`(?:${nt}|${et})`,ot=`(?:${Je}(?:d|ll|m|re|s|t|ve))?`,at=`(?:${Je}(?:D|LL|M|RE|S|T|VE))?`,ct="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",lt="[\\ufe0e\\ufe0f]?",ut=lt+ct+`(?:\\u200d(?:${[`[^${He}]`,tt,rt].join("|")})${lt+ct})*`,ht=`(?:${[Qe,tt,rt].join("|")})${ut}`,dt=RegExp([`${nt}?${Xe}+${ot}(?=${[Ye,nt,"$"].join("|")})`,`${it}+${at}(?=${[Ye,nt+st,"$"].join("|")})`,`${nt}?${st}+${ot}`,`${nt}+${at}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",ht].join("|"),"g");const ft=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 ]/),pt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function gt(e,t){if(void 0===t){const t=ft(e)?function(e){return e.match(dt)}(e):function(e){return e.match(pt)}(e);return t||[]}return e.match(t)||[]}function yt(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return`${e.map((e=>null==e?e:yt(e)))}`;if(H.isSymbol(e))return e.toString();const t=`${e}`;return"0"==t&&1/e==-Infinity?"-0":t}const mt=Ne("toUpperCase"),wt=Ne("toLowerCase");var bt={toString:yt,startCase:e=>gt(`${e}`.replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+mt(t)),""),snakeCase:e=>gt(yt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"_":"")+t.toLowerCase()),""),kebabCase:e=>gt(yt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?"-":"")+t.toLowerCase()),""),camelCase:e=>gt(yt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>(t=t.toLowerCase(),e+(r?mt(t):t))),""),upperCase:e=>gt(yt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toUpperCase()),""),upperFirst:mt,lowerCase:e=>gt(yt(e).replace(/['\u2019]/g,"")).reduce(((e,t,r)=>e+(r?" ":"")+t.toLowerCase()),""),lowerFirst:wt,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 vt=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]=vt(e[r]));return t};const _t=(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]=xt(e[o],a,r)}return n},xt=(e,t,r={})=>{let n={};return n=e&&"object"==typeof e&&!Array.isArray(e)?_t(e,t,r):_t({...e},t,r),n},St=(e,t,r={})=>_t({...e},t,{cover:!0,...r}),kt=(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=>{kt(i,e,r,n,s)})),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,set:o=>{r.call(n,o,i),i=o,s&&kt(e,t,r,n,s)},get:()=>i})};var $t={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:bt.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:vt,merge:xt,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]=bt.parseValue(n,{number:t,boolean:r});else e[n]=bt.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:St,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=St(r,e,{ignoreUndefined:n,ignoreNull:s,ignoreZero:i,ignoreEmptyArray:o,ignoreEmptyString:a,cover:c}))),r},observe:kt,find:(e,t)=>{if(e&&"object"==typeof e)return Object.entries(e||{}).find((([e,r])=>!(!t||!t(e,r))))}};var At={...H,...j,...$t,...de,includes:function(e,t,r,n){e=H.isArrayLike(e)?e:function(e){return e?xe(e,function(e){return H.isArrayLike(e)?Ce(e):function(e){if(!H.isPrototype(e))return $e(e);var t=[];for(var r in Object(e))j.hasOwnProperty.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}(e)):[]}(e),r=r&&!n?re.toInteger(r):0;var s=e.length;return r<0&&(r=Ae(s+r,0)),H.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,_e,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(H.isObject(e)&&(r=H.isArray(e)?e.entries():Object.entries(e),r))for(const[e,n]of r)t&&t(e,n)}};var Ct={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 Ot={...Ct,stepAction:function(e,t,r=100){if(!H.isFunction(t))return;if(!H.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(!H.isArray(e)||e.length<=0)return[];const r=t;return e.slice(r)},take:function(e,t,r=0){if(!H.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!H.isArray(e)||e.length<=0?[]:[...new Set(e)]},randoms:function(e,t=1,r=!1){const n=e.length||0;return ve.randoms(n,t,r).map((t=>e[t]))||[]},toKV:(e,t,r)=>{const n={};return t&&r?((e||[]).forEach((e=>{if(!e||!H.isObject(e))return;const s=e[t];(H.isString(s)&&""!==s||H.isNumber(s))&&(n[s]=e[r])})),n):n}};const Et="[object Object]",qt="[object Array]",jt=e=>Object.prototype.toString.call(e),Lt=(e,t,r=!1)=>{if(e===t)return;const n=jt(e);if(n===jt(t))if(n===qt&&e.length>=t.length)for(let r=0;r<t.length;r++)Lt(e[r],t[r]);else if(n===Et&&Object.keys(e).length>=Object.keys(t).length)for(let n in t)r||void 0!==e[n]?Lt(e[n],t[n]):e[n]=null},Pt=(e,t,r,n="",s=!1)=>{if(e===t)return;const i=jt(e),o=jt(t);if(i===qt&&o===i&&e.length>=t.length)for(let s=0;s<e.length;s++)Pt(e[s],t[s],r,`${n}[${s}]`);else if(i===Et&&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=jt(s),c=jt(o);if(s!==o)if(a===qt&&c===a&&s.length>=o.length)for(let e=0;e<s.length;e++)Pt(s[e],o[e],r,`${n?n+".":""}${i}[${e}]`);else if(a===Et&&c===a&&Object.keys(s).length>=Object.keys(o).length)for(let e in s)Pt(s[e],o[e],r,`${n?n+".":""}${i}.${e}`);else r[`${n?n+".":""}${i}`]=s}}else r[n]=e};class Tt{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 Ft{reqConfig={};handleRequest;handleEncrypt;handleDecrypt;handleError;interceptors={request:new Tt,response:new Tt};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){Ft.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Ft.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=$t.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(Ft.blockId,(()=>this._fetch(s,n.hasEncrypt))),i=await Ft.requestLock[Ft.blockId].request;else if(Ft.requestLock[Ft.blockId]&&Ft.requestLock[Ft.blockId].lock&&await Ft.requestLock[Ft.blockId].request,"debounce"===n.model||"debounceUrl"===n.model){let e;e="debounceUrl"===n.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Ft.requestLock[e]||this.lockR(e,(()=>this._fetch(s,n.hasEncrypt))),i=await Ft.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 Mt=e=>"function"!=typeof e?e:(t={})=>new Promise(((r,n)=>{e(Object.assign(t,{success:r,fail:n}))}));var Rt={diff:function(e,t){const r={};return(e=>{if(jt(e)===Et)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];jt(n[t])!==Et&&(n[t]={}),n=n[t]}n[r[s-1]]=e[t],delete e[t]}})(e),Lt(e,t,!0),Pt(e,t,r,"",!0),r},promixify:Mt,run:(e,t={})=>e?ye.run(Mt(e)(t)):ye.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:Ft,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;$t.observe(s,o,a,e,c)}))}};const Bt=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"),d=h.indexOf(r);d>=0?(n=h.substr(0,d),o=h.substr(d+1)):(n=h,o=""),a=i?decodeURIComponent(n):n,u=i?decodeURIComponent(o):o,j.hasOwnProperty.call(c,a)&&s?Array.isArray(c[a])?c[a].push(u):c[a]=[c[a],u]:c[a]=u}return $t.parseValue(c,{number:o,boolean:a}),c},Dt=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},It=function(e,t=!0){return t?encodeURIComponent(e):e},Ut=function(e,{cleanZero:t=!1,cleanNull:r=!1,cleanWhitespace:n=!1}={}){return!(!t||0!==e)||(!(!r||null!=e)||!(!n||"string"!=typeof e||""!==e.trim()))},zt=/^(https?):\/\/([\w.\_\-]+)(?::(\d+))?/,Kt=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}},Nt=e=>{const t={href:e,url:"",origin:"",protocol:"",host:"",port:"",query:""};if(!e)return t;const r=e.match(zt);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 Ht={parse:Bt,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=It(Dt(n),s)+r,l=e[n];return Array.isArray(l)?l.map((function(e){return c+It(Dt(e),s)})).join(t):Ut(l,{cleanZero:i,cleanNull:o,cleanWhitespace:a})?"":c+It(Dt(l),s)})).filter(Boolean).join(t):n?It(Dt(n),s)+r+It(Dt(e),s):""},https:e=>e?e.replace(/^http[s]?/,"https"):e,parseUrl:e=>{const t=Nt(e),{origin:r="",url:n="",query:s=""}=t,i=Kt(n),o=Bt(s,{multiple:!0,uri:!1});return{...t,...i,pathname:n.substring(n.indexOf(r||"")+r.length),params:o}},parsePath:Kt,parseHost:Nt,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 Vt=/%[sdj%]/g;let Wt=()=>{};function Zt(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 Gt(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(Vt,(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 Jt(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 Yt(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&&(Wt=(e,t)=>{"undefined"!=typeof console&&console.warn&&"undefined"==typeof ASYNC_VALIDATOR_NO_WARNING&&t.every((e=>"string"==typeof e))&&console.warn(e,t)});class Qt extends Error{errors;fields;constructor(e,t){super("Async Validation Error"),this.errors=e,this.fields=t}}function Xt(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);Yt(o,r,(e=>(n(e),e.length?i(new Qt(e,Zt(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 Qt(l,Zt(l))):t(s)};o.length||(n(l),t(s)),o.forEach((t=>{const n=e[t];-1!==i.indexOf(t)?Yt(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 er(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 tr(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 rr=(e,t,r,n,s,i)=>{!e.required||r.hasOwnProperty(e.field||"")&&!Jt(t,i||e.type)||n.push(Gt(s.messages.required,e.fullField))};let nr;const sr=/^(([^<>()\[\]\\.,;:\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,}))$/,ir=/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i,or={integer:e=>or.number(e)&&parseInt(e,10)===e,float:e=>or.number(e)&&!or.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&&!or.array(e),method:e=>"function"==typeof e,email:e=>"string"==typeof e&&e.length<=320&&!!e.match(sr),url:e=>"string"==typeof e&&e.length<=2048&&!!e.match((()=>{if(nr)return nr;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 nr=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"),nr})()),hex:e=>"string"==typeof e&&!!e.match(ir)},ar="enum";var cr={required:rr,whitespace:(e,t,r,n,s)=>{(/^\s+$/.test(t)||""===t)&&n.push(Gt(s.messages.whitespace,e.fullField))},type:(e,t,r,n,s)=>{if(e.required&&void 0===t)return void rr(e,t,r,n,s);const i=e.type;["integer","float","array","regexp","object","method","email","number","date","url","hex"].indexOf(i)>-1?or[i](t)||n.push(Gt(s.messages.types[i],e.fullField,e.type)):i&&typeof t!==e.type&&n.push(Gt(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,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),i?l!==e.len&&n.push(Gt(s.messages[u].len,e.fullField,e.len)):o&&!a&&l<e.min?n.push(Gt(s.messages[u].min,e.fullField,e.min)):a&&!o&&l>e.max?n.push(Gt(s.messages[u].max,e.fullField,e.max)):o&&a&&(l<e.min||l>e.max)&&n.push(Gt(s.messages[u].range,e.fullField,e.min,e.max))},enum:(e,t,r,n,s)=>{e[ar]=Array.isArray(e[ar])?e[ar]:[],-1===e[ar].indexOf(t)&&n.push(Gt(s.messages[ar],e.fullField,e[ar].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(Gt(s.messages.pattern.mismatch,e.fullField,t,e.pattern));else if("string"==typeof e.pattern){new RegExp(e.pattern).test(t)||n.push(Gt(s.messages.pattern.mismatch,e.fullField,t,e.pattern))}}};const lr=(e,t,r,n,s)=>{const i=e.type,o=[];if(e.required||!e.required&&n.hasOwnProperty(e.field)){if(Jt(t,i)&&!e.required)return r();cr.required(e,t,n,o,s,i),Jt(t,i)||cr.type(e,t,n,o,s)}r(o)};var ur={string:(e,t,r,n,s)=>{const i=[];if(e.required||!e.required&&n.hasOwnProperty(e.field||"")){if(Jt(t,"string")&&!e.required)return r();cr.required(e,t,n,i,s,"string"),Jt(t,"string")||(cr.type(e,t,n,i,s),cr.range(e,t,n,i,s),cr.pattern(e,t,n,i,s),!0===e.whitespace&&cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&cr.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),Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&(cr.type(e,t,n,i,s),cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),Jt(t)||cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&(cr.type(e,t,n,i,s),cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&(cr.type(e,t,n,i,s),cr.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();cr.required(e,t,n,i,s,"array"),null!=t&&(cr.type(e,t,n,i,s),cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s),void 0!==t&&cr.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(Jt(t,"string")&&!e.required)return r();cr.required(e,t,n,i,s),Jt(t,"string")||cr.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(Jt(t,"date")&&!e.required)return r();if(cr.required(e,t,n,i,s),!Jt(t,"date")){let r;r=t instanceof Date?t:new Date(t),cr.type(e,r,n,i,s),r&&cr.range(e,r.getTime(),n,i,s)}}r(i)},url:lr,hex:lr,email:lr,required:(e,t,r,n,s)=>{const i=[],o=Array.isArray(t)?"array":typeof t;cr.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(Jt(t)&&!e.required)return r();cr.required(e,t,n,i,s)}r(i)}};function hr(){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 dr=hr();class fr{static register=function(e,t){if("function"!=typeof t)throw new Error("Cannot register a validator by type, validator is not a function");ur[e]=t};static warning=Wt;static messages=dr;static validators=ur;rules={};_messages=dr;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=tr(hr(),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===dr&&(e=hr()),tr(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 Xt(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&&fr.warning("async-validator:",l),l.length&&void 0!==r.message&&(l=[].concat(r.message));let u=l.map(er(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(er(r,n)):s.error&&(u=[s.error(r,Gt(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 fr(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=Zt(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&&!ur.hasOwnProperty(e.type))throw new Error(Gt("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]?ur.required:ur[this.getType(e)]||void 0}}function pr(e){return new fr(e)}var gr={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:pr,validate:function(e,t,r={},n=(()=>{})){return ye.run(pr(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 yr={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 mr={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 wr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var br={toBase64:(e="")=>{let t,r,n,s,i,o,a,c="",l=0;for(e=mr.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+wr.charAt(s)+wr.charAt(i)+wr.charAt(o)+wr.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=wr.indexOf(e.charAt(l++)),i=wr.indexOf(e.charAt(l++)),o=wr.indexOf(e.charAt(l++)),a=wr.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=mr.fromUtf8(c),c},bytesToBase64:e=>{let t,r,n,s,i,o,a,c="",l=0;if(!e||!H.isArrayLike(e)||!H.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+wr.charAt(s)+wr.charAt(i)+wr.charAt(o)+wr.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=wr.indexOf(e.charAt(l++)),i=wr.indexOf(e.charAt(l++)),o=wr.indexOf(e.charAt(l++)),a=wr.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 vr=e=>br.toBase64(e);var _r={encode:vr,decode:e=>br.fromBase64(e),encodeByOss:e=>vr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var xr={...f,base64:_r,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 Sr=e=>{if(!e)return"";if(!At.isObject(e))return"";let t="";return At.forof(e,((e,r)=>{r&&(t+=`${bt.kebabCase(e)}:${r};`)})),t},kr=["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"],$r=["top","bottom","left","right","padding","margin","marginTop","marginRight","marginBottom","marginLeft","paddingTop","paddingRight","paddingBottom","paddingLeft","height","width","border","borderLeft","borderRight","borderTop","borderBottom","borderColor","borderRadius"],Ar=(e,t="px")=>e&&t?"0"===e?e:gr.isFloat(e.toString())?`${e}${t}`:e:e;var Cr={stringify:Sr,parse:(e,{camel:t=!1,pure:r=!0}={})=>{if(!e.trim())return;const n=Ht.parse(e,{sep:";",eq:":",uri:!1}),s={};return At.forof(n,((e,n)=>{if(!n)return;const i=t?r&&e.startsWith("_")?e:bt.camelCase(e):e;gr.isFloat(n)||n.length>=2&&n.startsWith(".")&&gr.isNumber(n.substr(1))?s[i]=+n:s[i]=n})),s},fixValue:Ar,style:(e,t="px")=>{if(!e)return"";const r=At.copy(e,{fields:kr});At.forof(r,((e,n)=>{($r.includes(e)||$r.includes(bt.camelCase(e)))&&(r[e]=Ar(n,t))}));return Sr(r)},commonFields:kr};const Or=(e,t="",r=!1)=>{try{if(!e)return;const n=Ht.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}?${Ht.stringify(t,{uri:!1})}`,i=new XMLHttpRequest;i.open("GET",r,!0),i.responseType="blob",i.onload=function(){Er(i.response,s)},i.onerror=function(t){console.error(`[ddan] downloadUrl ${e}`,t)},i.send()}}catch(t){console.error(`[ddan] downloadUrl ${e}`,t)}},Er=(e,t="")=>{try{if(!e)return;const r=URL?.createObjectURL(e);if(!r)return;Or(r,t),URL?.revokeObjectURL(r)}catch(e){console.error("[ddan] downloadFile",e)}},qr=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}},jr=(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)))})),Lr=(e,t=!0)=>!(!t||"prompt"!==e)||"granted"===e;var Pr={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:Or,download:(e,t="")=>{e&&("string"!=typeof e?Er(e,t):Or(e,t))},downloadFile:Er,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();Or(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?jr("clipboard-write").then((t=>{Lr(t,!1)?navigator.clipboard.writeText(e).then((()=>r(!0))).catch((()=>r(qr(e)))):r(qr(e))})).catch((()=>{r(qr(e))})):r(qr(e))})),queryPermission:jr,isAllowed:Lr,legacyCopy:qr};var Tr={ossImage:(e,t={})=>{if(!e)return e;const r=Ht.parseUrl(e).url;if(t.domain){if(!e.startsWith("http"))return e;const r=Ot.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=Ht.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=>br.toBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")};var Fr={...mr,...br,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 br.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?br.bytesToBase64(r):r.reduce(((e,t)=>e+String.fromCharCode(t)),"")},bytesToStr:e=>{if(!e||!H.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=>H.isBrowser?btoa(e):Buffer.from(e,"utf-8").toString("base64"),base64ToUtf8:e=>H.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]=ve.random(256);return t},textEncode:e=>mr.toUtf8Bytes(e),textDecode:e=>mr.fromUtf8Bytes(new Uint8Array(e))};const Mr=({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 Rr(e){const{response:t}=e;return 0===t.code?Promise.resolve(t):Promise.reject(t)}function Br(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(At.isPlainObject(e)){const r=Ht.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 Dr{host="";reqConfig={};handleError;interceptors={request:new Tt,response:new Tt};constructor(e){this.host=e.host||"",this.reqConfig=e.config,this.interceptors.request.use(e.handleRequest||[]),this.interceptors.request.use(Br),this.interceptors.response.use(e.handleResponse||Rr),this.handleError=e.handleError}static blockId="blockid";static requestLock={};lockR(e,t){Dr.requestLock[e]={lock:!0,request:t()}}unlockR(e){delete Dr.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=At.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(Dr.blockId,(()=>Mr(s))),i=await Dr.requestLock[Dr.blockId].request;else if(Dr.requestLock[Dr.blockId]&&Dr.requestLock[Dr.blockId].lock&&await Dr.requestLock[Dr.blockId].request,"debounce"===r.model||"debounceUrl"===r.model){let e;e="debounceUrl"===r.model?this.getIdFromReqUrl(s):this.getIdFromReq(s),Dr.requestLock[e]||this.lockR(e,(()=>Mr(s))),i=await Dr.requestLock[e].request,this.unlockR(e)}else i=await Mr(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 Ir={overrode:!1,tag:!1,format:"hh:mm:ss.SSS"},Ur=e=>(...t)=>{const r=console[e];Ir.overrode?r(...t):zr(r,e,...t)},zr=(e,t,...r)=>{const n=x.format(new Date,Ir.format),s=Ir.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 Kr={override:()=>{if(Ir.overrode)return;Ir.overrode=!0;["log","info","warn","error"].forEach((e=>{const t=console[e];console[e]=(...r)=>{zr(t,e,...r)}}))},log:Ur("log"),info:Ur("info"),warn:Ur("warn"),error:Ur("error"),config:({tag:e=Ir.tag,format:t=Ir.format}={})=>{Ir.tag=e,Ir.format=t}};var Nr={getDataURL:e=>{const t={contentType:"",dataUrl:""};return ue.to(fetch(e).then((e=>(t.contentType=e.headers.get("content-type")||"",e.arrayBuffer()))).then((e=>(t.dataUrl=`data:${t.contentType};base64,`+Fr.ab2str(e,!0),t))))},getArrayBuffer:async e=>ue.to(fetch(e).then((e=>e.arrayBuffer()))),getJson:async e=>ue.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=ve.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 Hr=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,${_r.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}`}},Vr=(e,t,r)=>({key:e,fields:t,storage:r});class Wr{key;storage;fields=[];constructor(e){this.key=e?.key||"",this.fields=e?.fields||[],this.storage=e?.storage||void 0}save=ye.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=$t.copy(e,{fields:this.fields});this.save(r)}}class Zr extends g{setters={};getters={};actions={};persist;constructor(){super()}async dispatch(e,t=void 0){const r=this,n=Reflect.get(r.actions,e);if(!H.isFunction(n))return;const[,s]=await ye.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=$t.copy(t);else{const[,t]=await ye.exec((()=>this.dispatch(e)),`${this.__eventId}_${e}`);r=t}return r}commit(e,t){H.isObject(t)&&(t=$t.copy(t)),this[e]=t}}const Gr=(e,t)=>{const r=Object.assign(new Zr,e||{});r.__persist=new Wr(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 H.isFunction(n)?n(e):Reflect.get(e,t,r)},set:(e,t,r,n)=>{const s=Reflect.get(e.setters,t);if(H.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 Jr{host="";list=[];constructor(e,t={}){this._parseHost(e);const{width:r=500,height:n=400}=t,s=Ht.parseUrl(e)?.params||{};s["x-oss-process"]=`image/resize,w_${r},h_${n},m_fill`;const i=Ht.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=xr.base64.encodeByOss(n),i=Ht.stringify({image:s,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}text(e,t={},r={}){if(!e)return;const n={g:"nw",...t},s=xr.base64.encodeByOss(e),i=Ht.stringify({text:s,...n,...r},{sep:",",eq:"_"});this.list.push(`/watermark,${i}`)}result(){return this.list.join("")}}const Yr=(e,t)=>new Jr(e,t);class Qr{__list=[];constructor(){this.clear()}add(e){const t=ye.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 Xr=new class{state=Gr(new Zr);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=At.copy(r);At.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 Qr};class en{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 tn=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 en;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=$t.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 Ot.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)))}},rn=e=>{try{const t=Fr.ab2str(e,!0);return t.match(/.{1,64}/g)?.join("\n")||""}catch(e){return""}},nn=(e="",t="PUBLIC KEY")=>`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`;var sn={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=rn(t),n=nn(r,"PUBLIC KEY"),s=await window.crypto.subtle.exportKey("pkcs8",e.privateKey),i=rn(s);return{publicKey:r,publicKeyPem:n,privateKey:i,privateKeyPem:nn(i,"PRIVATE KEY")}}catch(e){return console.error("generateKeys failed:",e),{publicKey:"",publicKeyPem:"",privateKey:"",privateKeyPem:""}}},format_pem_key:nn,format_pem_content:rn,encrypt:async(e,t)=>{try{const r=(new TextEncoder).encode(e),n=await window.crypto.subtle.importKey("spki",Fr.str2ab(t,!0),{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},n,r);return Fr.ab2str(s,!0)}catch(e){return console.error("encrypt failed:",e),""}},decrypt:async(e,t)=>{try{const r=Fr.str2ab(e,!0),n=await window.crypto.subtle.importKey("pkcs8",Fr.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 on={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 an=a.default?.webcrypto?.subtle;var cn={...on,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",Fr.base64ToBytes(this.sharedSecret),Fr.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",Fr.base64ToBytes(this.sharedSecret),Fr.base64ToBytes(r));n.setAuthTag(Fr.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 an.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 an.exportKey("spki",e);return Fr.ab2str(t,!0)}async importSpkiKey(e){const t=Fr.base64ToBytes(e);return await an.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 an.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=Fr.textEncode(e),r=await an.encrypt({name:"AES-GCM",iv:Fr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Fr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Fr.str2ab(e,!0),n=await an.decrypt({name:"AES-GCM",iv:Fr.base64ToBytes(t)},this.__sharedSecret,r);return Fr.textDecode(n)}},SockServer:class{upstreamProxy;server=null;clientSockets=new Set;allowedDomains;connectionPool={};__debug=!1;constructor(e,t=[],r=!1){this.upstreamProxy=e,this.allowedDomains=new Set(t),this.__debug=!1}validateProxyConfig(e){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.server)return console.log("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(`SOCKS5 proxy server is running on port ${t}`)})),this.server.on("error",(e=>{console.error("SOCKS5 proxy server error:",e),this.close()})),t):t}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("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("SockServer handleSocksConnection",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("Error handling SOCKS connection:",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 console.log(`Reusing connection for ${t}`),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=>{console.error("Client socket error:",e),t.end()})),t.on("error",(t=>{console.error("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("Closing SOCKS5 proxy server..."),this.server.close((e=>{e&&console.error("Error closing the server:",e)})),this.clientSockets.forEach((e=>e.destroy())),Object.values(this.connectionPool).forEach((e=>e.destroy())),this.server=null)}}};var ln={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 Fr.ab2str(t,!0)}async importSpkiKey(e){const t=Fr.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=Fr.textEncode(e),r=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:Fr.base64ToBytes(this.iv)},this.__sharedSecret,t),n=Fr.ab2str(r,!0);return{iv:this.iv,text:n}}async decode(e,t){if(!this.__sharedSecret||!t)return"";const r=Fr.str2ab(e,!0),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:Fr.base64ToBytes(t)},this.__sharedSecret,r);return Fr.textDecode(n)}}};const un={gbk:l,math:ve,list:Ot,string:bt,time:x,obj:$t,rule:gr,regex:yr,...Fr,...xr,...At,Event:g},hn={...Fr,...xr,...ye},dn={mini:Rt,css:Cr,qs:Ht,icon:Hr,html:Pr},fn={cdn:Tr,watermark:Yr},pn={Store:Zr,storeRef:Gr,Persist:Wr,persistConfig:Vr},gn=Xr,yn=tn,mn=Kr,wn={fetch:Nr,Http:Dr,css:Cr,qs:Ht,icon:Hr,html:Pr,rsa:sn,...ln},bn={...cn};var vn={gbk:l,time:x,hook:ye,math:ve,util:At,list:Ot,string:bt,obj:$t,crypto:xr,mini:Rt,qs:Ht,css:Cr,cdn:Tr,html:Pr,icon:Hr,rule:gr,regex:yr,convert:Fr,Event:g,Http:Dr,Store:Zr,storeRef:Gr,Persist:Wr,persistConfig:Vr,watermark:Yr,joker:Xr,tracker:tn,logger:Kr,fetch:Nr,rsa:sn};e.dCdn=fn,e.dHook=hn,e.dJoker=gn,e.dLogger=mn,e.dMini=dn,e.dNode=bn,e.dStore=pn,e.dTracker=yn,e.dUtil=un,e.dWeb=wn,e.default=vn,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const brotli_1 = require("./brotli");
|
|
4
4
|
const ecdh_1 = require("./ecdh");
|
|
5
5
|
const ecdhSpki_1 = require("./ecdhSpki");
|
|
6
|
-
|
|
6
|
+
const sockServer_1 = require("./sockServer");
|
|
7
|
+
exports.default = { ...brotli_1.default, Ecdh: ecdh_1.default, EcdhSpki: ecdhSpki_1.default, SockServer: sockServer_1.SockServer };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SockServer = void 0;
|
|
4
|
+
const net_1 = require("net");
|
|
5
|
+
const socks_1 = require("socks");
|
|
6
|
+
class SockServer {
|
|
7
|
+
upstreamProxy;
|
|
8
|
+
server = null;
|
|
9
|
+
clientSockets = new Set();
|
|
10
|
+
allowedDomains;
|
|
11
|
+
connectionPool = {};
|
|
12
|
+
__debug = false;
|
|
13
|
+
constructor(upstreamProxy, allowedDomains = [], debug = false) {
|
|
14
|
+
this.upstreamProxy = upstreamProxy;
|
|
15
|
+
this.allowedDomains = new Set(allowedDomains);
|
|
16
|
+
this.__debug = false;
|
|
17
|
+
}
|
|
18
|
+
validateProxyConfig(proxyConfig) {
|
|
19
|
+
const { ipaddress, port, userId, password } = proxyConfig;
|
|
20
|
+
if (!ipaddress || typeof ipaddress !== 'string') {
|
|
21
|
+
return '无效的上游代理 IP 地址';
|
|
22
|
+
}
|
|
23
|
+
if (!port || typeof port !== 'number') {
|
|
24
|
+
return '无效的上游代理端口';
|
|
25
|
+
}
|
|
26
|
+
if (!userId || typeof userId !== 'string') {
|
|
27
|
+
return '无效的上游代理用户名';
|
|
28
|
+
}
|
|
29
|
+
if (!password || typeof password !== 'string') {
|
|
30
|
+
return '无效的上游代理密码';
|
|
31
|
+
}
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
async start(startPort = 9968) {
|
|
35
|
+
if (this.server) {
|
|
36
|
+
console.log(`Server is already running`);
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
const port = await this.findAvailablePort(startPort);
|
|
40
|
+
if (!port)
|
|
41
|
+
return port;
|
|
42
|
+
this.server = net_1.default.createServer((socket) => this.handleSocksConnection(socket));
|
|
43
|
+
this.server.listen(port, () => {
|
|
44
|
+
this.__debug && console.log(`SOCKS5 proxy server is running on port ${port}`);
|
|
45
|
+
});
|
|
46
|
+
this.server.on('error', (err) => {
|
|
47
|
+
console.error('SOCKS5 proxy server error:', err);
|
|
48
|
+
this.close();
|
|
49
|
+
});
|
|
50
|
+
return port;
|
|
51
|
+
}
|
|
52
|
+
async findAvailablePort(startPort, maxRetries = 200 // 最大重试次数
|
|
53
|
+
) {
|
|
54
|
+
let port = startPort;
|
|
55
|
+
let retries = 0;
|
|
56
|
+
while (retries < maxRetries) {
|
|
57
|
+
try {
|
|
58
|
+
await new Promise((resolve, reject) => {
|
|
59
|
+
const testServer = net_1.default.createServer();
|
|
60
|
+
testServer.unref();
|
|
61
|
+
testServer.on('error', reject);
|
|
62
|
+
testServer.listen(port, () => {
|
|
63
|
+
testServer.close(() => resolve());
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return port; // 找到可用端口
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
retries++; // 记录重试次数
|
|
70
|
+
port++; // 尝试下一个端口
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
console.warn('findAvailablePort failed');
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
async handleSocksConnection(clientSocket) {
|
|
77
|
+
this.clientSockets.add(clientSocket);
|
|
78
|
+
clientSocket.on('close', () => {
|
|
79
|
+
this.clientSockets.delete(clientSocket);
|
|
80
|
+
clientSocket?.destroy();
|
|
81
|
+
});
|
|
82
|
+
try {
|
|
83
|
+
await this.performHandshake(clientSocket);
|
|
84
|
+
const destination = await this.parseClientRequest(clientSocket);
|
|
85
|
+
this.__debug && console.log(`SockServer handleSocksConnection`, destination.addr);
|
|
86
|
+
if (this.isAllowedDomain(destination.addr)) {
|
|
87
|
+
// 允许的域名,走上游代理
|
|
88
|
+
const upstreamSocket = await this.connectToUpstreamProxy(destination);
|
|
89
|
+
this.setupDataForwarding(clientSocket, upstreamSocket);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// 不允许的域名,走本地连接
|
|
93
|
+
const localSocket = await this.connectToLocal(destination);
|
|
94
|
+
this.setupDataForwarding(clientSocket, localSocket);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
console.error('Error handling SOCKS connection:', err);
|
|
99
|
+
clientSocket.end(new Uint8Array([0x05, 0x01]));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
performHandshake(clientSocket) {
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
clientSocket.once('data', (data) => {
|
|
105
|
+
if (data[0] !== 0x05) {
|
|
106
|
+
return reject(new Error('Unsupported SOCKS version'));
|
|
107
|
+
}
|
|
108
|
+
clientSocket.write(new Uint8Array([0x05, 0x00]));
|
|
109
|
+
resolve();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
parseClientRequest(clientSocket) {
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
clientSocket.once('data', (data) => {
|
|
116
|
+
let addr;
|
|
117
|
+
let port;
|
|
118
|
+
if (data[1] !== 0x01) {
|
|
119
|
+
return reject(new Error('Unsupported command'));
|
|
120
|
+
}
|
|
121
|
+
if (data[3] === 0x01) {
|
|
122
|
+
// IPv4 地址
|
|
123
|
+
addr = data.slice(4, 8).join('.');
|
|
124
|
+
port = data.readUInt16BE(8);
|
|
125
|
+
}
|
|
126
|
+
else if (data[3] === 0x03) {
|
|
127
|
+
// 域名
|
|
128
|
+
const len = data[4];
|
|
129
|
+
addr = data.slice(5, 5 + len).toString();
|
|
130
|
+
port = data.readUInt16BE(5 + len);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return reject(new Error('Unsupported address type'));
|
|
134
|
+
}
|
|
135
|
+
resolve({ addr, port });
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// 上游代理连接
|
|
140
|
+
async connectToUpstreamProxy(destination) {
|
|
141
|
+
const destKey = `${destination.addr}:${destination.port}`;
|
|
142
|
+
// 如果已有连接在池中,复用
|
|
143
|
+
if (this.connectionPool[destKey] && !this.connectionPool[destKey].destroyed) {
|
|
144
|
+
console.log(`Reusing connection for ${destKey}`);
|
|
145
|
+
return this.connectionPool[destKey];
|
|
146
|
+
}
|
|
147
|
+
const options = {
|
|
148
|
+
proxy: { ...this.upstreamProxy, type: 5 },
|
|
149
|
+
command: 'connect',
|
|
150
|
+
destination: {
|
|
151
|
+
host: destination.addr,
|
|
152
|
+
port: destination.port,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
try {
|
|
156
|
+
const { socket: upstreamSocket } = await socks_1.SocksClient.createConnection(options);
|
|
157
|
+
this.connectionPool[destKey] = upstreamSocket;
|
|
158
|
+
upstreamSocket.on('close', () => {
|
|
159
|
+
delete this.connectionPool[destKey];
|
|
160
|
+
});
|
|
161
|
+
return upstreamSocket;
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
throw new Error('Failed to connect to upstream proxy: ' + err);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// 本地连接
|
|
168
|
+
connectToLocal(destination) {
|
|
169
|
+
return new Promise((resolve, reject) => {
|
|
170
|
+
const localSocket = net_1.default.createConnection(destination.port, destination.addr, () => {
|
|
171
|
+
resolve(localSocket);
|
|
172
|
+
});
|
|
173
|
+
localSocket.on('error', (err) => {
|
|
174
|
+
reject(err);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
setupDataForwarding(clientSocket, targetSocket) {
|
|
179
|
+
clientSocket.write(new Uint8Array([0x05, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]));
|
|
180
|
+
clientSocket.pipe(targetSocket);
|
|
181
|
+
targetSocket.pipe(clientSocket);
|
|
182
|
+
clientSocket.on('close', () => {
|
|
183
|
+
targetSocket.end();
|
|
184
|
+
});
|
|
185
|
+
targetSocket.on('close', () => {
|
|
186
|
+
clientSocket.end();
|
|
187
|
+
});
|
|
188
|
+
clientSocket.on('error', (err) => {
|
|
189
|
+
console.error('Client socket error:', err);
|
|
190
|
+
targetSocket.end();
|
|
191
|
+
});
|
|
192
|
+
targetSocket.on('error', (err) => {
|
|
193
|
+
console.error('Target socket error:', err);
|
|
194
|
+
clientSocket.end();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
isAllowedDomain(addr) {
|
|
198
|
+
// return this.allowedDomains.has(addr);
|
|
199
|
+
// 只匹配主域名,忽略子域名
|
|
200
|
+
for (const domain of this.allowedDomains) {
|
|
201
|
+
if (domain === '*')
|
|
202
|
+
return true;
|
|
203
|
+
if (addr.includes(domain))
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
close() {
|
|
209
|
+
if (this.server) {
|
|
210
|
+
console.log('Closing SOCKS5 proxy server...');
|
|
211
|
+
this.server.close((err) => {
|
|
212
|
+
if (err) {
|
|
213
|
+
console.error('Error closing the server:', err);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
// 销毁客户端 socket
|
|
217
|
+
this.clientSockets.forEach((socket) => socket.destroy());
|
|
218
|
+
// 销毁所有连接池中的 socket
|
|
219
|
+
Object.values(this.connectionPool).forEach((socket) => socket.destroy());
|
|
220
|
+
this.server = null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.SockServer = SockServer;
|
package/bin/types/index.d.ts
CHANGED
|
@@ -501,6 +501,7 @@ declare const dWeb: {
|
|
|
501
501
|
declare const dNode: {
|
|
502
502
|
Ecdh: typeof import("./modules/node/ecdh").default;
|
|
503
503
|
EcdhSpki: typeof import("./modules/node/ecdhSpki").default;
|
|
504
|
+
SockServer: typeof import("./modules/node/sockServer").SockServer;
|
|
504
505
|
brotliCompress: typeof import("./modules/node/brotli").brotliCompress;
|
|
505
506
|
brotliDecompress: typeof import("./modules/node/brotli").brotliDecompress;
|
|
506
507
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import Ecdh from "./ecdh";
|
|
2
2
|
import EcdhSpki from "./ecdhSpki";
|
|
3
|
+
import { SockServer } from "./sockServer";
|
|
3
4
|
declare const _default: {
|
|
4
5
|
Ecdh: typeof Ecdh;
|
|
5
6
|
EcdhSpki: typeof EcdhSpki;
|
|
7
|
+
SockServer: typeof SockServer;
|
|
6
8
|
brotliCompress: typeof import("./brotli").brotliCompress;
|
|
7
9
|
brotliDecompress: typeof import("./brotli").brotliDecompress;
|
|
8
10
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface IProxyConfig {
|
|
2
|
+
ipaddress: string;
|
|
3
|
+
port: number;
|
|
4
|
+
type?: 5;
|
|
5
|
+
userId: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class SockServer {
|
|
9
|
+
private upstreamProxy;
|
|
10
|
+
private server;
|
|
11
|
+
private clientSockets;
|
|
12
|
+
private allowedDomains;
|
|
13
|
+
private connectionPool;
|
|
14
|
+
__debug: boolean;
|
|
15
|
+
constructor(upstreamProxy: IProxyConfig, allowedDomains?: string[], debug?: boolean);
|
|
16
|
+
validateProxyConfig(proxyConfig: IProxyConfig): "无效的上游代理 IP 地址" | "无效的上游代理端口" | "无效的上游代理用户名" | "无效的上游代理密码" | "";
|
|
17
|
+
start(startPort?: number): Promise<number>;
|
|
18
|
+
private findAvailablePort;
|
|
19
|
+
private handleSocksConnection;
|
|
20
|
+
private performHandshake;
|
|
21
|
+
private parseClientRequest;
|
|
22
|
+
private connectToUpstreamProxy;
|
|
23
|
+
private connectToLocal;
|
|
24
|
+
private setupDataForwarding;
|
|
25
|
+
private isAllowedDomain;
|
|
26
|
+
close(): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ddan-js",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddan-js",
|
|
@@ -143,5 +143,8 @@
|
|
|
143
143
|
"tslint-config-standard": "^9.0.0",
|
|
144
144
|
"typedoc": "^0.24.0",
|
|
145
145
|
"typescript": "^5.0.4"
|
|
146
|
+
},
|
|
147
|
+
"dependencies": {
|
|
148
|
+
"socks": "^2.8.3"
|
|
146
149
|
}
|
|
147
150
|
}
|