esexts 2.2.4 → 2.2.5

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/dist/esexts.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function r(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function i(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(){return JSON.stringify(this)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...n(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...n(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{$length:function(){return this.length},$substring:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...n(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},end:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var s=0,c=0,l=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var u=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u);
1
+ "use strict";function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function r(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function i(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(...e){return JSON.stringify(this,...e)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...n(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...n(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{$length:function(){return this.length},$substring:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...n(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},end:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var s=0,c=0,l=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var u=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u);
package/dist/esexts.d.ts CHANGED
@@ -40,17 +40,32 @@ declare global {
40
40
  * Object 实例扩展
41
41
  */
42
42
  interface Object {
43
+ /**
44
+ * 将值转换为 JSON 字符串
45
+ * @param v 要转换的值
46
+ * @param replacer 替换函数或数组
47
+ * @param space 缩进空格
48
+ * @returns JSON 字符串
49
+ */
50
+ $stringify(replacer?: any, space?: string | number): string;
51
+
43
52
  /**
44
53
  * 克隆对象
45
54
  * @returns 克隆后的新对象
46
55
  */
47
- $clone(): Record<string, any>;
56
+ $clone(): this;
48
57
 
49
58
  /**
50
59
  * 获取对象的长度(属性数量)
51
60
  * @returns 对象的属性数量
52
61
  */
53
62
  $length(): number;
63
+
64
+ /**
65
+ * 检查对象是否为空
66
+ * @returns 如果对象为空返回 true,否则返回 false
67
+ */
68
+ $empty(): boolean;
54
69
 
55
70
  /**
56
71
  * 获取对象的键值对迭代器
@@ -77,15 +92,6 @@ declare global {
77
92
  */
78
93
  $assign(...sources: any[]): Record<string, any>;
79
94
 
80
- /**
81
- * 将值转换为 JSON 字符串
82
- * @param v 要转换的值
83
- * @param replacer 替换函数或数组
84
- * @param space 缩进空格
85
- * @returns JSON 字符串
86
- */
87
- $stringify(replacer?: any, space?: string | number): string;
88
-
89
95
  /**
90
96
  * 合并多个对象到当前对象
91
97
  * @param args 要合并的对象列表
@@ -100,12 +106,6 @@ declare global {
100
106
  */
101
107
  $concat(...args: Record<string, any>[]): Record<string, any>;
102
108
 
103
- /**
104
- * 检查对象是否为空
105
- * @returns 如果对象为空返回 true,否则返回 false
106
- */
107
- $empty(): boolean;
108
-
109
109
  /**
110
110
  * 检查对象是否包含指定键
111
111
  * @param key 要检查的键
@@ -692,11 +692,32 @@ declare global {
692
692
  * Array 实例扩展
693
693
  */
694
694
  interface Array<T> {
695
+ /**
696
+ * 将值转换为 JSON 字符串
697
+ * @param v 要转换的值
698
+ * @param replacer 替换函数或数组
699
+ * @param space 缩进空格
700
+ * @returns JSON 字符串
701
+ */
702
+ $stringify(replacer?: any, space?: string | number): string;
703
+
704
+ /**
705
+ * 克隆数组
706
+ * @returns 克隆后的新数组
707
+ */
708
+ $clone(): this;
709
+
695
710
  /**
696
711
  * 获取数组长度
697
712
  * @returns 数组长度
698
713
  */
699
714
  $length(): number;
715
+
716
+ /**
717
+ * 检查数组是否为空
718
+ * @returns 如果数组为空返回 true,否则返回 false
719
+ */
720
+ $empty(): boolean;
700
721
 
701
722
  /**
702
723
  * 获取数组的键值对迭代器
@@ -715,14 +736,7 @@ declare global {
715
736
  * @returns 值迭代器
716
737
  */
717
738
  $values(): T[];
718
-
719
- /**
720
- * 映射数组元素
721
- * @param callback 映射函数
722
- * @returns 映射后的新数组
723
- */
724
- $map<U>(callback: (v: T, i: number, array: T[]) => U): U[];
725
-
739
+
726
740
  /**
727
741
  * 向数组末尾添加元素, 并返回当前数组
728
742
  * @param items 要添加的元素
@@ -786,12 +800,6 @@ declare global {
786
800
  */
787
801
  $unshift0(...items: T[]): T;
788
802
 
789
- /**
790
- * 检查数组是否为空
791
- * @returns 如果数组为空返回 true,否则返回 false
792
- */
793
- $empty(): boolean;
794
-
795
803
  /**
796
804
  * 获取数组的第一个元素
797
805
  * @param defval 默认值
@@ -951,10 +959,31 @@ declare global {
951
959
  */
952
960
  interface Map<K, V> {
953
961
  /**
954
- * 获取 Map 的大小
955
- * @returns Map 的大小
962
+ * 将值转换为 JSON 字符串
963
+ * @param v 要转换的值
964
+ * @param replacer 替换函数或数组
965
+ * @param space 缩进空格
966
+ * @returns JSON 字符串
967
+ */
968
+ $stringify(replacer?: any, space?: string | number): string;
969
+
970
+ /**
971
+ * 克隆 Map
972
+ * @returns 克隆后的新 Map
973
+ */
974
+ $clone(): this;
975
+
976
+ /**
977
+ * 获取 Map 长度
978
+ * @returns Map 长度
956
979
  */
957
980
  $length(): number;
981
+
982
+ /**
983
+ * 检查 Map 是否为空
984
+ * @returns 如果 Map 为空返回 true,否则返回 false
985
+ */
986
+ $empty(): boolean;
958
987
 
959
988
  /**
960
989
  * 获取 Map 的键值对迭代器
@@ -1122,28 +1151,49 @@ declare global {
1122
1151
  */
1123
1152
  interface Set<T> {
1124
1153
  /**
1125
- * 获取 Set 的大小
1126
- * @returns Set 的大小
1154
+ * 将值转换为 JSON 字符串
1155
+ * @param v 要转换的值
1156
+ * @param replacer 替换函数或数组
1157
+ * @param space 缩进空格
1158
+ * @returns JSON 字符串
1159
+ */
1160
+ $stringify(replacer?: any, space?: string | number): string;
1161
+
1162
+ /**
1163
+ * 克隆 Set
1164
+ * @returns 克隆后的新 Set
1165
+ */
1166
+ $clone(): this;
1167
+
1168
+ /**
1169
+ * 获取 Set 长度
1170
+ * @returns Set 长度
1127
1171
  */
1128
1172
  $length(): number;
1173
+
1174
+ /**
1175
+ * 检查 Set 是否为空
1176
+ * @returns 如果 Set 为空返回 true,否则返回 false
1177
+ */
1178
+ $empty(): boolean;
1129
1179
 
1130
1180
  /**
1131
1181
  * 获取 Set 的键值对迭代器
1132
1182
  * @returns 键值对迭代器
1133
1183
  */
1134
- $entries(): IterableIterator<[T, T]>;
1184
+ $entries(): [number, T][];
1135
1185
 
1136
1186
  /**
1137
1187
  * 获取 Set 的键迭代器
1138
1188
  * @returns 键迭代器
1139
1189
  */
1140
- $keys(): IterableIterator<T>;
1190
+ $keys(): number[];
1141
1191
 
1142
1192
  /**
1143
1193
  * 获取 Set 的值迭代器
1144
1194
  * @returns 值迭代器
1145
1195
  */
1146
- $values(): IterableIterator<T>;
1196
+ $values(): T[];
1147
1197
 
1148
1198
  /**
1149
1199
  * 添加元素, 并返回当前Map
package/dist/esexts.js CHANGED
@@ -75,8 +75,8 @@ e(Object, {
75
75
  return o(this, ...e);
76
76
  }
77
77
  }), e(Object.prototype, {
78
- $stringify: function() {
79
- return JSON.stringify(this);
78
+ $stringify: function(...e) {
79
+ return JSON.stringify(this, ...e);
80
80
  },
81
81
  $clone: function() {
82
82
  return JSON.parse(JSON.stringify(this));
@@ -1 +1 @@
1
- "use strict";(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function r(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function i(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(){return JSON.stringify(this)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...n(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...n(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{$length:function(){return this.length},$substring:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...n(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},end:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var s=0,c=0,l=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var u=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u)});
1
+ "use strict";(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function r(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function i(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(...e){return JSON.stringify(this,...e)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...n(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...n(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{$length:function(){return this.length},$substring:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...n(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},end:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var s=0,c=0,l=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var u=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",