@flemist/simple-utils 2.1.5 → 2.1.7
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/build/browser/index.cjs +1 -1
- package/build/browser/index.mjs +178 -146
- package/build/common/async/Locker.d.ts +28 -0
- package/build/common/async/index.d.ts +2 -0
- package/build/common/async/promise.d.ts +7 -0
- package/build/common/cache/Cache.d.ts +46 -0
- package/build/common/cache/CacheStats.d.ts +20 -0
- package/build/common/cache/MemoryStorage.d.ts +11 -0
- package/build/common/cache/getHashKey.d.ts +1 -0
- package/build/common/cache/getJsonKey.d.ts +1 -0
- package/build/common/cache/index.d.ts +6 -0
- package/build/common/cache/types.d.ts +28 -0
- package/build/common/converter/converterBufferToGzip.d.ts +4 -0
- package/build/common/converter/converterErrorToBuffer.d.ts +2 -0
- package/build/common/converter/converterErrorToGzip.d.ts +4 -0
- package/build/common/converter/converterJson.d.ts +2 -0
- package/build/common/converter/converterJsonBuffer.d.ts +2 -0
- package/build/common/converter/converterJsonGzip.d.ts +4 -0
- package/build/common/converter/converterStringToBuffer.d.ts +2 -0
- package/build/common/converter/helpers.d.ts +13 -0
- package/build/common/converter/index.d.ts +11 -0
- package/build/common/converter/mapObjectConverter.d.ts +2 -0
- package/build/common/converter/setArrayConverter.d.ts +2 -0
- package/build/common/converter/types.d.ts +41 -0
- package/build/common/gzip/compressGzip.d.ts +35 -0
- package/build/common/gzip/decompressGzip.d.ts +2 -0
- package/build/common/gzip/index.d.ts +2 -0
- package/build/common/index.cjs +1 -1
- package/build/common/index.d.ts +3 -0
- package/build/common/index.mjs +178 -146
- package/build/common/string/index.d.ts +1 -1
- package/build/node/cache/FileStatStorage.d.ts +23 -0
- package/build/node/cache/FileStorage.d.ts +29 -0
- package/build/node/cache/createConverterSubPath.d.ts +12 -0
- package/build/node/cache/createFileCacheOptions.d.ts +17 -0
- package/build/node/cache/generateTempFileName.d.ts +1 -0
- package/build/node/cache/index.d.ts +6 -0
- package/build/node/cache/writeFileThroughTmp.d.ts +2 -0
- package/build/node/fs/index.d.ts +1 -0
- package/build/node/fs/readDirRecursive.d.ts +6 -0
- package/build/node/index.cjs +8 -8
- package/build/node/index.d.ts +1 -0
- package/build/node/index.mjs +1000 -701
- package/build/urlGet-BtyqjC2r.mjs +2452 -0
- package/build/urlGet-BukRa7Gq.js +17 -0
- package/package.json +37 -38
- package/build/common/time/dateToString.d.ts +0 -2
- package/build/urlGet-CerQ1cKh.js +0 -17
- package/build/urlGet-DZEwtNXt.mjs +0 -2000
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";const ft=require("@flemist/abort-controller-fast"),Tt=require("@flemist/time-controller"),b=require("@flemist/async-utils"),Xt=require("fflate");function Yt(t){if(!t||t.timeout==null)return null;const e=new ft.AbortControllerFast,r=t.timeController??Tt.timeControllerDefault;if(t.timeout){const n=r.setTimeout(()=>{e.abort(new ft.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 nr(t,e){const r=Yt(e);try{return await t(r?.signal??e?.abortSignal??null)}finally{r?.abort()}}class sr{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const r=s=>(this._options.persist?this._promiseOrValue=s:(this._promiseOrValue=null,this._hasValue=!1),s),n=s=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),s};if(b.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 or{_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=o=>(this._options.persist?this._promiseOrValues.set(e,o):this._promiseOrValues.delete(e),o),s=o=>{throw this._options.persist||this._promiseOrValues.delete(e),o};if(b.isPromiseLike(r))r=r.then(n,s);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)}}class Zt{_lockPromise=null;get hasQueued(){return this._lockPromise!=null}lock(e){if(this._lockPromise)return b.promiseLikeToPromise(this._lockPromise.then(()=>this.lock(e)));const r=e();if(b.isPromiseLike(r)){const n=r.then(()=>{this._lockPromise===n&&(this._lockPromise=null)},()=>{this._lockPromise===n&&(this._lockPromise=null)});this._lockPromise=n}return b.promiseLikeToPromise(r)}}class te{_lockers=new Map;lock(e,r){let n=this._lockers.get(e);n==null&&(n=new Zt,this._lockers.set(e,n));const s=()=>{n.hasQueued||this._lockers.delete(e)};let o;try{o=n.lock(r)}catch(i){throw s(),i}return b.isPromiseLike(o)?o.then(i=>(s(),i),i=>{throw s(),i}):(s(),o)}hasQueued(e){const r=this._lockers.get(e);return r!=null&&r.hasQueued}}var At=(t=>(t[t.none=0]="none",t[t.error=1]="error",t[t.warn=2]="warn",t[t.debug=3]="debug",t))(At||{});async function ir(t){const e=t.abortSignal??null,r=t.timeController??Tt.timeControllerDefault;let n=0;for(;;)try{return await t.func({abortSignal:e})}catch(s){if((t.logLevel==null||t.logLevel>=At.error)&&console.error("[withRetry] error",s),e?.aborted)throw s;const o=t.delay({error:s,retryCount:n++,abortSignal:e});if(o==null||(typeof o=="number"?await b.delay(o,e??void 0,r):await o(),e?.aborted))throw s}}function ur({maxRetries:t,delays:e,isRetriableError:r}){return function({retryCount:s,error:o}){if(s==null||t!=null&&s>=t)return null;if(r==null||r(o)){if(Array.isArray(e))return e[Math.min(s,e.length-1)];{const i=e.mult??2;return Math.min(e.min*i**s,e.max)}}return null}}async function k(t){const e=await Promise.allSettled(t),r=[];return e.forEach(n=>{if(n.status==="fulfilled")r.push(n.value);else throw n.reason}),r}class ee{_options;_statsMap=null;_totalSize=null;_initPromise=null;constructor(e){this._options=e}async loadStatsMap(e){const r=await this._options.storage.getEntries(),n=[];r.forEach((s,o)=>{const i=this._options.converter?this._options.converter.from(s):s;b.isPromiseLike(i)?n.push(i.then(u=>{e(o,u)})):e(o,i)}),await Promise.all(n)}init(){return this._initPromise==null&&(this._initPromise=this._init()),this._initPromise}async _init(){const e=new Map;let r=0;await this.loadStatsMap((n,s)=>{e.set(n,s),r+=s.size}),this._statsMap=e,this._totalSize=r}async getTotalSize(){return await this.init(),this._totalSize}async get(e){return await this.init(),this._statsMap.get(e)??null}async set(e,r){if(await this.init(),r!=null){const n=this._options.converter?await this._options.converter.to(r):r;await this._options.storage.set(e,n);const s=this._statsMap.get(e);this._statsMap.set(e,r),this._totalSize+=r.size-(s?.size??0)}else{await this._options.storage.delete(e);const n=this._statsMap.get(e);n!=null&&(this._statsMap.delete(e),this._totalSize-=n.size)}}async getEntries(){return await this.init(),this._statsMap}}function ar(t,e){return t[1].dateUsed!==e[1].dateUsed?t[1].dateUsed<e[1].dateUsed?-1:1:t[1].size!==e[1].size?t[1].size<e[1].size?-1:1:t[1].dateModified!==e[1].dateModified?t[1].dateModified<e[1].dateModified?-1:1:t[0]!==e[0]?t[0]<e[0]?-1:1:0}class cr{_options;_timeController;_locker;_stats;constructor(e){this._options=e,this._timeController=e.timeController??Tt.timeControllerDefault,this._locker=new te,this._stats=new ee({storage:e.storages.stat,converter:e.converterStat})}async freeUpSpace(e,r,n){if(this._options.totalSize==null)return;const s=this._options.totalSize[0],o=this._options.totalSize[1];if(n>o)throw new Error(`[Cache][freeUpSpace] value size (${n}) exceeds maximum total size (${o})`);let i=await this._stats.getTotalSize();if(i+=n-(r??0),i<=o)return;const u=[],a=await this._stats.getEntries(),c=Array.from(a.entries());c.sort(ar),c.forEach(([l,d])=>{if(l===e||this._locker.hasQueued(l))return;const f=-d.size;(i>o||i+f>s)&&(u.push(this._locker.lock(l,async()=>(await k([this._options.storages.value.delete(l),this._options.storages.error.delete(l)]),this._stats.set(l,null)))),i+=f)}),await k(u)}async getOrCreate(e,r){const n=this._options.converterInput?await this._options.converterInput(e):e;return this._locker.lock(n,async()=>{let s=await this._stats.get(n);if(s==null||this._options.isExpired!=null&&this._options.isExpired(s))await k([this._options.storages.value.delete(n),this._options.storages.error.delete(n),this._stats.set(n,null)]),s=null;else{const[p,f]=await Promise.all([this._options.storages.value.get(n),this._options.storages.error.get(n)]),h=this._timeController.now();if(!s.hasError&&p!=null){const m={...s,dateUsed:h},_=this._options.converterValue?await this._options.converterValue.from(p):p;return await this._stats.set(n,m),_}if(s.hasError&&f!=null){const m={...s,dateUsed:h},_=this._options.converterError?await this._options.converterError.from(f):f;throw await this._stats.set(n,m),_}}let o=null,i=null,u=!1;try{o=await r(e)}catch(p){i=p,u=!0}if(u){const p=this._options.converterError?await this._options.converterError.to(i):i,f=this._options.getSize.error(p)+this._options.getSize.stat();await this.freeUpSpace(n,s?.size,f),await k([this._options.storages.error.set(n,p),this._options.storages.value.delete(n)]);const h=this._timeController.now(),m={dateModified:h,dateUsed:h,size:f,hasError:!0};throw await this._stats.set(n,m),i}const a=this._options.converterValue?await this._options.converterValue.to(o):o,c=this._options.getSize.value(a)+this._options.getSize.stat();await this.freeUpSpace(n,s?.size,c),await k([this._options.storages.value.set(n,a),this._options.storages.error.delete(n)]);const l=this._timeController.now(),d={dateModified:l,dateUsed:l,size:c};return await this._stats.set(n,d),o})}async delete(e){const r=this._options.converterInput?await this._options.converterInput(e):e;return this._locker.lock(r,async()=>{await k([this._options.storages.value.delete(r),this._options.storages.error.delete(r),this._stats.set(r,null)])})}async clear(){const[e,r,n]=await Promise.all([this._options.storages.value.getKeys(),this._options.storages.error.getKeys(),this._options.storages.stat.getKeys()]),s=new Set([...e,...r,...n]),o=[];s.forEach(i=>{const u=this._locker.lock(i,async()=>{const a=[],c=this._options.storages.value.delete(i);b.isPromiseLike(c)&&a.push(c);const l=this._options.storages.error.delete(i);b.isPromiseLike(l)&&a.push(l);const d=this._stats.set(i,null);b.isPromiseLike(d)&&a.push(d),await k(a)});b.isPromiseLike(u)&&o.push(u)}),await k(o)}}class lr{_cache=new Map;set(e,r){this._cache.set(e,r)}get(e){return this._cache.get(e)}delete(e){this._cache.delete(e)}clear(){this._cache.clear()}getKeys(){return Array.from(this._cache.keys())}getEntries(){return new Map(this._cache)}}function xt(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,r=[];for(let n=0;n<e;n++)r.push(xt(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]=xt(t[r]));return e}return t}function H(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(!H(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)&&!H(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)&&!H(e[r],null))return!1;return!0}return!1}function fr(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(!H(n,e.get(r)))return!1;return!0}function hr(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 ht(t){return!t||typeof t!="object"?t:Array.isArray(t)?t.map(ht):t&&Object.keys(t).sort().reduce((e,r)=>{const n=ht(t[r]);return n!=null&&(e[r]=n),e},{})}function mr(t,e){return Object.defineProperty(t,"name",{value:e,configurable:!0}),t}function re(t){return t=ht(t),JSON.stringify(t??null)}let it=null;function pr(){if(!it){it=new Array(256);for(let t=0;t<256;t++)it[t]=t.toString(16).padStart(2,"0")}return it}function ne(t){const e=pr(),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let n="";for(let s=0,o=r.length;s<o;s++)n+=e[r[s]];return n}let Et=null,se=null,ut=null,oe=null;function dr(){Et||(Et=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]),se=new Uint32Array(64),oe=new TextEncoder,ut=new Uint8Array(65536))}function ie(t){if(t==null)return null;dr();const e=Et,r=se,n=oe;let s=ut,o;if(typeof t=="string"){const w=t.length*3;s.length<w+128&&(s=ut=new Uint8Array(w+128));const y=n.encodeInto(t,s);o=s.subarray(0,y.written)}else if(t instanceof Uint8Array)o=t;else if(ArrayBuffer.isView(t))o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else throw new Error(`[sha256Buffer] Unsupported content type: ${typeof t}`);const i=o.length,u=i+72>>>6<<6;s.length<u&&(s=ut=new Uint8Array(u)),o!==s&&s.set(o),s[i]=128;for(let w=i+1;w<u;w++)s[w]=0;const a=i*8,c=a/4294967296|0,l=a|0;s[u-8]=c>>>24,s[u-7]=c>>>16,s[u-6]=c>>>8,s[u-5]=c,s[u-4]=l>>>24,s[u-3]=l>>>16,s[u-2]=l>>>8,s[u-1]=l;let d=1779033703,p=-1150833019,f=1013904242,h=-1521486534,m=1359893119,_=-1694144372,O=528734635,E=1541459225;for(let w=0;w<u;w+=64){for(let S=0;S<16;S++){const x=w+(S<<2);r[S]=s[x]<<24|s[x+1]<<16|s[x+2]<<8|s[x+3]}for(let S=16;S<64;S++){const x=r[S-15],N=r[S-2],bt=(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3,ot=(N>>>17|N<<15)^(N>>>19|N<<13)^N>>>10;r[S]=r[S-16]+bt+r[S-7]+ot|0}let y=d,T=p,nt=f,_t=h,A=m,st=_,B=O,wt=E;for(let S=0;S<64;S+=4)for(let x=0;x<4;x++){const N=S+x,bt=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7),ot=wt+bt+(B^A&(st^B))+e[N]+r[N]|0,rr=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&T^nt&(y^T))|0;wt=B,B=st,st=A,A=_t+ot|0,_t=nt,nt=T,T=y,y=ot+rr|0}d=d+y|0,p=p+T|0,f=f+nt|0,h=h+_t|0,m=m+A|0,_=_+st|0,O=O+B|0,E=E+wt|0}const M=new Uint8Array(32),K=[d,p,f,h,m,_,O,E];for(let w=0;w<8;w++){const y=K[w],T=w<<2;M[T]=y>>>24,M[T+1]=y>>>16&255,M[T+2]=y>>>8&255,M[T+3]=y&255}return M}function ue(t){const e=ie(t);return e?ne(e):null}function gr(t){const e=re(t);return ue(e)}function yr(t,e){return t==null?e:(r,n)=>t(r,s=>e(s,n))}function _r(t,e){return t==null?e:r=>t(r,n=>e(n))}function ae(t,e){return t==null?e:(r,n)=>t(r,s=>e(s,n))}function ce(t,e){return t==null?e:(r,n)=>t(r,s=>e(s,n))}function le(t,e){return t==null?e:{to:ae((r,n)=>t.to(r,n),(r,n)=>e.to(r,n))}}function fe(t,e){return t==null?e:{from:ce((r,n)=>t.from(r,n),(r,n)=>e.from(r,n))}}function wr(t,e){return t==null?e:{to:le(t,e).to,from:fe(t,e).from}}function he(t,e){return t==null?e:r=>t(r,n=>e(n))}function me(t,e){return t==null?e:r=>t(r,n=>e(n))}function pe(t,e){return t==null?e:{to:he((r,n)=>t.to(r,n),r=>e.to(r))}}function de(t,e){return t==null?e:{from:me((r,n)=>t.from(r,n),r=>e.from(r))}}function br(t,e){return t==null?e:{to:pe(t,e).to,from:de(t,e).from}}const Mt={to:t=>JSON.stringify(t??null,null,2),from:t=>JSON.parse(t)},Q={to:t=>new TextEncoder().encode(t),from:t=>new TextDecoder().decode(t)},Ct={to:t=>{const e=Mt.to(t);return Q.to(e)},from:t=>{const e=Q.from(t);return Mt.from(e)}};async function ge(t,e){return new Promise((r,n)=>{Xt.gzip(t,{level:e.level},(s,o)=>{s?n(s):r(o)})})}function Sr(t){return t[0]===31&&t[1]===139}async function ye(t){return new Promise((e,r)=>{Xt.gunzip(t,(n,s)=>{n?r(n):e(s)})})}function kt(t){return{to:e=>t==null?e:ge(e,t),from:e=>t==null?e:ye(e)}}function Or(t){const e=kt(t);return{to:r=>{const n=Ct.to(r);return e.to(n)},from:async r=>{const n=await e.from(r);return Ct.from(n)}}}function xr(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return"&rt;";case'"':return""";default:return"'"}})}function Er(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function It(t,e,r){const n=e==null?t:new Date(t.toLocaleString("en-US",{timeZone:e})),s=r==null?t:new Date(t.toLocaleString("en-US",{timeZone:r}));return new Date(t.getTime()+s.getTime()-n.getTime())}function _e(t,e){t=It(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),s=t.getUTCDate().toString().padStart(2,"0"),o=t.getUTCHours().toString().padStart(2,"0"),i=t.getUTCMinutes().toString().padStart(2,"0"),u=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${s} ${o}:${i}:${u}`}let Mr=0;const St=new WeakMap;function L(t){if(St.has(t))return St.get(t);const e=Mr++;return St.set(t,e),e}function G(t,e,r){if(t==null)return null;if(e==null||t.length<=e)return t;const n=r?.appendEllipsis?"…":"",s=n.length+(r?.appendTruncatedLength?String(t.length).length+2:0),o=Math.max(0,e-s),i=r?.appendTruncatedLength?`(${t.length-o})`:"";return o<=0?i+n:r?.fromStart?i+n+t.slice(t.length-o):t.slice(0,o)+n+i}function qt(t,e){try{return t[e]}catch(r){return"Error: "+(r instanceof Error?r.message:String(r))}}function I(t,e,r,n){const{pretty:s,filter:o,maxDepth:i,maxItems:u,maxStringLength:a,showObjectId:c,showArrayIndex:l,customToString:d}=e??{};if(r==null&&(r=[]),n==null&&(n=new Set),d){const f=d(t,r,h=>I(h,e,r,n));if(f!=null)return G(f,a,e?.truncateOptions)}const p=r.length;if(typeof t=="string")return t=G(t,a,e?.truncateOptions),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??""}#${L(t)}[${t.byteLength}]`;if(t instanceof RegExp)return G(String(t),a,e?.truncateOptions);if(t instanceof Date)return _e(t);if(t instanceof Object){if(n.has(t)||i!=null&&p>=i)return`${t.constructor===Object?"":t.constructor?.name??""}#${L(t)}`;n.add(t)}if(t instanceof Error)return G(t.stack||t.message||String(t),a,e?.truncateOptions);if(Array.isArray(t)){const f=s?" ".repeat(p):"";let h="";c&&(h+=`#${L(t)} `),h+="[";let m=0,_=!1;for(let O=0;O<t.length;O++){if(u!=null&&m>=u){_=!0;break}const E=[...r,String(O)],M=qt(t,O);if(o!=null&&!o(E,M))continue;const K=I(M,e,E,n);m>0&&(h+=","),s&&(h+=`
|
|
2
|
+
`),s&&(h+=`${f} `),l&&(h+=`${O}: `),h+=`${K}`,m++}return _?(m>0&&(h+=","),s?(h+=`
|
|
3
|
+
`,h+=`${f} ...
|
|
4
|
+
`):h+="...",h+=f,h+="]"):(m>0&&s&&(h+=`
|
|
5
|
+
${f}`),h+="]"),h}if(t instanceof Map){let f="";return c&&(f+=`#${L(t)} `),f+="Map",f+=I(Array.from(t.entries()),e,r,n),f}if(t instanceof Set){let f="";return c&&(f+=`#${L(t)} `),f+="Set",f+=I(Array.from(t.values()),e,r,n),f}{const f=t.constructor===Object?"":t.constructor?.name??"",h=s?" ".repeat(p):"";let m=f?`${f} `:"";c&&(m+=`#${L(t)} `),m+="{";let _=0,O=!1;for(const E in t){if(u!=null&&_>=u){O=!0;break}const M=[...r,E],K=qt(t,E);if(o!=null&&!o(M,K))continue;const w=I(K,e,M,n);_>0&&(m+=","),s&&(m+=`
|
|
6
|
+
`),s&&(m+=`${h} `),m+=`${E}: ${w}`,_++}return O&&(_>0&&(m+=","),s?(m+=`
|
|
7
|
+
`,m+=`${h} ...
|
|
8
|
+
`):m+="...",m+=h),_>0&&s&&!O&&(m+=`
|
|
9
|
+
${h}`),m+="}",m}}function we(t,e){t=It(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),s=t.getUTCDate().toString().padStart(2,"0"),o=t.getUTCHours().toString().padStart(2,"0"),i=t.getUTCMinutes().toString().padStart(2,"0"),u=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${s}_${o}-${i}-${u}`}const $t={to:t=>{const e=I(t,{pretty:!0,maxDepth:10,maxItems:50,maxStringLength:1e3});return Q.to(e)},from:t=>Q.from(t)};function Cr(t){const e=kt(t);return{to:r=>{const n=$t.to(r);return e.to(n)},from:async r=>{const n=await e.from(r);return $t.from(n)}}}const $r={to:t=>Array.from(t.entries()).reduce((e,[r,n])=>(e[r]=n,e),{}),from:t=>new Map(Object.entries(t))},Tr={to:t=>Array.from(t),from:t=>new Set(t)};function be(t,e){return t==null?e:e==null?t:Math.min(t,e)}function Se(t,e){return t==null?e:e==null?t:Math.max(t,e)}function Ar(t,e,r){return Se(be(t,e),r)}function kr(t,e){return(t%e+e)%e}function Ir(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 vr(){return Math.random()}function Pr(){return Math.random()*2**32>>>0}function Oe(t){return t!=null?Ir(t):vr}class mt{_seed;_rnd;constructor(e){this._seed=e,this._rnd=Oe(e)}get seed(){return this._seed}nextSeed(){return this.next()*2**32>>>0}nextRandom(){return new mt(this.nextSeed())}next(){return this._rnd()}clone(){return new mt(this._seed)}}function vt(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 xe(t,e,r){return Math.floor(vt(t,e,r))}function Nr(t,e){return t.next()<(e??.5)}function Rr(t,e,r){if(Array.isArray(e)){const o=e;e=o.length,r=i=>o[i]}if(!r)throw new Error("[random][randomIndexWeighted] getWeight is required");let n=0;for(let o=0;o<e;o++)n+=r(o);if(n===0)return-1;let s=vt(t,n);for(let o=0;o<e;o++)if(s-=r(o),s<0)return o;return e-1}function Pt(t,e){if(e.length===0)throw new Error("[random][randomItem] items is empty");const r=xe(t,e.length);return e[r]}function zr(t,e,r){if(e.length===0)throw new Error("[random][randomItems] items is empty");const n=[];for(let s=0;s<r;s++)n.push(Pt(t,e));return n}function Dr(t,e,r){let n=Object.values(e);return r&&(n=n.filter(r)),Pt(t,n)}const Ee=1073741789,at=(Ee>>2)-1;function Ur(t=at,e){if(t<=0)throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);if(t>at)throw new Error(`[random][PseudoRandom] count(${t}) must be <= ${at}`);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+Ee)%t,r}}let W=null;function Lr(){const t=Date.now();return W==null||t>W?(W=t,t):(W++,W)}async function jr({url:t,timeout:e}={}){t||(t=typeof window<"u"?"/":"https://google.com");let r;try{const n=new ft.AbortControllerFast;r=e?setTimeout(()=>{n.abort()},e):null;const s=await fetch(t,{method:"HEAD",signal:ft.toAbortSignal(n.signal)}),o=s.headers.get("date");if(!o)throw new Error(`[Now][getDateInet] No date header in response: ${s.status} ${t}`);return new Date(o).getTime()}finally{r&&clearTimeout(r)}}function Kr(t){const e=alert;return window.alert=r=>t(e,r),()=>{window.alert=e}}var F=(t=>(t.log="log",t.warn="warn",t.error="error",t.info="info",t.debug="debug",t.trace="trace",t.assert="assert",t))(F||{});const Jt=Object.values(F);function U(t){return function(){t.apply(console,arguments)}}const Ht={log:U(console.log),warn:U(console.warn),error:U(console.error),info:U(console.info),debug:U(console.debug),trace:U(console.trace),assert:U(console.assert)};function Nt(t){return Jt.forEach(e=>{console[e]=(...r)=>{t(Ht,e,r)}}),()=>{Jt.forEach(e=>{console[e]=Ht[e]})}}function Fr(t){return function(r){let n=null;const o=Nt((u,a,c)=>{try{t(u,a,c)}catch(l){throw n||(n=l),l}}),i=()=>{if(o(),n)throw n};try{const u=r();return b.isPromiseLike(u)?u.then(a=>(i(),a),a=>{throw i(),a}):(i(),u)}catch(u){throw i(),u}}}class Rt{_listeners=new Map;_listenersAdd=new Map;_startStopNotifier;_emit;_update;_unsubscribeNotifier=null;_emitLast;_hasLast;_last=void 0;_emitting=!1;_subscribing=!1;_actionOnCycle;constructor({emitLastEvent:e,startStopNotifier:r,hasLast:n,last:s,actionOnCycle:o}={}){this._startStopNotifier=r??null,this._emit=r?i=>this.emit(i):null,this._update=r?i=>this.update(i):null,this._emitLast=e??!1,this._hasLast=n??!1,this._last=s,this._actionOnCycle=o??!1}get hasLast(){return this._hasLast}get last(){return this._last}get hasListeners(){return this._listeners.size>0}subscribe(e){const r={};if(this._emitting?this._listenersAdd.set(r,e):this._listeners.set(r,e),this._subscribing&&this._actionOnCycle==="throw")throw new Error("[Rx][Subject] Circular subscription detected");if((this._hasLast||this._subscribing&&this._actionOnCycle==="emitLast")&&e(this._last),this._startStopNotifier&&this._listeners.size+this._listenersAdd.size===1)try{this._subscribing=!0,this._unsubscribeNotifier=this._startStopNotifier(this._emit,this._update)??null}finally{this._subscribing=!1}return()=>{if(this._listeners.delete(r),this._listenersAdd.delete(r),this._startStopNotifier&&this._listeners.size===0&&this._listenersAdd.size===0){const n=this._unsubscribeNotifier;this._unsubscribeNotifier=null,n?.()}}}emit(e){if(this._emitting){if(this._actionOnCycle==="throw")throw new Error("[Rx][Subject] Circular emit detected");this._actionOnCycle==="emitLast"&&(this._last=e,this._hasLast=!0);return}const r=()=>{this._listenersAdd.size>0&&(this._listenersAdd.forEach((n,s)=>{this._listeners.set(s,n)}),this._listenersAdd.clear()),this._emitting=!1};try{this._emitting=!0,this._emitLast&&(this._last=e,this._hasLast=!0);let n;if(this._listeners.forEach(s=>{const o=s(e);b.isPromiseLike(o)&&(n||(n=[]),n.push(o))}),n)return Promise.all(n).then(r,s=>{throw r(),s});r()}catch(n){throw r(),n}}update(e){if(!this._emitLast)throw new Error("[Rx][Subject] update available only for subjects with emitLastEvent");const r=e(this._last);return this.emit(r)}}function Vr(t,e){return I(t,{maxDepth:5,maxItems:10,...e})}function Br(t){return t.map(e=>e&&typeof e=="object"?Vr(e):e)}function Wr(t){return`${we(new Date)} [${t.level.toUpperCase()}] ${Br(t.args).join(" ")}`}let pt=null,Ot=null;function Me(){return Ot||(Ot=new Rt({startStopNotifier:t=>(pt=t,()=>{pt=null})})),Ot}function Gr(){return Nt((t,e,r)=>{e==="assert"&&r[0]===!0||(e===F.error||e===F.warn||e===F.assert)&&(pt&&pt({date:Date.now(),level:e,args:r}),t[e](...r))})}function qr(t){if(typeof window>"u")return b.EMPTY_FUNC;const{levels:e,predicate:r}=t;return Me().subscribe(n=>{if(e&&!e.includes(n.level))return;const s=n.args.join(`
|
|
10
|
+
`);r&&!r({text:s,message:n})||alert(s)})}function Ce(){let t=new Error().stack;if(t!=null){const e=t.indexOf(`
|
|
11
|
+
`);e!=null&&e>=0&&(t=t.substring(e+1))}return t??""}function Jr(t){return function(...e){const r=Ce();try{return t.apply(this,e)}catch(n){throw n instanceof Error||(n=new Error(String(n))),n.stack=n.stack?n.stack+`
|
|
12
|
+
`+r:r,n}}}function Hr(t){return t!=null&&typeof t=="object"&&typeof t.subscribe=="function"}class Qr{_subjects=new Map;_getLastEvent;constructor({getLastEvent:e}={}){this._getLastEvent=e}subscribe(e,r){let n=this._subjects.get(e);n||(n=new Rt,this._subjects.set(e,n));const s=n.subscribe(r);if(this._getLastEvent){const o=this._getLastEvent(e);r(o)}return()=>{s(),n?.hasListeners||this._subjects.delete(e)}}emit(e,r){const n=this._subjects.get(e);if(n)return n.emit(r)}forEach(e){this._subjects.forEach(e)}observable(e){return{subscribe:r=>this.subscribe(e,r)}}emitter(e){return{emit:r=>this.emit(e,r)}}subject(e){return{subscribe:r=>this.subscribe(e,r),emit:r=>this.emit(e,r)}}}function Xr(t,e,r){return new Promise(n=>{let s=!1,o;function i(l){a?.(),o?.(),s=!0,n(l)}function u(l){a?.(),o?.(),s=!0,n(Promise.reject(l))}const a=r?.subscribe(u);let c=!0;o=t.subscribe(l=>{(!e||e(l,c))&&i(l),c=!1}),s&&o?.()})}class R extends Error{constructor(e){super(e)}}class g{_args;constructor(e){this._args=e&&{...e}}set(e){return this._args={...this._args??{},...e},this}name(e){return this.set({name:e})}toString(e){const r=this._args?.name;return r?typeof r=="string"?r:r(e):this.nameDefault(e)}}function $e(t,e){return I(t,{maxDepth:1,maxItems:5,...e})}function z(t){return t instanceof g}function Z(t){return $e(t)}function dt(t,...e){if(t==null)return"";const r=$e(t,{filter:(n,s)=>{if(n.length===0)return!0;if(n.length!==1)return!1;const o=n[0];return!(o==="name"||o==="expected"||s==null||s===!1||e.includes(o))}});return/^(#\d+\s*)\{}$/.test(r)?"":`(${r})`}function X(t){const{result:e,cause:r,nested:n,error:s}=t;if(s){if(!(s instanceof Error))throw new R(`[test][validateMatchResult] error must be an instance of Error, but it is: ${s}`);if(e!=null)throw new R(`[test][validateMatchResult] result must be null if error is set, but it is: ${e}`);if(r!=null)throw new R(`[test][validateMatchResult] cause must be null if error is set, but it is: ${r}`);if(n!=null)throw new R(`[test][validateMatchResult] nested must be null if error is set, but it is: ${n}`);return t}if(typeof e!="boolean")throw new R(`[test][validateMatchResult] result must be a boolean, but it is: ${e}`);if(typeof r!="string"&&r!=null)throw new R(`[test][validateMatchResult] cause must be a string or null, but it is: ${r}`);if(n!=null&&!(n instanceof Array))throw new R(`[test][validateMatchResult] nested must be an array or null, but it is: ${n}`);return t}function Te(t,e,r){return X({actual:t,expected:e,result:null,cause:null,nested:null,error:r})}function zt(t,e,r){return X({actual:t,expected:e,result:r,cause:null,nested:null,error:null})}function Dt(t,e,r){return typeof r=="boolean"?zt(t,e,r):X(typeof r=="string"?{actual:t,expected:e,result:!1,cause:r,nested:null,error:null}:{actual:t,expected:e,result:r.result,cause:r.cause??null,nested:r.nested??null,error:null})}function C(t,e){try{if(z(e)){const r=e.match(t);return Dt(t,e,r)}return zt(t,e,t===e)}catch(r){return Te(t,e,r)}}class Ut extends g{match(e){const r=this._args.expected,n=C(e,r);return{result:!n.result,nested:[{actualKey:null,result:n}]}}nameDefault(){return"not"}}function Ae(t,e){const r=Lt(t.result,e);return r?{actualKey:t.actualKey,expectedKey:t.expectedKey,result:r}:null}function Lt(t,e){if(e?!t.result:t.result)return null;t.expected instanceof Ut&&(e=!e);let r=null;return t.nested&&t.nested.forEach(n=>{const s=Ae(n,e);s&&(r||(r=[]),r.push(s))}),{actual:t.actual,expected:t.expected,result:t.result,cause:t.cause,nested:r,error:t.error}}function ke(t,e){const r=jt(t.result,e+" ");return`${e}${t.actualKey==null?"| ":t.actualKey+": "}${r}`}function jt(t,e){if(t.result)return t.expected.toString();let r="";t.nested&&(r=t.nested.map(s=>ke(s,e)).join(`
|
|
13
|
+
`));let n=t.cause||"";return r?(n||(n=z(t.expected)?t.expected.toString(t.actual):""),`${n}
|
|
14
|
+
${r}`):`${n}
|
|
15
|
+
${e}expected: ${z(t.expected)?t.expected.toString(t.actual):t.expected}
|
|
16
|
+
${e}actual: ${Z(t.actual)}`}class Kt extends Error{constructor(e){super(e)}}function q(t){return function(r,n){const s=C(t,r);if(s.error)throw s.error;const o=Lt(s,!1);if(!o)return;const i=jt(o,"");console.log(`[test][check] CheckError:
|
|
17
|
+
`+i);const u=new Kt(i);throw n?.(u),u}}function Yr(t){return function(r,n){let s;try{s=t()}catch(o){q(o)(n);return}return b.isPromiseLike(s)?s.then(o=>(q(o)(r),o)).catch(o=>{if(o instanceof Kt)throw o;try{q(o)(n)}catch(i){throw console.error("[test][check] error",i),o}}):(q(s)(r),s)}}const tt=10;class Ft extends g{match(e){if(e==null)return`Expected array, got "${e}"`;if(typeof e!="object")return`Expected array, got "${typeof e}"`;if(!(e instanceof Array))return"Expected array";const r=this._args?.expected;if(r==null)return!0;const n=this._args?.maxReportItems??tt,s=this._args?.matchType||"equals";if(s==="equals"){if(e.length!==r.length)return`Expected array length to be ${r.length}, got ${e.length}`;let o=!0,i=0,u=0;const a=[];for(let c=0;c<r.length;c++){const l=e[c],d=r[c],p=C(l,d);if(p.result?(i<n&&a.push({actualKey:c,expectedKey:c,result:p}),i++):(u<n&&a.push({actualKey:c,expectedKey:c,result:p}),u++,o=!1),!o&&i>=n&&u>=n)break}return{result:o,nested:a}}if(s==="includes"){let o=!0;const i=[];let u=0,a=0;for(let c=0;c<r.length;c++){const l=r[c];let d=!1;for(let p=0;p<e.length;p++){const f=e[p],h=C(f,l);if(h.result){d=!0,u<n&&i.push({actualKey:p,expectedKey:c,result:h}),u++;break}}if(d||(o=!1,a<n&&i.push({expectedKey:c,result:{result:!1,actual:void 0,expected:l}}),a++),!o&&u>=n&&a>=n)break}return{result:o,nested:i}}return`Unknown matchType "${s}"`}nameDefault(){return`array ${this._args?.matchType||"equals"} ${Z(this._args?.expected)}`}}class Ie extends g{match(){return!0}nameDefault(){return"any"}}class ve extends g{match(e){if(typeof e!="object")return`Expected array, got "${typeof e}"`;if(!(e instanceof Array))return"Expected array";const r=this._args.expected;let n=!0;const s=[],o=this._args?.maxReportItems??tt;let i=0,u=0;for(let a=0;a<e.length;a++){const c=e[a],l=C(c,r);if(l.result?(i<o&&s.push({actualKey:a,expectedKey:a,result:l}),i++):(u<o&&s.push({actualKey:a,expectedKey:a,result:l}),u++,n=!1),!n&&i>=o&&u>=o)break}return{result:n,nested:s}}nameDefault(){return"array item"}}class Pe extends g{match(e){const{expected:r,convert:n}=this._args,s=C(n(e),r),o=[{result:s}];return{result:s.result,nested:o}}nameDefault(){return"convert"}}class Vt extends g{match(e){const{expected:r,nonStrict:n}=this._args;return n?e==r:e===r}nameDefault(){return`is(${Z(this._args.expected)})`}}class Ne extends g{match(e){if(e==null)return`Expected number, got "${e}"`;if(typeof e!="number")return`Expected number, got "${typeof e}"`;if(this._args==null)return Number.isFinite(e)?!0:"Expected finite number";if(!this._args.allowNaN&&Number.isNaN(e))return"Expected not NaN";if(!this._args.allowInfinity&&!Number.isFinite(e))return"Expected not Infinity";const{min:r,max:n,float:s}=this._args;return!s&&!Number.isInteger(e)?`Expected integer, got "${e}"`:r!=null&&e<r?`Expected number to be >= ${r}, got ${e}`:n!=null&&e>n?`Expected number to be <= ${n}, got ${e}`:!0}nameDefault(){return`number(${dt(this._args)})`}}class Re extends g{match(e){if(e==null)return`Expected object, got "${e}"`;if(Array.isArray(e))return"Expected object, got array";if(typeof e!="object")return`Expected object, got "${typeof e}"`;const r=this._args?.expected;if(r==null)return!0;let n=!0;const s=[],o=this._args?.maxReportItems??tt;let i=0,u=0;for(const a in r){if(!Object.prototype.hasOwnProperty.call(r,a))continue;const c=e[a],l=r[a],d=C(c,l);if(d.result?(i<o&&s.push({actualKey:a,expectedKey:a,result:d}),i++):(u<o&&s.push({actualKey:a,expectedKey:a,result:d}),u++,n=!1),!n&&i>=o&&u>=o)break}if(!this._args?.ignoreExtraKeys)for(const a in e){if(!Object.prototype.hasOwnProperty.call(e,a)||Object.prototype.hasOwnProperty.call(r,a))continue;const c=e[a];if(u<o&&s.push({actualKey:a,expectedKey:a,result:Dt(c,void 0,"Unexpected key")}),u++,n=!1,u>=o)break}return{result:n,nested:s}}nameDefault(){return"object"+dt(this._args)}}class ze extends g{match(e){if(e==null)return`Expected string, got ${e}`;if(typeof e!="string")return`Expected string, got "${typeof e}"`;if(this._args==null)return!0;const{pattern:r}=this._args;if(r!=null){if(typeof r=="function")return r(e);if(!r.test(e))return!1}return!0}nameDefault(){return this._args?.pattern?`string(${this._args.pattern})`:"string"}}class De extends g{match(e){const r=this._args.expected;return e instanceof r?!0:`Expected instance of "${r}", got "${e}"`}nameDefault(){return`instanceOf(${this._args.expected.name})`}}class Ue extends g{constructor(e){super({...e,expected:e.expected instanceof Set?e.expected:new Set(e.expected)})}match(e){return!!this._args.expected.has(e)}nameDefault(){return`in(${Z(this._args.expected)})`}}class et extends g{match(e){const{type:r,expecteds:n,pipe:s}=this._args;let o=r==="and";const i=[];for(let u=0;u<n.length;u++){const a=n[u],c=C(e,a);if(i.push({actualKey:`<${r} ${u}>`,expectedKey:`<${r} ${u}>`,result:c}),r==="or"){if(c.result&&(o=!0,s))break}else if(r==="and"){if(!c.result&&(o=!1,s))break}else throw new Error(`[test][MatcherFew] Unknown type "${r}"`)}return{result:n.length===0||o,nested:i}}nameDefault(){return this._args.type}}class Le extends g{match(e){const r=this._args.matcher;return z(r)?r.match(e):r(e)}nameDefault(e){const r=this._args.name;return typeof r=="string"?r:r?r(e):"custom"}}class je extends g{match(){return!1}nameDefault(){return"never"}}class Ke extends g{match(e){if(e==null)return`Expected object, got "${e}"`;if(Array.isArray(e))return"Expected object, got array";if(typeof e!="object")return`Expected object, got "${typeof e}"`;const r=this._args?.expected;if(r==null)return!0;let n=!0;const s=[],o=this._args?.maxReportItems??tt;let i=0,u=0;for(const a in e){if(!Object.prototype.hasOwnProperty.call(e,a))continue;const c=[a,e[a]],l=C(c,r);if(l.result?(i<o&&s.push({actualKey:a,expectedKey:a,result:l}),i++):(u<o&&s.push({actualKey:a,expectedKey:a,result:l}),u++,n=!1),!n&&i>=o&&u>=o)break}return{result:n,nested:s}}nameDefault(){return"object entries"+dt(this._args)}}class Fe extends g{_hasExpected=!1;_expected=void 0;get expected(){return this._expected}set expected(e){this._expected=e,this._hasExpected=!0}match(e){const r=C(e,this._expected),n=[{result:r}];return{result:r.result,nested:n}}nameDefault(){return"ref"}}function D(t){return new Ft({expected:t})}function Zr(t){return new Ft({expected:t,matchType:"includes"})}function V(){return new Ie}function tn(){return new Fe}function en(t){return new je({name:t})}function rn(t,e){const r=new ve({expected:e});return t==null?r:$(qe(z(t)||typeof t=="number"?t:rt(t)),r).name("array item")}function v(t,e,r){return new Pe({name:t,convert:e,expected:r})}function Ve(t){return new Vt({expected:t,nonStrict:!0})}function Be(t){return new Vt({expected:t,nonStrict:!1})}function Bt(t){return new Ne(t)}function rt(t){return Bt({...t,float:!1})}function nn(t){return Bt({...t,float:!0})}function P(t){return new Re({expected:t})}function ct(t,e,r=null){if(t instanceof g||e&&(t=e(t,r),t instanceof g))return t;if(t==null)return Y();if(Array.isArray(t)){const n=t.map((s,o)=>ct(s,e,o));return D(n)}if(t.constructor===Object){const n={};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=ct(t[s],e,s));return P(n)}return t instanceof b.ValueState?Xe({...t,value:ct(t.value,e,"value")}):Be(t)}function sn(t){return P(t).set({ignoreExtraKeys:!0})}function Wt(t){return new ze({pattern:t})}function on(t){return new De({expected:t})}function We(t){return v("typeof",e=>e===null?"null":typeof e,t)}function un(t){return v("constructor",e=>e.constructor,t)}function lt(){return We("boolean")}function Y(){return Ve(null)}function an(){return Qe(Y())}function cn(...t){return new et({expecteds:t,type:"or",pipe:!1})}function ln(...t){return new et({expecteds:t,type:"and",pipe:!1})}function Ge(...t){return new et({expecteds:t,type:"or",pipe:!0})}function $(...t){return new et({expecteds:t,type:"and",pipe:!0})}function j(t,e){return e==null?Ge(Y(),t):e?t:Y()}function qe(t){const e=typeof t=="number"||z(t)?t:rt(t??{min:1});return $(D(),v("length",r=>r.length,e)).name("array length")}function fn(t){const e=typeof t=="number"||z(t)?t:rt(t??{min:1});return $(Wt(),v("length",r=>r.length,e)).name("string length")}function hn(t){return $(P(),t)}function mn(t){return $(D(),t)}function pn(t){return $(P(),v("keys",e=>Object.keys(e),t))}function dn(t){return $(P(),v("values",e=>Object.values(e),t))}function gn(t){return $(P(),v("entries",e=>Object.entries(e),t))}function gt(t){return new Ke({expected:t})}function yn(t){return gt(D([t,V()]))}function _n(t){return gt(D([V(),t]))}function wn(t,e){return gt(D([t,e]))}function bn(t){return $(P(),v("keys not null",e=>Object.keys(e).filter(r=>e[r]!=null),t))}function Je(t){return new Ue({expected:t})}function Sn(t){return Je(Object.values(t))}function Gt(t,e){return new Le({matcher:e,name:t})}const On=Math.ceil(Date.now()-10*365.25*24*60*60*1e3),xn=Math.ceil(Date.now()+10*365.25*24*60*60*1e3);function J(t){return rt({...t,min:t?.min??On,max:t?.max??xn}).name("int date")}function He(t){const e={min:t?.from?.min??t?.common?.min,max:t?.from?.max??t?.common?.max,float:t?.from?.float??t?.common?.float,optional:t?.from?.optional??t?.common?.optional},r={min:t?.to?.min??t?.common?.min,max:t?.to?.max??t?.common?.max,float:t?.to?.float??t?.common?.float,optional:t?.to?.optional??t?.common?.optional};return $(D([e.optional?j(J()):J(),r.optional?j(J()):J()]),Gt("min <= max",n=>n[0]!=null&&n[1]!=null&&n[0]>n[1]?`Expected range to be [min, max], got [${n.join(", ")}]`:!0)).name("range")}function En(t){return He({...t,common:{min:new Date(2020,0,1).getTime(),max:Date.now()+900*1e3,...t?.common}}).name("range date")}function Qe(t){return new Ut({expected:t})}function Mn(){return Wt(/^[\da-f-]{36}|[\da-f]{32}$/i).name("uuid")}function Xe(t){return P({[Symbol.toStringTag]:j(V()),loading:j(lt()),hasValue:j(lt()),value:V(),hasError:j(lt()),error:V(),...t})}function Cn(t){return t!=null&&typeof t=="string"&&(t=new TextEncoder().encode(t).buffer),Gt("array buffer",e=>{if(e==null||typeof e!="object"||typeof e.byteLength!="number")return`Expected array buffer, got "${e}"`;if(t==null)return!0;if(e.byteLength!==t.byteLength)return`Expected array buffer length to be ${t.byteLength}, got ${e.byteLength}`;for(let r=0,n=t.byteLength;r<n;r++)if(e[r]!==t[r])return`Expected array buffer[${r}] to be ${t[r]}, got ${e[r]}`;return!0})}function Qt(t){return t.replace(/\W/g,"").toLowerCase()}function Ye(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 Ze(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 tr(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function er(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function yt(t,e){const r=Ye(e),n=Qt(t);for(const[s,o]of r.entries())if(Qt(s)===n)return o;return null}function $n(t,e){return Ze(yt(t,e))}function Tn(t,e){return tr(yt(t,e))}function An(t,e){return er(yt(t,e))}exports.Cache=cr;exports.CacheStats=ee;exports.CheckError=Kt;exports.ConsoleMessageLevel=F;exports.Lazy=sr;exports.LazyWithId=or;exports.Locker=Zt;exports.LockerWithId=te;exports.LogLevel=At;exports.MAX_REPORT_ITEMS_DEFAULT=tt;exports.MatchInternalError=R;exports.Matcher=g;exports.MatcherAny=Ie;exports.MatcherArray=Ft;exports.MatcherArrayItem=ve;exports.MatcherConvert=Pe;exports.MatcherCustom=Le;exports.MatcherFew=et;exports.MatcherIn=Ue;exports.MatcherInstanceOf=De;exports.MatcherIs=Vt;exports.MatcherNever=je;exports.MatcherNot=Ut;exports.MatcherNumber=Ne;exports.MatcherObject=Re;exports.MatcherObjectEntry=Ke;exports.MatcherRef=Fe;exports.MatcherString=ze;exports.MemoryStorage=lr;exports.Random=mt;exports.Subject=Rt;exports.SubjectWithId=Qr;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=at;exports.alertConsole=qr;exports.alertReplace=Kr;exports.argsToString=dt;exports.check=q;exports.checkFunc=Yr;exports.compressGzip=ge;exports.consoleIntercept=Gr;exports.consoleMessageToString=Wr;exports.consoleReplace=Nt;exports.convertTimeZone=It;exports.converterErrorToBuffer=$t;exports.converterJson=Mt;exports.converterJsonBuffer=Ct;exports.converterStringToBuffer=Q;exports.createConverterBufferToGzip=kt;exports.createConverterErrorToGzip=Cr;exports.createConverterJsonGzip=Or;exports.createMatchResult=Dt;exports.createMatchResultBoolean=zt;exports.createMatchResultError=Te;exports.createTaskDelayRetry=ur;exports.createUniquePseudoRandom=Ur;exports.dateNowUnique=Lr;exports.decompressGzip=ye;exports.deepCloneJsonLike=xt;exports.deepEqualJsonLike=H;exports.deepEqualJsonLikeMap=fr;exports.equalArray=hr;exports.escapeHtml=xr;exports.escapeRegExp=Er;exports.expectedToString=Z;exports.filterMatchResult=Lt;exports.filterMatchResultNested=Ae;exports.fixStackTrace=Jr;exports.formatAny=I;exports.formatDate=_e;exports.formatDateFileName=we;exports.getConsoleMessages=Me;exports.getDateInet=jr;exports.getHashKey=gr;exports.getJsonKey=re;exports.getNormalizedObject=ht;exports.getObjectId=L;exports.getRandomFunc=Oe;exports.getRandomSeed=Pr;exports.getStackTrace=Ce;exports.isGzipCompressed=Sr;exports.isMatcher=z;exports.isObservable=Hr;exports.mapObjectConverter=$r;exports.match=C;exports.matchAnd=ln;exports.matchAndPipe=$;exports.matchAny=V;exports.matchArray=D;exports.matchArrayBuffer=Cn;exports.matchArrayIncludes=Zr;exports.matchArrayItem=rn;exports.matchArrayLength=qe;exports.matchArrayWith=mn;exports.matchBoolean=lt;exports.matchConstructor=un;exports.matchConvert=v;exports.matchCustom=Gt;exports.matchDeep=ct;exports.matchEnum=Sn;exports.matchFloat=nn;exports.matchIn=Je;exports.matchInstanceOf=on;exports.matchInt=rt;exports.matchIntDate=J;exports.matchIs=Be;exports.matchIsNonStrict=Ve;exports.matchNever=en;exports.matchNot=Qe;exports.matchNotNullish=an;exports.matchNullish=Y;exports.matchNumber=Bt;exports.matchObject=P;exports.matchObjectEntries=gn;exports.matchObjectEntry=gt;exports.matchObjectKey=yn;exports.matchObjectKeyValue=wn;exports.matchObjectKeys=pn;exports.matchObjectKeysNotNull=bn;exports.matchObjectPartial=sn;exports.matchObjectValue=_n;exports.matchObjectValues=dn;exports.matchObjectWith=hn;exports.matchOptional=j;exports.matchOr=cn;exports.matchOrPipe=Ge;exports.matchRange=He;exports.matchRangeDate=En;exports.matchRef=tn;exports.matchResultNestedToString=ke;exports.matchResultToString=jt;exports.matchString=Wt;exports.matchStringLength=fn;exports.matchTypeOf=We;exports.matchUuid=Mn;exports.matchValueState=Xe;exports.max=Se;exports.min=be;exports.minMax=Ar;exports.numberMod=kr;exports.promiseAllWait=k;exports.randomBoolean=Nr;exports.randomEnum=Dr;exports.randomFloat=vt;exports.randomIndexWeighted=Rr;exports.randomInt=xe;exports.randomItem=Pt;exports.randomItems=zr;exports.setArrayConverter=Tr;exports.setFuncName=mr;exports.sha256=ue;exports.sha256Buffer=ie;exports.timeoutAbortController=Yt;exports.toConvertFrom=me;exports.toConvertTo=he;exports.toConvertWithDefaultFrom=ce;exports.toConvertWithDefaultTo=ae;exports.toConverter=br;exports.toConverterFrom=de;exports.toConverterTo=pe;exports.toConverterWithDefault=wr;exports.toConverterWithDefaultFrom=fe;exports.toConverterWithDefaultTo=le;exports.toCorrect=_r;exports.toCorrectWithDefault=yr;exports.toHex=ne;exports.truncateString=G;exports.urlGetBoolean=$n;exports.urlGetFloat=An;exports.urlGetInt=Tn;exports.urlGetParams=Ye;exports.urlGetString=yt;exports.urlParamToBoolean=Ze;exports.urlParamToFloat=er;exports.urlParamToInt=tr;exports.validateMatchResult=X;exports.waitObservable=Xr;exports.withConsoleReplace=Fr;exports.withRetry=ir;exports.withTimeout=nr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemist/simple-utils",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "Simple simple utils",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"types": "build/common/index.d.ts",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"require": "./build/node/index.cjs"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"packageManager": "pnpm@10.18.3",
|
|
38
37
|
"engines": {
|
|
39
38
|
"node": ">=20"
|
|
40
39
|
},
|
|
@@ -63,46 +62,14 @@
|
|
|
63
62
|
"publishConfig": {
|
|
64
63
|
"access": "public"
|
|
65
64
|
},
|
|
66
|
-
"scripts": {
|
|
67
|
-
"========================= install =========================": "",
|
|
68
|
-
"_prepublishOnly": "run-p audit lint build test:all && npm login",
|
|
69
|
-
"prepare": "node .husky/install.mjs",
|
|
70
|
-
"install:playwright": "pnpm exec playwright install --with-deps",
|
|
71
|
-
"========================= deploy =========================": "",
|
|
72
|
-
"build": "vite build",
|
|
73
|
-
"========================= lint =========================": "",
|
|
74
|
-
"audit": "pnpm audit --prod",
|
|
75
|
-
"lint:es": "eslint .",
|
|
76
|
-
"lint:es:fix": "eslint --fix .",
|
|
77
|
-
"lint": "run-p lint:es",
|
|
78
|
-
"lint:fix": "run-s lint:es:fix",
|
|
79
|
-
"lint-staged": "lint-staged",
|
|
80
|
-
"check:types": "tsc --noEmit",
|
|
81
|
-
"check": "run-p audit check:types lint",
|
|
82
|
-
"========================= test =========================": "",
|
|
83
|
-
"test:node": "vitest --run --config vite.projects.ts --project node --bail 3",
|
|
84
|
-
"test:browser": "vitest --run --config vite.projects.ts --project browser --bail 3",
|
|
85
|
-
"test:chrome": "vitest --run --config vite.projects.ts --project browser --browser chromium --bail 3",
|
|
86
|
-
"test:all": "vitest --run --config vite.projects.ts --bail 3",
|
|
87
|
-
"test": "run-s test:node test:browser",
|
|
88
|
-
"========================= dev =========================": "",
|
|
89
|
-
"kill-node": "taskkill /F /IM node.exe",
|
|
90
|
-
"kill-java": "taskkill /F /IM java.exe",
|
|
91
|
-
"kill-chrome": "taskkill /F /IM chrome.exe",
|
|
92
|
-
"========================= mcp =========================": "",
|
|
93
|
-
"mcp:playwright": "mcp-server-playwright --port 8002 --host local.host --isolated",
|
|
94
|
-
"mcp:tools": "mcp-project-tools",
|
|
95
|
-
"========================= other =========================": "",
|
|
96
|
-
"dep:fix": "tsx tools/dep-fix.ts"
|
|
97
|
-
},
|
|
98
65
|
"devDependencies": {
|
|
99
66
|
"@eslint/compat": "1.2.4",
|
|
100
67
|
"@eslint/eslintrc": "3.2.0",
|
|
101
68
|
"@eslint/js": "9.17.0",
|
|
102
69
|
"@flemist/copy-glob-flat": "0.0.5",
|
|
103
|
-
"@flemist/mcp-project-tools": "
|
|
104
|
-
"@flemist/test-utils": "1.0.
|
|
105
|
-
"@flemist/test-variants": "
|
|
70
|
+
"@flemist/mcp-project-tools": "5.0.2",
|
|
71
|
+
"@flemist/test-utils": "1.0.4",
|
|
72
|
+
"@flemist/test-variants": "5.0.8",
|
|
106
73
|
"@types/eslint": "9.6.1",
|
|
107
74
|
"@types/node": "22.12.0",
|
|
108
75
|
"@typescript-eslint/eslint-plugin": "8.19.0",
|
|
@@ -131,10 +98,42 @@
|
|
|
131
98
|
"dependencies": {
|
|
132
99
|
"@flemist/abort-controller-fast": "^1.0.0",
|
|
133
100
|
"@flemist/async-utils": "^1.2.8",
|
|
101
|
+
"@flemist/pairing-heap": "^1.0.0",
|
|
134
102
|
"@flemist/priority-queue": "^1.0.1",
|
|
135
103
|
"@flemist/time-controller": "^1.0.4",
|
|
136
104
|
"@flemist/time-limits": "^2.0.4",
|
|
105
|
+
"fflate": "^0.8.2",
|
|
137
106
|
"picomatch": "^4.0.4",
|
|
138
107
|
"tslib": ">=2.8.1"
|
|
108
|
+
},
|
|
109
|
+
"scripts": {
|
|
110
|
+
"========================= install =========================": "",
|
|
111
|
+
"install:playwright": "pnpm exec playwright install --with-deps",
|
|
112
|
+
"========================= deploy =========================": "",
|
|
113
|
+
"build": "vite build",
|
|
114
|
+
"========================= lint =========================": "",
|
|
115
|
+
"audit": "pnpm audit --prod",
|
|
116
|
+
"lint:es": "eslint .",
|
|
117
|
+
"lint:es:fix": "eslint --fix .",
|
|
118
|
+
"lint": "run-p lint:es",
|
|
119
|
+
"lint:fix": "run-s lint:es:fix",
|
|
120
|
+
"lint-staged": "lint-staged",
|
|
121
|
+
"check:types": "tsc --noEmit",
|
|
122
|
+
"check": "run-p audit check:types lint",
|
|
123
|
+
"========================= test =========================": "",
|
|
124
|
+
"test:node": "vitest --run --config vite.projects.ts --project node --bail 3",
|
|
125
|
+
"test:browser": "vitest --run --config vite.projects.ts --project browser --bail 3",
|
|
126
|
+
"test:chrome": "vitest --run --config vite.projects.ts --project browser --browser chromium --bail 3",
|
|
127
|
+
"test:all": "vitest --run --config vite.projects.ts --bail 3",
|
|
128
|
+
"test": "run-s test:node test:browser",
|
|
129
|
+
"========================= dev =========================": "",
|
|
130
|
+
"kill-node": "taskkill /F /IM node.exe",
|
|
131
|
+
"kill-java": "taskkill /F /IM java.exe",
|
|
132
|
+
"kill-chrome": "taskkill /F /IM chrome.exe",
|
|
133
|
+
"========================= mcp =========================": "",
|
|
134
|
+
"mcp:playwright": "mcp-server-playwright --port 8002 --host local.host --isolated",
|
|
135
|
+
"mcp:tools": "mcp-project-tools",
|
|
136
|
+
"========================= other =========================": "",
|
|
137
|
+
"dep:fix": "tsx tools/dep-fix.ts"
|
|
139
138
|
}
|
|
140
|
-
}
|
|
139
|
+
}
|
package/build/urlGet-CerQ1cKh.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";const ct=require("@flemist/abort-controller-fast"),U=require("@flemist/async-utils"),zt=require("@flemist/time-controller");let st=null;function Ue(){if(!st){st=new Array(256);for(let t=0;t<256;t++)st[t]=t.toString(16).padStart(2,"0")}return st}function qt(t){const e=Ue(),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let n="";for(let s=0,i=r.length;s<i;s++)n+=e[r[s]];return n}let _t=null,Wt=null,it=null,Gt=null;function je(){_t||(_t=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]),Wt=new Uint32Array(64),Gt=new TextEncoder,it=new Uint8Array(65536))}function Ht(t){if(t==null)return null;je();const e=_t,r=Wt,n=Gt;let s=it,i;if(typeof t=="string"){const g=t.length*3;s.length<g+128&&(s=it=new Uint8Array(g+128));const p=n.encodeInto(t,s);i=s.subarray(0,p.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 u=i.length,o=u+72>>>6<<6;s.length<o&&(s=it=new Uint8Array(o)),i!==s&&s.set(i),s[u]=128;for(let g=u+1;g<o;g++)s[g]=0;const a=u*8,c=a/4294967296|0,f=a|0;s[o-8]=c>>>24,s[o-7]=c>>>16,s[o-6]=c>>>8,s[o-5]=c,s[o-4]=f>>>24,s[o-3]=f>>>16,s[o-2]=f>>>8,s[o-1]=f;let b=1779033703,y=-1150833019,h=1013904242,l=-1521486534,m=1359893119,O=-1694144372,_=528734635,S=1541459225;for(let g=0;g<o;g+=64){for(let w=0;w<16;w++){const x=g+(w<<2);r[w]=s[x]<<24|s[x+1]<<16|s[x+2]<<8|s[x+3]}for(let w=16;w<64;w++){const x=r[w-15],N=r[w-2],gt=(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3,nt=(N>>>17|N<<15)^(N>>>19|N<<13)^N>>>10;r[w]=r[w-16]+gt+r[w-7]+nt|0}let p=b,A=y,et=h,pt=l,T=m,rt=O,B=_,yt=S;for(let w=0;w<64;w+=4)for(let x=0;x<4;x++){const N=w+x,gt=(T>>>6|T<<26)^(T>>>11|T<<21)^(T>>>25|T<<7),nt=yt+gt+(B^T&(rt^B))+e[N]+r[N]|0,De=((p>>>2|p<<30)^(p>>>13|p<<19)^(p>>>22|p<<10))+(p&A^et&(p^A))|0;yt=B,B=rt,rt=T,T=pt+nt|0,pt=et,et=A,A=p,p=nt+De|0}b=b+p|0,y=y+A|0,h=h+et|0,l=l+pt|0,m=m+T|0,O=O+rt|0,_=_+B|0,S=S+yt|0}const E=new Uint8Array(32),F=[b,y,h,l,m,O,_,S];for(let g=0;g<8;g++){const p=F[g],A=g<<2;E[A]=p>>>24,E[A+1]=p>>>16&255,E[A+2]=p>>>8&255,E[A+3]=p&255}return E}function Pe(t){const e=Ht(t);return e?qt(e):null}function Jt(t,e){return t==null?e:e==null?t:Math.min(t,e)}function Xt(t,e){return t==null?e:e==null?t:Math.max(t,e)}function Le(t,e,r){return Xt(Jt(t,e),r)}function Ke(t,e){return(t%e+e)%e}function Fe(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 ve(){return Math.random()}function Ve(){return Math.random()*2**32>>>0}function Yt(t){return t!=null?Fe(t):ve}class lt{_seed;_rnd;constructor(e){this._seed=e,this._rnd=Yt(e)}get seed(){return this._seed}nextSeed(){return this.next()*2**32>>>0}nextRandom(){return new lt(this.nextSeed())}next(){return this._rnd()}clone(){return new lt(this._seed)}}function St(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 Qt(t,e,r){return Math.floor(St(t,e,r))}function Be(t,e){return t.next()<(e??.5)}function ze(t,e,r){if(Array.isArray(e)){const i=e;e=i.length,r=u=>i[u]}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 s=St(t,n);for(let i=0;i<e;i++)if(s-=r(i),s<0)return i;return e-1}function Et(t,e){if(e.length===0)throw new Error("[random][randomItem] items is empty");const r=Qt(t,e.length);return e[r]}function qe(t,e,r){if(e.length===0)throw new Error("[random][randomItems] items is empty");const n=[];for(let s=0;s<r;s++)n.push(Et(t,e));return n}function We(t,e,r){let n=Object.values(e);return r&&(n=n.filter(r)),Et(t,n)}const Zt=1073741789,ot=(Zt>>2)-1;function Ge(t=ot,e){if(t<=0)throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);if(t>ot)throw new Error(`[random][PseudoRandom] count(${t}) must be <= ${ot}`);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+Zt)%t,r}}let z=null;function He(){const t=Date.now();return z==null||t>z?(z=t,t):(z++,z)}async function Je({url:t,timeout:e}={}){t||(t=typeof window<"u"?"/":"https://google.com");let r;try{const n=new ct.AbortControllerFast;r=e?setTimeout(()=>{n.abort()},e):null;const s=await fetch(t,{method:"HEAD",signal:ct.toAbortSignal(n.signal)}),i=s.headers.get("date");if(!i)throw new Error(`[Now][getDateInet] No date header in response: ${s.status} ${t}`);return new Date(i).getTime()}finally{r&&clearTimeout(r)}}function $t(t,e,r){const n=e==null?t:new Date(t.toLocaleString("en-US",{timeZone:e})),s=r==null?t:new Date(t.toLocaleString("en-US",{timeZone:r}));return new Date(t.getTime()+s.getTime()-n.getTime())}function te(t,e){t=$t(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),s=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),u=t.getUTCMinutes().toString().padStart(2,"0"),o=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${s} ${i}:${u}:${o}`}let Xe=0;const bt=new WeakMap;function L(t){if(bt.has(t))return bt.get(t);const e=Xe++;return bt.set(t,e),e}function q(t,e,r){if(t==null)return null;if(e==null||t.length<=e)return t;const n=r?.appendEllipsis?"…":"",s=n.length+(r?.appendTruncatedLength?String(t.length).length+2:0),i=Math.max(0,e-s),u=r?.appendTruncatedLength?`(${t.length-i})`:"";return i<=0?u+n:r?.fromStart?u+n+t.slice(t.length-i):t.slice(0,i)+n+u}function Ft(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:s,filter:i,maxDepth:u,maxItems:o,maxStringLength:a,showObjectId:c,showArrayIndex:f,customToString:b}=e??{};if(r==null&&(r=[]),n==null&&(n=new Set),b){const h=b(t,r,l=>k(l,e,r,n));if(h!=null)return q(h,a,e?.truncateOptions)}const y=r.length;if(typeof t=="string")return t=q(t,a,e?.truncateOptions),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??""}#${L(t)}[${t.byteLength}]`;if(t instanceof RegExp)return q(String(t),a,e?.truncateOptions);if(t instanceof Date)return te(t);if(t instanceof Object){if(n.has(t)||u!=null&&y>=u)return`${t.constructor===Object?"":t.constructor?.name??""}#${L(t)}`;n.add(t)}if(t instanceof Error)return q(t.stack||t.message||String(t),a,e?.truncateOptions);if(Array.isArray(t)){const h=s?" ".repeat(y):"";let l="";c&&(l+=`#${L(t)} `),l+="[";let m=0,O=!1;for(let _=0;_<t.length;_++){if(o!=null&&m>=o){O=!0;break}const S=[...r,String(_)],E=Ft(t,_);if(i!=null&&!i(S,E))continue;const F=k(E,e,S,n);m>0&&(l+=","),s&&(l+=`
|
|
2
|
-
`),s&&(l+=`${h} `),f&&(l+=`${_}: `),l+=`${F}`,m++}return O?(m>0&&(l+=","),s?(l+=`
|
|
3
|
-
`,l+=`${h} ...
|
|
4
|
-
`):l+="...",l+=h,l+="]"):(m>0&&s&&(l+=`
|
|
5
|
-
${h}`),l+="]"),l}if(t instanceof Map){let h="";return c&&(h+=`#${L(t)} `),h+="Map",h+=k(Array.from(t.entries()),e,r,n),h}if(t instanceof Set){let h="";return c&&(h+=`#${L(t)} `),h+="Set",h+=k(Array.from(t.values()),e,r,n),h}{const h=t.constructor===Object?"":t.constructor?.name??"",l=s?" ".repeat(y):"";let m=h?`${h} `:"";c&&(m+=`#${L(t)} `),m+="{";let O=0,_=!1;for(const S in t){if(o!=null&&O>=o){_=!0;break}const E=[...r,S],F=Ft(t,S);if(i!=null&&!i(E,F))continue;const g=k(F,e,E,n);O>0&&(m+=","),s&&(m+=`
|
|
6
|
-
`),s&&(m+=`${l} `),m+=`${S}: ${g}`,O++}return _&&(O>0&&(m+=","),s?(m+=`
|
|
7
|
-
`,m+=`${l} ...
|
|
8
|
-
`):m+="...",m+=l),O>0&&s&&!_&&(m+=`
|
|
9
|
-
${l}`),m+="}",m}}function ee(t,e){t=$t(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),s=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),u=t.getUTCMinutes().toString().padStart(2,"0"),o=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${s}_${i}-${u}-${o}`}function Ye(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return"&rt;";case'"':return""";default:return"'"}})}function Qe(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function xt(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,r=[];for(let n=0;n<e;n++)r.push(xt(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]=xt(t[r]));return e}return t}function H(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(!H(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)&&!H(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)&&!H(e[r],null))return!1;return!0}return!1}function Ze(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(!H(n,e.get(r)))return!1;return!0}function tr(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 Ot(t){return!t||typeof t!="object"?t:Array.isArray(t)?t.map(Ot):t&&Object.keys(t).sort().reduce((e,r)=>{const n=Ot(t[r]);return n!=null&&(e[r]=n),e},{})}function er(t,e){return Object.defineProperty(t,"name",{value:e,configurable:!0}),t}function rr(t){const e=alert;return window.alert=r=>t(e,r),()=>{window.alert=e}}var v=(t=>(t.log="log",t.warn="warn",t.error="error",t.info="info",t.debug="debug",t.trace="trace",t.assert="assert",t))(v||{});const vt=Object.values(v);function P(t){return function(){t.apply(console,arguments)}}const Vt={log:P(console.log),warn:P(console.warn),error:P(console.error),info:P(console.info),debug:P(console.debug),trace:P(console.trace),assert:P(console.assert)};function Mt(t){return vt.forEach(e=>{console[e]=(...r)=>{t(Vt,e,r)}}),()=>{vt.forEach(e=>{console[e]=Vt[e]})}}function nr(t){return function(r){let n=null;const i=Mt((o,a,c)=>{try{t(o,a,c)}catch(f){throw n||(n=f),f}}),u=()=>{if(i(),n)throw n};try{const o=r();return U.isPromiseLike(o)?o.then(a=>(u(),a),a=>{throw u(),a}):(u(),o)}catch(o){throw u(),o}}}class At{_listeners=new Map;_listenersAdd=new Map;_startStopNotifier;_emit;_update;_unsubscribeNotifier=null;_emitLast;_hasLast;_last=void 0;_emitting=!1;_subscribing=!1;_actionOnCycle;constructor({emitLastEvent:e,startStopNotifier:r,hasLast:n,last:s,actionOnCycle:i}={}){this._startStopNotifier=r??null,this._emit=r?u=>this.emit(u):null,this._update=r?u=>this.update(u):null,this._emitLast=e??!1,this._hasLast=n??!1,this._last=s,this._actionOnCycle=i??!1}get hasLast(){return this._hasLast}get last(){return this._last}get hasListeners(){return this._listeners.size>0}subscribe(e){const r={};if(this._emitting?this._listenersAdd.set(r,e):this._listeners.set(r,e),this._subscribing&&this._actionOnCycle==="throw")throw new Error("[Rx][Subject] Circular subscription detected");if((this._hasLast||this._subscribing&&this._actionOnCycle==="emitLast")&&e(this._last),this._startStopNotifier&&this._listeners.size+this._listenersAdd.size===1)try{this._subscribing=!0,this._unsubscribeNotifier=this._startStopNotifier(this._emit,this._update)??null}finally{this._subscribing=!1}return()=>{if(this._listeners.delete(r),this._listenersAdd.delete(r),this._startStopNotifier&&this._listeners.size===0&&this._listenersAdd.size===0){const n=this._unsubscribeNotifier;this._unsubscribeNotifier=null,n?.()}}}emit(e){if(this._emitting){if(this._actionOnCycle==="throw")throw new Error("[Rx][Subject] Circular emit detected");this._actionOnCycle==="emitLast"&&(this._last=e,this._hasLast=!0);return}const r=()=>{this._listenersAdd.size>0&&(this._listenersAdd.forEach((n,s)=>{this._listeners.set(s,n)}),this._listenersAdd.clear()),this._emitting=!1};try{this._emitting=!0,this._emitLast&&(this._last=e,this._hasLast=!0);let n;if(this._listeners.forEach(s=>{const i=s(e);U.isPromiseLike(i)&&(n||(n=[]),n.push(i))}),n)return Promise.all(n).then(r,s=>{throw r(),s});r()}catch(n){throw r(),n}}update(e){if(!this._emitLast)throw new Error("[Rx][Subject] update available only for subjects with emitLastEvent");const r=e(this._last);return this.emit(r)}}function sr(t,e){return k(t,{maxDepth:5,maxItems:10,...e})}function ir(t){return t.map(e=>e&&typeof e=="object"?sr(e):e)}function or(t){return`${ee(new Date)} [${t.level.toUpperCase()}] ${ir(t.args).join(" ")}`}let ft=null,wt=null;function re(){return wt||(wt=new At({startStopNotifier:t=>(ft=t,()=>{ft=null})})),wt}function ur(){return Mt((t,e,r)=>{e==="assert"&&r[0]===!0||(e===v.error||e===v.warn||e===v.assert)&&(ft&&ft({date:Date.now(),level:e,args:r}),t[e](...r))})}function ar(t){if(typeof window>"u")return U.EMPTY_FUNC;const{levels:e,predicate:r}=t;return re().subscribe(n=>{if(e&&!e.includes(n.level))return;const s=n.args.join(`
|
|
10
|
-
`);r&&!r({text:s,message:n})||alert(s)})}var Tt=(t=>(t[t.none=0]="none",t[t.error=1]="error",t[t.warn=2]="warn",t[t.debug=3]="debug",t))(Tt||{});function ne(){let t=new Error().stack;if(t!=null){const e=t.indexOf(`
|
|
11
|
-
`);e!=null&&e>=0&&(t=t.substring(e+1))}return t??""}function cr(t){return function(...e){const r=ne();try{return t.apply(this,e)}catch(n){throw n instanceof Error||(n=new Error(String(n))),n.stack=n.stack?n.stack+`
|
|
12
|
-
`+r:r,n}}}function se(t){if(!t||t.timeout==null)return null;const e=new ct.AbortControllerFast,r=t.timeController??zt.timeControllerDefault;if(t.timeout){const n=r.setTimeout(()=>{e.abort(new ct.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 lr(t,e){const r=se(e);try{return await t(r?.signal??e?.abortSignal??null)}finally{r?.abort()}}class fr{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const r=s=>(this._options.persist?this._promiseOrValue=s:(this._promiseOrValue=null,this._hasValue=!1),s),n=s=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),s};if(U.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 hr{_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),s=i=>{throw this._options.persist||this._promiseOrValues.delete(e),i};if(U.isPromiseLike(r))r=r.then(n,s);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)}}async function mr(t){const e=t.abortSignal??null,r=t.timeController??zt.timeControllerDefault;let n=0;for(;;)try{return await t.func({abortSignal:e})}catch(s){if((t.logLevel==null||t.logLevel>=Tt.error)&&console.error("[withRetry] error",s),e?.aborted)throw s;const i=t.delay({error:s,retryCount:n++,abortSignal:e});if(i==null||(typeof i=="number"?await U.delay(i,e??void 0,r):await i(),e?.aborted))throw s}}function dr({maxRetries:t,delays:e,isRetriableError:r}){return function({retryCount:s,error:i}){if(s==null||t!=null&&s>=t)return null;if(r==null||r(i)){if(Array.isArray(e))return e[Math.min(s,e.length-1)];{const u=e.mult??2;return Math.min(e.min*u**s,e.max)}}return null}}function pr(t){return t!=null&&typeof t=="object"&&typeof t.subscribe=="function"}class yr{_subjects=new Map;_getLastEvent;constructor({getLastEvent:e}={}){this._getLastEvent=e}subscribe(e,r){let n=this._subjects.get(e);n||(n=new At,this._subjects.set(e,n));const s=n.subscribe(r);if(this._getLastEvent){const i=this._getLastEvent(e);r(i)}return()=>{s(),n?.hasListeners||this._subjects.delete(e)}}emit(e,r){const n=this._subjects.get(e);if(n)return n.emit(r)}forEach(e){this._subjects.forEach(e)}observable(e){return{subscribe:r=>this.subscribe(e,r)}}emitter(e){return{emit:r=>this.emit(e,r)}}subject(e){return{subscribe:r=>this.subscribe(e,r),emit:r=>this.emit(e,r)}}}function gr(t,e,r){return new Promise(n=>{let s=!1,i;function u(f){a?.(),i?.(),s=!0,n(f)}function o(f){a?.(),i?.(),s=!0,n(Promise.reject(f))}const a=r?.subscribe(o);let c=!0;i=t.subscribe(f=>{(!e||e(f,c))&&u(f),c=!1}),s&&i?.()})}class R extends Error{constructor(e){super(e)}}class d{_args;constructor(e){this._args=e&&{...e}}set(e){return this._args={...this._args??{},...e},this}name(e){return this.set({name:e})}toString(e){const r=this._args?.name;return r?typeof r=="string"?r:r(e):this.nameDefault(e)}}function ie(t,e){return k(t,{maxDepth:1,maxItems:5,...e})}function D(t){return t instanceof d}function Y(t){return ie(t)}function ht(t,...e){if(t==null)return"";const r=ie(t,{filter:(n,s)=>{if(n.length===0)return!0;if(n.length!==1)return!1;const i=n[0];return!(i==="name"||i==="expected"||s==null||s===!1||e.includes(i))}});return/^(#\d+\s*)\{}$/.test(r)?"":`(${r})`}function J(t){const{result:e,cause:r,nested:n,error:s}=t;if(s){if(!(s instanceof Error))throw new R(`[test][validateMatchResult] error must be an instance of Error, but it is: ${s}`);if(e!=null)throw new R(`[test][validateMatchResult] result must be null if error is set, but it is: ${e}`);if(r!=null)throw new R(`[test][validateMatchResult] cause must be null if error is set, but it is: ${r}`);if(n!=null)throw new R(`[test][validateMatchResult] nested must be null if error is set, but it is: ${n}`);return t}if(typeof e!="boolean")throw new R(`[test][validateMatchResult] result must be a boolean, but it is: ${e}`);if(typeof r!="string"&&r!=null)throw new R(`[test][validateMatchResult] cause must be a string or null, but it is: ${r}`);if(n!=null&&!(n instanceof Array))throw new R(`[test][validateMatchResult] nested must be an array or null, but it is: ${n}`);return t}function oe(t,e,r){return J({actual:t,expected:e,result:null,cause:null,nested:null,error:r})}function It(t,e,r){return J({actual:t,expected:e,result:r,cause:null,nested:null,error:null})}function Ct(t,e,r){return typeof r=="boolean"?It(t,e,r):J(typeof r=="string"?{actual:t,expected:e,result:!1,cause:r,nested:null,error:null}:{actual:t,expected:e,result:r.result,cause:r.cause??null,nested:r.nested??null,error:null})}function $(t,e){try{if(D(e)){const r=e.match(t);return Ct(t,e,r)}return It(t,e,t===e)}catch(r){return oe(t,e,r)}}class Nt extends d{match(e){const r=this._args.expected,n=$(e,r);return{result:!n.result,nested:[{actualKey:null,result:n}]}}nameDefault(){return"not"}}function ue(t,e){const r=Rt(t.result,e);return r?{actualKey:t.actualKey,expectedKey:t.expectedKey,result:r}:null}function Rt(t,e){if(e?!t.result:t.result)return null;t.expected instanceof Nt&&(e=!e);let r=null;return t.nested&&t.nested.forEach(n=>{const s=ue(n,e);s&&(r||(r=[]),r.push(s))}),{actual:t.actual,expected:t.expected,result:t.result,cause:t.cause,nested:r,error:t.error}}function ae(t,e){const r=kt(t.result,e+" ");return`${e}${t.actualKey==null?"| ":t.actualKey+": "}${r}`}function kt(t,e){if(t.result)return t.expected.toString();let r="";t.nested&&(r=t.nested.map(s=>ae(s,e)).join(`
|
|
13
|
-
`));let n=t.cause||"";return r?(n||(n=D(t.expected)?t.expected.toString(t.actual):""),`${n}
|
|
14
|
-
${r}`):`${n}
|
|
15
|
-
${e}expected: ${D(t.expected)?t.expected.toString(t.actual):t.expected}
|
|
16
|
-
${e}actual: ${Y(t.actual)}`}class Dt extends Error{constructor(e){super(e)}}function W(t){return function(r,n){const s=$(t,r);if(s.error)throw s.error;const i=Rt(s,!1);if(!i)return;const u=kt(i,"");console.log(`[test][check] CheckError:
|
|
17
|
-
`+u);const o=new Dt(u);throw n?.(o),o}}function br(t){return function(r,n){let s;try{s=t()}catch(i){W(i)(n);return}return U.isPromiseLike(s)?s.then(i=>(W(i)(r),i)).catch(i=>{if(i instanceof Dt)throw i;try{W(i)(n)}catch(u){throw console.error("[test][check] error",u),i}}):(W(s)(r),s)}}const Q=10;class Ut extends d{match(e){if(e==null)return`Expected array, got "${e}"`;if(typeof e!="object")return`Expected array, got "${typeof e}"`;if(!(e instanceof Array))return"Expected array";const r=this._args?.expected;if(r==null)return!0;const n=this._args?.maxReportItems??Q,s=this._args?.matchType||"equals";if(s==="equals"){if(e.length!==r.length)return`Expected array length to be ${r.length}, got ${e.length}`;let i=!0,u=0,o=0;const a=[];for(let c=0;c<r.length;c++){const f=e[c],b=r[c],y=$(f,b);if(y.result?(u<n&&a.push({actualKey:c,expectedKey:c,result:y}),u++):(o<n&&a.push({actualKey:c,expectedKey:c,result:y}),o++,i=!1),!i&&u>=n&&o>=n)break}return{result:i,nested:a}}if(s==="includes"){let i=!0;const u=[];let o=0,a=0;for(let c=0;c<r.length;c++){const f=r[c];let b=!1;for(let y=0;y<e.length;y++){const h=e[y],l=$(h,f);if(l.result){b=!0,o<n&&u.push({actualKey:y,expectedKey:c,result:l}),o++;break}}if(b||(i=!1,a<n&&u.push({expectedKey:c,result:{result:!1,actual:void 0,expected:f}}),a++),!i&&o>=n&&a>=n)break}return{result:i,nested:u}}return`Unknown matchType "${s}"`}nameDefault(){return`array ${this._args?.matchType||"equals"} ${Y(this._args?.expected)}`}}class ce extends d{match(){return!0}nameDefault(){return"any"}}class le extends d{match(e){if(typeof e!="object")return`Expected array, got "${typeof e}"`;if(!(e instanceof Array))return"Expected array";const r=this._args.expected;let n=!0;const s=[],i=this._args?.maxReportItems??Q;let u=0,o=0;for(let a=0;a<e.length;a++){const c=e[a],f=$(c,r);if(f.result?(u<i&&s.push({actualKey:a,expectedKey:a,result:f}),u++):(o<i&&s.push({actualKey:a,expectedKey:a,result:f}),o++,n=!1),!n&&u>=i&&o>=i)break}return{result:n,nested:s}}nameDefault(){return"array item"}}class fe extends d{match(e){const{expected:r,convert:n}=this._args,s=$(n(e),r),i=[{result:s}];return{result:s.result,nested:i}}nameDefault(){return"convert"}}class jt extends d{match(e){const{expected:r,nonStrict:n}=this._args;return n?e==r:e===r}nameDefault(){return`is(${Y(this._args.expected)})`}}class he extends d{match(e){if(e==null)return`Expected number, got "${e}"`;if(typeof e!="number")return`Expected number, got "${typeof e}"`;if(this._args==null)return Number.isFinite(e)?!0:"Expected finite number";if(!this._args.allowNaN&&Number.isNaN(e))return"Expected not NaN";if(!this._args.allowInfinity&&!Number.isFinite(e))return"Expected not Infinity";const{min:r,max:n,float:s}=this._args;return!s&&!Number.isInteger(e)?`Expected integer, got "${e}"`:r!=null&&e<r?`Expected number to be >= ${r}, got ${e}`:n!=null&&e>n?`Expected number to be <= ${n}, got ${e}`:!0}nameDefault(){return`number(${ht(this._args)})`}}class me extends d{match(e){if(e==null)return`Expected object, got "${e}"`;if(Array.isArray(e))return"Expected object, got array";if(typeof e!="object")return`Expected object, got "${typeof e}"`;const r=this._args?.expected;if(r==null)return!0;let n=!0;const s=[],i=this._args?.maxReportItems??Q;let u=0,o=0;for(const a in r){if(!Object.prototype.hasOwnProperty.call(r,a))continue;const c=e[a],f=r[a],b=$(c,f);if(b.result?(u<i&&s.push({actualKey:a,expectedKey:a,result:b}),u++):(o<i&&s.push({actualKey:a,expectedKey:a,result:b}),o++,n=!1),!n&&u>=i&&o>=i)break}if(!this._args?.ignoreExtraKeys)for(const a in e){if(!Object.prototype.hasOwnProperty.call(e,a)||Object.prototype.hasOwnProperty.call(r,a))continue;const c=e[a];if(o<i&&s.push({actualKey:a,expectedKey:a,result:Ct(c,void 0,"Unexpected key")}),o++,n=!1,o>=i)break}return{result:n,nested:s}}nameDefault(){return"object"+ht(this._args)}}class de extends d{match(e){if(e==null)return`Expected string, got ${e}`;if(typeof e!="string")return`Expected string, got "${typeof e}"`;if(this._args==null)return!0;const{pattern:r}=this._args;if(r!=null){if(typeof r=="function")return r(e);if(!r.test(e))return!1}return!0}nameDefault(){return this._args?.pattern?`string(${this._args.pattern})`:"string"}}class pe extends d{match(e){const r=this._args.expected;return e instanceof r?!0:`Expected instance of "${r}", got "${e}"`}nameDefault(){return`instanceOf(${this._args.expected.name})`}}class ye extends d{constructor(e){super({...e,expected:e.expected instanceof Set?e.expected:new Set(e.expected)})}match(e){return!!this._args.expected.has(e)}nameDefault(){return`in(${Y(this._args.expected)})`}}class Z extends d{match(e){const{type:r,expecteds:n,pipe:s}=this._args;let i=r==="and";const u=[];for(let o=0;o<n.length;o++){const a=n[o],c=$(e,a);if(u.push({actualKey:`<${r} ${o}>`,expectedKey:`<${r} ${o}>`,result:c}),r==="or"){if(c.result&&(i=!0,s))break}else if(r==="and"){if(!c.result&&(i=!1,s))break}else throw new Error(`[test][MatcherFew] Unknown type "${r}"`)}return{result:n.length===0||i,nested:u}}nameDefault(){return this._args.type}}class ge extends d{match(e){const r=this._args.matcher;return D(r)?r.match(e):r(e)}nameDefault(e){const r=this._args.name;return typeof r=="string"?r:r?r(e):"custom"}}class be extends d{match(){return!1}nameDefault(){return"never"}}class we extends d{match(e){if(e==null)return`Expected object, got "${e}"`;if(Array.isArray(e))return"Expected object, got array";if(typeof e!="object")return`Expected object, got "${typeof e}"`;const r=this._args?.expected;if(r==null)return!0;let n=!0;const s=[],i=this._args?.maxReportItems??Q;let u=0,o=0;for(const a in e){if(!Object.prototype.hasOwnProperty.call(e,a))continue;const c=[a,e[a]],f=$(c,r);if(f.result?(u<i&&s.push({actualKey:a,expectedKey:a,result:f}),u++):(o<i&&s.push({actualKey:a,expectedKey:a,result:f}),o++,n=!1),!n&&u>=i&&o>=i)break}return{result:n,nested:s}}nameDefault(){return"object entries"+ht(this._args)}}class _e extends d{_hasExpected=!1;_expected=void 0;get expected(){return this._expected}set expected(e){this._expected=e,this._hasExpected=!0}match(e){const r=$(e,this._expected),n=[{result:r}];return{result:r.result,nested:n}}nameDefault(){return"ref"}}function j(t){return new Ut({expected:t})}function wr(t){return new Ut({expected:t,matchType:"includes"})}function V(){return new ce}function _r(){return new _e}function xr(t){return new be({name:t})}function Or(t,e){const r=new le({expected:e});return t==null?r:M($e(D(t)||typeof t=="number"?t:tt(t)),r).name("array item")}function I(t,e,r){return new fe({name:t,convert:e,expected:r})}function xe(t){return new jt({expected:t,nonStrict:!0})}function Oe(t){return new jt({expected:t,nonStrict:!1})}function Pt(t){return new he(t)}function tt(t){return Pt({...t,float:!1})}function Sr(t){return Pt({...t,float:!0})}function C(t){return new me({expected:t})}function ut(t,e,r=null){if(t instanceof d||e&&(t=e(t,r),t instanceof d))return t;if(t==null)return X();if(Array.isArray(t)){const n=t.map((s,i)=>ut(s,e,i));return j(n)}if(t.constructor===Object){const n={};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=ut(t[s],e,s));return C(n)}return t instanceof U.ValueState?Ie({...t,value:ut(t.value,e,"value")}):Oe(t)}function Er(t){return C(t).set({ignoreExtraKeys:!0})}function Lt(t){return new de({pattern:t})}function $r(t){return new pe({expected:t})}function Se(t){return I("typeof",e=>e===null?"null":typeof e,t)}function Mr(t){return I("constructor",e=>e.constructor,t)}function at(){return Se("boolean")}function X(){return xe(null)}function Ar(){return Te(X())}function Tr(...t){return new Z({expecteds:t,type:"or",pipe:!1})}function Ir(...t){return new Z({expecteds:t,type:"and",pipe:!1})}function Ee(...t){return new Z({expecteds:t,type:"or",pipe:!0})}function M(...t){return new Z({expecteds:t,type:"and",pipe:!0})}function K(t,e){return e==null?Ee(X(),t):e?t:X()}function $e(t){const e=typeof t=="number"||D(t)?t:tt(t??{min:1});return M(j(),I("length",r=>r.length,e)).name("array length")}function Cr(t){const e=typeof t=="number"||D(t)?t:tt(t??{min:1});return M(Lt(),I("length",r=>r.length,e)).name("string length")}function Nr(t){return M(C(),t)}function Rr(t){return M(j(),t)}function kr(t){return M(C(),I("keys",e=>Object.keys(e),t))}function Dr(t){return M(C(),I("values",e=>Object.values(e),t))}function Ur(t){return M(C(),I("entries",e=>Object.entries(e),t))}function mt(t){return new we({expected:t})}function jr(t){return mt(j([t,V()]))}function Pr(t){return mt(j([V(),t]))}function Lr(t,e){return mt(j([t,e]))}function Kr(t){return M(C(),I("keys not null",e=>Object.keys(e).filter(r=>e[r]!=null),t))}function Me(t){return new ye({expected:t})}function Fr(t){return Me(Object.values(t))}function Kt(t,e){return new ge({matcher:e,name:t})}const vr=Math.ceil(Date.now()-10*365.25*24*60*60*1e3),Vr=Math.ceil(Date.now()+10*365.25*24*60*60*1e3);function G(t){return tt({...t,min:t?.min??vr,max:t?.max??Vr}).name("int date")}function Ae(t){const e={min:t?.from?.min??t?.common?.min,max:t?.from?.max??t?.common?.max,float:t?.from?.float??t?.common?.float,optional:t?.from?.optional??t?.common?.optional},r={min:t?.to?.min??t?.common?.min,max:t?.to?.max??t?.common?.max,float:t?.to?.float??t?.common?.float,optional:t?.to?.optional??t?.common?.optional};return M(j([e.optional?K(G()):G(),r.optional?K(G()):G()]),Kt("min <= max",n=>n[0]!=null&&n[1]!=null&&n[0]>n[1]?`Expected range to be [min, max], got [${n.join(", ")}]`:!0)).name("range")}function Br(t){return Ae({...t,common:{min:new Date(2020,0,1).getTime(),max:Date.now()+900*1e3,...t?.common}}).name("range date")}function Te(t){return new Nt({expected:t})}function zr(){return Lt(/^[\da-f-]{36}|[\da-f]{32}$/i).name("uuid")}function Ie(t){return C({[Symbol.toStringTag]:K(V()),loading:K(at()),hasValue:K(at()),value:V(),hasError:K(at()),error:V(),...t})}function qr(t){return t!=null&&typeof t=="string"&&(t=new TextEncoder().encode(t).buffer),Kt("array buffer",e=>{if(e==null||typeof e!="object"||typeof e.byteLength!="number")return`Expected array buffer, got "${e}"`;if(t==null)return!0;if(e.byteLength!==t.byteLength)return`Expected array buffer length to be ${t.byteLength}, got ${e.byteLength}`;for(let r=0,n=t.byteLength;r<n;r++)if(e[r]!==t[r])return`Expected array buffer[${r}] to be ${t[r]}, got ${e[r]}`;return!0})}function Bt(t){return t.replace(/\W/g,"").toLowerCase()}function Ce(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 Ne(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 Re(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function ke(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function dt(t,e){const r=Ce(e),n=Bt(t);for(const[s,i]of r.entries())if(Bt(s)===n)return i;return null}function Wr(t,e){return Ne(dt(t,e))}function Gr(t,e){return Re(dt(t,e))}function Hr(t,e){return ke(dt(t,e))}exports.CheckError=Dt;exports.ConsoleMessageLevel=v;exports.Lazy=fr;exports.LazyWithId=hr;exports.LogLevel=Tt;exports.MAX_REPORT_ITEMS_DEFAULT=Q;exports.MatchInternalError=R;exports.Matcher=d;exports.MatcherAny=ce;exports.MatcherArray=Ut;exports.MatcherArrayItem=le;exports.MatcherConvert=fe;exports.MatcherCustom=ge;exports.MatcherFew=Z;exports.MatcherIn=ye;exports.MatcherInstanceOf=pe;exports.MatcherIs=jt;exports.MatcherNever=be;exports.MatcherNot=Nt;exports.MatcherNumber=he;exports.MatcherObject=me;exports.MatcherObjectEntry=we;exports.MatcherRef=_e;exports.MatcherString=de;exports.Random=lt;exports.Subject=At;exports.SubjectWithId=yr;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=ot;exports.alertConsole=ar;exports.alertReplace=rr;exports.argsToString=ht;exports.check=W;exports.checkFunc=br;exports.consoleIntercept=ur;exports.consoleMessageToString=or;exports.consoleReplace=Mt;exports.convertTimeZone=$t;exports.createMatchResult=Ct;exports.createMatchResultBoolean=It;exports.createMatchResultError=oe;exports.createTaskDelayRetry=dr;exports.createUniquePseudoRandom=Ge;exports.dateNowUnique=He;exports.deepCloneJsonLike=xt;exports.deepEqualJsonLike=H;exports.deepEqualJsonLikeMap=Ze;exports.equalArray=tr;exports.escapeHtml=Ye;exports.escapeRegExp=Qe;exports.expectedToString=Y;exports.filterMatchResult=Rt;exports.filterMatchResultNested=ue;exports.fixStackTrace=cr;exports.formatAny=k;exports.formatDate=te;exports.formatDateFileName=ee;exports.getConsoleMessages=re;exports.getDateInet=Je;exports.getNormalizedObject=Ot;exports.getObjectId=L;exports.getRandomFunc=Yt;exports.getRandomSeed=Ve;exports.getStackTrace=ne;exports.isMatcher=D;exports.isObservable=pr;exports.match=$;exports.matchAnd=Ir;exports.matchAndPipe=M;exports.matchAny=V;exports.matchArray=j;exports.matchArrayBuffer=qr;exports.matchArrayIncludes=wr;exports.matchArrayItem=Or;exports.matchArrayLength=$e;exports.matchArrayWith=Rr;exports.matchBoolean=at;exports.matchConstructor=Mr;exports.matchConvert=I;exports.matchCustom=Kt;exports.matchDeep=ut;exports.matchEnum=Fr;exports.matchFloat=Sr;exports.matchIn=Me;exports.matchInstanceOf=$r;exports.matchInt=tt;exports.matchIntDate=G;exports.matchIs=Oe;exports.matchIsNonStrict=xe;exports.matchNever=xr;exports.matchNot=Te;exports.matchNotNullish=Ar;exports.matchNullish=X;exports.matchNumber=Pt;exports.matchObject=C;exports.matchObjectEntries=Ur;exports.matchObjectEntry=mt;exports.matchObjectKey=jr;exports.matchObjectKeyValue=Lr;exports.matchObjectKeys=kr;exports.matchObjectKeysNotNull=Kr;exports.matchObjectPartial=Er;exports.matchObjectValue=Pr;exports.matchObjectValues=Dr;exports.matchObjectWith=Nr;exports.matchOptional=K;exports.matchOr=Tr;exports.matchOrPipe=Ee;exports.matchRange=Ae;exports.matchRangeDate=Br;exports.matchRef=_r;exports.matchResultNestedToString=ae;exports.matchResultToString=kt;exports.matchString=Lt;exports.matchStringLength=Cr;exports.matchTypeOf=Se;exports.matchUuid=zr;exports.matchValueState=Ie;exports.max=Xt;exports.min=Jt;exports.minMax=Le;exports.numberMod=Ke;exports.randomBoolean=Be;exports.randomEnum=We;exports.randomFloat=St;exports.randomIndexWeighted=ze;exports.randomInt=Qt;exports.randomItem=Et;exports.randomItems=qe;exports.setFuncName=er;exports.sha256=Pe;exports.sha256Buffer=Ht;exports.timeoutAbortController=se;exports.toHex=qt;exports.truncateString=q;exports.urlGetBoolean=Wr;exports.urlGetFloat=Hr;exports.urlGetInt=Gr;exports.urlGetParams=Ce;exports.urlGetString=dt;exports.urlParamToBoolean=Ne;exports.urlParamToFloat=ke;exports.urlParamToInt=Re;exports.validateMatchResult=J;exports.waitObservable=gr;exports.withConsoleReplace=nr;exports.withRetry=mr;exports.withTimeout=lr;
|