@vicin/sigil 3.0.0 → 3.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/CHANGELOG.md +11 -0
- package/README.md +65 -9
- package/dist/index.d.mts +120 -196
- package/dist/index.d.ts +120 -196
- package/dist/index.global.js +530 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +526 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +515 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -6
package/dist/index.global.js
CHANGED
|
@@ -1,6 +1,532 @@
|
|
|
1
|
-
(function(exports){'use strict';var xt=Object.defineProperty;var Et=(i,r,h)=>r in i?xt(i,r,{enumerable:true,configurable:true,writable:true,value:h}):i[r]=h;var q=(i,r,h)=>Et(i,typeof r!="symbol"?r+"":r,h);var ae={labelValidation:null,skipLabelInheritanceCheck:false,autofillLabels:true},_t=i=>{if("autofillLabels"in i){if(typeof i.autofillLabels!="boolean")throw new Error("'updateSigilOptions.autofillLabels' must be boolean");ae.autofillLabels=i.autofillLabels;}if("skipLabelInheritanceCheck"in i){if(typeof i.skipLabelInheritanceCheck!="boolean")throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");ae.skipLabelInheritanceCheck=i.skipLabelInheritanceCheck;}if("labelValidation"in i){let r=i.labelValidation;if(r!==null&&typeof r!="function"&&!(r instanceof RegExp))throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");ae.labelValidation=r!=null?r:null;}},yt=/^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;var Ne=Symbol.for("@vicin/sigil.__SIGIL__"),Te=Symbol.for("@vicin/sigil.__SIGIL_BASE__"),Be=Symbol.for("@vicin/sigil.__DECORATED__"),Ce=Symbol.for("@vicin/sigil.__INHERITANCE_CHECKED__"),Q=Symbol.for("@vicin/sigil.__LABEL__"),pe=Symbol.for("@vicin/sigil.__EFFECTIVE_LABEL__"),H=Symbol.for("@vicin/sigil.__LABEL_LINEAGE__"),ie=Symbol.for("@vicin/sigil.__LABEL_SET__");var xe=BigInt(4294967295),We=BigInt(32);function Lt(i,r=false){return r?{h:Number(i&xe),l:Number(i>>We&xe)}:{h:Number(i>>We&xe)|0,l:Number(i&xe)|0}}function Ke(i,r=false){let h=i.length,S=new Uint32Array(h),d=new Uint32Array(h);for(let _=0;_<h;_++){let{h:p,l:x}=Lt(i[_],r);[S[_],d[_]]=[p,x];}return [S,d]}var Ye=(i,r,h)=>i<<h|r>>>32-h,Ze=(i,r,h)=>r<<h|i>>>32-h,Je=(i,r,h)=>r<<h-32|i>>>64-h,Qe=(i,r,h)=>i<<h-32|r>>>64-h;function mt(i){return i instanceof Uint8Array||ArrayBuffer.isView(i)&&i.constructor.name==="Uint8Array"}function ve(i,r=""){if(!Number.isSafeInteger(i)||i<0){let h=r&&`"${r}" `;throw new Error(`${h}expected integer >= 0, got ${i}`)}}function Ee(i,r,h=""){let S=mt(i),d=i==null?void 0:i.length,_=r!==void 0;if(!S||_){let p=h&&`"${h}" `,x="",O=S?`length=${d}`:`type=${typeof i}`;throw new Error(p+"expected Uint8Array"+x+", got "+O)}return i}function De(i,r=true){if(i.destroyed)throw new Error("Hash instance has been destroyed");if(r&&i.finished)throw new Error("Hash#digest() has already been called")}function et(i,r){Ee(i,void 0,"digestInto() output");let h=r.outputLen;if(i.length<h)throw new Error('"digestInto() output" expected to be of length >='+h)}function tt(i){return new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4))}function Re(...i){for(let r=0;r<i.length;r++)i[r].fill(0);}var Ot=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bt(i){return i<<24&4278190080|i<<8&16711680|i>>>8&65280|i>>>24&255}function It(i){for(let r=0;r<i.length;r++)i[r]=bt(i[r]);return i}var Pe=Ot?i=>i:It;function it(i,r={}){let h=(d,_)=>i(_).update(d).digest(),S=i(void 0);return h.outputLen=S.outputLen,h.blockLen=S.blockLen,h.create=d=>i(d),Object.assign(h,r),Object.freeze(h)}var nt=i=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,i])});var At=BigInt(0),de=BigInt(1),kt=BigInt(2),Nt=BigInt(7),Tt=BigInt(256),Bt=BigInt(113),st=[],ct=[],lt=[];for(let i=0,r=de,h=1,S=0;i<24;i++){[h,S]=[S,(2*h+3*S)%5],st.push(2*(5*S+h)),ct.push((i+1)*(i+2)/2%64);let d=At;for(let _=0;_<7;_++)r=(r<<de^(r>>Nt)*Bt)%Tt,r&kt&&(d^=de<<(de<<BigInt(_))-de);lt.push(d);}var ft=Ke(lt,true),Ct=ft[0],vt=ft[1],rt=(i,r,h)=>h>32?Je(i,r,h):Ye(i,r,h),ot=(i,r,h)=>h>32?Qe(i,r,h):Ze(i,r,h);function Dt(i,r=24){let h=new Uint32Array(10);for(let S=24-r;S<24;S++){for(let p=0;p<10;p++)h[p]=i[p]^i[p+10]^i[p+20]^i[p+30]^i[p+40];for(let p=0;p<10;p+=2){let x=(p+8)%10,O=(p+2)%10,m=h[O],N=h[O+1],D=rt(m,N,1)^h[x],V=ot(m,N,1)^h[x+1];for(let Z=0;Z<50;Z+=10)i[p+Z]^=D,i[p+Z+1]^=V;}let d=i[2],_=i[3];for(let p=0;p<24;p++){let x=ct[p],O=rt(d,_,x),m=ot(d,_,x),N=st[p];d=i[N],_=i[N+1],i[N]=O,i[N+1]=m;}for(let p=0;p<50;p+=10){for(let x=0;x<10;x++)h[x]=i[p+x];for(let x=0;x<10;x++)i[p+x]^=~h[(x+2)%10]&h[(x+4)%10];}i[0]^=Ct[S],i[1]^=vt[S];}Re(h);}var Ue=class i{constructor(r,h,S,d=false,_=24){q(this,"state");q(this,"pos",0);q(this,"posOut",0);q(this,"finished",false);q(this,"state32");q(this,"destroyed",false);q(this,"blockLen");q(this,"suffix");q(this,"outputLen");q(this,"enableXOF",false);q(this,"rounds");if(this.blockLen=r,this.suffix=h,this.outputLen=S,this.enableXOF=d,this.rounds=_,ve(S,"outputLen"),!(0<r&&r<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=tt(this.state);}clone(){return this._cloneInto()}keccak(){Pe(this.state32),Dt(this.state32,this.rounds),Pe(this.state32),this.posOut=0,this.pos=0;}update(r){De(this),Ee(r);let{blockLen:h,state:S}=this,d=r.length;for(let _=0;_<d;){let p=Math.min(h-this.pos,d-_);for(let x=0;x<p;x++)S[this.pos++]^=r[_++];this.pos===h&&this.keccak();}return this}finish(){if(this.finished)return;this.finished=true;let{state:r,suffix:h,pos:S,blockLen:d}=this;r[S]^=h,(h&128)!==0&&S===d-1&&this.keccak(),r[d-1]^=128,this.keccak();}writeInto(r){De(this,false),Ee(r),this.finish();let h=this.state,{blockLen:S}=this;for(let d=0,_=r.length;d<_;){this.posOut>=S&&this.keccak();let p=Math.min(S-this.posOut,_-d);r.set(h.subarray(this.posOut,this.posOut+p),d),this.posOut+=p,d+=p;}return r}xofInto(r){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(r)}xof(r){return ve(r),this.xofInto(new Uint8Array(r))}digestInto(r){if(et(r,this),this.finished)throw new Error("digest() was already called");return this.writeInto(r),this.destroy(),r}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=true,Re(this.state);}_cloneInto(r){let{blockLen:h,suffix:S,outputLen:d,rounds:_,enableXOF:p}=this;return r||(r=new i(h,S,d,p,_)),r.state32.set(this.state32),r.pos=this.pos,r.posOut=this.posOut,r.finished=this.finished,r.rounds=_,r.suffix=S,r.outputLen=d,r.enableXOF=p,r.destroyed=this.destroyed,r}},Rt=(i,r,h,S={})=>it(()=>new Ue(r,i,h),S);var at=Rt(6,72,64,nt(10));var Pt=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Fe=Math.ceil,z=Math.floor,M="[BigNumber Error] ",ut=M+"Number primitive has more than 15 significant digits: ",Y=1e14,b=14,He=9007199254740991,Me=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],se=1e7,P=1e9;function ht(i){var r,h,S,d=E.prototype={constructor:E,toString:null,valueOf:null},_=new E(1),p=20,x=4,O=-7,m=21,N=-1e7,D=1e7,V=false,Z=1,oe=0,me={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},fe="0123456789abcdefghijklmnopqrstuvwxyz",Oe=true;function E(e,t){var n,a,s,l,g,o,c,u,f=this;if(!(f instanceof E))return new E(e,t);if(t==null){if(e&&e._isBigNumber===true){f.s=e.s,!e.c||e.e>D?f.c=f.e=null:e.e<N?f.c=[f.e=0]:(f.e=e.e,f.c=e.c.slice());return}if((o=typeof e=="number")&&e*0==0){if(f.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,g=e;g>=10;g/=10,l++);l>D?f.c=f.e=null:(f.e=l,f.c=[e]);return}u=String(e);}else {if(!Pt.test(u=String(e)))return S(f,u,o);f.s=u.charCodeAt(0)==45?(u=u.slice(1),-1):1;}(l=u.indexOf("."))>-1&&(u=u.replace(".","")),(g=u.search(/e/i))>0?(l<0&&(l=g),l+=+u.slice(g+1),u=u.substring(0,g)):l<0&&(l=u.length);}else {if(B(t,2,fe.length,"Base"),t==10&&Oe)return f=new E(e),G(f,p+f.e+1,x);if(u=String(e),o=typeof e=="number"){if(e*0!=0)return S(f,u,o,t);if(f.s=1/e<0?(u=u.slice(1),-1):1,E.DEBUG&&u.replace(/^0\.0*|\./,"").length>15)throw Error(ut+e)}else f.s=u.charCodeAt(0)===45?(u=u.slice(1),-1):1;for(n=fe.slice(0,t),l=g=0,c=u.length;g<c;g++)if(n.indexOf(a=u.charAt(g))<0){if(a=="."){if(g>l){l=c;continue}}else if(!s&&(u==u.toUpperCase()&&(u=u.toLowerCase())||u==u.toLowerCase()&&(u=u.toUpperCase()))){s=true,g=-1,l=0;continue}return S(f,String(e),o,t)}o=false,u=h(u,t,10,f.s),(l=u.indexOf("."))>-1?u=u.replace(".",""):l=u.length;}for(g=0;u.charCodeAt(g)===48;g++);for(c=u.length;u.charCodeAt(--c)===48;);if(u=u.slice(g,++c)){if(c-=g,o&&E.DEBUG&&c>15&&(e>He||e!==z(e)))throw Error(ut+f.s*e);if((l=l-g-1)>D)f.c=f.e=null;else if(l<N)f.c=[f.e=0];else {if(f.e=l,f.c=[],g=(l+1)%b,l<0&&(g+=b),g<c){for(g&&f.c.push(+u.slice(0,g)),c-=b;g<c;)f.c.push(+u.slice(g,g+=b));g=b-(u=u.slice(g)).length;}else g-=c;for(;g--;u+="0");f.c.push(+u);}}else f.c=[f.e=0];}E.clone=ht,E.ROUND_UP=0,E.ROUND_DOWN=1,E.ROUND_CEIL=2,E.ROUND_FLOOR=3,E.ROUND_HALF_UP=4,E.ROUND_HALF_DOWN=5,E.ROUND_HALF_EVEN=6,E.ROUND_HALF_CEIL=7,E.ROUND_HALF_FLOOR=8,E.EUCLID=9,E.config=E.set=function(e){var t,n;if(e!=null)if(typeof e=="object"){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(n=e[t],B(n,0,P,t),p=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(n=e[t],B(n,0,8,t),x=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(n=e[t],n&&n.pop?(B(n[0],-P,0,t),B(n[1],0,P,t),O=n[0],m=n[1]):(B(n,-P,P,t),O=-(m=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if(n=e[t],n&&n.pop)B(n[0],-P,-1,t),B(n[1],1,P,t),N=n[0],D=n[1];else if(B(n,-P,P,t),n)N=-(D=n<0?-n:n);else throw Error(M+t+" cannot be zero: "+n);if(e.hasOwnProperty(t="CRYPTO"))if(n=e[t],n===!!n)if(n)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))V=n;else throw V=!n,Error(M+"crypto unavailable");else V=n;else throw Error(M+t+" not true or false: "+n);if(e.hasOwnProperty(t="MODULO_MODE")&&(n=e[t],B(n,0,9,t),Z=n),e.hasOwnProperty(t="POW_PRECISION")&&(n=e[t],B(n,0,P,t),oe=n),e.hasOwnProperty(t="FORMAT"))if(n=e[t],typeof n=="object")me=n;else throw Error(M+t+" not an object: "+n);if(e.hasOwnProperty(t="ALPHABET"))if(n=e[t],typeof n=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))Oe=n.slice(0,10)=="0123456789",fe=n;else throw Error(M+t+" invalid: "+n)}else throw Error(M+"Object expected: "+e);return {DECIMAL_PLACES:p,ROUNDING_MODE:x,EXPONENTIAL_AT:[O,m],RANGE:[N,D],CRYPTO:V,MODULO_MODE:Z,POW_PRECISION:oe,FORMAT:me,ALPHABET:fe}},E.isBigNumber=function(e){if(!e||e._isBigNumber!==true)return false;if(!E.DEBUG)return true;var t,n,a=e.c,s=e.e,l=e.s;e:if({}.toString.call(a)=="[object Array]"){if((l===1||l===-1)&&s>=-P&&s<=P&&s===z(s)){if(a[0]===0){if(s===0&&a.length===1)return true;break e}if(t=(s+1)%b,t<1&&(t+=b),String(a[0]).length==t){for(t=0;t<a.length;t++)if(n=a[t],n<0||n>=Y||n!==z(n))break e;if(n!==0)return true}}}else if(a===null&&s===null&&(l===null||l===1||l===-1))return true;throw Error(M+"Invalid BigNumber: "+e)},E.maximum=E.max=function(){return ze(arguments,-1)},E.minimum=E.min=function(){return ze(arguments,1)},E.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return z(Math.random()*e)}:function(){return (Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(n){var a,s,l,g,o,c=0,u=[],f=new E(_);if(n==null?n=p:B(n,0,P),g=Fe(n/b),V)if(crypto.getRandomValues){for(a=crypto.getRandomValues(new Uint32Array(g*=2));c<g;)o=a[c]*131072+(a[c+1]>>>11),o>=9e15?(s=crypto.getRandomValues(new Uint32Array(2)),a[c]=s[0],a[c+1]=s[1]):(u.push(o%1e14),c+=2);c=g/2;}else if(crypto.randomBytes){for(a=crypto.randomBytes(g*=7);c<g;)o=(a[c]&31)*281474976710656+a[c+1]*1099511627776+a[c+2]*4294967296+a[c+3]*16777216+(a[c+4]<<16)+(a[c+5]<<8)+a[c+6],o>=9e15?crypto.randomBytes(7).copy(a,c):(u.push(o%1e14),c+=7);c=g/7;}else throw V=false,Error(M+"crypto unavailable");if(!V)for(;c<g;)o=t(),o<9e15&&(u[c++]=o%1e14);for(g=u[--c],n%=b,g&&n&&(o=Me[b-n],u[c]=z(g/o)*o);u[c]===0;u.pop(),c--);if(c<0)u=[l=0];else {for(l=-1;u[0]===0;u.splice(0,1),l-=b);for(c=1,o=u[0];o>=10;o/=10,c++);c<b&&(l-=b-c);}return f.e=l,f.c=u,f}})(),E.sum=function(){for(var e=1,t=arguments,n=new E(t[0]);e<t.length;)n=n.plus(t[e++]);return n},h=(function(){var e="0123456789";function t(n,a,s,l){for(var g,o=[0],c,u=0,f=n.length;u<f;){for(c=o.length;c--;o[c]*=a);for(o[0]+=l.indexOf(n.charAt(u++)),g=0;g<o.length;g++)o[g]>s-1&&(o[g+1]==null&&(o[g+1]=0),o[g+1]+=o[g]/s|0,o[g]%=s);}return o.reverse()}return function(n,a,s,l,g){var o,c,u,f,w,y,L,A,C=n.indexOf("."),R=p,I=x;for(C>=0&&(f=oe,oe=0,n=n.replace(".",""),A=new E(a),y=A.pow(n.length-C),oe=f,A.c=t(ne(X(y.c),y.e,"0"),10,s,e),A.e=A.c.length),L=t(n,a,s,g?(o=fe,e):(o=e,fe)),u=f=L.length;L[--f]==0;L.pop());if(!L[0])return o.charAt(0);if(C<0?--u:(y.c=L,y.e=u,y.s=l,y=r(y,A,R,I,s),L=y.c,w=y.r,u=y.e),c=u+R+1,C=L[c],f=s/2,w=w||c<0||L[c+1]!=null,w=I<4?(C!=null||w)&&(I==0||I==(y.s<0?3:2)):C>f||C==f&&(I==4||w||I==6&&L[c-1]&1||I==(y.s<0?8:7)),c<1||!L[0])n=w?ne(o.charAt(1),-R,o.charAt(0)):o.charAt(0);else {if(L.length=c,w)for(--s;++L[--c]>s;)L[c]=0,c||(++u,L=[1].concat(L));for(f=L.length;!L[--f];);for(C=0,n="";C<=f;n+=o.charAt(L[C++]));n=ne(n,u,o.charAt(0));}return n}})(),r=(function(){function e(a,s,l){var g,o,c,u,f=0,w=a.length,y=s%se,L=s/se|0;for(a=a.slice();w--;)c=a[w]%se,u=a[w]/se|0,g=L*c+u*y,o=y*c+g%se*se+f,f=(o/l|0)+(g/se|0)+L*u,a[w]=o%l;return f&&(a=[f].concat(a)),a}function t(a,s,l,g){var o,c;if(l!=g)c=l>g?1:-1;else for(o=c=0;o<l;o++)if(a[o]!=s[o]){c=a[o]>s[o]?1:-1;break}return c}function n(a,s,l,g){for(var o=0;l--;)a[l]-=o,o=a[l]<s[l]?1:0,a[l]=o*g+a[l]-s[l];for(;!a[0]&&a.length>1;a.splice(0,1));}return function(a,s,l,g,o){var c,u,f,w,y,L,A,C,R,I,k,U,Se,Ae,ke,J,ge,j=a.s==s.s?1:-1,F=a.c,v=s.c;if(!F||!F[0]||!v||!v[0])return new E(!a.s||!s.s||(F?v&&F[0]==v[0]:!v)?NaN:F&&F[0]==0||!v?j*0:j/0);for(C=new E(j),R=C.c=[],u=a.e-s.e,j=l+u+1,o||(o=Y,u=W(a.e/b)-W(s.e/b),j=j/b|0),f=0;v[f]==(F[f]||0);f++);if(v[f]>(F[f]||0)&&u--,j<0)R.push(1),w=true;else {for(Ae=F.length,J=v.length,f=0,j+=2,y=z(o/(v[0]+1)),y>1&&(v=e(v,y,o),F=e(F,y,o),J=v.length,Ae=F.length),Se=J,I=F.slice(0,J),k=I.length;k<J;I[k++]=0);ge=v.slice(),ge=[0].concat(ge),ke=v[0],v[1]>=o/2&&ke++;do{if(y=0,c=t(v,I,J,k),c<0){if(U=I[0],J!=k&&(U=U*o+(I[1]||0)),y=z(U/ke),y>1)for(y>=o&&(y=o-1),L=e(v,y,o),A=L.length,k=I.length;t(L,I,A,k)==1;)y--,n(L,J<A?ge:v,A,o),A=L.length,c=1;else y==0&&(c=y=1),L=v.slice(),A=L.length;if(A<k&&(L=[0].concat(L)),n(I,L,k,o),k=I.length,c==-1)for(;t(v,I,J,k)<1;)y++,n(I,J<k?ge:v,k,o),k=I.length;}else c===0&&(y++,I=[0]);R[f++]=y,I[0]?I[k++]=F[Se]||0:(I=[F[Se]],k=1);}while((Se++<Ae||I[0]!=null)&&j--);w=I[0]!=null,R[0]||R.splice(0,1);}if(o==Y){for(f=1,j=R[0];j>=10;j/=10,f++);G(C,l+(C.e=f+u*b-1)+1,g,w);}else C.e=u,C.r=+w;return C}})();function be(e,t,n,a){var s,l,g,o,c;if(n==null?n=x:B(n,0,8),!e.c)return e.toString();if(s=e.c[0],g=e.e,t==null)c=X(e.c),c=a==1||a==2&&(g<=O||g>=m)?ye(c,g):ne(c,g,"0");else if(e=G(new E(e),t,n),l=e.e,c=X(e.c),o=c.length,a==1||a==2&&(t<=l||l<=O)){for(;o<t;c+="0",o++);c=ye(c,l);}else if(t-=g+(a===2&&l>g),c=ne(c,l,"0"),l+1>o){if(--t>0)for(c+=".";t--;c+="0");}else if(t+=l-o,t>0)for(l+1==o&&(c+=".");t--;c+="0");return e.s<0&&s?"-"+c:c}function ze(e,t){for(var n,a,s=1,l=new E(e[0]);s<e.length;s++)a=new E(e[s]),(!a.s||(n=ue(l,a))===t||n===0&&l.s===t)&&(l=a);return l}function Ie(e,t,n){for(var a=1,s=t.length;!t[--s];t.pop());for(s=t[0];s>=10;s/=10,a++);return (n=a+n*b-1)>D?e.c=e.e=null:n<N?e.c=[e.e=0]:(e.e=n,e.c=t),e}S=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,a=/^-?(Infinity|NaN)$/,s=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(l,g,o,c){var u,f=o?g:g.replace(s,"");if(a.test(f))l.s=isNaN(f)?null:f<0?-1:1;else {if(!o&&(f=f.replace(e,function(w,y,L){return u=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!c||c==u?y:w}),c&&(u=c,f=f.replace(t,"$1").replace(n,"0.$1")),g!=f))return new E(f,u);if(E.DEBUG)throw Error(M+"Not a"+(c?" base "+c:"")+" number: "+g);l.s=null;}l.c=l.e=null;}})();function G(e,t,n,a){var s,l,g,o,c,u,f,w=e.c,y=Me;if(w){e:{for(s=1,o=w[0];o>=10;o/=10,s++);if(l=t-s,l<0)l+=b,g=t,c=w[u=0],f=z(c/y[s-g-1]%10);else if(u=Fe((l+1)/b),u>=w.length)if(a){for(;w.length<=u;w.push(0));c=f=0,s=1,l%=b,g=l-b+1;}else break e;else {for(c=o=w[u],s=1;o>=10;o/=10,s++);l%=b,g=l-b+s,f=g<0?0:z(c/y[s-g-1]%10);}if(a=a||t<0||w[u+1]!=null||(g<0?c:c%y[s-g-1]),a=n<4?(f||a)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||a||n==6&&(l>0?g>0?c/y[s-g]:0:w[u-1])%10&1||n==(e.s<0?8:7)),t<1||!w[0])return w.length=0,a?(t-=e.e+1,w[0]=y[(b-t%b)%b],e.e=-t||0):w[0]=e.e=0,e;if(l==0?(w.length=u,o=1,u--):(w.length=u+1,o=y[b-l],w[u]=g>0?z(c/y[s-g]%y[g])*o:0),a)for(;;)if(u==0){for(l=1,g=w[0];g>=10;g/=10,l++);for(g=w[0]+=o,o=1;g>=10;g/=10,o++);l!=o&&(e.e++,w[0]==Y&&(w[0]=1));break}else {if(w[u]+=o,w[u]!=Y)break;w[u--]=0,o=1;}for(l=w.length;w[--l]===0;w.pop());}e.e>D?e.c=e.e=null:e.e<N&&(e.c=[e.e=0]);}return e}function te(e){var t,n=e.e;return n===null?e.toString():(t=X(e.c),t=n<=O||n>=m?ye(t,n):ne(t,n,"0"),e.s<0?"-"+t:t)}return d.absoluteValue=d.abs=function(){var e=new E(this);return e.s<0&&(e.s=1),e},d.comparedTo=function(e,t){return ue(this,new E(e,t))},d.decimalPlaces=d.dp=function(e,t){var n,a,s,l=this;if(e!=null)return B(e,0,P),t==null?t=x:B(t,0,8),G(new E(l),e+l.e+1,t);if(!(n=l.c))return null;if(a=((s=n.length-1)-W(this.e/b))*b,s=n[s])for(;s%10==0;s/=10,a--);return a<0&&(a=0),a},d.dividedBy=d.div=function(e,t){return r(this,new E(e,t),p,x)},d.dividedToIntegerBy=d.idiv=function(e,t){return r(this,new E(e,t),0,1)},d.exponentiatedBy=d.pow=function(e,t){var n,a,s,l,g,o,c,u,f,w=this;if(e=new E(e),e.c&&!e.isInteger())throw Error(M+"Exponent not an integer: "+te(e));if(t!=null&&(t=new E(t)),o=e.e>14,!w.c||!w.c[0]||w.c[0]==1&&!w.e&&w.c.length==1||!e.c||!e.c[0])return f=new E(Math.pow(+te(w),o?e.s*(2-_e(e)):+te(e))),t?f.mod(t):f;if(c=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new E(NaN);a=!c&&w.isInteger()&&t.isInteger(),a&&(w=w.mod(t));}else {if(e.e>9&&(w.e>0||w.e<-1||(w.e==0?w.c[0]>1||o&&w.c[1]>=24e7:w.c[0]<8e13||o&&w.c[0]<=9999975e7)))return l=w.s<0&&_e(e)?-0:0,w.e>-1&&(l=1/l),new E(c?1/l:l);oe&&(l=Fe(oe/b+2));}for(o?(n=new E(.5),c&&(e.s=1),u=_e(e)):(s=Math.abs(+te(e)),u=s%2),f=new E(_);;){if(u){if(f=f.times(w),!f.c)break;l?f.c.length>l&&(f.c.length=l):a&&(f=f.mod(t));}if(s){if(s=z(s/2),s===0)break;u=s%2;}else if(e=e.times(n),G(e,e.e+1,1),e.e>14)u=_e(e);else {if(s=+te(e),s===0)break;u=s%2;}w=w.times(w),l?w.c&&w.c.length>l&&(w.c.length=l):a&&(w=w.mod(t));}return a?f:(c&&(f=_.div(f)),t?f.mod(t):l?G(f,oe,x,g):f)},d.integerValue=function(e){var t=new E(this);return e==null?e=x:B(e,0,8),G(t,t.e+1,e)},d.isEqualTo=d.eq=function(e,t){return ue(this,new E(e,t))===0},d.isFinite=function(){return !!this.c},d.isGreaterThan=d.gt=function(e,t){return ue(this,new E(e,t))>0},d.isGreaterThanOrEqualTo=d.gte=function(e,t){return (t=ue(this,new E(e,t)))===1||t===0},d.isInteger=function(){return !!this.c&&W(this.e/b)>this.c.length-2},d.isLessThan=d.lt=function(e,t){return ue(this,new E(e,t))<0},d.isLessThanOrEqualTo=d.lte=function(e,t){return (t=ue(this,new E(e,t)))===-1||t===0},d.isNaN=function(){return !this.s},d.isNegative=function(){return this.s<0},d.isPositive=function(){return this.s>0},d.isZero=function(){return !!this.c&&this.c[0]==0},d.minus=function(e,t){var n,a,s,l,g=this,o=g.s;if(e=new E(e,t),t=e.s,!o||!t)return new E(NaN);if(o!=t)return e.s=-t,g.plus(e);var c=g.e/b,u=e.e/b,f=g.c,w=e.c;if(!c||!u){if(!f||!w)return f?(e.s=-t,e):new E(w?g:NaN);if(!f[0]||!w[0])return w[0]?(e.s=-t,e):new E(f[0]?g:x==3?-0:0)}if(c=W(c),u=W(u),f=f.slice(),o=c-u){for((l=o<0)?(o=-o,s=f):(u=c,s=w),s.reverse(),t=o;t--;s.push(0));s.reverse();}else for(a=(l=(o=f.length)<(t=w.length))?o:t,o=t=0;t<a;t++)if(f[t]!=w[t]){l=f[t]<w[t];break}if(l&&(s=f,f=w,w=s,e.s=-e.s),t=(a=w.length)-(n=f.length),t>0)for(;t--;f[n++]=0);for(t=Y-1;a>o;){if(f[--a]<w[a]){for(n=a;n&&!f[--n];f[n]=t);--f[n],f[a]+=Y;}f[a]-=w[a];}for(;f[0]==0;f.splice(0,1),--u);return f[0]?Ie(e,f,u):(e.s=x==3?-1:1,e.c=[e.e=0],e)},d.modulo=d.mod=function(e,t){var n,a,s=this;return e=new E(e,t),!s.c||!e.s||e.c&&!e.c[0]?new E(NaN):!e.c||s.c&&!s.c[0]?new E(s):(Z==9?(a=e.s,e.s=1,n=r(s,e,0,3),e.s=a,n.s*=a):n=r(s,e,0,Z),e=s.minus(n.times(e)),!e.c[0]&&Z==1&&(e.s=s.s),e)},d.multipliedBy=d.times=function(e,t){var n,a,s,l,g,o,c,u,f,w,y,L,A,C,R,I=this,k=I.c,U=(e=new E(e,t)).c;if(!k||!U||!k[0]||!U[0])return !I.s||!e.s||k&&!k[0]&&!U||U&&!U[0]&&!k?e.c=e.e=e.s=null:(e.s*=I.s,!k||!U?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(a=W(I.e/b)+W(e.e/b),e.s*=I.s,c=k.length,w=U.length,c<w&&(A=k,k=U,U=A,s=c,c=w,w=s),s=c+w,A=[];s--;A.push(0));for(C=Y,R=se,s=w;--s>=0;){for(n=0,y=U[s]%R,L=U[s]/R|0,g=c,l=s+g;l>s;)u=k[--g]%R,f=k[g]/R|0,o=L*u+f*y,u=y*u+o%R*R+A[l]+n,n=(u/C|0)+(o/R|0)+L*f,A[l--]=u%C;A[l]=n;}return n?++a:A.splice(0,1),Ie(e,A,a)},d.negated=function(){var e=new E(this);return e.s=-e.s||null,e},d.plus=function(e,t){var n,a=this,s=a.s;if(e=new E(e,t),t=e.s,!s||!t)return new E(NaN);if(s!=t)return e.s=-t,a.minus(e);var l=a.e/b,g=e.e/b,o=a.c,c=e.c;if(!l||!g){if(!o||!c)return new E(s/0);if(!o[0]||!c[0])return c[0]?e:new E(o[0]?a:s*0)}if(l=W(l),g=W(g),o=o.slice(),s=l-g){for(s>0?(g=l,n=c):(s=-s,n=o),n.reverse();s--;n.push(0));n.reverse();}for(s=o.length,t=c.length,s-t<0&&(n=c,c=o,o=n,t=s),s=0;t;)s=(o[--t]=o[t]+c[t]+s)/Y|0,o[t]=Y===o[t]?0:o[t]%Y;return s&&(o=[s].concat(o),++g),Ie(e,o,g)},d.precision=d.sd=function(e,t){var n,a,s,l=this;if(e!=null&&e!==!!e)return B(e,1,P),t==null?t=x:B(t,0,8),G(new E(l),e,t);if(!(n=l.c))return null;if(s=n.length-1,a=s*b+1,s=n[s]){for(;s%10==0;s/=10,a--);for(s=n[0];s>=10;s/=10,a++);}return e&&l.e+1>a&&(a=l.e+1),a},d.shiftedBy=function(e){return B(e,-He,He),this.times("1e"+e)},d.squareRoot=d.sqrt=function(){var e,t,n,a,s,l=this,g=l.c,o=l.s,c=l.e,u=p+4,f=new E("0.5");if(o!==1||!g||!g[0])return new E(!o||o<0&&(!g||g[0])?NaN:g?l:1/0);if(o=Math.sqrt(+te(l)),o==0||o==1/0?(t=X(g),(t.length+c)%2==0&&(t+="0"),o=Math.sqrt(+t),c=W((c+1)/2)-(c<0||c%2),o==1/0?t="5e"+c:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new E(t)):n=new E(o+""),n.c[0]){for(c=n.e,o=c+u,o<3&&(o=0);;)if(s=n,n=f.times(s.plus(r(l,s,u,1))),X(s.c).slice(0,o)===(t=X(n.c)).slice(0,o))if(n.e<c&&--o,t=t.slice(o-3,o+1),t=="9999"||!a&&t=="4999"){if(!a&&(G(s,s.e+p+2,0),s.times(s).eq(l))){n=s;break}u+=4,o+=4,a=1;}else {(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(G(n,n.e+p+2,1),e=!n.times(n).eq(l));break}}return G(n,n.e+p+1,x,e)},d.toExponential=function(e,t){return e!=null&&(B(e,0,P),e++),be(this,e,t,1)},d.toFixed=function(e,t){return e!=null&&(B(e,0,P),e=e+this.e+1),be(this,e,t)},d.toFormat=function(e,t,n){var a,s=this;if(n==null)e!=null&&t&&typeof t=="object"?(n=t,t=null):e&&typeof e=="object"?(n=e,e=t=null):n=me;else if(typeof n!="object")throw Error(M+"Argument not an object: "+n);if(a=s.toFixed(e,t),s.c){var l,g=a.split("."),o=+n.groupSize,c=+n.secondaryGroupSize,u=n.groupSeparator||"",f=g[0],w=g[1],y=s.s<0,L=y?f.slice(1):f,A=L.length;if(c&&(l=o,o=c,c=l,A-=l),o>0&&A>0){for(l=A%o||o,f=L.substr(0,l);l<A;l+=o)f+=u+L.substr(l,o);c>0&&(f+=u+L.slice(l)),y&&(f="-"+f);}a=w?f+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?w.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):w):f;}return (n.prefix||"")+a+(n.suffix||"")},d.toFraction=function(e){var t,n,a,s,l,g,o,c,u,f,w,y,L=this,A=L.c;if(e!=null&&(o=new E(e),!o.isInteger()&&(o.c||o.s!==1)||o.lt(_)))throw Error(M+"Argument "+(o.isInteger()?"out of range: ":"not an integer: ")+te(o));if(!A)return new E(L);for(t=new E(_),u=n=new E(_),a=c=new E(_),y=X(A),l=t.e=y.length-L.e-1,t.c[0]=Me[(g=l%b)<0?b+g:g],e=!e||o.comparedTo(t)>0?l>0?t:u:o,g=D,D=1/0,o=new E(y),c.c[0]=0;f=r(o,t,0,1),s=n.plus(f.times(a)),s.comparedTo(e)!=1;)n=a,a=s,u=c.plus(f.times(s=u)),c=s,t=o.minus(f.times(s=t)),o=s;return s=r(e.minus(n),a,0,1),c=c.plus(s.times(u)),n=n.plus(s.times(a)),c.s=u.s=L.s,l=l*2,w=r(u,a,l,x).minus(L).abs().comparedTo(r(c,n,l,x).minus(L).abs())<1?[u,a]:[c,n],D=g,w},d.toNumber=function(){return +te(this)},d.toPrecision=function(e,t){return e!=null&&B(e,1,P),be(this,e,t,2)},d.toString=function(e){var t,n=this,a=n.s,s=n.e;return s===null?a?(t="Infinity",a<0&&(t="-"+t)):t="NaN":(e==null?t=s<=O||s>=m?ye(X(n.c),s):ne(X(n.c),s,"0"):e===10&&Oe?(n=G(new E(n),p+s+1,x),t=ne(X(n.c),n.e,"0")):(B(e,2,fe.length,"Base"),t=h(ne(X(n.c),s,"0"),10,e,a,true)),a<0&&n.c[0]&&(t="-"+t)),t},d.valueOf=d.toJSON=function(){return te(this)},d._isBigNumber=true,d[Symbol.toStringTag]="BigNumber",d[Symbol.for("nodejs.util.inspect.custom")]=d.valueOf,i!=null&&E.set(i),E}function W(i){var r=i|0;return i>0||i===r?r:r-1}function X(i){for(var r,h,S=1,d=i.length,_=i[0]+"";S<d;){for(r=i[S++]+"",h=b-r.length;h--;r="0"+r);_+=r;}for(d=_.length;_.charCodeAt(--d)===48;);return _.slice(0,d+1||1)}function ue(i,r){var h,S,d=i.c,_=r.c,p=i.s,x=r.s,O=i.e,m=r.e;if(!p||!x)return null;if(h=d&&!d[0],S=_&&!_[0],h||S)return h?S?0:-x:p;if(p!=x)return p;if(h=p<0,S=O==m,!d||!_)return S?0:!d^h?1:-1;if(!S)return O>m^h?1:-1;for(x=(O=d.length)<(m=_.length)?O:m,p=0;p<x;p++)if(d[p]!=_[p])return d[p]>_[p]^h?1:-1;return O==m?0:O>m^h?1:-1}function B(i,r,h,S){if(i<r||i>h||i!==z(i))throw Error(M+(S||"Argument")+(typeof i=="number"?i<r||i>h?" out of range: ":" not an integer: ":" not a primitive number: ")+String(i))}function _e(i){var r=i.c.length-1;return W(i.e/b)==r&&i.c[r]%2!=0}function ye(i,r){return (i.length>1?i.charAt(0)+"."+i.slice(1):i)+(r<0?"e":"e+")+r}function ne(i,r,h){var S,d;if(r<0){for(d=h+".";++r;d+=h);i=d+i;}else if(S=i.length,++r>S){for(d=h,r-=S;--r;d+=h);i+=d;}else r<S&&(i=i.slice(0,r)+"."+i.slice(r));return i}var Ut=ht(),gt=Ut;var Ft=24,we=32,Ht=()=>typeof globalThis!="undefined"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"?()=>{let i=new Uint32Array(1);return globalThis.crypto.getRandomValues(i),i[0]/4294967296}:Math.random,$e=Ht(),Ve=(i=4,r=$e)=>{let h="";for(;h.length<i;)h=h+Math.floor(r()*36).toString(36);return h};function Mt(i){let r=new gt(0);for(let h of i.values())r=r.multipliedBy(256).plus(h);return r}var dt=(i="")=>{let r=new TextEncoder;return Mt(at(r.encode(i))).toString(36).slice(1)},pt=Array.from({length:26},(i,r)=>String.fromCharCode(r+97)),Vt=i=>pt[Math.floor(i()*pt.length)],$t=({globalObj:i=typeof global!="undefined"?global:typeof window!="undefined"?window:{},random:r=$e}={})=>{let h=Object.keys(i).toString(),S=h.length?h+Ve(we,r):Ve(we,r);return dt(S).substring(0,we)},Gt=i=>()=>i++,jt=476782367,wt=({random:i=$e,counter:r=Gt(Math.floor(i()*jt)),length:h=Ft,fingerprint:S=$t({random:i})}={})=>{if(h>we)throw new Error(`Length must be between 2 and ${we}. Received: ${h}`);return function(){let _=Vt(i),p=Date.now().toString(36),x=r().toString(36),O=Ve(h,i),m=`${p+O+x+S}`;return `${_+dt(m).substring(1,h)}`}},Ge=qt(wt);function qt(i){let r;return ()=>(r||(r=i()),r())}function ce(i,r,h){if(process.env.NODE_ENV!=="production"&&Xe(i))throw new Error(`Constructor ${i} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`);Object.defineProperty(i,Q,{value:r,configurable:true,enumerable:false,writable:false}),h!=null&&h.isInheritanceCheck||Object.defineProperty(i,pe,{value:r,configurable:true,enumerable:false,writable:false});let S=Object.getPrototypeOf(i),d=S&&S[H]?S[H]:[],_=h!=null&&h.isMixin&&r!=="Sigil"?["Sigil",...d,r]:[...d,r];Object.defineProperty(i,H,{value:_,configurable:true,enumerable:false,writable:false}),Object.defineProperty(i,ie,{value:new Set(_),configurable:true,enumerable:false,writable:false}),h!=null&&h.isInheritanceCheck||Xt(i);}function $(i,r){var _,p;if(re(i)||((_=r==null?void 0:r.skipLabelInheritanceCheck)!=null?_:ae.skipLabelInheritanceCheck))return;let h=[i],S=Object.getPrototypeOf(i);for(;ee(S);)h.push(S),S=Object.getPrototypeOf(S);let d=new Map;for(let x=h.length-1;x>=0;x--){let O=h[x];if(!O)continue;let m=O[Q];if(d.has(m)){if(process.env.NODE_ENV!=="production"&&(Xe(O)||!((p=r==null?void 0:r.autofillLabels)!=null?p:ae.autofillLabels)))throw new Error(`[Sigil Error] Class "${O.name}" re-uses Sigil label "${m}" from ancestor "${d.get(m)}". Each Sigil subclass must use a unique label. Did you forget to use "WithSigil(newLabel)" on the subclass?`);m=le(),ce(O,m,{isInheritanceCheck:true});}d.set(m,O.name);}zt(i);}function he(i,r){var S;let h=(S=r==null?void 0:r.labelValidation)!=null?S:ae.labelValidation;if(h){let d;if(h instanceof RegExp?d=h.test(i):d=h(i),process.env.NODE_ENV!=="production"&&!d)throw new Error(`[Sigil] Invalid identity label "${i}". Make sure that supplied label matches validation regex or function.`)}}function le(){return `@Sigil.auto-${Ge()}`}function je(i){Object.defineProperty(i,Ne,{value:true,configurable:false,enumerable:false,writable:false});}function qe(i){Object.defineProperty(i,Te,{value:true,configurable:false,enumerable:false,writable:false});}function Xt(i){Object.defineProperty(i,Be,{value:true,configurable:false,enumerable:false,writable:false});}function zt(i){Object.defineProperty(i,Ce,{value:true,configurable:false,enumerable:false,writable:false});}function ee(i){return typeof i=="function"&&i[Ne]===true}function K(i){if(!i||typeof i!="object")return false;let r=T(i);return ee(r)}function St(i){return Object.hasOwn(i,Te)}function Wt(i){if(!i||typeof i!="object")return false;let r=T(i);return St(r)}function Xe(i){return Object.hasOwn(i,Be)}function re(i){return Object.hasOwn(i,Ce)}function T(i){var r,h,S;return !i||typeof i!="object"?null:(S=(h=i.constructor)!=null?h:(r=Object.getPrototypeOf(i))==null?void 0:r.constructor)!=null?S:null}function Le(i,r,h){if(ee(i))throw new Error(`[Sigil Error] 'Sigilify(${r})' already sigilified.`);let S;r?(he(r,h),S=r):S=le();class d extends i{static get SigilLabel(){return re(this)||$(this),this[Q]}static get SigilEffectiveLabel(){return this[pe]}static get SigilLabelLineage(){var p;return re(this)||$(this),[...(p=this[H])!=null?p:[]]}static get SigilLabelSet(){re(this)||$(this);let p=new Set;for(let x of this[ie])p.add(x);return p}constructor(...p){super(...p),Object.getPrototypeOf(this)!==new.target.prototype&&Object.setPrototypeOf(this,new.target.prototype);let x=T(this);if(!x){if(process.env.NODE_ENV!=="production")throw new Error(`[Sigil Error] 'Sigilify(${r})' instance without constructor`);return}$(x);}static isSigilified(p){return K(p)}static isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=this[Q];return !!x&&x.has(O)}static isOfTypeStrict(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=this[H];return !!x&&O.every((N,D)=>N===x[D])}isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=T(this)[Q];return !!x&&x.has(O)}isOfTypeStrict(p){var m,N;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=(N=T(this))==null?void 0:N[H];return !!x&&O.every((D,V)=>D===x[V])}getSigilLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilLabel}getSigilEffectiveLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilEffectiveLabel}getSigilLabelLineage(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return ["@Sigil.unknown"]}return p.SigilLabelLineage}getSigilLabelSet(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return new Set(["@Sigil.unknown"])}return p.SigilLabelSet}}return ce(d,S,{isMixin:true}),je(d),qe(d),d}function Kt(i,r,h){if(ee(i))throw new Error(`[Sigil Error] 'Sigilify(${r})' already sigilified.`);let S;r?(he(r,h),S=r):S=le();class d extends i{static get SigilLabel(){return re(this)||$(this),this[Q]}static get SigilEffectiveLabel(){return this[pe]}static get SigilLabelLineage(){var p;return re(this)||$(this),[...(p=this[H])!=null?p:[]]}static get SigilLabelSet(){re(this)||$(this);let p=new Set;for(let x of this[ie])p.add(x);return p}constructor(...p){super(...p),Object.getPrototypeOf(this)!==new.target.prototype&&Object.setPrototypeOf(this,new.target.prototype);let x=T(this);if(!x){if(process.env.NODE_ENV!=="production")throw new Error(`[Sigil Error] 'Sigilify(${r})' instance without constructor`);return}$(x);}static isSigilified(p){return K(p)}static isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=this[Q];return !!x&&x.has(O)}static isOfTypeStrict(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=this[H];return !!x&&O.every((N,D)=>N===x[D])}isOfType(p){var m;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[ie],O=T(this)[Q];return !!x&&x.has(O)}isOfTypeStrict(p){var m,N;if(!K(p))return false;let x=(m=T(p))==null?void 0:m[H],O=(N=T(this))==null?void 0:N[H];return !!x&&O.every((D,V)=>D===x[V])}getSigilLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilLabel}getSigilEffectiveLabel(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return "@Sigil.unknown"}return p.SigilEffectiveLabel}getSigilLabelLineage(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return ["@Sigil.unknown"]}return p.SigilLabelLineage}getSigilLabelSet(){let p=T(this);if(!p){if(process.env.NODE_ENV!=="production")throw new Error("[Sigil Error] Sigil class instance without constructor");return new Set(["@Sigil.unknown"])}return p.SigilLabelSet}}return ce(d,S,{isMixin:true}),je(d),qe(d),d}var Yt=Le(class{},"Sigil"),Zt=Le(Error,"SigilError");function Jt(i,r){let h;return i?(he(i,r),h=i):h=le(),function(S,d){if(d.kind==="class"){if(!ee(S))throw new Error(`[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${S.name}`);ce(S,h),$(S,r);}}}function Qt(i,r,h){var _;if(!ee(i))throw new Error(`[Sigil Error] 'withSigil' HOF accept only Sigil classes but used on class ${(_=i==null?void 0:i.name)!=null?_:"unknown"}`);let S;r?(he(r,h),S=r):S=le();let d=i;return ce(d,S),$(d,h),i}/*! Bundled license information:
|
|
1
|
+
(function (exports) {
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// src/options.ts
|
|
5
|
+
var OPTIONS = {
|
|
6
|
+
labelValidation: null,
|
|
7
|
+
autofillLabels: true
|
|
8
|
+
};
|
|
9
|
+
var updateSigilOptions = (opts) => {
|
|
10
|
+
if ("autofillLabels" in opts) {
|
|
11
|
+
if (typeof opts.autofillLabels !== "boolean")
|
|
12
|
+
throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
|
|
13
|
+
OPTIONS.autofillLabels = opts.autofillLabels;
|
|
14
|
+
}
|
|
15
|
+
if ("labelValidation" in opts) {
|
|
16
|
+
const val = opts.labelValidation;
|
|
17
|
+
if (val !== null && typeof val !== "function" && !(val instanceof RegExp))
|
|
18
|
+
throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");
|
|
19
|
+
OPTIONS.labelValidation = val != null ? val : null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
|
|
23
|
+
|
|
24
|
+
// src/symbols.ts
|
|
25
|
+
var __SIGIL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__SIGIL__");
|
|
26
|
+
var __LABEL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__LABEL__");
|
|
27
|
+
var __EFFECTIVE_LABEL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__EFFECTIVE_LABEL__");
|
|
28
|
+
var __LINEAGE__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__LINEAGE__");
|
|
29
|
+
|
|
30
|
+
// src/helpers.ts
|
|
31
|
+
var AUTO_LABEL_PREFEX = "@Sigil-auto";
|
|
32
|
+
var handledCtors = /* @__PURE__ */ new WeakSet();
|
|
33
|
+
function handleSigil(ctor, label, opts) {
|
|
34
|
+
if (handledCtors.has(ctor)) return;
|
|
35
|
+
handledCtors.add(ctor);
|
|
36
|
+
verifyLabel(ctor, label, opts);
|
|
37
|
+
const ancLabelsMap = handleAncestors(ctor, opts);
|
|
38
|
+
if (label && ancLabelsMap.has(label))
|
|
39
|
+
throw new Error(
|
|
40
|
+
`[Sigil Error] Attempt to assign label '${label}' to ${ctor.name} but label is already used by parent '${ancLabelsMap.get(label)}', Make sure that every class has a unique label`
|
|
41
|
+
);
|
|
42
|
+
sigilify(ctor, label != null ? label : generateRandomLabel(ctor));
|
|
43
|
+
}
|
|
44
|
+
function handleAncestors(ctor, opts) {
|
|
45
|
+
var _a;
|
|
46
|
+
const autofillLabels = (_a = opts == null ? void 0 : opts.autofillLabels) != null ? _a : OPTIONS.autofillLabels;
|
|
47
|
+
const ancestors = [];
|
|
48
|
+
let a = Object.getPrototypeOf(ctor);
|
|
49
|
+
while (a && typeof a === "function" && a.prototype[__SIGIL__]) {
|
|
50
|
+
ancestors.unshift(a);
|
|
51
|
+
a = Object.getPrototypeOf(a);
|
|
52
|
+
}
|
|
53
|
+
const labelOwner = /* @__PURE__ */ new Map();
|
|
54
|
+
for (const a2 of ancestors) {
|
|
55
|
+
const l = a2.prototype[__LABEL__];
|
|
56
|
+
if (labelOwner.has(l)) {
|
|
57
|
+
if (!autofillLabels)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`[Sigil Error] Class '${a2.name}' is not sigilified with 'autofillLabels' setted to 'false', Make sure to sigilify all Sigil classes or set 'autofillLabels' to 'true'`
|
|
60
|
+
);
|
|
61
|
+
sigilify(a2, generateRandomLabel(a2));
|
|
62
|
+
}
|
|
63
|
+
labelOwner.set(labelOf(a2), a2.name);
|
|
64
|
+
}
|
|
65
|
+
return labelOwner;
|
|
66
|
+
}
|
|
67
|
+
function sigilify(ctor, label) {
|
|
68
|
+
var _a;
|
|
69
|
+
const sym = Symbol.for(label);
|
|
70
|
+
Object.defineProperty(ctor.prototype, __SIGIL__, {
|
|
71
|
+
value: sym,
|
|
72
|
+
configurable: false,
|
|
73
|
+
enumerable: false,
|
|
74
|
+
writable: false
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(ctor.prototype, sym, {
|
|
77
|
+
value: true,
|
|
78
|
+
configurable: false,
|
|
79
|
+
enumerable: false,
|
|
80
|
+
writable: false
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(ctor.prototype, __LABEL__, {
|
|
83
|
+
value: label,
|
|
84
|
+
configurable: false,
|
|
85
|
+
enumerable: false,
|
|
86
|
+
writable: false
|
|
87
|
+
});
|
|
88
|
+
if (!label.startsWith(AUTO_LABEL_PREFEX))
|
|
89
|
+
Object.defineProperty(ctor.prototype, __EFFECTIVE_LABEL__, {
|
|
90
|
+
value: label,
|
|
91
|
+
configurable: false,
|
|
92
|
+
enumerable: false,
|
|
93
|
+
writable: false
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(ctor.prototype, __LINEAGE__, {
|
|
96
|
+
value: /* @__PURE__ */ new Set(["Sigil", ...(_a = lineageOf(ctor)) != null ? _a : [], label]),
|
|
97
|
+
configurable: false,
|
|
98
|
+
enumerable: false,
|
|
99
|
+
writable: false
|
|
100
|
+
});
|
|
101
|
+
const sigilSym = /* @__PURE__ */ Symbol.for("Sigil");
|
|
102
|
+
if (ctor.prototype[sigilSym] !== true)
|
|
103
|
+
Object.defineProperty(ctor.prototype, sigilSym, {
|
|
104
|
+
value: true,
|
|
105
|
+
configurable: false,
|
|
106
|
+
enumerable: false,
|
|
107
|
+
writable: false
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function isSigilCtor(ctor) {
|
|
111
|
+
return typeof ctor === "function" && __SIGIL__ in ctor.prototype;
|
|
112
|
+
}
|
|
113
|
+
function isSigilInstance(inst) {
|
|
114
|
+
return !!inst && typeof inst === "object" && __SIGIL__ in inst;
|
|
115
|
+
}
|
|
116
|
+
function hasOwnSigil(ctor) {
|
|
117
|
+
return typeof ctor === "function" && Object.hasOwn(ctor.prototype, __SIGIL__);
|
|
118
|
+
}
|
|
119
|
+
function labelOf(ctor) {
|
|
120
|
+
return ctor.prototype[__LABEL__];
|
|
121
|
+
}
|
|
122
|
+
function lineageOf(ctor) {
|
|
123
|
+
return ctor.prototype[__LINEAGE__];
|
|
124
|
+
}
|
|
125
|
+
function verifyLabel(ctor, label, opts) {
|
|
126
|
+
var _a, _b;
|
|
127
|
+
const labelValidation = (_a = opts == null ? void 0 : opts.labelValidation) != null ? _a : OPTIONS.labelValidation;
|
|
128
|
+
const autofillLabels = (_b = opts == null ? void 0 : opts.autofillLabels) != null ? _b : OPTIONS.autofillLabels;
|
|
129
|
+
if (!label) {
|
|
130
|
+
if (!autofillLabels)
|
|
131
|
+
throw new Error(
|
|
132
|
+
`[Sigil Error] Class '${ctor.name}' is not sigilified with 'autofillLabels' setted to 'false', Make sure to sigilify all Sigil classes or set 'autofillLabels' to 'true'`
|
|
133
|
+
);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (label.startsWith(AUTO_LABEL_PREFEX))
|
|
137
|
+
throw new Error(`'${AUTO_LABEL_PREFEX}' is a prefex reserved by the library`);
|
|
138
|
+
if (labelValidation) {
|
|
139
|
+
let valid;
|
|
140
|
+
if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
|
|
141
|
+
else valid = labelValidation(label);
|
|
142
|
+
if (process.env.NODE_ENV !== "production") {
|
|
143
|
+
if (!valid)
|
|
144
|
+
throw new Error(
|
|
145
|
+
`[Sigil Error] Invalid identity label "${label}". Make sure that supplied label matches validation regex or function`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!globalThis.__SigilabelCounter) globalThis.__SigilabelCounter = 0;
|
|
151
|
+
function generateRandomLabel(ctor) {
|
|
152
|
+
const namePart = ctor && typeof ctor.name === "string" && ctor.name.length ? ctor.name : "C";
|
|
153
|
+
const counter = globalThis.__SigilabelCounter++;
|
|
154
|
+
const time = Date.now().toString(36);
|
|
155
|
+
const rand = Math.random().toString(36).slice(2, 6);
|
|
156
|
+
return `${AUTO_LABEL_PREFEX}:${namePart}:${time}:${counter.toString(36)}:${rand}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/mixin.ts
|
|
160
|
+
function Sigilify(Base, label, opts) {
|
|
161
|
+
if (hasOwnSigil(Base))
|
|
162
|
+
throw new Error(
|
|
163
|
+
`[Sigil Error] Class '${Base.name}' with label '${Base.SigilLabel}' is already sigilified`
|
|
164
|
+
);
|
|
165
|
+
class Sigilified extends Base {
|
|
166
|
+
/**
|
|
167
|
+
* Class-level identity label constant for this sigil constructor.
|
|
168
|
+
*/
|
|
169
|
+
static get SigilLabel() {
|
|
170
|
+
var _a;
|
|
171
|
+
handleSigil(this);
|
|
172
|
+
return (_a = this.prototype) == null ? void 0 : _a[__LABEL__];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
176
|
+
*/
|
|
177
|
+
static get SigilEffectiveLabel() {
|
|
178
|
+
var _a;
|
|
179
|
+
handleSigil(this);
|
|
180
|
+
return (_a = this.prototype) == null ? void 0 : _a[__EFFECTIVE_LABEL__];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Linearized sigil type label chain for the current constructor.
|
|
184
|
+
*
|
|
185
|
+
* Useful for debugging and performing strict lineage comparisons.
|
|
186
|
+
*
|
|
187
|
+
* @returns An array of labels representing parent → child type labels.
|
|
188
|
+
*/
|
|
189
|
+
static get SigilLabelLineage() {
|
|
190
|
+
var _a, _b;
|
|
191
|
+
handleSigil(this);
|
|
192
|
+
return [...(_b = (_a = this.prototype) == null ? void 0 : _a[__LINEAGE__]) != null ? _b : []];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Sigil type label set for the current constructor.
|
|
196
|
+
* Useful for debugging.
|
|
197
|
+
*
|
|
198
|
+
* @returns A Readonly Set of labels that represent the type lineage.
|
|
199
|
+
*/
|
|
200
|
+
static get SigilLabelSet() {
|
|
201
|
+
var _a;
|
|
202
|
+
handleSigil(this);
|
|
203
|
+
return (_a = this.prototype) == null ? void 0 : _a[__LINEAGE__];
|
|
204
|
+
}
|
|
205
|
+
constructor(...args) {
|
|
206
|
+
super(...args);
|
|
207
|
+
const ctor = new.target;
|
|
208
|
+
handleSigil(ctor);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
212
|
+
*
|
|
213
|
+
* @param obj - The value to test.
|
|
214
|
+
* @returns `true` if `obj` is a sigil instance.
|
|
215
|
+
*/
|
|
216
|
+
static isSigilified(obj) {
|
|
217
|
+
return isSigilInstance(obj);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Check whether `other` is (or inherits from) the instance represented by the
|
|
221
|
+
* calling constructor.
|
|
222
|
+
*
|
|
223
|
+
* This replaces `instanceof` so that checks remain valid across bundles/realms
|
|
224
|
+
* and when subclassing.
|
|
225
|
+
*
|
|
226
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
227
|
+
* @param this - The constructor performing the type check.
|
|
228
|
+
* @param other - The object to test.
|
|
229
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
230
|
+
*/
|
|
231
|
+
static isOfType(other) {
|
|
232
|
+
var _a;
|
|
233
|
+
handleSigil(this);
|
|
234
|
+
if (other == null || typeof other !== "object") return false;
|
|
235
|
+
return other[(_a = this.prototype) == null ? void 0 : _a[__SIGIL__]] === true;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Check whether `other` is exactly the same instance represented by the
|
|
239
|
+
* calling constructor.
|
|
240
|
+
*
|
|
241
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
242
|
+
* @param this - The constructor performing the type check.
|
|
243
|
+
* @param other - The object to test.
|
|
244
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
245
|
+
*/
|
|
246
|
+
static isExactType(other) {
|
|
247
|
+
var _a, _b, _c;
|
|
248
|
+
handleSigil(this);
|
|
249
|
+
if (other == null || typeof other !== "object") return false;
|
|
250
|
+
if (((_a = this.prototype) == null ? void 0 : _a[__LINEAGE__].size) !== ((_b = other[__LINEAGE__]) == null ? void 0 : _b.size))
|
|
251
|
+
return false;
|
|
252
|
+
return other[(_c = this.prototype) == null ? void 0 : _c[__SIGIL__]] === true;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Check whether `other` is (or inherits from) the instance represented by the
|
|
256
|
+
* calling constructor.
|
|
257
|
+
*
|
|
258
|
+
* This replaces `instanceof` so that checks remain valid across bundles/realms
|
|
259
|
+
* and when subclassing.
|
|
260
|
+
*
|
|
261
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
262
|
+
* @param this - The constructor performing the type check.
|
|
263
|
+
* @param other - The object to test.
|
|
264
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
265
|
+
*/
|
|
266
|
+
isOfType(other) {
|
|
267
|
+
if (other == null || typeof other !== "object") return false;
|
|
268
|
+
return other[this[__SIGIL__]] === true;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Check whether `other` is exactly the same instance represented by the
|
|
272
|
+
* calling constructor.
|
|
273
|
+
*
|
|
274
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
275
|
+
* @param this - The constructor performing the type check.
|
|
276
|
+
* @param other - The object to test.
|
|
277
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
278
|
+
*/
|
|
279
|
+
isExactType(other) {
|
|
280
|
+
var _a;
|
|
281
|
+
if (other == null || typeof other !== "object") return false;
|
|
282
|
+
if (this[__LINEAGE__].size !== ((_a = other[__LINEAGE__]) == null ? void 0 : _a.size)) return false;
|
|
283
|
+
return other[this[__SIGIL__]] === true;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
287
|
+
*
|
|
288
|
+
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:mm2gkdwn:0:g1sq').
|
|
289
|
+
*/
|
|
290
|
+
getSigilLabel() {
|
|
291
|
+
return this[__LABEL__];
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
295
|
+
*
|
|
296
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName').
|
|
297
|
+
*/
|
|
298
|
+
getSigilEffectiveLabel() {
|
|
299
|
+
return this[__EFFECTIVE_LABEL__];
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
303
|
+
*
|
|
304
|
+
* @returns readonly array of labels representing the type lineage.
|
|
305
|
+
*/
|
|
306
|
+
getSigilLabelLineage() {
|
|
307
|
+
return [...this[__LINEAGE__]];
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Returns a copy of the sigil type label lineage set for this instance's constructor.
|
|
311
|
+
*
|
|
312
|
+
* @returns readonly array of labels representing the type lineage.
|
|
313
|
+
*/
|
|
314
|
+
getSigilLabelSet() {
|
|
315
|
+
return this[__LINEAGE__];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
handleSigil(Sigilified, label, opts);
|
|
319
|
+
return Sigilified;
|
|
320
|
+
}
|
|
321
|
+
function SigilifyAbstract(Base, label, opts) {
|
|
322
|
+
if (hasOwnSigil(Base))
|
|
323
|
+
throw new Error(
|
|
324
|
+
`[Sigil Error] Base class '${Base.name}' with label '${Base.SigilLabel}' is already sigilified`
|
|
325
|
+
);
|
|
326
|
+
class Sigilified extends Base {
|
|
327
|
+
/**
|
|
328
|
+
* Class-level identity label constant for this sigil constructor.
|
|
329
|
+
*/
|
|
330
|
+
static get SigilLabel() {
|
|
331
|
+
var _a;
|
|
332
|
+
handleSigil(this);
|
|
333
|
+
return (_a = this.prototype) == null ? void 0 : _a[__LABEL__];
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
337
|
+
*/
|
|
338
|
+
static get SigilEffectiveLabel() {
|
|
339
|
+
var _a;
|
|
340
|
+
handleSigil(this);
|
|
341
|
+
return (_a = this.prototype) == null ? void 0 : _a[__EFFECTIVE_LABEL__];
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Linearized sigil type label chain for the current constructor.
|
|
345
|
+
*
|
|
346
|
+
* Useful for debugging and performing strict lineage comparisons.
|
|
347
|
+
*
|
|
348
|
+
* @returns An array of labels representing parent → child type labels.
|
|
349
|
+
*/
|
|
350
|
+
static get SigilLabelLineage() {
|
|
351
|
+
var _a, _b;
|
|
352
|
+
handleSigil(this);
|
|
353
|
+
return [...(_b = (_a = this.prototype) == null ? void 0 : _a[__LINEAGE__]) != null ? _b : []];
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Sigil type label set for the current constructor.
|
|
357
|
+
* Useful for debugging.
|
|
358
|
+
*
|
|
359
|
+
* @returns A Readonly Set of labels that represent the type lineage.
|
|
360
|
+
*/
|
|
361
|
+
static get SigilLabelSet() {
|
|
362
|
+
var _a;
|
|
363
|
+
handleSigil(this);
|
|
364
|
+
return (_a = this.prototype) == null ? void 0 : _a[__LINEAGE__];
|
|
365
|
+
}
|
|
366
|
+
constructor(...args) {
|
|
367
|
+
super(...args);
|
|
368
|
+
const ctor = new.target;
|
|
369
|
+
handleSigil(ctor);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
373
|
+
*
|
|
374
|
+
* @param obj - The value to test.
|
|
375
|
+
* @returns `true` if `obj` is a sigil instance.
|
|
376
|
+
*/
|
|
377
|
+
static isSigilified(obj) {
|
|
378
|
+
return isSigilInstance(obj);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Check whether `other` is (or inherits from) the instance represented by the
|
|
382
|
+
* calling constructor.
|
|
383
|
+
*
|
|
384
|
+
* This replaces `instanceof` so that checks remain valid across bundles/realms
|
|
385
|
+
* and when subclassing.
|
|
386
|
+
*
|
|
387
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
388
|
+
* @param this - The constructor performing the type check.
|
|
389
|
+
* @param other - The object to test.
|
|
390
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
391
|
+
*/
|
|
392
|
+
static isOfType(other) {
|
|
393
|
+
var _a;
|
|
394
|
+
if (other == null || typeof other !== "object") return false;
|
|
395
|
+
return other[(_a = this.prototype) == null ? void 0 : _a[__SIGIL__]] === true;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Check whether `other` is exactly the same instance represented by the
|
|
399
|
+
* calling constructor.
|
|
400
|
+
*
|
|
401
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
402
|
+
* @param this - The constructor performing the type check.
|
|
403
|
+
* @param other - The object to test.
|
|
404
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
405
|
+
*/
|
|
406
|
+
static isExactType(other) {
|
|
407
|
+
var _a, _b, _c;
|
|
408
|
+
if (other == null || typeof other !== "object") return false;
|
|
409
|
+
if (((_a = this.prototype) == null ? void 0 : _a[__LINEAGE__].size) !== ((_b = other[__LINEAGE__]) == null ? void 0 : _b.size))
|
|
410
|
+
return false;
|
|
411
|
+
return other[(_c = this.prototype) == null ? void 0 : _c[__SIGIL__]] === true;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Check whether `other` is (or inherits from) the instance represented by the
|
|
415
|
+
* calling constructor.
|
|
416
|
+
*
|
|
417
|
+
* This replaces `instanceof` so that checks remain valid across bundles/realms
|
|
418
|
+
* and when subclassing.
|
|
419
|
+
*
|
|
420
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
421
|
+
* @param this - The constructor performing the type check.
|
|
422
|
+
* @param other - The object to test.
|
|
423
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
424
|
+
*/
|
|
425
|
+
isOfType(other) {
|
|
426
|
+
if (other == null || typeof other !== "object") return false;
|
|
427
|
+
return other[this[__SIGIL__]] === true;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Check whether `other` is exactly the same instance represented by the
|
|
431
|
+
* calling constructor.
|
|
432
|
+
*
|
|
433
|
+
* @typeParam T - The specific sigil constructor (`this`).
|
|
434
|
+
* @param this - The constructor performing the type check.
|
|
435
|
+
* @param other - The object to test.
|
|
436
|
+
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
437
|
+
*/
|
|
438
|
+
isExactType(other) {
|
|
439
|
+
var _a;
|
|
440
|
+
if (other == null || typeof other !== "object") return false;
|
|
441
|
+
if (this[__LINEAGE__].size !== ((_a = other[__LINEAGE__]) == null ? void 0 : _a.size)) return false;
|
|
442
|
+
return other[this[__SIGIL__]] === true;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
446
|
+
*
|
|
447
|
+
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:mm2gkdwn:0:g1sq').
|
|
448
|
+
*/
|
|
449
|
+
getSigilLabel() {
|
|
450
|
+
return this[__LABEL__];
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
454
|
+
*
|
|
455
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName').
|
|
456
|
+
*/
|
|
457
|
+
getSigilEffectiveLabel() {
|
|
458
|
+
return this[__EFFECTIVE_LABEL__];
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
462
|
+
*
|
|
463
|
+
* @returns readonly array of labels representing the type lineage.
|
|
464
|
+
*/
|
|
465
|
+
getSigilLabelLineage() {
|
|
466
|
+
return [...this[__LINEAGE__]];
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Returns a copy of the sigil type label lineage set for this instance's constructor.
|
|
470
|
+
*
|
|
471
|
+
* @returns readonly array of labels representing the type lineage.
|
|
472
|
+
*/
|
|
473
|
+
getSigilLabelSet() {
|
|
474
|
+
return this[__LINEAGE__];
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
handleSigil(Sigilified, label, opts);
|
|
478
|
+
return Sigilified;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// src/classes.ts
|
|
482
|
+
var Sigil = Sigilify(class {
|
|
483
|
+
}, "Sigil");
|
|
484
|
+
var SigilError = Sigilify(Error, "SigilError");
|
|
485
|
+
|
|
486
|
+
// src/decorator.ts
|
|
487
|
+
function WithSigil(label, opts) {
|
|
488
|
+
return function(value, context) {
|
|
489
|
+
if (context.kind !== "class") return;
|
|
490
|
+
if (!isSigilCtor(value))
|
|
491
|
+
throw new Error(
|
|
492
|
+
`[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
|
|
493
|
+
);
|
|
494
|
+
if (hasOwnSigil(value))
|
|
495
|
+
throw new Error(
|
|
496
|
+
`[Sigil Error] Class '${value.name}' with label '${value.SigilLabel}' is already sigilified`
|
|
497
|
+
);
|
|
498
|
+
handleSigil(value, label, opts);
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// src/hof.ts
|
|
503
|
+
function withSigil(Class, label, opts) {
|
|
504
|
+
var _a;
|
|
505
|
+
if (!isSigilCtor(Class))
|
|
506
|
+
throw new Error(
|
|
507
|
+
`[Sigil Error] 'withSigil' HOF accept only Sigil classes but used on class ${(_a = Class == null ? void 0 : Class.name) != null ? _a : "unknown"}`
|
|
508
|
+
);
|
|
509
|
+
if (hasOwnSigil(Class))
|
|
510
|
+
throw new Error(
|
|
511
|
+
`[Sigil Error] Class '${Class.name}' with label '${Class.SigilLabel}' is already sigilified`
|
|
512
|
+
);
|
|
513
|
+
handleSigil(Class, label, opts);
|
|
514
|
+
return Class;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
exports.DEFAULT_LABEL_REGEX = DEFAULT_LABEL_REGEX;
|
|
518
|
+
exports.Sigil = Sigil;
|
|
519
|
+
exports.SigilError = SigilError;
|
|
520
|
+
exports.Sigilify = Sigilify;
|
|
521
|
+
exports.SigilifyAbstract = SigilifyAbstract;
|
|
522
|
+
exports.WithSigil = WithSigil;
|
|
523
|
+
exports.isSigilCtor = isSigilCtor;
|
|
524
|
+
exports.isSigilInstance = isSigilInstance;
|
|
525
|
+
exports.updateSigilOptions = updateSigilOptions;
|
|
526
|
+
exports.withSigil = withSigil;
|
|
527
|
+
|
|
528
|
+
return exports;
|
|
529
|
+
|
|
530
|
+
})({});
|
|
531
|
+
//# sourceMappingURL=index.global.js.map
|
|
6
532
|
//# sourceMappingURL=index.global.js.map
|