@remotex-labs/xjet 1.0.1 → 1.1.0
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/README.md +1 -0
- package/dist/bash.js +16 -16
- package/dist/bash.js.map +5 -5
- package/dist/index.d.ts +441 -90
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/shared.d.ts +337 -0
- package/dist/shared.js +59 -59
- package/dist/shared.js.map +5 -5
- package/package.json +4 -4
package/dist/shared.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)?null:`"${t}"`:typeof t=="number"?`${Number.isFinite(t)?t:t.toString()}`:typeof t=="boolean"?`${t}`:typeof t=="symbol"?`${t.toString()}`:typeof t=="bigint"?`${t}n`:typeof t=="function"?`[Function: ${t.name||"anonymous"}]`:t===null?"null":t===void 0?"undefined":
|
|
3
|
-
`);e.push('String "');for(let a of s)e.push(`${r}${a}`);e.push('"');return}if(typeof t=="object"&&t!==null){if(i.has(t)){e.push("[Circular]");return}i.add(t),t instanceof Map
|
|
1
|
+
var wi=Object.create;var De=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var lt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ne=t=>{throw TypeError(t)};var Ai=(t,e,r)=>e in t?De(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var o=(t,e)=>De(t,"name",{value:e,configurable:!0});var de=t=>[,,,wi(t?.[lt("metadata")]??null)],ut=["class","method","getter","setter","accessor","field","value","get","set"],ie=t=>t!==void 0&&typeof t!="function"?ne("Function expected"):t,$i=(t,e,r,i,n)=>({kind:ut[t],name:e,metadata:i,addInitializer:s=>r._?ne("Already initialized"):n.push(ie(s||null))}),Ii=(t,e)=>Ai(e,lt("metadata"),t[3]),me=(t,e,r,i)=>{for(var n=0,s=t[e>>1],a=s&&s.length;n<a;n++)e&1?s[n].call(r):i=s[n].call(r,i);return i},ge=(t,e,r,i,n,s)=>{var a,c,l,h,g,f=e&7,k=!!(e&8),y=!!(e&16),T=f>3?t.length+1:f?k?1:2:0,te=ut[f+5],re=f>3&&(t[T-1]=[]),Pe=t[T]||(t[T]=[]),O=f&&(!y&&!k&&(n=n.prototype),f<5&&(f>3||!y)&&Si(f<4?n:{get[r](){return at(this,s)},set[r](C){return ct(this,s,C)}},r));f?y&&f<4&&o(s,(f>2?"set ":f>1?"get ":"")+r):o(n,r);for(var Fe=i.length-1;Fe>=0;Fe--)h=$i(f,r,l={},t[3],Pe),f&&(h.static=k,h.private=y,g=h.access={has:y?C=>Ci(n,C):C=>r in C},f^3&&(g.get=y?C=>(f^1?at:Ri)(C,n,f^4?s:O.get):C=>C[r]),f>2&&(g.set=y?(C,Ne)=>ct(C,n,Ne,f^4?s:O.set):(C,Ne)=>C[r]=Ne)),c=(0,i[Fe])(f?f<4?y?s:O[te]:f>4?void 0:{get:O.get,set:O.set}:n,h),l._=1,f^4||c===void 0?ie(c)&&(f>4?re.unshift(c):f?y?s=c:O[te]=c:n=c):typeof c!="object"||c===null?ne("Object expected"):(ie(a=c.get)&&(O.get=a),ie(a=c.set)&&(O.set=a),ie(a=c.init)&&re.unshift(a));return f||Ii(t,n),O&&De(n,r,O),y?f^4?s:O:n};var ze=(t,e,r)=>e.has(t)||ne("Cannot "+r),Ci=(t,e)=>Object(e)!==e?ne('Cannot use the "in" operator on this value'):t.has(e),at=(t,e,r)=>(ze(t,e,"read from private field"),r?r.call(t):e.get(t));var ct=(t,e,r,i)=>(ze(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r),Ri=(t,e,r)=>(ze(t,e,"access private method"),r);var Li={dim:[2,22],bold:[1,22],reset:[0,0],hidden:[8,28],inverse:[7,27]},Oi={red:[31,39],gray:[90,39],blue:[34,39],cyan:[36,39],black:[30,39],white:[37,39],green:[32,39],yellow:[33,39],magenta:[35,39],redBright:[91,39],blueBright:[94,39],cyanBright:[96,39],whiteBright:[97,39],greenBright:[92,39],blackBright:[90,39],yellowBright:[93,39],magentaBright:[95,39],darkGray:["38;5;238",39],lightGray:["38;5;252",39],lightCyan:["38;5;81",39],lightCoral:["38;5;203",39],oliveGreen:["38;5;149",39],deepOrange:["38;5;166",39],brightPink:["38;5;197",39],lightOrange:["38;5;215",39],burntOrange:["38;5;208",39],lightYellow:["38;5;230",39],canaryYellow:["38;5;227",39],lightGoldenrodYellow:["38;5;221",39]},ji={bgRed:[41,49],bgBlue:[44,49],bgCyan:[46,49],bgGray:[100,49],bgBlack:[40,49],bgGreen:[42,49],bgWhite:[47,49],bgYellow:[43,49],bgMagenta:[45,49],bgRedBright:[101,49],bgBlueBright:[104,49],bgCyanBright:[106,49],bgBlackBright:[100,49],bgWhiteBright:[107,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgMagentaBright:[105,49]},ht={...Li,...Oi,...ji},ye="\x1B[",ve="m";function pt(t,e){if(globalThis.NO_COLOR)return e;let r=t.length;if(r===0)return e;if(r===1)return`${ye}${t[0][0]}${ve}${e}${ye}${t[0][1]}${ve}`;let i=new Array(r),n=new Array(r);for(let s=0;s<r;s++)n[s]=`${ye}${t[s][0]}${ve}`,i[r-s-1]=`${ye}${t[s][1]}${ve}`;return n.concat(e,i).join("")}o(pt,"I");function be(t,e,r,i){if(typeof e!="number"||typeof r!="number"||typeof i!="number")throw new Error(`RGB values must be numbers, received: r=${typeof e}, g=${typeof r}, b=${typeof i}`);let n=t==="fg"?38:48,s=t==="fg"?39:49;return[`${n};2;${e};${r};${i}`,s]}o(be,"y");function ft(t){let e=t.replace(/^#/,"").toLowerCase();if(!/^([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(e))throw new Error(`Invalid hex color format: "${t}". Expected 3 or 6 hex digits.`);if(e.length===3){let s=parseInt(e[0]+e[0],16),a=parseInt(e[1]+e[1],16),c=parseInt(e[2]+e[2],16);return[s,a,c]}let r=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),n=parseInt(e.slice(4,6),16);return[r,i,n]}o(ft,"_");function G(t=[]){let e=o((...i)=>{if(Array.isArray(i[0])&&"raw"in i[0]){let[n,...s]=i,a=n.reduce((c,l,h)=>c+l+(h<s.length?String(s[h]??""):""),"");return pt(t,a)}return pt(t,i.join(" "))},"e"),r={rgb:o((i,n,s)=>G([...t,be("fg",i,n,s)]),"rgb"),bgRgb:o((i,n,s)=>G([...t,be("bg",i,n,s)]),"bgRgb"),hex:o(i=>G([...t,be("fg",...ft(i))]),"hex"),bgHex:o(i=>G([...t,be("bg",...ft(i))]),"bgHex")};return new Proxy(e,{get(i,n){if(typeof n!="string")throw new Error(`Invalid property: ${String(n)}`);return n in ht?G([...t,ht[n]]):n in r?r[n]:Reflect.get(i,n)}})}o(G,"m");var F=G();var Bi=Object.defineProperty,u=o((t,e)=>Bi(t,"name",{value:e,configurable:!0}),"o");function xt(t,e){return e!=null&&(e.constructor===t||typeof e=="function")}o(xt,"nt");u(xt,"isA");function Ee(t,e){return t==null||typeof t!="object"&&typeof t!="function"?!1:e in t||Object.prototype.hasOwnProperty.call(t,e)}o(Ee,"X");u(Ee,"hasKey");function I(t){return!!t&&Ee(t,"expectedLabel")&&xt(Function,t.matches)}o(I,"b");u(I,"isAsymmetric");function Ke(t,e){let r=I(t),i=I(e);if(!(r&&i)){if(r)return t.matches(e);if(i)return e.matches(t)}}o(Ke,"ce");u(Ke,"asymmetricMatch");function Et(t,e,r=!0){if(Array.isArray(t)&&Array.isArray(e))return r&&t.length!==e.length?!1:t.every((s,a)=>x(s,e[a],r));let i=Object.keys(t),n=Object.keys(e);if(r&&i.length!==n.length)return!1;for(let s of i)if(!Ee(e,s)||!x(t[s],e[s],r))return!1;return!0}o(Et,"it");u(Et,"deepEquals");function x(t,e,r=!0){if(t===e||Object.is(t,e))return!0;if(t===null||e===null)return!1;let i=Ke(t,e);return i!==void 0?i:t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():t instanceof RegExp&&e instanceof RegExp?t.source===e.source&&t.flags===e.flags:globalThis.URL&&t instanceof globalThis.URL&&e instanceof globalThis.URL?t.href===e.href:typeof t=="object"&&typeof e=="object"?Et(t,e,r):!1}o(x,"g");u(x,"equals");function kt(t){let e={};for(let r of Object.keys(t)){let i=t[r];i&&(e[r]=i)}return e.name=t.name,e.stack=t.stack,e.message=t.message,e}o(kt,"de");u(kt,"serializesError");function Z(t){return t!=null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}o(Z,"me");u(Z,"isPromise");var wt=" ";function St(t){return typeof t=="string"?t.includes(`
|
|
2
|
+
`)?null:`"${t}"`:typeof t=="number"?`${Number.isFinite(t)?t:t.toString()}`:typeof t=="boolean"?`${t}`:typeof t=="symbol"?`${t.toString()}`:typeof t=="bigint"?`${t}n`:typeof t=="function"?`[Function: ${t.name||"anonymous"}]`:t===null?"null":t===void 0?"undefined":I(t)?t.expectedLabel??t.constructor.name:t instanceof Date?`[Date: ${t.toISOString()}]`:t instanceof RegExp?t.toString():t instanceof Error?`[${t.name}: ${t.message}]`:t instanceof Promise?"[Promise <pending>]":t instanceof ArrayBuffer?`ArrayBuffer { byteLength: ${t.byteLength} }`:t instanceof DataView?`DataView { byteLength: ${t.byteLength}, byteOffset: ${t.byteOffset} }`:null}o(St,"st");u(St,"serializePrimitive");function At(t){return t===null?"null":t===void 0?"undefined":typeof t=="object"?Object.prototype.toString.call(t):JSON.stringify(t)}o(At,"ot");u(At,"serializeMapKey");function se(t,e,r,i,n=""){if(t.length===0)return;if(t.length<2){let a=`${n}${r}${t[t.length-1]}`;e.push(i?a:`${a},`);return}e.push(`${n}${r}${t[0]}`);for(let a=1;a<t.length-1;a++)e.push(n+t[a]);let s=`${n}${t[t.length-1]}`;e.push(i?s:`${s},`)}o(se,"Q");u(se,"appendLines");function $t(t,e,r,i){if(t.size===0){e.push("Map {}");return}e.push("Map {");let n=Array.from(t.entries());n.forEach(([s,a],c)=>{let l=At(s),h=[];Q(a,h,r,i),se(h,e,`${l} => `,c===n.length-1,r)}),e.push("}")}o($t,"ct");u($t,"serializeMap");function It(t,e,r,i){if(t.length===0){e.push("[]");return}e.push("["),t.forEach((n,s)=>{let a=[];Q(n,a,r,i),se(a,e,"",s===t.length-1,r)}),e.push("]")}o(It,"at");u(It,"serializeArray");function Ct(t,e,r,i){if(t.size===0){e.push("Set {}");return}e.push("Set {");let n=Array.from(t);n.forEach((s,a)=>{let c=[];Q(s,c,r,i),se(c,e,"",a===n.length-1,r)}),e.push("}")}o(Ct,"ut");u(Ct,"serializeSet");function Rt(t,e,r){let i=Array.from(t);if(i.length===0){e.push("Buffer {}");return}e.push("Buffer {");for(let n=0;n<i.length;n++){let s=i[n],a=n===i.length-1?"":",";e.push(`${r}${s}${a}`)}e.push("}")}o(Rt,"ht");u(Rt,"serializeBuffer");function Lt(t,e,r){let i=Object.prototype.toString.call(t).slice(8,-1),n=Array.from(t);if(n.length===0){e.push(`${i} []`);return}e.push(`${i} [`);for(let s=0;s<n.length;s++){let a=n[s],c=s===n.length-1?"":",";e.push(`${r}${a}${c}`)}e.push("]")}o(Lt,"pt");u(Lt,"serializeTypedArray");function He(t,e,r,i){let n=t.constructor&&t.constructor!==Object?t.constructor.name:"Object",s=Object.entries(t);if(s.length===0){e.push(`${n} {}`);return}e.push(`${n} {`),s.forEach(([a,c],l)=>{let h=[];Q(c,h,r,i),se(h,e,`${String(a)}: `,l===s.length-1,r)}),e.push("}")}o(He,"ye");u(He,"serializeObject");function Q(t,e,r=wt,i){let n=St(t);if(n!==null){e.push(n);return}if(typeof t=="string"){let s=t.split(`
|
|
3
|
+
`);e.push('String "');for(let a of s)e.push(`${r}${a}`);e.push('"');return}if(typeof t=="object"&&t!==null){if(i.has(t)){e.push("[Circular]");return}i.add(t),t instanceof Map?$t(t,e,r,i):Array.isArray(t)?It(t,e,r,i):t instanceof Set?Ct(t,e,r,i):t instanceof Buffer?Rt(t,e,r):ArrayBuffer.isView(t)&&!(t instanceof DataView)?Lt(t,e,r):He(t,e,r,i);return}He(t,e,r,i)}o(Q,"B");u(Q,"serializeValue");function _(t){if(t&&typeof t=="object"){if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(e[r]=i);return e.name=t?.name??e.name,e.message=t?.message??e.message,e.stack=t?.stack??e.stack,e}return t}o(_,"ae");u(_,"serializeError");function w(t,e=wt){let r=[];return Q(t,r,e,new WeakSet),r}o(w,"v");u(w,"serialize");var Mi=(t=>(t[t.DELETE=-1]="DELETE",t[t.EQUAL=0]="EQUAL",t[t.INSERT=1]="INSERT",t))(Mi||{});function Ot(){let t=0;for(;this.aStart+t<this.aEnd&&this.bStart+t<this.bEnd&&this.isMatch(this.aStart+t,this.bStart+t);)t++;return t}o(Ot,"lt");u(Ot,"countCommonForward");function jt(){let t=0;for(;this.aEnd-1-t>=this.aStart&&this.bEnd-1-t>=this.bStart&&this.isMatch(this.aEnd-1-t,this.bEnd-1-t);)t++;return t}o(jt,"ft");u(jt,"countCommonBackward");function Bt(t,e,r){let i=this.aEnd-this.aStart,n=this.bEnd-this.bStart,s=[];for(let a=r;a>0;a--){let c=t[a-1],l=i-n,h,g=c[l-1+e],f=c[l+1+e];l===-a||l!==a&&g<f?h=l+1:h=l-1;let k=h+e,y=c[k],T=y-h;for(;i>y&&n>T;)--i,--n,s.push([1,this.aStart+i,this.bStart+n]);i===y?s.push([0,this.aStart+y,this.bStart+T]):s.push([0,this.aStart+y,this.bStart+T]),i=y,n=T}for(let a of s.reverse())this.foundSubsequence(...a)}o(Bt,"dt");u(Bt,"backtrackFlat");function Mt(){let t=this.aEnd-this.aStart,e=this.bEnd-this.bStart,r=t+e,i=0,n=new Array(2*r+1).fill(0),s=[];for(let a=0;a<=r;a++){let c=new Array(2*r+1);s[a]=c;for(let l=-a;l<=a;l+=2){let h=l+r,g;l===-a||l!==a&&n[l-1+r]<n[l+1+r]?g=n[l+1+r]:g=n[l-1+r]+1;let f=g-l;for(;g<t&&f<e&&this.isMatch(this.aStart+g,this.bStart+f);)g++,f++;if(n[h]=g,c[h]=g,g>=t&&f>=e)return i=a,Bt.call(this,s,r,i)}}}o(Mt,"mt");u(Mt,"findMiddleSnake");function Pt(){let t=Ot.call(this),e=this.aStart+t>=this.aEnd&&this.bStart+t>=this.bEnd;if(t>0&&(this.foundSubsequence(t,this.aStart,this.bStart),e))return;this.aStart+=t,this.bStart+=t;let r=jt.call(this);this.aEnd-=r,this.bEnd-=r,(this.aStart<this.aEnd||this.bStart<this.bEnd)&&Mt.call(this),r>0&&this.foundSubsequence(r,this.aEnd,this.bEnd)}o(Pt,"yt");u(Pt,"diffSequence");function Ue(t,e,r,i){let n={aStart:0,bStart:0,aEnd:t,bEnd:e,isMatch:r,foundSubsequence:i};Pt.call(n)}o(Ue,"ve");u(Ue,"createDiff");function Je(t,e){let r=0,i=0,n="",s="",a=[];function c(l,h){let g=a[a.length-1];g&&g[0]===l?g[1]+=h:a.push([l,h])}return o(c,"a"),u(c,"pushDiff"),Ue(t.length,e.length,(l,h)=>t[l]===e[h],(l,h,g)=>{r!==h&&(s+=t.slice(r,h)),i!==g&&(n+=e.slice(i,g)),l>0&&(s&&(c(-1,s),s=""),n&&(c(1,n),n=""),c(0,e.slice(g,g+l))),r=h+l,i=g+l}),r!==t.length&&(s+=t.slice(r)),i!==e.length&&(n+=e.slice(i)),s&&a.push([-1,s]),n&&a.push([1,n]),a}o(Je,"G");u(Je,"diffStringsRaw");function Ve(t,e){let r=0,i=0,n=[];for(Ue(t.length,e.length,(s,a)=>{let c=t[s].trimEnd().endsWith(","),l=e[a].trimEnd().endsWith(",");return c&&!l?e[a]+=",":!c&&l&&(t[s]+=","),t[s]===e[a]},(s,a,c)=>{for(;r!==a;r+=1)n.push([-1,t[r]]);for(;i!==c;i+=1)n.push([1,e[i]]);for(;s!==0;s-=1,r+=1,i+=1)n.push([0,e[i]])});r!==t.length;r+=1)n.push([-1,t[r]]);for(;i!==e.length;i+=1)n.push([1,e[i]]);return n}o(Ve,"Z");u(Ve,"diffLinesRaw");function We(t){let e=[],r=[],i=[],n=u(()=>{e.length&&(i.push([-1,e.join("")]),e=[]),r.length&&(i.push([1,r.join("")]),r=[])},"flushBuffers");for(let s=0;s<t.length;s++){let[a,c]=t[s];if(a===0){if(c.length<=1){let l=s>0?t[s-1][0]:null,h=s+1<t.length?t[s+1][0]:null,g=u(f=>f===-1||f===1,"isEdit");if(g(l)&&g(h)){for(let f of c)e.push(f),r.push(f);continue}}n(),i.push([0,c])}else if(a===-1)for(let l of c)e.push(l);else if(a===1)for(let l of c)r.push(l);else n(),i.push([a,c])}return n(),i}o(We,"_");u(We,"cleanupSemantic");var M=F.dim,Pi=F.lightOrange,p=F.lightCoral,m=F.oliveGreen,Ft=F.cyan,N=F.inverse,Pn=F.whiteBright;function j(t){return t===null?"null":t===!0?"true":t===!1?"false":t&&typeof t=="object"?t.constructor?.name??"Object":typeof t}o(j,"k");u(j,"getType");function Nt(t,e,r=!0){let i="",n="",s=Je(t||" ",e||" ");r&&(s=We(s));for(let[a,c]of s)a===0?(i+=c,n+=c):a===-1?i+=N(c):a===1&&(n+=N(c));return[i,n]}o(Nt,"gt");u(Nt,"normalizeStrings");function Dt(t,e){let r=[...t],i=[...e],n=Math.max(t.length,e.length);for(let s=0;s<n;s++)[r[s],i[s]]=oe(t[s],e[s]);return[r,i]}o(Dt,"vt");u(Dt,"normalizeArrays");function zt(t,e){let r={...t},i={...e},n=new Set([...Object.keys(t),...Object.keys(e)]);for(let s of n)s in t&&s in e&&([r[s],i[s]]=oe(t[s],e[s]));return[r,i]}o(zt,"Et");u(zt,"normalizeObjects");function oe(t,e,r=!0){if(t===e)return[t,e];let i=typeof t,n=typeof e;return Ke(t,e)===!0?(I(t)&&(t=e),I(e)&&(e=t),[t,e]):i==="string"&&n==="string"?Nt(t,e,r):!t||!e||i!=="object"||n!=="object"?[t,e]:Array.isArray(t)&&Array.isArray(e)?Dt(t,e):zt(t,e)}o(oe,"ee");u(oe,"normalizeAsymmetric");function Ht(t,e,r,i=!0){let n=t.split(`
|
|
4
4
|
`),s=e.split(`
|
|
5
|
-
`);r.push(
|
|
5
|
+
`);r.push(Ft(`
|
|
6
6
|
@@ -1,${n.length} +1,${s.length} @@
|
|
7
|
-
`));let a=Math.max(n.length,s.length);for(let c=0;c<a;c++){let
|
|
8
|
-
`)}o(
|
|
9
|
-
@@ -1,${
|
|
10
|
-
`));let g=
|
|
11
|
-
`)}o(
|
|
7
|
+
`));let a=Math.max(n.length,s.length);for(let c=0;c<a;c++){let l=n[c],h=s[c];if(l===h){l&&r.push(M(` ${l}`));continue}let g=[],f=[];if(l!==void 0&&h!==void 0){let k=Je(l||" ",h||" ");i&&(k=We(k));for(let[y,T]of k)y===0?(g.push(T),f.push(T)):y===-1?g.push(N(T)):y===1&&f.push(N(T))}l===void 0&&f.push(h),!h===void 0&&g.push(l),g.length>0&&r.push(m(`- ${g.join("")}`)),f.length>0&&r.push(p(`+ ${f.join("")}`))}return r.join(`
|
|
8
|
+
`)}o(Ht,"bt");u(Ht,"diffStrings");function xe(t,e){let r=[];[t,e]=oe(t,e,!0);let i=w(t,""),n=w(e,""),s=Ve(i,n);for(let[a,c]of s){let l=c,h="";l.endsWith(",")&&(l=l.slice(0,-1),h=","),a===0?r.push(M(l)+h):a===1&&r.push(p(l)+h)}return r}o(xe,"te");u(xe,"diffArgs");function ke(t,e,r=!0){let i=j(t),n=j(e),s=[];if(i!==n&&(s.push("Expected type: "+m(i)),s.push("Received type: "+p(n))),i==="string"&&n==="string")return Ht(t,e,s,r);let[a,c]=oe(t,e,r),l=w(a),h=w(c);s.push(Ft(`
|
|
9
|
+
@@ -1,${l.length} +1,${h.length} @@
|
|
10
|
+
`));let g=Ve(l,h);for(let[f,k]of g)f===0?s.push(M(` ${k}`)):f===-1?s.push(m(`- ${k}`)):f===1&&s.push(p(`+ ${k}`));return s.join(`
|
|
11
|
+
`)}o(ke,"D");u(ke,"diffComponent");var qe=class extends Error{static{o(this,"C")}static{u(this,"xJetBaseError")}constructor(t,e="xJetError"){super(t),Object.setPrototypeOf(this,new.target.prototype),this.name=e,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return kt(this)}};function we(t){let{comment:e,assertionChain:r,expectedLabels:i=[],receivedLabeled:n="received"}=t;if(!r.length)throw new Error('Expected non-empty matcher chain (e.g., ["toEqual"]). Received an empty array.');let s=[M("expect("),p(n),M(")"),".",r.join(".")];return i.length>0?(s.push("("),s.push(i.map(a=>m(a)).join(", ")),s.push(")")):s.push("()"),e&&s.push(M(" // "+e)),s.join("")}o(we,"O");u(we,"composeStatement");var K=class extends qe{static{o(this,"w")}static{u(this,"xJetTypeError")}constructor(t){let e=[`${we(t)}
|
|
12
12
|
`,`Matcher error: ${t.message}
|
|
13
|
-
`];t.expected&&(t.expected.type&&e.push(`Expected has type: ${t.expected.type}`),e.push(`Expected has value: ${m(
|
|
14
|
-
`))}`)),t.received&&(t.received.type&&e.push(`Received has type: ${t.received.type}`),e.push(`Received has value: ${
|
|
13
|
+
`];t.expected&&(t.expected.type&&e.push(`Expected has type: ${t.expected.type}`),e.push(`Expected has value: ${m(w(t.expected.value).join(`
|
|
14
|
+
`))}`)),t.received&&(t.received.type&&e.push(`Received has type: ${t.received.type}`),e.push(`Received has value: ${p(w(t.received.value).join(`
|
|
15
15
|
`))}`)),super(e.join(`
|
|
16
|
-
`),"xJetTypeError")}},
|
|
16
|
+
`),"xJetTypeError")}},Fi=class extends qe{static{o(this,"re")}static{u(this,"xJetExpectError")}matcherResult;constructor(t){let e=[`${we(t)}
|
|
17
17
|
`];t.info&&e.push(...t.info),super(e.join(`
|
|
18
|
-
`),"xJetExpectError"),t.assertion&&(this.matcherResult=t.assertion,this.matcherResult.message=this.message)}};function
|
|
19
|
-
`):n.push(`Received value: ${
|
|
20
|
-
`)):n.push(`Received value: ${
|
|
21
|
-
`)):a.push(`Error value: ${
|
|
22
|
-
`),f.push(...g)},handleInfo(f){f.push(`Expected: ${m(d(t))}`),f.push(`Received: ${
|
|
23
|
-
`),f.push(...g)}})}o(
|
|
24
|
-
`)}o(
|
|
25
|
-
`)}o(
|
|
26
|
-
`),r.push(
|
|
27
|
-
`)}})}o(
|
|
28
|
-
`)}})}o(
|
|
18
|
+
`),"xJetExpectError"),t.assertion&&(this.matcherResult=t.assertion,this.matcherResult.message=this.message)}};function S(t,e,r,i=[]){let n=j(t);if(!e.includes(n)&&!e.includes(typeof t))throw new K({expectedLabels:i,assertionChain:this.assertionChain,message:`${(r==="Received"?p:m)(r)} value must be a ${e.join(" or ")}`,[r==="Expected"?"expected":"received"]:{value:t,type:n}})}o(S,"E");u(S,"ensureType");function Ye(t,e,r=[]){if(t==null)throw new K({expectedLabels:r,assertionChain:this.assertionChain,message:`${(e==="Received"?p:m)(e)} value must not be null nor undefined`,[e==="Expected"?"expected":"received"]:{value:t}})}o(Ye,"he");u(Ye,"ensureNotNullish");function d(t){return w(t,"").join(" ")}o(d,"l");u(d,"serializeOneLine");function b(t){let{pass:e}=t;if(!(e&&this.notModifier||!e&&!this.notModifier))return;let r=[],i={pass:e,name:this.macherName,received:this.received,expected:t.expected};throw this.notModifier?t.handleNot?.call(this,r):t.handleInfo?.call(this,r),new Fi({info:r,assertion:i,...t,assertionChain:this.assertionChain})}o(b,"y");u(b,"handleFailure");function P(t){b.call(this,{...t,handleNot(e){e.push(`Expected: not ${m(d(this.received))}`)},handleInfo(e){t.note&&e.push(M(t.note),""),e.push(ke(t.expected,this.received,!0))}})}o(P,"M");u(P,"handleDiffFailure");function _t(t,e){let r=" ".repeat(e.length);b.call(this,{...t,handleNot(i){i.push(`Expected: not ${e} ${m(d(t.expected))}`),i.push(`Received: ${r} ${p(d(this.received))}`)},handleInfo(i){i.push(`Expected: ${e} ${m(d(t.expected))}`),i.push(`Received: ${r} ${p(d(this.received))}`)}})}o(_t,"be");u(_t,"handleComparisonFailure");function _e(t){let e=t,r=e!=null&&typeof e.message=="string",i=r&&typeof e.name=="string"&&typeof e.stack=="string";return{isError:i,value:t,message:String(r?e.message:t),hasMessage:i?!0:r,serializedError:_(t)}}o(_e,"xe");u(_e,"getThrown");function ae(t,e,r,i=!1){return[u(n=>{n.push(`Expected ${t}: not ${m(e)}`),r?.hasMessage?n.push(`Received message: ${p(d(i?r.message:N(r.message)))}
|
|
19
|
+
`):n.push(`Received value: ${p(d(r?.value))}`)},"handleNot"),u(n=>{n.push(`Expected ${t}: ${m(e)}`),r?.hasMessage?(i&&n.push(`Received name: ${p(d(r.value?.name))}`),n.push(`Received message: ${p(d(r.message))}
|
|
20
|
+
`)):n.push(`Received value: ${p(d(r?.value))}`)},"handleInfo")]}o(ae,"ne");u(ae,"buildInfo");function Kt(t,e){let r=e!=null&&e.value instanceof t,[i,n]=ae("constructor",t.name,e);return[r,i,n]}o(Kt,"xt");u(Kt,"toThrowExpectedClass");function Ut(t,e){let r=e!=null&&e.message.includes(t),[i,n]=ae("substring",`"${t}"`,e);return[r,i,n]}o(Ut,"St");u(Ut,"toThrowExpectedString");function Jt(t,e){let r=e!=null&&t.test(e.message),[i,n]=ae("pattern",d(t),e);return[r,i,n]}o(Jt,"Tt");u(Jt,"toThrowExpectedRegExp");function Vt(t,e){let r=e!=null&&t.matches(e.value),[i,n]=ae("asymmetric",d(t),e,!0);return[r,i,n]}o(Vt,"wt");u(Vt,"toThrowExpectedAsymmetric");function Wt(t,e){return[e!=null&&x(_(t),e.serializedError),u(r=>{r.push(`Expected: not ${m(d(e.serializedError))}`)},"handleNot"),u(r=>{r.push(ke(t,e.serializedError,!0))},"handleInfo")]}o(Wt,"$t");u(Wt,"toThrowExpectedObject");function qt(t){let e=null,r=t?["expected"]:[];if(this.rejectsModifier)e=_e(this.received);else if(typeof this.received=="function")try{this.received()}catch(a){e=_e(a)}else S.call(this,this.received,["function"],"Received",r);let i=!1,n,s;t?typeof t=="function"?[i,n,s]=Kt.call(this,t,e):typeof t=="string"?[i,n,s]=Ut.call(this,t,e):t instanceof RegExp?[i,n,s]=Jt.call(this,t,e):I(t)?[i,n,s]=Vt.call(this,t,e):e!==null&&typeof t=="object"?[i,n,s]=Wt.call(this,t,e):S.call(this,t,["string","function","RegExp","object"],"Expected",r):(i=e!=null,n=u(a=>{e?.hasMessage?(a.push(`Error name: ${p(e.value?.name)}`),a.push(`Error message: ${p(d(e.message))}
|
|
21
|
+
`)):a.push(`Error value: ${p(d(e?.value))}`)},"handleNot")),b.call(Object.assign({},this,{received:e?.serializedError}),{pass:i,expected:t,expectedLabels:r,handleNot(a){n?.call(this,a)},handleInfo(a){e?s?.call(this,a):a.push(`${p("Received")} function did not throw`)}})}o(qt,"Se");u(qt,"toThrow");function Yt(t){let e=["length"];if(S.call(this,t,["number","bigint"],"Expected",e),!Object.hasOwn(this.received,"length")||!Number.isSafeInteger(this.received.length))throw new K({expectedLabels:e,message:`${p("received")} value must have a length property whose value must be a number`,received:{value:this.received,type:j(this.received)},assertionChain:this.assertionChain});let r=this.received,i=r.length==t;b.call(this,{pass:i,expectedLabels:e,handleNot(n){n.push(`Expected length: not ${m(d(t))}`),n.push(`Received string: ${p(d(r))}`)},handleInfo(n){n.push(`Expected length: ${m(d(t))}`),n.push(`Received length: ${p(d(r.length))}`),n.push(`Received string: ${p(d(r))}`)}})}o(Yt,"Te");u(Yt,"toHaveLength");function Gt(t){let e=["expected"];S.call(this,this.received,["string"],"Received",e),S.call(this,t,["string","RegExp"],"Expected",e);let r=this.received,i=typeof t=="string"?r.includes(t):new RegExp(t).test(r);b.call(this,{pass:i,expectedLabels:e,handleNot(n){n.push(`Expected: not ${m(d(r))}`)},handleInfo(n){t instanceof RegExp?(n.push(`Expected pattern: ${m(d(t))}`),n.push(`Received string: ${p(d(r))}`)):n.push(ke(t,r,!0))}})}o(Gt,"we");u(Gt,"toMatch");function ce(t,e,r=[]){if(S.call(this,t,["number","bigint"],e,r),t<0)throw new K({expectedLabels:r,assertionChain:this.assertionChain,message:`${(e==="Received"?p:m)(e)} value must be positive number`,[e==="Received"?"received":"expected"]:{value:t,type:j(t)}})}o(ce,"z");u(ce,"ensurePositiveNumber");function le(t,e){let r=this.received,i=["Expected"];S.call(this,t,["number","bigint"],"Expected",i),S.call(this,r,["number","bigint"],"Received",i);let n;switch(e){case">":n=r>t;break;case">=":n=r>=t;break;case"<":n=r<t;break;case"<=":n=r<=t;break;default:n=!1}_t.call(this,{pass:n,expectedLabels:i,expected:t},e)}o(le,"F");u(le,"handleNumericComparison");function Xt(t,e=2){let r=["expected","precision"];S.call(this,t,["number"],"Expected",r),S.call(this,this.received,["number"],"Received",r);let i=this.received,n=Math.abs(t-i),s=Math.pow(10,-e)/2,a=e<20?s.toFixed(e+1):s.toString(),c=this.notModifier?" ":" ",l=this.notModifier?"not < ":"< ",h=n<s,g=[`Expected precision: ${c}${m(e.toString())}`,`Expected difference: ${l}${m(a)}`,`Received difference: ${c}${p(n.toString())}`];b.call(this,{pass:h,expectedLabels:r,handleNot(f){f.push(`Expected: not ${m(d(t))}`),f.push(`Received: ${p(d(i))}
|
|
22
|
+
`),f.push(...g)},handleInfo(f){f.push(`Expected: ${m(d(t))}`),f.push(`Received: ${p(d(i))}
|
|
23
|
+
`),f.push(...g)}})}o(Xt,"$e");u(Xt,"toBeCloseTo");function Zt(t){le.call(this,t,">")}o(Zt,"ke");u(Zt,"toBeGreaterThan");function Qt(t){le.call(this,t,">=")}o(Qt,"Ae");u(Qt,"toBeGreaterThanOrEqual");function er(t){le.call(this,t,"<")}o(er,"Re");u(er,"toBeLessThan");function tr(t){le.call(this,t,"<=")}o(tr,"Me");u(tr,"toBeLessThanOrEqual");function B(t=[]){if(!this.received?.xJetMock||!this.received?.mock)throw new K({expectedLabels:t,assertionChain:this.assertionChain,message:`${p("Received")} value must be a mock or spy function`,received:{value:this.received}})}o(B,"I");u(B,"ensureMock");function z(t){return w(t,"").slice(1,-1).map(e=>m(e.replace(",",""))).join(", ")}o(z,"L");u(z,"serializeCallArgs");function Ge(t,e,r,i="->",n=!1,s=3){if(!e?.length)return"";let a=0,c=-1,l=e.length;r&&r>=1&&r<=l&&(c=r-1,a=Math.max(0,Math.min(c-1,l-(s-1))));let h=Math.min(a+s,l),g=String(h).length,f=" ".repeat(i.length+1),k=new Array(h-a);for(let y=a;y<h;y++){let T=e[y],te=String(y+1).padStart(g," "),re=y===c?`${i} `:f;if(n&&Array.isArray(T)&&T.length<1){k[y-a]=`${re}${te}: called with 0 arguments`;continue}let Pe=n?xe(t,T).slice(1,-1):xe(t,T);k[y-a]=`${re}${te}: ${Pe.join(" ")}`}return k.join(`
|
|
24
|
+
`)}o(Ge,"Ie");u(Ge,"serializeList");function rr(t,e,r=[],i=3){if(!e?.length||!r.length)return"";let n=e.length,s=String(n).length+3,a=[];for(let c=0;c<r.length;c++){let l=r[c]-1;if(l<0||l>=n)continue;let h=xe(t,e[l]).slice(1,-1);if(a.push(`${String(l+1).padStart(s," ")}: ${h.join(" ")}`),a.length>=i)break}return a.join(`
|
|
25
|
+
`)}o(rr,"Ce");u(rr,"serializeHighlightedCalls");function H(t,e,r,i){return Ge(t,e,r,i,!0)}o(H,"N");u(H,"serializeCallList");function X(t,e,r,i){return Ge(t,e,r,i,!1)}o(X,"P");u(X,"serializeReturnList");function ir(){B.call(this);let t=this.received.mock.calls,e=this.received.mock.calls.length;b.call(this,{pass:e>0,receivedLabeled:this.received.name,handleNot(r){r.push(`Expected calls: ${m("0")}`),r.push(`Received calls: ${p(e.toString())}
|
|
26
|
+
`),r.push(H([],t))},handleInfo(r){r.push(`Expected calls: >= ${m("1")}`),r.push(`Received calls: ${p(e.toString())}
|
|
27
|
+
`)}})}o(ir,"je");u(ir,"toHaveBeenCalled");function nr(t){let e=["expected"];B.call(this,e),ce.call(this,t,"expected",e);let r=this.received.mock.calls.length;b.call(this,{expected:t,pass:r==t,expectedLabels:e,receivedLabeled:this.received.name,handleNot(i){i.push(`Expected calls: != ${m(t.toString())}`)},handleInfo(i){i.push(`Expected calls: ${m(t.toString())}`),i.push(`Received calls: ${p(r.toString())}
|
|
28
|
+
`)}})}o(nr,"Le");u(nr,"toHaveBeenCalledTimes");function sr(...t){let e=["...args"];B.call(this,e);let r=this.received.mock.calls,i=this.received.mock.calls.length,n=[];r.forEach((a,c)=>{a.length===t.length&&x(t,a)&&n.push(c+1)});let s=n.length>0;b.call(this,{pass:s,expectedLabels:e,expected:t,receivedLabeled:this.received.name,handleNot(a){a.push(`Expected: not ${z(t)}`),a.push(`Received:
|
|
29
29
|
|
|
30
|
-
${
|
|
31
|
-
`),a.push(`Calls: ${
|
|
30
|
+
${rr(t,r,n)}
|
|
31
|
+
`),a.push(`Calls: ${p(i.toString())}`)},handleInfo(a){a.push(`Expected: ${z(t)}`),a.push(`Received:
|
|
32
32
|
|
|
33
|
-
${
|
|
34
|
-
`),a.push(`Calls: ${
|
|
33
|
+
${H(t,r)}
|
|
34
|
+
`),a.push(`Calls: ${p(i.toString())}`)}})}o(sr,"Ne");u(sr,"toHaveBeenCalledWith");function or(...t){let e=["...args"];B.call(this,e);let r=this.received.mock.calls,i=r.length,n=this.received.mock.calls.at(-1),s=n!==void 0&&x(t,n);b.call(this,{pass:s,expectedLabels:e,expected:t,receivedLabeled:this.received.name,handleNot(a){a.push(`Expected: not ${z(t)}`),a.push(`Received:
|
|
35
35
|
|
|
36
|
-
${
|
|
37
|
-
`),a.push(`Calls: ${
|
|
36
|
+
${H(t,r,r.length)}
|
|
37
|
+
`),a.push(`Calls: ${p(i.toString())}`)},handleInfo(a){a.push(`Expected: ${z(t)}`),a.push(`Received:
|
|
38
38
|
|
|
39
|
-
${
|
|
40
|
-
`),a.push(`Calls: ${
|
|
39
|
+
${H(t,r,r.length)}
|
|
40
|
+
`),a.push(`Calls: ${p(i.toString())}`)}})}o(or,"De");u(or,"toHaveBeenLastCalledWith");function ar(t,...e){let r=["nthCall","...args"];B.call(this,r),ce.call(this,t,"nthCall",r);let i=this.received.mock.calls,n=i.length,s=this.received.mock.calls.at(t-1),a=s!==void 0&&x(e,s);b.call(this,{pass:a,expectedLabels:r,expected:e,receivedLabeled:this.received.name,handleNot(c){c.push(`nthCall: ${t}`),c.push(`Expected: not ${z(e)}`),c.push(`Received:
|
|
41
41
|
|
|
42
|
-
${
|
|
43
|
-
`),c.push(`Calls: ${
|
|
42
|
+
${H(e,i,t)}
|
|
43
|
+
`),c.push(`Calls: ${p(n.toString())}`)},handleInfo(c){c.push(`nthCall: ${t}`),c.push(`Expected: ${z(e)}`),c.push(`Received:
|
|
44
44
|
|
|
45
|
-
${
|
|
46
|
-
`),c.push(`Calls: ${
|
|
47
|
-
`),i.push(
|
|
48
|
-
Calls: ${
|
|
49
|
-
`),c.push(
|
|
50
|
-
Calls: ${
|
|
51
|
-
`),c.push(
|
|
52
|
-
Returns: ${
|
|
53
|
-
`),
|
|
54
|
-
Returns: ${
|
|
55
|
-
`),
|
|
56
|
-
Returns: ${
|
|
57
|
-
`),e?c.push(`Expected value: ${m(d(e))}`):c.push(`Received value: ${
|
|
58
|
-
`)},handleInfo(n){n.push(`Expected constructor: ${m(t.name)}`),r!==null&&typeof r=="object"&&Object.getPrototypeOf(r)!==null&&"constructor"in r?n.push(`Received constructor: ${
|
|
59
|
-
Received value has no prototype`),n.push(`Received value: ${
|
|
60
|
-
`))}`),s.push(`Received string: ${
|
|
45
|
+
${H(e,i,t)}
|
|
46
|
+
`),c.push(`Calls: ${p(n.toString())}`)}})}o(ar,"Oe");u(ar,"toHaveBeenNthCalledWith");function cr(){B.call(this);let t=[],e=this.received.mock.calls.length,r=this.received.mock.results.reduce((i,n)=>n.type==="return"?(t.push(n.value),i+1):i,0);b.call(this,{pass:r>0,receivedLabeled:this.received.name,handleNot(i){i.push(`Expected returns: ${m("0")}`),i.push(`Received returns: ${p(r.toString())}
|
|
47
|
+
`),i.push(X(void 0,t)),i.push(`
|
|
48
|
+
Calls: ${p(e.toString())}`)},handleInfo(i){i.push(`Expected returns: >= ${m("1")}`),i.push(`Received returns: ${p(r.toString())}`),i.push(`Calls: ${p(e.toString())}`)}})}o(cr,"Pe");u(cr,"toHaveReturned");function lr(t){let e=["expected"];B.call(this,e),ce.call(this,t,"expected",e);let r=this.received.mock.calls.length,i=this.received.mock.results.reduce((n,s)=>s.type==="return"?n+1:n,0);b.call(this,{expectedLabels:e,pass:i==t,expected:t,receivedLabeled:this.received.name,handleNot(n){n.push(`Expected returns: != ${m(t.toString())}`),n.push(`Calls: ${p(r.toString())}`)},handleInfo(n){n.push(`Expected returns: ${m(t.toString())}`),n.push(`Received returns: ${p(i.toString())}`),n.push(`Calls: ${p(r.toString())}`)}})}o(lr,"Be");u(lr,"toHaveReturnedTimes");function ur(t){let e=["expected"];B.call(this,e);let r=[],i=this.received.mock.calls.length,n=this.received.mock.results.reduce((c,l)=>l.type==="return"?(r.push(l.value),c+1):c,0),s=r.at(-1),a=r.length>0&&x(t,s);b.call(this,{pass:a,expectedLabels:e,expected:t,receivedLabeled:this.received.name,handleNot(c){c.push(`Expected returns: not ${m(d(t))}`),c.push(`Received returns:
|
|
49
|
+
`),c.push(X(t,r,n)),c.push(`
|
|
50
|
+
Calls: ${p(i.toString())}`)},handleInfo(c){c.push(`Expected returns: ${m(d(t))}`),r.length>0&&(c.push(`Received returns:
|
|
51
|
+
`),c.push(X(t,r,n))),c.push(`
|
|
52
|
+
Returns: ${p(n.toString())}`),c.push(`Calls: ${p(i.toString())}`)}})}o(ur,"ze");u(ur,"toHaveLastReturnedWith");function hr(t,e){let r=["nthCall","expected"];B.call(this,r),ce.call(this,t,"nthCall",r);let i=[],n=this.received.mock.calls.length,s=this.received.mock.results.reduce((l,h)=>h.type==="return"?(i.push(h.value),l+1):l,0),a=i.at(t-1),c=t<=i.length&&x(e,a);b.call(this,{pass:c,expectedLabels:r,expected:e,receivedLabeled:this.received.name,handleNot(l){l.push(`nthCall: ${t}`),l.push(`Expected returns: not ${m(d(e))}`),l.push(`Received returns:
|
|
53
|
+
`),l.push(X(e,i,t)),l.push(`
|
|
54
|
+
Returns: ${p(s.toString())}`),l.push(`Calls: ${p(n.toString())}`)},handleInfo(l){l.push(`nthCall: ${t}`),l.push(`Expected returns: ${m(d(e))}`),l.push(`Received returns:
|
|
55
|
+
`),l.push(X(e,i,t)),l.push(`
|
|
56
|
+
Returns: ${p(s.toString())}`),l.push(`Calls: ${p(n.toString())}`)}})}o(hr,"Fe");u(hr,"toHaveNthReturnedWith");function pr(t){let e=I(t)?t.matches(this.received):Object.is(this.received,t),r=!e&&x(this.received,t)?'If it should pass with deep equality, replace "toBe" with "toEqual"':void 0;P.call(this,{note:r,pass:e,expected:t,comment:"Object.is equality",expectedLabels:["expected"]})}o(pr,"He");u(pr,"toBe");function fr(t){let e=x(this.received,t);P.call(this,{pass:e,expected:t,comment:"deep equality",expectedLabels:["expected"]})}o(fr,"qe");u(fr,"toEqual");function dr(){let t=this.received===null;P.call(this,{pass:t,expected:null})}o(dr,"Ve");u(dr,"toBeNull");function mr(){let t=this.received===void 0;P.call(this,{pass:t,expected:void 0})}o(mr,"We");u(mr,"toBeUndefined");function gr(){let t=Number.isNaN(this.received);P.call(this,{pass:t,expected:NaN})}o(gr,"Je");u(gr,"toBeNaN");function yr(){let t=!!this.received;P.call(this,{pass:t,expected:!0})}o(yr,"Ke");u(yr,"toBeTruthy");function vr(){let t=!this.received;P.call(this,{pass:t,expected:!1})}o(vr,"Ue");u(vr,"toBeFalsy");function br(){let t=this.received!==void 0;b.call(this,{pass:t,expected:void 0,handleNot(e){e.push(`Expected: ${m(d(void 0))}`)},handleInfo(e){e.push(`Received: ${p(d(this.received))}`)}})}o(br,"Xe");u(br,"toBeDefined");function Tr(t,e){let r=["path","value"];Ye.call(this,this.received,"Received",r),S.call(this,t,["string","Array"],"Expected path",r);let i=!0,n=this.received,s=[],a=typeof t=="string"?t.split(".").filter(Boolean):t;for(let c of a){if(!n||!Object.hasOwn(n,c)){i=!1;break}s.push(c),n=n[c]}i&&e!==void 0&&(i=x(n,e)),b.call(this,{pass:i,expectedLabels:r,handleNot(c){c.push(`Expected: not ${m(d(a))}
|
|
57
|
+
`),e?c.push(`Expected value: ${m(d(e))}`):c.push(`Received value: ${p(d(n))}`)},handleInfo(c){c.push(`Expected path: ${m(d(a))}`),Object.is(s.join(""),a.join(""))||c.push(`Received path: ${p(d(s))}`),c.push(""),e&&c.push(`Expected value: ${m(d(e))}`),c.push(`Received value: ${p(d(n))}`)}})}o(Tr,"Qe");u(Tr,"toHaveProperty");function xr(t){let e=["expected"];S.call(this,t,["function"],"Received",e);let r=this.received,i=r instanceof t;b.call(this,{pass:i,expectedLabels:e,handleNot(n){n.push(`Expected constructor: not ${m(t.name)}
|
|
58
|
+
`)},handleInfo(n){n.push(`Expected constructor: ${m(t.name)}`),r!==null&&typeof r=="object"&&Object.getPrototypeOf(r)!==null&&"constructor"in r?n.push(`Received constructor: ${p(r.constructor.name)}`):(n.push(`
|
|
59
|
+
Received value has no prototype`),n.push(`Received value: ${p(d(r))}`))}})}o(xr,"Ye");u(xr,"toBeInstanceOf");function Er(t){let e=["expected"];S.call(this,this.received,["string","Array"],"Received",e);let r=this.received,i=j(r);if(typeof r=="string"&&typeof t!="string")throw new K({expectedLabels:e,message:`${m("expected")} value must be a string if ${p("received")} value is a string`,expected:{value:t,type:j(t)},received:{value:r,type:i},assertionChain:this.assertionChain});let n=r.indexOf(t)!==-1;b.call(this,{pass:n,expectedLabels:e,comment:"indexOf",handleNot(s){i==="string"?(s.push(`Expected substring: not ${m(d(t))}`),s.push(`Received string: ${p(d(r)).replace(String(t),N(String(t)))}`)):(s.push(`Expected value: not ${m(d(t))}`),s.push(`Received array: ${p(d(r)).replace(d(t),N(d(t)))}`))},handleInfo(s){i==="string"?(s.push(`Expected substring: ${m(w(t,"").join(`
|
|
60
|
+
`))}`),s.push(`Received string: ${p(w(i,"").join(`
|
|
61
61
|
`))}`)):([...r].findIndex(a=>x(a,t))!==-1&&s.push(M(`Looks like you wanted to test for object/array equality with the stricter \`toContain\` matcher.
|
|
62
|
-
You probably need to use \`${
|
|
63
|
-
`)),s.push(`Expected value: ${m(d(t))}`),s.push(`Received array: ${
|
|
64
|
-
`,`Matcher error: ${t.message}`,`${t.promiseKind} to value: ${
|
|
65
|
-
`),"xJetPromiseError")}},Ir=class{static{o(this,"U")}constructor(t){this.received=t}static{l(this,"MatcherService")}macherName="";promise;notModifier=!1;assertionChain=[];rejectsModifier=!1;resolvesModifier=!1;get not(){return this.notModifier=!0,this}get rejects(){if(this.resolvesModifier)throw new Error('Cannot use "rejects" modifier after "resolved" modifier.');return this.rejectsModifier=!0,this}get resolves(){if(this.rejectsModifier)throw new Error('Cannot use "resolved" modifier after "rejects" modifier.');return this.resolvesModifier=!0,this}invoke(t,e,r){return this.macherName=t,this.rejectsModifier||this.resolvesModifier?(this.pushToChain(t),this.promise=this.resolvesModifier?"resolves":"rejects",this.invokeAsync(e,r)):(this.pushToChain(t),e.call(this,...r))}async invokeAsync(t,e){let r=!1,i=typeof this.received=="function"?this.received():this.received;if(!X(i))throw new _({message:`${h("received")} value must be a promise or a function returning a promise`,assertionChain:this.assertionChain,received:{type:O(i),value:i}});try{this.received=await i,r=!0}catch(n){this.resolvesModifier&&this.throwPromiseError("Rejected",n),this.received=n}return r&&this.rejectsModifier&&this.throwPromiseError("Resolved",this.received),t.call(this,...e)}pushToChain(t){this.promise&&this.assertionChain.push(this.promise),this.notModifier&&this.assertionChain.push("not"),this.assertionChain.push(t)}throwPromiseError(t,e){let r=t==="Resolved"?"resolved":"rejected",i=t==="Resolved"?"rejected":"resolved";throw new ji({message:`${h("received")} promise ${r} instead of ${i}`,received:e,promiseKind:t,assertionChain:this.assertionChain})}};for(let t of Object.keys(ht)){let e=Ir.prototype,r=ht[t];Object.defineProperty(e,t,{value:l(function(...i){return this.invoke(t,r,i)},"value")}),Object.defineProperty(e[t],"name",{value:t})}var Mi=l((t,...e)=>{if(e.length>0)throw new Error(`Expect takes at most one argument. Received ${e.length+1} arguments instead.`);return new Ir(t)},"coreExpect"),Rr=Object.assign(Mi,Oi);var Bi="xJet.mock()",A=class t extends Function{static{o(this,"MockState")}static mocks=[];name;xJetMock=!0;state;restore;queuedImplementations=[];implementation;originalImplementation;constructor(e,r,i){return super(),this.name=i??Bi,this.state=this.initState(),this.implementation=e,this.restore=r||(()=>{this.implementation=e}),this.originalImplementation=e||(()=>{}),new Proxy(this,{apply:this.invokeFunction,construct:this.invokeClass})}getMockName(){return this.name}get mock(){return this.state}get original(){return this.originalImplementation}mockClear(){return this.state=this.initState(),this}mockReset(){return this.mockClear(),this.queuedImplementations=[],this}mockRestore(){this.restore(),this.mockReset();let e=t.mocks.indexOf(this);return e!==-1&&t.mocks.splice(e,1),this}getMockImplementation(){return this.implementation}getNextImplementation(){return this.queuedImplementations.length?this.queuedImplementations.shift():this.implementation}mockImplementation(e){return this.implementation=e,this}mockImplementationOnce(e){return this.queuedImplementations.push(e),this}mockReturnValue(e){return this.mockImplementation(()=>e),this}mockResolvedValue(e){return this.mockImplementation(()=>Promise.resolve(e)),this}mockResolvedValueOnce(e){return this.mockImplementationOnce(()=>Promise.resolve(e)),this}mockReturnValueOnce(e){return this.mockImplementationOnce(()=>e),this}mockRejectedValue(e){return this.mockImplementation(()=>Promise.reject(e)),this}mockRejectedValueOnce(e){return this.mockImplementationOnce(()=>Promise.reject(e)),this}[Symbol.for("nodejs.util.inspect.custom")](){return`<Mock Constructor ${this.name}>`}initState(){return{calls:[],results:[],lastCall:void 0,contexts:[],instances:[],invocationCallOrder:[]}}invoke(e,r){let i=e,n=this.getNextImplementation(),s=r;typeof n=="function"&&(n.__boundArgs&&s.unshift(...n.__boundArgs),n.__boundThis&&(i=n.__boundThis)),this.state.calls.push(s),this.state.contexts.push(i),this.state.invocationCallOrder.push(this.state.invocationCallOrder.length+1);let a,c=this.state.results.push({value:void 0,type:"incomplete"})-1;if(n)try{a={type:"return",value:n.call(void 0,...r)}}catch(u){a={value:u,type:"throw"}}else a={type:"return",value:void 0};return this.state.lastCall=r,this.state.results[c]=a,a.value}invokeFunction(e,r,i){return e.state.instances.push(r),e.invoke.call(e,r,i)}invokeClass(e,r,i){let n=e.invoke.call(e,i,r),s=typeof n=="object"&&n!==null&&n.constructor;return e.state.instances.push(s?n:i),typeof n=="object"?n:i}};var Ve=new Map,Lr=new Map;function Or(t){return function(e){Lr.set(e,t||{})}}o(Or,"Injectable");function S(t,...e){if(Ve.has(t))return Ve.get(t);let r=Lr.get(t);if(!r)throw new Error(`Cannot inject ${t.name} \u2013 not marked @Injectable`);let i=r.factory?r.factory(...e):new t(...e);return r?.scope==="singleton"&&Ve.set(t,i),i}o(S,"inject");function Br(t,e,r){let i=`${e}${r}`,n=t[i];if(!r)throw new Error(`Invalid type(${r}) parameter`);if(!(i in t))throw new Error(`Method "${i.toString()}" does not exist on Buffer`);return n.bind(t)}o(Br,"b");function Pr(t,e){return Br(t,"read",e)}o(Pr,"h");function Nr(t,e){return Br(t,"write",e)}o(Nr,"d");function We(t,e,r=0){if(e<0)throw new Error("Split position cannot be negative");if(e>t.length)throw new Error("Split position cannot exceed buffer length");let i=t.subarray(0,e),n=e+r;return n>=t.length?[i,Buffer.alloc(0)]:[i,t.subarray(n)]}o(We,"f");function zr(t=0){let{position:e,type:r}=this.descriptor,i=this.offset+e+t;return r.toObject(this.buffer.subarray(i),n=>{this.offset+=n})}o(zr,"l");function Pi(){let t=[],{arraySize:e=0,size:r}=this.descriptor;t.length=e;for(let i=0;i<e;i++)t[i]=zr.call(this,i*r);return t}o(Pi,"U");function Ni(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Pi.call(this):zr.call(this)}o(Ni,"S");function Dr(t,e=0){t??={};let{position:r,type:i,size:n}=this.descriptor,s=i.toBuffer(t),a=this.offset+r+e,[c,u]=We(this.buffer,a,n);this.buffer=Buffer.concat([c,s,u]),s.length>n&&(this.offset+=s.length-n)}o(Dr,"T");function zi(t){let{arraySize:e=0,size:r}=this.descriptor;for(let i=0;i<e;i++){let n=i<t.length?t[i]:{};Dr.call(this,n,i*r)}}o(zi,"W");function Di(t){return"arraySize"in this.descriptor&&this.descriptor.arraySize?zi.call(this,Array.isArray(t)?t:[t]):Dr.call(this,Array.isArray(t)?t[0]||{}:t)}o(Di,"I");var K={Int8:8,UInt8:8,Int16LE:16,Int16BE:16,UInt16LE:16,UInt16BE:16,FloatLE:32,FloatBE:32,Int32LE:32,Int32BE:32,UInt32LE:32,UInt32BE:32,DoubleLE:64,DoubleBE:64,BigInt64LE:64,BigInt64BE:64,BigUInt64LE:64,BigUInt64BE:64};function Fi(t,e=0){let r=/^([A-Za-z][A-Za-z0-9]*)(?:\[(\d+)\])?$/i,i=t.match(r);if(!i)throw new Error(`Invalid primitive descriptor: ${t}`);let n=K[i[1]];if(!n)throw new Error(`Invalid primitive type: ${i[1]}`);let s=i[1],a=i[2]?parseInt(i[2]):void 0;return{type:s,position:e,size:n/8,arraySize:a,kind:"primitive"}}o(Fi,"x");function Fr(t=0){let{position:e,type:r}=this.descriptor,i=this.offset+e+t;return Pr(this.buffer,r)(i)}o(Fr,"z");function Hi(){let t=[],{arraySize:e=0,size:r}=this.descriptor;t.length=e;for(let i=0;i<e;i++)t[i]=Fr.call(this,i*r);return t}o(Hi,"N");function _i(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Hi.call(this):Fr.call(this)}o(_i,"w");function Hr(t,e=0){t??=0;let{position:r,type:i}=this.descriptor,n=i.includes("Big");if(n&&t===0&&(t=BigInt(0)),n&&typeof t!="bigint")throw new TypeError(`Expected a BigInt for field "${i}", but received ${t}`);if(!n&&typeof t!="number")throw new TypeError(`Expected a number for field "${i}", but received ${t}`);let s=this.offset+r+e;Nr(this.buffer,i)(t,s)}o(Hr,"B");function Ki(t){let{arraySize:e=0,size:r}=this.descriptor;for(let i=0;i<e;i++){let n=i<t.length?t[i]:0;Hr.call(this,n,i*r)}}o(Ki,"_");function Ui(t){if("arraySize"in this.descriptor&&this.descriptor.arraySize)return Ki.call(this,Array.isArray(t)?t:[t]);Hr.call(this,Array.isArray(t)?t[0]||0:t)}o(Ui,"P");var jr=new Map;function Ye(t){return t.startsWith("Int")}o(Ye,"y");function _r(t){let e=jr.get(t);return e===void 0&&(e=(1<<t)-1,jr.set(t,e)),e}o(_r,"D");function Ji(t,e){return Ye(t.type)?Number(BigInt.asIntN(t.bitSize,BigInt(e))):e}o(Ji,"j");function Vi(t,e){let r=Ye(t.type),{bitSize:i,type:n}=t,s=r?(1<<i-1)-1:(1<<i)-1,a=r?-(1<<i-1):0;if(e<a||e>s)throw new RangeError(`Value ${e} does not fit within ${i} bits for type ${n}`)}o(Vi,"G");function Kr(t,e){if(t.bitSize<1||t.bitPosition<0)throw new Error(`bitSize(${t.bitSize}) and bitPosition(${t.bitPosition}) must be greater than bitSize(1) and bitPosition(0) for ${e}`);if(K[t.type]>32)throw new Error(`${t.type} is not supported yet`);if(t.bitPosition+t.bitSize>K[t.type])throw new Error(`bitPosition(${t.bitPosition}) + bitSize(${t.bitSize}) exceeds ${t.type} size for ${e}`)}o(Kr,"v");function Wi(t,e){Kr(e,"read operation");let{type:r,bitPosition:i,bitSize:n}=e,s=_r(n),a=t>>i&s;return Ye(r)&&a&1<<n-1?a|~s:a}o(Wi,"Z");function qi(t,e,r){Kr(e,"write operation"),Vi(e,r);let{bitPosition:i,bitSize:n}=e,s=Ji(e,r),a=_r(n)<<i;return t&~a|s<<i&a}o(qi,"q");function Yi(t,e=0,r=0){let[i,n]=t.split(":",2),s=parseInt(n,10),a=K[i],c=i.endsWith("BE");if(!a)throw new Error(`${i} is not supported`);if(r<0||r>=a)throw new Error(`Bitfield position ${r} is out of bounds (must be between 0 and ${a-1})`);if(!s)throw new Error(`${t} is not valid`);if(s+r>=a)throw new Error(`${i} size (${a}) is not enough to hold ${s} bits starting at position ${r}`);return{kind:"bitfield",type:i,size:a/8,position:e,bitSize:s,bitPosition:r,isBigEndian:c}}o(Yi,"$");function Gi(){let t=this.descriptor.position+this.offset,e=this.descriptor.isBigEndian?"BE":"LE",r=this.buffer[`readUInt${e}`](t,this.descriptor.size);return Wi(r,this.descriptor)}o(Gi,"C");function Xi(t){let e=this.descriptor.position+this.offset,r=this.descriptor.isBigEndian?"BE":"LE",i=this.buffer[`readUInt${r}`](e,this.descriptor.size),n=qi(i,this.descriptor,t);this.buffer[`writeUInt${r}`](n,e,this.descriptor.size)}o(Xi,"F");var Mr=new Set(["utf8","ascii","string"]);function Zi(t,e=0){let r=/^(utf8|ascii|string)(?:\[(\d+)\])?$/i,i=t.match(r);if(!i)throw new Error(`Invalid string descriptor: ${t}`);let n=i[1].toLowerCase(),s=i[2]?parseInt(i[2]):void 0;return{type:n,arraySize:s,position:e,size:2,lengthType:"UInt16LE",kind:"string"}}o(Zi,"A");function Ur(t=0){let{position:e,type:r,size:i}=this.descriptor,n=this.offset+e+t,s=r==="string"?"utf8":r;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let a=this.descriptor.lengthType,c=Number(Pr(this.buffer,a)(n)),u=n+i;if(this.offset+=c,u+c>this.buffer.length)throw new Error(`String prefix length exceeds buffer position: ${u} size: ${c} > ${this.buffer.length}`);return this.buffer.subarray(u,u+c).toString(s)}if("nullTerminated"in this.descriptor){let a=n,c="maxLength"in this.descriptor?this.descriptor.maxLength:0;for(;a<this.buffer.length&&this.buffer[a]!==0;){if(c&&a>c)throw new Error(`NullTerminated String exceeds maximum length of ${c}`);a++}let u=a-n;return this.offset+=u+1,this.buffer.subarray(n,a).toString(s)}return this.buffer.subarray(n,n+i).toString(s)}o(Ur,"M");function Qi(){let t=[],{arraySize:e=0,size:r}=this.descriptor;t.length=e;for(let i=0;i<e;i++)t[i]=Ur.call(this,i*r);return t}o(Qi,"Y");function en(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Qi.call(this):Ur.call(this)}o(en,"L");function Jr(t,e=0){t??="";let{position:r,type:i,size:n}=this.descriptor,s=this.offset+r+e,a=i==="string"?"utf8":i;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let c=Buffer.from(t,a);Nr(this.buffer,this.descriptor.lengthType)(c.length,s);let[u,p]=We(this.buffer,s+n);this.buffer=Buffer.concat([u,c,p]),this.offset+=c.length;return}if("nullTerminated"in this.descriptor){"maxLength"in this.descriptor&&this.descriptor.maxLength&&(t=t.length>this.descriptor.maxLength?t.slice(0,this.descriptor.maxLength):t);let c=t.endsWith("\0")?t:`${t}\0`,u=Buffer.from(c,a),[p,g]=We(this.buffer,s,n);this.buffer=Buffer.concat([p,u,g]),this.offset+=u.length;return}this.buffer.write(t,s,n,a)}o(Jr,"k");function tn(t){let{arraySize:e=0,size:r}=this.descriptor;for(let i=0;i<e;i++){let n=i<t.length?t[i]:"";Jr.call(this,n,i*r)}}o(tn,"O");function rn(t){return"arraySize"in this.descriptor&&this.descriptor.arraySize?tn.call(this,Array.isArray(t)?t:[t]):Jr.call(this,Array.isArray(t)?t[0]||"":t)}o(rn,"V");var U=class qe{static{o(this,"e")}size;schema=new Map;constructor(e){this.size=this.compileSchema(e)}toObject(e,r){if(!Buffer.isBuffer(e))throw new Error(`Expected a buffer, but received ${typeof e}`);if(e.length<this.size)throw new Error(`Buffer size is less than expected: ${e.length} < ${this.size}`);let i={},n={buffer:e,offset:0};for(let[s,a]of this.schema)n.descriptor=a,i[s]=this.readValue(n,a.kind);return r&&typeof r=="function"&&r(n.offset),i}toBuffer(e){if(!e||typeof e!="object")throw new Error(`Expected an object of fields, but received ${typeof e}`);let r={buffer:Buffer.alloc(this.size),offset:0};for(let[i,n]of this.schema){r.descriptor=n;let s=e[i];this.writeValue(r,n.kind,s)}return r.buffer}readValue(e,r){switch(r){case"struct":return Ni.call(e);case"bitfield":return Gi.call(e);case"string":return en.call(e);default:return _i.call(e)}}writeValue(e,r,i){switch(r){case"struct":Di.call(e,i);break;case"bitfield":Xi.call(e,i);break;case"string":rn.call(e,i);break;default:Ui.call(e,i)}}computeFieldSize(e,r){if(e.type instanceof qe)return{...e,position:r,size:e.type.size,kind:"struct"};if(Mr.has(e.type))return this.computeStringFieldSize(e,r);let i=K[e.type];if(i!==void 0)return{...e,position:r,size:i/8,kind:"primitive"};throw new Error(`Invalid field type: ${e.type}`)}computeStringFieldSize(e,r){let i={...e,position:r,kind:"string"};if("lengthType"in e&&e.lengthType){let n=K[e.lengthType];if(!n)throw new Error(`Invalid length type: ${e.lengthType}`);i.size=n/8}else"nullTerminated"in e&&e.nullTerminated?i.size=0:(!("size"in e)||!e.size)&&(i.lengthType="UInt16LE",i.size=K.UInt16LE/8);return i}parseStringNotation(e,r){return e.includes(":")?Yi(e,r):[...Mr].find(i=>e.startsWith(i))?Zi(e,r):Fi(e,r)}convertToSizedField(e,r){return e instanceof qe?{type:e,position:r,size:e.size,kind:"struct"}:typeof e=="string"?this.parseStringNotation(e,r):this.computeFieldSize(e,r)}compileSchema(e){let r={bits:0,bytes:0,bitFieldSize:0,bitFieldType:"UInt8"};for(let[i,n]of Object.entries(e)){let s=this.convertToSizedField(n,r.bytes);if("arraySize"in s&&s.arraySize&&s.arraySize>=Number.MAX_SAFE_INTEGER)throw new Error(`Array size exceeds maximum safe integer: ${s.arraySize}`);"bitSize"in s&&s.bitSize>0?this.processBitfield(r,i,s):this.processStandardField(r,i,s)}return r.bits>0&&(r.bytes+=r.bitFieldSize),r.bytes}processBitfield(e,r,i){let n=i.size*8,s=i.bitSize;(e.bits+s>n||e.bitFieldType!==i.type||e.bitFieldSize!==i.size)&&(e.bytes+=e.bitFieldSize,e.bits=0,i.position=e.bytes),i.bitPosition=e.bits,this.schema.set(r,i),e.bits+=s,e.bitFieldType=i.type,e.bitFieldSize=i.size}processStandardField(e,r,i){e.bits>0&&(e.bytes+=e.bitFieldSize,e.bits=0,i.position=e.bytes),this.schema.set(r,i);let n="arraySize"in i&&i.arraySize||0,s=n>0?i.size*n:i.size;e.bytes+=s}};var nn=new U({line:"UInt32LE",column:"UInt32LE",source:"string"}),Ge=new U({kind:"UInt8:4",suiteId:{type:"string",size:14},runnerId:{type:"string",size:14},timestamp:"string"}),Vr=new U({level:"UInt8",message:{type:"string",lengthType:"UInt32LE"},ancestry:{type:"string",lengthType:"UInt32LE"},invocation:nn}),Ee=new U({error:{type:"string",lengthType:"UInt32LE"}}),Wr=new U({type:"UInt8:5",todo:"UInt8:1",skipped:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"}}),qr=new U({type:"UInt8:5",passed:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"},errors:{type:"string",lengthType:"UInt32LE"}});var Yr={1:Vr,2:Ee,3:Wr,4:qr};function le(t,e){let r=Yr[t];if(!r)throw new Error(`Invalid schema kind: ${t}`);let i={kind:t,suiteId:globalThis?.__XJET?.runtime?.suiteId??"",runnerId:globalThis?.__XJET?.runtime.runnerId??"",timestamp:new Date().toISOString()};return Buffer.concat([Ge.toBuffer(i),r.toBuffer(e)])}o(le,"encodePacket");function Xr(t,e,r){let i=Ge.toBuffer({kind:2,suiteId:e??"",runnerId:r??"",timestamp:new Date().toISOString()}),n=Ee.toBuffer({error:JSON.stringify(H(t))});return Buffer.concat([i,n])}o(Xr,"encodeErrorSchema");function J(t,e={}){dispatch(le(3,{type:t,todo:e?.todo,skipped:e?.skipped,duration:e?.duration,ancestry:e?.ancestry?.join(","),description:e?.description}))}o(J,"emitStatus");function Te(t,e){let r=e.errors?.map(i=>H(i))||[];dispatch(le(4,{type:t,errors:r.length>0?JSON.stringify(r):"",ancestry:e.ancestry.join(""),duration:e.duration,description:e.description}))}o(Te,"emitEvent");var Xe=(s=>(s[s.Silent=0]="Silent",s[s.Error=1]="Error",s[s.Warn=2]="Warn",s[s.Info=3]="Info",s[s.Debug=4]="Debug",s))(Xe||{});var ue=class{constructor(e="",r={skip:!1,only:!1}){this.description=e;this.describeOptions=r}static{o(this,"DescribeModel")}ancestry=[];testsStack=[];describesStack=[];startTime=0;hooks={afterAll:[],afterEach:[],beforeAll:[],beforeEach:[]};get options(){return this.describeOptions}get tests(){return[...this.testsStack,...this.describesStack.flatMap(e=>e.tests)]}addHook(e,r){let i=this.hooks[e];if(!i)throw new Error(`Invalid hook type: ${e}`);i.push(r)}addTest(e){e&&(e.setAncestry(this.ancestry),this.description&&e.setAncestry([this.description]),e.applyExecutionFlags(this.options.skip,this.options.only),this.testsStack.push(e))}addDescribe(e){e&&(e.inheritFromParentDescribe(this),this.describesStack.push(e))}async run(e){this.startTime=Date.now(),this.notifyDescribeStatus(this.options.skip);let r=!e.afterAllErrors?.length,i=!e.beforeAllErrors?.length;try{e.beforeAllErrors?.length||await this.executeHooks("beforeAll",e);for(let n of this.shuffleTests(this.testsStack)){if(e.hasError)return;await n.run(e,this.executeHooks.bind(this))}for(let n of this.describesStack){if(e.hasError)return;await n.run(e)}await this.executeHooks("afterAll",e),e.afterAllErrors?.length?this.notifyDescribeFailure(e.afterAllErrors):this.notifyDescribeAction()}catch(n){this.notifyDescribeFailure([n,...e.afterAllErrors]),globalThis.__XJET?.runtime.bail&&(e.hasError=!0)}finally{r&&(e.afterAllErrors=[]),i&&(e.beforeAllErrors=[])}}inheritFromParentDescribe(e){this.ancestry.push(...e.ancestry),this.hooks.beforeEach=[...e.hooks.beforeEach,...this.hooks.beforeEach],this.hooks.afterEach=[...e.hooks.afterEach,...this.hooks.afterEach],e.description&&this.ancestry.push(e.description),e.options.skip&&(this.describeOptions.skip=!0),e.options.only&&(this.describeOptions.only=!0)}async executeHooks(e,r){if(!this.options.skip){r.beforeAllErrors=r.beforeAllErrors||[],r.afterAllErrors=r.afterAllErrors||[];for(let i of this.hooks[e])try{await i.run(r)}catch(n){await this.handleHookError(e,n,r)}}}async handleHookError(e,r,i){if(e==="beforeAll")i.beforeAllErrors.push(r);else if(e==="afterAll")i.afterAllErrors.push(r);else throw r}getExecutionDuration(){return this.startTime===0?0:Date.now()-this.startTime}notifyDescribeStatus(e=!1){J(2,{skipped:e,ancestry:this.ancestry,description:this.description})}notifyDescribeAction(e=[]){Te(2,{errors:e,ancestry:this.ancestry,description:this.description,duration:this.getExecutionDuration()})}notifyDescribeFailure(e){e?.length&&this.notifyDescribeAction(e)}shuffleTests(e){if(!(globalThis.__XJET?.runtime.randomize??!1)||e.length<=1)return e;let i=e.length;for(let n=i-1;n>0;n--){let s=Math.floor(Math.random()*(n+1));[e[n],e[s]]=[e[s],e[n]]}return e}};var R=class extends Error{static{o(this,"ExecutionError")}constructor(e){super(e),this.name="xJetExecutionError"}toJSON(){let e={};for(let r of Object.keys(this)){let i=this[r];i&&(e[r]=i)}return e.name=this.name,e.stack=this.stack,e.message=this.message,e}};var ei,Ze;ei=[Or({scope:"singleton"})];var V=class V{static{o(this,"SuiteState")}onlyMode=!1;currentDescribe;currentTest;hasTests=!1;rootDescribe;filterRegexChain=[];constructor(){this.rootDescribe=new ue,this.currentDescribe=this.rootDescribe,Array.isArray(__XJET?.runtime.filter)&&__XJET.runtime.filter.length>0&&(this.onlyMode=!0,this.filterRegexChain=__XJET.runtime.filter.map(e=>new RegExp(`^${e}$`)))}static matchesFilter(e,r){if(r.length>e.length)return!1;let i=e.length-r.length;return r.every((n,s)=>n.test(e[i+s]))}get isOnlyMode(){return this.onlyMode}get root(){return this.rootDescribe}get describe(){return this.currentDescribe}get test(){return this.currentTest}set test(e){this.currentTest=e}async run(e){try{let r=Date.now();if(J(4),!this.hasTests)throw new R("Your test suite must contain at least one test");await this.root.run(e),J(3,{duration:Date.now()-r})}catch(r){dispatch(Xr(r,__XJET.runtime.suiteId,__XJET.runtime.runnerId))}}addDescribe(e,r,i={},n=[]){let s={skip:!1,only:!1,...i};if(s.only&&(this.onlyMode=!0),this.filterRegexChain.length>0){let u=[...this.currentDescribe.ancestry,this.currentDescribe.description,e];V.matchesFilter(u,this.filterRegexChain)&&(s.only=!0)}let a=new ue(e,s);this.currentDescribe.addDescribe(a);let c=this.currentDescribe;this.currentDescribe=a;try{r.apply({},n)}finally{this.currentDescribe=c}}addTest(e){if(this.hasTests=!0,e.options.only&&(this.onlyMode=!0),this.currentDescribe.addTest(e),this.filterRegexChain.length>0){let r=[...e.ancestry,e.description];V.matchesFilter(r,this.filterRegexChain)&&(e.options.only=!0)}}};Ze=nt(null),V=at(Ze,0,"SuiteState",ei,V),ot(Ze,1,V);var E=V;var Q={V8:{GLOBAL:/at\s(.*):(\d+):(\d+)/,STANDARD:/at\s(.*?)\((?:(.+?):(\d+):(\d+)|(native))\)/,EVAL:/^at\s(.+?)\s\(eval\sat\s(.+?)\s?\((.*):(\d+):(\d+)\),\s(.+?):(\d+):(\d+)\)$/},SPIDERMONKEY:{EVAL:/^(.*)@(.+?):(\d+):(\d+),\s(.+?)@(.+?):(\d+):(\d+)$/,STANDARD:/^(.*)@(.*?)(?:(\[native code\])|:(\d+):(\d+))$/},JAVASCRIPT_CORE:{STANDARD:/^(?:(global|eval)\s)?(.*)@(.*?)(?::(\d+)(?::(\d+))?)?$/}},sn=(t=>(t[t.V8=0]="V8",t[t.SPIDERMONKEY=1]="SPIDERMONKEY",t[t.JAVASCRIPT_CORE=2]="JAVASCRIPT_CORE",t[t.UNKNOWN=3]="UNKNOWN",t))(sn||{});function on(t){return t.startsWith(" at ")||t.startsWith("at ")?0:t.includes("@")?/(?:global|eval) code@/.test(t)?2:1:3}o(on,"l");function W(t){return t.startsWith("file://")?t.startsWith("file:///")&&/^file:\/\/\/[A-Za-z]:/.test(t)?t.substring(8):t.substring(7):(t=t.replace(/\\/g,"/"),t)}o(W,"c");function Qe(t){return{source:t,eval:!1,async:!1,native:!1,constructor:!1}}o(Qe,"u");function $(t){return t&&t.trim()!==""?parseInt(t,10):void 0}o($,"i");function an(t){let e=Qe(t);t.toLowerCase().includes("new")&&(e.constructor=!0),t.toLowerCase().includes("async")&&(e.async=!0);let r=t.match(Q.V8.EVAL),i=t.match(Q.V8.GLOBAL),n=!r&&t.match(Q.V8.STANDARD);return r?(e.eval=!0,e.functionName=r[1]||void 0,e.evalOrigin={line:$(r[4])??void 0,column:$(r[5])??void 0,fileName:r[3]?W(r[3]):void 0,functionName:r[2]||"<anonymous>"},e.line=$(r[7])??void 0,e.column=$(r[8])??void 0,e.fileName=r[6]?W(r[6]):void 0):n?(e.functionName=n[1]?n[1].trim():void 0,n[5]==="native"?(e.native=!0,e.fileName="[native code]"):(e.line=$(n[3])??void 0,e.column=$(n[4])??void 0,e.fileName=n[2]?W(n[2]):void 0,e.fileName?.includes("node:")&&(e.native=!0))):i&&(e.fileName=i[1]?W(i[1]):void 0,e.line=$(i[2])??void 0,e.column=$(i[3])??void 0),e}o(an,"N");function cn(t){let e=Qe(t),r=t.match(Q.SPIDERMONKEY.EVAL);if(r)return e.eval=!0,e.functionName=r[1]?r[1]:void 0,t.toLowerCase().includes("constructor")&&(e.constructor=!0),t.toLowerCase().includes("async")&&(e.async=!0),e.evalOrigin={line:$(r[7])??void 0,column:$(r[8])??void 0,fileName:W(r[6]),functionName:r[5]?r[5]:void 0},e.line=$(r[3])??void 0,e.column=$(r[4])??void 0,e;let i=t.match(Q.SPIDERMONKEY.STANDARD);return i&&(e.functionName=i[1]?i[1]:void 0,e.fileName=W(i[2]),i[3]==="[native code]"?e.fileName="[native code]":(e.line=$(i[4])??void 0,e.column=$(i[5])??void 0)),e}o(cn,"S");function ln(t){let e=Qe(t),r=t.match(Q.JAVASCRIPT_CORE.STANDARD);return r&&(e.functionName=r[2],e.eval=r[1]==="eval"||r[3]==="eval",t.toLowerCase().includes("constructor")&&(e.constructor=!0),t.toLowerCase().includes("async")&&(e.async=!0),r[3]==="[native code]"?(e.native=!0,e.fileName="[native code]"):(e.line=$(r[4])??void 0,e.column=$(r[5])??void 0,e.fileName=W(r[3]))),e}o(ln,"p");function un(t,e){switch(e){case 1:return cn(t);case 2:return ln(t);case 0:default:return an(t)}}o(un,"g");function hn(t){if(!t)return"";let e=/^\s*at .+$|^.+@.+:\d+:\d+$|^@.+:\d+:\d+$|^.+@\[native code\]$/,r=t.split(`
|
|
62
|
+
You probably need to use \`${Pi("toContainEqual")}\` instead.
|
|
63
|
+
`)),s.push(`Expected value: ${m(d(t))}`),s.push(`Received array: ${p(d(i))}`))}})}o(Er,"Ge");u(Er,"toContain");function kr(t){let e=["expected"];S.call(this,this.received,["string","Array"],"Received",e);let r=this.received,i=j(r),n=[...r].findIndex(s=>x(s,t))!==-1;b.call(this,{pass:n,expectedLabels:e,comment:"deep equality",handleNot(s){s.push(`Expected value: not ${m(d(t))}`),s.push(`Received array: ${p(d(r)).replace(d(t),N(d(t)))}`)},handleInfo(s){i==="string"&&typeof t=="string"&&r.indexOf(t)!==-1&&s.push(M("Looks like you wanted to test for string equality with the stricter `toContainEqual` matcher. You probably need to use `toContain` instead.\n")),s.push(`Expected: ${m(d(t))}`),s.push(`Received: ${p(d(r))}`)}})}o(kr,"Ze");u(kr,"toContainEqual");function wr(t){let e=["expected"];Ye.call(this,this.received,"Received",e),S.call(this,this.received,["object"],"Received",e),S.call(this,t,["object"],"Expected",e);let r=this.received,i=x(t,r,!1);P.call(this,{pass:i,expected:t,expectedLabels:e})}o(wr,"_e");u(wr,"toMatchObject");var dt={toThrow:qt,toMatch:Gt,toHaveLength:Yt,toContain:Er,toMatchObject:wr,toHaveProperty:Tr,toBeInstanceOf:xr,toContainEqual:kr,toBe:pr,toEqual:fr,toBeNaN:gr,toBeNull:dr,toBeFalsy:vr,toBeTruthy:yr,toBeDefined:br,toBeUndefined:mr,toBeCloseTo:Xt,toBeLessThan:er,toBeGreaterThan:Zt,toBeLessThanOrEqual:tr,toBeGreaterThanOrEqual:Qt,toHaveReturned:cr,toHaveBeenCalled:ir,toHaveReturnedTimes:lr,toHaveBeenCalledWith:sr,toHaveBeenCalledTimes:nr,toHaveNthReturnedWith:hr,toHaveLastReturnedWith:ur,toHaveBeenNthCalledWith:ar,toHaveBeenLastCalledWith:or},D=class{static{o(this,"T")}constructor(t,e=!1){this.name=t,this.isInverse=e}static{u(this,"AbstractPattern")}applyInverse(t){return this.isInverse?!t:t}},Ni=class Te extends D{static{o(this,"e")}constructor(e){super(`Any<${e.name}>`),this.expected=e}static{u(this,"AnyPattern")}static TYPE_CHECKS={String:u(e=>typeof e=="string"||e instanceof String,"String"),Number:u(e=>typeof e=="number"||e instanceof Number,"Number"),Function:u(e=>typeof e=="function"||e instanceof Function,"Function"),Boolean:u(e=>typeof e=="boolean"||e instanceof Boolean,"Boolean"),BigInt:u(e=>typeof e=="bigint"||e instanceof BigInt,"BigInt"),Symbol:u(e=>typeof e=="symbol"||e instanceof Symbol,"Symbol"),Object:u(e=>typeof e=="object","Object"),Array:Array.isArray};static create(e){if(e===void 0)throw new TypeError("any() expects to be passed a constructor function. Please pass one or use anything() to match any object.");return new Te(e)}get expectedLabel(){return`Any<${this.expected.name}>`}matches(e){return this.expected.name in Te.TYPE_CHECKS?Te.TYPE_CHECKS[this.expected.name](e):e instanceof this.expected}},mt=class Sr extends D{static{o(this,"e")}constructor(e,r){super("ArrayOf",e),this.expected=r}static{u(this,"ArrayOfPattern")}static create(e,r){if(r===void 0)throw new TypeError("arrayOf() expects a matcher or value.");return new Sr(e,r)}get expectedLabel(){return`${this.isInverse?"Not ":""}ArrayOf( ${this.describe(this.expected)} )`}matches(e){if(!Array.isArray(e))return this.applyInverse(!1);let r=e.every(i=>this.matchElement(i,this.expected));return this.applyInverse(r)}matchElement(e,r){return I(r)?r.matches(e):x(e,r)}describe(e){return I(e)?e.expectedLabel:typeof e=="string"?`"${e}"`:w(e,"").join(" ")}},gt=class Ar extends D{static{o(this,"e")}constructor(e,r,i=2){super("CloseTo",e),this.expected=r,this.precision=i}static{u(this,"CloseToPattern")}static create(e,r,i){return new Ar(e,r,i)}get expectedLabel(){let e=this.isInverse?"Not ":"",r=this.precision!==1?"s":"";return`${e}CloseTo(${this.expected}, ${this.precision} digit${r})`}matches(e){let r=this.expected;return typeof e!="number"||typeof r!="number"?this.applyInverse(!1):this.applyInverse(Math.abs(e-r)<Math.pow(10,-this.precision)/2)}},Di=class $r extends D{static{o(this,"e")}static{u(this,"AnythingPattern")}constructor(){super("Anything")}static create(){return new $r}get expectedLabel(){return"Anything"}matches(e){return e!=null}},yt=class Ir extends D{static{o(this,"e")}constructor(e,r){super("StringMatching",e),this.expected=r}static{u(this,"StringMatchingPattern")}static create(e,r){let i=typeof r;if(r==null)throw new TypeError("stringMatching() expects a string or RegExp.");if(i!=="string"&&!(r instanceof RegExp))throw new TypeError("stringMatching() expects a string or RegExp.");return new Ir(e,r)}get expectedLabel(){let e=this.isInverse?"Not ":"";return typeof this.expected=="string"?`${e}stringMatching("${this.expected}")`:`${e}stringMatching(${this.expected.toString()})`}matches(e){if(typeof e!="string")return this.applyInverse(!1);let r;return typeof this.expected=="string"?r=e.includes(this.expected):r=this.expected.test(e),this.applyInverse(r)}},vt=class Cr extends D{static{o(this,"e")}constructor(e,r){super("ArrayContaining",e),this.expected=r}static{u(this,"ArrayContainingPattern")}static create(e,r){if(!Array.isArray(r))throw new TypeError("arrayContaining() expects an array.");return new Cr(e,r)}get expectedLabel(){return`${this.isInverse?"Not ":""}ArrayContaining(${this.describe(this.expected)})`}matches(e){if(!Array.isArray(e))return this.applyInverse(!1);let r=this.expected.every(i=>e.some(n=>this.matchElement(n,i)));return this.applyInverse(r)}matchElement(e,r){return I(r)?r.matches(e):x(e,r)}describe(e){return I(e)?e.expectedLabel:w(e,"").join(" ")}},bt=class Rr extends D{static{o(this,"e")}constructor(e,r){super("ObjectContaining",e),this.expected=r}static{u(this,"ObjectContainingPattern")}static create(e,r){if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError("objectContaining() expects a plain object.");return new Rr(e,r)}get expectedLabel(){return`${this.isInverse?"Not ":""}ObjectContaining(${this.describe(this.expected)})`}matches(e){if(typeof e!="object"||e===null)return this.applyInverse(!1);let r=Object.keys(this.expected).every(i=>Ee(e,i)?this.matchElement(e[i],this.expected[i]):!1);return this.applyInverse(r)}matchElement(e,r){return I(r)?r.matches(e):x(e,r)}describe(e){return I(e)?e.expectedLabel:w(e,"").join(" ")}},Tt=class Lr extends D{static{o(this,"e")}constructor(e,r){super("StringContaining",e),this.expected=r}static{u(this,"StringContainingPattern")}static create(e,r){if(typeof r!="string")throw new TypeError("stringContaining() expects a string.");return new Lr(e,r)}get expectedLabel(){return`${this.isInverse?"Not ":""}stringContaining("${this.expected}")`}matches(e){return typeof e!="string"?this.applyInverse(!1):this.applyInverse(e.includes(this.expected))}},zi={any:Ni.create,anything:Di.create,closeTo:gt.create.bind(null,!1),arrayOf:mt.create.bind(null,!1),stringMatching:yt.create.bind(null,!1),arrayContaining:vt.create.bind(null,!1),objectContaining:bt.create.bind(null,!1),stringContaining:Tt.create.bind(null,!1),not:{closeTo:gt.create.bind(null,!0),arrayOf:mt.create.bind(null,!0),stringMatching:yt.create.bind(null,!0),arrayContaining:vt.create.bind(null,!0),objectContaining:bt.create.bind(null,!1),stringContaining:Tt.create.bind(null,!0)}},Hi=class extends qe{static{o(this,"oe")}static{u(this,"xJetPromiseError")}constructor(t){let e=[`${we(t)}
|
|
64
|
+
`,`Matcher error: ${t.message}`,`${t.promiseKind} to value: ${p(w(t.received,"").join(" "))}`];super(e.join(`
|
|
65
|
+
`),"xJetPromiseError")}},Or=class{static{o(this,"U")}constructor(t){this.received=t}static{u(this,"MatcherService")}macherName="";promise;notModifier=!1;assertionChain=[];rejectsModifier=!1;resolvesModifier=!1;get not(){return this.notModifier=!0,this}get rejects(){if(this.resolvesModifier)throw new Error('Cannot use "rejects" modifier after "resolved" modifier.');return this.rejectsModifier=!0,this}get resolves(){if(this.rejectsModifier)throw new Error('Cannot use "resolved" modifier after "rejects" modifier.');return this.resolvesModifier=!0,this}invoke(t,e,r){return this.macherName=t,this.rejectsModifier||this.resolvesModifier?(this.pushToChain(t),this.promise=this.resolvesModifier?"resolves":"rejects",this.invokeAsync(e,r)):(this.pushToChain(t),e.call(this,...r))}async invokeAsync(t,e){let r=!1,i=typeof this.received=="function"?this.received():this.received;if(!Z(i))throw new K({message:`${p("received")} value must be a promise or a function returning a promise`,assertionChain:this.assertionChain,received:{type:j(i),value:i}});try{this.received=await i,r=!0}catch(n){this.resolvesModifier&&this.throwPromiseError("Rejected",n),this.received=n}return r&&this.rejectsModifier&&this.throwPromiseError("Resolved",this.received),t.call(this,...e)}pushToChain(t){this.promise&&this.assertionChain.push(this.promise),this.notModifier&&this.assertionChain.push("not"),this.assertionChain.push(t)}throwPromiseError(t,e){let r=t==="Resolved"?"resolved":"rejected",i=t==="Resolved"?"rejected":"resolved";throw new Hi({message:`${p("received")} promise ${r} instead of ${i}`,received:e,promiseKind:t,assertionChain:this.assertionChain})}};for(let t of Object.keys(dt)){let e=Or.prototype,r=dt[t];Object.defineProperty(e,t,{value:u(function(...i){return this.invoke(t,r,i)},"value")}),Object.defineProperty(e[t],"name",{value:t})}var _i=u((t,...e)=>{if(e.length>0)throw new Error(`Expect takes at most one argument. Received ${e.length+1} arguments instead.`);return new Or(t)},"coreExpect"),jr=Object.assign(_i,zi);var Ki="xJet.mock()",$=class t extends Function{static{o(this,"MockState")}static mocks=[];name;xJetMock=!0;state;restore;queuedImplementations=[];implementation;originalImplementation;constructor(e,r,i){return super(),this.name=i??Ki,this.state=this.initState(),this.implementation=e,this.restore=r||(()=>{this.implementation=e}),this.originalImplementation=e||(()=>{}),new Proxy(this,{apply:this.invokeFunction,construct:this.invokeClass})}getMockName(){return this.name}get mock(){return this.state}get original(){return this.originalImplementation}mockClear(){return this.state=this.initState(),this}mockReset(){return this.mockClear(),this.queuedImplementations=[],this}mockRestore(){this.restore(),this.mockReset();let e=t.mocks.indexOf(this);return e!==-1&&t.mocks.splice(e,1),this}getMockImplementation(){return this.implementation}getNextImplementation(){return this.queuedImplementations.length?this.queuedImplementations.shift():this.implementation}mockImplementation(e){return this.implementation=e,this}mockImplementationOnce(e){return this.queuedImplementations.push(e),this}mockReturnValue(e){return this.mockImplementation(()=>e),this}mockResolvedValue(e){return this.mockImplementation(()=>Promise.resolve(e)),this}mockResolvedValueOnce(e){return this.mockImplementationOnce(()=>Promise.resolve(e)),this}mockReturnValueOnce(e){return this.mockImplementationOnce(()=>e),this}mockRejectedValue(e){return this.mockImplementation(()=>Promise.reject(e)),this}mockRejectedValueOnce(e){return this.mockImplementationOnce(()=>Promise.reject(e)),this}[Symbol.for("nodejs.util.inspect.custom")](){return`<Mock Constructor ${this.name}>`}initState(){return{calls:[],results:[],lastCall:void 0,contexts:[],instances:[],invocationCallOrder:[]}}invoke(e,r){let i=e,n=this.getNextImplementation(),s=r;typeof n=="function"&&(n.__boundArgs&&s.unshift(...n.__boundArgs),n.__boundThis&&(i=n.__boundThis)),this.state.calls.push(s),this.state.contexts.push(i),this.state.invocationCallOrder.push(this.state.invocationCallOrder.length+1);let a,c=this.state.results.push({value:void 0,type:"incomplete"})-1;if(n)try{a={type:"return",value:n.call(void 0,...r)}}catch(l){a={value:l,type:"throw"}}else a={type:"return",value:void 0};return this.state.lastCall=r,this.state.results[c]=a,a.value}invokeFunction(e,r,i){return e.state.instances.push(r),e.invoke.call(e,r,i)}invokeClass(e,r,i){let n=e.invoke.call(e,i,r),s=typeof n=="object"&&n!==null&&n.constructor;return e.state.instances.push(s?n:i),typeof n=="object"?n:i}};var Xe=new Map,Br=new Map;function Se(t){return function(e){Br.set(e,t||{})}}o(Se,"Injectable");function v(t,...e){if(Xe.has(t))return Xe.get(t);let r=Br.get(t);if(!r)throw new Error(`Cannot inject ${t.name} \u2013 not marked @Injectable`);let i=r.factory?r.factory(...e):new t(...e);return r?.scope==="singleton"&&Xe.set(t,i),i}o(v,"inject");function Fr(t,e,r){let i=`${e}${r}`,n=t[i];if(!r)throw new Error(`Invalid type(${r}) parameter`);if(!(i in t))throw new Error(`Method "${i.toString()}" does not exist on Buffer`);return n.bind(t)}o(Fr,"b");function Nr(t,e){return Fr(t,"read",e)}o(Nr,"h");function Dr(t,e){return Fr(t,"write",e)}o(Dr,"d");function Ze(t,e,r=0){if(e<0)throw new Error("Split position cannot be negative");if(e>t.length)throw new Error("Split position cannot exceed buffer length");let i=t.subarray(0,e),n=e+r;return n>=t.length?[i,Buffer.alloc(0)]:[i,t.subarray(n)]}o(Ze,"f");function zr(t=0){let{position:e,type:r}=this.descriptor,i=this.offset+e+t;return r.toObject(this.buffer.subarray(i),n=>{this.offset+=n})}o(zr,"l");function Ui(){let t=[],{arraySize:e=0,size:r}=this.descriptor;t.length=e;for(let i=0;i<e;i++)t[i]=zr.call(this,i*r);return t}o(Ui,"U");function Ji(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Ui.call(this):zr.call(this)}o(Ji,"S");function Hr(t,e=0){t??={};let{position:r,type:i,size:n}=this.descriptor,s=i.toBuffer(t),a=this.offset+r+e,[c,l]=Ze(this.buffer,a,n);this.buffer=Buffer.concat([c,s,l]),s.length>n&&(this.offset+=s.length-n)}o(Hr,"T");function Vi(t){let{arraySize:e=0,size:r}=this.descriptor;for(let i=0;i<e;i++){let n=i<t.length?t[i]:{};Hr.call(this,n,i*r)}}o(Vi,"W");function Wi(t){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Vi.call(this,Array.isArray(t)?t:[t]):Hr.call(this,Array.isArray(t)?t[0]||{}:t)}o(Wi,"I");var U={Int8:8,UInt8:8,Int16LE:16,Int16BE:16,UInt16LE:16,UInt16BE:16,FloatLE:32,FloatBE:32,Int32LE:32,Int32BE:32,UInt32LE:32,UInt32BE:32,DoubleLE:64,DoubleBE:64,BigInt64LE:64,BigInt64BE:64,BigUInt64LE:64,BigUInt64BE:64};function qi(t,e=0){let r=/^([A-Za-z][A-Za-z0-9]*)(?:\[(\d+)\])?$/i,i=t.match(r);if(!i)throw new Error(`Invalid primitive descriptor: ${t}`);let n=U[i[1]];if(!n)throw new Error(`Invalid primitive type: ${i[1]}`);let s=i[1],a=i[2]?parseInt(i[2]):void 0;return{type:s,position:e,size:n/8,arraySize:a,kind:"primitive"}}o(qi,"x");function _r(t=0){let{position:e,type:r}=this.descriptor,i=this.offset+e+t;return Nr(this.buffer,r)(i)}o(_r,"z");function Yi(){let t=[],{arraySize:e=0,size:r}=this.descriptor;t.length=e;for(let i=0;i<e;i++)t[i]=_r.call(this,i*r);return t}o(Yi,"N");function Gi(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?Yi.call(this):_r.call(this)}o(Gi,"w");function Kr(t,e=0){t??=0;let{position:r,type:i}=this.descriptor,n=i.includes("Big");if(n&&t===0&&(t=BigInt(0)),n&&typeof t!="bigint")throw new TypeError(`Expected a BigInt for field "${i}", but received ${t}`);if(!n&&typeof t!="number")throw new TypeError(`Expected a number for field "${i}", but received ${t}`);let s=this.offset+r+e;Dr(this.buffer,i)(t,s)}o(Kr,"B");function Xi(t){let{arraySize:e=0,size:r}=this.descriptor;for(let i=0;i<e;i++){let n=i<t.length?t[i]:0;Kr.call(this,n,i*r)}}o(Xi,"_");function Zi(t){if("arraySize"in this.descriptor&&this.descriptor.arraySize)return Xi.call(this,Array.isArray(t)?t:[t]);Kr.call(this,Array.isArray(t)?t[0]||0:t)}o(Zi,"P");var Mr=new Map;function et(t){return t.startsWith("Int")}o(et,"y");function Ur(t){let e=Mr.get(t);return e===void 0&&(e=(1<<t)-1,Mr.set(t,e)),e}o(Ur,"D");function Qi(t,e){return et(t.type)?Number(BigInt.asIntN(t.bitSize,BigInt(e))):e}o(Qi,"j");function en(t,e){let r=et(t.type),{bitSize:i,type:n}=t,s=r?(1<<i-1)-1:(1<<i)-1,a=r?-(1<<i-1):0;if(e<a||e>s)throw new RangeError(`Value ${e} does not fit within ${i} bits for type ${n}`)}o(en,"G");function Jr(t,e){if(t.bitSize<1||t.bitPosition<0)throw new Error(`bitSize(${t.bitSize}) and bitPosition(${t.bitPosition}) must be greater than bitSize(1) and bitPosition(0) for ${e}`);if(U[t.type]>32)throw new Error(`${t.type} is not supported yet`);if(t.bitPosition+t.bitSize>U[t.type])throw new Error(`bitPosition(${t.bitPosition}) + bitSize(${t.bitSize}) exceeds ${t.type} size for ${e}`)}o(Jr,"v");function tn(t,e){Jr(e,"read operation");let{type:r,bitPosition:i,bitSize:n}=e,s=Ur(n),a=t>>i&s;return et(r)&&a&1<<n-1?a|~s:a}o(tn,"Z");function rn(t,e,r){Jr(e,"write operation"),en(e,r);let{bitPosition:i,bitSize:n}=e,s=Qi(e,r),a=Ur(n)<<i;return t&~a|s<<i&a}o(rn,"q");function nn(t,e=0,r=0){let[i,n]=t.split(":",2),s=parseInt(n,10),a=U[i],c=i.endsWith("BE");if(!a)throw new Error(`${i} is not supported`);if(r<0||r>=a)throw new Error(`Bitfield position ${r} is out of bounds (must be between 0 and ${a-1})`);if(!s)throw new Error(`${t} is not valid`);if(s+r>=a)throw new Error(`${i} size (${a}) is not enough to hold ${s} bits starting at position ${r}`);return{kind:"bitfield",type:i,size:a/8,position:e,bitSize:s,bitPosition:r,isBigEndian:c}}o(nn,"$");function sn(){let t=this.descriptor.position+this.offset,e=this.descriptor.isBigEndian?"BE":"LE",r=this.buffer[`readUInt${e}`](t,this.descriptor.size);return tn(r,this.descriptor)}o(sn,"C");function on(t){let e=this.descriptor.position+this.offset,r=this.descriptor.isBigEndian?"BE":"LE",i=this.buffer[`readUInt${r}`](e,this.descriptor.size),n=rn(i,this.descriptor,t);this.buffer[`writeUInt${r}`](n,e,this.descriptor.size)}o(on,"F");var Pr=new Set(["utf8","ascii","string"]);function an(t,e=0){let r=/^(utf8|ascii|string)(?:\[(\d+)\])?$/i,i=t.match(r);if(!i)throw new Error(`Invalid string descriptor: ${t}`);let n=i[1].toLowerCase(),s=i[2]?parseInt(i[2]):void 0;return{type:n,arraySize:s,position:e,size:2,lengthType:"UInt16LE",kind:"string"}}o(an,"A");function Vr(t=0){let{position:e,type:r,size:i}=this.descriptor,n=this.offset+e+t,s=r==="string"?"utf8":r;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let a=this.descriptor.lengthType,c=Number(Nr(this.buffer,a)(n)),l=n+i;if(this.offset+=c,l+c>this.buffer.length)throw new Error(`String prefix length exceeds buffer position: ${l} size: ${c} > ${this.buffer.length}`);return this.buffer.subarray(l,l+c).toString(s)}if("nullTerminated"in this.descriptor){let a=n,c="maxLength"in this.descriptor?this.descriptor.maxLength:0;for(;a<this.buffer.length&&this.buffer[a]!==0;){if(c&&a>c)throw new Error(`NullTerminated String exceeds maximum length of ${c}`);a++}let l=a-n;return this.offset+=l+1,this.buffer.subarray(n,a).toString(s)}return this.buffer.subarray(n,n+i).toString(s)}o(Vr,"M");function cn(){let t=[],{arraySize:e=0,size:r}=this.descriptor;t.length=e;for(let i=0;i<e;i++)t[i]=Vr.call(this,i*r);return t}o(cn,"Y");function ln(){return"arraySize"in this.descriptor&&this.descriptor.arraySize?cn.call(this):Vr.call(this)}o(ln,"L");function Wr(t,e=0){t??="";let{position:r,type:i,size:n}=this.descriptor,s=this.offset+r+e,a=i==="string"?"utf8":i;if("lengthType"in this.descriptor&&this.descriptor.lengthType){if(this.descriptor.lengthType.includes("Big"))throw new Error("BigInt are not supported");let c=Buffer.from(t,a);Dr(this.buffer,this.descriptor.lengthType)(c.length,s);let[l,h]=Ze(this.buffer,s+n);this.buffer=Buffer.concat([l,c,h]),this.offset+=c.length;return}if("nullTerminated"in this.descriptor){"maxLength"in this.descriptor&&this.descriptor.maxLength&&(t=t.length>this.descriptor.maxLength?t.slice(0,this.descriptor.maxLength):t);let c=t.endsWith("\0")?t:`${t}\0`,l=Buffer.from(c,a),[h,g]=Ze(this.buffer,s,n);this.buffer=Buffer.concat([h,l,g]),this.offset+=l.length;return}this.buffer.write(t,s,n,a)}o(Wr,"k");function un(t){let{arraySize:e=0,size:r}=this.descriptor;for(let i=0;i<e;i++){let n=i<t.length?t[i]:"";Wr.call(this,n,i*r)}}o(un,"O");function hn(t){return"arraySize"in this.descriptor&&this.descriptor.arraySize?un.call(this,Array.isArray(t)?t:[t]):Wr.call(this,Array.isArray(t)?t[0]||"":t)}o(hn,"V");var J=class Qe{static{o(this,"e")}size;schema=new Map;constructor(e){this.size=this.compileSchema(e)}toObject(e,r){if(!Buffer.isBuffer(e))throw new Error(`Expected a buffer, but received ${typeof e}`);if(e.length<this.size)throw new Error(`Buffer size is less than expected: ${e.length} < ${this.size}`);let i={},n={buffer:e,offset:0};for(let[s,a]of this.schema)n.descriptor=a,i[s]=this.readValue(n,a.kind);return r&&typeof r=="function"&&r(n.offset),i}toBuffer(e){if(!e||typeof e!="object")throw new Error(`Expected an object of fields, but received ${typeof e}`);let r={buffer:Buffer.alloc(this.size),offset:0};for(let[i,n]of this.schema){r.descriptor=n;let s=e[i];this.writeValue(r,n.kind,s)}return r.buffer}readValue(e,r){switch(r){case"struct":return Ji.call(e);case"bitfield":return sn.call(e);case"string":return ln.call(e);default:return Gi.call(e)}}writeValue(e,r,i){switch(r){case"struct":Wi.call(e,i);break;case"bitfield":on.call(e,i);break;case"string":hn.call(e,i);break;default:Zi.call(e,i)}}computeFieldSize(e,r){if(e.type instanceof Qe)return{...e,position:r,size:e.type.size,kind:"struct"};if(Pr.has(e.type))return this.computeStringFieldSize(e,r);let i=U[e.type];if(i!==void 0)return{...e,position:r,size:i/8,kind:"primitive"};throw new Error(`Invalid field type: ${e.type}`)}computeStringFieldSize(e,r){let i={...e,position:r,kind:"string"};if("lengthType"in e&&e.lengthType){let n=U[e.lengthType];if(!n)throw new Error(`Invalid length type: ${e.lengthType}`);i.size=n/8}else"nullTerminated"in e&&e.nullTerminated?i.size=0:(!("size"in e)||!e.size)&&(i.lengthType="UInt16LE",i.size=U.UInt16LE/8);return i}parseStringNotation(e,r){return e.includes(":")?nn(e,r):[...Pr].find(i=>e.startsWith(i))?an(e,r):qi(e,r)}convertToSizedField(e,r){return e instanceof Qe?{type:e,position:r,size:e.size,kind:"struct"}:typeof e=="string"?this.parseStringNotation(e,r):this.computeFieldSize(e,r)}compileSchema(e){let r={bits:0,bytes:0,bitFieldSize:0,bitFieldType:"UInt8"};for(let[i,n]of Object.entries(e)){let s=this.convertToSizedField(n,r.bytes);if("arraySize"in s&&s.arraySize&&s.arraySize>=Number.MAX_SAFE_INTEGER)throw new Error(`Array size exceeds maximum safe integer: ${s.arraySize}`);"bitSize"in s&&s.bitSize>0?this.processBitfield(r,i,s):this.processStandardField(r,i,s)}return r.bits>0&&(r.bytes+=r.bitFieldSize),r.bytes}processBitfield(e,r,i){let n=i.size*8,s=i.bitSize;(e.bits+s>n||e.bitFieldType!==i.type||e.bitFieldSize!==i.size)&&(e.bytes+=e.bitFieldSize,e.bits=0,i.position=e.bytes),i.bitPosition=e.bits,this.schema.set(r,i),e.bits+=s,e.bitFieldType=i.type,e.bitFieldSize=i.size}processStandardField(e,r,i){e.bits>0&&(e.bytes+=e.bitFieldSize,e.bits=0,i.position=e.bytes),this.schema.set(r,i);let n="arraySize"in i&&i.arraySize||0,s=n>0?i.size*n:i.size;e.bytes+=s}};var pn=new J({line:"UInt32LE",column:"UInt32LE",source:"string"}),tt=new J({kind:"UInt8:4",suiteId:{type:"string",size:14},runnerId:{type:"string",size:14},timestamp:"string"}),qr=new J({level:"UInt8",message:{type:"string",lengthType:"UInt32LE"},ancestry:{type:"string",lengthType:"UInt32LE"},invocation:pn}),Ae=new J({error:{type:"string",lengthType:"UInt32LE"}}),Yr=new J({type:"UInt8:5",todo:"UInt8:1",skipped:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"}}),Gr=new J({type:"UInt8:5",passed:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"},errors:{type:"string",lengthType:"UInt32LE"}});var Xr={1:qr,2:Ae,3:Yr,4:Gr};function ue(t,e){let r=Xr[t];if(!r)throw new Error(`Invalid schema kind: ${t}`);let i={kind:t,suiteId:globalThis?.__XJET?.runtime?.suiteId??"",runnerId:globalThis?.__XJET?.runtime.runnerId??"",timestamp:new Date().toISOString()};return Buffer.concat([tt.toBuffer(i),r.toBuffer(e)])}o(ue,"encodePacket");function Qr(t,e,r){let i=tt.toBuffer({kind:2,suiteId:e??"",runnerId:r??"",timestamp:new Date().toISOString()}),n=Ae.toBuffer({error:JSON.stringify(_(t))});return Buffer.concat([i,n])}o(Qr,"encodeErrorSchema");function V(t,e={}){dispatch(ue(3,{type:t,todo:e?.todo,skipped:e?.skipped,duration:e?.duration,ancestry:e?.ancestry?.join(","),description:e?.description}))}o(V,"emitStatus");function $e(t,e){let r=e.errors?.map(i=>_(i))||[];dispatch(ue(4,{type:t,errors:r.length>0?JSON.stringify(r):"",ancestry:e.ancestry.join(""),duration:e.duration,description:e.description}))}o($e,"emitEvent");var rt=(s=>(s[s.Silent=0]="Silent",s[s.Error=1]="Error",s[s.Warn=2]="Warn",s[s.Info=3]="Info",s[s.Debug=4]="Debug",s))(rt||{});var he=class{constructor(e="",r={skip:!1,only:!1}){this.description=e;this.describeOptions=r}static{o(this,"DescribeModel")}ancestry=[];testsStack=[];describesStack=[];startTime=0;hooks={afterAll:[],afterEach:[],beforeAll:[],beforeEach:[]};get options(){return this.describeOptions}get tests(){return[...this.testsStack,...this.describesStack.flatMap(e=>e.tests)]}addHook(e,r){let i=this.hooks[e];if(!i)throw new Error(`Invalid hook type: ${e}`);i.push(r)}addTest(e){e&&(e.setAncestry(this.ancestry),this.description&&e.setAncestry([this.description]),e.applyExecutionFlags(this.options.skip,this.options.only),this.testsStack.push(e))}addDescribe(e){e&&(e.inheritFromParentDescribe(this),this.describesStack.push(e))}async run(e){this.startTime=Date.now(),this.notifyDescribeStatus(this.options.skip);let r=!e.afterAllErrors?.length,i=!e.beforeAllErrors?.length;try{e.beforeAllErrors?.length||await this.executeHooks("beforeAll",e);for(let n of this.shuffleTests(this.testsStack)){if(e.hasError)return;await n.run(e,this.executeHooks.bind(this))}for(let n of this.describesStack){if(e.hasError)return;await n.run(e)}await this.executeHooks("afterAll",e),e.afterAllErrors?.length?this.notifyDescribeFailure(e.afterAllErrors):this.notifyDescribeAction()}catch(n){this.notifyDescribeFailure([n,...e.afterAllErrors]),globalThis.__XJET?.runtime.bail&&(e.hasError=!0)}finally{r&&(e.afterAllErrors=[]),i&&(e.beforeAllErrors=[])}}inheritFromParentDescribe(e){this.ancestry.push(...e.ancestry),this.hooks.beforeEach=[...e.hooks.beforeEach,...this.hooks.beforeEach],this.hooks.afterEach=[...e.hooks.afterEach,...this.hooks.afterEach],e.description&&this.ancestry.push(e.description),e.options.skip&&(this.describeOptions.skip=!0),e.options.only&&(this.describeOptions.only=!0)}async executeHooks(e,r){if(!this.options.skip){r.beforeAllErrors=r.beforeAllErrors||[],r.afterAllErrors=r.afterAllErrors||[];for(let i of this.hooks[e])try{await i.run(r)}catch(n){await this.handleHookError(e,n,r)}}}async handleHookError(e,r,i){if(e==="beforeAll")i.beforeAllErrors.push(r);else if(e==="afterAll")i.afterAllErrors.push(r);else throw r}getExecutionDuration(){return this.startTime===0?0:Date.now()-this.startTime}notifyDescribeStatus(e=!1){V(2,{skipped:e,ancestry:this.ancestry,description:this.description})}notifyDescribeAction(e=[]){$e(2,{errors:e,ancestry:this.ancestry,description:this.description,duration:this.getExecutionDuration()})}notifyDescribeFailure(e){e?.length&&this.notifyDescribeAction(e)}shuffleTests(e){if(!(globalThis.__XJET?.runtime.randomize??!1)||e.length<=1)return e;let i=e.length;for(let n=i-1;n>0;n--){let s=Math.floor(Math.random()*(n+1));[e[n],e[s]]=[e[s],e[n]]}return e}};var R=class extends Error{static{o(this,"ExecutionError")}constructor(e){super(e),this.name="xJetExecutionError"}toJSON(){let e={};for(let r of Object.keys(this)){let i=this[r];i&&(e[r]=i)}return e.name=this.name,e.stack=this.stack,e.message=this.message,e}};var ri,it;ri=[Se({scope:"singleton"})];var W=class W{static{o(this,"SuiteState")}onlyMode=!1;currentDescribe;currentTest;hasTests=!1;rootDescribe;filterRegexChain=[];constructor(){this.rootDescribe=new he,this.currentDescribe=this.rootDescribe,Array.isArray(__XJET?.runtime.filter)&&__XJET.runtime.filter.length>0&&(this.onlyMode=!0,this.filterRegexChain=__XJET.runtime.filter.map(e=>new RegExp(`^${e}$`)))}static matchesFilter(e,r){if(r.length>e.length)return!1;let i=e.length-r.length;return r.every((n,s)=>n.test(e[i+s]))}get isOnlyMode(){return this.onlyMode}get root(){return this.rootDescribe}get describe(){return this.currentDescribe}get test(){return this.currentTest}set test(e){this.currentTest=e}async run(e){try{let r=Date.now();if(V(4),!this.hasTests)throw new R("Your test suite must contain at least one test");await this.root.run(e),V(3,{duration:Date.now()-r})}catch(r){dispatch(Qr(r,__XJET.runtime.suiteId,__XJET.runtime.runnerId))}}addDescribe(e,r,i={},n=[]){let s={skip:!1,only:!1,...i};if(s.only&&(this.onlyMode=!0),this.filterRegexChain.length>0){let l=[...this.currentDescribe.ancestry,this.currentDescribe.description,e];W.matchesFilter(l,this.filterRegexChain)&&(s.only=!0)}let a=new he(e,s);this.currentDescribe.addDescribe(a);let c=this.currentDescribe;this.currentDescribe=a;try{r.apply({},n)}finally{this.currentDescribe=c}}addTest(e){if(this.hasTests=!0,e.options.only&&(this.onlyMode=!0),this.currentDescribe.addTest(e),this.filterRegexChain.length>0){let r=[...e.ancestry,e.description];W.matchesFilter(r,this.filterRegexChain)&&(e.options.only=!0)}}};it=de(null),W=ge(it,0,"SuiteState",ri,W),me(it,1,W);var E=W;var ee={V8:{GLOBAL:/at\s(.*):(\d+):(\d+)/,STANDARD:/at\s(.*?)\((?:(.+?):(\d+):(\d+)|(native))\)/,EVAL:/^at\s(.+?)\s\(eval\sat\s(.+?)\s?\((.*):(\d+):(\d+)\),\s(.+?):(\d+):(\d+)\)$/},SPIDERMONKEY:{EVAL:/^(.*)@(.+?):(\d+):(\d+),\s(.+?)@(.+?):(\d+):(\d+)$/,STANDARD:/^(.*)@(.*?)(?:(\[native code\])|:(\d+):(\d+))$/},JAVASCRIPT_CORE:{STANDARD:/^(?:(global|eval)\s)?(.*)@(.*?)(?::(\d+)(?::(\d+))?)?$/}},fn=(t=>(t[t.V8=0]="V8",t[t.SPIDERMONKEY=1]="SPIDERMONKEY",t[t.JAVASCRIPT_CORE=2]="JAVASCRIPT_CORE",t[t.UNKNOWN=3]="UNKNOWN",t))(fn||{});function dn(t){return t.startsWith(" at ")||t.startsWith("at ")?0:t.includes("@")?/(?:global|eval) code@/.test(t)?2:1:3}o(dn,"l");function q(t){return t.startsWith("file://")?t.startsWith("file:///")&&/^file:\/\/\/[A-Za-z]:/.test(t)?t.substring(8):t.substring(7):(t=t.replace(/\\/g,"/"),t)}o(q,"c");function nt(t){return{source:t,eval:!1,async:!1,native:!1,constructor:!1}}o(nt,"u");function A(t){return t&&t.trim()!==""?parseInt(t,10):void 0}o(A,"i");function mn(t){let e=nt(t);t.toLowerCase().includes("new")&&(e.constructor=!0),t.toLowerCase().includes("async")&&(e.async=!0);let r=t.match(ee.V8.EVAL),i=t.match(ee.V8.GLOBAL),n=!r&&t.match(ee.V8.STANDARD);return r?(e.eval=!0,e.functionName=r[1]||void 0,e.evalOrigin={line:A(r[4])??void 0,column:A(r[5])??void 0,fileName:r[3]?q(r[3]):void 0,functionName:r[2]||"<anonymous>"},e.line=A(r[7])??void 0,e.column=A(r[8])??void 0,e.fileName=r[6]?q(r[6]):void 0):n?(e.functionName=n[1]?n[1].trim():void 0,n[5]==="native"?(e.native=!0,e.fileName="[native code]"):(e.line=A(n[3])??void 0,e.column=A(n[4])??void 0,e.fileName=n[2]?q(n[2]):void 0,e.fileName?.includes("node:")&&(e.native=!0))):i&&(e.fileName=i[1]?q(i[1]):void 0,e.line=A(i[2])??void 0,e.column=A(i[3])??void 0),e}o(mn,"N");function gn(t){let e=nt(t),r=t.match(ee.SPIDERMONKEY.EVAL);if(r)return e.eval=!0,e.functionName=r[1]?r[1]:void 0,t.toLowerCase().includes("constructor")&&(e.constructor=!0),t.toLowerCase().includes("async")&&(e.async=!0),e.evalOrigin={line:A(r[7])??void 0,column:A(r[8])??void 0,fileName:q(r[6]),functionName:r[5]?r[5]:void 0},e.line=A(r[3])??void 0,e.column=A(r[4])??void 0,e;let i=t.match(ee.SPIDERMONKEY.STANDARD);return i&&(e.functionName=i[1]?i[1]:void 0,e.fileName=q(i[2]),i[3]==="[native code]"?e.fileName="[native code]":(e.line=A(i[4])??void 0,e.column=A(i[5])??void 0)),e}o(gn,"S");function yn(t){let e=nt(t),r=t.match(ee.JAVASCRIPT_CORE.STANDARD);return r&&(e.functionName=r[2],e.eval=r[1]==="eval"||r[3]==="eval",t.toLowerCase().includes("constructor")&&(e.constructor=!0),t.toLowerCase().includes("async")&&(e.async=!0),r[3]==="[native code]"?(e.native=!0,e.fileName="[native code]"):(e.line=A(r[4])??void 0,e.column=A(r[5])??void 0,e.fileName=q(r[3]))),e}o(yn,"p");function vn(t,e){switch(e){case 1:return gn(t);case 2:return yn(t);case 0:default:return mn(t)}}o(vn,"g");function bn(t){if(!t)return"";let e=/^\s*at .+$|^.+@.+:\d+:\d+$|^@.+:\d+:\d+$|^.+@\[native code\]$/,r=t.split(`
|
|
66
66
|
`);for(let i=0;i<r.length;i++)if(e.test(r[i]))return r.slice(i).join(`
|
|
67
|
-
`);return""}o(
|
|
68
|
-
`).map(c=>c.trim()).filter(c=>c.trim()!=="");return{name:r,message:n,stack:a.map(c=>
|
|
67
|
+
`);return""}o(bn,"A");function ii(t){let e=typeof t=="string"?{stack:t,message:t,name:""}:t,r=e.name||"Error",i=bn(e.stack||""),n=e?.message||"",s=dn(i),a=i.split(`
|
|
68
|
+
`).map(c=>c.trim()).filter(c=>c.trim()!=="");return{name:r,message:n,stack:a.map(c=>vn(c,s)),rawStack:i}}o(ii,"E");function ni(t=2){let r=ii(new Error).stack[t];if(r?.line&&r?.column&&r?.fileName)return{line:r.line,column:r.column,source:r.fileName}}o(ni,"getInvocationLocation");function Y(t=2){let e=new Error;return e.stack?e.stack.split(`
|
|
69
69
|
`).slice(t+1).join(`
|
|
70
|
-
`):""}o(
|
|
71
|
-
`)).join(" "),s=
|
|
72
|
-
${i}`)}};async function
|
|
73
|
-
${e}`}};var
|
|
70
|
+
`):""}o(Y,"getTrimmedStackString");function pe(t){return function(...e){let r=v(E).test;r||(r=v(E).describe);let i=[...r?.ancestry??[],r?.description].join(","),n=e.map(a=>w(a).join(`
|
|
71
|
+
`)).join(" "),s=ni();dispatch(ue(1,{level:rt[t],message:n,ancestry:i??"",invocation:s}))}}o(pe,"createLogHandler");var si=pe("Info"),oi=pe("Info"),ai=pe("Warn"),ci=pe("Error"),li=pe("Debug");function xn(t,e){let r=t[e],i=Object.getOwnPropertyDescriptor(t,e)||{},n=new $(()=>r,()=>{t[e]=i.value,Object.defineProperty(t,e,i)},"xJet.spyOn()");return $.mocks.push(n),Object.defineProperty(t,e,{get(){return n.apply(this,[])},set(s){return n.mockImplementation(()=>s),n.apply(this,[s])}}),n}o(xn,"spyOnDescriptorProperty");function ui(t,e){if(t==null||typeof t!="object"&&typeof t!="function")throw new R("Target must be an object or function");if(e===null)throw new R("Spied property/method key is required");if(!(e in t))throw new R(`Property/method '${String(e)}' does not exist on target`);let r=Reflect.get(t,e),i=t;if(!r)throw new Error(`Property '${String(e)}' does not exist in the provided object`);if(r.xJetMock)return r;let n=Object.getOwnPropertyDescriptor(t,e);if(n?.get&&!n.configurable)if("default"in i&&i.default[e]===r)t=i.default,n=Object.getOwnPropertyDescriptor(t,e);else throw new Error(`Property '${String(e)}' is not configurable in an getter object`);if(typeof r!="function"||n?.get)return xn(t,e);let s=r,a=Object.getOwnPropertyDescriptor(s,"prototype");s.prototype&&a&&!a.writable&&(s=o((...l)=>new r(...l),"fn"));let c=new $(s,()=>{Reflect.set(t,e,r)},"xJet.spyOn()");return $.mocks.push(c),Reflect.set(t,e,c),c}o(ui,"spyOnImplementation");var hi,st;hi=[Se({scope:"singleton"})];var L=class{static{o(this,"TimerService")}timers=new Map;originalDateNow=Date.now;originalSetTimeout=globalThis.setTimeout;originalSetInterval=globalThis.setInterval;originalClearTimeout=globalThis.clearTimeout;originalClearInterval=globalThis.clearInterval;now=0;nextId=1;useFakeTimers(){let e=o((a,c=0,...l)=>{let h=this.nextId++;return this.timers.set(h,{id:h,callback:a,time:this.now+c,interval:null,args:l??[]}),h},"setTimeout"),r=o((a,c=0)=>{let l=this.nextId++;return this.timers.set(l,{id:l,callback:a,time:this.now+c,interval:c,args:[]}),l},"setInterval"),i=o(a=>{this.timers.delete(a)},"clearTimeout"),n=o(a=>{this.timers.delete(a)},"clearInterval"),s=globalThis;s.setTimeout=e,s.setInterval=r,s.clearTimeout=i,s.clearInterval=n}useRealTimers(){globalThis.setTimeout=this.originalSetTimeout,globalThis.clearTimeout=this.originalClearTimeout,globalThis.setInterval=this.originalSetInterval,globalThis.clearInterval=this.originalClearInterval,Date.now=this.originalDateNow}advanceTimersByTime(e){this.now+=e,this.runDueTimers()}runAllTimers(){for(;this.timers.size>0;)this.now=Math.min(...Array.from(this.timers.values()).map(e=>e.time)),this.runDueTimers()}runOnlyPendingTimers(){let e=new Set(this.timers.keys());for(;e.size>0;){let r=Array.from(this.timers.values()).filter(i=>e.has(i.id)).map(i=>i.time);if(r.length===0)break;this.now=Math.min(...r),this.runDueTimers(e);for(let i of e)this.timers.has(i)||e.delete(i)}}runDueTimers(e){let r=!0;for(;r;){r=!1;let i=Array.from(this.timers.values()).sort((n,s)=>n.time-s.time);for(let n of i)if(this.timers.has(n.id)&&!(e&&!e.has(n.id))&&n.time<=this.now){if(n.interval!==null)for(;n.time<=this.now;)n.callback(),n.time+=n.interval;else n.callback(),this.timers.delete(n.id);r=!0}}}};st=de(null),L=ge(st,0,"TimerService",hi,L),me(st,1,L);function pi(){v(L).useFakeTimers()}o(pi,"useFakeTimers");function fi(){v(L).useRealTimers()}o(fi,"useRealTimers");function di(){v(L).runAllTimers()}o(di,"runAllTimers");function mi(){v(L).runOnlyPendingTimers()}o(mi,"runOnlyPendingTimers");function gi(t=0){v(L).advanceTimersByTime(t)}o(gi,"advanceTimersByTime");var kn=/\$([#\w.])+/g;function wn(t){return typeof t=="string"?t:JSON.stringify(t,null,4)}o(wn,"prettyFormat");function Sn(t,e){if(!(!e.length||!t))try{return e.reduce((r,i)=>{if(r==null||typeof r!="object")throw new Error("Path traversal failed");return r[i]},t)}catch{return}}o(Sn,"getValueByPath");function An(t,e,r){if(!t||typeof t!="string"||!t.startsWith("$"))return t;if(t==="$#")return String(r);let i=t.slice(1).split("."),n=Sn(e,i);if(n==null)return t;if(typeof n=="object")try{return JSON.stringify(n,(s,a)=>s&&typeof a=="object"?"[Object]":a)}catch{return String(n)}return String(n)}o(An,"resolveVariable");function $n(t,e,r){return t.replace(kn,i=>An(i,e,r))}o($n,"interpolateVariables");function yi(t,e,r){let i=0;return t.includes("$")&&!t.includes("%%")&&(t=$n(t,e[0],r)),t.replace(/%([psdifjo#%])/g,(n,s)=>{if(s==="%")return"%";if(s==="#")return String(r);let a=e[i++];switch(s){case"p":return wn(a);case"s":return String(a);case"d":return Number(a).toString();case"i":return Math.floor(Number(a)).toString();case"f":return Number(a).toString();case"j":return JSON.stringify(a);case"o":return Object.prototype.toString.call(a);default:return n}})}o(yi,"printf");function In(t,e){let r=t[0].split("|").map(i=>i.trim());if(r.length===0||r.some(i=>i===""))throw new Error("Template string headings must not be empty and should contain pipe delimiters.");if(e.length%r.length!==0)throw new Error("Not enough arguments supplied for given headings.");return Array.from({length:e.length/r.length},(i,n)=>r.reduce((s,a,c)=>(s[a]=e[n*r.length+c],s),{}))}o(In,"parseTemplate");function Ie(t,...e){if(e.length<2)throw new Error("`.each` must be called with at leas 2 argument or Tagged Template Literal.");let i=e[0]instanceof Array&&e[0].raw!==void 0?In(e.shift(),e):e;return(n,s,a)=>{i.forEach((c,l)=>{let h=Array.isArray(c)?c:[c];t(yi(n,h,Number(l)),s,h,a)})}}o(Ie,"each");var Ce=class extends Error{static{o(this,"TimeoutError")}constructor(e,r,i=""){super(`Exceeded timeout of ${e} ms at ${r}`),Object.setPrototypeOf(this,new.target.prototype),this.name="xJetTimeoutError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="xJetFailingError",i&&(this.stack=`${this.name}: ${this.message}
|
|
72
|
+
${i}`)}};async function Re(t,e,r,i){let n=v(L),s=typeof t=="function"?Promise.resolve(t()):Promise.resolve(t);if(e===-1||!n.originalSetTimeout)return s;let a,c=new Promise((l,h)=>{a=n.originalSetTimeout?.(()=>h(new Ce(e,r,i)),e)});try{return await Promise.race([s,c])}finally{n.originalClearTimeout?.(a)}}o(Re,"withTimeout");var Le=class t extends R{static{o(this,"FailingError")}constructor(e){super("Failing test passed even though it was supposed to fail. Remove `.failing` to remove error."),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.name="xJetFailingError",this.stack=`${this.name}: ${this.message}
|
|
73
|
+
${e}`}};var Oe=class{constructor(e,r,i,n=[],s={}){this.description=e;this.testImplementation=r;this.timeoutDuration=i;this.testParameters=n;this.testOptions=s}static{o(this,"TestModel")}ancestry=[];executionLocation="";executionStartTime=0;get options(){return this.testOptions}setExecutionLocation(e){this.executionLocation=e}applyExecutionFlags(e,r){this.testOptions.skip||=e,this.testOptions.only||=r}setAncestry(e){this.ancestry.push(...e)}async run(e,r,i=!1){if(v(E).test=this,this.executionStartTime=Date.now(),!this.shouldSkipDueToSetupErrors(e)&&!this.determineSkipAction(i))try{await this.executeTestWithLifecycle(e,r),this.validateTestOutcome()}catch(n){this.notifyTestFailure(n),globalThis.__XJET?.runtime.bail&&(e.hasError=!0)}finally{v(E).test=void 0}}shouldSkipDueToSetupErrors(e){return e.beforeAllErrors&&e.beforeAllErrors.length>0?(this.notifyTestFailure(e.beforeAllErrors),!0):!1}determineSkipAction(e){return v(E).isOnlyMode&&!this.testOptions.only?(this.notifyTestStatus(!0),!0):this.testOptions.skip||this.testOptions.todo?(this.notifyTestStatus(this.testOptions.skip,this.testOptions.todo),!0):e&&!this.testOptions.only?(this.notifyTestStatus(!0),!0):!1}async executeTestWithLifecycle(e,r){await r("beforeEach",e),await Re(this.executeTestWithContext(e),this.timeoutDuration,`'${this.timeoutDuration}' test`,this.executionLocation),await r("afterEach",e)}validateTestOutcome(){if(this.testOptions.failing)throw new Le(this.executionLocation);this.notifyTestAction()}isCallbackStyle(){return this.testImplementation.length===1&&this.testParameters.length===0?!0:this.testImplementation.length===2}getExecutionStrategy(){return Z(this.testImplementation)?"ASYNC":this.isCallbackStyle()?"CALLBACK":"SYNC"}async executeTestWithContext(e){switch(this.getExecutionStrategy()){case"ASYNC":case"SYNC":await this.testImplementation.apply(e,this.testParameters);break;case"CALLBACK":await this.executeCallbackStyleTest(e);break}}async executeCallbackStyleTest(e){return new Promise((r,i)=>{let n=o(a=>{a&&i(a),r()},"callbackFn"),s=[...this.testParameters];s.push(n),this.testImplementation.apply(e,s)})}getExecutionDuration(){return this.executionStartTime===0?0:Date.now()-this.executionStartTime}notifyTestStatus(e=!1,r=!1){V(1,{todo:r,skipped:e,ancestry:this.ancestry,description:this.description})}notifyTestAction(e=[]){$e(1,{errors:e,ancestry:this.ancestry,duration:this.getExecutionDuration(),description:this.description})}notifyTestFailure(e){this.notifyTestAction(Array.isArray(e)?e:[e])}};var fe=class t extends Function{static{o(this,"TestDirective")}static instance;static ERROR_MESSAGES={SKIP_ONLY:'Cannot use "only" flag on skipped test',ONLY_SKIP:'Cannot use "skip" flag on only test',SKIP_TODO:'Cannot use "todo" flag on skipped test',SKIP_FAILING:'Cannot use "failing" flag on skipped test'};static DEFAULT_TIMEOUT=globalThis.__XJET?.runtime.timeout??5e3;options={};invocationStack="";constructor(){return super(),new Proxy(this,{apply:o((e,r,i)=>{let[n,s,a]=i;this.invocationStack=Y(2),e.invoke(n,s,[],a)},"apply")})}static getInstance(){return t.instance||(t.instance=new t),t.instance}get skip(){if(this.options.only)throw new Error(t.ERROR_MESSAGES.ONLY_SKIP);return this.options.skip=!0,this}get only(){if(this.options.skip)throw new Error(t.ERROR_MESSAGES.SKIP_ONLY);return this.options.only=!0,this}get todo(){if(this.options.skip)throw new Error(t.ERROR_MESSAGES.SKIP_TODO);return this.options.todo=!0,this}get failing(){if(this.options.skip)throw new Error(t.ERROR_MESSAGES.SKIP_FAILING);return this.options.failing=!0,this}each(...e){return Ie(this.invoke.bind(this),...e)}invoke(e,r,i=[],n){this.validateTestNesting(e),r||(this.options.todo=!0);let s=this.createTest(e,r,i,n);this.registerTest(s,this.invocationStack),this.resetFlags()}validateTestNesting(e){let r=v(E).test;if(r)throw new Error(`Cannot nest a test inside a test '${e}' in '${r.description}'`)}createTest(e,r,i,n){return new Oe(e,r,n??t.DEFAULT_TIMEOUT,i,{...this.options})}registerTest(e,r){r&&e.setExecutionLocation(r),v(E).addTest(e)}resetFlags(){this.options={}}};var je=class t extends Function{static{o(this,"DescribeDirective")}static instance=null;options={};constructor(){return super(),new Proxy(this,{apply(e,r,i){e.invoke(i[0],i[1])}})}static getInstance(){return t.instance||(t.instance=new t),t.instance}get skip(){if(this.options.only)throw new Error('Cannot use "skip" flag on only test');return this.options.skip=!0,this}get only(){if(this.options.skip)throw new Error('Cannot use "only" flag on skipped test');return this.options.only=!0,this}each(...e){return Ie(this.invoke.bind(this),...e)}invoke(e,r,i=[]){let n=v(E),s=n.test;if(s)throw new Error(`Cannot nest a describe inside a test '${e}' in '${s.description}'`);n.addDescribe(e,r,this.options,i),this.options={}}};function Cn(t){if(t.name in globalThis)return globalThis;let e=t.name,r=globalThis;for(let i of Object.keys(globalThis)){let n=r[i];if(!(typeof n!="function"&&typeof n!="object")&&n&&e in n)return r[i]}}o(Cn,"getParentObject");function vi(t,e){return new $(t,e,"xJet.fn()")}o(vi,"fnImplementation");function bi(t){if(t.xJetMock)return t;let e=Cn(t);if(!e)throw new R("Method is not part of an object");let r=Object.getOwnPropertyDescriptor(e,t.name);r?.get&&!r.configurable&&"default"in e&&e.default[t.name]===t&&(e=e.default);let i=e[t.name];if(t.prototype&&!Object.getOwnPropertyDescriptor(t,"prototype")?.writable){let n=new $((...s)=>new t(...s),()=>{e[t.name]=i});return e[t.name]=n,$.mocks.push(n),e[t.name]}if(typeof t=="function"){let n=new $(t,()=>{e[t.name]=i});return e[t.name]=n,$.mocks.push(n),e[t.name]}throw new R("Invalid method type")}o(bi,"mockImplementation");var Be=class{constructor(e,r){this.hookFunction=e;this.timeout=r}static{o(this,"HookModel")}location="";setLocation(e){this.location=e}async run(e){return Re(this.executeHook(this.hookFunction,e),this.timeout,"hook while waiting for 'done()' to be called.",this.location)}async executeHook(e,r){if(Z(e)&&e.length>0)throw new Error(`Async hook '${e.name}' should not use 'done' callback.`);return e.length>0?this.executeCallbackHook(e,r):e.call(r)}executeCallbackHook(e,r){return new Promise((i,n)=>{e.call(r,s=>{s?n(s):i()})})}};var Rn=globalThis.__XJET?.runtime.timeout??5e3;function Me(t,e,r,i=Rn){let n=new Be(e,i);n.setLocation(r),v(E).describe.addHook(t,n)}o(Me,"createHook");function Ti(t,e){Me("afterAll",t,Y(),e)}o(Ti,"afterAllDirective");function xi(t,e){Me("beforeAll",t,Y(),e)}o(xi,"beforeAllDirective");function Ei(t,e){Me("afterEach",t,Y(),e)}o(Ei,"afterEachDirective");function ki(t,e){Me("beforeEach",t,Y(),e)}o(ki,"beforeEachDirective");function ot(t){[...$.mocks].map(r=>{r[t]()})}o(ot,"clearMocks");var Ln=o(()=>{let t=globalThis;t.xJet={fn:vi,mock:bi,spyOn:ui,clearAllMocks:o(()=>ot("mockClear"),"clearAllMocks"),resetAllMocks:o(()=>ot("mockReset"),"resetAllMocks"),restoreAllMocks:o(()=>ot("mockRestore"),"restoreAllMocks"),log:si,info:oi,warn:ai,error:ci,debug:li,runAllTimers:di,useFakeTimers:pi,useRealTimers:fi,advanceTimersByTime:gi,runOnlyPendingTimers:mi},t.expect=jr,t.state=v(E),t.it=fe.getInstance(),t.test=fe.getInstance(),t.describe=je.getInstance(),t.afterAll=Ti,t.beforeAll=xi,t.afterEach=Ei,t.beforeEach=ki},"setupGlobals");Ln();
|
|
74
74
|
//# sourceMappingURL=shared.js.map
|