@flemist/simple-utils 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-Be7wEmXE.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.setFuncName=e.setFuncName;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.truncateString=e.truncateString;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-jyEOC24k.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.setFuncName=e.setFuncName;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.truncateString=e.truncateString;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
@@ -1,4 +1,4 @@
1
- import { H as s, O as o, P as t, R as n, U as r, G as m, I as l, q as d, l as u, o as i, A as c, B as p, C as g, D as I, y as R, z as T, K as f, u as x, v as N, w as h, p as E, E as F, d as L, g as M, L as P, b as S, m as U, c as k, n as q, f as A, k as C, r as D, h as G, e as y, i as B, j as O, F as b, a as w, s as z, M as J, t as _, x as v, X as H, Z as W, Y as j, Q, W as X, S as Z, V as K, T as V, J as Y, N as $ } from "../urlGet-A6tzime-.mjs";
1
+ import { H as s, O as o, P as t, R as n, U as r, G as m, I as l, q as d, l as u, o as i, A as c, B as p, C as g, D as I, y as R, z as T, K as f, u as x, v as N, w as h, p as E, E as F, d as L, g as M, L as P, b as S, m as U, c as k, n as q, f as A, k as C, r as D, h as G, e as y, i as B, j as O, F as b, a as w, s as z, M as J, t as _, x as v, X as H, Z as W, Y as j, Q, W as X, S as Z, V as K, T as V, J as Y, N as $ } from "../urlGet-gscwyYHD.mjs";
2
2
  export {
3
3
  s as ConsoleMessageLevel,
4
4
  o as Lazy,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-Be7wEmXE.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.setFuncName=e.setFuncName;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.truncateString=e.truncateString;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-jyEOC24k.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.setFuncName=e.setFuncName;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.truncateString=e.truncateString;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
@@ -1,4 +1,4 @@
1
- import { H as s, O as o, P as t, R as n, U as r, G as m, I as l, q as d, l as u, o as i, A as c, B as p, C as g, D as I, y as R, z as T, K as f, u as x, v as N, w as h, p as E, E as F, d as L, g as M, L as P, b as S, m as U, c as k, n as q, f as A, k as C, r as D, h as G, e as y, i as B, j as O, F as b, a as w, s as z, M as J, t as _, x as v, X as H, Z as W, Y as j, Q, W as X, S as Z, V as K, T as V, J as Y, N as $ } from "../urlGet-A6tzime-.mjs";
1
+ import { H as s, O as o, P as t, R as n, U as r, G as m, I as l, q as d, l as u, o as i, A as c, B as p, C as g, D as I, y as R, z as T, K as f, u as x, v as N, w as h, p as E, E as F, d as L, g as M, L as P, b as S, m as U, c as k, n as q, f as A, k as C, r as D, h as G, e as y, i as B, j as O, F as b, a as w, s as z, M as J, t as _, x as v, X as H, Z as W, Y as j, Q, W as X, S as Z, V as K, T as V, J as Y, N as $ } from "../urlGet-gscwyYHD.mjs";
2
2
  export {
3
3
  s as ConsoleMessageLevel,
4
4
  o as Lazy,
@@ -1,3 +1,4 @@
1
+ import { TruncateStringOptions } from './truncateString';
1
2
  export type FormatAnyToString = (obj: any, path: string[], toString: (obj: any) => any) => string | null | undefined | void;
2
3
  export type FormatAnyOptions = {
3
4
  pretty?: boolean;
@@ -8,5 +9,6 @@ export type FormatAnyOptions = {
8
9
  showObjectId?: boolean;
9
10
  showArrayIndex?: boolean;
10
11
  customToString?: null | FormatAnyToString;
12
+ truncateOptions?: null | TruncateStringOptions;
11
13
  };
12
14
  export declare function formatAny(obj: any, options?: null | FormatAnyOptions, path?: null | string[], visited?: null | Set<any>): string;
@@ -1,5 +1,7 @@
1
1
  export type TruncateStringOptions = {
2
- fromStart?: boolean;
2
+ fromStart?: null | boolean;
3
+ appendEllipsis?: null | boolean;
4
+ appendTruncatedLength?: null | boolean;
3
5
  };
4
6
  export declare function truncateString(str: string, maxLength: number | null | undefined, options?: null | TruncateStringOptions): string;
5
7
  export declare function truncateString(str: string | null | undefined, maxLength: number | null | undefined, options?: null | TruncateStringOptions): string | null;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../urlGet-Be7wEmXE.js"),C=require("@flemist/async-utils"),S=require("@flemist/time-limits"),b=require("node:os"),V=require("path"),W=require("@flemist/priority-queue"),ee=require("fs"),te=require("picomatch");function j(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const w=j(V),g=j(ee),z=new S.Pool(b.cpus().length);function x(e){return e.replace(/\\/g,"/")}let I=null;function ne(e){I==null&&(I=new Map);const n=x(e);let a=I.get(n);return a==null&&(a=new C.Locker,I.set(n,a)),a}function re(e){const{filePath:n,func:a}=e;return ne(n).lock(()=>S.poolRunWait({pool:z,count:1,func:a}))}function B(e){return e.match(/^[/\\]?[^/\\]+/)[0]}function H(e,n){return B(e)+"|"+n.ino}function $(e){return e.endsWith(":")&&(e+="/"),w.resolve(e)}function _(e,n){e.totalSize+=n.totalSize,e.maxFileDateModified=Math.max(e.maxFileDateModified,n.maxFileDateModified),e.countFiles+=n.countFiles,e.countDirs+=n.countDirs,e.countLinks+=n.countLinks}const J=function(n){return n.code==="ENOENT"};function Q(e){const n=e.paths;if(!n||n.length===0)return Promise.resolve({totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0});const a=e.level??0,i=e.walkedIds??new Set,r=e.abortSignal,l=e.pool??z,p=e.handleError,d=e.priority??W.priorityCreate(0),c=e.walkLinks??!1,m=e.log,D=e.handlePath,N=e.matchPath;async function R(L){if(!(p&&await p(L))&&!J(L))throw L}function Y(L){return!(!m||m.minTotalContentSize!=null&&L<m.minTotalContentSize||m.maxNestedLevel!=null&&a>m.maxNestedLevel)}return C.useAbortController(async L=>{const E=C.combineAbortSignals(r,L),T={totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0};function q(f,y){if(Y(y.totalSize)){const o=`${y.totalSize.toLocaleString("en-US").replace(/,/g," ").padStart(19)}: ${f}`;m?.handleLog?m.handleLog(o):console.log(o)}}async function G(f,y,k,o){return D?await S.poolRunWait({pool:l,func:async()=>{try{return await D({level:a,path:f,stat:y,itemStat:k,totalStat:T,abortSignal:E})}catch(u){return await R(u),!1}},count:1,priority:o,abortSignal:E}):!0}async function O(f,y,k,o){o||(o=f);const u=await S.poolRunWait({pool:l,func:()=>g.promises.lstat(f).catch(R),count:1,priority:W.priorityCreate(y,W.priorityCreate(1,d)),abortSignal:E});if(!u||!k&&u.isFile())return null;const U=H(f,u);if(i.has(U))return null;i.add(U);let s={totalSize:u.size,maxFileDateModified:u.isDirectory()?0:u.mtimeMs,countFiles:0,countDirs:0,countLinks:0};const M=W.priorityCreate(y,W.priorityCreate(u.isDirectory()?2:3,d));if(u.isSymbolicLink()){if(c){const h=await S.poolRunWait({pool:l,func:()=>g.promises.readlink(f).catch(R).then(F=>F??null),count:1,priority:M,abortSignal:E});if(h){const F=w.isAbsolute(h)?h:w.resolve(w.dirname(o),h),v=await O(F,y,k,o);v&&(s=v)}}return(k||s.countFiles+s.countDirs+s.countLinks>=1)&&(s.countLinks+=1,await G(o,u,s,M)&&(_(T,s),q(o,s))),s}else if(u.isDirectory()){const h=await S.poolRunWait({pool:l,func:()=>g.promises.readdir(f).catch(R),count:1,priority:d,abortSignal:E});if(h){for(let F=0,v=h.length;F<v;F++)h[F]=w.join(o,h[F]);s=await Q({...e,paths:h,abortSignal:E,priority:M,level:a+1,walkedIds:i})}}return(k||s.countFiles+s.countDirs+s.countLinks>=1)&&(u.isDirectory()?s.countDirs+=1:u.isFile()&&(s.countFiles+=1),await G(o,u,s,M)&&(_(T,s),q(o,s))),s}const A=[];for(let f=0,y=n.length;f<y;f++){const k=$(n[f]),o=N?N(k):!0;o!==!1&&A.push(O(k,f,o))}return await Promise.all(A),T})}function ae(e){return Q(e)}function ie({globs:e,rootDir:n,noCase:a}){const i=[];return e.forEach(r=>{r=x(r).trim();const l=r.startsWith("^");l&&(r=r.substring(1).trim());const p=r.startsWith("!");if(p&&(r=r.substring(1).trim()),r.startsWith("!")||r.startsWith("^"))throw new Error(`Invalid glob pattern: "${r}". The syntax '${r.substring(0,2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`);r.startsWith("/")&&(r="."+r);const d=x(n?w.resolve(n,r):r);if(!d)return;let c;try{c=te(d,{nocase:a??!1,dot:!0,strictBrackets:!0})}catch(m){throw new Error(`Invalid glob pattern: "${r}". ${m instanceof Error?m.message:"Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`)}i.push({exclude:l,negative:p,debugInfo:d,match:c})}),function(l){l=x(l);let p=null,d=!1;for(let c=0,m=i.length;c<m;c++){const D=i[c];D.match(l)&&(D.exclude?d=!D.negative:(p=!D.negative,d=!1))}return d?!1:p}}function X(e){const n=e.startsWith("!");return n&&(e=e.substring(1)),e.startsWith("/")?e=e.substring(1):!e.startsWith("**")&&!e.startsWith("../")&&(e=`**/${e}`),n&&(e="!"+e),e}function Z(e,n){if(!n||n===".")return e;const a=e.startsWith("^");a&&(e=e.substring(1));const i=e.startsWith("!");return i&&(e=e.substring(1)),e.startsWith("/")?(n.endsWith("/")&&(n=n.substring(0,n.length-1)),e=n+e):(n.endsWith("/")||(n+="/"),e.startsWith("./")?e=n+e.substring(2):e.startsWith("../")?e=n+e:(n.startsWith("..")&&(n=""),e.startsWith("**")?e=n+e:e=n+"**/"+e)),e=x(w.normalize(e)),i&&(e="!"+e),a&&(e="^"+e),e}function P(e){return"^"+e}async function K(e){const a=(await g.promises.readFile(e,"utf-8")).split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../urlGet-jyEOC24k.js"),C=require("@flemist/async-utils"),S=require("@flemist/time-limits"),b=require("node:os"),V=require("path"),W=require("@flemist/priority-queue"),ee=require("fs"),te=require("picomatch");function j(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const w=j(V),g=j(ee),z=new S.Pool(b.cpus().length);function x(e){return e.replace(/\\/g,"/")}let I=null;function ne(e){I==null&&(I=new Map);const n=x(e);let a=I.get(n);return a==null&&(a=new C.Locker,I.set(n,a)),a}function re(e){const{filePath:n,func:a}=e;return ne(n).lock(()=>S.poolRunWait({pool:z,count:1,func:a}))}function B(e){return e.match(/^[/\\]?[^/\\]+/)[0]}function H(e,n){return B(e)+"|"+n.ino}function $(e){return e.endsWith(":")&&(e+="/"),w.resolve(e)}function _(e,n){e.totalSize+=n.totalSize,e.maxFileDateModified=Math.max(e.maxFileDateModified,n.maxFileDateModified),e.countFiles+=n.countFiles,e.countDirs+=n.countDirs,e.countLinks+=n.countLinks}const J=function(n){return n.code==="ENOENT"};function Q(e){const n=e.paths;if(!n||n.length===0)return Promise.resolve({totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0});const a=e.level??0,i=e.walkedIds??new Set,r=e.abortSignal,l=e.pool??z,p=e.handleError,d=e.priority??W.priorityCreate(0),c=e.walkLinks??!1,m=e.log,D=e.handlePath,N=e.matchPath;async function R(L){if(!(p&&await p(L))&&!J(L))throw L}function Y(L){return!(!m||m.minTotalContentSize!=null&&L<m.minTotalContentSize||m.maxNestedLevel!=null&&a>m.maxNestedLevel)}return C.useAbortController(async L=>{const E=C.combineAbortSignals(r,L),T={totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0};function q(f,y){if(Y(y.totalSize)){const o=`${y.totalSize.toLocaleString("en-US").replace(/,/g," ").padStart(19)}: ${f}`;m?.handleLog?m.handleLog(o):console.log(o)}}async function G(f,y,k,o){return D?await S.poolRunWait({pool:l,func:async()=>{try{return await D({level:a,path:f,stat:y,itemStat:k,totalStat:T,abortSignal:E})}catch(u){return await R(u),!1}},count:1,priority:o,abortSignal:E}):!0}async function O(f,y,k,o){o||(o=f);const u=await S.poolRunWait({pool:l,func:()=>g.promises.lstat(f).catch(R),count:1,priority:W.priorityCreate(y,W.priorityCreate(1,d)),abortSignal:E});if(!u||!k&&u.isFile())return null;const U=H(f,u);if(i.has(U))return null;i.add(U);let s={totalSize:u.size,maxFileDateModified:u.isDirectory()?0:u.mtimeMs,countFiles:0,countDirs:0,countLinks:0};const M=W.priorityCreate(y,W.priorityCreate(u.isDirectory()?2:3,d));if(u.isSymbolicLink()){if(c){const h=await S.poolRunWait({pool:l,func:()=>g.promises.readlink(f).catch(R).then(F=>F??null),count:1,priority:M,abortSignal:E});if(h){const F=w.isAbsolute(h)?h:w.resolve(w.dirname(o),h),v=await O(F,y,k,o);v&&(s=v)}}return(k||s.countFiles+s.countDirs+s.countLinks>=1)&&(s.countLinks+=1,await G(o,u,s,M)&&(_(T,s),q(o,s))),s}else if(u.isDirectory()){const h=await S.poolRunWait({pool:l,func:()=>g.promises.readdir(f).catch(R),count:1,priority:d,abortSignal:E});if(h){for(let F=0,v=h.length;F<v;F++)h[F]=w.join(o,h[F]);s=await Q({...e,paths:h,abortSignal:E,priority:M,level:a+1,walkedIds:i})}}return(k||s.countFiles+s.countDirs+s.countLinks>=1)&&(u.isDirectory()?s.countDirs+=1:u.isFile()&&(s.countFiles+=1),await G(o,u,s,M)&&(_(T,s),q(o,s))),s}const A=[];for(let f=0,y=n.length;f<y;f++){const k=$(n[f]),o=N?N(k):!0;o!==!1&&A.push(O(k,f,o))}return await Promise.all(A),T})}function ae(e){return Q(e)}function ie({globs:e,rootDir:n,noCase:a}){const i=[];return e.forEach(r=>{r=x(r).trim();const l=r.startsWith("^");l&&(r=r.substring(1).trim());const p=r.startsWith("!");if(p&&(r=r.substring(1).trim()),r.startsWith("!")||r.startsWith("^"))throw new Error(`Invalid glob pattern: "${r}". The syntax '${r.substring(0,2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`);r.startsWith("/")&&(r="."+r);const d=x(n?w.resolve(n,r):r);if(!d)return;let c;try{c=te(d,{nocase:a??!1,dot:!0,strictBrackets:!0})}catch(m){throw new Error(`Invalid glob pattern: "${r}". ${m instanceof Error?m.message:"Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`)}i.push({exclude:l,negative:p,debugInfo:d,match:c})}),function(l){l=x(l);let p=null,d=!1;for(let c=0,m=i.length;c<m;c++){const D=i[c];D.match(l)&&(D.exclude?d=!D.negative:(p=!D.negative,d=!1))}return d?!1:p}}function X(e){const n=e.startsWith("!");return n&&(e=e.substring(1)),e.startsWith("/")?e=e.substring(1):!e.startsWith("**")&&!e.startsWith("../")&&(e=`**/${e}`),n&&(e="!"+e),e}function Z(e,n){if(!n||n===".")return e;const a=e.startsWith("^");a&&(e=e.substring(1));const i=e.startsWith("!");return i&&(e=e.substring(1)),e.startsWith("/")?(n.endsWith("/")&&(n=n.substring(0,n.length-1)),e=n+e):(n.endsWith("/")||(n+="/"),e.startsWith("./")?e=n+e.substring(2):e.startsWith("../")?e=n+e:(n.startsWith("..")&&(n=""),e.startsWith("**")?e=n+e:e=n+"**/"+e)),e=x(w.normalize(e)),i&&(e="!"+e),a&&(e="^"+e),e}function P(e){return"^"+e}async function K(e){const a=(await g.promises.readFile(e,"utf-8")).split(`
2
2
  `),i=[];return a.forEach(r=>{r=r.trim(),!(!r||r.startsWith("#"))&&i.push(r)}),i}async function se(e){const n=e.rootDir??".",a=[];if(!e.globs?.length)return a;const i=[];return e.globs.forEach(r=>{r.value&&(r.valueType==="file-contains-patterns"?i.push(r):r.valueType==="pattern"&&a.push(r.exclude?P(r.value):r.value))}),i.length&&await Promise.all(i.map(async r=>{await S.poolRunWait({pool:z,count:1,func:async()=>{const l=w.resolve(n,r.value),p=await K(l),d=w.relative(n,w.dirname(l));p.forEach(c=>{c=X(c),c=Z(c,d),a.push(r.exclude?P(c):c)})}})})),a}exports.ConsoleMessageLevel=t.ConsoleMessageLevel;exports.Lazy=t.Lazy;exports.LazyWithId=t.LazyWithId;exports.Random=t.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=t.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=t.alertReplace;exports.consoleReplace=t.consoleReplace;exports.convertTimeZone=t.convertTimeZone;exports.createUniquePseudoRandom=t.createUniquePseudoRandom;exports.dateNowUnique=t.dateNowUnique;exports.deepCloneJsonLike=t.deepCloneJsonLike;exports.deepEqualJsonLike=t.deepEqualJsonLike;exports.deepEqualJsonLikeMap=t.deepEqualJsonLikeMap;exports.equalArray=t.equalArray;exports.escapeHtml=t.escapeHtml;exports.escapeRegExp=t.escapeRegExp;exports.fixStackTrace=t.fixStackTrace;exports.formatAny=t.formatAny;exports.formatDate=t.formatDate;exports.formatDateFileName=t.formatDateFileName;exports.getDateInet=t.getDateInet;exports.getNormalizedObject=t.getNormalizedObject;exports.getRandomFunc=t.getRandomFunc;exports.getRandomSeed=t.getRandomSeed;exports.getStackTrace=t.getStackTrace;exports.max=t.max;exports.min=t.min;exports.minMax=t.minMax;exports.numberMod=t.numberMod;exports.randomBoolean=t.randomBoolean;exports.randomEnum=t.randomEnum;exports.randomFloat=t.randomFloat;exports.randomIndexWeighted=t.randomIndexWeighted;exports.randomInt=t.randomInt;exports.randomItem=t.randomItem;exports.randomItems=t.randomItems;exports.setFuncName=t.setFuncName;exports.sha256=t.sha256;exports.sha256Buffer=t.sha256Buffer;exports.timeoutAbortController=t.timeoutAbortController;exports.toHex=t.toHex;exports.truncateString=t.truncateString;exports.urlGetBoolean=t.urlGetBoolean;exports.urlGetFloat=t.urlGetFloat;exports.urlGetInt=t.urlGetInt;exports.urlGetParams=t.urlGetParams;exports.urlGetString=t.urlGetString;exports.urlParamToBoolean=t.urlParamToBoolean;exports.urlParamToFloat=t.urlParamToFloat;exports.urlParamToInt=t.urlParamToInt;exports.withConsoleReplace=t.withConsoleReplace;exports.withTimeout=t.withTimeout;exports.createMatchPath=ie;exports.fileLock=re;exports.getDrive=B;exports.getFileId=H;exports.globGitIgnoreToPicomatch=X;exports.globToRelative=Z;exports.loadGlobs=se;exports.loadGlobsFromFile=K;exports.pathNormalize=x;exports.pathResolve=$;exports.poolFs=z;exports.walkPathHandleErrorDefault=J;exports.walkPaths=ae;
@@ -1,4 +1,4 @@
1
- import { H as mt, O as ht, P as pt, R as kt, U as wt, G as yt, I as xt, q as Ft, l as Lt, o as Dt, A as St, B as Et, C as Wt, D as zt, y as vt, z as Mt, K as Tt, u as It, v as Nt, w as Rt, p as Ct, E as At, d as Gt, g as Ut, L as Ot, b as $t, m as qt, c as Bt, n as _t, f as jt, k as Ht, r as Jt, h as gt, e as Pt, i as Qt, j as Xt, F as Zt, a as Kt, s as Yt, M as Vt, t as bt, x as te, X as ee, Z as ne, Y as se, Q as ae, W as re, S as ie, V as oe, T as ce, J as ue, N as le } from "../urlGet-A6tzime-.mjs";
1
+ import { H as mt, O as ht, P as pt, R as kt, U as wt, G as yt, I as xt, q as Ft, l as Lt, o as Dt, A as St, B as Et, C as Wt, D as zt, y as vt, z as Mt, K as Tt, u as It, v as Nt, w as Rt, p as Ct, E as At, d as Gt, g as Ut, L as Ot, b as $t, m as qt, c as Bt, n as _t, f as jt, k as Ht, r as Jt, h as gt, e as Pt, i as Qt, j as Xt, F as Zt, a as Kt, s as Yt, M as Vt, t as bt, x as te, X as ee, Z as ne, Y as se, Q as ae, W as re, S as ie, V as oe, T as ce, J as ue, N as le } from "../urlGet-gscwyYHD.mjs";
2
2
  import { Locker as j, useAbortController as H, combineAbortSignals as J } from "@flemist/async-utils";
3
3
  import { Pool as g, poolRunWait as D } from "@flemist/time-limits";
4
4
  import P from "node:os";
@@ -1,24 +1,24 @@
1
1
  import { AbortControllerFast as et, toAbortSignal as ft, AbortError as ct } from "@flemist/abort-controller-fast";
2
2
  import { isPromiseLike as X } from "@flemist/async-utils";
3
3
  import { timeControllerDefault as ht } from "@flemist/time-controller";
4
- let V = null;
4
+ let L = null;
5
5
  function mt() {
6
- if (!V) {
7
- V = new Array(256);
6
+ if (!L) {
7
+ L = new Array(256);
8
8
  for (let t = 0; t < 256; t++)
9
- V[t] = t.toString(16).padStart(2, "0");
9
+ L[t] = t.toString(16).padStart(2, "0");
10
10
  }
11
- return V;
11
+ return L;
12
12
  }
13
13
  function pt(t) {
14
- const e = mt(), r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
15
- let n = "";
16
- for (let o = 0, s = r.length; o < s; o++)
17
- n += e[r[o]];
18
- return n;
19
- }
20
- let J = null, rt = null, B = null, nt = null;
21
- function dt() {
14
+ const e = mt(), n = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
15
+ let r = "";
16
+ for (let o = 0, s = n.length; o < s; o++)
17
+ r += e[n[o]];
18
+ return r;
19
+ }
20
+ let J = null, nt = null, B = null, rt = null;
21
+ function gt() {
22
22
  J || (J = new Uint32Array([
23
23
  1116352408,
24
24
  1899447441,
@@ -84,19 +84,19 @@ function dt() {
84
84
  2756734187,
85
85
  3204031479,
86
86
  3329325298
87
- ]), rt = new Uint32Array(64), nt = new TextEncoder(), B = new Uint8Array(65536));
87
+ ]), nt = new Uint32Array(64), rt = new TextEncoder(), B = new Uint8Array(65536));
88
88
  }
89
- function yt(t) {
89
+ function dt(t) {
90
90
  if (t == null)
91
91
  return null;
92
- dt();
93
- const e = J, r = rt, n = nt;
92
+ gt();
93
+ const e = J, n = nt, r = rt;
94
94
  let o = B, s;
95
95
  if (typeof t == "string") {
96
- const c = t.length * 3;
97
- o.length < c + 128 && (o = B = new Uint8Array(c + 128));
98
- const f = n.encodeInto(t, o);
99
- s = o.subarray(0, f.written);
96
+ const h = t.length * 3;
97
+ o.length < h + 128 && (o = B = new Uint8Array(h + 128));
98
+ const c = r.encodeInto(t, o);
99
+ s = o.subarray(0, c.written);
100
100
  } else if (t instanceof Uint8Array)
101
101
  s = t;
102
102
  else if (ArrayBuffer.isView(t))
@@ -109,73 +109,73 @@ function yt(t) {
109
109
  throw new Error(
110
110
  `[sha256Buffer] Unsupported content type: ${typeof t}`
111
111
  );
112
- const m = s.length, a = m + 72 >>> 6 << 6;
113
- o.length < a && (o = B = new Uint8Array(a)), s !== o && o.set(s), o[m] = 128;
114
- for (let c = m + 1; c < a; c++)
115
- o[c] = 0;
116
- const U = m * 8, O = U / 4294967296 | 0, C = U | 0;
117
- o[a - 8] = O >>> 24, o[a - 7] = O >>> 16, o[a - 6] = O >>> 8, o[a - 5] = O, o[a - 4] = C >>> 24, o[a - 3] = C >>> 16, o[a - 2] = C >>> 8, o[a - 1] = C;
118
- let T = 1779033703, $ = -1150833019, u = 1013904242, i = -1521486534, l = 1359893119, y = -1694144372, p = 528734635, w = 1541459225;
119
- for (let c = 0; c < a; c += 64) {
120
- for (let h = 0; h < 16; h++) {
121
- const d = c + (h << 2);
122
- r[h] = o[d] << 24 | o[d + 1] << 16 | o[d + 2] << 8 | o[d + 3];
112
+ const f = s.length, a = f + 72 >>> 6 << 6;
113
+ o.length < a && (o = B = new Uint8Array(a)), s !== o && o.set(s), o[f] = 128;
114
+ for (let h = f + 1; h < a; h++)
115
+ o[h] = 0;
116
+ const T = f * 8, _ = T / 4294967296 | 0, C = T | 0;
117
+ o[a - 8] = _ >>> 24, o[a - 7] = _ >>> 16, o[a - 6] = _ >>> 8, o[a - 5] = _, o[a - 4] = C >>> 24, o[a - 3] = C >>> 16, o[a - 2] = C >>> 8, o[a - 1] = C;
118
+ let U = 1779033703, $ = -1150833019, u = 1013904242, i = -1521486534, l = 1359893119, d = -1694144372, p = 528734635, y = 1541459225;
119
+ for (let h = 0; h < a; h += 64) {
120
+ for (let m = 0; m < 16; m++) {
121
+ const g = h + (m << 2);
122
+ n[m] = o[g] << 24 | o[g + 1] << 16 | o[g + 2] << 8 | o[g + 3];
123
123
  }
124
- for (let h = 16; h < 64; h++) {
125
- const d = r[h - 15], A = r[h - 2], H = (d >>> 7 | d << 25) ^ (d >>> 18 | d << 14) ^ d >>> 3, D = (A >>> 17 | A << 15) ^ (A >>> 19 | A << 13) ^ A >>> 10;
126
- r[h] = r[h - 16] + H + r[h - 7] + D | 0;
124
+ for (let m = 16; m < 64; m++) {
125
+ const g = n[m - 15], A = n[m - 2], H = (g >>> 7 | g << 25) ^ (g >>> 18 | g << 14) ^ g >>> 3, D = (A >>> 17 | A << 15) ^ (A >>> 19 | A << 13) ^ A >>> 10;
126
+ n[m] = n[m - 16] + H + n[m - 7] + D | 0;
127
127
  }
128
- let f = T, S = $, M = u, F = i, _ = l, P = y, k = p, q = w;
129
- for (let h = 0; h < 64; h += 4)
130
- for (let d = 0; d < 4; d++) {
131
- const A = h + d, H = (_ >>> 6 | _ << 26) ^ (_ >>> 11 | _ << 21) ^ (_ >>> 25 | _ << 7), D = q + H + (k ^ _ & (P ^ k)) + e[A] + r[A] | 0, at = ((f >>> 2 | f << 30) ^ (f >>> 13 | f << 19) ^ (f >>> 22 | f << 10)) + (f & S ^ M & (f ^ S)) | 0;
132
- q = k, k = P, P = _, _ = F + D | 0, F = M, M = S, S = f, f = D + at | 0;
128
+ let c = U, S = $, N = u, F = i, O = l, P = d, x = p, q = y;
129
+ for (let m = 0; m < 64; m += 4)
130
+ for (let g = 0; g < 4; g++) {
131
+ const A = m + g, H = (O >>> 6 | O << 26) ^ (O >>> 11 | O << 21) ^ (O >>> 25 | O << 7), D = q + H + (x ^ O & (P ^ x)) + e[A] + n[A] | 0, at = ((c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10)) + (c & S ^ N & (c ^ S)) | 0;
132
+ q = x, x = P, P = O, O = F + D | 0, F = N, N = S, S = c, c = D + at | 0;
133
133
  }
134
- T = T + f | 0, $ = $ + S | 0, u = u + M | 0, i = i + F | 0, l = l + _ | 0, y = y + P | 0, p = p + k | 0, w = w + q | 0;
134
+ U = U + c | 0, $ = $ + S | 0, u = u + N | 0, i = i + F | 0, l = l + O | 0, d = d + P | 0, p = p + x | 0, y = y + q | 0;
135
135
  }
136
- const g = new Uint8Array(32), R = [T, $, u, i, l, y, p, w];
137
- for (let c = 0; c < 8; c++) {
138
- const f = R[c], S = c << 2;
139
- g[S] = f >>> 24, g[S + 1] = f >>> 16 & 255, g[S + 2] = f >>> 8 & 255, g[S + 3] = f & 255;
136
+ const w = new Uint8Array(32), R = [U, $, u, i, l, d, p, y];
137
+ for (let h = 0; h < 8; h++) {
138
+ const c = R[h], S = h << 2;
139
+ w[S] = c >>> 24, w[S + 1] = c >>> 16 & 255, w[S + 2] = c >>> 8 & 255, w[S + 3] = c & 255;
140
140
  }
141
- return g;
141
+ return w;
142
142
  }
143
- function Vt(t) {
144
- const e = yt(t);
143
+ function Lt(t) {
144
+ const e = dt(t);
145
145
  return e ? pt(e) : null;
146
146
  }
147
- function wt(t, e) {
147
+ function yt(t, e) {
148
148
  return t == null ? e : e == null ? t : Math.min(t, e);
149
149
  }
150
- function gt(t, e) {
150
+ function wt(t, e) {
151
151
  return t == null ? e : e == null ? t : Math.max(t, e);
152
152
  }
153
- function Lt(t, e, r) {
154
- return gt(wt(t, e), r);
153
+ function Vt(t, e, n) {
154
+ return wt(yt(t, e), n);
155
155
  }
156
156
  function Bt(t, e) {
157
157
  return (t % e + e) % e;
158
158
  }
159
159
  function St(t) {
160
160
  return function() {
161
- let r = t += 1831565813;
162
- return r = Math.imul(r ^ r >>> 15, r | 1), r ^= r + Math.imul(r ^ r >>> 7, r | 61), (r ^ r >>> 14) / 4294967296 + 0.5;
161
+ let n = t += 1831565813;
162
+ return n = Math.imul(n ^ n >>> 15, n | 1), n ^= n + Math.imul(n ^ n >>> 7, n | 61), (n ^ n >>> 14) / 4294967296 + 0.5;
163
163
  };
164
164
  }
165
- function _t() {
165
+ function Ot() {
166
166
  return Math.random();
167
167
  }
168
168
  function zt() {
169
169
  return Math.random() * 2 ** 32 >>> 0;
170
170
  }
171
- function Ot(t) {
172
- return t != null ? St(t) : _t;
171
+ function _t(t) {
172
+ return t != null ? St(t) : Ot;
173
173
  }
174
174
  class Y {
175
175
  _seed;
176
176
  _rnd;
177
177
  constructor(e) {
178
- this._seed = e, this._rnd = Ot(e);
178
+ this._seed = e, this._rnd = _t(e);
179
179
  }
180
180
  get seed() {
181
181
  return this._seed;
@@ -193,54 +193,54 @@ class Y {
193
193
  return new Y(this._seed);
194
194
  }
195
195
  }
196
- function ot(t, e, r) {
197
- if (r == null && (r = e, e = 0), r <= e)
196
+ function ot(t, e, n) {
197
+ if (n == null && (n = e, e = 0), n <= e)
198
198
  throw new Error(
199
- `[random][randomFloat] toExclusive (${r}) must be greater than from (${e})`
199
+ `[random][randomFloat] toExclusive (${n}) must be greater than from (${e})`
200
200
  );
201
- return t.next() * (r - e) + e;
201
+ return t.next() * (n - e) + e;
202
202
  }
203
- function $t(t, e, r) {
204
- return Math.floor(ot(t, e, r));
203
+ function $t(t, e, n) {
204
+ return Math.floor(ot(t, e, n));
205
205
  }
206
206
  function Ft(t, e) {
207
207
  return t.next() < (e ?? 0.5);
208
208
  }
209
- function qt(t, e, r) {
209
+ function qt(t, e, n) {
210
210
  if (Array.isArray(e)) {
211
211
  const s = e;
212
- e = s.length, r = (m) => s[m];
212
+ e = s.length, n = (f) => s[f];
213
213
  }
214
- if (!r)
214
+ if (!n)
215
215
  throw new Error("[random][randomIndexWeighted] getWeight is required");
216
- let n = 0;
216
+ let r = 0;
217
217
  for (let s = 0; s < e; s++)
218
- n += r(s);
219
- if (n === 0)
218
+ r += n(s);
219
+ if (r === 0)
220
220
  return -1;
221
- let o = ot(t, n);
221
+ let o = ot(t, r);
222
222
  for (let s = 0; s < e; s++)
223
- if (o -= r(s), o < 0)
223
+ if (o -= n(s), o < 0)
224
224
  return s;
225
225
  return e - 1;
226
226
  }
227
227
  function st(t, e) {
228
228
  if (e.length === 0)
229
229
  throw new Error("[random][randomItem] items is empty");
230
- const r = $t(t, e.length);
231
- return e[r];
230
+ const n = $t(t, e.length);
231
+ return e[n];
232
232
  }
233
- function Ht(t, e, r) {
233
+ function Ht(t, e, n) {
234
234
  if (e.length === 0)
235
235
  throw new Error("[random][randomItems] items is empty");
236
- const n = [];
237
- for (let o = 0; o < r; o++)
238
- n.push(st(t, e));
239
- return n;
236
+ const r = [];
237
+ for (let o = 0; o < n; o++)
238
+ r.push(st(t, e));
239
+ return r;
240
240
  }
241
- function Wt(t, e, r) {
242
- let n = Object.values(e);
243
- return r && (n = n.filter(r)), st(t, n);
241
+ function Wt(t, e, n) {
242
+ let r = Object.values(e);
243
+ return n && (r = r.filter(n)), st(t, r);
244
244
  }
245
245
  const it = 1073741789, W = (it >> 2) - 1;
246
246
  function Gt(t = W, e) {
@@ -254,30 +254,30 @@ function Gt(t = W, e) {
254
254
  throw new Error(
255
255
  `[random][PseudoRandom] startFrom(${e}) must be < count(${t})`
256
256
  );
257
- let r = e;
257
+ let n = e;
258
258
  return function() {
259
- return r = (r + it) % t, r;
259
+ return n = (n + it) % t, n;
260
260
  };
261
261
  }
262
- let N = null;
262
+ let k = null;
263
263
  function Jt() {
264
264
  const t = Date.now();
265
- return N == null || t > N ? (N = t, t) : (N++, N);
265
+ return k == null || t > k ? (k = t, t) : (k++, k);
266
266
  }
267
267
  async function Yt({
268
268
  url: t,
269
269
  timeout: e
270
270
  } = {}) {
271
271
  t || (t = typeof window < "u" ? "/" : "https://google.com");
272
- let r;
272
+ let n;
273
273
  try {
274
- const n = new et();
275
- r = e ? setTimeout(() => {
276
- n.abort();
274
+ const r = new et();
275
+ n = e ? setTimeout(() => {
276
+ r.abort();
277
277
  }, e) : null;
278
278
  const o = await fetch(t, {
279
279
  method: "HEAD",
280
- signal: ft(n.signal)
280
+ signal: ft(r.signal)
281
281
  }), s = o.headers.get("date");
282
282
  if (!s)
283
283
  throw new Error(
@@ -285,144 +285,154 @@ async function Yt({
285
285
  );
286
286
  return new Date(s).getTime();
287
287
  } finally {
288
- r && clearTimeout(r);
288
+ n && clearTimeout(n);
289
289
  }
290
290
  }
291
- function ut(t, e, r) {
292
- const n = e == null ? t : new Date(
291
+ function ut(t, e, n) {
292
+ const r = e == null ? t : new Date(
293
293
  t.toLocaleString("en-US", {
294
294
  timeZone: e
295
295
  })
296
- ), o = r == null ? t : new Date(
296
+ ), o = n == null ? t : new Date(
297
297
  t.toLocaleString("en-US", {
298
- timeZone: r
298
+ timeZone: n
299
299
  })
300
300
  );
301
301
  return new Date(
302
- t.getTime() + o.getTime() - n.getTime()
302
+ t.getTime() + o.getTime() - r.getTime()
303
303
  );
304
304
  }
305
305
  function At(t, e) {
306
306
  t = ut(t, "UTC", e);
307
- const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), m = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
308
- return `${r}-${n}-${o} ${s}:${m}:${a}`;
307
+ const n = t.getUTCFullYear().toString().padStart(4, "0"), r = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), f = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
308
+ return `${n}-${r}-${o} ${s}:${f}:${a}`;
309
309
  }
310
- let Ut = 0;
310
+ let Tt = 0;
311
311
  const G = /* @__PURE__ */ new WeakMap();
312
312
  function I(t) {
313
313
  if (G.has(t))
314
314
  return G.get(t);
315
- const e = Ut++;
315
+ const e = Tt++;
316
316
  return G.set(t, e), e;
317
317
  }
318
- function L(t, e, r) {
319
- return t == null ? t ?? null : e == null ? t : t.length > e ? e <= 0 ? "…" : r?.fromStart ? "…" + t.slice(t.length - e + 1) : t.slice(0, e - 1) + "…" : t;
318
+ function V(t, e, n) {
319
+ if (t == null)
320
+ return null;
321
+ if (e == null || t.length <= e)
322
+ return t;
323
+ const r = n?.appendEllipsis ? "…" : "", o = r.length + (n?.appendTruncatedLength ? String(t.length).length + 2 : 0), s = Math.max(0, e - o), f = n?.appendTruncatedLength ? `(${t.length - s})` : "";
324
+ return s <= 0 ? f + r : n?.fromStart ? f + r + t.slice(t.length - s) : t.slice(0, s) + r + f;
320
325
  }
321
326
  function K(t, e) {
322
327
  try {
323
328
  return t[e];
324
- } catch (r) {
325
- return "Error: " + (r instanceof Error ? r.message : String(r));
329
+ } catch (n) {
330
+ return "Error: " + (n instanceof Error ? n.message : String(n));
326
331
  }
327
332
  }
328
- function x(t, e, r, n) {
333
+ function M(t, e, n, r) {
329
334
  const {
330
335
  pretty: o,
331
336
  filter: s,
332
- maxDepth: m,
337
+ maxDepth: f,
333
338
  maxItems: a,
334
- maxStringLength: U,
335
- showObjectId: O,
339
+ maxStringLength: T,
340
+ showObjectId: _,
336
341
  showArrayIndex: C,
337
- customToString: T
342
+ customToString: U
338
343
  } = e ?? {};
339
- if (r == null && (r = []), n == null && (n = /* @__PURE__ */ new Set()), T) {
340
- const u = T(
344
+ if (n == null && (n = []), r == null && (r = /* @__PURE__ */ new Set()), U) {
345
+ const u = U(
341
346
  t,
342
- r,
343
- (i) => x(i, e, r, n)
347
+ n,
348
+ (i) => M(i, e, n, r)
344
349
  );
345
350
  if (u != null)
346
- return L(u, U);
351
+ return V(u, T, e?.truncateOptions);
347
352
  }
348
- const $ = r.length;
353
+ const $ = n.length;
349
354
  if (typeof t == "string")
350
- return t = L(t, U), n.size > 0 && (t = JSON.stringify(t)), t;
355
+ return t = V(t, T, e?.truncateOptions), r.size > 0 && (t = JSON.stringify(t)), t;
351
356
  if (t == null || typeof t != "object")
352
357
  return String(t);
353
358
  if (t instanceof ArrayBuffer || ArrayBuffer.isView(t))
354
359
  return `${t.constructor?.name ?? ""}#${I(t)}[${t.byteLength}]`;
355
360
  if (t instanceof RegExp)
356
- return L(String(t), U);
361
+ return V(
362
+ String(t),
363
+ T,
364
+ e?.truncateOptions
365
+ );
357
366
  if (t instanceof Date)
358
367
  return At(t);
359
368
  if (t instanceof Object) {
360
- if (n.has(t) || m != null && $ >= m)
369
+ if (r.has(t) || f != null && $ >= f)
361
370
  return `${t.constructor === Object ? "" : t.constructor?.name ?? ""}#${I(t)}`;
362
- n.add(t);
371
+ r.add(t);
363
372
  }
364
373
  if (t instanceof Error)
365
- return L(
374
+ return V(
366
375
  t.stack || t.message || String(t),
367
- U
376
+ T,
377
+ e?.truncateOptions
368
378
  );
369
379
  if (Array.isArray(t)) {
370
380
  const u = o ? " ".repeat($) : "";
371
381
  let i = "";
372
- O && (i += `#${I(t)} `), i += "[";
373
- let l = 0, y = !1;
382
+ _ && (i += `#${I(t)} `), i += "[";
383
+ let l = 0, d = !1;
374
384
  for (let p = 0; p < t.length; p++) {
375
385
  if (a != null && l >= a) {
376
- y = !0;
386
+ d = !0;
377
387
  break;
378
388
  }
379
- const w = [...r, String(p)], g = K(t, p);
380
- if (s != null && !s(w, g))
389
+ const y = [...n, String(p)], w = K(t, p);
390
+ if (s != null && !s(y, w))
381
391
  continue;
382
- const R = x(g, e, w, n);
392
+ const R = M(w, e, y, r);
383
393
  l > 0 && (i += ","), o && (i += `
384
394
  `), o && (i += `${u} `), C && (i += `${p}: `), i += `${R}`, l++;
385
395
  }
386
- return y ? (l > 0 && (i += ","), o ? (i += `
396
+ return d ? (l > 0 && (i += ","), o ? (i += `
387
397
  `, i += `${u} ...
388
398
  `) : i += "...", i += u, i += "]") : (l > 0 && o && (i += `
389
399
  ${u}`), i += "]"), i;
390
400
  }
391
401
  if (t instanceof Map) {
392
402
  let u = "";
393
- return O && (u += `#${I(t)} `), u += "Map", u += x(Array.from(t.entries()), e, r, n), u;
403
+ return _ && (u += `#${I(t)} `), u += "Map", u += M(Array.from(t.entries()), e, n, r), u;
394
404
  }
395
405
  if (t instanceof Set) {
396
406
  let u = "";
397
- return O && (u += `#${I(t)} `), u += "Set", u += x(Array.from(t.values()), e, r, n), u;
407
+ return _ && (u += `#${I(t)} `), u += "Set", u += M(Array.from(t.values()), e, n, r), u;
398
408
  }
399
409
  {
400
410
  const u = t.constructor === Object ? "" : t.constructor?.name ?? "", i = o ? " ".repeat($) : "";
401
411
  let l = u ? `${u} ` : "";
402
- O && (l += `#${I(t)} `), l += "{";
403
- let y = 0, p = !1;
404
- for (const w in t) {
405
- if (a != null && y >= a) {
412
+ _ && (l += `#${I(t)} `), l += "{";
413
+ let d = 0, p = !1;
414
+ for (const y in t) {
415
+ if (a != null && d >= a) {
406
416
  p = !0;
407
417
  break;
408
418
  }
409
- const g = [...r, w], R = K(t, w);
410
- if (s != null && !s(g, R))
419
+ const w = [...n, y], R = K(t, y);
420
+ if (s != null && !s(w, R))
411
421
  continue;
412
- const c = x(R, e, g, n);
413
- y > 0 && (l += ","), o && (l += `
414
- `), o && (l += `${i} `), l += `${w}: ${c}`, y++;
422
+ const h = M(R, e, w, r);
423
+ d > 0 && (l += ","), o && (l += `
424
+ `), o && (l += `${i} `), l += `${y}: ${h}`, d++;
415
425
  }
416
- return p && (y > 0 && (l += ","), o ? (l += `
426
+ return p && (d > 0 && (l += ","), o ? (l += `
417
427
  `, l += `${i} ...
418
- `) : l += "...", l += i), y > 0 && o && !p && (l += `
428
+ `) : l += "...", l += i), d > 0 && o && !p && (l += `
419
429
  ${i}`), l += "}", l;
420
430
  }
421
431
  }
422
432
  function Xt(t, e) {
423
433
  t = ut(t, "UTC", e);
424
- const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), m = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
425
- return `${r}-${n}-${o}_${s}-${m}-${a}`;
434
+ const n = t.getUTCFullYear().toString().padStart(4, "0"), r = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), f = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
435
+ return `${n}-${r}-${o}_${s}-${f}-${a}`;
426
436
  }
427
437
  function bt(t) {
428
438
  return t == null ? null : t.replace(/[&<>"']/g, (e) => {
@@ -447,17 +457,17 @@ function Q(t) {
447
457
  if (t == null)
448
458
  return null;
449
459
  if (Array.isArray(t)) {
450
- const e = t.length, r = [];
451
- for (let n = 0; n < e; n++)
452
- r.push(Q(t[n]));
453
- return r;
460
+ const e = t.length, n = [];
461
+ for (let r = 0; r < e; r++)
462
+ n.push(Q(t[r]));
463
+ return n;
454
464
  }
455
465
  if (typeof t == "object") {
456
466
  if (t.constructor && t.constructor !== Object)
457
467
  return t;
458
468
  const e = {};
459
- for (const r in t)
460
- Object.prototype.hasOwnProperty.call(t, r) && (e[r] = Q(t[r]));
469
+ for (const n in t)
470
+ Object.prototype.hasOwnProperty.call(t, n) && (e[n] = Q(t[n]));
461
471
  return e;
462
472
  }
463
473
  return t;
@@ -472,25 +482,25 @@ function z(t, e) {
472
482
  if (Array.isArray(t)) {
473
483
  if (!Array.isArray(e))
474
484
  return !1;
475
- const r = t.length;
476
- if (r !== e.length)
485
+ const n = t.length;
486
+ if (n !== e.length)
477
487
  return !1;
478
- for (let n = 0; n < r; n++)
479
- if (!z(t[n], e[n]))
488
+ for (let r = 0; r < n; r++)
489
+ if (!z(t[r], e[r]))
480
490
  return !1;
481
491
  return !0;
482
492
  }
483
493
  if (typeof t == "object") {
484
494
  if (typeof e != "object" || t.constructor && t.constructor !== Object || e.constructor && e.constructor !== Object)
485
495
  return !1;
486
- for (const r in t)
487
- if (Object.prototype.hasOwnProperty.call(t, r) && !z(
488
- t[r],
489
- Object.prototype.hasOwnProperty.call(e, r) ? e[r] : null
496
+ for (const n in t)
497
+ if (Object.prototype.hasOwnProperty.call(t, n) && !z(
498
+ t[n],
499
+ Object.prototype.hasOwnProperty.call(e, n) ? e[n] : null
490
500
  ))
491
501
  return !1;
492
- for (const r in e)
493
- if (Object.prototype.hasOwnProperty.call(e, r) && !Object.prototype.hasOwnProperty.call(t, r) && !z(e[r], null))
502
+ for (const n in e)
503
+ if (Object.prototype.hasOwnProperty.call(e, n) && !Object.prototype.hasOwnProperty.call(t, n) && !z(e[n], null))
494
504
  return !1;
495
505
  return !0;
496
506
  }
@@ -501,24 +511,24 @@ function Qt(t, e) {
501
511
  return t == null == (e == null);
502
512
  if (t.size !== e.size)
503
513
  return !1;
504
- for (const [r, n] of t)
505
- if (!z(n, e.get(r)))
514
+ for (const [n, r] of t)
515
+ if (!z(r, e.get(n)))
506
516
  return !1;
507
517
  return !0;
508
518
  }
509
519
  function Zt(t, e) {
510
- const r = t.length;
511
- if (r !== e.length)
520
+ const n = t.length;
521
+ if (n !== e.length)
512
522
  return !1;
513
- for (let n = 0; n < r; n++)
514
- if (t[n] !== e[n])
523
+ for (let r = 0; r < n; r++)
524
+ if (t[r] !== e[r])
515
525
  return !1;
516
526
  return !0;
517
527
  }
518
528
  function Z(t) {
519
- return !t || typeof t != "object" ? t : Array.isArray(t) ? t.map(Z) : t && Object.keys(t).sort().reduce((e, r) => {
520
- const n = Z(t[r]);
521
- return n != null && (e[r] = n), e;
529
+ return !t || typeof t != "object" ? t : Array.isArray(t) ? t.map(Z) : t && Object.keys(t).sort().reduce((e, n) => {
530
+ const r = Z(t[n]);
531
+ return r != null && (e[n] = r), e;
522
532
  }, {});
523
533
  }
524
534
  function vt(t, e) {
@@ -526,7 +536,7 @@ function vt(t, e) {
526
536
  }
527
537
  function jt(t) {
528
538
  const e = alert;
529
- return window.alert = (r) => t(e, r), () => {
539
+ return window.alert = (n) => t(e, n), () => {
530
540
  window.alert = e;
531
541
  };
532
542
  }
@@ -546,10 +556,10 @@ const j = {
546
556
  trace: E(console.trace),
547
557
  assert: E(console.assert)
548
558
  };
549
- function Tt(t) {
559
+ function Ut(t) {
550
560
  return v.forEach((e) => {
551
- console[e] = (...r) => {
552
- t(j, e, r);
561
+ console[e] = (...n) => {
562
+ t(j, e, n);
553
563
  };
554
564
  }), () => {
555
565
  v.forEach((e) => {
@@ -558,18 +568,18 @@ function Tt(t) {
558
568
  };
559
569
  }
560
570
  function te(t) {
561
- return function(r) {
562
- const n = Tt(t);
571
+ return function(n) {
572
+ const r = Ut(t);
563
573
  try {
564
- const o = r();
574
+ const o = n();
565
575
  return X(o) ? o.then(
566
- (s) => (n(), s),
576
+ (s) => (r(), s),
567
577
  (s) => {
568
- throw n(), s;
578
+ throw r(), s;
569
579
  }
570
580
  ) : o;
571
581
  } finally {
572
- n();
582
+ r();
573
583
  }
574
584
  };
575
585
  }
@@ -584,21 +594,21 @@ function Et() {
584
594
  }
585
595
  function ee(t) {
586
596
  return function(...e) {
587
- const r = Et();
597
+ const n = Et();
588
598
  try {
589
599
  return t.apply(this, e);
590
- } catch (n) {
591
- throw n instanceof Error || (n = new Error(String(n))), n.stack = n.stack ? n.stack + `
592
- ` + r : r, n;
600
+ } catch (r) {
601
+ throw r instanceof Error || (r = new Error(String(r))), r.stack = r.stack ? r.stack + `
602
+ ` + n : n, r;
593
603
  }
594
604
  };
595
605
  }
596
606
  function Ct(t) {
597
607
  if (!t || t.timeout == null)
598
608
  return null;
599
- const e = new et(), r = t.timeController ?? ht;
609
+ const e = new et(), n = t.timeController ?? ht;
600
610
  if (t.timeout) {
601
- const n = r.setTimeout(() => {
611
+ const r = n.setTimeout(() => {
602
612
  e.abort(
603
613
  new ct(
604
614
  `[timeoutAbortController] Timeout error: ${t.timeout}ms`
@@ -606,22 +616,22 @@ function Ct(t) {
606
616
  );
607
617
  }, t.timeout);
608
618
  e.signal.subscribe(() => {
609
- clearTimeout(n);
619
+ clearTimeout(r);
610
620
  });
611
621
  }
612
- return t.abortSignal?.subscribe((n) => {
613
- e.abort(n);
622
+ return t.abortSignal?.subscribe((r) => {
623
+ e.abort(r);
614
624
  }), e;
615
625
  }
616
- async function re(t, e) {
617
- const r = Ct(e);
626
+ async function ne(t, e) {
627
+ const n = Ct(e);
618
628
  try {
619
- return await t(r?.signal ?? e?.abortSignal ?? null);
629
+ return await t(n?.signal ?? e?.abortSignal ?? null);
620
630
  } finally {
621
- r?.abort();
631
+ n?.abort();
622
632
  }
623
633
  }
624
- class ne {
634
+ class re {
625
635
  _options;
626
636
  _hasValue = !1;
627
637
  _promiseOrValue = null;
@@ -631,11 +641,11 @@ class ne {
631
641
  run() {
632
642
  if (!this._hasValue) {
633
643
  let e = this._options.func();
634
- const r = (o) => (this._options.persist ? this._promiseOrValue = o : (this._promiseOrValue = null, this._hasValue = !1), o), n = (o) => {
644
+ const n = (o) => (this._options.persist ? this._promiseOrValue = o : (this._promiseOrValue = null, this._hasValue = !1), o), r = (o) => {
635
645
  throw this._options.persist || (this._promiseOrValue = null, this._hasValue = !1), o;
636
646
  };
637
647
  if (X(e))
638
- e = e.then(r, n);
648
+ e = e.then(n, r);
639
649
  else if (!this._options.persist)
640
650
  return e;
641
651
  this._promiseOrValue = e, this._hasValue = !0;
@@ -657,22 +667,22 @@ class oe {
657
667
  run(e) {
658
668
  if (this._promiseOrValues.has(e))
659
669
  return this._promiseOrValues.get(e);
660
- let r = this._options.func(e);
661
- const n = (s) => (this._options.persist ? this._promiseOrValues.set(e, s) : this._promiseOrValues.delete(e), s), o = (s) => {
670
+ let n = this._options.func(e);
671
+ const r = (s) => (this._options.persist ? this._promiseOrValues.set(e, s) : this._promiseOrValues.delete(e), s), o = (s) => {
662
672
  throw this._options.persist || this._promiseOrValues.delete(e), s;
663
673
  };
664
- if (X(r))
665
- r = r.then(n, o);
674
+ if (X(n))
675
+ n = n.then(r, o);
666
676
  else if (!this._options.persist)
667
- return r;
668
- return this._promiseOrValues.set(e, r), r;
677
+ return n;
678
+ return this._promiseOrValues.set(e, n), n;
669
679
  }
670
- set(e, r) {
680
+ set(e, n) {
671
681
  if (!this._options.persist)
672
682
  throw new Error(
673
683
  "[LazyWithId][set] Cannot set value when persist is false"
674
684
  );
675
- this._promiseOrValues.set(e, r);
685
+ this._promiseOrValues.set(e, n);
676
686
  }
677
687
  }
678
688
  function tt(t) {
@@ -684,14 +694,14 @@ function Rt(t) {
684
694
  function It(t) {
685
695
  return t == null ? null : (t = t.toLowerCase().trim(), t === "true" || t === "1" || t === "yes" ? !0 : t === "false" || t === "0" || t === "no" ? !1 : null);
686
696
  }
687
- function kt(t) {
697
+ function xt(t) {
688
698
  if (t == null)
689
699
  return null;
690
700
  t = t.trim();
691
701
  const e = parseInt(t, 10);
692
702
  return isNaN(e) ? null : e;
693
703
  }
694
- function Nt(t) {
704
+ function kt(t) {
695
705
  if (t == null)
696
706
  return null;
697
707
  t = t.trim();
@@ -699,9 +709,9 @@ function Nt(t) {
699
709
  return isNaN(e) ? null : e;
700
710
  }
701
711
  function b(t, e) {
702
- const r = Rt(e), n = tt(t);
703
- for (const [o, s] of r.entries())
704
- if (tt(o) === n)
712
+ const n = Rt(e), r = tt(t);
713
+ for (const [o, s] of n.entries())
714
+ if (tt(o) === r)
705
715
  return s;
706
716
  return null;
707
717
  }
@@ -709,10 +719,10 @@ function se(t, e) {
709
719
  return It(b(t, e));
710
720
  }
711
721
  function ie(t, e) {
712
- return kt(b(t, e));
722
+ return xt(b(t, e));
713
723
  }
714
724
  function ue(t, e) {
715
- return Nt(b(t, e));
725
+ return kt(b(t, e));
716
726
  }
717
727
  export {
718
728
  Q as A,
@@ -723,28 +733,28 @@ export {
723
733
  vt as F,
724
734
  jt as G,
725
735
  lt as H,
726
- Tt as I,
736
+ Ut as I,
727
737
  te as J,
728
738
  ee as K,
729
739
  Et as L,
730
740
  Ct as M,
731
- re as N,
732
- ne as O,
741
+ ne as N,
742
+ re as O,
733
743
  oe as P,
734
744
  Rt as Q,
735
745
  Y as R,
736
746
  It as S,
737
- kt as T,
747
+ xt as T,
738
748
  W as U,
739
- Nt as V,
749
+ kt as V,
740
750
  b as W,
741
751
  se as X,
742
752
  ie as Y,
743
753
  ue as Z,
744
- Vt as a,
745
- gt as b,
746
- Lt as c,
747
- Ot as d,
754
+ Lt as a,
755
+ wt as b,
756
+ Vt as c,
757
+ _t as d,
748
758
  $t as e,
749
759
  Ft as f,
750
760
  zt as g,
@@ -753,18 +763,18 @@ export {
753
763
  Ht as j,
754
764
  Wt as k,
755
765
  Gt as l,
756
- wt as m,
766
+ yt as m,
757
767
  Bt as n,
758
768
  Jt as o,
759
769
  Yt as p,
760
770
  ut as q,
761
771
  ot as r,
762
- yt as s,
772
+ dt as s,
763
773
  pt as t,
764
- x as u,
774
+ M as u,
765
775
  At as v,
766
776
  Xt as w,
767
- L as x,
777
+ V as x,
768
778
  bt as y,
769
779
  Kt as z
770
780
  };
@@ -0,0 +1,11 @@
1
+ "use strict";const z=require("@flemist/abort-controller-fast"),K=require("@flemist/async-utils"),Ut=require("@flemist/time-controller");let q=null;function At(){if(!q){q=new Array(256);for(let t=0;t<256;t++)q[t]=t.toString(16).padStart(2,"0")}return q}function st(t){const e=At(),n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let r="";for(let o=0,i=n.length;o<i;o++)r+=e[n[o]];return r}let Y=null,ut=null,B=null,lt=null;function Et(){Y||(Y=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ut=new Uint32Array(64),lt=new TextEncoder,B=new Uint8Array(65536))}function at(t){if(t==null)return null;Et();const e=Y,n=ut,r=lt;let o=B,i;if(typeof t=="string"){const h=t.length*3;o.length<h+128&&(o=B=new Uint8Array(h+128));const f=r.encodeInto(t,o);i=o.subarray(0,f.written)}else if(t instanceof Uint8Array)i=t;else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else throw new Error(`[sha256Buffer] Unsupported content type: ${typeof t}`);const c=i.length,a=c+72>>>6<<6;o.length<a&&(o=B=new Uint8Array(a)),i!==o&&o.set(i),o[c]=128;for(let h=c+1;h<a;h++)o[h]=0;const U=c*8,_=U/4294967296|0,C=U|0;o[a-8]=_>>>24,o[a-7]=_>>>16,o[a-6]=_>>>8,o[a-5]=_,o[a-4]=C>>>24,o[a-3]=C>>>16,o[a-2]=C>>>8,o[a-1]=C;let A=1779033703,T=-1150833019,u=1013904242,s=-1521486534,l=1359893119,g=-1694144372,d=528734635,y=1541459225;for(let h=0;h<a;h+=64){for(let m=0;m<16;m++){const p=h+(m<<2);n[m]=o[p]<<24|o[p+1]<<16|o[p+2]<<8|o[p+3]}for(let m=16;m<64;m++){const p=n[m-15],$=n[m-2],b=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,F=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;n[m]=n[m-16]+b+n[m-7]+F|0}let f=A,S=T,L=u,W=s,O=l,D=g,x=d,J=y;for(let m=0;m<64;m+=4)for(let p=0;p<4;p++){const $=m+p,b=(O>>>6|O<<26)^(O>>>11|O<<21)^(O>>>25|O<<7),F=J+b+(x^O&(D^x))+e[$]+n[$]|0,$t=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&S^L&(f^S))|0;J=x,x=D,D=O,O=W+F|0,W=L,L=S,S=f,f=F+$t|0}A=A+f|0,T=T+S|0,u=u+L|0,s=s+W|0,l=l+O|0,g=g+D|0,d=d+x|0,y=y+J|0}const w=new Uint8Array(32),R=[A,T,u,s,l,g,d,y];for(let h=0;h<8;h++){const f=R[h],S=h<<2;w[S]=f>>>24,w[S+1]=f>>>16&255,w[S+2]=f>>>8&255,w[S+3]=f&255}return w}function Ct(t){const e=at(t);return e?st(e):null}function ct(t,e){return t==null?e:e==null?t:Math.min(t,e)}function ft(t,e){return t==null?e:e==null?t:Math.max(t,e)}function Rt(t,e,n){return ft(ct(t,e),n)}function It(t,e){return(t%e+e)%e}function kt(t){return function(){let n=t+=1831565813;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),(n^n>>>14)/4294967296+.5}}function xt(){return Math.random()}function Nt(){return Math.random()*2**32>>>0}function ht(t){return t!=null?kt(t):xt}class G{_seed;_rnd;constructor(e){this._seed=e,this._rnd=ht(e)}get seed(){return this._seed}nextSeed(){return this.next()*2**32>>>0}nextRandom(){return new G(this.nextSeed())}next(){return this._rnd()}clone(){return new G(this._seed)}}function v(t,e,n){if(n==null&&(n=e,e=0),n<=e)throw new Error(`[random][randomFloat] toExclusive (${n}) must be greater than from (${e})`);return t.next()*(n-e)+e}function mt(t,e,n){return Math.floor(v(t,e,n))}function Mt(t,e){return t.next()<(e??.5)}function Pt(t,e,n){if(Array.isArray(e)){const i=e;e=i.length,n=c=>i[c]}if(!n)throw new Error("[random][randomIndexWeighted] getWeight is required");let r=0;for(let i=0;i<e;i++)r+=n(i);if(r===0)return-1;let o=v(t,r);for(let i=0;i<e;i++)if(o-=n(i),o<0)return i;return e-1}function j(t,e){if(e.length===0)throw new Error("[random][randomItem] items is empty");const n=mt(t,e.length);return e[n]}function Lt(t,e,n){if(e.length===0)throw new Error("[random][randomItems] items is empty");const r=[];for(let o=0;o<n;o++)r.push(j(t,e));return r}function Dt(t,e,n){let r=Object.values(e);return n&&(r=r.filter(n)),j(t,r)}const dt=1073741789,V=(dt>>2)-1;function Ft(t=V,e){if(t<=0)throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);if(t>V)throw new Error(`[random][PseudoRandom] count(${t}) must be <= ${V}`);if(e==null&&(e=Math.floor(Math.random()*t)),e>=t)throw new Error(`[random][PseudoRandom] startFrom(${e}) must be < count(${t})`);let n=e;return function(){return n=(n+dt)%t,n}}let N=null;function qt(){const t=Date.now();return N==null||t>N?(N=t,t):(N++,N)}async function Bt({url:t,timeout:e}={}){t||(t=typeof window<"u"?"/":"https://google.com");let n;try{const r=new z.AbortControllerFast;n=e?setTimeout(()=>{r.abort()},e):null;const o=await fetch(t,{method:"HEAD",signal:z.toAbortSignal(r.signal)}),i=o.headers.get("date");if(!i)throw new Error(`[Now][getDateInet] No date header in response: ${o.status} ${t}`);return new Date(i).getTime()}finally{n&&clearTimeout(n)}}function tt(t,e,n){const r=e==null?t:new Date(t.toLocaleString("en-US",{timeZone:e})),o=n==null?t:new Date(t.toLocaleString("en-US",{timeZone:n}));return new Date(t.getTime()+o.getTime()-r.getTime())}function pt(t,e){t=tt(t,"UTC",e);const n=t.getUTCFullYear().toString().padStart(4,"0"),r=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${n}-${r}-${o} ${i}:${c}:${a}`}let Vt=0;const X=new WeakMap;function I(t){if(X.has(t))return X.get(t);const e=Vt++;return X.set(t,e),e}function M(t,e,n){if(t==null)return null;if(e==null||t.length<=e)return t;const r=n?.appendEllipsis?"…":"",o=r.length+(n?.appendTruncatedLength?String(t.length).length+2:0),i=Math.max(0,e-o),c=n?.appendTruncatedLength?`(${t.length-i})`:"";return i<=0?c+r:n?.fromStart?c+r+t.slice(t.length-i):t.slice(0,i)+r+c}function nt(t,e){try{return t[e]}catch(n){return"Error: "+(n instanceof Error?n.message:String(n))}}function k(t,e,n,r){const{pretty:o,filter:i,maxDepth:c,maxItems:a,maxStringLength:U,showObjectId:_,showArrayIndex:C,customToString:A}=e??{};if(n==null&&(n=[]),r==null&&(r=new Set),A){const u=A(t,n,s=>k(s,e,n,r));if(u!=null)return M(u,U,e?.truncateOptions)}const T=n.length;if(typeof t=="string")return t=M(t,U,e?.truncateOptions),r.size>0&&(t=JSON.stringify(t)),t;if(t==null||typeof t!="object")return String(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return`${t.constructor?.name??""}#${I(t)}[${t.byteLength}]`;if(t instanceof RegExp)return M(String(t),U,e?.truncateOptions);if(t instanceof Date)return pt(t);if(t instanceof Object){if(r.has(t)||c!=null&&T>=c)return`${t.constructor===Object?"":t.constructor?.name??""}#${I(t)}`;r.add(t)}if(t instanceof Error)return M(t.stack||t.message||String(t),U,e?.truncateOptions);if(Array.isArray(t)){const u=o?" ".repeat(T):"";let s="";_&&(s+=`#${I(t)} `),s+="[";let l=0,g=!1;for(let d=0;d<t.length;d++){if(a!=null&&l>=a){g=!0;break}const y=[...n,String(d)],w=nt(t,d);if(i!=null&&!i(y,w))continue;const R=k(w,e,y,r);l>0&&(s+=","),o&&(s+=`
2
+ `),o&&(s+=`${u} `),C&&(s+=`${d}: `),s+=`${R}`,l++}return g?(l>0&&(s+=","),o?(s+=`
3
+ `,s+=`${u} ...
4
+ `):s+="...",s+=u,s+="]"):(l>0&&o&&(s+=`
5
+ ${u}`),s+="]"),s}if(t instanceof Map){let u="";return _&&(u+=`#${I(t)} `),u+="Map",u+=k(Array.from(t.entries()),e,n,r),u}if(t instanceof Set){let u="";return _&&(u+=`#${I(t)} `),u+="Set",u+=k(Array.from(t.values()),e,n,r),u}{const u=t.constructor===Object?"":t.constructor?.name??"",s=o?" ".repeat(T):"";let l=u?`${u} `:"";_&&(l+=`#${I(t)} `),l+="{";let g=0,d=!1;for(const y in t){if(a!=null&&g>=a){d=!0;break}const w=[...n,y],R=nt(t,y);if(i!=null&&!i(w,R))continue;const h=k(R,e,w,r);g>0&&(l+=","),o&&(l+=`
6
+ `),o&&(l+=`${s} `),l+=`${y}: ${h}`,g++}return d&&(g>0&&(l+=","),o?(l+=`
7
+ `,l+=`${s} ...
8
+ `):l+="...",l+=s),g>0&&o&&!d&&(l+=`
9
+ ${s}`),l+="}",l}}function zt(t,e){t=tt(t,"UTC",e);const n=t.getUTCFullYear().toString().padStart(4,"0"),r=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${n}-${r}-${o}_${i}-${c}-${a}`}function Gt(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&amp;";case"<":return"&lt;";case">":return"&rt;";case'"':return"&quot;";default:return"&#039;"}})}function Ht(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function Q(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,n=[];for(let r=0;r<e;r++)n.push(Q(t[r]));return n}if(typeof t=="object"){if(t.constructor&&t.constructor!==Object)return t;const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=Q(t[n]));return e}return t}function P(t,e){if(t===e)return!0;if(t==null)return e==null;if(e==null)return!1;if(Array.isArray(t)){if(!Array.isArray(e))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(!P(t[r],e[r]))return!1;return!0}if(typeof t=="object"){if(typeof e!="object"||t.constructor&&t.constructor!==Object||e.constructor&&e.constructor!==Object)return!1;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&!P(t[n],Object.prototype.hasOwnProperty.call(e,n)?e[n]:null))return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&!Object.prototype.hasOwnProperty.call(t,n)&&!P(e[n],null))return!1;return!0}return!1}function Wt(t,e){if(t==null||e==null)return t==null==(e==null);if(t.size!==e.size)return!1;for(const[n,r]of t)if(!P(r,e.get(n)))return!1;return!0}function Jt(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function Z(t){return!t||typeof t!="object"?t:Array.isArray(t)?t.map(Z):t&&Object.keys(t).sort().reduce((e,n)=>{const r=Z(t[n]);return r!=null&&(e[n]=r),e},{})}function bt(t,e){return Object.defineProperty(t,"name",{value:e,configurable:!0}),t}function Xt(t){const e=alert;return window.alert=n=>t(e,n),()=>{window.alert=e}}var et=(t=>(t.log="log",t.warn="warn",t.error="error",t.info="info",t.debug="debug",t.trace="trace",t.assert="assert",t))(et||{});const rt=Object.values(et);function E(t){return function(){t.apply(console,arguments)}}const ot={log:E(console.log),warn:E(console.warn),error:E(console.error),info:E(console.info),debug:E(console.debug),trace:E(console.trace),assert:E(console.assert)};function gt(t){return rt.forEach(e=>{console[e]=(...n)=>{t(ot,e,n)}}),()=>{rt.forEach(e=>{console[e]=ot[e]})}}function Yt(t){return function(n){const r=gt(t);try{const o=n();return K.isPromiseLike(o)?o.then(i=>(r(),i),i=>{throw r(),i}):o}finally{r()}}}function yt(){let t=new Error().stack;if(t!=null){const e=t.indexOf(`
10
+ `);e!=null&&e>=0&&(t=t.substring(e+1))}return t??""}function Qt(t){return function(...e){const n=yt();try{return t.apply(this,e)}catch(r){throw r instanceof Error||(r=new Error(String(r))),r.stack=r.stack?r.stack+`
11
+ `+n:n,r}}}function wt(t){if(!t||t.timeout==null)return null;const e=new z.AbortControllerFast,n=t.timeController??Ut.timeControllerDefault;if(t.timeout){const r=n.setTimeout(()=>{e.abort(new z.AbortError(`[timeoutAbortController] Timeout error: ${t.timeout}ms`))},t.timeout);e.signal.subscribe(()=>{clearTimeout(r)})}return t.abortSignal?.subscribe(r=>{e.abort(r)}),e}async function Zt(t,e){const n=wt(e);try{return await t(n?.signal??e?.abortSignal??null)}finally{n?.abort()}}class Kt{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const n=o=>(this._options.persist?this._promiseOrValue=o:(this._promiseOrValue=null,this._hasValue=!1),o),r=o=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),o};if(K.isPromiseLike(e))e=e.then(n,r);else if(!this._options.persist)return e;this._promiseOrValue=e,this._hasValue=!0}return this._promiseOrValue}set(e){if(!this._options.persist)throw new Error("[Lazy][set] Cannot set value when persist is false");this._hasValue=!0,this._promiseOrValue=e}}class vt{_options;_promiseOrValues=new Map;constructor(e){this._options=e}run(e){if(this._promiseOrValues.has(e))return this._promiseOrValues.get(e);let n=this._options.func(e);const r=i=>(this._options.persist?this._promiseOrValues.set(e,i):this._promiseOrValues.delete(e),i),o=i=>{throw this._options.persist||this._promiseOrValues.delete(e),i};if(K.isPromiseLike(n))n=n.then(r,o);else if(!this._options.persist)return n;return this._promiseOrValues.set(e,n),n}set(e,n){if(!this._options.persist)throw new Error("[LazyWithId][set] Cannot set value when persist is false");this._promiseOrValues.set(e,n)}}function it(t){return t.replace(/\W/g,"").toLowerCase()}function St(t){return t instanceof URL?t.searchParams:t instanceof URLSearchParams?t:typeof t=="string"?new URL(t).searchParams:typeof window<"u"?new URL(window.location.href).searchParams:new URLSearchParams}function Ot(t){return t==null?null:(t=t.toLowerCase().trim(),t==="true"||t==="1"||t==="yes"?!0:t==="false"||t==="0"||t==="no"?!1:null)}function _t(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function Tt(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function H(t,e){const n=St(e),r=it(t);for(const[o,i]of n.entries())if(it(o)===r)return i;return null}function jt(t,e){return Ot(H(t,e))}function te(t,e){return _t(H(t,e))}function ee(t,e){return Tt(H(t,e))}exports.ConsoleMessageLevel=et;exports.Lazy=Kt;exports.LazyWithId=vt;exports.Random=G;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=V;exports.alertReplace=Xt;exports.consoleReplace=gt;exports.convertTimeZone=tt;exports.createUniquePseudoRandom=Ft;exports.dateNowUnique=qt;exports.deepCloneJsonLike=Q;exports.deepEqualJsonLike=P;exports.deepEqualJsonLikeMap=Wt;exports.equalArray=Jt;exports.escapeHtml=Gt;exports.escapeRegExp=Ht;exports.fixStackTrace=Qt;exports.formatAny=k;exports.formatDate=pt;exports.formatDateFileName=zt;exports.getDateInet=Bt;exports.getNormalizedObject=Z;exports.getRandomFunc=ht;exports.getRandomSeed=Nt;exports.getStackTrace=yt;exports.max=ft;exports.min=ct;exports.minMax=Rt;exports.numberMod=It;exports.randomBoolean=Mt;exports.randomEnum=Dt;exports.randomFloat=v;exports.randomIndexWeighted=Pt;exports.randomInt=mt;exports.randomItem=j;exports.randomItems=Lt;exports.setFuncName=bt;exports.sha256=Ct;exports.sha256Buffer=at;exports.timeoutAbortController=wt;exports.toHex=st;exports.truncateString=M;exports.urlGetBoolean=jt;exports.urlGetFloat=ee;exports.urlGetInt=te;exports.urlGetParams=St;exports.urlGetString=H;exports.urlParamToBoolean=Ot;exports.urlParamToFloat=Tt;exports.urlParamToInt=_t;exports.withConsoleReplace=Yt;exports.withTimeout=Zt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemist/simple-utils",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Simple simple utils",
5
5
  "sideEffects": false,
6
6
  "types": "build/common/index.d.ts",
@@ -1,11 +0,0 @@
1
- "use strict";const z=require("@flemist/abort-controller-fast"),K=require("@flemist/async-utils"),At=require("@flemist/time-controller");let q=null;function Tt(){if(!q){q=new Array(256);for(let t=0;t<256;t++)q[t]=t.toString(16).padStart(2,"0")}return q}function st(t){const e=Tt(),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let n="";for(let o=0,i=r.length;o<i;o++)n+=e[r[o]];return n}let Y=null,ut=null,B=null,lt=null;function Et(){Y||(Y=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ut=new Uint32Array(64),lt=new TextEncoder,B=new Uint8Array(65536))}function at(t){if(t==null)return null;Et();const e=Y,r=ut,n=lt;let o=B,i;if(typeof t=="string"){const f=t.length*3;o.length<f+128&&(o=B=new Uint8Array(f+128));const c=n.encodeInto(t,o);i=o.subarray(0,c.written)}else if(t instanceof Uint8Array)i=t;else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else throw new Error(`[sha256Buffer] Unsupported content type: ${typeof t}`);const m=i.length,a=m+72>>>6<<6;o.length<a&&(o=B=new Uint8Array(a)),i!==o&&o.set(i),o[m]=128;for(let f=m+1;f<a;f++)o[f]=0;const A=m*8,O=A/4294967296|0,C=A|0;o[a-8]=O>>>24,o[a-7]=O>>>16,o[a-6]=O>>>8,o[a-5]=O,o[a-4]=C>>>24,o[a-3]=C>>>16,o[a-2]=C>>>8,o[a-1]=C;let T=1779033703,U=-1150833019,u=1013904242,s=-1521486534,l=1359893119,g=-1694144372,d=528734635,y=1541459225;for(let f=0;f<a;f+=64){for(let h=0;h<16;h++){const p=f+(h<<2);r[h]=o[p]<<24|o[p+1]<<16|o[p+2]<<8|o[p+3]}for(let h=16;h<64;h++){const p=r[h-15],$=r[h-2],b=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,F=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;r[h]=r[h-16]+b+r[h-7]+F|0}let c=T,S=U,D=u,W=s,_=l,L=g,N=d,J=y;for(let h=0;h<64;h+=4)for(let p=0;p<4;p++){const $=h+p,b=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),F=J+b+(N^_&(L^N))+e[$]+r[$]|0,$t=((c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10))+(c&S^D&(c^S))|0;J=N,N=L,L=_,_=W+F|0,W=D,D=S,S=c,c=F+$t|0}T=T+c|0,U=U+S|0,u=u+D|0,s=s+W|0,l=l+_|0,g=g+L|0,d=d+N|0,y=y+J|0}const w=new Uint8Array(32),R=[T,U,u,s,l,g,d,y];for(let f=0;f<8;f++){const c=R[f],S=f<<2;w[S]=c>>>24,w[S+1]=c>>>16&255,w[S+2]=c>>>8&255,w[S+3]=c&255}return w}function Ct(t){const e=at(t);return e?st(e):null}function ct(t,e){return t==null?e:e==null?t:Math.min(t,e)}function ft(t,e){return t==null?e:e==null?t:Math.max(t,e)}function Rt(t,e,r){return ft(ct(t,e),r)}function It(t,e){return(t%e+e)%e}function kt(t){return function(){let r=t+=1831565813;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),(r^r>>>14)/4294967296+.5}}function Nt(){return Math.random()}function Pt(){return Math.random()*2**32>>>0}function ht(t){return t!=null?kt(t):Nt}class G{_seed;_rnd;constructor(e){this._seed=e,this._rnd=ht(e)}get seed(){return this._seed}nextSeed(){return this.next()*2**32>>>0}nextRandom(){return new G(this.nextSeed())}next(){return this._rnd()}clone(){return new G(this._seed)}}function v(t,e,r){if(r==null&&(r=e,e=0),r<=e)throw new Error(`[random][randomFloat] toExclusive (${r}) must be greater than from (${e})`);return t.next()*(r-e)+e}function mt(t,e,r){return Math.floor(v(t,e,r))}function Mt(t,e){return t.next()<(e??.5)}function xt(t,e,r){if(Array.isArray(e)){const i=e;e=i.length,r=m=>i[m]}if(!r)throw new Error("[random][randomIndexWeighted] getWeight is required");let n=0;for(let i=0;i<e;i++)n+=r(i);if(n===0)return-1;let o=v(t,n);for(let i=0;i<e;i++)if(o-=r(i),o<0)return i;return e-1}function j(t,e){if(e.length===0)throw new Error("[random][randomItem] items is empty");const r=mt(t,e.length);return e[r]}function Dt(t,e,r){if(e.length===0)throw new Error("[random][randomItems] items is empty");const n=[];for(let o=0;o<r;o++)n.push(j(t,e));return n}function Lt(t,e,r){let n=Object.values(e);return r&&(n=n.filter(r)),j(t,n)}const dt=1073741789,V=(dt>>2)-1;function Ft(t=V,e){if(t<=0)throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);if(t>V)throw new Error(`[random][PseudoRandom] count(${t}) must be <= ${V}`);if(e==null&&(e=Math.floor(Math.random()*t)),e>=t)throw new Error(`[random][PseudoRandom] startFrom(${e}) must be < count(${t})`);let r=e;return function(){return r=(r+dt)%t,r}}let P=null;function qt(){const t=Date.now();return P==null||t>P?(P=t,t):(P++,P)}async function Bt({url:t,timeout:e}={}){t||(t=typeof window<"u"?"/":"https://google.com");let r;try{const n=new z.AbortControllerFast;r=e?setTimeout(()=>{n.abort()},e):null;const o=await fetch(t,{method:"HEAD",signal:z.toAbortSignal(n.signal)}),i=o.headers.get("date");if(!i)throw new Error(`[Now][getDateInet] No date header in response: ${o.status} ${t}`);return new Date(i).getTime()}finally{r&&clearTimeout(r)}}function tt(t,e,r){const n=e==null?t:new Date(t.toLocaleString("en-US",{timeZone:e})),o=r==null?t:new Date(t.toLocaleString("en-US",{timeZone:r}));return new Date(t.getTime()+o.getTime()-n.getTime())}function pt(t,e){t=tt(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),m=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o} ${i}:${m}:${a}`}let Vt=0;const X=new WeakMap;function I(t){if(X.has(t))return X.get(t);const e=Vt++;return X.set(t,e),e}function M(t,e,r){return t==null?t??null:e==null?t:t.length>e?e<=0?"…":r?.fromStart?"…"+t.slice(t.length-e+1):t.slice(0,e-1)+"…":t}function rt(t,e){try{return t[e]}catch(r){return"Error: "+(r instanceof Error?r.message:String(r))}}function k(t,e,r,n){const{pretty:o,filter:i,maxDepth:m,maxItems:a,maxStringLength:A,showObjectId:O,showArrayIndex:C,customToString:T}=e??{};if(r==null&&(r=[]),n==null&&(n=new Set),T){const u=T(t,r,s=>k(s,e,r,n));if(u!=null)return M(u,A)}const U=r.length;if(typeof t=="string")return t=M(t,A),n.size>0&&(t=JSON.stringify(t)),t;if(t==null||typeof t!="object")return String(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return`${t.constructor?.name??""}#${I(t)}[${t.byteLength}]`;if(t instanceof RegExp)return M(String(t),A);if(t instanceof Date)return pt(t);if(t instanceof Object){if(n.has(t)||m!=null&&U>=m)return`${t.constructor===Object?"":t.constructor?.name??""}#${I(t)}`;n.add(t)}if(t instanceof Error)return M(t.stack||t.message||String(t),A);if(Array.isArray(t)){const u=o?" ".repeat(U):"";let s="";O&&(s+=`#${I(t)} `),s+="[";let l=0,g=!1;for(let d=0;d<t.length;d++){if(a!=null&&l>=a){g=!0;break}const y=[...r,String(d)],w=rt(t,d);if(i!=null&&!i(y,w))continue;const R=k(w,e,y,n);l>0&&(s+=","),o&&(s+=`
2
- `),o&&(s+=`${u} `),C&&(s+=`${d}: `),s+=`${R}`,l++}return g?(l>0&&(s+=","),o?(s+=`
3
- `,s+=`${u} ...
4
- `):s+="...",s+=u,s+="]"):(l>0&&o&&(s+=`
5
- ${u}`),s+="]"),s}if(t instanceof Map){let u="";return O&&(u+=`#${I(t)} `),u+="Map",u+=k(Array.from(t.entries()),e,r,n),u}if(t instanceof Set){let u="";return O&&(u+=`#${I(t)} `),u+="Set",u+=k(Array.from(t.values()),e,r,n),u}{const u=t.constructor===Object?"":t.constructor?.name??"",s=o?" ".repeat(U):"";let l=u?`${u} `:"";O&&(l+=`#${I(t)} `),l+="{";let g=0,d=!1;for(const y in t){if(a!=null&&g>=a){d=!0;break}const w=[...r,y],R=rt(t,y);if(i!=null&&!i(w,R))continue;const f=k(R,e,w,n);g>0&&(l+=","),o&&(l+=`
6
- `),o&&(l+=`${s} `),l+=`${y}: ${f}`,g++}return d&&(g>0&&(l+=","),o?(l+=`
7
- `,l+=`${s} ...
8
- `):l+="...",l+=s),g>0&&o&&!d&&(l+=`
9
- ${s}`),l+="}",l}}function zt(t,e){t=tt(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),m=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o}_${i}-${m}-${a}`}function Gt(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&amp;";case"<":return"&lt;";case">":return"&rt;";case'"':return"&quot;";default:return"&#039;"}})}function Ht(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function Q(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,r=[];for(let n=0;n<e;n++)r.push(Q(t[n]));return r}if(typeof t=="object"){if(t.constructor&&t.constructor!==Object)return t;const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Q(t[r]));return e}return t}function x(t,e){if(t===e)return!0;if(t==null)return e==null;if(e==null)return!1;if(Array.isArray(t)){if(!Array.isArray(e))return!1;const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(!x(t[n],e[n]))return!1;return!0}if(typeof t=="object"){if(typeof e!="object"||t.constructor&&t.constructor!==Object||e.constructor&&e.constructor!==Object)return!1;for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!x(t[r],Object.prototype.hasOwnProperty.call(e,r)?e[r]:null))return!1;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(t,r)&&!x(e[r],null))return!1;return!0}return!1}function Wt(t,e){if(t==null||e==null)return t==null==(e==null);if(t.size!==e.size)return!1;for(const[r,n]of t)if(!x(n,e.get(r)))return!1;return!0}function Jt(t,e){const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Z(t){return!t||typeof t!="object"?t:Array.isArray(t)?t.map(Z):t&&Object.keys(t).sort().reduce((e,r)=>{const n=Z(t[r]);return n!=null&&(e[r]=n),e},{})}function bt(t,e){return Object.defineProperty(t,"name",{value:e,configurable:!0}),t}function Xt(t){const e=alert;return window.alert=r=>t(e,r),()=>{window.alert=e}}var et=(t=>(t.log="log",t.warn="warn",t.error="error",t.info="info",t.debug="debug",t.trace="trace",t.assert="assert",t))(et||{});const nt=Object.values(et);function E(t){return function(){t.apply(console,arguments)}}const ot={log:E(console.log),warn:E(console.warn),error:E(console.error),info:E(console.info),debug:E(console.debug),trace:E(console.trace),assert:E(console.assert)};function gt(t){return nt.forEach(e=>{console[e]=(...r)=>{t(ot,e,r)}}),()=>{nt.forEach(e=>{console[e]=ot[e]})}}function Yt(t){return function(r){const n=gt(t);try{const o=r();return K.isPromiseLike(o)?o.then(i=>(n(),i),i=>{throw n(),i}):o}finally{n()}}}function yt(){let t=new Error().stack;if(t!=null){const e=t.indexOf(`
10
- `);e!=null&&e>=0&&(t=t.substring(e+1))}return t??""}function Qt(t){return function(...e){const r=yt();try{return t.apply(this,e)}catch(n){throw n instanceof Error||(n=new Error(String(n))),n.stack=n.stack?n.stack+`
11
- `+r:r,n}}}function wt(t){if(!t||t.timeout==null)return null;const e=new z.AbortControllerFast,r=t.timeController??At.timeControllerDefault;if(t.timeout){const n=r.setTimeout(()=>{e.abort(new z.AbortError(`[timeoutAbortController] Timeout error: ${t.timeout}ms`))},t.timeout);e.signal.subscribe(()=>{clearTimeout(n)})}return t.abortSignal?.subscribe(n=>{e.abort(n)}),e}async function Zt(t,e){const r=wt(e);try{return await t(r?.signal??e?.abortSignal??null)}finally{r?.abort()}}class Kt{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const r=o=>(this._options.persist?this._promiseOrValue=o:(this._promiseOrValue=null,this._hasValue=!1),o),n=o=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),o};if(K.isPromiseLike(e))e=e.then(r,n);else if(!this._options.persist)return e;this._promiseOrValue=e,this._hasValue=!0}return this._promiseOrValue}set(e){if(!this._options.persist)throw new Error("[Lazy][set] Cannot set value when persist is false");this._hasValue=!0,this._promiseOrValue=e}}class vt{_options;_promiseOrValues=new Map;constructor(e){this._options=e}run(e){if(this._promiseOrValues.has(e))return this._promiseOrValues.get(e);let r=this._options.func(e);const n=i=>(this._options.persist?this._promiseOrValues.set(e,i):this._promiseOrValues.delete(e),i),o=i=>{throw this._options.persist||this._promiseOrValues.delete(e),i};if(K.isPromiseLike(r))r=r.then(n,o);else if(!this._options.persist)return r;return this._promiseOrValues.set(e,r),r}set(e,r){if(!this._options.persist)throw new Error("[LazyWithId][set] Cannot set value when persist is false");this._promiseOrValues.set(e,r)}}function it(t){return t.replace(/\W/g,"").toLowerCase()}function St(t){return t instanceof URL?t.searchParams:t instanceof URLSearchParams?t:typeof t=="string"?new URL(t).searchParams:typeof window<"u"?new URL(window.location.href).searchParams:new URLSearchParams}function _t(t){return t==null?null:(t=t.toLowerCase().trim(),t==="true"||t==="1"||t==="yes"?!0:t==="false"||t==="0"||t==="no"?!1:null)}function Ot(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function Ut(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function H(t,e){const r=St(e),n=it(t);for(const[o,i]of r.entries())if(it(o)===n)return i;return null}function jt(t,e){return _t(H(t,e))}function te(t,e){return Ot(H(t,e))}function ee(t,e){return Ut(H(t,e))}exports.ConsoleMessageLevel=et;exports.Lazy=Kt;exports.LazyWithId=vt;exports.Random=G;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=V;exports.alertReplace=Xt;exports.consoleReplace=gt;exports.convertTimeZone=tt;exports.createUniquePseudoRandom=Ft;exports.dateNowUnique=qt;exports.deepCloneJsonLike=Q;exports.deepEqualJsonLike=x;exports.deepEqualJsonLikeMap=Wt;exports.equalArray=Jt;exports.escapeHtml=Gt;exports.escapeRegExp=Ht;exports.fixStackTrace=Qt;exports.formatAny=k;exports.formatDate=pt;exports.formatDateFileName=zt;exports.getDateInet=Bt;exports.getNormalizedObject=Z;exports.getRandomFunc=ht;exports.getRandomSeed=Pt;exports.getStackTrace=yt;exports.max=ft;exports.min=ct;exports.minMax=Rt;exports.numberMod=It;exports.randomBoolean=Mt;exports.randomEnum=Lt;exports.randomFloat=v;exports.randomIndexWeighted=xt;exports.randomInt=mt;exports.randomItem=j;exports.randomItems=Dt;exports.setFuncName=bt;exports.sha256=Ct;exports.sha256Buffer=at;exports.timeoutAbortController=wt;exports.toHex=st;exports.truncateString=M;exports.urlGetBoolean=jt;exports.urlGetFloat=ee;exports.urlGetInt=te;exports.urlGetParams=St;exports.urlGetString=H;exports.urlParamToBoolean=_t;exports.urlParamToFloat=Ut;exports.urlParamToInt=Ot;exports.withConsoleReplace=Yt;exports.withTimeout=Zt;