@ztimson/utils 0.19.2 → 0.20.1
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/cache.d.ts +13 -5
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +292 -420
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -5
package/dist/cache.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
export type CacheOptions = {
|
|
2
|
+
/** Delete keys automatically after x amount of seconds */
|
|
3
|
+
ttl?: number;
|
|
4
|
+
/** Storage to persist cache */
|
|
5
|
+
storage?: Storage;
|
|
6
|
+
/** Key cache will be stored under */
|
|
7
|
+
storageKey?: string;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Map of data which tracks whether it is a complete collection & offers optional expiry of cached values
|
|
3
11
|
*/
|
|
4
12
|
export declare class Cache<K extends string | number | symbol, T> {
|
|
5
13
|
readonly key?: keyof T | undefined;
|
|
6
|
-
|
|
14
|
+
readonly options: CacheOptions;
|
|
7
15
|
private store;
|
|
8
16
|
/** Support index lookups */
|
|
9
17
|
[key: string | number | symbol]: T | any;
|
|
@@ -13,9 +21,9 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
13
21
|
* Create new cache
|
|
14
22
|
*
|
|
15
23
|
* @param {keyof T} key Default property to use as primary key
|
|
16
|
-
* @param
|
|
24
|
+
* @param options
|
|
17
25
|
*/
|
|
18
|
-
constructor(key?: keyof T | undefined,
|
|
26
|
+
constructor(key?: keyof T | undefined, options?: CacheOptions);
|
|
19
27
|
private getKey;
|
|
20
28
|
/**
|
|
21
29
|
* Get all cached items
|
|
@@ -30,7 +38,7 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
30
38
|
* @param {number | undefined} ttl Override default expiry
|
|
31
39
|
* @return {this}
|
|
32
40
|
*/
|
|
33
|
-
add(value: T, ttl?:
|
|
41
|
+
add(value: T, ttl?: any): this;
|
|
34
42
|
/**
|
|
35
43
|
* Add several rows to the cache
|
|
36
44
|
*
|
|
@@ -73,7 +81,7 @@ export declare class Cache<K extends string | number | symbol, T> {
|
|
|
73
81
|
*
|
|
74
82
|
* @param {K} key Key item will be cached under
|
|
75
83
|
* @param {T} value Item to cache
|
|
76
|
-
* @param {number | undefined} ttl Override default expiry
|
|
84
|
+
* @param {number | undefined} ttl Override default expiry in seconds
|
|
77
85
|
* @return {this}
|
|
78
86
|
*/
|
|
79
87
|
set(key: K, value: T, ttl?: number | undefined): this;
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(c,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(c=typeof globalThis<"u"?globalThis:c||self,m(c.utils={}))})(this,function(c){"use strict";var
|
|
2
|
-
`)}class j extends Promise{constructor(e){super((r,i)=>e(s=>r(s),s=>i(s),s=>this.progress=s));a(this,"listeners",[]);a(this,"_progress",0)}get progress(){return this._progress}set progress(e){e!=this._progress&&(this._progress=e,this.listeners.forEach(r=>r(e)))}static from(e){return e instanceof j?e:new j((r,i)=>e.then((...s)=>r(...s)).catch((...s)=>i(...s)))}from(e){const r=j.from(e);return this.onProgress(i=>r.progress=i),r}onProgress(e){return this.listeners.push(e),this}then(e,r){const i=super.then(e,r);return this.from(i)}catch(e){return this.from(super.catch(e))}finally(e){return this.from(super.finally(e))}}function Ct(n,t){n instanceof Blob||(n=new Blob(S(n)));const e=URL.createObjectURL(n);ut(e,t),URL.revokeObjectURL(e)}function ut(n,t){const e=document.createElement("a");e.href=n,e.download=t||n.split("/").pop(),document.body.appendChild(e),e.click(),document.body.removeChild(e)}function Nt(n={}){return new Promise(t=>{const e=document.createElement("input");e.type="file",e.accept=n.accept||"*",e.style.display="none",e.multiple=!!n.multiple,e.onblur=e.onchange=async()=>{t(Array.from(e.files)),e.remove()},document.body.appendChild(e),e.click()})}function Lt(n,t=new Date){(typeof t=="number"||typeof t=="string")&&(t=new Date(t));const e=`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}-${t.getDate().toString().padStart(2,"0")}_${t.getHours().toString().padStart(2,"0")}-${t.getMinutes().toString().padStart(2,"0")}-${t.getSeconds().toString().padStart(2,"0")}`;return n?n.replace("{{TIMESTAMP}}",e):e}function Pt(n){return new j((t,e,r)=>{const i=new XMLHttpRequest,s=new FormData;n.files.forEach(o=>s.append("file",o)),i.withCredentials=!!n.withCredentials,i.upload.addEventListener("progress",o=>o.lengthComputable?r(o.loaded/o.total):null),i.addEventListener("loadend",()=>t(P(i.responseText))),i.addEventListener("error",()=>e(P(i.responseText))),i.addEventListener("timeout",()=>e({error:"Request timed out"})),i.open("POST",n.url),Object.entries(n.headers||{}).forEach(([o,u])=>i.setRequestHeader(o,u)),i.send(s)})}class F{constructor(){a(this,"listeners",{})}static emit(t,...e){(this.listeners["*"]||[]).forEach(r=>r(t,...e)),(this.listeners[t.toString()]||[]).forEach(r=>r(...e))}static off(t,e){const r=t.toString();this.listeners[r]=(this.listeners[r]||[]).filter(i=>i===e)}static on(t,e){var i;const r=t.toString();return this.listeners[r]||(this.listeners[r]=[]),(i=this.listeners[r])==null||i.push(e),()=>this.off(t,e)}static once(t,e){return new Promise(r=>{const i=this.on(t,(...s)=>{r(s.length==1?s[0]:s),e&&e(...s),i()})})}emit(t,...e){(this.listeners["*"]||[]).forEach(r=>r(t,...e)),(this.listeners[t]||[]).forEach(r=>r(...e))}off(t,e){this.listeners[t]=(this.listeners[t]||[]).filter(r=>r===e)}on(t,e){var r;return this.listeners[t]||(this.listeners[t]=[]),(r=this.listeners[t])==null||r.push(e),()=>this.off(t,e)}once(t,e){return new Promise(r=>{const i=this.on(t,(...s)=>{r(s.length==1?s[0]:s),e&&e(...s),i()})})}}a(F,"listeners",{});class p extends Error{constructor(e,r){super(e);a(this,"_code");r!=null&&(this._code=r)}get code(){return this._code||this.constructor.code}set code(e){this._code=e}static from(e){const r=Number(e.statusCode)??Number(e.code),i=new this(e.message||e.toString());return Object.assign(i,{stack:e.stack,...e,code:r??void 0})}static instanceof(e){return e.constructor.code!=null}toString(){return this.message||super.toString()}}a(p,"code",500);class G extends p{constructor(t="Bad Request"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(G,"code",400);class H extends p{constructor(t="Unauthorized"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(H,"code",401);class Y extends p{constructor(t="Payment Required"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Y,"code",402);class W extends p{constructor(t="Forbidden"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(W,"code",403);class J extends p{constructor(t="Not Found"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(J,"code",404);class z extends p{constructor(t="Method Not Allowed"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(z,"code",405);class K extends p{constructor(t="Not Acceptable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(K,"code",406);class _ extends p{constructor(t="Internal Server Error"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(_,"code",500);class V extends p{constructor(t="Not Implemented"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(V,"code",501);class Z extends p{constructor(t="Bad Gateway"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Z,"code",502);class Q extends p{constructor(t="Service Unavailable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Q,"code",503);class X extends p{constructor(t="Gateway Timeout"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(X,"code",504);function Tt(n,t){if(n>=200&&n<300)return null;switch(n){case 400:return new G(t);case 401:return new H(t);case 402:return new Y(t);case 403:return new W(t);case 404:return new J(t);case 405:return new z(t);case 406:return new K(t);case 500:return new _(t);case 501:return new V(t);case 502:return new Z(t);case 503:return new Q(t);case 504:return new X(t);default:return new p(t,n)}}const b=class b{constructor(t={}){a(this,"interceptors",{});a(this,"headers",{});a(this,"url");this.url=t.url??null,this.headers=t.headers||{},t.interceptors&&t.interceptors.forEach(e=>b.addInterceptor(e))}static addInterceptor(t){const e=Object.keys(b.interceptors).length.toString();return b.interceptors[e]=t,()=>{b.interceptors[e]=null}}addInterceptor(t){const e=Object.keys(this.interceptors).length.toString();return this.interceptors[e]=t,()=>{this.interceptors[e]=null}}request(t={}){var i;if(!this.url&&!t.url)throw new Error("URL needs to be set");let e=((i=t.url)!=null&&i.startsWith("http")?t.url:(this.url||"")+(t.url||"")).replace(/([^:]\/)\/+/g,"$1");if(t.fragment&&(e.includes("#")?e.replace(/#.*(\?|\n)/g,(s,o)=>`#${t.fragment}${o}`):e+="#"+t.fragment),t.query){const s=Array.isArray(t.query)?t.query:Object.keys(t.query).map(o=>({key:o,value:t.query[o]}));e+=(e.includes("?")?"&":"?")+s.map(o=>`${o.key}=${o.value}`).join("&")}const r=m({"Content-Type":t.body?t.body instanceof FormData?"multipart/form-data":"application/json":void 0,...b.headers,...this.headers,...t.headers});return typeof t.body=="object"&&t.body!=null&&r["Content-Type"]=="application/json"&&(t.body=JSON.stringify(t.body)),new j((s,o,u)=>{fetch(e,{headers:r,method:t.method||(t.body?"POST":"GET"),body:t.body}).then(async l=>{var pt,wt;for(let f of[...Object.values(b.interceptors),...Object.values(this.interceptors)])await new Promise(D=>f(l,()=>D()));const k=l.headers.get("Content-Length"),it=k?parseInt(k,10):0;let gt=0;const st=(pt=l.body)==null?void 0:pt.getReader(),fe=new ReadableStream({start(f){function D(){st==null||st.read().then(L=>{if(L.done)return f.close();gt+=L.value.byteLength,u(gt/it),f.enqueue(L.value),D()}).catch(L=>f.error(L))}D()}});if(l.data=new Response(fe),t.decode==null||t.decode){const f=(wt=l.headers.get("Content-Type"))==null?void 0:wt.toLowerCase();f!=null&&f.includes("form")?l.data=await l.data.formData():f!=null&&f.includes("json")?l.data=await l.data.json():f!=null&&f.includes("text")?l.data=await l.data.text():f!=null&&f.includes("application")&&(l.data=await l.data.blob())}l.ok?s(l):o(l)})})}};a(b,"interceptors",{}),a(b,"headers",{});let x=b;function It(n){const t=n.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return P(decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join("")))}const v={CLEAR:"\x1B[0m",BRIGHT:"\x1B[1m",DIM:"\x1B[2m",UNDERSCORE:"\x1B[4m",BLINK:"\x1B[5m",REVERSE:"\x1B[7m",HIDDEN:"\x1B[8m"},N={BLACK:"\x1B[30m",RED:"\x1B[31m",GREEN:"\x1B[32m",YELLOW:"\x1B[33m",BLUE:"\x1B[34m",MAGENTA:"\x1B[35m",CYAN:"\x1B[36m",LIGHT_GREY:"\x1B[37m",GREY:"\x1B[90m",LIGHT_RED:"\x1B[91m",LIGHT_GREEN:"\x1B[92m",LIGHT_YELLOW:"\x1B[93m",LIGHT_BLUE:"\x1B[94m",LIGHT_MAGENTA:"\x1B[95m",LIGHT_CYAN:"\x1B[96m",WHITE:"\x1B[97m"},Mt={BLACK:"\x1B[40m",RED:"\x1B[41m",GREEN:"\x1B[42m",YELLOW:"\x1B[43m",BLUE:"\x1B[44m",MAGENTA:"\x1B[45m",CYAN:"\x1B[46m",WHITE:"\x1B[47m",GREY:"\x1B[100m"};var lt=(n=>(n[n.ERROR=0]="ERROR",n[n.WARN=1]="WARN",n[n.INFO=2]="INFO",n[n.LOG=3]="LOG",n[n.DEBUG=4]="DEBUG",n))(lt||{});const E=class E extends F{constructor(t){super(),this.namespace=t}pad(t,e,r,i=!1){const s=t.toString(),o=e-s.length;if(o<=0)return s;const u=Array(~~(o/r.length)).fill(r).join("");return i?s+u:u+s}format(...t){const e=new Date;return`${`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()} ${this.pad(e.getHours().toString(),2,"0")}:${this.pad(e.getMinutes().toString(),2,"0")}:${this.pad(e.getSeconds().toString(),2,"0")}.${this.pad(e.getMilliseconds().toString(),3,"0",!0)}`}${this.namespace?` [${this.namespace}]`:""} ${t.join(" ")}`}debug(...t){if(E.LOG_LEVEL<4)return;const e=this.format(...t);E.emit(4,e),console.debug(N.LIGHT_GREY+e+v.CLEAR)}log(...t){if(E.LOG_LEVEL<3)return;const e=this.format(...t);E.emit(3,e),console.log(v.CLEAR+e)}info(...t){if(E.LOG_LEVEL<2)return;const e=this.format(...t);E.emit(2,e),console.info(N.BLUE+e+v.CLEAR)}warn(...t){if(E.LOG_LEVEL<1)return;const e=this.format(...t);E.emit(1,e),console.warn(N.YELLOW+e+v.CLEAR)}error(...t){if(E.LOG_LEVEL<0)return;const e=this.format(...t);E.emit(0,e),console.error(N.RED+e+v.CLEAR)}};a(E,"LOG_LEVEL",4);let tt=E;function kt(n){const t=(u,l)=>l<1e-7?u:t(l,~~(u%l)),e=n.toString().length-2;let r=Math.pow(10,e),i=n*r;const s=t(i,r);i=~~(i/s),r=~~(r/s);const o=~~(i/r);return i-=o*r,`${o?o+" ":""}${~~i}/${~~r}`}function Dt(n){let t=n.split(" ");const e=t.length==2?Number(t[0]):0;return t=t.pop().split("/"),e+Number(t[0])/Number(t[1])}const et="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",nt="0123456789",rt="~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/",Ut=et+nt+rt;function qt(n,t=2){if(n===0)return"0 Bytes";const e=1024,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(n)/Math.log(e));return parseFloat((n/Math.pow(e,i)).toFixed(t))+" "+r[i]}function Ft(n){const t=/(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);if(!t)throw new Error(`Number cannot be parsed: ${n}`);return`${t[1]??""} (${t[2]}) ${t[3]}-${t[4]}`.trim()}function Gt(n,t,e){return`${n.slice(0,e)}${t}${n.slice(e+1)}`}function Ht(n,t,e=" ",r=!0){return r?n.toString().padStart(t,e):n.toString().padEnd(t,e)}function Yt(n){return Array(n).fill(null).map(()=>Math.round(Math.random()*15).toString(16)).join("")}function Wt(n,t=Ut){return Array(n).fill(null).map(()=>{const e=~~(Math.random()*t.length);return t[e]}).join("")}function Jt(n,t=!1,e=!1,r=!1){if(!t&&!e&&!r)throw new Error("Must enable at least one: letters, numbers, symbols");return Array(n).fill(null).map(()=>{let i;do{const s=~~(Math.random()*3);t&&s==0?i=et[~~(Math.random()*et.length)]:e&&s==1?i=nt[~~(Math.random()*nt.length)]:r&&s==2&&(i=rt[~~(Math.random()*rt.length)])}while(!i);return i}).join("")}function zt(n,t){if(typeof t=="string"&&(t=new RegExp(t,"g")),!t.global)throw new TypeError("Regular expression must be global.");let e=[],r;for(;(r=t.exec(n))!==null;)e.push(r);return e}function Kt(n){const t=new RegExp("(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$","gm").exec(n),e=(t==null?void 0:t.groups)??{},r=e.domain.split(".");if(e.port!=null&&(e.port=Number(e.port)),r.length>2&&(e.domain=r.splice(-2,2).join("."),e.subdomain=r.join(".")),e.query){const i=e.query.split("&"),s={};i.forEach(o=>{const[u,l]=o.split("=");s[u]=l}),e.query=s}return e}function ft(n){var t=_t(Zt(Qt(Vt(n),8*n.length)));return t.toLowerCase()}function _t(n){for(var t,e="0123456789ABCDEF",r="",i=0;i<n.length;i++)t=n.charCodeAt(i),r+=e.charAt(t>>>4&15)+e.charAt(15&t);return r}function Vt(n){for(var t=Array(n.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*n.length;e+=8)t[e>>5]|=(255&n.charCodeAt(e/8))<<e%32;return t}function Zt(n){for(var t="",e=0;e<32*n.length;e+=8)t+=String.fromCharCode(n[e>>5]>>>e%32&255);return t}function Qt(n,t){n[t>>5]|=128<<t%32,n[14+(t+64>>>9<<4)]=t;for(var e=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<n.length;o+=16){var u=e,l=r,k=i,it=s;r=g(r=g(r=g(r=g(r=y(r=y(r=y(r=y(r=d(r=d(r=d(r=d(r=h(r=h(r=h(r=h(r,i=h(i,s=h(s,e=h(e,r,i,s,n[o+0],7,-680876936),r,i,n[o+1],12,-389564586),e,r,n[o+2],17,606105819),s,e,n[o+3],22,-1044525330),i=h(i,s=h(s,e=h(e,r,i,s,n[o+4],7,-176418897),r,i,n[o+5],12,1200080426),e,r,n[o+6],17,-1473231341),s,e,n[o+7],22,-45705983),i=h(i,s=h(s,e=h(e,r,i,s,n[o+8],7,1770035416),r,i,n[o+9],12,-1958414417),e,r,n[o+10],17,-42063),s,e,n[o+11],22,-1990404162),i=h(i,s=h(s,e=h(e,r,i,s,n[o+12],7,1804603682),r,i,n[o+13],12,-40341101),e,r,n[o+14],17,-1502002290),s,e,n[o+15],22,1236535329),i=d(i,s=d(s,e=d(e,r,i,s,n[o+1],5,-165796510),r,i,n[o+6],9,-1069501632),e,r,n[o+11],14,643717713),s,e,n[o+0],20,-373897302),i=d(i,s=d(s,e=d(e,r,i,s,n[o+5],5,-701558691),r,i,n[o+10],9,38016083),e,r,n[o+15],14,-660478335),s,e,n[o+4],20,-405537848),i=d(i,s=d(s,e=d(e,r,i,s,n[o+9],5,568446438),r,i,n[o+14],9,-1019803690),e,r,n[o+3],14,-187363961),s,e,n[o+8],20,1163531501),i=d(i,s=d(s,e=d(e,r,i,s,n[o+13],5,-1444681467),r,i,n[o+2],9,-51403784),e,r,n[o+7],14,1735328473),s,e,n[o+12],20,-1926607734),i=y(i,s=y(s,e=y(e,r,i,s,n[o+5],4,-378558),r,i,n[o+8],11,-2022574463),e,r,n[o+11],16,1839030562),s,e,n[o+14],23,-35309556),i=y(i,s=y(s,e=y(e,r,i,s,n[o+1],4,-1530992060),r,i,n[o+4],11,1272893353),e,r,n[o+7],16,-155497632),s,e,n[o+10],23,-1094730640),i=y(i,s=y(s,e=y(e,r,i,s,n[o+13],4,681279174),r,i,n[o+0],11,-358537222),e,r,n[o+3],16,-722521979),s,e,n[o+6],23,76029189),i=y(i,s=y(s,e=y(e,r,i,s,n[o+9],4,-640364487),r,i,n[o+12],11,-421815835),e,r,n[o+15],16,530742520),s,e,n[o+2],23,-995338651),i=g(i,s=g(s,e=g(e,r,i,s,n[o+0],6,-198630844),r,i,n[o+7],10,1126891415),e,r,n[o+14],15,-1416354905),s,e,n[o+5],21,-57434055),i=g(i,s=g(s,e=g(e,r,i,s,n[o+12],6,1700485571),r,i,n[o+3],10,-1894986606),e,r,n[o+10],15,-1051523),s,e,n[o+1],21,-2054922799),i=g(i,s=g(s,e=g(e,r,i,s,n[o+8],6,1873313359),r,i,n[o+15],10,-30611744),e,r,n[o+6],15,-1560198380),s,e,n[o+13],21,1309151649),i=g(i,s=g(s,e=g(e,r,i,s,n[o+4],6,-145523070),r,i,n[o+11],10,-1120210379),e,r,n[o+2],15,718787259),s,e,n[o+9],21,-343485551),e=O(e,u),r=O(r,l),i=O(i,k),s=O(s,it)}return Array(e,r,i,s)}function T(n,t,e,r,i,s){return O(Xt(O(O(t,n),O(r,s)),i),e)}function h(n,t,e,r,i,s,o){return T(t&e|~t&r,n,t,i,s,o)}function d(n,t,e,r,i,s,o){return T(t&r|e&~r,n,t,i,s,o)}function y(n,t,e,r,i,s,o){return T(t^e^r,n,t,i,s,o)}function g(n,t,e,r,i,s,o){return T(e^(t|~r),n,t,i,s,o)}function O(n,t){var e=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(e>>16)<<16|65535&e}function Xt(n,t){return n<<t|n>>>32-t}function xt(n){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n)}function te(n,t="mp"){return n?`https://www.gravatar.com/avatar/${ft(n)}?d=${t}`:""}function ee(n){return n.replace(/[.*+?^${}()|\[\]\\]/g,"\\$&")}function ne(n,...t){const e=[];for(let r=0;r<n.length||r<t.length;r++)n[r]&&e.push(n[r]),t[r]&&e.push(t[r]);return new w(e.join(""))}function ht(n,...t){let e=[];for(let s=0;s<n.length||s<t.length;s++)n[s]&&e.push(n[s]),t[s]&&e.push(t[s]);const[r,i]=e.join("").split(":");return w.toString(r,i==null?void 0:i.split(""))}class w{constructor(t){a(this,"module");a(this,"fullPath");a(this,"path");a(this,"name");a(this,"methods");a(this,"all");a(this,"none");a(this,"create");a(this,"read");a(this,"update");a(this,"delete");var o;if(typeof t=="object")return Object.assign(this,t);let[e,r,i]=t.split(":");i||(i=r||"*"),(e=="*"||!e&&i=="*")&&(e="",i="*");let s=e.split("/").filter(u=>!!u);this.module=((o=s.splice(0,1)[0])==null?void 0:o.toLowerCase())||"",this.fullPath=e,this.path=s.join("/"),this.name=s.pop()||"",this.methods=i.split(""),this.all=i==null?void 0:i.includes("*"),this.none=i==null?void 0:i.includes("n"),this.create=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("w"))||(i==null?void 0:i.includes("c"))),this.read=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("r"))),this.update=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("w"))||(i==null?void 0:i.includes("u"))),this.delete=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("w"))||(i==null?void 0:i.includes("d")))}static combine(t){let e=!1;const r=t.map(i=>new w(i)).toSorted((i,s)=>{const o=i.fullPath.length,u=s.fullPath.length;return o<u?1:o>u?-1:0}).reduce((i,s)=>(s.none&&(e=!0),i?(e||(s.all&&(i.all=!0),(s.all||s.create)&&(i.create=!0),(s.all||s.read)&&(i.read=!0),(s.all||s.update)&&(i.update=!0),(s.all||s.delete)&&(i.delete=!0),i.methods=[...i.methods,...s.methods]),i):s),null);return r.all&&(r.methods=["*"]),r.none&&(r.methods=["n"]),r.methods=new B(r.methods),r.raw=ht`${r.fullPath}:${r.methods}`,r}static has(t,...e){const r=S(e).map(s=>new w(s)),i=S(t).map(s=>new w(s));return!!r.find(s=>{if(!s.fullPath&&s.all)return!0;const o=i.filter(l=>s.fullPath.startsWith(l.fullPath));if(!o.length)return!1;const u=w.combine(o);return!u.none&&(u.all||new B(u.methods).intersection(new B(s.methods)).length)})}static hasAll(t,...e){return e.filter(r=>w.has(t,r)).length==e.length}static hasFatal(t,...e){if(!w.has(t,...e))throw new Error(`Requires one of: ${S(e).join(", ")}`)}static hasAllFatal(t,...e){if(!w.hasAll(t,...e))throw new Error(`Requires all: ${S(e).join(", ")}`)}static toString(t,e){let r=S(t).filter(i=>i!=null).join("/");return e!=null&&e.length&&(r+=`:${S(e).map(i=>i.toLowerCase()).join("")}`),r==null?void 0:r.trim().replaceAll(/\/{2,}/g,"/").replaceAll(/(^\/|\/$)/g,"")}toString(){return w.toString(this.fullPath,this.methods)}}class re{constructor(){a(this,"listeners",[])}emit(t,...e){const r=new w(t);this.listeners.filter(i=>w.has(i[0],t)).forEach(async i=>i[1](r,...e))}off(t){this.listeners=this.listeners.filter(e=>e[1]!=t)}on(t,e){return S(t).forEach(r=>this.listeners.push([new w(r),e])),()=>this.off(e)}once(t,e){return new Promise(r=>{const i=this.on(t,(s,...o)=>{r(o.length<2?o[0]:o),e&&e(s,...o),i()})})}relayEvents(t){t.on("*",(e,...r)=>this.emit(e,...r))}}function ie(n){(typeof n=="number"||typeof n=="string")&&(n=new Date(n));let t=n.getHours(),e="AM";return t>=12?(t>12&&(t-=12),e="PM"):t==0&&(t=12),`${n.getFullYear()}-${(n.getMonth()+1).toString().padStart(2,"0")}-${n.getDate().toString().padStart(2,"0")}, ${t}:${n.getMinutes().toString().padStart(2,"0")} ${e}`}function dt(n){return new Promise(t=>setTimeout(t,n))}async function se(n,t=100){for(;await n();)await dt(t)}function oe(n){return(n instanceof Date?n.getTime():n)-new Date().getTime()}function ce(){return Object.keys({})}var I=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ae={},C={};Object.defineProperty(C,"__esModule",{value:!0}),C.persist=C.Persist=void 0;class yt{constructor(t,e={}){a(this,"key");a(this,"options");a(this,"storage");a(this,"watches",{});a(this,"_value");this.key=t,this.options=e,this.storage=e.storage||localStorage,this.load()}get value(){var t;return this._value!==void 0?this._value:(t=this.options)==null?void 0:t.default}set value(t){t==null||typeof t!="object"?this._value=t:this._value=new Proxy(t,{get:(e,r)=>typeof e[r]=="function"?(...s)=>{const o=e[r](...s);return this.save(),o}:e[r],set:(e,r,i)=>(e[r]=i,this.save(),!0)}),this.save()}notify(t){Object.values(this.watches).forEach(e=>e(t))}clear(){this.storage.removeItem(this.key)}save(){this._value===void 0?this.clear():this.storage.setItem(this.key,JSON.stringify(this._value)),this.notify(this.value)}load(){if(this.storage[this.key]!=null){let t=JSON.parse(this.storage.getItem(this.key));t!=null&&typeof t=="object"&&this.options.type&&(t.__proto__=this.options.type.prototype),this.value=t}else this.value=this.options.default||void 0}watch(t){const e=Object.keys(this.watches).length;return this.watches[e]=t,()=>{delete this.watches[e]}}toString(){return JSON.stringify(this.value)}valueOf(){return this.value}}C.Persist=yt;function ue(n){return(t,e)=>{const r=(n==null?void 0:n.key)||`${t.constructor.name}.${e.toString()}`,i=new yt(r,n);Object.defineProperty(t,e,{get:function(){return i.value},set:function(s){i.value=s}})}}C.persist=ue;var M={};Object.defineProperty(M,"__esModule",{value:!0}),M.MemoryStorage=void 0;class le{get length(){return Object.keys(this).length}clear(){Object.keys(this).forEach(t=>this.removeItem(t))}getItem(t){return this[t]}key(t){return Object.keys(this)[t]}removeItem(t){delete this[t]}setItem(t,e){this[t]=e}}M.MemoryStorage=le,function(n){var t=I&&I.__createBinding||(Object.create?function(r,i,s,o){o===void 0&&(o=s);var u=Object.getOwnPropertyDescriptor(i,s);(!u||("get"in u?!i.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(r,o,u)}:function(r,i,s,o){o===void 0&&(o=s),r[o]=i[s]}),e=I&&I.__exportStar||function(r,i){for(var s in r)s!=="default"&&!Object.prototype.hasOwnProperty.call(i,s)&&t(i,r,s)};Object.defineProperty(n,"__esModule",{value:!0}),e(C,n),e(M,n)}(ae),c.ASet=B,c.BadGatewayError=Z,c.BadRequestError=G,c.Cache=$t,c.CliBackground=Mt,c.CliEffects=v,c.CliForeground=N,c.CustomError=p,c.ForbiddenError=W,c.GatewayTimeoutError=X,c.Http=x,c.InternalServerError=_,c.JSONAttemptParse=P,c.JSONSanitize=St,c.LOG_LEVEL=lt,c.Logger=tt,c.MethodNotAllowedError=z,c.NotAcceptableError=K,c.NotFoundError=J,c.NotImplementedError=V,c.PE=ne,c.PES=ht,c.PathEvent=w,c.PathEventEmitter=re,c.PaymentRequiredError=Y,c.PromiseProgress=j,c.ServiceUnavailableError=Q,c.TypedEmitter=F,c.UnauthorizedError=H,c.addUnique=Bt,c.arrayDiff=Ot,c.caseInsensitiveSort=At,c.clean=m,c.csv=vt,c.dec2Frac=kt,c.deepCopy=R,c.deepMerge=ot,c.dotNotation=A,c.downloadFile=Ct,c.downloadUrl=ut,c.encodeQuery=mt,c.errorFromCode=Tt,c.escapeRegex=ee,c.fileBrowser=Nt,c.findByProp=jt,c.flattenArr=ct,c.flattenObj=U,c.formData=Et,c.formatBytes=qt,c.formatDate=ie,c.formatPhoneNumber=Ft,c.fracToDec=Dt,c.gravatar=te,c.includes=q,c.insertAt=Gt,c.isEqual=$,c.jwtDecode=It,c.makeArray=S,c.makeUnique=at,c.matchAll=zt,c.md5=ft,c.mixin=bt,c.pad=Ht,c.parseUrl=Kt,c.randomHex=Yt,c.randomString=Wt,c.randomStringBuilder=Jt,c.sleep=dt,c.sleepWhile=se,c.sortByProp=Rt,c.timeUntil=oe,c.timestampFilename=Lt,c.tyoeKeys=ce,c.uploadWithProgress=Pt,c.validateEmail=xt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(c=typeof globalThis<"u"?globalThis:c||self,m(c.utils={}))})(this,function(c){"use strict";var se=Object.defineProperty;var oe=(c,m,C)=>m in c?se(c,m,{enumerable:!0,configurable:!0,writable:!0,value:C}):c[m]=C;var a=(c,m,C)=>oe(c,typeof m!="symbol"?m+"":m,C);function m(n,t=!1){if(n==null)throw new Error("Cannot clean a NULL value");return Array.isArray(n)?n=n.filter(e=>e!=null):Object.entries(n).forEach(([e,r])=>{(t&&r===void 0||!t&&r==null)&&delete n[e]}),n}function C(n){return structuredClone(n)}function rt(n,...t){return t.forEach(e=>{for(const r in e)e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?(n[r]||(n[r]={}),rt(n[r],e[r])):n[r]=e[r]}),n}function O(n,t,e){if(!(n==null||!t))return t.split(/[.[\]]/g).filter(r=>r.length).reduce((r,i,s,o)=>{if((i[0]=='"'||i[0]=="'")&&(i=i.slice(1,-1)),!(r!=null&&r.hasOwnProperty(i))){if(e==null)return;r[i]={}}return e!==void 0&&s==o.length-1?r[i]=e:r[i]},n)}function yt(n){return Object.entries(n).map(([t,e])=>encodeURIComponent(t)+"="+encodeURIComponent(e)).join("&")}function M(n,t,e={}){if(typeof n=="object"&&!Array.isArray(n)){for(const r of Object.keys(n)){const i=t?t+"."+r:r;typeof n[r]=="object"?M(n[r],i,e):e[i]=n[r]}return e}}function gt(n){const t=new FormData;return Object.entries(n).forEach(([e,r])=>t.append(e,r)),t}function k(n,t,e=!1){if(n==null)return e;if(Array.isArray(t))return t.findIndex((i,s)=>!k(n[s],t[s],e))==-1;const r=typeof t;return r!=typeof n?!1:r=="object"?Object.keys(t).find(i=>!k(n[i],t[i],e))==null:r=="function"?n.toString()==t.toString():n==t}function $(n,t){const e=typeof n,r=typeof t;return e!="object"||n==null||r!="object"||t==null?e=="function"&&r=="function"?n.toString()==t.toString():n===t:Object.keys(n).length!=Object.keys(t).length?!1:Object.keys(n).every(s=>$(n[s],t[s]))}function pt(n,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{Object.defineProperty(n.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})})}function T(n){try{return JSON.parse(n)}catch{return n}}function wt(n,t){let e=[];return JSON.stringify(n,(r,i)=>{if(typeof i=="object"&&i!==null){if(e.includes(i))return;e.push(i)}return i},t)}function mt(n,t){return n.indexOf(t)===-1&&n.push(t),n}function Et(n,t){return st([...n.filter(e=>!t.includes(r=>$(e,r))),...t.filter(e=>!n.includes(r=>$(e,r)))])}function St(n){return function(t,e){const r=O(t,n),i=O(e,n);return typeof r!="string"||typeof i!="string"?1:r.toLowerCase().localeCompare(i.toLowerCase())}}function bt(n,t){return e=>$(O(e,n),t)}function it(n,t=[]){return n.forEach(e=>Array.isArray(e)?it(e,t):t.push(e)),t}function Bt(n,t=!1){return function(e,r){const i=O(e,n),s=O(r,n);return typeof i=="number"&&typeof s=="number"?(t?-1:1)*(i-s):i>s?t?-1:1:i<s?t?1:-1:0}}function st(n){for(let t=n.length-1;t>=0;t--)n.slice(0,t).find(e=>$(e,n[t]))&&n.splice(t,1);return n}function b(n){return Array.isArray(n)?n:[n]}class B extends Array{get size(){return this.length}constructor(t=[]){super(),t!=null&&t.forEach&&t.forEach(e=>this.add(e))}add(...t){t.filter(e=>!this.has(e)).forEach(e=>this.push(e))}delete(...t){t.forEach(e=>{const r=this.indexOf(e);r!=-1&&this.slice(r,1)})}difference(t){return new B(this.filter(e=>!t.has(e)))}has(t){return this.indexOf(t)!=-1}intersection(t){return new B(this.filter(e=>t.has(e)))}isDisjointFrom(t){return this.intersection(t).size==0}isSubsetOf(t){return this.findIndex(e=>!t.has(e))==-1}isSuperset(t){return t.findIndex(e=>!this.has(e))==-1}symmetricDifference(t){return new B([...this.difference(t),...t.difference(this)])}union(t){return new B([...this,...t])}}class At{constructor(t,e={}){a(this,"store",{});a(this,"complete",!1);a(this,"values",this.all());if(this.key=t,this.options=e,e.storageKey&&!e.storage&&(e.storage=localStorage),e.storageKey&&e.storage){const r=e.storage.getItem(e.storageKey);if(r)try{Object.assign(this.store,JSON.parse(r))}catch{}}return new Proxy(this,{get:(r,i)=>i in r?r[i]:r.store[i],set:(r,i,s)=>(i in r?r[i]=s:r.store[i]=s,!0)})}getKey(t){if(!this.key)throw new Error("No key defined");return t[this.key]}all(){return Object.values(this.store)}add(t,e=this.ttl){const r=this.getKey(t);return this.set(r,t,e),this}addAll(t,e=!0){return t.forEach(r=>this.add(r)),this.complete=e,this}delete(t){delete this.store[t],this.options.storageKey&&this.options.storage&&this.options.storage.setItem(this.options.storageKey,JSON.stringify(this.store))}entries(){return Object.entries(this.store)}get(t){return this.store[t]}keys(){return Object.keys(this.store)}map(){return structuredClone(this.store)}set(t,e,r=this.options.ttl){return this.store[t]=e,this.options.storageKey&&this.options.storage&&this.options.storage.setItem(this.options.storageKey,JSON.stringify(this.store)),r&&setTimeout(()=>{this.complete=!1,this.delete(t)},r*1e3),this}}function Ot(n,t=!0){const e=n.reduce((r,i)=>(Object.keys(t?M(i):i).forEach(s=>{r.includes(s)||r.push(s)}),r),[]);return[e.join(","),...n.map(r=>e.map(i=>{const s=O(r,i),o=typeof s;return o=="string"&&s.includes(",")?`"${s}"`:o=="object"?`"${JSON.stringify(s)}"`:s}).join(","))].join(`
|
|
2
|
+
`)}class R extends Promise{constructor(e){super((r,i)=>e(s=>r(s),s=>i(s),s=>this.progress=s));a(this,"listeners",[]);a(this,"_progress",0)}get progress(){return this._progress}set progress(e){e!=this._progress&&(this._progress=e,this.listeners.forEach(r=>r(e)))}static from(e){return e instanceof R?e:new R((r,i)=>e.then((...s)=>r(...s)).catch((...s)=>i(...s)))}from(e){const r=R.from(e);return this.onProgress(i=>r.progress=i),r}onProgress(e){return this.listeners.push(e),this}then(e,r){const i=super.then(e,r);return this.from(i)}catch(e){return this.from(super.catch(e))}finally(e){return this.from(super.finally(e))}}function Rt(n,t){n instanceof Blob||(n=new Blob(b(n)));const e=URL.createObjectURL(n);ot(e,t),URL.revokeObjectURL(e)}function ot(n,t){const e=document.createElement("a");e.href=n,e.download=t||n.split("/").pop(),document.body.appendChild(e),e.click(),document.body.removeChild(e)}function Ct(n={}){return new Promise(t=>{const e=document.createElement("input");e.type="file",e.accept=n.accept||"*",e.style.display="none",e.multiple=!!n.multiple,e.onblur=e.onchange=async()=>{t(Array.from(e.files)),e.remove()},document.body.appendChild(e),e.click()})}function $t(n,t=new Date){(typeof t=="number"||typeof t=="string")&&(t=new Date(t));const e=`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}-${t.getDate().toString().padStart(2,"0")}_${t.getHours().toString().padStart(2,"0")}-${t.getMinutes().toString().padStart(2,"0")}-${t.getSeconds().toString().padStart(2,"0")}`;return n?n.replace("{{TIMESTAMP}}",e):e}function Nt(n){return new R((t,e,r)=>{const i=new XMLHttpRequest,s=new FormData;n.files.forEach(o=>s.append("file",o)),i.withCredentials=!!n.withCredentials,i.upload.addEventListener("progress",o=>o.lengthComputable?r(o.loaded/o.total):null),i.addEventListener("loadend",()=>t(T(i.responseText))),i.addEventListener("error",()=>e(T(i.responseText))),i.addEventListener("timeout",()=>e({error:"Request timed out"})),i.open("POST",n.url),Object.entries(n.headers||{}).forEach(([o,l])=>i.setRequestHeader(o,l)),i.send(s)})}class U{constructor(){a(this,"listeners",{})}static emit(t,...e){(this.listeners["*"]||[]).forEach(r=>r(t,...e)),(this.listeners[t.toString()]||[]).forEach(r=>r(...e))}static off(t,e){const r=t.toString();this.listeners[r]=(this.listeners[r]||[]).filter(i=>i===e)}static on(t,e){var i;const r=t.toString();return this.listeners[r]||(this.listeners[r]=[]),(i=this.listeners[r])==null||i.push(e),()=>this.off(t,e)}static once(t,e){return new Promise(r=>{const i=this.on(t,(...s)=>{r(s.length==1?s[0]:s),e&&e(...s),i()})})}emit(t,...e){(this.listeners["*"]||[]).forEach(r=>r(t,...e)),(this.listeners[t]||[]).forEach(r=>r(...e))}off(t,e){this.listeners[t]=(this.listeners[t]||[]).filter(r=>r===e)}on(t,e){var r;return this.listeners[t]||(this.listeners[t]=[]),(r=this.listeners[t])==null||r.push(e),()=>this.off(t,e)}once(t,e){return new Promise(r=>{const i=this.on(t,(...s)=>{r(s.length==1?s[0]:s),e&&e(...s),i()})})}}a(U,"listeners",{});class p extends Error{constructor(e,r){super(e);a(this,"_code");r!=null&&(this._code=r)}get code(){return this._code||this.constructor.code}set code(e){this._code=e}static from(e){const r=Number(e.statusCode)??Number(e.code),i=new this(e.message||e.toString());return Object.assign(i,{stack:e.stack,...e,code:r??void 0})}static instanceof(e){return e.constructor.code!=null}toString(){return this.message||super.toString()}}a(p,"code",500);class q extends p{constructor(t="Bad Request"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(q,"code",400);class F extends p{constructor(t="Unauthorized"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(F,"code",401);class G extends p{constructor(t="Payment Required"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(G,"code",402);class v extends p{constructor(t="Forbidden"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(v,"code",403);class H extends p{constructor(t="Not Found"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(H,"code",404);class Y extends p{constructor(t="Method Not Allowed"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Y,"code",405);class K extends p{constructor(t="Not Acceptable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(K,"code",406);class W extends p{constructor(t="Internal Server Error"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(W,"code",500);class J extends p{constructor(t="Not Implemented"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(J,"code",501);class z extends p{constructor(t="Bad Gateway"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(z,"code",502);class V extends p{constructor(t="Service Unavailable"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(V,"code",503);class Z extends p{constructor(t="Gateway Timeout"){super(t)}static instanceof(t){return t.constructor.code==this.code}}a(Z,"code",504);function Lt(n,t){if(n>=200&&n<300)return null;switch(n){case 400:return new q(t);case 401:return new F(t);case 402:return new G(t);case 403:return new v(t);case 404:return new H(t);case 405:return new Y(t);case 406:return new K(t);case 500:return new W(t);case 501:return new J(t);case 502:return new z(t);case 503:return new V(t);case 504:return new Z(t);default:return new p(t,n)}}const S=class S{constructor(t={}){a(this,"interceptors",{});a(this,"headers",{});a(this,"url");this.url=t.url??null,this.headers=t.headers||{},t.interceptors&&t.interceptors.forEach(e=>S.addInterceptor(e))}static addInterceptor(t){const e=Object.keys(S.interceptors).length.toString();return S.interceptors[e]=t,()=>{S.interceptors[e]=null}}addInterceptor(t){const e=Object.keys(this.interceptors).length.toString();return this.interceptors[e]=t,()=>{this.interceptors[e]=null}}request(t={}){var i;if(!this.url&&!t.url)throw new Error("URL needs to be set");let e=((i=t.url)!=null&&i.startsWith("http")?t.url:(this.url||"")+(t.url||"")).replace(/([^:]\/)\/+/g,"$1");if(t.fragment&&(e.includes("#")?e.replace(/#.*(\?|\n)/g,(s,o)=>`#${t.fragment}${o}`):e+="#"+t.fragment),t.query){const s=Array.isArray(t.query)?t.query:Object.keys(t.query).map(o=>({key:o,value:t.query[o]}));e+=(e.includes("?")?"&":"?")+s.map(o=>`${o.key}=${o.value}`).join("&")}const r=m({"Content-Type":t.body?t.body instanceof FormData?"multipart/form-data":"application/json":void 0,...S.headers,...this.headers,...t.headers});return typeof t.body=="object"&&t.body!=null&&r["Content-Type"]=="application/json"&&(t.body=JSON.stringify(t.body)),new R((s,o,l)=>{fetch(e,{headers:r,method:t.method||(t.body?"POST":"GET"),body:t.body}).then(async u=>{var ht,dt;for(let f of[...Object.values(S.interceptors),...Object.values(this.interceptors)])await new Promise(D=>f(u,()=>D()));const P=u.headers.get("Content-Length"),et=P?parseInt(P,10):0;let ft=0;const nt=(ht=u.body)==null?void 0:ht.getReader(),ie=new ReadableStream({start(f){function D(){nt==null||nt.read().then(j=>{if(j.done)return f.close();ft+=j.value.byteLength,l(ft/et),f.enqueue(j.value),D()}).catch(j=>f.error(j))}D()}});if(u.data=new Response(ie),t.decode==null||t.decode){const f=(dt=u.headers.get("Content-Type"))==null?void 0:dt.toLowerCase();f!=null&&f.includes("form")?u.data=await u.data.formData():f!=null&&f.includes("json")?u.data=await u.data.json():f!=null&&f.includes("text")?u.data=await u.data.text():f!=null&&f.includes("application")&&(u.data=await u.data.blob())}u.ok?s(u):o(u)})})}};a(S,"interceptors",{}),a(S,"headers",{});let Q=S;function jt(n){const t=n.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return T(decodeURIComponent(atob(t).split("").map(function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join("")))}const N={CLEAR:"\x1B[0m",BRIGHT:"\x1B[1m",DIM:"\x1B[2m",UNDERSCORE:"\x1B[4m",BLINK:"\x1B[5m",REVERSE:"\x1B[7m",HIDDEN:"\x1B[8m"},L={BLACK:"\x1B[30m",RED:"\x1B[31m",GREEN:"\x1B[32m",YELLOW:"\x1B[33m",BLUE:"\x1B[34m",MAGENTA:"\x1B[35m",CYAN:"\x1B[36m",LIGHT_GREY:"\x1B[37m",GREY:"\x1B[90m",LIGHT_RED:"\x1B[91m",LIGHT_GREEN:"\x1B[92m",LIGHT_YELLOW:"\x1B[93m",LIGHT_BLUE:"\x1B[94m",LIGHT_MAGENTA:"\x1B[95m",LIGHT_CYAN:"\x1B[96m",WHITE:"\x1B[97m"},Tt={BLACK:"\x1B[40m",RED:"\x1B[41m",GREEN:"\x1B[42m",YELLOW:"\x1B[43m",BLUE:"\x1B[44m",MAGENTA:"\x1B[45m",CYAN:"\x1B[46m",WHITE:"\x1B[47m",GREY:"\x1B[100m"};var ct=(n=>(n[n.ERROR=0]="ERROR",n[n.WARN=1]="WARN",n[n.INFO=2]="INFO",n[n.LOG=3]="LOG",n[n.DEBUG=4]="DEBUG",n))(ct||{});const E=class E extends U{constructor(t){super(),this.namespace=t}pad(t,e,r,i=!1){const s=t.toString(),o=e-s.length;if(o<=0)return s;const l=Array(~~(o/r.length)).fill(r).join("");return i?s+l:l+s}format(...t){const e=new Date;return`${`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()} ${this.pad(e.getHours().toString(),2,"0")}:${this.pad(e.getMinutes().toString(),2,"0")}:${this.pad(e.getSeconds().toString(),2,"0")}.${this.pad(e.getMilliseconds().toString(),3,"0",!0)}`}${this.namespace?` [${this.namespace}]`:""} ${t.join(" ")}`}debug(...t){if(E.LOG_LEVEL<4)return;const e=this.format(...t);E.emit(4,e),console.debug(L.LIGHT_GREY+e+N.CLEAR)}log(...t){if(E.LOG_LEVEL<3)return;const e=this.format(...t);E.emit(3,e),console.log(N.CLEAR+e)}info(...t){if(E.LOG_LEVEL<2)return;const e=this.format(...t);E.emit(2,e),console.info(L.BLUE+e+N.CLEAR)}warn(...t){if(E.LOG_LEVEL<1)return;const e=this.format(...t);E.emit(1,e),console.warn(L.YELLOW+e+N.CLEAR)}error(...t){if(E.LOG_LEVEL<0)return;const e=this.format(...t);E.emit(0,e),console.error(L.RED+e+N.CLEAR)}};a(E,"LOG_LEVEL",4);let X=E;function It(n){const t=(l,u)=>u<1e-7?l:t(u,~~(l%u)),e=n.toString().length-2;let r=Math.pow(10,e),i=n*r;const s=t(i,r);i=~~(i/s),r=~~(r/s);const o=~~(i/r);return i-=o*r,`${o?o+" ":""}${~~i}/${~~r}`}function Pt(n){let t=n.split(" ");const e=t.length==2?Number(t[0]):0;return t=t.pop().split("/"),e+Number(t[0])/Number(t[1])}const x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",_="0123456789",tt="~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/",Dt=x+_+tt;function Mt(n,t=2){if(n===0)return"0 Bytes";const e=1024,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(n)/Math.log(e));return parseFloat((n/Math.pow(e,i)).toFixed(t))+" "+r[i]}function kt(n){const t=/(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);if(!t)throw new Error(`Number cannot be parsed: ${n}`);return`${t[1]??""} (${t[2]}) ${t[3]}-${t[4]}`.trim()}function Ut(n,t,e){return`${n.slice(0,e)}${t}${n.slice(e+1)}`}function qt(n,t,e=" ",r=!0){return r?n.toString().padStart(t,e):n.toString().padEnd(t,e)}function Ft(n){return Array(n).fill(null).map(()=>Math.round(Math.random()*15).toString(16)).join("")}function Gt(n,t=Dt){return Array(n).fill(null).map(()=>{const e=~~(Math.random()*t.length);return t[e]}).join("")}function vt(n,t=!1,e=!1,r=!1){if(!t&&!e&&!r)throw new Error("Must enable at least one: letters, numbers, symbols");return Array(n).fill(null).map(()=>{let i;do{const s=~~(Math.random()*3);t&&s==0?i=x[~~(Math.random()*x.length)]:e&&s==1?i=_[~~(Math.random()*_.length)]:r&&s==2&&(i=tt[~~(Math.random()*tt.length)])}while(!i);return i}).join("")}function Ht(n,t){if(typeof t=="string"&&(t=new RegExp(t,"g")),!t.global)throw new TypeError("Regular expression must be global.");let e=[],r;for(;(r=t.exec(n))!==null;)e.push(r);return e}function Yt(n){const t=new RegExp("(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$","gm").exec(n),e=(t==null?void 0:t.groups)??{},r=e.domain.split(".");if(e.port!=null&&(e.port=Number(e.port)),r.length>2&&(e.domain=r.splice(-2,2).join("."),e.subdomain=r.join(".")),e.query){const i=e.query.split("&"),s={};i.forEach(o=>{const[l,u]=o.split("=");s[l]=u}),e.query=s}return e}function at(n){var t=Kt(Jt(zt(Wt(n),8*n.length)));return t.toLowerCase()}function Kt(n){for(var t,e="0123456789ABCDEF",r="",i=0;i<n.length;i++)t=n.charCodeAt(i),r+=e.charAt(t>>>4&15)+e.charAt(15&t);return r}function Wt(n){for(var t=Array(n.length>>2),e=0;e<t.length;e++)t[e]=0;for(e=0;e<8*n.length;e+=8)t[e>>5]|=(255&n.charCodeAt(e/8))<<e%32;return t}function Jt(n){for(var t="",e=0;e<32*n.length;e+=8)t+=String.fromCharCode(n[e>>5]>>>e%32&255);return t}function zt(n,t){n[t>>5]|=128<<t%32,n[14+(t+64>>>9<<4)]=t;for(var e=1732584193,r=-271733879,i=-1732584194,s=271733878,o=0;o<n.length;o+=16){var l=e,u=r,P=i,et=s;r=g(r=g(r=g(r=g(r=y(r=y(r=y(r=y(r=d(r=d(r=d(r=d(r=h(r=h(r=h(r=h(r,i=h(i,s=h(s,e=h(e,r,i,s,n[o+0],7,-680876936),r,i,n[o+1],12,-389564586),e,r,n[o+2],17,606105819),s,e,n[o+3],22,-1044525330),i=h(i,s=h(s,e=h(e,r,i,s,n[o+4],7,-176418897),r,i,n[o+5],12,1200080426),e,r,n[o+6],17,-1473231341),s,e,n[o+7],22,-45705983),i=h(i,s=h(s,e=h(e,r,i,s,n[o+8],7,1770035416),r,i,n[o+9],12,-1958414417),e,r,n[o+10],17,-42063),s,e,n[o+11],22,-1990404162),i=h(i,s=h(s,e=h(e,r,i,s,n[o+12],7,1804603682),r,i,n[o+13],12,-40341101),e,r,n[o+14],17,-1502002290),s,e,n[o+15],22,1236535329),i=d(i,s=d(s,e=d(e,r,i,s,n[o+1],5,-165796510),r,i,n[o+6],9,-1069501632),e,r,n[o+11],14,643717713),s,e,n[o+0],20,-373897302),i=d(i,s=d(s,e=d(e,r,i,s,n[o+5],5,-701558691),r,i,n[o+10],9,38016083),e,r,n[o+15],14,-660478335),s,e,n[o+4],20,-405537848),i=d(i,s=d(s,e=d(e,r,i,s,n[o+9],5,568446438),r,i,n[o+14],9,-1019803690),e,r,n[o+3],14,-187363961),s,e,n[o+8],20,1163531501),i=d(i,s=d(s,e=d(e,r,i,s,n[o+13],5,-1444681467),r,i,n[o+2],9,-51403784),e,r,n[o+7],14,1735328473),s,e,n[o+12],20,-1926607734),i=y(i,s=y(s,e=y(e,r,i,s,n[o+5],4,-378558),r,i,n[o+8],11,-2022574463),e,r,n[o+11],16,1839030562),s,e,n[o+14],23,-35309556),i=y(i,s=y(s,e=y(e,r,i,s,n[o+1],4,-1530992060),r,i,n[o+4],11,1272893353),e,r,n[o+7],16,-155497632),s,e,n[o+10],23,-1094730640),i=y(i,s=y(s,e=y(e,r,i,s,n[o+13],4,681279174),r,i,n[o+0],11,-358537222),e,r,n[o+3],16,-722521979),s,e,n[o+6],23,76029189),i=y(i,s=y(s,e=y(e,r,i,s,n[o+9],4,-640364487),r,i,n[o+12],11,-421815835),e,r,n[o+15],16,530742520),s,e,n[o+2],23,-995338651),i=g(i,s=g(s,e=g(e,r,i,s,n[o+0],6,-198630844),r,i,n[o+7],10,1126891415),e,r,n[o+14],15,-1416354905),s,e,n[o+5],21,-57434055),i=g(i,s=g(s,e=g(e,r,i,s,n[o+12],6,1700485571),r,i,n[o+3],10,-1894986606),e,r,n[o+10],15,-1051523),s,e,n[o+1],21,-2054922799),i=g(i,s=g(s,e=g(e,r,i,s,n[o+8],6,1873313359),r,i,n[o+15],10,-30611744),e,r,n[o+6],15,-1560198380),s,e,n[o+13],21,1309151649),i=g(i,s=g(s,e=g(e,r,i,s,n[o+4],6,-145523070),r,i,n[o+11],10,-1120210379),e,r,n[o+2],15,718787259),s,e,n[o+9],21,-343485551),e=A(e,l),r=A(r,u),i=A(i,P),s=A(s,et)}return Array(e,r,i,s)}function I(n,t,e,r,i,s){return A(Vt(A(A(t,n),A(r,s)),i),e)}function h(n,t,e,r,i,s,o){return I(t&e|~t&r,n,t,i,s,o)}function d(n,t,e,r,i,s,o){return I(t&r|e&~r,n,t,i,s,o)}function y(n,t,e,r,i,s,o){return I(t^e^r,n,t,i,s,o)}function g(n,t,e,r,i,s,o){return I(e^(t|~r),n,t,i,s,o)}function A(n,t){var e=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(e>>16)<<16|65535&e}function Vt(n,t){return n<<t|n>>>32-t}function Zt(n){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n)}function Qt(n,t="mp"){return n?`https://www.gravatar.com/avatar/${at(n)}?d=${t}`:""}function Xt(n){return n.replace(/[.*+?^${}()|\[\]\\]/g,"\\$&")}function xt(n,...t){const e=[];for(let r=0;r<n.length||r<t.length;r++)n[r]&&e.push(n[r]),t[r]&&e.push(t[r]);return new w(e.join(""))}function ut(n,...t){let e=[];for(let s=0;s<n.length||s<t.length;s++)n[s]&&e.push(n[s]),t[s]&&e.push(t[s]);const[r,i]=e.join("").split(":");return w.toString(r,i==null?void 0:i.split(""))}class w{constructor(t){a(this,"module");a(this,"fullPath");a(this,"path");a(this,"name");a(this,"methods");a(this,"all");a(this,"none");a(this,"create");a(this,"read");a(this,"update");a(this,"delete");var o;if(typeof t=="object")return Object.assign(this,t);let[e,r,i]=t.split(":");i||(i=r||"*"),(e=="*"||!e&&i=="*")&&(e="",i="*");let s=e.split("/").filter(l=>!!l);this.module=((o=s.splice(0,1)[0])==null?void 0:o.toLowerCase())||"",this.fullPath=e,this.path=s.join("/"),this.name=s.pop()||"",this.methods=i.split(""),this.all=i==null?void 0:i.includes("*"),this.none=i==null?void 0:i.includes("n"),this.create=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("w"))||(i==null?void 0:i.includes("c"))),this.read=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("r"))),this.update=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("w"))||(i==null?void 0:i.includes("u"))),this.delete=!(i!=null&&i.includes("n"))&&((i==null?void 0:i.includes("*"))||(i==null?void 0:i.includes("w"))||(i==null?void 0:i.includes("d")))}static combine(t){let e=!1;const r=t.map(i=>new w(i)).toSorted((i,s)=>{const o=i.fullPath.length,l=s.fullPath.length;return o<l?1:o>l?-1:0}).reduce((i,s)=>(s.none&&(e=!0),i?(e||(s.all&&(i.all=!0),(s.all||s.create)&&(i.create=!0),(s.all||s.read)&&(i.read=!0),(s.all||s.update)&&(i.update=!0),(s.all||s.delete)&&(i.delete=!0),i.methods=[...i.methods,...s.methods]),i):s),null);return r.all&&(r.methods=["*"]),r.none&&(r.methods=["n"]),r.methods=new B(r.methods),r.raw=ut`${r.fullPath}:${r.methods}`,r}static has(t,...e){const r=b(e).map(s=>new w(s)),i=b(t).map(s=>new w(s));return!!r.find(s=>{if(!s.fullPath&&s.all)return!0;const o=i.filter(u=>s.fullPath.startsWith(u.fullPath));if(!o.length)return!1;const l=w.combine(o);return!l.none&&(l.all||new B(l.methods).intersection(new B(s.methods)).length)})}static hasAll(t,...e){return e.filter(r=>w.has(t,r)).length==e.length}static hasFatal(t,...e){if(!w.has(t,...e))throw new Error(`Requires one of: ${b(e).join(", ")}`)}static hasAllFatal(t,...e){if(!w.hasAll(t,...e))throw new Error(`Requires all: ${b(e).join(", ")}`)}static toString(t,e){let r=b(t).filter(i=>i!=null).join("/");return e!=null&&e.length&&(r+=`:${b(e).map(i=>i.toLowerCase()).join("")}`),r==null?void 0:r.trim().replaceAll(/\/{2,}/g,"/").replaceAll(/(^\/|\/$)/g,"")}toString(){return w.toString(this.fullPath,this.methods)}}class _t{constructor(){a(this,"listeners",[])}emit(t,...e){const r=new w(t);this.listeners.filter(i=>w.has(i[0],t)).forEach(async i=>i[1](r,...e))}off(t){this.listeners=this.listeners.filter(e=>e[1]!=t)}on(t,e){return b(t).forEach(r=>this.listeners.push([new w(r),e])),()=>this.off(e)}once(t,e){return new Promise(r=>{const i=this.on(t,(s,...o)=>{r(o.length<2?o[0]:o),e&&e(s,...o),i()})})}relayEvents(t){t.on("*",(e,...r)=>this.emit(e,...r))}}function te(n){(typeof n=="number"||typeof n=="string")&&(n=new Date(n));let t=n.getHours(),e="AM";return t>=12?(t>12&&(t-=12),e="PM"):t==0&&(t=12),`${n.getFullYear()}-${(n.getMonth()+1).toString().padStart(2,"0")}-${n.getDate().toString().padStart(2,"0")}, ${t}:${n.getMinutes().toString().padStart(2,"0")} ${e}`}function lt(n){return new Promise(t=>setTimeout(t,n))}async function ee(n,t=100){for(;await n();)await lt(t)}function ne(n){return(n instanceof Date?n.getTime():n)-new Date().getTime()}function re(){return Object.keys({})}c.ASet=B,c.BadGatewayError=z,c.BadRequestError=q,c.Cache=At,c.CliBackground=Tt,c.CliEffects=N,c.CliForeground=L,c.CustomError=p,c.ForbiddenError=v,c.GatewayTimeoutError=Z,c.Http=Q,c.InternalServerError=W,c.JSONAttemptParse=T,c.JSONSanitize=wt,c.LOG_LEVEL=ct,c.Logger=X,c.MethodNotAllowedError=Y,c.NotAcceptableError=K,c.NotFoundError=H,c.NotImplementedError=J,c.PE=xt,c.PES=ut,c.PathEvent=w,c.PathEventEmitter=_t,c.PaymentRequiredError=G,c.PromiseProgress=R,c.ServiceUnavailableError=V,c.TypedEmitter=U,c.UnauthorizedError=F,c.addUnique=mt,c.arrayDiff=Et,c.caseInsensitiveSort=St,c.clean=m,c.csv=Ot,c.dec2Frac=It,c.deepCopy=C,c.deepMerge=rt,c.dotNotation=O,c.downloadFile=Rt,c.downloadUrl=ot,c.encodeQuery=yt,c.errorFromCode=Lt,c.escapeRegex=Xt,c.fileBrowser=Ct,c.findByProp=bt,c.flattenArr=it,c.flattenObj=M,c.formData=gt,c.formatBytes=Mt,c.formatDate=te,c.formatPhoneNumber=kt,c.fracToDec=Pt,c.gravatar=Qt,c.includes=k,c.insertAt=Ut,c.isEqual=$,c.jwtDecode=jt,c.makeArray=b,c.makeUnique=st,c.matchAll=Ht,c.md5=at,c.mixin=pt,c.pad=qt,c.parseUrl=Yt,c.randomHex=Ft,c.randomString=Gt,c.randomStringBuilder=vt,c.sleep=lt,c.sleepWhile=ee,c.sortByProp=Bt,c.timeUntil=ne,c.timestampFilename=$t,c.tyoeKeys=re,c.uploadWithProgress=Nt,c.validateEmail=Zt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|