@mikeargento/bitgraph-player 0.14.0 → 0.16.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/LICENSE +1 -1
- package/README.md +32 -18
- package/dist/__tests__/base-floor-check.test.d.ts +2 -0
- package/dist/__tests__/base-floor-check.test.d.ts.map +1 -0
- package/dist/__tests__/base-floor-check.test.js +163 -0
- package/dist/__tests__/base-floor-check.test.js.map +1 -0
- package/dist/__tests__/cast-order.test.js +1 -1
- package/dist/__tests__/cast-order.test.js.map +1 -1
- package/dist/__tests__/check.test.js +2 -2
- package/dist/__tests__/check.test.js.map +1 -1
- package/dist/__tests__/evaluate-verdict.test.js +1 -1
- package/dist/__tests__/evaluate-verdict.test.js.map +1 -1
- package/dist/__tests__/fixtures.js +1 -1
- package/dist/__tests__/fixtures.js.map +1 -1
- package/dist/__tests__/fuse-check.test.js +2 -2
- package/dist/__tests__/fuse-check.test.js.map +1 -1
- package/dist/__tests__/init-play.test.js +1 -1
- package/dist/__tests__/init-play.test.js.map +1 -1
- package/dist/__tests__/logic-rule.test.js +1 -1
- package/dist/__tests__/logic-rule.test.js.map +1 -1
- package/dist/__tests__/sig-v2.test.js +1 -1
- package/dist/__tests__/sig-v2.test.js.map +1 -1
- package/dist/cast.js +1 -1
- package/dist/cast.js.map +1 -1
- package/dist/check.d.ts +58 -9
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +102 -32
- package/dist/check.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/evaluate.js +1 -1
- package/dist/evaluate.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/logic.js +1 -1
- package/dist/logic.js.map +1 -1
- package/dist/order.d.ts +4 -1
- package/dist/order.d.ts.map +1 -1
- package/dist/order.js +10 -1
- package/dist/order.js.map +1 -1
- package/dist/play.js +1 -1
- package/dist/play.js.map +1 -1
- package/dist/rule.js +1 -1
- package/dist/rule.js.map +1 -1
- package/dist/sig.js +1 -1
- package/dist/sig.js.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/verdict.d.ts +1 -1
- package/dist/verdict.js +2 -2
- package/dist/verdict.js.map +1 -1
- package/dist-web/verify.html +3 -3
- package/package.json +15 -7
- package/src/__tests__/base-floor-check.test.ts +187 -0
- package/src/__tests__/cast-order.test.ts +1 -1
- package/src/__tests__/check.test.ts +2 -2
- package/src/__tests__/evaluate-verdict.test.ts +1 -1
- package/src/__tests__/fixtures.ts +1 -1
- package/src/__tests__/fuse-check.test.ts +2 -2
- package/src/__tests__/init-play.test.ts +1 -1
- package/src/__tests__/logic-rule.test.ts +1 -1
- package/src/__tests__/sig-v2.test.ts +1 -1
- package/src/cast.ts +1 -1
- package/src/check.ts +167 -40
- package/src/cli.ts +1 -1
- package/src/evaluate.ts +1 -1
- package/src/index.ts +1 -1
- package/src/init.ts +1 -1
- package/src/logic.ts +1 -1
- package/src/order.ts +13 -2
- package/src/play.ts +1 -1
- package/src/rule.ts +1 -1
- package/src/sig.ts +1 -1
- package/src/types.ts +1 -1
- package/src/verdict.ts +2 -2
package/dist-web/verify.html
CHANGED
|
@@ -136,7 +136,7 @@ h1.bg-page-title { font-size: clamp(26px, 6vw, 40px); font-weight: 600; letter-s
|
|
|
136
136
|
</div>
|
|
137
137
|
</main>
|
|
138
138
|
<script>
|
|
139
|
-
"use strict";(()=>{var Bc=Object.create;var ui=Object.defineProperty;var vc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Ic=Object.getPrototypeOf,kc=Object.prototype.hasOwnProperty;var Sc=(t,e)=>()=>(t&&(e=t(t=0)),e);var dr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Tc=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ac(e))!kc.call(t,o)&&o!==n&&ui(t,o,{get:()=>e[o],enumerable:!(r=vc(e,o))||r.enumerable});return t};var Hc=(t,e,n)=>(n=t!=null?Bc(Ic(t)):{},Tc(e||!t||!t.__esModule?ui(n,"default",{value:t,enumerable:!0}):n,t));var li=dr(bn=>{"use strict";y();bn.byteLength=Rc;bn.toByteArray=Pc;bn.fromByteArray=Nc;var ke=[],be=[],Cc=typeof Uint8Array<"u"?Uint8Array:Array,hr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(pt=0,di=hr.length;pt<di;++pt)ke[pt]=hr[pt],be[hr.charCodeAt(pt)]=pt;var pt,di;be[45]=62;be[95]=63;function hi(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function Rc(t){var e=hi(t),n=e[0],r=e[1];return(n+r)*3/4-r}function $c(t,e,n){return(e+n)*3/4-n}function Pc(t){var e,n=hi(t),r=n[0],o=n[1],i=new Cc($c(t,r,o)),s=0,a=o>0?r-4:r,c;for(c=0;c<a;c+=4)e=be[t.charCodeAt(c)]<<18|be[t.charCodeAt(c+1)]<<12|be[t.charCodeAt(c+2)]<<6|be[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return o===2&&(e=be[t.charCodeAt(c)]<<2|be[t.charCodeAt(c+1)]>>4,i[s++]=e&255),o===1&&(e=be[t.charCodeAt(c)]<<10|be[t.charCodeAt(c+1)]<<4|be[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function Mc(t){return ke[t>>18&63]+ke[t>>12&63]+ke[t>>6&63]+ke[t&63]}function Dc(t,e,n){for(var r,o=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Mc(r));return o.join("")}function Nc(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(Dc(t,s,s+i>a?a:s+i));return r===1?(e=t[n-1],o.push(ke[e>>2]+ke[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],o.push(ke[e>>10]+ke[e>>4&63]+ke[e<<2&63]+"=")),o.join("")}});var pi=dr(lr=>{y();lr.read=function(t,e,n,r,o){var i,s,a=o*8-r-1,c=(1<<a)-1,f=c>>1,u=-7,d=n?o-1:0,h=n?-1:1,l=t[e+d];for(d+=h,i=l&(1<<-u)-1,l>>=-u,u+=a;u>0;i=i*256+t[e+d],d+=h,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=s*256+t[e+d],d+=h,u-=8);if(i===0)i=1-f;else{if(i===c)return s?NaN:(l?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-f}return(l?-1:1)*s*Math.pow(2,i-r)};lr.write=function(t,e,n,r,o,i){var s,a,c,f=i*8-o-1,u=(1<<f)-1,d=u>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,m=r?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=h/c:e+=h*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(e*c-1)*Math.pow(2,o),s=s+d):(a=e*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;t[n+l]=a&255,l+=m,a/=256,o-=8);for(s=s<<o|a,f+=o;f>0;t[n+l]=s&255,l+=m,s/=256,f-=8);t[n+l-m]|=p*128}});var Ri=dr($t=>{"use strict";y();var pr=li(),Ct=pi(),mi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$t.Buffer=g;$t.SlowBuffer=jc;$t.INSPECT_MAX_BYTES=50;var yn=2147483647;$t.kMaxLength=yn;g.TYPED_ARRAY_SUPPORT=Lc();!g.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Lc(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Ne(t){if(t>yn)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,g.prototype),e}function g(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return yr(t)}return wi(t,e,n)}g.poolSize=8192;function wi(t,e,n){if(typeof t=="string")return Fc(t,e);if(ArrayBuffer.isView(t))return _c(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Se(t,ArrayBuffer)||t&&Se(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Se(t,SharedArrayBuffer)||t&&Se(t.buffer,SharedArrayBuffer)))return gr(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return g.from(r,e,n);let o=Uc(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return g.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}g.from=function(t,e,n){return wi(t,e,n)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function xi(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Oc(t,e,n){return xi(t),t<=0?Ne(t):e!==void 0?typeof n=="string"?Ne(t).fill(e,n):Ne(t).fill(e):Ne(t)}g.alloc=function(t,e,n){return Oc(t,e,n)};function yr(t){return xi(t),Ne(t<0?0:wr(t)|0)}g.allocUnsafe=function(t){return yr(t)};g.allocUnsafeSlow=function(t){return yr(t)};function Fc(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=Ei(t,e)|0,r=Ne(n),o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}function mr(t){let e=t.length<0?0:wr(t.length)|0,n=Ne(e);for(let r=0;r<e;r+=1)n[r]=t[r]&255;return n}function _c(t){if(Se(t,Uint8Array)){let e=new Uint8Array(t);return gr(e.buffer,e.byteOffset,e.byteLength)}return mr(t)}function gr(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&n===void 0?r=new Uint8Array(t):n===void 0?r=new Uint8Array(t,e):r=new Uint8Array(t,e,n),Object.setPrototypeOf(r,g.prototype),r}function Uc(t){if(g.isBuffer(t)){let e=wr(t.length)|0,n=Ne(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||Er(t.length)?Ne(0):mr(t);if(t.type==="Buffer"&&Array.isArray(t.data))return mr(t.data)}function wr(t){if(t>=yn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+yn.toString(16)+" bytes");return t|0}function jc(t){return+t!=t&&(t=0),g.alloc(+t)}g.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==g.prototype};g.compare=function(e,n){if(Se(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),Se(n,Uint8Array)&&(n=g.from(n,n.offset,n.byteLength)),!g.isBuffer(e)||!g.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;let r=e.length,o=n.length;for(let i=0,s=Math.min(r,o);i<s;++i)if(e[i]!==n[i]){r=e[i],o=n[i];break}return r<o?-1:o<r?1:0};g.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};g.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return g.alloc(0);let r;if(n===void 0)for(n=0,r=0;r<e.length;++r)n+=e[r].length;let o=g.allocUnsafe(n),i=0;for(r=0;r<e.length;++r){let s=e[r];if(Se(s,Uint8Array))i+s.length>o.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(g.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function Ei(t,e){if(g.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Se(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let n=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return br(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Ci(t).length;default:if(o)return r?-1:br(t).length;e=(""+e).toLowerCase(),o=!0}}g.byteLength=Ei;function Kc(t,e,n){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Qc(this,e,n);case"utf8":case"utf-8":return vi(this,e,n);case"ascii":return Xc(this,e,n);case"latin1":case"binary":return Jc(this,e,n);case"base64":return Zc(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ef(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}g.prototype._isBuffer=!0;function mt(t,e,n){let r=t[e];t[e]=t[n],t[n]=r}g.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<e;n+=2)mt(this,n,n+1);return this};g.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<e;n+=4)mt(this,n,n+3),mt(this,n+1,n+2);return this};g.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<e;n+=8)mt(this,n,n+7),mt(this,n+1,n+6),mt(this,n+2,n+5),mt(this,n+3,n+4);return this};g.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?vi(this,0,e):Kc.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(e){if(!g.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:g.compare(this,e)===0};g.prototype.inspect=function(){let e="",n=$t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};mi&&(g.prototype[mi]=g.prototype.inspect);g.prototype.compare=function(e,n,r,o,i){if(Se(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(n===void 0&&(n=0),r===void 0&&(r=e?e.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),n<0||r>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&n>=r)return 0;if(o>=i)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,o>>>=0,i>>>=0,this===e)return 0;let s=i-o,a=r-n,c=Math.min(s,a),f=this.slice(o,i),u=e.slice(n,r);for(let d=0;d<c;++d)if(f[d]!==u[d]){s=f[d],a=u[d];break}return s<a?-1:a<s?1:0};function Bi(t,e,n,r,o){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Er(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof e=="string"&&(e=g.from(e,r)),g.isBuffer(e))return e.length===0?-1:gi(t,e,n,r,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):gi(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function gi(t,e,n,r,o){let i=1,s=t.length,a=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,n/=2}function c(u,d){return i===1?u[d]:u.readUInt16BE(d*i)}let f;if(o){let u=-1;for(f=n;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*i}else u!==-1&&(f-=f-u),u=-1}else for(n+a>s&&(n=s-a),f=n;f>=0;f--){let u=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){u=!1;break}if(u)return f}return-1}g.prototype.includes=function(e,n,r){return this.indexOf(e,n,r)!==-1};g.prototype.indexOf=function(e,n,r){return Bi(this,e,n,r,!0)};g.prototype.lastIndexOf=function(e,n,r){return Bi(this,e,n,r,!1)};function Vc(t,e,n,r){n=Number(n)||0;let o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;let i=e.length;r>i/2&&(r=i/2);let s;for(s=0;s<r;++s){let a=parseInt(e.substr(s*2,2),16);if(Er(a))return s;t[n+s]=a}return s}function zc(t,e,n,r){return wn(br(e,t.length-n),t,n,r)}function qc(t,e,n,r){return wn(of(e),t,n,r)}function Gc(t,e,n,r){return wn(Ci(e),t,n,r)}function Wc(t,e,n,r){return wn(sf(e,t.length-n),t,n,r)}g.prototype.write=function(e,n,r,o){if(n===void 0)o="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")o=n,r=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(r)?(r=r>>>0,o===void 0&&(o="utf8")):(o=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-n;if((r===void 0||r>i)&&(r=i),e.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return Vc(this,e,n,r);case"utf8":case"utf-8":return zc(this,e,n,r);case"ascii":case"latin1":case"binary":return qc(this,e,n,r);case"base64":return Gc(this,e,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wc(this,e,n,r);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Zc(t,e,n){return e===0&&n===t.length?pr.fromByteArray(t):pr.fromByteArray(t.slice(e,n))}function vi(t,e,n){n=Math.min(t.length,n);let r=[],o=e;for(;o<n;){let i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=n){let c,f,u,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[o+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[o+1],f=t[o+2],(c&192)===128&&(f&192)===128&&(d=(i&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=t[o+1],f=t[o+2],u=t[o+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(d=(i&15)<<18|(c&63)<<12|(f&63)<<6|u&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),o+=a}return Yc(r)}var bi=4096;function Yc(t){let e=t.length;if(e<=bi)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=bi));return n}function Xc(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]&127);return r}function Jc(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function Qc(t,e,n){let r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let i=e;i<n;++i)o+=af[t[i]];return o}function ef(t,e,n){let r=t.slice(e,n),o="";for(let i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+r[i+1]*256);return o}g.prototype.slice=function(e,n){let r=this.length;e=~~e,n=n===void 0?r:~~n,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<e&&(n=e);let o=this.subarray(e,n);return Object.setPrototypeOf(o,g.prototype),o};function J(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return o};g.prototype.readUintBE=g.prototype.readUIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e+--n],i=1;for(;n>0&&(i*=256);)o+=this[e+--n]*i;return o};g.prototype.readUint8=g.prototype.readUInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]|this[e+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]<<8|this[e+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};g.prototype.readBigUInt64LE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+r*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});g.prototype.readBigUInt64BE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=n*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r;return(BigInt(o)<<BigInt(32))+BigInt(i)});g.prototype.readIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o};g.prototype.readIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=n,i=1,s=this[e+--o];for(;o>0&&(i*=256);)s+=this[e+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s};g.prototype.readInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};g.prototype.readInt16LE=function(e,n){e=e>>>0,n||J(e,2,this.length);let r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};g.prototype.readInt16BE=function(e,n){e=e>>>0,n||J(e,2,this.length);let r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};g.prototype.readInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};g.prototype.readInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};g.prototype.readBigInt64LE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});g.prototype.readBigInt64BE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=(n<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r)});g.prototype.readFloatLE=function(e,n){return e=e>>>0,n||J(e,4,this.length),Ct.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,n){return e=e>>>0,n||J(e,4,this.length),Ct.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||J(e,8,this.length),Ct.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||J(e,8,this.length),Ct.read(this,e,!1,52,8)};function fe(t,e,n,r,o,i){if(!g.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;fe(this,e,n,r,a,0)}let i=1,s=0;for(this[n]=e&255;++s<r&&(i*=256);)this[n+s]=e/i&255;return n+r};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;fe(this,e,n,r,a,0)}let i=r-1,s=1;for(this[n+i]=e&255;--i>=0&&(s*=256);)this[n+i]=e/s&255;return n+r};g.prototype.writeUint8=g.prototype.writeUInt8=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,1,255,0),this[n]=e&255,n+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=e&255,n+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};function Ai(t,e,n,r,o){Hi(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,n}function Ii(t,e,n,r,o){Hi(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i=i>>8,t[n+6]=i,i=i>>8,t[n+5]=i,i=i>>8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s=s>>8,t[n+2]=s,s=s>>8,t[n+1]=s,s=s>>8,t[n]=s,n+8}g.prototype.writeBigUInt64LE=et(function(e,n=0){return Ai(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=et(function(e,n=0){return Ii(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);fe(this,e,n,r,c-1,-c)}let i=0,s=1,a=0;for(this[n]=e&255;++i<r&&(s*=256);)e<0&&a===0&&this[n+i-1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};g.prototype.writeIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);fe(this,e,n,r,c-1,-c)}let i=r-1,s=1,a=0;for(this[n+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[n+i+1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};g.prototype.writeInt8=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};g.prototype.writeInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,2147483647,-2147483648),this[n]=e&255,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4};g.prototype.writeInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};g.prototype.writeBigInt64LE=et(function(e,n=0){return Ai(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=et(function(e,n=0){return Ii(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ki(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Si(t,e,n,r,o){return e=+e,n=n>>>0,o||ki(t,e,n,4,34028234663852886e22,-34028234663852886e22),Ct.write(t,e,n,r,23,4),n+4}g.prototype.writeFloatLE=function(e,n,r){return Si(this,e,n,!0,r)};g.prototype.writeFloatBE=function(e,n,r){return Si(this,e,n,!1,r)};function Ti(t,e,n,r,o){return e=+e,n=n>>>0,o||ki(t,e,n,8,17976931348623157e292,-17976931348623157e292),Ct.write(t,e,n,r,52,8),n+8}g.prototype.writeDoubleLE=function(e,n,r){return Ti(this,e,n,!0,r)};g.prototype.writeDoubleBE=function(e,n,r){return Ti(this,e,n,!1,r)};g.prototype.copy=function(e,n,r,o){if(!g.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!o&&o!==0&&(o=this.length),n>=e.length&&(n=e.length),n||(n=0),o>0&&o<r&&(o=r),o===r||e.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n<o-r&&(o=e.length-n+r);let i=o-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,r,o):Uint8Array.prototype.set.call(e,this.subarray(r,o),n),i};g.prototype.fill=function(e,n,r,o){if(typeof e=="string"){if(typeof n=="string"?(o=n,n=0,r=this.length):typeof r=="string"&&(o=r,r=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!g.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);let i;if(typeof e=="number")for(i=n;i<r;++i)this[i]=e;else{let s=g.isBuffer(e)?e:g.from(e,o),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-n;++i)this[i+n]=s[i%a]}return this};var Ht={};function xr(t,e,n){Ht[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}xr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);xr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);xr("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=yi(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=yi(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r},RangeError);function yi(t){let e="",n=t.length,r=t[0]==="-"?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function tf(t,e,n){Rt(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&Yt(e,t.length-(n+1))}function Hi(t,e,n,r,o,i){if(t>n||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${n}${s}`,new Ht.ERR_OUT_OF_RANGE("value",a,t)}tf(r,o,i)}function Rt(t,e){if(typeof t!="number")throw new Ht.ERR_INVALID_ARG_TYPE(e,"number",t)}function Yt(t,e,n){throw Math.floor(t)!==t?(Rt(t,n),new Ht.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new Ht.ERR_BUFFER_OUT_OF_BOUNDS:new Ht.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var nf=/[^+/0-9A-Za-z-_]/g;function rf(t){if(t=t.split("=")[0],t=t.trim().replace(nf,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function br(t,e){e=e||1/0;let n,r=t.length,o=null,i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function of(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function sf(t,e){let n,r,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}function Ci(t){return pr.toByteArray(rf(t))}function wn(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function Se(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Er(t){return t!==t}var af=(function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let r=n*16;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e})();function et(t){return typeof BigInt>"u"?cf:t}function cf(){throw new Error("BigInt not supported")}});var B,y=Sc(()=>{"use strict";B=Hc(Ri(),1);globalThis.Buffer=B.Buffer});y();y();var ff={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ne,n:xn,Gx:$i,Gy:Pi,a:Br,d:vr}=ff,uf=8n,Xt=32,Ar=64,ye=(t="")=>{throw new Error(t)},df=t=>typeof t=="bigint",Fi=t=>typeof t=="string",hf=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",Mt=(t,e)=>!hf(t)||typeof e=="number"&&e>0&&t.length!==e?ye("Uint8Array expected"):t,An=t=>new Uint8Array(t),Tr=t=>Uint8Array.from(t),_i=(t,e)=>t.toString(16).padStart(e,"0"),Hr=t=>Array.from(Mt(t)).map(e=>_i(e,2)).join(""),Le={_0:48,_9:57,A:65,F:70,a:97,f:102},Mi=t=>{if(t>=Le._0&&t<=Le._9)return t-Le._0;if(t>=Le.A&&t<=Le.F)return t-(Le.A-10);if(t>=Le.a&&t<=Le.f)return t-(Le.a-10)},Cr=t=>{let e="hex invalid";if(!Fi(t))return ye(e);let n=t.length,r=n/2;if(n%2)return ye(e);let o=An(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Mi(t.charCodeAt(s)),c=Mi(t.charCodeAt(s+1));if(a===void 0||c===void 0)return ye(e);o[i]=a*16+c}return o},En=(t,e)=>Mt(Fi(t)?Cr(t):Tr(Mt(t)),e),Ui=()=>globalThis?.crypto,lf=()=>Ui()?.subtle??ye("crypto.subtle must be defined"),Ir=(...t)=>{let e=An(t.reduce((r,o)=>r+Mt(o).length,0)),n=0;return t.forEach(r=>{e.set(r,n),n+=r.length}),e},pf=(t=Xt)=>Ui().getRandomValues(An(t)),Bn=BigInt,gt=(t,e,n,r="bad number: out of range")=>df(t)&&e<=t&&t<n?t:ye(r),T=(t,e=ne)=>{let n=t%e;return n>=0n?n:e+n},mf=t=>T(t,xn),ji=(t,e)=>{(t===0n||e<=0n)&&ye("no inverse n="+t+" mod="+e);let n=T(t,e),r=e,o=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=r/n,f=r%n,u=o-s*c,d=i-a*c;r=n,n=f,o=s,i=a,s=u,a=d}return r===1n?T(o,e):ye("no inverse")};var Di=t=>t instanceof Oe?t:ye("Point expected"),kr=2n**256n,Oe=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,r,o){let i=kr;this.ex=gt(e,0n,i),this.ey=gt(n,0n,i),this.ez=gt(r,1n,i),this.et=gt(o,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,T(e.x*e.y))}static fromBytes(e,n=!1){let r=vr,o=Tr(Mt(e,Xt)),i=e[31];o[31]=i&-129;let s=Rr(o);gt(s,0n,n?kr:ne);let c=T(s*s),f=T(c-1n),u=T(r*c+1n),{isValid:d,value:h}=yf(f,u);d||ye("bad point: y not sqrt");let l=(h&1n)===1n,m=(i&128)!==0;return!n&&h===0n&&m&&ye("bad point: x==0, isLastByteOdd"),m!==l&&(h=T(-h)),new t(h,s,1n,T(h*s))}assertValidity(){let e=Br,n=vr,r=this;if(r.is0())throw new Error("bad point: ZERO");let{ex:o,ey:i,ez:s,et:a}=r,c=T(o*o),f=T(i*i),u=T(s*s),d=T(u*u),h=T(c*e),l=T(u*T(h+f)),m=T(d+T(n*T(c*f)));if(l!==m)throw new Error("bad point: equation left != right (1)");let p=T(o*i),w=T(s*a);if(p!==w)throw new Error("bad point: equation left != right (2)");return this}equals(e){let{ex:n,ey:r,ez:o}=this,{ex:i,ey:s,ez:a}=Di(e),c=T(n*a),f=T(i*o),u=T(r*a),d=T(s*o);return c===f&&u===d}is0(){return this.equals(Pt)}negate(){return new t(T(-this.ex),this.ey,this.ez,T(-this.et))}double(){let{ex:e,ey:n,ez:r}=this,o=Br,i=T(e*e),s=T(n*n),a=T(2n*T(r*r)),c=T(o*i),f=e+n,u=T(T(f*f)-i-s),d=c+s,h=d-a,l=c-s,m=T(u*h),p=T(d*l),w=T(u*l),b=T(h*d);return new t(m,p,b,w)}add(e){let{ex:n,ey:r,ez:o,et:i}=this,{ex:s,ey:a,ez:c,et:f}=Di(e),u=Br,d=vr,h=T(n*s),l=T(r*a),m=T(i*d*f),p=T(o*c),w=T((n+r)*(s+a)-h-l),b=T(p-m),k=T(p+m),v=T(l-u*h),O=T(w*b),z=T(k*v),S=T(w*v),_=T(b*k);return new t(O,z,_,S)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return Pt;if(gt(e,1n,xn),e===1n)return this;if(this.equals(Dt))return If(e).p;let r=Pt,o=Dt;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?r=r.add(i):n&&(o=o.add(i));return r}toAffine(){let{ex:e,ey:n,ez:r}=this;if(this.equals(Pt))return{x:0n,y:1n};let o=ji(r,ne);return T(r*o)!==1n&&ye("invalid inverse"),{x:T(e*o),y:T(n*o)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),r=gf(n);return r[31]|=e&1n?128:0,r}toHex(){return Hr(this.toBytes())}clearCofactor(){return this.multiply(Bn(uf),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(xn/2n,!1).double();return xn%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(En(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},Dt=new Oe($i,Pi,1n,T($i*Pi)),Pt=new Oe(0n,1n,1n,0n);Oe.BASE=Dt;Oe.ZERO=Pt;var gf=t=>Cr(_i(gt(t,0n,kr),Ar)).reverse(),Rr=t=>Bn("0x"+Hr(Tr(Mt(t)).reverse())),Te=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=ne;return n},bf=t=>{let n=t*t%ne*t%ne,r=Te(n,2n)*n%ne,o=Te(r,1n)*t%ne,i=Te(o,5n)*o%ne,s=Te(i,10n)*i%ne,a=Te(s,20n)*s%ne,c=Te(a,40n)*a%ne,f=Te(c,80n)*c%ne,u=Te(f,80n)*c%ne,d=Te(u,10n)*i%ne;return{pow_p_5_8:Te(d,2n)*t%ne,b2:n}},Ni=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,yf=(t,e)=>{let n=T(e*e*e),r=T(n*n*e),o=bf(t*r).pow_p_5_8,i=T(t*n*o),s=T(e*i*i),a=i,c=T(i*Ni),f=s===t,u=s===T(-t),d=s===T(-t*Ni);return f&&(i=a),(u||d)&&(i=c),(T(i)&1n)===1n&&(i=T(-i)),{isValid:f||u,value:i}},wf=t=>mf(Rr(t)),xf=(...t)=>In.sha512Async(...t);var Ef=t=>xf(t.hashable).then(t.finish);var Ki={zip215:!0},Bf=(t,e,n,r=Ki)=>{t=En(t,Ar),e=En(e),n=En(n,Xt);let{zip215:o}=r,i,s,a,c,f=Uint8Array.of();try{i=Oe.fromHex(n,o),s=Oe.fromHex(t.slice(0,Xt),o),a=Rr(t.slice(Xt,Ar)),c=Dt.multiply(a,!1),f=Ir(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:d=>{if(c==null||!o&&i.isSmallOrder())return!1;let h=wf(d);return s.add(i.multiply(h,!1)).add(c.negate()).clearCofactor().is0()}}},$r=async(t,e,n,r=Ki)=>Ef(Bf(t,e,n,r));var In={sha512Async:async(...t)=>{let e=lf(),n=Ir(...t);return An(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:Hr,hexToBytes:Cr,concatBytes:Ir,mod:T,invert:ji,randomBytes:pf};var vn=8,vf=256,Vi=Math.ceil(vf/vn)+1,Sr=2**(vn-1),Af=()=>{let t=[],e=Dt,n=e;for(let r=0;r<Vi;r++){n=e,t.push(n);for(let o=1;o<Sr;o++)n=n.add(e),t.push(n);e=n.double()}return t},Li,Oi=(t,e)=>{let n=e.negate();return t?n:e},If=t=>{let e=Li||(Li=Af()),n=Pt,r=Dt,o=2**vn,i=o,s=Bn(o-1),a=Bn(vn);for(let c=0;c<Vi;c++){let f=Number(t&s);t>>=a,f>Sr&&(f-=i,t+=1n);let u=c*Sr,d=u,h=u+Math.abs(f)-1,l=c%2!==0,m=f<0;f===0?r=r.add(Oi(l,e[d])):n=n.add(Oi(m,e[h]))}return{p:n,f:r}};y();y();y();function Sf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bt(t,...e){if(!Sf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Lt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kn(t,e){bt(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function zi(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function He(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Sn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Be(t,e){return t<<32-e|t>>>e}var Tf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Cf(t){for(let e=0;e<t.length;e++)t[e]=Hf(t[e]);return t}var Mr=Tf?t=>t:Cf;function Rf(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Jt(t){return typeof t=="string"&&(t=Rf(t)),bt(t),t}var Nt=class{};function Qt(t){let e=r=>t().update(Jt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function $f(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}function qi(t,e,n){return t&e^~t&n}function Gi(t,e,n){return t&e^t&n^e&n}var en=class extends Nt{constructor(e,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Sn(this.buffer)}update(e){Lt(this),e=Jt(e),bt(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Sn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Lt(this),kn(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,He(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let d=s;d<o;d++)n[d]=0;$f(r,o-8,BigInt(this.length*8),i),this.process(r,0);let a=Sn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Fe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);y();var Tn=BigInt(4294967295),Wi=BigInt(32);function Pf(t,e=!1){return e?{h:Number(t&Tn),l:Number(t>>Wi&Tn)}:{h:Number(t>>Wi&Tn)|0,l:Number(t&Tn)|0}}function Hn(t,e=!1){let n=t.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=Pf(t[i],e);[r[i],o[i]]=[s,a]}return[r,o]}var Dr=(t,e,n)=>t>>>n,Nr=(t,e,n)=>t<<32-n|e>>>n,yt=(t,e,n)=>t>>>n|e<<32-n,wt=(t,e,n)=>t<<32-n|e>>>n,tn=(t,e,n)=>t<<64-n|e>>>n-32,nn=(t,e,n)=>t>>>n-32|e<<64-n;var Zi=(t,e,n)=>t<<n|e>>>32-n,Yi=(t,e,n)=>e<<n|t>>>32-n,Xi=(t,e,n)=>e<<n-32|t>>>64-n,Ji=(t,e,n)=>t<<n-32|e>>>64-n;function Ce(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}var Qi=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),es=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,ts=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),ns=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,rs=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),os=(t,e,n,r,o,i)=>e+n+r+o+i+(t/2**32|0)|0;var Df=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),tt=new Uint32Array(64),Cn=class extends en{constructor(e=32){super(64,e,8,!1),this.A=Fe[0]|0,this.B=Fe[1]|0,this.C=Fe[2]|0,this.D=Fe[3]|0,this.E=Fe[4]|0,this.F=Fe[5]|0,this.G=Fe[6]|0,this.H=Fe[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)tt[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=tt[d-15],l=tt[d-2],m=Be(h,7)^Be(h,18)^h>>>3,p=Be(l,17)^Be(l,19)^l>>>10;tt[d]=p+tt[d-7]+m+tt[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=Be(a,6)^Be(a,11)^Be(a,25),l=u+h+qi(a,c,f)+Df[d]+tt[d]|0,p=(Be(r,2)^Be(r,13)^Be(r,22))+Gi(r,o,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=o,o=r,r=l+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){He(tt)}destroy(){this.set(0,0,0,0,0,0,0,0),He(this.buffer)}};var is=Hn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Nf=is[0],Lf=is[1],nt=new Uint32Array(80),rt=new Uint32Array(80),Lr=class extends en{constructor(e=64){super(128,e,16,!1),this.Ah=Q[0]|0,this.Al=Q[1]|0,this.Bh=Q[2]|0,this.Bl=Q[3]|0,this.Ch=Q[4]|0,this.Cl=Q[5]|0,this.Dh=Q[6]|0,this.Dl=Q[7]|0,this.Eh=Q[8]|0,this.El=Q[9]|0,this.Fh=Q[10]|0,this.Fl=Q[11]|0,this.Gh=Q[12]|0,this.Gl=Q[13]|0,this.Hh=Q[14]|0,this.Hl=Q[15]|0}get(){let{Ah:e,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:d,Fl:h,Gh:l,Gl:m,Hh:p,Hl:w}=this;return[e,n,r,o,i,s,a,c,f,u,d,h,l,m,p,w]}set(e,n,r,o,i,s,a,c,f,u,d,h,l,m,p,w){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=d|0,this.Fl=h|0,this.Gh=l|0,this.Gl=m|0,this.Hh=p|0,this.Hl=w|0}process(e,n){for(let v=0;v<16;v++,n+=4)nt[v]=e.getUint32(n),rt[v]=e.getUint32(n+=4);for(let v=16;v<80;v++){let O=nt[v-15]|0,z=rt[v-15]|0,S=yt(O,z,1)^yt(O,z,8)^Dr(O,z,7),_=wt(O,z,1)^wt(O,z,8)^Nr(O,z,7),F=nt[v-2]|0,G=rt[v-2]|0,q=yt(F,G,19)^tn(F,G,61)^Dr(F,G,6),ge=wt(F,G,19)^nn(F,G,61)^Nr(F,G,6),D=ts(_,ge,rt[v-7],rt[v-16]),ae=ns(D,S,q,nt[v-7],nt[v-16]);nt[v]=ae|0,rt[v]=D|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:h,Fh:l,Fl:m,Gh:p,Gl:w,Hh:b,Hl:k}=this;for(let v=0;v<80;v++){let O=yt(d,h,14)^yt(d,h,18)^tn(d,h,41),z=wt(d,h,14)^wt(d,h,18)^nn(d,h,41),S=d&l^~d&p,_=h&m^~h&w,F=rs(k,z,_,Lf[v],rt[v]),G=os(F,b,O,S,Nf[v],nt[v]),q=F|0,ge=yt(r,o,28)^tn(r,o,34)^tn(r,o,39),D=wt(r,o,28)^nn(r,o,34)^nn(r,o,39),ae=r&i^r&a^i&a,re=o&s^o&c^s&c;b=p|0,k=w|0,p=l|0,w=m|0,l=d|0,m=h|0,{h:d,l:h}=Ce(f|0,u|0,G|0,q|0),f=a|0,u=c|0,a=i|0,c=s|0,i=r|0,s=o|0;let L=Qi(q,D,re);r=es(L,G,ge,ae),o=L|0}({h:r,l:o}=Ce(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=Ce(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Ce(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Ce(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:h}=Ce(this.Eh|0,this.El|0,d|0,h|0),{h:l,l:m}=Ce(this.Fh|0,this.Fl|0,l|0,m|0),{h:p,l:w}=Ce(this.Gh|0,this.Gl|0,p|0,w|0),{h:b,l:k}=Ce(this.Hh|0,this.Hl|0,b|0,k|0),this.set(r,o,i,s,a,c,f,u,d,h,l,m,p,w,b,k)}roundClean(){He(nt,rt)}destroy(){He(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ss=Qt(()=>new Cn);var Rn=Qt(()=>new Lr);y();y();y();function ue(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var as=ue("fs.createReadStream"),Al=ue("fs.readFileSync"),Il=ue("fs.existsSync"),kl=ue("fs.writeFileSync"),Of=ue("fs.open"),Ff=ue("fs.readdir"),cs=ue("fs.readFile"),_f=ue("fs.stat"),Sl=ue("fs.mkdir"),Tl=ue("fs.writeFile"),fs=ue("path.join"),Hl=ue("path.basename"),us=ue("zlib.createGunzip"),Uf=ue("zlib.gzipSync");y();var U=ss;y();y();y();y();y();y();y();var jf=t=>t/2**32|0,Kf=t=>t>>>0;function ds(t,e,n,r){let o=jf(n),i=Kf(n);t.setUint32(e,r?i:o,r),t.setUint32(e+4,r?o:i,r)}y();function $n(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var Or=t=>t?`"${t}" `:"";function _e(t,e=""){if(typeof t!="number")throw new TypeError(Or(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(Or(e)+"expected integer >= 0, got "+t);return t}function Re(t,e,n=""){if($n(t)&&(e===void 0||t.length===e))return t;e!==void 0&&_e(e,"length");let r=$n(t),o=e!==void 0?` of length ${e}`:"",i=r?`length=${t.length}`:`type=${typeof t}`,s=Or(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function Pn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(_e(t.outputLen),_e(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var hs=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function Ot(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function Mn(t,e){Re(t,void 0,"output");let n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function rn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Dn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ve(t,e){return t<<32-e|t>>>e}var ps=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Vf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Nn(t){if(Re(t),ps)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Vf[t[n]];return e}function ls(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Fr(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(ps)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){let s=ls(t.charCodeAt(i)),a=ls(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=s*16+a}return r}function ms(...t){let e=0;for(let r=0;r<t.length;r++){let o=t[r];Re(o),e+=o.length}let n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){let i=t[r];n.set(i,o),o+=i.length}return n}function zf(t,e,n="opts"){return hs(t,"defaults"),e!==void 0&&hs(e,n),Object.assign(t,e)}function gs(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=zf({},e,"info");let n=(o,i)=>t(i).update(o).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=o=>t(o),Object.assign(n,e),Object.freeze(n)}function bs(t=32){_e(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ys=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ws(t,e,n){return t&e^~t&n}function xs(t,e,n){return t&e^t&n^e&n}var Ln=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,r,o){this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Dn(this.buffer)}update(e){Ot(this),Re(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(o-this.pos,i-a);if(c===o){let f=Dn(e);for(;o<=i-a;a+=o)this.process(f,a);s=!0;continue}r.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){Ot(this),Mn(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>o-s&&(this.process(r,0),n.fill(0)),ds(r,o-8,this.length*8,i),this.process(r,0),this.roundClean();let a=e===n?r:Dn(e),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneIntoMeta(e){let{buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,s&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Es=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qf=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ot=new Uint32Array(64),_r=class extends Ln{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,n){super(64,e,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let d=0;d<16;d++,n+=4)ot[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=ot[d-15],l=ot[d-2],m=ve(h,7)^ve(h,18)^h>>>3,p=ve(l,17)^ve(l,19)^l>>>10;ot[d]=p+ot[d-7]+m+ot[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=ve(a,6)^ve(a,11)^ve(a,25),l=u+h+ws(a,c,f)+qf[d]+ot[d]|0,p=(ve(r,2)^ve(r,13)^ve(r,22))+xs(r,o,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=o,o=r,r=l+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){rn(ot)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),rn(this.buffer)}},Ur=class extends _r{constructor(){super(32,Es)}};var Bs=gs(()=>new Ur,ys(1));y();function Fn(t,e,n=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let r=0;r<t.length;r++)n(t[r],`${e}[${r}]`);return t}var X=(t,e,n)=>Re(t,e,n),jr=_e;function As(t,e=""){if(typeof t!="string"){let n=e&&`"${e}" `;throw new TypeError(n+"expected string, got type="+typeof t)}return t}function it(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function xt(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var Kr=Nn,Ue=(...t)=>ms(...t),_n=t=>Fr(t),Ft=$n,Un=t=>bs(t),On=BigInt(0),vs=BigInt(1),Gf=t=>t?`"${t}" `:"";function $e(t,e=""){if(typeof t!="boolean")throw new TypeError(Gf(e)+"expected boolean, got type="+typeof t);return t}function jn(t){if(typeof t=="bigint"){if(!st(t))throw new RangeError("positive bigint expected, got "+t)}else jr(t);return t}function _t(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(n+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let n=e&&`"${e}" `;throw new RangeError(n+"expected safe integer, got "+t)}}function on(t){let e=jn(t).toString(16);return e.length&1?"0"+e:e}function Is(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?On:BigInt("0x"+t)}function Pe(t){return Is(Nn(t))}function Vr(t){return Is(Nn(Wf(Re(t)).reverse()))}function Kn(t,e){if(_e(e),e===0)throw new Error("zero output length is invalid");t=jn(t);let n=e*2,r=t.toString(16);if(r.length>n)throw new RangeError("number is too large");return Fr(r.padStart(n,"0"))}function zr(t,e){return Kn(t,e).reverse()}function Wf(t){return Uint8Array.from(X(t))}function st(t){return typeof t=="bigint"&&On<=t}function qr(t,e,n){return st(t)&&st(e)&&st(n)&&e<=t&&t<n}function Gr(t,e,n,r){if(!qr(e,n,r))throw new RangeError("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function Ut(t){if(t<On)throw new Error("expected non-negative bigint, got "+t);return t===On?0:t.toString(2).length}var sn=t=>(_t(t,"n"),(vs<<BigInt(t))-vs);function ks(t,e,n){if(_e(t,"hashLen"),_e(e,"qByteLen"),typeof n!="function")throw new TypeError("hmacFn must be a function");let r=w=>new Uint8Array(w),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=r(t),f=r(t),u=0,d=()=>{c.fill(1),f.fill(0),u=0},h=(...w)=>n(f,Ue(c,...w)),l=(w=o)=>{f=h(i,w),c=h(),w.length!==0&&(f=h(s,w),c=h())},m=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let w=0,b=[];for(;w<e;){c=h();let k=c.slice();b.push(k),w+=c.length}return Ue(...b)};return(w,b)=>{d(),l(w);let k;for(;(k=b(m()))===void 0;)l();return d(),k}}function at(t,e={},n={},r="object"){it(t,r),it(e,"fields"),it(n,"optFields");function o(s,a,c){let f=r==="object"?`param "${String(s)}"`:`"${r}.${String(s)}"`,u=t[s];if(!Object.hasOwn(t,s)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let d=typeof u;if(d!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${d}`)}let i=(s,a)=>Object.entries(s).forEach(([c,f])=>o(c,f,a));i(e,!1),i(n,!0)}y();y();var ee=BigInt(0),V=BigInt(1),ct=BigInt(2),Cs=BigInt(3),Wr=BigInt(4),Rs=BigInt(5),Zf=BigInt(7),$s=BigInt(8),Yf=BigInt(9),Xf=BigInt(15),Ps=BigInt(16),Jf=BigInt("0x10000000000000000");function he(t,e){if(e<=ee)throw new Error("mod: expected positive modulus, got "+e);let n=t%e;return n>=ee?n:e+n}function Ms(t,e,n){if(n<=V)throw new Error("pow: expected modulus > 1, got "+n);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<ee)throw new Error("invalid exponent, negatives unsupported");if(e===ee)return V;if(e===V)return t;let r=t%n;if(r<ee&&(r+=n),e<Jf){let a=V;for(;e>ee;)e&V&&(a=a*r%n),r=r*r%n,e>>=V;return a}let o=[];for(;e>ee;)o.push(Number(e&Xf)),e>>=Wr;let i=new Array(16);i[0]=V,i[1]=r;for(let a=2;a<16;a++)i[a]=i[a-1]*r%n;let s=i[o[o.length-1]];for(let a=o.length-2;a>=0;a--){s=s*s%n,s=s*s%n,s=s*s%n,s=s*s%n;let c=o[a];c!==0&&(s=s*i[c]%n)}return s}function Ss(t,e){if(t===ee)throw new Error("invert: expected non-zero number");if(e<=V)throw new Error("invert: expected modulus > 1, got "+e);let n=he(t,e),r=e,o=ee,i=V;for(;n!==ee;){let a=r/n,c=r-n*a,f=o-i*a;r=n,n=c,o=i,i=f}if(r!==V)throw new Error("invert: does not exist");return he(o,e)}function Ds(t,e){if(e<=V)throw new Error("invertCt: expected prime modulus > 1, got "+e);let n=he(t,e);if(n===ee)throw new Error("invertCt: expected non-zero number");let r=Ms(n,e-ct,e);if(he(n*r,e)!==V)throw new Error("invertCt: does not exist");return r}function Zr(t,e,n){let r=t;if(!r.eql(r.sqr(e),n))throw new Error("Cannot find square root")}function Yr(t,e){if((t&V)===ee)throw new Error(e+": expected odd modulus, got "+t)}function Ns(t,e){let n=t,r=(n.ORDER+V)/Wr,o=n.pow(e,r);return Zr(n,o,e),o}function Qf(t,e){let n=t,r=(n.ORDER-Rs)/$s,o=n.mul(e,ct),i=n.pow(o,r),s=n.mul(e,i),a=n.mul(n.mul(s,ct),i),c=n.mul(s,n.sub(a,n.ONE));return Zr(n,c,e),c}function eu(t){let e=zn(t),n=Ls(t),r=n(e,e.neg(e.ONE)),o=n(e,r),i=n(e,e.neg(r)),s=(t+Zf)/Ps;return((a,c)=>{let f=a,u=f.pow(c,s),d=f.mul(u,r),h=f.mul(u,o),l=f.mul(u,i),m=f.eql(f.sqr(d),c),p=f.eql(f.sqr(h),c);u=f.cmov(u,d,m),d=f.cmov(l,h,p);let w=f.eql(f.sqr(d),c),b=f.cmov(u,d,w);return Zr(f,b,c),b})}function Ls(t){if(t<Cs)throw new Error("sqrt is not defined for small field");Yr(t,"tonelliShanks");let e=t-V,n=0;for(;e%ct===ee;)e/=ct,n++;let r=ct,o=zn(t);for(;Ts(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Ns;let i=o.pow(r,e),s=(e+V)/ct;return function(c,f){let u=c;if(u.is0(f))return f;if(Ts(u,f)!==1)throw new Error("Cannot find square root");let d=n,h=u.mul(u.ONE,i),l=u.pow(f,e),m=u.pow(f,s);for(;!u.eql(l,u.ONE);){if(u.is0(l))throw new Error("Cannot find square root: probably non-prime P");let p=1,w=u.sqr(l);for(;!u.eql(w,u.ONE);)if(p++,w=u.sqr(w),p===d)throw new Error("Cannot find square root");let b=V<<BigInt(d-p-1),k=u.pow(h,b);d=p,h=u.sqr(k),l=u.mul(l,h),m=u.mul(m,k)}return m}}function tu(t){return Yr(t,"Fp.sqrt"),t%Wr===Cs?Ns:t%$s===Rs?Qf:t%Ps===Yf?eu(t):Ls(t)}var nu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function jt(t){if(it(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);_t(t.BYTES,"BYTES"),_t(t.BITS,"BITS");for(let e of nu)xt(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=V)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Xr(t,e,n=!1){jt(t),Fn(e,"nums"),$e(n,"passZero");let r=t,o=new Array(e.length).fill(n?r.ZERO:void 0),i=e.reduce((a,c,f)=>r.is0(c)?a:(o[f]=a,r.mul(a,c)),r.ONE),s=r.inv(i);return e.reduceRight((a,c,f)=>r.is0(c)?a:(o[f]=r.mul(a,o[f]),r.mul(a,c)),s),o}function Ts(t,e){jt(t);let n=t;Yr(n.ORDER,"FpLegendre");let r=(n.ORDER-V)/ct,o=n.pow(e,r),i=n.eql(o,n.ONE),s=n.eql(o,n.ZERO),a=n.eql(o,n.neg(n.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function ru(t,e){if(e!==void 0&&jr(e),t<=ee)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let n=Ut(t);if(e!==void 0&&e<n)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${n})`);let r=e!==void 0?e:n,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}var Hs=new WeakMap,Vn=class{ORDER;BITS;BYTES;isLE;ZERO=ee;ONE=V;_lengths;_mod;constructor(e,n={}){if(e<=V)throw new Error("invalid field: expected ORDER > 1, got "+e);let r;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(r=n.BITS),typeof n.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:n.sqrt,enumerable:!0}),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=Object.freeze(n.allowedLengths.slice())),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));let{nBitLength:o,nByteLength:i}=ru(e,r);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return he(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ee<=e&&e<this.ORDER}is0(e){return e===ee}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&V)===V}neg(e){return he(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return he(e*e,this.ORDER)}add(e,n){return he(e+n,this.ORDER)}sub(e,n){return he(e-n,this.ORDER)}mul(e,n){return he(e*n,this.ORDER)}pow(e,n){return Ms(e,n,this.ORDER)}div(e,n){return he(e*Ss(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return Ss(e,this.ORDER)}sqrt(e){let n=Hs.get(this);return n||Hs.set(this,n=tu(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?zr(e,this.BYTES):Kn(e,this.BYTES)}fromBytes(e,n=!1){X(e);let{_lengths:r,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Vr(e):Pe(e);if(a&&(c=he(c,s)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Xr(this,e,!0)}cmov(e,n,r){return $e(r,"condition"),r?n:e}};function zn(t,e={}){return Object.freeze(Vn.prototype),new Vn(t,e)}function Os(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=V)throw new Error("field order must be greater than 1");let e=Ut(t-V);return Math.ceil(e/8)}function qn(t){let e=Os(t);return e+Math.ceil(e/2)}function Jr(t,e,n=!1){X(t);let r=t.length,o=Os(e),i=Math.max(qn(e),16);if(r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);let s=n?Vr(t):Pe(t),a=he(s,e-V)+V;return n?zr(a,o):Kn(a,o)}var to=BigInt(0),an=BigInt(1),ou=BigInt(4),Qr=16,Fs=128,iu=5,_s=2**31;function Kt(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);xt(e.fromAffine,"Point.fromAffine"),xt(e.fromBytes,"Point.fromBytes"),xt(e.fromHex,"Point.fromHex"),it(e.BASE,"Point.BASE"),it(e.ZERO,"Point.ZERO"),jt(e.Fp),jt(e.Fn)}function js(t,e){Kt(t),Ks(e,t);let n=Xr(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function su(t,e,n=1){if(!Number.isSafeInteger(t)||t<n||t>e)throw new Error("invalid window size, expected ["+n+".."+e+"], got W="+t)}function au(t,e){let n=t*(4*e+128);if(n>_s)throw new Error("invalid window size: table would need ~"+Math.ceil(n/2**20)+" MiB, max "+_s/2**20+" MiB")}function no(t,e){if(t!==void 0){xt(t,"randomBytes");try{let n=t(e);if(!Ft(n)||n.length!==e)return}catch{return}return t}}function Ks(t,e){Fn(t,"points"),t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function cu(t,e,n){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,o)=>{if(!(n===void 0?e.isValid(r):st(r)&&r<n))throw new Error("invalid scalar at index "+o)})}var Vs=new WeakMap;function eo(t){return Vs.get(t)||1}function fu(t,e){let n=t.double(),r=[t];for(let o=1;o<e;o++)r.push(r[o-1].add(n));return r}function uu(t,e){let n=2**e,r=n/2,o=BigInt(n-1),i=[];for(;t>to;){let s=0;t&an&&(s=Number(t&o),s>=r&&(s-=n),t-=BigInt(s)),i.push(s),t>>=an}return i}function du(t,e,n){let r=2**e,o=r/2,i=BigInt(r-1),s=BigInt(e),a=[];for(let c=0;c<n;c++){let f=Number(t&i);t>>=s,f>o&&(f-=r,t+=an),a.push(f)}if(t!==to)throw new Error("invalid wnaf");return a}function hu(t,e,n){let r=0;for(let i of n)r=Math.max(r,i.length);let o=t;for(let i=r-1;i>=0;i--){i!==r-1&&(o=o.double());for(let s=0;s<n.length;s++){let a=n[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var Gn=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){Kt(e),this.randomBytes=no(n,Qr),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,n,r){let o=Math.ceil(r/n)+1,i=2**(n-1),s=[],a=e;for(let c=0;c<o;c++){let f=a;for(let u=0;u<i;u++)s.push(f),f=f.add(a);a=s[s.length-1].double()}return{W:n,bits:r,windows:o,comp:s}}wnafCachedCT(e,n){let{W:r,windows:o,comp:i}=e,s=2**(r-1),a=du(n,r,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let d=a[u],h=u*s,l=Math.abs(d)-1,m=i[h];for(let w=1;w<s;w++)m=w===l?i[h+w]:m;let p=m.negate();d===0?f=f.add(i[h]):c=c.add(d<0?p:m)}return{p:c,f}}getWnafPrecomputes(e,n,r,o){let i=this.wnafPrecomputes.get(n),s=i?.find(a=>a.W===e&&a.bits===r);return s||(s=this.buildWnafTable(n,e,r),typeof o=="function"&&(s={...s,comp:o(s.comp)}),i||(i=[],this.wnafPrecomputes.set(n,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,n){if(this.assertPoint(e),!qr(n,an,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,r,o){let i=eo(e);return i===1?this.fixedWindowCT(e,n,r):this.wnafCachedCT(this.getWnafPrecomputes(i,e,r,o),n)}mulCT(e,n,r){return this.validateMulInput(e,n),this.runCT(e,n,this.bits,r)}mulCTBlinded(e,n,r){if(this.validateMulInput(e,n),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+Fs,i=this.randomBytes(Qr);if(!Ft(i)||i.length!==Qr)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=n+Pe(i)*this.Point.Fn.ORDER;return this.runCT(e,s,o,r)}fixedWindowCT(e,n,r){let o=iu,i=1<<o,s=sn(o),a=new Array(i);a[0]=this.ZERO;for(let u=1;u<i;u++)a[u]=a[u-1].add(e);let c=Math.ceil(r/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let l=0;l<o;l++)f=f.double();let d=Number(n>>BigInt(u*o)&s),h=a[0];for(let l=1;l<i;l++)h=l===d?a[l]:h;f=f.add(h)}return{p:f,f}}shouldBlind(e,n){return this.randomBytes===void 0?!1:n===an?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,n,r,o){return this.shouldBlind(e,r)?this.mulCTBlinded(e,n,o):this.mulCT(e,n,o)}mulUnsafe(e,n,r){if(this.assertPoint(e),!st(n))throw new Error("invalid scalar");let o=eo(e);if(o===1||n>=this.Point.Fn.ORDER)return Wn(this.Point,[e],[n],!0);let i=this.getWnafPrecomputes(o,e,this.bits,r);return this.wnafCachedCT(i,n).p}setWindowSize(e,n){this.assertPoint(e),su(n,this.bits);let r=Math.ceil((this.bits+Fs)/n)+1;au(r*2**(n-1),this.Point.Fp.BYTES),Vs.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return eo(e)!==1}};function Wn(t,e,n,r=!1){if(Kt(t),Ks(e,t),$e(r,"allowOversized"),cu(n,t.Fn,r?t.Fn.ORDER**ou:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(s=>fu(s,4)),i=n.map(s=>uu(s,4));return hu(t.ZERO,o,i)}function Us(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return jt(e),e}else return zn(t,{isLE:n})}function zs(t,e,n={},r){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);at(n);for(let c of["p","n","h"]){let f=e[c];if(!(st(f)&&f!==to))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Us(e.p,n.Fp,r),i=Us(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function qs(t,e){return function(r){let o=t(r);return{secretKey:o,publicKey:e(o)}}}y();y();var Zn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(Pn(e),Re(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),rn(o)}update(e){return Ot(this),this.iHash.update(e),this}digestInto(e){Ot(this),Mn(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Gs=(()=>{let t=((e,n,r)=>new Zn(e,n).update(r).digest());return t.create=(e,n)=>new Zn(e,n),t})();y();var lu=BigInt(0),ro=class extends Error{constructor(e=""){super(e)}},je={Err:ro,_tlv:{encode:(t,e)=>{let{Err:n}=je;if(_t(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(As(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let r=e.length/2,o=on(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");let i=r>127?on(o.length/2|128):"";return on(t)+i+o+e},decode(t,e){let{Err:n}=je;e=X(e,void 0,"DER data");let r=0;if(t<0||t>255)throw new n("tlv.decode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");let o=e[r++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");let f=e.subarray(r,r+c);if(f.length!==c)throw new n("tlv.decode: length bytes not complete");if(f[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(r+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}let a=e.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+s)}}},_int:{encode(t){let{Err:e}=je;if(jn(t),t<lu)throw new e("integer: negative integers are not allowed");let n=on(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){let{Err:e}=je;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Pe(t)}},toSig(t){let{Err:e,_int:n,_tlv:r}=je,o=X(t,void 0,"signature"),{v:i,l:s}=r.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=r.decode(2,i),{v:f,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(f)}},hexFromSig(t){let{_tlv:e,_int:n}=je;at(t,{r:"bigint",s:"bigint"},{},"sig");let r=e.encode(2,n.encode(t.r)),o=e.encode(2,n.encode(t.s)),i=r+o;return e.encode(48,i)}},oo=(Object.freeze(je._tlv),Object.freeze(je._int),Object.freeze(je));var Ws=(t,e)=>(t+(t>=0?e:-e)/Zs)/e;function pu(t,e,n){Gr("scalar",t,Ke,n);let[[r,o],[i,s]]=e,a=Ws(s*t,n),c=Ws(-o*t,n),f=t-a*r-c*i,u=-a*o-c*s,d=f<Ke,h=u<Ke;d&&(f=-f),h&&(u=-u);let l=sn(Math.ceil(Ut(n)/2))+Et;if(f<Ke||f>=l||u<Ke||u>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:f,k2neg:h,k2:u}}function ao(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function io(t,e){at(t);let n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return $e(n.lowS,"lowS"),$e(n.prehash,"prehash"),n.format!==void 0&&ao(n.format),n}var Ke=BigInt(0),Et=BigInt(1),Zs=BigInt(2),so=BigInt(3),mu=BigInt(4);function Ys(t,e={}){let n=zs("weierstrass",t,e),r=n.Fp,o=n.Fn,i=n.CURVE,{h:s,n:a}=i;at(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=e,u=e.randomBytes===void 0?Un:e.randomBytes;if(c&&(!r.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=Js(r,o);function h(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(L,E,A){if(f&&E.is0())return Uint8Array.of(0);let{x:C,y:M}=E.toAffine(),I=r.toBytes(C);if($e(A,"isCompressed"),A){h();let x=!r.isOdd(M);return Ue(Xs(x),I)}else return Ue(Uint8Array.of(4),I,r.toBytes(M))}function m(L){X(L,void 0,"Point");let{publicKey:E,publicKeyUncompressed:A}=d,C=L.length,M=L[0],I=L.subarray(1);if(f&&C===1&&M===0)return{x:r.ZERO,y:r.ZERO};if(C===E&&(M===2||M===3)){let x=r.fromBytes(I);if(!r.isValid(x))throw new Error("bad point: is not on curve, wrong x");let H=v(x),R;try{R=r.sqrt(H)}catch(K){let j=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+j)}h();let N=r.isOdd(R);return(M&1)===1!==N&&(R=r.neg(R)),{x,y:R}}else if(C===A&&M===4){let x=r.BYTES,H=r.fromBytes(I.subarray(0,x)),R=r.fromBytes(I.subarray(x,x*2));if(!O(H,R))throw new Error("bad point: is not on curve");return{x:H,y:R}}else throw new Error(`bad point: got length ${C}, expected compressed=${E} or uncompressed=${A}`)}let p=e.toBytes===void 0?l:e.toBytes,w=e.fromBytes===void 0?m:e.fromBytes,b=r.mul(i.b,so),k=r.is0(i.a)?L=>r.ZERO:L=>r.mul(i.a,L);function v(L){let E=r.sqr(L),A=r.mul(E,L);return r.add(r.add(A,r.mul(L,i.a)),i.b)}function O(L,E){let A=r.sqr(E),C=v(L);return r.eql(A,C)}if(!O(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let z=r.mul(r.pow(i.a,so),mu),S=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(z,S)))throw new Error("bad curve params: a or b");function _(L,E,A=!1){if(!r.isValid(E)||A&&r.is0(E))throw new Error(`bad point coordinate ${L}`);return E}function F(L){if(!(L instanceof D))throw new Error("Weierstrass Point expected")}function G(L){if(!c||!c.basises)throw new Error("no endo");return pu(L,c.basises,o.ORDER)}function q(L,E,A,C){if(!o.isValid(C))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:M,k1:I,k2neg:x,k2:H}=G(C),R=new D(r.mul(A.X,c.beta),A.Y,A.Z);L.push(M?A.negate():A,x?R.negate():R),E.push(I,H)}else L.push(A),E.push(C)}let ge=new WeakSet;class D{static BASE=new D(i.Gx,i.Gy,r.ONE);static ZERO=new D(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=o;X;Y;Z;constructor(E,A,C){this.X=_("x",E),this.Y=_("y",A,!0),this.Z=_("z",C),Object.freeze(this)}static CURVE(){return i}static fromAffine(E){let{x:A,y:C}=E||{};if(!E||!r.isValid(A)||!r.isValid(C))throw new Error("invalid affine point");if(E instanceof D)throw new Error("projective point not allowed");return r.is0(A)&&r.is0(C)?D.ZERO:new D(A,C,r.ONE)}static fromBytes(E){let A=D.fromAffine(w(X(E,void 0,"point")));return A.assertValidity(),A}static fromHex(E){return D.fromBytes(_n(E))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=6,A=!0){return re.setWindowSize(this,E),A||this.multiply(so),this}assertValidity(){let E=this;if(E.is0()){if(e.allowInfinityPoint&&r.is0(E.X)&&r.eql(E.Y,r.ONE)&&r.is0(E.Z))return;throw new Error("bad point: ZERO")}if(ge.has(E))return;let{x:A,y:C}=E.toAffine();if(!r.isValid(A)||!r.isValid(C))throw new Error("bad point: x or y not field elements");if(!O(A,C))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");ge.add(E)}hasEvenY(){let{y:E}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(E)}equals(E){F(E);let{X:A,Y:C,Z:M}=this,{X:I,Y:x,Z:H}=E,R=r.eql(r.mul(A,H),r.mul(I,M)),N=r.eql(r.mul(C,H),r.mul(x,M));return R&&N}negate(){return new D(this.X,r.neg(this.Y),this.Z)}double(){let{X:E,Y:A,Z:C}=this,M=r.ZERO,I=r.ZERO,x=r.ZERO,H=r.mul(E,E),R=r.mul(A,A),N=r.mul(C,C),P=r.mul(E,A);return P=r.add(P,P),x=r.mul(E,C),x=r.add(x,x),M=k(x),I=r.mul(b,N),I=r.add(M,I),M=r.sub(R,I),I=r.add(R,I),I=r.mul(M,I),M=r.mul(P,M),x=r.mul(b,x),N=k(N),P=r.sub(H,N),P=k(P),P=r.add(P,x),x=r.add(H,H),H=r.add(x,H),H=r.add(H,N),H=r.mul(H,P),I=r.add(I,H),N=r.mul(A,C),N=r.add(N,N),H=r.mul(N,P),M=r.sub(M,H),x=r.mul(N,R),x=r.add(x,x),x=r.add(x,x),new D(M,I,x)}add(E){F(E);let{X:A,Y:C,Z:M}=this,{X:I,Y:x,Z:H}=E,R=r.ZERO,N=r.ZERO,P=r.ZERO,K=r.mul(A,I),j=r.mul(C,x),Z=r.mul(M,H),ce=r.add(A,C),W=r.add(I,x);ce=r.mul(ce,W),W=r.add(K,j),ce=r.sub(ce,W),W=r.add(A,M);let te=r.add(I,H);return W=r.mul(W,te),te=r.add(K,Z),W=r.sub(W,te),te=r.add(C,M),R=r.add(x,H),te=r.mul(te,R),R=r.add(j,Z),te=r.sub(te,R),P=k(W),R=r.mul(b,Z),P=r.add(R,P),R=r.sub(j,P),P=r.add(j,P),N=r.mul(R,P),j=r.add(K,K),j=r.add(j,K),Z=k(Z),W=r.mul(b,W),j=r.add(j,Z),Z=r.sub(K,Z),Z=k(Z),W=r.add(W,Z),K=r.mul(j,W),N=r.add(N,K),K=r.mul(te,W),R=r.mul(ce,R),R=r.sub(R,K),K=r.mul(ce,j),P=r.mul(te,P),P=r.add(P,K),new D(R,N,P)}subtract(E){return F(E),this.add(E.negate())}is0(){return this.equals(D.ZERO)}multiply(E){if(!o.isValidNot0(E))throw new RangeError("invalid scalar: out of range");let{p:A,f:C}=re.mulSecret(this,E,s,ae);return ae([A,C])[0]}multiplyUnsafe(E){let A=this,C=E;if(!o.isValid(C))throw new RangeError("invalid scalar: out of range");if(C===Ke||A.is0())return D.ZERO;if(C===Et)return A;if(re.hasWindowSize(this))return re.mulUnsafe(A,C,ae);let M=[],I=[];return q(M,I,A,C),Wn(D,M,I)}mulAddUnsafe(E,A,C){F(A);let M=[],I=[];return q(M,I,this,E),q(M,I,A,C),Wn(D,M,I)}toAffine(E){let A=this,C=E;if(C!=null&&!r.isValid(C))throw new RangeError('"invertedZ" expected valid field element');let{X:M,Y:I,Z:x}=A;if(r.eql(x,r.ONE))return{x:M,y:I};let H=A.is0();C==null&&(C=H?r.ONE:r.inv(x));let R=r.mul(M,C),N=r.mul(I,C),P=r.mul(x,C);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(P,r.ONE))throw new Error("invZ was invalid");return{x:R,y:N}}isTorsionFree(){let{isTorsionFree:E}=e;return s===Et?!0:E?E(D,this):re.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:E}=e;return s===Et?this:E?E(D,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Et?this.is0():this.clearCofactor().is0()}toBytes(E=!0){return $e(E,"isCompressed"),this.assertValidity(),p(D,this,E)}toHex(E=!0){return Kr(this.toBytes(E))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ae=L=>js(D,L),re=new Gn(D,u);return re.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}function Xs(t){return Uint8Array.of(t?2:3)}function Js(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function gu(t,e={}){Kt(t);let{Fn:n}=t,r=e.randomBytes===void 0?Un:e.randomBytes,o=Object.assign(Js(t.Fp,n),{seed:Math.max(qn(n.ORDER),16)});function i(l){try{let m=n.fromBytes(l);return n.isValidNot0(m)}catch{return!1}}function s(l,m){let{publicKey:p,publicKeyUncompressed:w}=o;try{let b=l.length;return m===!0&&b!==p||m===!1&&b!==w?!1:!!t.fromBytes(l)}catch{return!1}}function a(l){return l=l===void 0?r(o.seed):l,Jr(X(l,o.seed,"seed"),n.ORDER)}function c(l,m=!0){return t.BASE.multiply(n.fromBytes(l)).toBytes(m)}function f(l){let{secretKey:m,publicKey:p,publicKeyUncompressed:w}=o,b=n._lengths;if(!Ft(l))return;let k=X(l,void 0,"key").length,v=k===p||k===w,O=k===m||!!b?.includes(k);if(!(v&&O))return v}function u(l,m,p=!0){if(f(l)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let w=n.fromBytes(l);return t.fromBytes(m).multiply(w).toBytes(p)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=qs(a,c);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:h,Point:t,utils:d,lengths:o})}function Qs(t,e,n={}){Kt(t);let r=e;Pn(r),at(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},n),i=o.randomBytes===void 0?Un:o.randomBytes,s=o.hmac===void 0?(I,x)=>Gs(r,I,x):o.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:u}=c,d=qn(f),h=no(i,d),{keygen:l,getPublicKey:m,getSharedSecret:p,utils:w,lengths:b}=gu(t,o),k={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},v=f*Zs+Et<a.ORDER;function O(I){let x=f>>Et;return I>x}function z(I,x){if(!c.isValidNot0(x))throw new Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return x}function S(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function _(I,x,H){return S(),(I===H?0:2)|Number(a.isOdd(x))}function F(){if(v)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function G(I,x){ao(x);let H=b.signature,R=x==="compact"?H:x==="recovered"?H+1:void 0;return X(I,R)}class q{r;s;recovery;constructor(x,H,R){if(this.r=z("r",x),this.s=z("s",H),R!=null){if(F(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(x,H=k.format){G(x,H);let R;if(H==="der"){let{r:j,s:Z}=oo.toSig(X(x));return new q(j,Z)}H==="recovered"&&(R=x[0],H="compact",x=x.subarray(1));let N=b.signature/2,P=x.subarray(0,N),K=x.subarray(N,N*2);return new q(c.fromBytes(P),c.fromBytes(K),R)}static fromHex(x,H){return this.fromBytes(_n(x),H)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new q(this.r,this.s,x)}recoverPublicKey(x){let{r:H,s:R}=this,N=this.assertRecovery(),P=N===2||N===3?H+f:H;if(!a.isValid(P))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=a.toBytes(P),j=t.fromBytes(Ue(Xs((N&1)===0),K)),Z=c.inv(P),ce=D(X(x,void 0,"msgHash")),W=c.create(-ce*Z),te=c.create(R*Z),Ae=t.BASE.mulAddUnsafe(W,j,te);if(Ae.is0())throw new Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return O(this.s)}toBytes(x=k.format){if(ao(x),x==="der")return _n(oo.hexFromSig(this));let{r:H,s:R}=this,N=c.toBytes(H),P=c.toBytes(R);return x==="recovered"?(F(),Ue(Uint8Array.of(this.assertRecovery()),N,P)):Ue(N,P)}toHex(x){return Kr(this.toBytes(x))}}Object.freeze(q.prototype),Object.freeze(q);let ge=o.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let H=Pe(x),R=x.length*8-u;return R>0?H>>BigInt(R):H}:o.bits2int,D=o.bits2int_modN===void 0?function(x){return c.create(ge(x))}:o.bits2int_modN,ae=sn(u);function re(I){return Gr("num < 2^"+u,I,Ke,ae),c.toBytes(I)}function L(I,x){return X(I,void 0,"message"),x?X(r(I),void 0,"prehashed message"):I}function E(I,x,H){let{lowS:R,prehash:N,extraEntropy:P}=io(H,k);I=L(I,N);let K=D(I),j=c.fromBytes(x);if(!c.isValidNot0(j))throw new Error("invalid private key");let Z=[re(j),re(K)];if(P!=null&&P!==!1){let Ae=P===!0?i(b.secretKey):P;Z.push(X(Ae,void 0,"extraEntropy"))}let ce=Ue(...Z),W=K;function te(Ae){let Tt=ge(Ae);if(!c.isValidNot0(Tt))return;let Wt=t.BASE.multiply(Tt).toAffine(),Qe=c.create(Wt.x);if(Qe===Ke)return;let Ie;if(h!==void 0){let Zt=Pe(Jr(h(d),f)),wc=c.inv(c.mul(Zt,Tt)),xc=c.mul(Zt,W),Ec=c.mul(Zt,j);Ie=c.create(wc*c.create(xc+Ec*Qe))}else{let Zt=Ds(Tt,f);Ie=c.create(Zt*c.create(W+Qe*j))}if(Ie===Ke)return;let ur=_(Wt.x,Wt.y,Qe),fi=Ie;return R&&O(Ie)&&(fi=c.neg(Ie),ur^=1),new q(Qe,fi,v?void 0:ur)}return{seed:ce,k2sig:te}}function A(I,x,H={}){let{seed:R,k2sig:N}=E(I,x,H);return ks(r.outputLen,c.BYTES,s)(R,N).toBytes(H.format)}function C(I,x,H,R={}){let{lowS:N,prehash:P,format:K}=io(R,k);if(H=X(H,void 0,"publicKey"),x=L(x,P),!Ft(I)){let j=I instanceof q?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+j)}G(I,K);try{let j=q.fromBytes(I,K),Z=t.fromBytes(H);if(N&&j.hasHighS())return!1;let{r:ce,s:W}=j,te=D(x),Ae=c.inv(W),Tt=c.create(te*Ae),Wt=c.create(ce*Ae),Qe=t.BASE.mulAddUnsafe(Tt,Z,Wt);if(Qe.is0())return!1;let Ie=Qe.toAffine();return!(c.create(Ie.x)!==ce||K==="recovered"&&j.recovery!==_(Ie.x,Ie.y,ce))}catch{return!1}}function M(I,x,H={}){let{prehash:R}=io(H,k);return x=L(x,R),q.fromBytes(I,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:p,utils:w,lengths:b,Point:t,sign:A,verify:C,recoverPublicKey:M,Signature:q,hash:r})}var bu={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var yu=Ys(bu),ea=Qs(yu,Bs);var fo=globalThis.crypto,co=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=U.create();else if(n==="sha512")this.hasher=Rn.create();else throw new Error(`createHash: unsupported algorithm ${e} in the browser verifier`)}update(e){return this.hasher.update(typeof e=="string"?new TextEncoder().encode(e):e),this}digest(e){let n=this.hasher.digest(),r=B.Buffer.from(n);return e===void 0?r:r.toString(e)}};function Yn(t){return new co(t)}function uo(t){let e=[];return{update(n){return e.push(n),this},verify(n,r){try{let o=n instanceof Uint8Array?n:n.key,i=o.subarray(o.length-65);if(i.length!==65||i[0]!==4)return!1;let s=0;for(let f of e)s+=f.length;let a=new Uint8Array(s),c=0;for(let f of e)a.set(f,c),c+=f.length;return ea.verify(r,U(a),i,{format:"der",prehash:!1,lowS:!1})}catch{return!1}}}}y();function le(t){let e=ta(t);return new TextEncoder().encode(e)}function ta(t){return JSON.stringify(ho(t))}function ho(t){if(t===null||typeof t!="object"){if(typeof t>"u")throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");if(typeof t=="function"||typeof t=="symbol")throw new TypeError(`bitgraph-core/canonical: ${typeof t} values are not serializable to canonical JSON`);if(typeof t=="bigint")throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; convert to string (decimal) before canonicalizing");return t}if(Array.isArray(t))return t.map(ho);let e={};for(let n of Object.keys(t).sort()){let r=t[n];typeof r>"u"||(e[n]=ho(r))}return e}function Xn(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}async function po(t){let{proof:e,bytes:n,trustAnchors:r}=t,o=await na(e,n,r);return o===null?{valid:!0}:Su(o)}async function ft(t){let{proof:e,trustAnchors:n}=t,r=await na(e,void 0,n);return r===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:r}}async function na(t,e,n){let r=xu(t);if(r!==null)return r;let o=e===void 0?void 0:U(e),i;try{i=Vt(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(o!==void 0&&!Xn(o,i))return"artifact digest mismatch: the provided bytes do not match the committed digest";let s;try{s=Vt(t.signer.publicKeyB64)}catch{return"signer.publicKeyB64 is not valid base64"}if(s.length!==32)return`signer.publicKeyB64 decodes to ${s.length} bytes; expected 32 (Ed25519)`;let a={version:t.version,artifact:t.artifact,commit:t.commit,publicKeyB64:t.signer.publicKeyB64,enforcement:t.environment.enforcement,measurement:t.environment.measurement};t.environment.attestation!==void 0&&(a.attestationFormat=t.environment.attestation.format),t.agency!==void 0&&(a.actor=t.agency.actor),t.policy!==void 0&&(a.policy=t.policy),t.attribution!==void 0&&(a.attribution=t.attribution);let c=le(a),f;try{f=Vt(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(f.length!==64)return`signer.signatureB64 decodes to ${f.length} bytes; expected 64 (Ed25519)`;let u;try{u=await $r(f,c,s)}catch(d){return`signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!u)return"signature verification failed: signature does not match";if(t.agency!==void 0){let d=vu(t);if(d!==null)return d}if(t.slotAllocation!==void 0){let d=await Au(t);if(d!==null)return d}if(t.commit.epochLink!==void 0){let d=ku(t);if(d!==null)return d}if(n!==void 0){let d=Eu(t,n);if(d!==null)return d}return null}var wu=new Set(["stub","hw-key","measured-tee"]);function xu(t){if(t===null||typeof t!="object")return"proof must be an object";let e=t;if(e.version!=="bitgraph/1")return`unsupported proof version: ${String(e.version)}`;if(!cn(e.artifact))return"proof.artifact is missing or not an object";let n=e.artifact;if(n.hashAlg!=="sha256")return`unsupported hashAlg: ${String(n.hashAlg)}`;if(typeof n.digestB64!="string"||n.digestB64.length===0)return"proof.artifact.digestB64 must be a non-empty string";if(!cn(e.commit))return"proof.commit is missing or not an object";let r=e.commit;if(typeof r.nonceB64!="string"||r.nonceB64.length===0)return"proof.commit.nonceB64 must be a non-empty string";if(r.counter!==void 0&&typeof r.counter!="string")return"proof.commit.counter must be a string when present";if(r.time!==void 0&&(typeof r.time!="number"||!Number.isFinite(r.time)||r.time<0))return"proof.commit.time must be a non-negative finite number when present";if(r.prevB64!==void 0&&typeof r.prevB64!="string")return"proof.commit.prevB64 must be a string when present";if(r.epochId!==void 0&&typeof r.epochId!="string")return"proof.commit.epochId must be a string when present";if(!cn(e.signer))return"proof.signer is missing or not an object";let o=e.signer;if(typeof o.publicKeyB64!="string"||o.publicKeyB64.length===0)return"proof.signer.publicKeyB64 must be a non-empty string";if(typeof o.signatureB64!="string"||o.signatureB64.length===0)return"proof.signer.signatureB64 must be a non-empty string";if(!cn(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!wu.has(i.enforcement))return"proof.environment.enforcement must be one of: stub, hw-key, measured-tee";if(typeof i.measurement!="string"||i.measurement.length===0)return"proof.environment.measurement must be a non-empty string";if(i.attestation!==void 0){if(!cn(i.attestation))return"proof.environment.attestation must be an object when present";let s=i.attestation;if(typeof s.format!="string"||s.format.length===0)return"proof.environment.attestation.format must be a non-empty string";if(typeof s.reportB64!="string"||s.reportB64.length===0)return"proof.environment.attestation.reportB64 must be a non-empty string"}return null}function Eu(t,e){if(e.requireEnforcement!==void 0&&t.environment.enforcement!==e.requireEnforcement)return`enforcement tier "${t.environment.enforcement}" does not meet required tier "${e.requireEnforcement}"`;if(e.allowedMeasurements!==void 0&&e.allowedMeasurements.length>0&&!e.allowedMeasurements.includes(t.environment.measurement))return`measurement "${t.environment.measurement}" is not in the allowed set`;if(e.allowedPublicKeys!==void 0&&e.allowedPublicKeys.length>0&&!e.allowedPublicKeys.includes(t.signer.publicKeyB64))return"proof public key is not in the allowed set";if(e.requireAttestation===!0&&t.environment.attestation===void 0)return"policy requires attestation but proof has none";if(e.requireAttestationFormat!==void 0&&e.requireAttestationFormat.length>0){if(t.environment.attestation===void 0)return"policy requires attestation format but proof has no attestation";if(!e.requireAttestationFormat.includes(t.environment.attestation.format))return`attestation format "${t.environment.attestation.format}" is not in the required set`}if(e.minCounter!==void 0||e.maxCounter!==void 0){if(t.commit.counter===void 0)return"policy requires a counter but proof has none";let n;try{n=BigInt(t.commit.counter)}catch{return"could not parse proof counter value as integer"}if(e.minCounter!==void 0){let r;try{r=BigInt(e.minCounter)}catch{return"could not parse policy minCounter as integer"}if(n<r)return`counter ${t.commit.counter} is below minimum ${e.minCounter}`}if(e.maxCounter!==void 0){let r;try{r=BigInt(e.maxCounter)}catch{return"could not parse policy maxCounter as integer"}if(n>r)return`counter ${t.commit.counter} is above maximum ${e.maxCounter}`}}if(e.minTime!==void 0||e.maxTime!==void 0){if(t.commit.time===void 0)return"policy requires a time field but proof has none";if(e.minTime!==void 0&&t.commit.time<e.minTime)return`commit time ${t.commit.time} is before minimum ${e.minTime}`;if(e.maxTime!==void 0&&t.commit.time>e.maxTime)return`commit time ${t.commit.time} is after maximum ${e.maxTime}`}if(e.requireEpochId===!0&&(t.commit.epochId===void 0||t.commit.epochId.length===0))return"policy requires epochId but proof has none";if(e.requireActor===!0&&t.agency===void 0)return"policy requires actor (agency) but proof has none";if(e.allowedActorKeyIds!==void 0&&e.allowedActorKeyIds.length>0){if(t.agency===void 0)return"policy requires allowed actor key ID but proof has no agency";if(!e.allowedActorKeyIds.includes(t.agency.actor.keyId))return"actor key ID is not in the allowed set"}if(e.allowedActorProviders!==void 0&&e.allowedActorProviders.length>0){if(t.agency===void 0)return"policy requires allowed actor provider but proof has no agency";if(!e.allowedActorProviders.includes(t.agency.actor.provider))return`actor provider "${t.agency.actor.provider}" is not in the allowed set`}if(e.allowedOrigins!==void 0&&e.allowedOrigins.length>0){if(t.agency===void 0)return"policy requires an allowed origin but proof has no agency";let n=t.agency.authorization;if(!("format"in n)||n.format!=="webauthn")return"policy requires an allowed WebAuthn origin but the authorization is not WebAuthn";let r;try{r=JSON.parse(n.clientDataJSON).origin}catch{r=void 0}if(typeof r!="string"||!e.allowedOrigins.includes(r))return`WebAuthn origin "${r??"(none)"}" is not in the allowed set`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function Bu(t,e){if(typeof t!="string"||t.length===0)return"agency: clientDataJSON missing origin field";let n;try{n=new URL(t).hostname.toLowerCase()}catch{return"agency: clientDataJSON origin is not a valid origin"}if(!n)return"agency: clientDataJSON origin has no host";let r=e.subarray(0,32).toString("hex"),o=n.split("."),i=[];for(let a=0;a<o.length;a++){let c=o.slice(a).join(".");if(a>0&&o.length-a<2)break;i.push(c)}return i.some(a=>Yn("sha256").update(a,"utf8").digest("hex")===r)?null:"agency: authenticatorData rpIdHash does not match the origin's domain"}function vu(t){let e=t.agency,{actor:n,authorization:r}=e,o="format"in r&&r.format==="webauthn";if(typeof n.keyId!="string"||n.keyId.length===0)return"agency.actor.keyId must be a non-empty string";if(typeof n.publicKeyB64!="string"||n.publicKeyB64.length===0)return"agency.actor.publicKeyB64 must be a non-empty string";if(n.algorithm!=="ES256")return`agency.actor.algorithm must be "ES256", got "${String(n.algorithm)}"`;if(typeof n.provider!="string"||n.provider.length===0)return"agency.actor.provider must be a non-empty string";if(r.purpose!=="bitgraph/commit-authorize/v1")return`agency.authorization.purpose must be "bitgraph/commit-authorize/v1", got "${String(r.purpose)}"`;if(typeof r.signatureB64!="string"||r.signatureB64.length===0)return"agency.authorization.signatureB64 must be a non-empty string";let i;try{i=B.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(Yn("sha256").update(i).digest("hex")!==n.keyId)return"agency: actor.keyId does not match SHA-256 of public key";if(r.actorKeyId!==n.keyId)return"agency: authorization.actorKeyId does not match actor.keyId";if(r.artifactHash!==t.artifact.digestB64){let c=e.batchContext;if(!c||!Array.isArray(c.batchDigests)||!c.batchDigests.includes(t.artifact.digestB64)||c.batchDigests[0]!==r.artifactHash)return"agency: authorization.artifactHash does not match proof.artifact.digestB64"}let a;try{a=B.Buffer.from(r.signatureB64,"base64")}catch{return"agency.authorization.signatureB64 is not valid base64"}try{if(o){let c=r;if(typeof c.clientDataJSON!="string"||!c.clientDataJSON)return"agency: WebAuthn authorization missing clientDataJSON";if(typeof c.authenticatorDataB64!="string"||!c.authenticatorDataB64)return"agency: WebAuthn authorization missing authenticatorDataB64";let f;try{f=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(f.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${f.type}"`;if(!f.challenge)return"agency: clientDataJSON missing challenge field";let u=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;u.length%4;)u+="=";if(u!==r.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let d=B.Buffer.from(c.authenticatorDataB64,"base64");if(d.length<37)return"agency: authenticatorData too short";let h=d[32];if(!(h&1))return"agency: authenticatorData UP flag not set";if(!(h&4))return"agency: authenticatorData UV flag not set";let l=Bu(f.origin,d);if(l!==null)return l;let m=Yn("sha256").update(B.Buffer.from(c.clientDataJSON,"utf8")).digest(),p=B.Buffer.concat([d,m]),w=uo("SHA256");if(w.update(p),!w.verify({key:i,format:"der",type:"spki"},a))return"agency: WebAuthn P-256 signature verification failed"}else{let c={purpose:r.purpose,actorKeyId:r.actorKeyId,artifactHash:r.artifactHash,challenge:r.challenge,timestamp:r.timestamp};"protocolVersion"in r&&r.protocolVersion!==void 0&&(c.protocolVersion=r.protocolVersion);let f=B.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),u=uo("SHA256");if(u.update(f),!u.verify({key:i,format:"der",type:"spki"},a))return"agency: P-256 signature verification failed"}}catch(c){return`agency: P-256 signature verification error: ${c instanceof Error?c.message:String(c)}`}return null}async function Au(t){let e=t.slotAllocation;if(e.version!=="bitgraph/slot/1")return`slotAllocation.version must be "bitgraph/slot/1", got "${String(e.version)}"`;if(typeof e.nonceB64!="string"||e.nonceB64.length===0)return"slotAllocation.nonceB64 must be a non-empty string";if(typeof e.counter!="string"||e.counter.length===0)return"slotAllocation.counter must be a non-empty string";if(e.time!==void 0&&(typeof e.time!="number"||!Number.isFinite(e.time)||e.time<0))return"slotAllocation.time must be a non-negative finite number when present";if(typeof e.epochId!="string"||e.epochId.length===0)return"slotAllocation.epochId must be a non-empty string";if(typeof e.publicKeyB64!="string"||e.publicKeyB64.length===0)return"slotAllocation.publicKeyB64 must be a non-empty string";if(typeof e.signatureB64!="string"||e.signatureB64.length===0)return"slotAllocation.signatureB64 must be a non-empty string";let n={version:e.version,nonceB64:e.nonceB64,counter:e.counter,...e.time!==void 0?{time:e.time}:{},epochId:e.epochId,publicKeyB64:e.publicKeyB64,...e.chainId?{chainId:e.chainId}:{}},r=le(n),o,i;try{o=Vt(e.signatureB64),i=Vt(e.publicKeyB64)}catch{return"slotAllocation contains invalid base64"}if(o.length!==64)return`slotAllocation.signatureB64 decodes to ${o.length} bytes; expected 64 (Ed25519)`;if(i.length!==32)return`slotAllocation.publicKeyB64 decodes to ${i.length} bytes; expected 32 (Ed25519)`;let s;try{s=await $r(o,r,i)}catch(d){return`slotAllocation signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let d of c)if(a.has(d))return`slotAllocation body contains forbidden field '${d}' \u2014 causal independence violated`;if(typeof t.commit.slotHashB64!="string"||t.commit.slotHashB64.length===0)return"commit.slotHashB64 must be present when slotAllocation is present";let f=U(r),u;try{u=Vt(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!Xn(f,u))return"commit.slotHashB64 does not match SHA-256 of canonical slot body \u2014 slot binding broken";if(e.nonceB64!==t.commit.nonceB64)return"slotAllocation.nonceB64 does not match commit.nonceB64";if(typeof t.commit.slotCounter!="string"||t.commit.slotCounter.length===0)return"commit.slotCounter must be present when slotAllocation is present";if(t.commit.slotCounter!==e.counter)return"commit.slotCounter does not match slotAllocation.counter";if(t.commit.counter===void 0)return"commit.counter must be present for slot ordering verification";try{let d=BigInt(e.counter),h=BigInt(t.commit.counter);if(d>=h)return`slotAllocation.counter (${e.counter}) must be less than commit.counter (${t.commit.counter})`}catch{return"could not parse slot or commit counter as integer"}return e.publicKeyB64!==t.signer.publicKeyB64?"slotAllocation.publicKeyB64 does not match signer.publicKeyB64 \u2014 different enclave":t.commit.epochId!==void 0&&e.epochId!==t.commit.epochId?"slotAllocation.epochId does not match commit.epochId \u2014 different lifecycle":null}var lo=new Map;function Iu(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=U(new TextEncoder().encode(e));return B.Buffer.from(n).toString("base64")}function ku(t){let e=t.commit.epochLink;if(typeof e.prevEpochId!="string"||e.prevEpochId.length===0)return"epochLink.prevEpochId must be a non-empty string";if(typeof e.prevPublicKeyB64!="string"||e.prevPublicKeyB64.length===0)return"epochLink.prevPublicKeyB64 must be a non-empty string";if(typeof e.prevCounter!="string"||e.prevCounter.length===0)return"epochLink.prevCounter must be a non-empty string";if(typeof e.prevProofHashB64!="string"||e.prevProofHashB64.length===0)return"epochLink.prevProofHashB64 must be a non-empty string";if(typeof e.toEpochId!="string"||e.toEpochId.length===0)return"epochLink.toEpochId must be a non-empty string";if(typeof e.toPublicKeyB64!="string"||e.toPublicKeyB64.length===0)return"epochLink.toPublicKeyB64 must be a non-empty string";try{BigInt(e.prevCounter)}catch{return"epochLink.prevCounter is not a valid decimal string"}if(t.commit.epochId!==void 0&&e.toEpochId!==t.commit.epochId)return`epochLink.toEpochId "${e.toEpochId}" does not match proof commit.epochId "${t.commit.epochId}" \u2014 successor binding broken`;if(e.toPublicKeyB64!==t.signer.publicKeyB64)return"epochLink.toPublicKeyB64 does not match proof signer.publicKeyB64 \u2014 successor binding broken";if(e.prevEpochId===e.toEpochId)return"epochLink.prevEpochId equals toEpochId \u2014 epoch link must cross epoch boundary";if(e.prevPublicKeyB64===e.toPublicKeyB64)return"epochLink.prevPublicKeyB64 equals toPublicKeyB64 \u2014 epochs must have different keys";let n=Iu(e),r=lo.get(n);if(r!==void 0){if(r!==e.toEpochId)return`FORK DETECTED: predecessor (epoch=${e.prevEpochId.slice(0,12)}..., counter=${e.prevCounter}) already consumed by epoch ${r.slice(0,12)}..., but this proof claims consumption by epoch ${e.toEpochId.slice(0,12)}... \u2014 single-successor invariant violated`}else lo.set(n,e.toEpochId);return null}function Ve(){lo.clear()}function Su(t){return{valid:!1,reason:t}}function cn(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Vt(t){let e=B.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}y();function Jn(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};e.attribution&&(o.attribution=e.attribution),r?.attestation&&(o.attestationFormat=r.attestation.format);let i=le(o),s=U(i);return go(s)}var ra=["proofHash","ethereum"];function mo(t){let e=t,n=e;if(ra.some(o=>Object.prototype.hasOwnProperty.call(e,o))){n={};for(let o of Object.keys(e))ra.includes(o)||(n[o]=e[o])}let r=le(n);return go(U(r))}function go(t){if(typeof B.Buffer<"u")return B.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function oa(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};r?.attestation!==void 0&&(o.attestationFormat=r.attestation.format);let i=e.agency;return i!==void 0&&(o.actor=i.actor),e.policy!==void 0&&(o.policy=e.policy),e.attribution!==void 0&&(o.attribution=e.attribution),o}function bo(t){return go(U(le(oa(t))))}y();y();var zp=new Uint8Array([0]),qp=new Uint8Array([1]);var xe="bitgraph-fuse/1",aa=(()=>{let t=new TextEncoder().encode(xe),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})(),ca=xe,Qn="BGFUSE01",er=48,Bt="bitgraph-fuse/manifest.json",ut="bitgraph-fuse/original",zt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fn={};for(let t=0;t<zt.length;t++)fn[zt[t]]=t;function Ze(t){let e="";for(let n=0;n<t.length;n+=3){let r=t[n],o=n+1<t.length?t[n+1]:0,i=n+2<t.length?t[n+2]:0;e+=zt[r>>2]+zt[(r&3)<<4|o>>4],e+=n+1<t.length?zt[(o&15)<<2|i>>6]:"=",e+=n+2<t.length?zt[i&63]:"="}return e}function qt(t){if(typeof t!="string"||t.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))return null;let e=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-e),r=0;for(let o=0;o<t.length;o+=4){let i=fn[t[o]]<<18|fn[t[o+1]]<<12|(t[o+2]==="="?0:fn[t[o+2]])<<6|(t[o+3]==="="?0:fn[t[o+3]]);n[r++]=i>>16&255,r<n.length&&(n[r++]=i>>8&255),r<n.length&&(n[r++]=i&255)}return Ze(n)!==t?null:n}function we(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function yo(t){if(typeof t!="string"||t.length%2!==0||!/^[0-9a-f]*$/.test(t))return null;let e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function Ee(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function dt(...t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}var pe=t=>new TextEncoder().encode(t);function fa(t){return{version:t.version,nonceB64:t.nonceB64,counter:t.counter,...t.time!==void 0?{time:t.time}:{},epochId:t.epochId,publicKeyB64:t.publicKeyB64,...t.chainId?{chainId:t.chainId}:{}}}function ua(t){return U(le(fa(t)))}function da(t){let e=qt(t.nonceB64);if(e===null||e.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return dt(aa,ua(t),e)}function un(t){return U(da(t))}function vt(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e!==void 0&&e.length!==32)throw new TypeError("originDigest must be 32 bytes");let n={type:xe,...e!==void 0?{origin:{algorithm:"sha256",digest:we(e)}}:{},slotCommitment:{algorithm:"sha256",digest:we(t)}};return le(n)}function ze(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}function qe(t){if(!ze(t)||Object.keys(t).length!==2||t.algorithm!=="sha256"||typeof t.digest!="string")return null;let n=yo(t.digest);return n!==null&&n.length===32?n:null}function nr(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!ze(n))return null;let r=Object.keys(n).sort(),o=r.length===2?["slotCommitment","type"]:r.length===3?["origin","slotCommitment","type"]:null;if(o===null||r.join(",")!==o.join(",")||n.type!==xe)return null;let i=qe(n.slotCommitment);if(i===null)return null;let s;if("origin"in n){let a=qe(n.origin);if(a===null)return null;s=a}return Ee(vt(i,s),t)?s!==void 0?{commitment:i,originDigest:s}:{commitment:i}:null}var oe=512,Ru=8589934591;function $u(t,e){let n=t.toString(8).padStart(e-1,"0")+"\0";if(n.length!==e)throw new RangeError("field overflow");return pe(n)}function Ge(t,e){if(e>Ru)throw new RangeError("container entries are limited to 8 GiB");let n=new Uint8Array(oe),r=pe(t);if(r.length>100)throw new RangeError("ustar name too long");n.set(r,0),n.set(pe("0000644\0"),100),n.set(pe("0000000\0"),108),n.set(pe("0000000\0"),116),n.set($u(e,12),124),n.set(pe("00000000000\0"),136),n.set(pe(" "),148),n[156]=48,n.set(pe("ustar\0"),257),n.set(pe("00"),263);let o=0;for(let i of n)o+=i;return n.set(pe(o.toString(8).padStart(6,"0")+"\0 "),148),n}function We(t){return(oe-t%oe)%oe}function ia(t,e){return dt(Ge(Bt,e.length),e,new Uint8Array(We(e.length)),Ge(ut,t.length),t,new Uint8Array(We(t.length)),new Uint8Array(oe*2))}function ha(t){let e=[],n=0;for(;n+oe<=t.length;){let r=t.subarray(n,n+oe);if(r.every(f=>f===0)){let f=t.subarray(n);return f.length!==oe*2||!f.every(u=>u===0)?null:e}let o=r.indexOf(0,0),i=new TextDecoder().decode(r.subarray(0,o<0||o>100?100:o)),s=new TextDecoder().decode(r.subarray(124,135));if(!/^[0-7]{11}$/.test(s))return null;let a=parseInt(s,8);if(n+oe+a>t.length)return null;let c=t.subarray(n+oe,n+oe+a);e.push({name:i,data:c,headerBytes:r}),n+=oe+a+We(a)}return null}var Pu={id:"trailer/1",form:"A",byteExact:!0,build({original:t,commitment:e}){if(t===void 0)throw new TypeError("trailer/1 requires the original bytes");if(e.length!==32)throw new TypeError("commitment must be 32 bytes");return dt(t,pe(Qn),new Uint8Array(8),e)},locate(t){if(t.length<er)return null;let e=t.subarray(t.length-er);return!Ee(e.subarray(0,8),pe(Qn))||!e.subarray(8,16).every(n=>n===0)?null:{commitment:new Uint8Array(e.subarray(16,48)),originalBytes:t.subarray(0,t.length-er)}},frame({commitment:t}){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");return{prefix:new Uint8Array(0),suffix:dt(pe(Qn),new Uint8Array(8),t)}},scanPrefix(){return new Uint8Array(0)}},Mu={id:"container/1",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/1 requires the original bytes");let r=e??U(t);return ia(t,vt(n,r))},locate(t){let e=ha(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==Bt||r.name!==ut)return null;let o=nr(n.data);if(o===null||o.originDigest===void 0)return null;let i=ia(r.data,n.data);return Ee(i,t)?{commitment:o.commitment,originDigest:o.originDigest,originalBytes:r.data}:null},frame({originalSize:t,originDigest:e,commitment:n}){let r=vt(n,e);return{prefix:dt(Ge(Bt,r.length),r,new Uint8Array(We(r.length)),Ge(ut,t)),suffix:dt(new Uint8Array(We(t)),new Uint8Array(oe*2))}},scanPrefix(){return null}};function sa(t,e){return dt(Ge(ut,t.length),t,new Uint8Array(We(t.length)),Ge(Bt,e.length),e,new Uint8Array(We(e.length)),new Uint8Array(oe*2))}var Du={id:"container/2",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/2 requires the original bytes");let r=e??U(t);return sa(t,vt(n,r))},locate(t){let e=ha(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==ut||r.name!==Bt)return null;let o=nr(r.data);if(o===null||o.originDigest===void 0)return null;let i=sa(n.data,r.data);return Ee(i,t)?{commitment:o.commitment,originDigest:o.originDigest,originalBytes:n.data}:null},frame({originalSize:t,originDigest:e,commitment:n}){let r=vt(n,e);return{prefix:Ge(ut,t),suffix:dt(new Uint8Array(We(t)),Ge(Bt,r.length),r,new Uint8Array(We(r.length)),new Uint8Array(oe*2))}},scanPrefix(t){return Ge(ut,t)}},Nu={id:"produced/1",form:"C",byteExact:!1,build({original:t,originDigest:e,commitment:n}){if(t!==void 0)throw new TypeError("produced/1 takes no original; pass originDigest for a source reference");return vt(n,e)},locate(t){let e=nr(t);return e===null?null:e.originDigest!==void 0?{commitment:e.commitment,originDigest:e.originDigest}:{commitment:e.commitment}}},Gt=Object.freeze([Pu,Mu,Du,Nu]),At="set/1";var la=/^[a-z0-9][a-z0-9-]*\/[1-9][0-9]*$/;function pa(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e.length===0)throw new TypeError("a set lists at least one member");let n=[],r=new Set;for(let i of e){if(i.artifact.length!==32)throw new TypeError("member artifact digest must be 32 bytes");if(i.origin.length!==32)throw new TypeError("member origin digest must be 32 bytes");if(!la.test(i.placement))throw new TypeError(`member placement "${i.placement}" is not a placement id`);if(i.placement===At||i.placement===It)throw new TypeError("a set cannot list a set as a member");let s=we(i.artifact);if(r.has(s))throw new TypeError(`duplicate member artifact digest ${s}`);r.add(s),n.push({artifact:{algorithm:"sha256",digest:s},origin:{algorithm:"sha256",digest:we(i.origin)},placement:i.placement})}n.sort((i,s)=>i.artifact.digest<s.artifact.digest?-1:1);let o={members:n,placement:At,slotCommitment:{algorithm:"sha256",digest:we(t)},type:xe};return le(o)}function wo(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!ze(n)||Object.keys(n).sort().join(",")!=="members,placement,slotCommitment,type"||n.type!==xe||n.placement!==At)return null;let r=qe(n.slotCommitment);if(r===null)return null;let o=n.members;if(!Array.isArray(o)||o.length===0)return null;let i=[];for(let a of o){if(!ze(a)||Object.keys(a).sort().join(",")!=="artifact,origin,placement")return null;let c=qe(a.artifact),f=qe(a.origin),u=a.placement;if(c===null||f===null||typeof u!="string"||!la.test(u)||u===At||u===It)return null;i.push({artifact:c,origin:f,placement:u})}let s;try{s=pa(r,i)}catch{return null}return Ee(s,t)?{commitment:r,members:i}:null}var Lu={id:At,form:"C",byteExact:!1,build(){throw new TypeError("set/1 is built with buildSetManifest(commitment, members)")},locate(t){let e=wo(t);return e===null?null:{commitment:e.commitment}}},It="set/2",ma=`${xe}/member`,tr=1e6;function ga(t,e,n){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(n.length!==32)throw new TypeError("root must be 32 bytes");if(!Number.isInteger(e)||e<1||e>tr)throw new TypeError(`count must be an integer from 1 to ${tr}`);let r={count:e,placement:It,root:{algorithm:"sha256",digest:we(n)},slotCommitment:{algorithm:"sha256",digest:we(t)},type:xe};return le(r)}function xo(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!ze(n)||Object.keys(n).sort().join(",")!=="count,placement,root,slotCommitment,type"||n.type!==xe||n.placement!==It)return null;let r=n.count;if(typeof r!="number"||!Number.isInteger(r)||r<1||r>tr)return null;let o=qe(n.slotCommitment),i=qe(n.root);if(o===null||i===null)return null;let s;try{s=ga(o,r,i)}catch{return null}return Ee(s,t)?{commitment:o,count:r,root:i}:null}var Ou={id:It,form:"C",byteExact:!1,build(){throw new TypeError("set/2 is built with buildSetRoot(commitment, count, root)")},locate(t){let e=xo(t);return e===null?null:{commitment:e.commitment}}};function dn(t){return[...Gt,Lu,Ou].find(e=>e.id===t)}function kt(t){let e=t.attribution;if(e===void 0||e.name!==ca)return null;let n=typeof e.title=="string"&&e.title.length>0,r={placement:n?e.title:null,placementSource:n?"attribution":null,source:"attribution"};if(typeof e.message=="string"&&e.message.length>0){let o=qt(e.message);o!==null&&o.length===32&&(r.originDigest=o,r.originSource="attribution")}return r}function Eo(t,e){if(t===null)return e;if(e===null)return t;let n={...t};return n.placement===null&&e.placement!==null&&(n.placement=e.placement,n.placementSource="manifest"),n.originDigest===void 0&&e.originDigest!==void 0&&(n.originDigest=e.originDigest,n.originSource="manifest"),n}function Bo(t){let e=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return null}})():t;if(!ze(e)||e.type!==xe)return null;let n=e.manifest;if(!ze(n)||n.placement!==void 0&&typeof n.placement!="string"||qe(n.artifact)===null||n.origin!==void 0&&qe(n.origin)===null||n.fusedFile!==null&&typeof n.fusedFile!="string")return null;let o=e.proof;if(!ze(o)||o.version!=="bitgraph/1")return null;let i={type:xe,manifest:{placement:typeof n.placement=="string"?n.placement:"",...n.origin!==void 0?{origin:n.origin}:{},artifact:n.artifact,fusedFile:n.fusedFile},proof:o};if(e.fusePayload!==void 0){if(!ze(e.fusePayload))return null;i.fusePayload=e.fusePayload}return i}function vo(t){let e=t.manifest.placement.length>0,n={placement:e?t.manifest.placement:null,placementSource:e?"manifest":null,source:"manifest"};if(t.manifest.origin!==void 0){let r=yo(t.manifest.origin.digest);r!==null&&r.length===32&&(n.originDigest=r,n.originSource="manifest")}return n}y();function ba(t){let e=t.commit;if(typeof e.counter!="string"||typeof e.slotCounter!="string"||typeof e.epochId!="string")return null;let n;try{n=(BigInt(e.counter)-BigInt(e.slotCounter)).toString()}catch{return null}return{slotCounter:e.slotCounter,commitCounter:e.counter,epochId:e.epochId,chainId:typeof e.chainId=="string"?e.chainId:null,positions:n}}function ya(t){return`The exact fused bytes could not feasibly have been finalized before their signed slot allocation at position ${t.slotCounter}, and were committed no later than position ${t.commitCounter}.`}function Ao(t,e,n){if(e===null)return[];let r=[];return t==="FUSED_FROM_ORIGIN"?r.push(`The supplied original rebuilds the committed fused artifact byte for byte, so these exact original bytes existed no later than commit position ${e.commitCounter}.`):t==="FUSED_DIRECT"&&n&&r.push("The fused bytes carry an origin digest that matches the signed marker; the original itself was not supplied and was not checked."),(t==="FUSED_DIRECT"||t==="FUSED_FROM_ORIGIN")&&r.push(ya(e)),t==="RECORDED"&&r.push(`These exact bytes existed no later than commit position ${e.commitCounter}.`),r}async function Io(t){let{proof:e,bytes:n}=t,r=t.frame===void 0||t.frame===null?null:Bo(t.frame)??null,o=U(n),i=Ze(o),s=e?.artifact?.digestB64??"",a=(w,b,k)=>({category:w,proof:b.proof??{valid:!0},marker:b.marker??null,placement:b.placement??null,fileDigestB64:i,artifactDigestB64:s,originDigestB64:b.originDigestB64??null,slotCommitmentB64:b.slotCommitmentB64??null,span:b.span??null,policy:b.policy??{spanExceeded:!1,maxPositions:null},statements:b.statements??[],reason:k}),c=await ft(t.trustAnchors!==void 0?{proof:e,trustAnchors:t.trustAnchors}:{proof:e});if(!c.valid){let w=c.reason??"proof failed verification";return a("INVALID_UNDERLYING_PROOF",{proof:{valid:!1,reason:w}},w)}let f=Eo(kt(e),r!==null?vo(r):null),u=f?.originDigest,d=u!==void 0?Ze(u):null,h=ba(e),l=t.maxPositions===void 0?null:BigInt(t.maxPositions),m={spanExceeded:l!==null&&h!==null&&BigInt(h.positions)>l,maxPositions:l===null?null:l.toString()},p={proof:{valid:!0},marker:f,originDigestB64:d,span:h,policy:m};if(i===s){if(f===null)return a("RECORDED",{...p,statements:Ao("RECORDED",h,!1)},null);let w=e.slotAllocation;if(w===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so no commitment can be recomputed");let b;try{b=un(w)}catch(S){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${S instanceof Error?S.message:String(S)}`)}let k=Ze(b),v=f.placement===null?void 0:dn(f.placement),O=v===void 0?null:v.locate(n);if(f.placement===null){for(let S of Gt){let _=S.locate(n);if(_!==null){v=S,O=_;break}}if(v===void 0)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k},"no registered placement finds a commitment in the fused bytes")}else if(v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:k},`placement "${f.placement}" is not registered; the commitment cannot be located`);if(O===null)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k,placement:v.id},`no ${v.id} commitment found in the fused bytes`);if(!Ee(O.commitment,b))return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k,placement:v.id},"the commitment in the fused bytes does not match the proof's slot record");let z=!1;if(u!==void 0){let S=O.originDigest??(O.originalBytes!==void 0?U(O.originalBytes):void 0);if(S!==void 0){if(!Ee(S,u))return a("INVALID_ORIGIN_ATTRIBUTION",{...p,slotCommitmentB64:k,placement:v.id},f.originSource==="attribution"?"the origin digest in the signed attribution does not match the origin inside the fused bytes":"the origin digest in the manifest does not match the origin inside the fused bytes");z=!0}}return a("FUSED_DIRECT",{...p,slotCommitmentB64:k,placement:v.id,statements:Ao("FUSED_DIRECT",h,z)},null)}if(u!==void 0&&Ee(o,u)){let w=e.slotAllocation;if(w===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so the fused bytes cannot be rebuilt");let b;try{b=un(w)}catch(S){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${S instanceof Error?S.message:String(S)}`)}let k=Ze(b),v=f!==null&&f.placement!==null?dn(f.placement):void 0;if(f!==null&&f.placement!==null&&v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:k},`placement "${f.placement}" is not registered; the fused bytes cannot be rebuilt`);let O=v!==void 0?[v]:Gt.filter(S=>S.byteExact),z=e.artifact.digestB64;for(let S of O){if(!S.byteExact)continue;let _;try{_=S.build({original:n,originDigest:u,commitment:b})}catch{continue}if(Ze(U(_))===z)return a("FUSED_FROM_ORIGIN",{...p,slotCommitmentB64:k,placement:S.id,statements:Ao("FUSED_FROM_ORIGIN",h,!0)},null)}return a("RECONSTRUCTION_MISMATCH",{...p,slotCommitmentB64:k,placement:v?.id??null},v!==void 0?`rebuilding ${v.id} from this file and the proof's slot record does not reproduce the committed artifact digest`:"no registered byte-exact placement rebuilds the committed artifact digest from this file")}return a("NO_MATCH",p,"this file matches neither the committed artifact digest nor the origin digest; the proof proves nothing about it")}y();y();async function*xa(t,e){let n=new So(t,e?.maxTotalBytes),r=e?.maxEntryCount??Number.POSITIVE_INFINITY,o=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(u,d)=>{if(u>o)throw new Error(`tar: ${d} metadata entry of ${u} bytes exceeds the ${o}-byte cap`)};for(;;){let u=await n.readExact(512);if(u===null||qu(u))return;if(++c>r)throw new Error(`tar: archive exceeds the maximum of ${r} entries`);let d=Vu(u),h=d.typeflag;if(h==="x"||h==="g"){f(d.size,"PAX");let v=await wa(n,d.size);await n.skip(rr(d.size));let O=Gu(v);h==="x"?i=O:s=Wu(s,O);continue}if(h==="L"){f(d.size,"GNU long-name");let v=await wa(n,d.size);await n.skip(rr(d.size)),a=St(Zu(v));continue}if(h==="K"){await n.skip(d.size+rr(d.size));continue}let l=d.name;s!==null&&s.has("path")&&(l=s.get("path")),a!==null&&(l=a),i!==null&&i.has("path")&&(l=i.get("path"));let m=d.size,p=i?.get("size")??s?.get("size");if(p!==void 0){let v=Number(p);if(!Number.isSafeInteger(v)||v<0)throw new Error("tar: invalid PAX size value");m=v}i=null,a=null;let w=h==="0"||h==="\0",b={remaining:m},k=Ku(n,b);yield{path:l,size:m,kind:w?"file":"other",typeflag:h,body:k},b.remaining>0&&(await n.skip(b.remaining),b.remaining=0),await n.skip(rr(m))}}async function*Ku(t,e){for(;e.remaining>0;){let n=await t.readSome(e.remaining);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");e.remaining-=n.length,yield n}}async function wa(t,e){if(e===0)return new Uint8Array(0);let n=await t.readExact(e);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream)");return n}function Vu(t){zu(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),r=St(ko(t,0,100));if(St(ko(t,257,6))==="ustar"){let s=St(ko(t,345,155));s.length>0&&(r=`${s}/${r}`)}let i=Ea(t.subarray(124,136));return{name:r,size:i,typeflag:n}}function ko(t,e,n){let r=t.subarray(e,e+n),o=r.indexOf(0);return o===-1&&(o=r.length),r.subarray(0,o)}function Ea(t){if(t.length>0&&(t[0]&128)!==0){let r=0n;for(let o=0;o<t.length;o++){let i=o===0?t[0]&127:t[o];r=r<<8n|BigInt(i)}if(r>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("tar: numeric field exceeds the supported range");return Number(r)}let e=St(t).trim().replace(/\0+$/,"").trim();if(e.length===0)return 0;let n=Number.parseInt(e,8);if(!Number.isSafeInteger(n)||n<0)throw new Error(`tar: invalid octal numeric field: "${e}"`);return n}function zu(t){let e=Ea(t.subarray(148,156)),n=0;for(let r=0;r<512;r++)n+=r>=148&&r<156?32:t[r];if(n!==e)throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)")}function qu(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function Gu(t){let e=new Map,n=0;for(;n<t.length;){let r=n;for(;r<t.length&&t[r]!==32;)r++;if(r>=t.length)throw new Error("tar: malformed PAX record (no length delimiter)");let o=Number(St(t.subarray(n,r)));if(!Number.isInteger(o)||o<=0||n+o>t.length)throw new Error("tar: malformed PAX record (bad length)");let i=t.subarray(r+1,n+o);if(i.length===0||i[i.length-1]!==10)throw new Error("tar: malformed PAX record (missing newline)");let s=St(i.subarray(0,i.length-1)),a=s.indexOf("=");if(a===-1)throw new Error("tar: malformed PAX record (missing '=')");e.set(s.slice(0,a),s.slice(a+1)),n+=o}return e}function Wu(t,e){let n=new Map(t??[]);for(let[r,o]of e)n.set(r,o);return n}function St(t){return new TextDecoder("utf-8").decode(t)}function Zu(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var So=class{iter;chunks=[];head=0;available=0;ended=!1;totalPulled=0;maxTotalBytes;constructor(e,n){this.iter=e[Symbol.asyncIterator](),this.maxTotalBytes=n??Number.POSITIVE_INFINITY}async fill(){if(this.ended)return!1;let e=await this.iter.next();if(e.done===!0)return this.ended=!0,!1;let n=e.value;if(n.length>0){if(this.totalPulled+=n.length,this.totalPulled>this.maxTotalBytes)throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);this.chunks.push(n),this.available+=n.length}return!0}async readExact(e){for(;this.available<e;)if(!await this.fill()){if(this.available===0)return null;throw new Error("tar: truncated archive (unexpected end of stream)")}return this.take(e)}async readSome(e){for(;this.available===0;)if(!await this.fill())return null;let n=this.chunks[0],r=Math.min(e,n.length-this.head),o=n.subarray(this.head,this.head+r);return this.advance(r,n),o}async skip(e){let n=e;for(;n>0;){let r=await this.readSome(n);if(r===null)throw new Error("tar: truncated archive (unexpected end of stream)");n-=r.length}}take(e){let n=new Uint8Array(e),r=0;for(;r<e;){let o=this.chunks[0],i=Math.min(e-r,o.length-this.head);n.set(o.subarray(this.head,this.head+i),r),r+=i,this.advance(i,o)}return n}advance(e,n){this.head+=e,this.available-=e,this.head===n.length&&(this.chunks.shift(),this.head=0)}};function rr(t){return(512-t%512)%512}y();var Nm=new Uint8Array([0]);function Ba(t){let e=Array.from(t,r=>({pathBytes:Yu(r.path),entryDigest:r.entryDigest}));e.sort((r,o)=>Xu(r.pathBytes,o.pathBytes));let n=U.create();for(let r of e)n.update(r.entryDigest);return B.Buffer.from(n.digest()).toString("base64")}function Yu(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Xu(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let o=t[r]-e[r];if(o!==0)return o}return t.length-e.length}var va=8*1024*1024,Sa={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},Aa=new Uint8Array([0]),Ia="manifest.json",To="bitgraph-bundle/1",Ju="bitgraph-anchor-witness/1";var Ta=new WeakMap;async function Ho(t,e){let n=[],r=0,o=0,i=[],s=new Map,a=Array.from(t).sort((f,u)=>f.path<u.path?-1:f.path>u.path?1:0);for(let f of a){o++;let u=Ra(f.path);if(u.unsafe){r++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${u.reason}`});continue}let d=await nd(u.path,void 0,void 0,Ha(f.open()));i.push(rd(u.path,d)),s.set(u.path,f)}let c=ed({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:o,skippedUnsafePaths:r});return Ta.set(c,s),c}async function*Ha(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function Qu(t){let e=[],n=0;for await(let r of Ha(t.open()))e.push(r),n+=r.length;return $o(e,n)}function ed(t){let{bundlePath:e,container:n,scanned:r,strippedRootPrefix:o,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let S of r){let _=S.rawPath,F=S.entryDigestFull;o!==void 0&&(_=S.rawPath.slice(o.length+1),F=S.entryDigestStripped),c.has(_)&&i.push({code:"duplicate-path",path:_,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(_,{path:_,sha256Hex:S.sha256Hex,byteLength:S.byteLength,entryDigest:F,...S.json!==void 0?{json:S.json}:{}})}let f=Array.from(c.values()),u=Ba(f.filter(S=>S.path!==Ia).map(S=>({path:S.path,entryDigest:S.entryDigest}))),d=[],h=new Map,l=[],m=[],p=new Map,w,b=0,k=0,v=0;for(let S of f){if(S.path===Ia){w=fd(S,u,i);continue}let F=id(S.json)??S.json;if(F!==void 0&&$a(F)){let G=F.version;if(G==="bitgraph/1"){b++;let q=sd(S,F,h,d,i);q==="exact-duplicate"&&k++,q==="semantic-duplicate"&&v++;continue}l.push({code:"unsupported-version",path:S.path,version:G,fileSha256Hex:S.sha256Hex}),i.push({code:"unsupported-version",path:S.path,message:`proof-shaped file rejected: version "${G}" is not "bitgraph/1"`,details:{version:G}}),ka(S,p);continue}if(F!==void 0&&F.version===Ju){m.push({path:S.path,fileSha256Hex:S.sha256Hex,witness:F});continue}ka(S,p)}for(let S of d){let _=cd(S.proof.artifact);if(_===null)continue;let F=p.get(_);F!==void 0&&F.matchedProofHashes.push(S.proofHash)}let O=Array.from(p.values()),z={observed:d.length,proofFiles:b,exactDuplicates:k,semanticDuplicates:v,unsupportedVersion:l.length,artifacts:O.length,witnesses:m.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...o!==void 0?{strippedRootPrefix:o}:{},entriesScanned:s,proofs:d,unsupportedVersions:l,artifacts:O,witnesses:m,...w!==void 0?{manifest:w}:{},computedContentsHashB64:u,findings:i,counts:z}}async function*Co(t){yield*Ca(t,t.artifacts.filter(e=>e.matchedProofHashes.length>0))}async function*Ro(t,e){let n=new Set(e);n.size!==0&&(yield*Ca(t,t.artifacts.filter(r=>n.has(r.sha256Hex))))}async function*Ca(t,e){if(e.length===0)return;if(t.container==="memory"){let s=Ta.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let f=s.get(c);if(f===void 0)continue;let u;try{u=await Qu(f)}catch{continue}if(or(U(u))===a.sha256Hex){yield{sha256Hex:a.sha256Hex,path:c,bytes:u};break}}return}if(t.container==="directory"){for(let s of e)for(let a of s.paths){let c;try{c=new Uint8Array(await cs(fs(t.bundlePath,...a.split("/"))))}catch{continue}if(or(U(c))===s.sha256Hex){yield{sha256Hex:s.sha256Hex,path:a,bytes:c};break}}return}let n=new Map;for(let s of e)for(let a of s.paths)n.set(a,s);let r=new Set,{stream:o,close:i}=td(t.bundlePath,t.container);try{for await(let s of xa(o,Sa)){if(r.size===e.length)break;if(s.kind!=="file")continue;let a=Ra(s.path);if(a.unsafe)continue;let c=a.path;if(t.strippedRootPrefix!==void 0){if(!c.startsWith(`${t.strippedRootPrefix}/`))continue;c=c.slice(t.strippedRootPrefix.length+1)}let f=n.get(c);if(f===void 0||r.has(f.sha256Hex))continue;let u=[],d=0;for await(let l of s.body)u.push(l.slice()),d+=l.length;let h=$o(u,d);or(U(h))===f.sha256Hex&&(r.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:h})}}finally{i()}}function td(t,e){let n=as(t);if(e==="tar-gz"){let r=us();return n.pipe(r),n.on("error",o=>r.destroy(o)),{stream:r,close:()=>{r.destroy(),n.destroy()}}}return{stream:n,close:()=>n.destroy()}}async function nd(t,e,n,r){let o=new TextEncoder,i=U.create(),s=U.create();s.update(o.encode(t)),s.update(Aa);let a=e===void 0?void 0:U.create();a!==void 0&&(a.update(o.encode(e)),a.update(Aa));let c=n===void 0||n<=va,f=[],u=0;for await(let d of r)i.update(d),s.update(d),a?.update(d),u+=d.length,c&&(u>va?(f.length=0,c=!1):f.push(d.slice()));return{sha256Hex:or(i.digest()),byteLength:u,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:$o(f,u)}:{}}}function rd(t,e){let n=e.buffered===void 0?void 0:od(e.buffered);return{rawPath:t,sha256Hex:e.sha256Hex,byteLength:e.byteLength,entryDigestFull:e.entryDigestFull,...e.entryDigestStripped!==void 0?{entryDigestStripped:e.entryDigestStripped}:{},...n!==void 0?{json:n}:{}}}function od(t){let e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let n;try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}let r;try{r=JSON.parse(n)}catch{return}if(!(r===null||typeof r!="object"||Array.isArray(r)))return r}function Ra(t){if(t.includes("\0"))return{path:t,unsafe:!0,reason:"path contains a NUL byte"};let e=t.startsWith("/"),n=t.split("/").filter(o=>o!==""&&o!=="."),r=n.join("/");return e?{path:r,unsafe:!0,reason:"absolute path"}:n.some(o=>o==="..")?{path:r,unsafe:!0,reason:"path escapes the bundle root"}:r===""?{path:r,unsafe:!0,reason:"empty path"}:{path:r,unsafe:!1}}function ie(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function id(t){if(!ie(t)||t.type!=="bitgraph-fuse/1")return;let e=t.proof;return $a(e)?e:void 0}function $a(t){return ie(t)?typeof t.version=="string"&&ie(t.artifact)&&ie(t.commit)&&ie(t.signer):!1}function sd(t,e,n,r,o){let i=Jn(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=ad(e,i);a==="mismatch"&&o.push({code:"proofhash-mismatch",path:t.path,message:"embedded proofHash does not match the computed canonical proof hash",details:{embedded:e.proofHash,computed:i}});let c=n.get(i);if(c!==void 0){let w=c.sources.some(b=>b.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),o.push({code:w?"exact-duplicate":"semantic-duplicate",path:t.path,message:w?"byte-identical copy of an already observed proof":"different byte encoding of an already observed proof (same canonical identity)",details:{proofHash:i,firstObservedAt:c.sources[0].path}}),w?"exact-duplicate":"semantic-duplicate"}let f=ie(e.commit)?e.commit:{},u=ie(e.signer)?e.signer:{},d=ie(e.environment)?e.environment:{},h=me(f.counter),l=me(f.epochId),m=me(f.chainId),p={proofHash:i,chainHash:mo(e),proof:e,sources:[s],version:"bitgraph/1",...h!==void 0?{counter:h}:{},...me(f.slotCounter)!==void 0?{slotCounter:me(f.slotCounter)}:{},...me(f.prevB64)!==void 0?{prevB64:me(f.prevB64)}:{},...l!==void 0?{epochId:l}:{},chainId:m!==void 0&&m.length>0?m:"global",...me(u.publicKeyB64)!==void 0?{publicKeyB64:me(u.publicKeyB64)}:{},...me(d.measurement)!==void 0?{measurement:me(d.measurement)}:{},...me(d.enforcement)!==void 0?{enforcement:me(d.enforcement)}:{},hasSlotAllocation:ie(e.slotAllocation),hasAttestation:ie(d.attestation),hasAgency:ie(e.agency),hasEpochLink:ie(f.epochLink),embeddedProofHash:a,chainless:h===void 0&&l===void 0};return n.set(i,p),r.push(p),"new"}function ad(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function me(t){return typeof t=="string"?t:void 0}function ka(t,e){let n=e.get(t.sha256Hex);if(n!==void 0){n.paths.push(t.path);return}e.set(t.sha256Hex,{sha256Hex:t.sha256Hex,sha256B64:B.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function cd(t){if(!ie(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function fd(t,e,n){if(t.json===void 0)return n.push({code:"manifest-unparseable",path:t.path,message:"root manifest.json did not parse as a single JSON object; proceeding as if no manifest were present"}),{path:t.path,parsed:!1,recognized:!1,problems:[]};let r=t.json,o=r.version;if(o!==To)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(o)} is not "${To}"; the manifest was not interpreted`,...typeof o=="string"?{details:{version:o}}:{}}),{path:t.path,parsed:!0,...typeof o=="string"?{version:o}:{},recognized:!1,problems:[]};let i=ud(r);for(let c of i)n.push({code:"manifest-field-invalid",path:t.path,message:c});let s={path:t.path,parsed:!0,version:To,recognized:!0,manifest:r,problems:i},a=r.contentsHashB64;if(typeof a=="string"&&a.length>0){let c=a===e;s.contentsHash={declaredB64:a,computedB64:e,match:c},c||n.push({code:"manifest-contents-hash-mismatch",path:t.path,message:"manifest contentsHashB64 does not match the computed contents hash; the bundle held is not byte-for-byte the bundle the manifest describes. Advisory: this does not fail any proof.",details:{declared:a,computed:e}})}return s}function ud(t){let e=[],n=r=>Array.isArray(r)&&r.every(o=>typeof o=="string");if(t.epochIds!==void 0&&!n(t.epochIds)&&e.push("manifest.epochIds must be an array of strings when present"),t.chainIds!==void 0&&!n(t.chainIds)&&e.push("manifest.chainIds must be an array of strings when present"),t.proofCount!==void 0&&(typeof t.proofCount!="number"||!Number.isInteger(t.proofCount)||t.proofCount<0)&&e.push("manifest.proofCount must be a non-negative integer when present"),t.counterRanges!==void 0&&(Array.isArray(t.counterRanges)&&t.counterRanges.every(o=>ie(o)&&typeof o.epochId=="string"&&typeof o.chainId=="string"&&typeof o.min=="string"&&typeof o.max=="string")||e.push("manifest.counterRanges must be an array of { epochId, chainId, min, max } string fields when present")),t.generatedAt!==void 0&&typeof t.generatedAt!="string"&&e.push("manifest.generatedAt must be a string when present"),t.contentsHashB64!==void 0){let r=t.contentsHashB64,o=typeof r=="string"&&r.length>0;if(o){let i=B.Buffer.from(r,"base64");o=i.toString("base64")===r&&i.length===32}o||e.push("manifest.contentsHashB64 must be standard base64 of 32 bytes when present")}return t.artifactsIncluded!==void 0&&typeof t.artifactsIncluded!="boolean"&&e.push("manifest.artifactsIncluded must be a boolean when present"),t.openEpochs!==void 0&&(Array.isArray(t.openEpochs)&&t.openEpochs.every(o=>ie(o)&&typeof o.epochId=="string"&&typeof o.counterAtSnapshot=="string")||e.push("manifest.openEpochs must be an array of { epochId, counterAtSnapshot } string fields when present")),e}function or(t){return B.Buffer.from(t).toString("hex")}function $o(t,e){let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}y();async function Po(t,e){Ve();let n=e?.trustAnchors,r=new Map(t.proofs.map(f=>[f.proofHash,f])),o=new Map;for(let f of t.artifacts){if(f.matchedProofHashes.length===0)continue;let u=f.matchedProofHashes.map(d=>r.get(d)).filter(d=>d!==void 0);o.set(f.sha256Hex,u)}for await(let f of Co(t)){let u=o.get(f.sha256Hex)??[];for(let d of u){if(d.verification!==void 0)continue;let h=await po({proof:d.proof,bytes:f.bytes,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"full",status:h.valid?"verified":"failed",...h.reason!==void 0?{reason:h.reason}:{},artifactPath:f.path};d.verification=l}}for(let f of t.proofs){if(f.verification!==void 0)continue;let u=await ft({proof:f.proof,...n!==void 0?{trustAnchors:n}:{}}),d={tier:"integrity",status:u.valid?"artifact-unavailable":"failed",...u.reason!==void 0?{reason:u.reason}:{}};f.verification=d}let i=0,s=0,a=0,c=0;for(let f of t.proofs){let u=f.verification?.status;u==="verified"?i++:u==="failed"?s++:u==="artifact-unavailable"&&a++,f.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}y();y();var Pa=new WeakMap;async function Ye(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=Pa.get(t);if(n!==void 0)return n;Ve();let r=!1;try{r=(await ft({proof:t.proof})).valid}catch{r=!1}return Ve(),Pa.set(t,r),r}function Y(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function Me(t,e){let n=Y(t.counter),r=Y(e.counter);return n!==void 0&&r!==void 0&&n!==r?n<r?-1:1:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:t.proofHash<e.proofHash?-1:t.proofHash>e.proofHash?1:0}function de(t,e,n){let r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}async function Do(t){let e=[],n=[],r=new Map;for(let f of t.proofs){if(f.chainless){e.push(f.proofHash);continue}if(f.publicKeyB64===void 0){n.push(f.proofHash);continue}let u={publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId},d=JSON.stringify([u.publicKeyB64,u.epochId??null,u.chainId]),h=r.get(d);h===void 0?r.set(d,{key:u,members:[f]}):h.members.push(f)}let o=[...r.values()].sort((f,u)=>dd(f.key,u.key)),i=[],s=new Set,a=new Map;for(let f of o){let u=hd(f.key,f.members,s);i.push(u);for(let d of u.memberProofHashes)a.set(d,f.key)}let c=await md(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function dd(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";return n!==r?n<r?-1:1:t.publicKeyB64!==e.publicKeyB64?t.publicKeyB64<e.publicKeyB64?-1:1:0}function hd(t,e,n){let r=new Map(e.map(h=>[h.chainHash,h])),o=new Map,i=new Set,s=new Map;for(let h of e)s.set(h.proofHash,h.proofHash);let a=h=>{let l=h;for(;s.get(l)!==l;)l=s.get(l);let m=h;for(;m!==l;){let p=s.get(m);s.set(m,l),m=p}return l},c=(h,l)=>{let m=a(h),p=a(l);m!==p&&s.set(m,p)};for(let h of e){if(h.prevB64===void 0)continue;let l=r.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||(i.add(h.proofHash),de(o,l.proofHash,h),n.add(l.proofHash),c(l.proofHash,h.proofHash))}let f=new Map;for(let h of e)de(f,a(h.proofHash),h);let u=[];for(let h of f.values())u.push(ld(h,o,i));u.sort(pd);let d=[...e].sort(Me).map(h=>h.proofHash);return{key:t,memberProofHashes:d,components:u}}function ld(t,e,n){let r=[...t].sort(Me),o=r.filter(h=>h.prevB64===void 0),i=r.filter(h=>h.prevB64!==void 0&&!n.has(h.proofHash)),s=r.filter(h=>(e.get(h.proofHash)??[]).length===0),a=new Set,c=[],f=h=>{let l=[h];for(;l.length>0;){let m=l.pop();if(a.has(m))continue;a.add(m),c.push(m);let p=[...e.get(m)??[]].sort(Me);for(let w=p.length-1;w>=0;w--)l.push(p[w].proofHash)}};for(let h of[...o,...i])f(h.proofHash);for(let h of r)a.has(h.proofHash)||f(h.proofHash);let u,d;for(let h of t)for(let l of[h.counter,h.slotCounter]){let m=Y(l);m!==void 0&&((u===void 0||m<u)&&(u=m),(d===void 0||m>d)&&(d=m))}return{memberProofHashes:c,genesisProofHashes:o.map(h=>h.proofHash),brokenLinkProofHashes:i.map(h=>h.proofHash),terminalProofHashes:s.map(h=>h.proofHash),hasCounterEvidence:u!==void 0,...u!==void 0&&d!==void 0?{positionRange:{min:String(u),max:String(d)}}:{}}}function pd(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}async function md(t,e,n,r){let o=new Map;for(let h of e){let l=h.key.epochId;if(l===void 0)continue;let m=o.get(l);m===void 0&&(m={chainIds:new Set,publicKeys:new Set,proofCount:0},o.set(l,m)),m.chainIds.add(h.key.chainId),m.publicKeys.add(h.key.publicKeyB64),m.proofCount+=h.memberProofHashes.length}let i=new Map(t.proofs.map(h=>[h.chainHash,h])),s=[];for(let h of t.proofs){if(!h.hasEpochLink)continue;let l=gd(h);l!==null&&s.push(await bd(l,h,i,o,n,r))}let a=wd(s),c=new Set,f=new Map,u=new Map;for(let h of s)h.hardEdge&&(c.add(h.fromEpochId),c.add(h.toEpochId),Mo(f,h.toEpochId,h.fromEpochId),Mo(u,h.fromEpochId,h.toEpochId));return{epochs:[...o.entries()].sort(([h],[l])=>h<l?-1:h>l?1:0).map(([h,l])=>({epochId:h,chainIds:[...l.chainIds].sort(),publicKeysB64:[...l.publicKeys].sort(),proofCount:l.proofCount,ordering:c.has(h)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...f.get(h)??[]].sort(),linkedSuccessorEpochIds:[...u.get(h)??[]].sort()})),edges:s,orderedPairs:a}}function gd(t){let e=t.proof.commit;if(e===null||typeof e!="object")return null;let n=e.epochLink;if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,o=["prevEpochId","prevPublicKeyB64","prevCounter","prevProofHashB64","toEpochId","toPublicKeyB64"],i={};for(let s of o){let a=r[s];if(typeof a!="string"||a.length===0)return null;i[s]=a}return i}async function bd(t,e,n,r,o,i){let s=await Ye(e),a=n.get(t.prevProofHashB64);if(a===void 0){let h=r.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:h?"terminal-missing":"dangling",viaProofValid:s,hardEdge:!1}}let c=[];a.epochId!==t.prevEpochId&&c.push(`the referenced proof's epochId (${a.epochId??"absent"}) does not match epochLink.prevEpochId (${t.prevEpochId})`),a.publicKeyB64!==t.prevPublicKeyB64&&c.push("the referenced proof's signer key does not match epochLink.prevPublicKeyB64"),yd(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await Ye(a),u=c.length===0,d=i.has(a.proofHash);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:"matched",predecessorProofHash:a.proofHash,metadataConsistent:u,...u?{}:{inconsistencies:c},...d?{referencedProofIsTerminal:!o.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:u&&s&&f}}function yd(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=Y(t),r=Y(e);return n!==void 0&&r!==void 0&&n===r}function wd(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(Mo(e,i.fromEpochId,i.toEpochId),n.add(i.fromEpochId),n.add(i.toEpochId));let r=new Set;for(let i of n){let s=new Set,a=[...e.get(i)??[]];for(;a.length>0;){let c=a.pop();if(!s.has(c)){s.add(c);for(let f of e.get(c)??[])a.push(f)}}for(let c of s)c!==i&&r.add(`${i}\0${c}`)}let o=[];for(let i of r){let[s,a]=i.split("\0");r.has(`${a}\0${s}`)||o.push({beforeEpochId:s,afterEpochId:a})}return o.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),o}function Mo(t,e,n){let r=t.get(e);r===void 0?t.set(e,new Set([n])):r.add(n)}y();var xd=1e4;async function No(t,e){let n=[],r=[],o=[],i=new Map(t.proofs.map(c=>[c.proofHash,c])),s=new Map(t.proofs.map(c=>[c.chainHash,c])),a=new Map;for(let c of e.partitions)for(let f of c.memberProofHashes)a.set(f,c.key);for(let c of e.partitions){let f=c.memberProofHashes.map(u=>i.get(u));Ed(c,f,n),await Ma(c,f,"counter",n,r),await Ma(c,f,"slot",n,r),await Bd(c,f,n,r),await vd(c,f,s,n,r),Ad(c,f,s,a,n,o),await kd(c,f,n,r),Sd(c,f,n)}return await Td(e.epochRelationships.edges,i,n,r),{anomalies:n,divergences:r,boundaryEntryPoints:o}}function Ed(t,e,n){let r=new Set;for(let d of e){let h=Y(d.counter);h!==void 0&&r.add(h);let l=Y(d.slotCounter);l!==void 0&&r.add(l)}if(r.size<2)return;let o=[...r].sort((d,h)=>d<h?-1:d>h?1:0),i=[],s=[],a=0n;for(let d=1;d<o.length;d++){let h=o[d-1]+1n,l=o[d]-1n;if(!(h>l)){i.push({start:String(h),end:String(l)}),a+=l-h+1n;for(let m=h;m<=l&&s.length<xd;m++)s.push(String(m))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},f=String(o[0]),u=String(o[o.length-1]);n.push({code:"unexplained-counter-positions",partition:t.key,proofHashes:[],message:`${a} counter position${a===1n?"":"s"} within the observed range [${f}, ${u}] of this partition ${a===1n?"is":"are"} neither a commit position nor a referenced slot position in the supplied bundle. Such ${a===1n?"a position":"positions"} may mean a proof is absent from the bundle, or a slot that was allocated but never committed (a routine, benign occurrence); this offline audit cannot distinguish the two. It does not, by itself, establish that the authority failed to create or withheld any proof.`,details:c})}async function Ma(t,e,n,r,o){let i=new Map;for(let s of e){let a=n==="counter"?s.counter:s.slotCounter;if(a===void 0)continue;let c=Y(a);de(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of Lo(i)){if(a.length<2)continue;let{parties:c,context:f}=await ir(a);if(c.length<2)continue;let u=s.startsWith("raw:")?s.slice(4):s,d=n==="counter"?"counter-collision":"slot-collision";r.push({code:d,partition:t.key,proofHashes:a.map(h=>h.proofHash),message:n==="counter"?`${c.length} distinct valid proofs claim commit counter ${u} in one partition. The audit does not choose between them; all parties are preserved for adjudication.`:`${c.length} distinct valid proofs reference slot counter ${u} in one partition. A slot position is consumed exactly once; all parties are preserved for adjudication.`,details:{position:u,validParties:c.map(h=>h.proofHash),invalidObserved:f.map(h=>h.proofHash)}}),o.push({kind:d,partition:t.key,contested:n==="counter"?{counter:u}:{slotCounter:u},parties:c.map(De),invalidContext:f.map(De),explanation:n==="counter"?`Two or more independently valid proof objects claim commit counter ${u} in the same signer, epoch, and chain partition. A commit counter position can be consumed only once, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them; every party and its predecessor relationship is preserved for adjudication.`:`Two or more independently valid proof objects reference slot counter ${u} in the same signer, epoch, and chain partition. A slot position is allocated once and consumed by one commit, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them.`})}}async function Bd(t,e,n,r){let o=new Map,i=new Map;for(let a of e){let c=Y(a.counter);c!==void 0&&de(o,String(c),a);let f=Y(a.slotCounter);f!==void 0&&de(i,String(f),a)}let s=[...o.keys()].filter(a=>i.has(a)).sort((a,c)=>BigInt(a)<BigInt(c)?-1:BigInt(a)>BigInt(c)?1:0);for(let a of s){let c=o.get(a),f=i.get(a),u=[];for(let b of c)await Ye(b)&&u.push(b);let d=[];for(let b of f)await Ye(b)&&d.push(b);if(!u.some(b=>d.some(k=>k.proofHash!==b.proofHash)))continue;let l=new Map;for(let b of[...u,...d])l.set(b.proofHash,b);let m=[...l.values()],p=new Map;for(let b of[...c,...f])p.set(b.proofHash,b);let w=[...p.values()].filter(b=>!l.has(b.proofHash));n.push({code:"cross-kind-position-reuse",partition:t.key,proofHashes:[...p.keys()],message:`Counter position ${a} is committed by one proof and reserved as a slot by a different proof in the same partition. A single causal position is consumed once, as a slot or as a commit, never both across distinct proofs. The audit does not choose between them; all parties are preserved for adjudication.`,details:{position:a,commitParties:u.map(b=>b.proofHash),slotParties:d.map(b=>b.proofHash),validParties:m.map(b=>b.proofHash),invalidObserved:w.map(b=>b.proofHash)}}),r.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:m.map(De),invalidContext:w.map(De),explanation:`Two or more independently valid proof objects allocate counter position ${a} in the same signer, epoch, and chain partition through different roles: at least one commits at it and at least one reserves it as a slot. Each position in a chain is consumed exactly once, so at most one of these allocations can belong to the authoritative sequence. This pattern only arises through enclave malfunction, replay, or compromise. The audit tool does not choose between them; every party is preserved for adjudication.`})}}async function vd(t,e,n,r,o){let i=new Map;for(let s of e)s.prevB64!==void 0&&de(i,s.prevB64,s);for(let[s,a]of Lo(i)){if(a.length<2)continue;let{parties:c,context:f}=await ir(a);if(c.length<2)continue;let u=n.has(s);r.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(d=>d.proofHash),message:`${c.length} distinct valid proofs claim the same predecessor hash: a detectable fork. All branches are preserved; the audit does not choose between them.`,details:{prevB64:s,predecessorObserved:u,validParties:c.map(d=>d.proofHash),invalidObserved:f.map(d=>d.proofHash)}}),o.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map(De),invalidContext:f.map(De),explanation:`Two or more independently valid proof objects name the same predecessor proof in their prevB64 hash link. Each proof has exactly one successor in an intact chain, so this is a fork: the history diverges into multiple branches at that predecessor${u?", which is itself observed in the bundle":", which is absent from the bundle"}. All branches are shown; the audit tool does not select one.`})}}function Ad(t,e,n,r,o,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let f=Y(c.counter);f!==void 0&&(a===void 0||f<a)&&(a=f)}for(let c of[...e].sort(Me)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!Id(c.prevB64)){o.push({code:"chain-break-malformed",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 is not standard base64 of 32 bytes, so it can never match a canonical proof hash. The predecessor link is unusable as reconstruction evidence.",details:{prevB64:c.prevB64}});continue}let f=n.get(c.prevB64);if(f!==void 0){let h=r.get(f.proofHash);o.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,f.proofHash],message:"commit.prevB64 resolves to an observed proof outside this proof's own signer, epoch, and chain partition. prevB64 never bridges partitions (each epoch and chain keeps its own hash chain), so this link does not join the two.",details:{prevB64:c.prevB64,predecessorProofHash:f.proofHash,predecessorPartition:h!==void 0?{publicKeyB64:h.publicKeyB64,...h.epochId!==void 0?{epochId:h.epochId}:{},chainId:h.chainId}:"unchained-or-unpartitioned"}});continue}let u=Y(c.counter);if(u===void 0||a===void 0||u<=a){i.push({partition:t.key,proofHash:c.proofHash,prevB64:c.prevB64});continue}o.push({code:"chain-break-missing",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 references a predecessor proof that is absent from the supplied bundle, and a lower-positioned proof IS present, so this is an interior break (a hole), not the excerpt's starting boundary. The chain cannot be reconstructed across this link from the supplied evidence; this does not, by itself, establish that the predecessor never existed.",details:{prevB64:c.prevB64}})}}function Id(t){if(t.length===0)return!1;let e=B.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function kd(t,e,n,r){let o=[...e.filter(a=>a.prevB64===void 0)].sort(Me);if(o.length<2)return;let{parties:i,context:s}=await ir(o);n.push({code:"multiple-genesis",partition:t.key,proofHashes:o.map(a=>a.proofHash),message:`${o.length} proofs in one partition carry no prevB64 link. An epoch has exactly one first proof, so at most one of these can be the genesis of this partition's chain.`,details:{validParties:i.map(a=>a.proofHash),invalidObserved:s.map(a=>a.proofHash)}}),!(i.length<2)&&r.push({kind:"multiple-genesis",partition:t.key,contested:{...t.key.epochId!==void 0?{epochId:t.key.epochId}:{},chainId:t.key.chainId},parties:i.map(De),invalidContext:s.map(De),explanation:"Two or more independently valid proof objects in the same signer, epoch, and chain partition carry no predecessor link, each presenting itself as the first proof of the chain. An epoch has exactly one first proof, so at most one of these can be the genesis. The audit tool does not choose between them."})}function Sd(t,e,n){for(let r of[...e].sort(Me)){let o=Y(r.slotCounter),i=Y(r.counter);o===void 0||i===void 0||o<i||n.push({code:"slot-order-violation",partition:t.key,proofHashes:[r.proofHash],message:"commit.slotCounter is not strictly less than commit.counter. The slot must be allocated before the commit that consumes it, so this proof's declared positions contradict the nonce-first construction order.",details:{slotCounter:r.slotCounter,counter:r.counter}})}}async function Td(t,e,n,r){for(let s of t)s.resolution==="terminal-missing"?n.push({code:"epochlink-terminal-missing",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch that is observed in the bundle, but the referenced terminal proof is absent from the bundle. The lineage claim cannot be confirmed from the supplied evidence; this does not, by itself, establish that the terminal never existed.",details:{link:{...s.link}}}):s.resolution==="dangling"?n.push({code:"epochlink-dangling",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch and terminal proof, neither of which is observed in the bundle. The lineage claim dangles into unobserved history; it cannot be confirmed from the supplied evidence.",details:{link:{...s.link}}}):s.metadataConsistent===!1&&n.push({code:"epochlink-mismatch",proofHashes:[s.viaProofHash,...s.predecessorProofHash!==void 0?[s.predecessorProofHash]:[]],message:"commit.epochLink's prevProofHashB64 matches an observed proof, but the link's declared epoch, signer key, or counter disagrees with that proof. The hash reference and the declared metadata cannot both be right.",details:{link:{...s.link},inconsistencies:s.inconsistencies??[]}});let o=new Map;for(let s of t)de(o,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of Lo(o)){let a=new Set(s.map(h=>h.link.toEpochId));if(a.size<2)continue;let c=s.map(h=>e.get(h.viaProofHash)),{parties:f,context:u}=await ir(c),d=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(h=>h.viaProofHash),message:`The same predecessor terminal (epoch ${d.prevEpochId}, counter ${d.prevCounter}) is consumed by genesis proofs of ${a.size} distinct successor epochs. A predecessor may be consumed by at most one successor epoch, so this is a detectable fork at the epoch boundary. All branches are preserved.`,details:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:f.map(h=>h.proofHash),invalidObserved:u.map(h=>h.proofHash)}}),!(f.length<2)&&r.push({kind:"epochlink-fork",contested:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64},parties:f.map(De),invalidContext:u.map(De),explanation:"Two or more independently valid epoch-genesis proofs consume the same terminal proof of a prior epoch through their epochLink. The single-successor rule allows a terminal to be consumed by exactly one successor epoch, so at most one of these lineages can be the authoritative continuation. Note that whichever party verified second in this run carries a fork-detection failure from the canonical verifier; that ordering is an artifact of verification order, not evidence of which branch is authoritative. The audit tool does not choose between them."})}let i=new Map;for(let s of t){if(s.resolution!=="matched")continue;let a=i.get(s.fromEpochId);a===void 0?i.set(s.fromEpochId,new Set([s.toEpochId])):a.add(s.toEpochId)}for(let s of Hd(i)){let a=t.filter(c=>c.resolution==="matched"&&s.includes(c.fromEpochId)&&s.includes(c.toEpochId)).map(c=>c.viaProofHash);n.push({code:"epochlink-cycle",proofHashes:a,message:`Epoch lineage links form a cycle among ${s.length} epochs. Each link claims its successor epoch came after its predecessor, so a cycle means these ordering claims contradict each other; no ordering is asserted for the epochs involved.`,details:{epochIds:s}})}}function Hd(t){let e=new Map,n=new Set,r=[...t.keys()].sort();for(let o of r){if(n.has(o))continue;let i=[],s=new Set,a=new Map,c=[o];for(;c.length>0;){let f=c[c.length-1];s.has(f)||(s.add(f),i.push(f),a.set(f,[...t.get(f)??[]].sort()));let d=a.get(f).shift();if(d===void 0){c.pop(),s.delete(f),i.pop(),n.add(f);continue}if(s.has(d)){let h=i.indexOf(d),l=i.slice(h),m=Cd(l);e.set(m.join("|"),m);continue}n.has(d)||c.push(d)}}return[...e.values()].sort((o,i)=>{let s=o.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function Cd(t){let e=0;for(let n=1;n<t.length;n++)t[n]<t[e]&&(e=n);return[...t.slice(e),...t.slice(0,e)]}async function ir(t){let e=[],n=[];for(let r of t)await Ye(r)?e.push(r):n.push(r);return{parties:e,context:n}}function De(t){let e=t.verification;return{proofHash:t.proofHash,sourcePaths:t.sources.map(n=>n.path),...e!==void 0?{verificationTier:e.tier,verificationStatus:e.status,...e.reason!==void 0?{verificationReason:e.reason}:{}}:{},...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.prevB64!==void 0?{prevB64:t.prevB64}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.measurement!==void 0?{measurement:t.measurement}:{}}}function Lo(t){return[...t.entries()].sort(([e],[n])=>{let r=/^[0-9]+$/.test(e)?BigInt(e):void 0,o=/^[0-9]+$/.test(n)?BigInt(n):void 0;return r!==void 0&&o!==void 0&&r!==o?r<o?-1:1:r!==void 0&&o===void 0?-1:r===void 0&&o!==void 0?1:e<n?-1:e>n?1:0})}y();function Oo(t){let e=new Map;for(let a of t.proofs){let c=JSON.stringify([a.measurement??null,a.publicKeyB64??null,a.epochId??null,a.chainId,a.hasAttestation]),f=e.get(c);if(f!==void 0){f.proofHashes.push(a.proofHash);continue}e.set(c,{...a.measurement!==void 0?{measurement:a.measurement}:{},...a.publicKeyB64!==void 0?{publicKeyB64:a.publicKeyB64}:{},...a.epochId!==void 0?{epochId:a.epochId}:{},chainId:a.chainId,attestationPresent:a.hasAttestation,proofHashes:[a.proofHash]})}let n=[...e.values()].sort(Rd),r=new Map;for(let a of t.proofs)a.epochId!==void 0&&de(r,a.epochId,a);let o=[];for(let[a,c]of[...r.entries()].sort(([f],[u])=>f<u?-1:f>u?1:0)){let f=new Set,u=new Set;for(let d of c)d.publicKeyB64!==void 0&&f.add(d.publicKeyB64),d.measurement!==void 0&&u.add(d.measurement);f.size>=2&&o.push({code:"mid-epoch-signer-change",proofHashes:c.map(d=>d.proofHash),message:`${f.size} distinct signer keys appear within epoch ${a}. A single enclave boot generates exactly one keypair per epoch, so multiple keys under one epochId cannot come from one healthy authority lifecycle. All key groups are preserved for adjudication.`,details:{epochId:a,publicKeysB64:[...f].sort()}}),u.size>=2&&o.push({code:"mid-epoch-measurement-change",proofHashes:c.map(d=>d.proofHash),message:`${u.size} distinct declared measurements appear within epoch ${a}. A single enclave boot has exactly one measurement, so multiple declared measurements under one epochId cannot come from one healthy authority lifecycle. Declared measurements are self-reported; attestation validation is reported separately.`,details:{epochId:a,measurements:[...u].sort()}})}let i=new Map;for(let a of t.proofs){if(a.publicKeyB64===void 0||a.epochId===void 0)continue;let c=i.get(a.publicKeyB64);c===void 0?i.set(a.publicKeyB64,new Set([a.epochId])):c.add(a.epochId)}let s=[...i.entries()].filter(([,a])=>a.size>=2).map(([a,c])=>({publicKeyB64:a,epochIds:[...c].sort()})).sort((a,c)=>a.publicKeyB64<c.publicKeyB64?-1:a.publicKeyB64>c.publicKeyB64?1:0);return{groups:n,anomalies:o,sharedSignersAcrossEpochs:s}}function Rd(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";if(n!==r)return n<r?-1:1;let o=t.publicKeyB64??"",i=e.publicKeyB64??"";if(o!==i)return o<i?-1:1;let s=t.measurement??"",a=e.measurement??"";return s!==a?s<a?-1:1:t.attestationPresent!==e.attestationPresent?t.attestationPresent?-1:1:0}y();var $d="Ethereum Anchor",Da="ethereum-anchor",Pd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function Uo(t){let e=[],n=[],r=[];for(let o of t.proofs){let i=Fo(o,"name"),s=Md(o);if(!(i===$d)){s===Da&&(n.push(o.proofHash),r.push({code:"anchor-metadata-only-claim",..._o(o),message:"unsigned metadata.type claims ethereum-anchor, but the signed attribution does not identify this proof as an anchor. Metadata is advisory and unsigned; the proof is not treated as an anchor.",details:{proofHash:o.proofHash}}));continue}let c=s===Da?"agrees":s===void 0?"absent":"disagrees";c==="disagrees"&&r.push({code:"anchor-metadata-disagreement",..._o(o),message:`signed attribution identifies an Ethereum anchor, but unsigned metadata.type is ${JSON.stringify(s)}. The signed field governs; the disagreement is recorded.`,details:{proofHash:o.proofHash,metadataType:s}});let f=Fo(o,"message"),u=Fo(o,"title"),d=u!==void 0?Pd.exec(u)?.[1]??void 0:void 0;d===void 0&&r.push({code:"anchor-title-unparseable",..._o(o),message:u===void 0?"anchor proof carries no signed attribution.title; the signed block number is absent":"anchor attribution.title does not parse as an Etherscan block URL; the signed block number is treated as absent",details:{proofHash:o.proofHash,...u!==void 0?{title:u}:{}}});let h=o.verification;e.push({proofHash:o.proofHash,...o.epochId!==void 0?{epochId:o.epochId}:{},chainId:o.chainId,...o.counter!==void 0?{counter:o.counter}:{},...o.slotCounter!==void 0?{slotCounter:o.slotCounter}:{},...f!==void 0?{blockHash:f}:{},...d!==void 0?{blockNumber:d}:{},metadataCorroboration:c,...h!==void 0?{verificationTier:h.tier,verificationStatus:h.status,...h.reason!==void 0?{verificationReason:h.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:r}}function Fo(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function Md(t){let e=t.proof.metadata;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.type;return typeof n=="string"?n:void 0}function _o(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}y();y();var Dd=BigInt(0),hn=BigInt(1),Nd=BigInt(2),Ld=BigInt(7),Od=BigInt(256),Fd=BigInt(113),Oa=[],Fa=[],_a=[];for(let t=0,e=hn,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Oa.push(2*(5*r+n)),Fa.push((t+1)*(t+2)/2%64);let o=Dd;for(let i=0;i<7;i++)e=(e<<hn^(e>>Ld)*Fd)%Od,e&Nd&&(o^=hn<<(hn<<BigInt(i))-hn);_a.push(o)}var Ua=Hn(_a,!0),_d=Ua[0],Ud=Ua[1],Na=(t,e,n)=>n>32?Xi(t,e,n):Zi(t,e,n),La=(t,e,n)=>n>32?Ji(t,e,n):Yi(t,e,n);function jd(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,f=n[c],u=n[c+1],d=Na(f,u,1)^n[a],h=La(f,u,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=d,t[s+l+1]^=h}let o=t[2],i=t[3];for(let s=0;s<24;s++){let a=Fa[s],c=Na(o,i,a),f=La(o,i,a),u=Oa[s];o=t[u],i=t[u+1],t[u]=c,t[u+1]=f}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=_d[r],t[1]^=Ud[r]}He(n)}var jo=class t extends Nt{constructor(e,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Pr(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=zi(this.state)}clone(){return this._cloneInto()}keccak(){Mr(this.state32),jd(this.state32,this.rounds),Mr(this.state32),this.posOut=0,this.pos=0}update(e){Lt(this),e=Jt(e),bt(e);let{blockLen:n,state:r}=this,o=e.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){Lt(this,!1),bt(e),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=e.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);e.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Pr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(kn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,He(this.state)}_cloneInto(e){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return e||(e=new t(n,r,o,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=o,e.enableXOF=s,e.destroyed=this.destroyed,e}},Kd=(t,e,n)=>Qt(()=>new jo(e,t,n));var ja=Kd(1,136,256/8);y();function za(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=qa(t,0);if(n!==t.length)throw new Error(`RLP: ${t.length-n} trailing byte(s) after the top-level item`);if(!Array.isArray(e))throw new Error("RLP: top-level item is not a list");return e}function qa(t,e){let n=Ga(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=sr(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=Va(t,e+1,a),f=e+1+a,u=sr(t,f,c);return{item:t.subarray(f,u),next:u}}if(n<=247){let a=n-192,c=sr(t,e+1,a);return{item:Ka(t,e+1,c),next:c}}let r=n-247,o=Va(t,e+1,r),i=e+1+r,s=sr(t,i,o);return{item:Ka(t,i,s),next:s}}function Ka(t,e,n){let r=[],o=e;for(;o<n;){let i=qa(t,o);if(i.next>n)throw new Error("RLP: list item overruns its list payload");r.push(i.item),o=i.next}return r}function Va(t,e,n){if(n<1||n>8)throw new Error(`RLP: invalid length-of-length ${n}`);let r=0;for(let o=0;o<n;o++)r=r*256+Ga(t,e+o);if(r>t.length)throw new Error("RLP: declared length exceeds the input size");return r}function sr(t,e,n){let r=e+n;if(r>t.length)throw new Error("RLP: item is truncated");return r}function Ga(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function Ko(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function Wa(t){if(!t.startsWith("0x"))return null;let e=t.slice(2);if(e.length%2!==0||!/^[0-9a-fA-F]*$/.test(e))return null;let n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++)n[r]=Number.parseInt(e.slice(r*2,r*2+2),16);return n}function Za(t){return`0x${B.Buffer.from(t).toString("hex")}`}var Ya=8,Xa=11,Vd=/^0x[0-9a-fA-F]{64}$/,zd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function zo(t,e){let n=[],r=[],o=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=qd(i);if(s.failure!==void 0){let u={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(u),r.push(Vo(u));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),f=e.anchors.filter(u=>{let d=u.blockHash?.toLowerCase();return d!==void 0&&(d===a||d===c)});if(f.length===0){let u={witnessPath:i.path,verified:!1,reason:"witness-unmatched",detail:"neither the locally recomputed block hash nor the claimed blockHash matches any observed anchor's signed attribution.message",computedBlockHash:a};n.push(u),r.push(Vo(u));continue}for(let u of f){let d=o.get(u.proofHash),h=d!==void 0&&await Ye(d),l=Gd(s,i.path,u.proofHash,d,h);n.push(l),l.verified||r.push(Vo(l))}}return{outcomes:n,findings:r}}function qd(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return ar("headerRlpHex is missing or not a string");let r=e.blockNumber;if(typeof r!="number"||!Number.isInteger(r)||r<0)return ar("blockNumber is missing or not a non-negative integer");let o=e.blockHash;if(typeof o!="string"||!Vd.test(o))return ar("blockHash is missing or not 0x followed by 64 hex characters");let i=Wa(n);if(i===null)return ar("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=za(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:Za(ja(i)),items:s,claimedHash:o,claimedNumber:BigInt(r)}}function ar(t){return{failure:{reason:"witness-malformed",detail:t}}}function Gd(t,e,n,r,o){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(b,k,v)=>({...s,verified:!1,reason:b,detail:k,...v?.blockNumber!==void 0?{blockNumber:v.blockNumber}:{}});if(r===void 0||!o)return a("witness-anchor-invalid","the candidate anchor proof is not cryptographically valid; the witness confers nothing");let c=Wd(r);if(c===void 0||c.toLowerCase()!==i)return a("witness-hash-mismatch",c===void 0?"the anchor carries no signed attribution.message to compare against":"the locally recomputed block hash does not equal the anchor's signed attribution.message");let f=Xd(Yd(r));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let u=U(new TextEncoder().encode(c));if(!Jd(u,f))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let d=t.items,h=d[Ya];if(h===void 0||!(h instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Ya} (block number) is missing or not a byte string`);let l=Ko(h);if(l!==t.claimedNumber)return a("witness-block-number-mismatch",`the witness claims blockNumber ${t.claimedNumber}, but the header's number field is ${l}`,{blockNumber:String(l)});let m=Zd(r);if(m!==void 0){let b=zd.exec(m)?.[1];if(b!==void 0&&BigInt(b)!==l)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${b}, but the header's number field is ${l}`,{blockNumber:String(l)})}if(t.claimedHash.toLowerCase()!==i)return a("witness-claimed-hash-mismatch","the witness's claimed blockHash does not equal the locally recomputed block hash",{blockNumber:String(l)});let p=d[Xa];if(p===void 0||!(p instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Xa} (timestamp) is missing or not a byte string`,{blockNumber:String(l)});let w=Ko(p);return w>BigInt(Number.MAX_SAFE_INTEGER)?a("witness-header-shape","header timestamp does not fit a safe integer",{blockNumber:String(l)}):{...s,verified:!0,blockNumber:String(l),timestamp:Number(w)}}function Wd(t){return Ja(t,"message")}function Zd(t){return Ja(t,"title")}function Ja(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function Yd(t){let e=t.proof.artifact;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.digestB64;return typeof n=="string"?n:void 0}function Xd(t){if(t===void 0||t.length===0)return null;let e=B.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function Jd(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function Vo(t){return{code:t.reason,path:t.witnessPath,message:`anchor witness rejected: ${t.detail??"verification failed"}. The witness confers nothing; the anchor proof's own standing is unchanged.`,details:{...t.anchorProofHash!==void 0?{anchorProofHash:t.anchorProofHash}:{},...t.computedBlockHash!==void 0?{computedBlockHash:t.computedBlockHash}:{}}}}y();function qo(t,e,n,r){let o=new Map(t.proofs.map(u=>[u.proofHash,u])),i=new Map;for(let u of r.outcomes)!u.verified||u.anchorProofHash===void 0||i.has(u.anchorProofHash)||i.set(u.anchorProofHash,{anchorProofHash:u.anchorProofHash,timestamp:u.timestamp,blockHash:u.computedBlockHash,...u.blockNumber!==void 0?{blockNumber:u.blockNumber}:{}});let s=[...i.keys()].sort(),a=n.anchors.map(u=>u.proofHash).filter(u=>!i.has(u)).sort(),c=[];for(let u of e.partitions)c.push(...Qd(u,o,i));let f=ih(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function Qd(t,e,n){let r=t.memberProofHashes.map(h=>e.get(h)),o=new Map(r.map(h=>[h.chainHash,h])),i=r.filter(h=>n.has(h.proofHash)),s=new Map;for(let h of r){if(h.prevB64===void 0)continue;let l=o.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||de(s,l.proofHash,h)}let a=new Map,c=new Map;for(let h of i)a.set(h.proofHash,th(h,s)),c.set(h.proofHash,nh(h,o));let f=r.map(h=>{let l=new Map,m=new Map,p=Y(h.counter);for(let w of i){let b=w.proofHash,k=Y(w.counter);h.proofHash===b||a.get(b).has(h.proofHash)?l.set(b,"chain-link"):p!==void 0&&k!==void 0&&p>k&&(l.has(b)||l.set(b,"counter-order")),c.get(b).has(h.proofHash)?m.set(b,"chain-link"):h.proofHash!==b&&p!==void 0&&k!==void 0&&p<k&&(m.has(b)||m.set(b,"counter-order"))}return{member:h,lower:Qa("not-before",l,n),upper:Qa("not-after",m,n)}}),u=new Map;for(let h of f)de(u,eh(h),h);let d=[];for(let h of u.values()){let l=h.map(v=>v.member).sort(Me),m=h[0],p=m.lower,w=m.upper,b=p.length>0&&w.length>0?"lower-bounded-with-following-anchor":p.length>0?"lower-bounded":w.length>0?"upper-bounded":"ordered-but-unanchored",k=rh(l);d.push({partition:t.key,memberProofHashes:l.map(v=>v.proofHash),...k!==void 0?{positionRange:k}:{},status:b,lowerBounds:p,upperBounds:w})}return d.sort(oh),d}function Qa(t,e,n){if(e.size===0)return[];let r=[...e.entries()].map(([c,f])=>({anchorHash:c,evidenceKind:f,info:n.get(c)})),o=(c,f)=>f===void 0?!0:c.info.timestamp!==f.info.timestamp?t==="not-before"?c.info.timestamp>f.info.timestamp:c.info.timestamp<f.info.timestamp:c.evidenceKind!==f.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<f.anchorHash,i,s;for(let c of r)o(c,i)&&(i=c),c.evidenceKind==="chain-link"&&o(c,s)&&(s=c);let a=[ec(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(ec(t,s)),a}function ec(t,e){let{info:n,evidenceKind:r}=e,o=new Date(n.timestamp*1e3).toISOString(),i=n.blockNumber!==void 0?`Ethereum block ${n.blockNumber}`:"an Ethereum block",s=r==="chain-link"?"Evidence: a verified hash-link path connects these proofs and the anchor.":"Evidence: commit-counter ordering within the partition only, which relies on the authority's counter discipline rather than verifiable hash links (weaker).",a=t==="not-before"?`These proofs were committed no earlier than ${o} (unix ${n.timestamp}), the timestamp of ${i}: the block hash was unpredictable before that time and the anchor commit consumed it. Reading this as a wall-clock floor additionally assumes the anchored header is a genuine, publicly published Ethereum block: this offline audit checks the header's structure and hash binding, not proof-of-work, consensus, or chain membership, so it cannot confirm the block is real. ${s}`:`These proofs existed before the anchor commit that consumed the hash of ${i} (block timestamp ${o}, unix ${n.timestamp}). The block timestamp proves the anchor commit came at or after it, not how promptly; reading it as a wall-clock ceiling additionally assumes the anchor consumed a recently published block. ${s}`;return{kind:t,anchorProofHash:e.anchorHash,...n.blockNumber!==void 0?{blockNumber:n.blockNumber}:{},blockHash:n.blockHash,timestamp:n.timestamp,evidence:r,weaker:r==="counter-order",basis:t==="not-before"?"block-hash-unpredictability":"causal-precedence",boundClass:t==="not-before"?"evidence":"assumption",claim:t==="not-before"?a:"NOT a proof-carried upper bound. "+a}}function eh(t){let e=n=>n.map(r=>`${r.anchorProofHash}:${r.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function th(t,e){let n=new Set,r=[...e.get(t.proofHash)??[]];for(;r.length>0;){let o=r.pop();if(!n.has(o.proofHash)){n.add(o.proofHash);for(let i of e.get(o.proofHash)??[])r.push(i)}}return n}function nh(t,e){let n=new Set,r=t;for(;r!==void 0&&r.prevB64!==void 0;){let o=e.get(r.prevB64);if(o===void 0||n.has(o.proofHash)||o.proofHash===t.proofHash)break;n.add(o.proofHash),r=o}return n}function rh(t){let e,n;for(let r of t)for(let o of[r.counter,r.slotCounter]){let i=Y(o);i!==void 0&&((e===void 0||i<e)&&(e=i),(n===void 0||i>n)&&(n=i))}return e!==void 0&&n!==void 0?{min:String(e),max:String(n)}:void 0}function oh(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}function tc(t){return t?" The representative bound rests on commit-counter ordering rather than a verified hash-link path, which relies on the authority's counter discipline (weaker evidence).":""}function ih(t,e){let n=new Map;for(let i of t.epochRelationships.epochs)n.set(i.epochId,{totalProofCount:i.proofCount,lowerCovered:new Set,upperCovered:new Set});for(let i of e){let s=i.partition.epochId;if(s===void 0)continue;let a=n.get(s);if(a!==void 0){for(let c of i.lowerBounds){for(let f of i.memberProofHashes)a.lowerCovered.add(f);(a.lowerMin===void 0||c.timestamp<a.lowerMin.timestamp||c.timestamp===a.lowerMin.timestamp&&a.lowerMin.weaker&&!c.weaker)&&(a.lowerMin={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}for(let c of i.upperBounds){for(let f of i.memberProofHashes)a.upperCovered.add(f);(a.upperMax===void 0||c.timestamp>a.upperMax.timestamp||c.timestamp===a.upperMax.timestamp&&a.upperMax.weaker&&!c.weaker)&&(a.upperMax={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}}}for(let i of t.epochRelationships.epochs){let s=n.get(i.epochId),a=[];s.lowerMin!==void 0&&a.push({kind:"not-before",anchorProofHash:s.lowerMin.anchorProofHash,...s.lowerMin.blockNumber!==void 0?{blockNumber:s.lowerMin.blockNumber}:{},blockHash:s.lowerMin.blockHash,witnessTimestamp:s.lowerMin.timestamp,coverage:"members-after-anchor",coveredProofCount:s.lowerCovered.size,totalProofCount:s.totalProofCount,basis:"block-hash-unpredictability",evidence:s.lowerMin.evidence,weaker:s.lowerMin.weaker,claim:`${s.lowerCovered.size} of ${s.totalProofCount} observed proofs of this epoch were committed no earlier than unix ${s.lowerMin.timestamp}, grounded in block-hash unpredictability through verified anchor witnesses. This additionally assumes the anchored header is a genuine, publicly published Ethereum block, which this offline audit cannot confirm.`+tc(s.lowerMin.weaker)+" The remaining proofs sit causally before the covering anchors and carry no lower bound from this evidence."}),s.upperMax!==void 0&&a.push({kind:"not-after",anchorProofHash:s.upperMax.anchorProofHash,...s.upperMax.blockNumber!==void 0?{blockNumber:s.upperMax.blockNumber}:{},blockHash:s.upperMax.blockHash,witnessTimestamp:s.upperMax.timestamp,coverage:"members-before-anchor",coveredProofCount:s.upperCovered.size,totalProofCount:s.totalProofCount,basis:"causal-precedence",evidence:s.upperMax.evidence,weaker:s.upperMax.weaker,claim:`${s.upperCovered.size} of ${s.totalProofCount} observed proofs of this epoch existed before an anchor commit that consumed a block published at unix ${s.upperMax.timestamp}. Reading that timestamp as a wall-clock ceiling additionally assumes the anchor consumed a recently published block; the causal precedence itself is verified.`+tc(s.upperMax.weaker)+" Proofs after the covering anchors are not covered."}),a.length>0&&(i.anchorBounds=a)}let r=[],o=t.epochRelationships.epochs;for(let i of o){let s=n.get(i.epochId);if(s.upperMax!==void 0)for(let a of o){if(a.epochId===i.epochId)continue;let c=n.get(a.epochId);if(c.lowerMin===void 0||s.upperMax.timestamp>=c.lowerMin.timestamp)continue;let f=s.upperMax.evidence,u=c.lowerMin.evidence,d=s.upperMax.weaker||c.lowerMin.weaker;r.push({beforeEpochId:i.epochId,afterEpochId:a.epochId,upperAnchorProofHash:s.upperMax.anchorProofHash,upperBoundTimestamp:s.upperMax.timestamp,lowerAnchorProofHash:c.lowerMin.anchorProofHash,lowerBoundTimestamp:c.lowerMin.timestamp,basis:"anchor-bounds",assumptionDependent:!0,upperEvidence:f,lowerEvidence:u,weaker:d,beforeCoveredProofCount:s.upperCovered.size,beforeTotalProofCount:s.totalProofCount,afterCoveredProofCount:c.lowerCovered.size,afterTotalProofCount:c.totalProofCount,note:`The anchor-covered portion of epoch ${i.epochId} (${s.upperCovered.size} of ${s.totalProofCount} proofs) precedes the anchor-covered portion of epoch ${a.epochId} (${c.lowerCovered.size} of ${c.totalProofCount} proofs): the first is bounded not-after unix ${s.upperMax.timestamp} and the second not-before unix ${c.lowerMin.timestamp}. One-sided evidence about the covered portions only; the not-after side rests on the anchor-freshness assumption documented on its bound.`+(d?" At least one side rests on commit-counter ordering rather than a verified hash-link path (weaker evidence), which relies on the authority's counter discipline.":"")+" This is ordering evidence, never divergence."})}}return r.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),r}y();y();var nc=`-----BEGIN CERTIFICATE-----
|
|
139
|
+
"use strict";(()=>{var Jf=Object.create;var cs=Object.defineProperty;var Qf=Object.getOwnPropertyDescriptor;var eu=Object.getOwnPropertyNames;var tu=Object.getPrototypeOf,nu=Object.prototype.hasOwnProperty;var ru=(t,e)=>()=>(t&&(e=t(t=0)),e);var Yr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ou=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of eu(e))!nu.call(t,o)&&o!==n&&cs(t,o,{get:()=>e[o],enumerable:!(r=Qf(e,o))||r.enumerable});return t};var iu=(t,e,n)=>(n=t!=null?Jf(tu(t)):{},ou(e||!t||!t.__esModule?cs(n,"default",{value:t,enumerable:!0}):n,t));var ls=Yr(jn=>{"use strict";g();jn.byteLength=au;jn.toByteArray=fu;jn.fromByteArray=du;var _e=[],Ae=[],su=typeof Uint8Array<"u"?Uint8Array:Array,Zr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(It=0,fs=Zr.length;It<fs;++It)_e[It]=Zr[It],Ae[Zr.charCodeAt(It)]=It;var It,fs;Ae[45]=62;Ae[95]=63;function us(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function au(t){var e=us(t),n=e[0],r=e[1];return(n+r)*3/4-r}function cu(t,e,n){return(e+n)*3/4-n}function fu(t){var e,n=us(t),r=n[0],o=n[1],i=new su(cu(t,r,o)),s=0,a=o>0?r-4:r,c;for(c=0;c<a;c+=4)e=Ae[t.charCodeAt(c)]<<18|Ae[t.charCodeAt(c+1)]<<12|Ae[t.charCodeAt(c+2)]<<6|Ae[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return o===2&&(e=Ae[t.charCodeAt(c)]<<2|Ae[t.charCodeAt(c+1)]>>4,i[s++]=e&255),o===1&&(e=Ae[t.charCodeAt(c)]<<10|Ae[t.charCodeAt(c+1)]<<4|Ae[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function uu(t){return _e[t>>18&63]+_e[t>>12&63]+_e[t>>6&63]+_e[t&63]}function lu(t,e,n){for(var r,o=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(uu(r));return o.join("")}function du(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(lu(t,s,s+i>a?a:s+i));return r===1?(e=t[n-1],o.push(_e[e>>2]+_e[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],o.push(_e[e>>10]+_e[e>>4&63]+_e[e<<2&63]+"=")),o.join("")}});var ds=Yr(Xr=>{g();Xr.read=function(t,e,n,r,o){var i,s,a=o*8-r-1,c=(1<<a)-1,f=c>>1,u=-7,l=n?o-1:0,d=n?-1:1,h=t[e+l];for(l+=d,i=h&(1<<-u)-1,h>>=-u,u+=a;u>0;i=i*256+t[e+l],l+=d,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=s*256+t[e+l],l+=d,u-=8);if(i===0)i=1-f;else{if(i===c)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-f}return(h?-1:1)*s*Math.pow(2,i-r)};Xr.write=function(t,e,n,r,o,i){var s,a,c,f=i*8-o-1,u=(1<<f)-1,l=u>>1,d=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,m=r?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+l>=1?e+=d/c:e+=d*Math.pow(2,1-l),e*c>=2&&(s++,c/=2),s+l>=u?(a=0,s=u):s+l>=1?(a=(e*c-1)*Math.pow(2,o),s=s+l):(a=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[n+h]=a&255,h+=m,a/=256,o-=8);for(s=s<<o|a,f+=o;f>0;t[n+h]=s&255,h+=m,s/=256,f-=8);t[n+h-m]|=y*128}});var Cs=Yr(Gt=>{"use strict";g();var Jr=ls(),jt=ds(),hs=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Gt.Buffer=x;Gt.SlowBuffer=yu;Gt.INSPECT_MAX_BYTES=50;var Kn=2147483647;Gt.kMaxLength=Kn;x.TYPED_ARRAY_SUPPORT=hu();!x.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function hu(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(x.prototype,"parent",{enumerable:!0,get:function(){if(x.isBuffer(this))return this.buffer}});Object.defineProperty(x.prototype,"offset",{enumerable:!0,get:function(){if(x.isBuffer(this))return this.byteOffset}});function qe(t){if(t>Kn)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,x.prototype),e}function x(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return no(t)}return bs(t,e,n)}x.poolSize=8192;function bs(t,e,n){if(typeof t=="string")return mu(t,e);if(ArrayBuffer.isView(t))return gu(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Me(t,ArrayBuffer)||t&&Me(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Me(t,SharedArrayBuffer)||t&&Me(t.buffer,SharedArrayBuffer)))return eo(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return x.from(r,e,n);let o=bu(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return x.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}x.from=function(t,e,n){return bs(t,e,n)};Object.setPrototypeOf(x.prototype,Uint8Array.prototype);Object.setPrototypeOf(x,Uint8Array);function ys(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function pu(t,e,n){return ys(t),t<=0?qe(t):e!==void 0?typeof n=="string"?qe(t).fill(e,n):qe(t).fill(e):qe(t)}x.alloc=function(t,e,n){return pu(t,e,n)};function no(t){return ys(t),qe(t<0?0:ro(t)|0)}x.allocUnsafe=function(t){return no(t)};x.allocUnsafeSlow=function(t){return no(t)};function mu(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!x.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=ws(t,e)|0,r=qe(n),o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}function Qr(t){let e=t.length<0?0:ro(t.length)|0,n=qe(e);for(let r=0;r<e;r+=1)n[r]=t[r]&255;return n}function gu(t){if(Me(t,Uint8Array)){let e=new Uint8Array(t);return eo(e.buffer,e.byteOffset,e.byteLength)}return Qr(t)}function eo(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&n===void 0?r=new Uint8Array(t):n===void 0?r=new Uint8Array(t,e):r=new Uint8Array(t,e,n),Object.setPrototypeOf(r,x.prototype),r}function bu(t){if(x.isBuffer(t)){let e=ro(t.length)|0,n=qe(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||io(t.length)?qe(0):Qr(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Qr(t.data)}function ro(t){if(t>=Kn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Kn.toString(16)+" bytes");return t|0}function yu(t){return+t!=t&&(t=0),x.alloc(+t)}x.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==x.prototype};x.compare=function(e,n){if(Me(e,Uint8Array)&&(e=x.from(e,e.offset,e.byteLength)),Me(n,Uint8Array)&&(n=x.from(n,n.offset,n.byteLength)),!x.isBuffer(e)||!x.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;let r=e.length,o=n.length;for(let i=0,s=Math.min(r,o);i<s;++i)if(e[i]!==n[i]){r=e[i],o=n[i];break}return r<o?-1:o<r?1:0};x.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};x.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return x.alloc(0);let r;if(n===void 0)for(n=0,r=0;r<e.length;++r)n+=e[r].length;let o=x.allocUnsafe(n),i=0;for(r=0;r<e.length;++r){let s=e[r];if(Me(s,Uint8Array))i+s.length>o.length?(x.isBuffer(s)||(s=x.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(x.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function ws(t,e){if(x.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Me(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let n=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return to(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Ss(t).length;default:if(o)return r?-1:to(t).length;e=(""+e).toLowerCase(),o=!0}}x.byteLength=ws;function wu(t,e,n){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Cu(this,e,n);case"utf8":case"utf-8":return Es(this,e,n);case"ascii":return Iu(this,e,n);case"latin1":case"binary":return Su(this,e,n);case"base64":return Tu(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ru(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}x.prototype._isBuffer=!0;function St(t,e,n){let r=t[e];t[e]=t[n],t[n]=r}x.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<e;n+=2)St(this,n,n+1);return this};x.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<e;n+=4)St(this,n,n+3),St(this,n+1,n+2);return this};x.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<e;n+=8)St(this,n,n+7),St(this,n+1,n+6),St(this,n+2,n+5),St(this,n+3,n+4);return this};x.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Es(this,0,e):wu.apply(this,arguments)};x.prototype.toLocaleString=x.prototype.toString;x.prototype.equals=function(e){if(!x.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:x.compare(this,e)===0};x.prototype.inspect=function(){let e="",n=Gt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};hs&&(x.prototype[hs]=x.prototype.inspect);x.prototype.compare=function(e,n,r,o,i){if(Me(e,Uint8Array)&&(e=x.from(e,e.offset,e.byteLength)),!x.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(n===void 0&&(n=0),r===void 0&&(r=e?e.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),n<0||r>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&n>=r)return 0;if(o>=i)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,o>>>=0,i>>>=0,this===e)return 0;let s=i-o,a=r-n,c=Math.min(s,a),f=this.slice(o,i),u=e.slice(n,r);for(let l=0;l<c;++l)if(f[l]!==u[l]){s=f[l],a=u[l];break}return s<a?-1:a<s?1:0};function xs(t,e,n,r,o){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,io(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof e=="string"&&(e=x.from(e,r)),x.isBuffer(e))return e.length===0?-1:ps(t,e,n,r,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):ps(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function ps(t,e,n,r,o){let i=1,s=t.length,a=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,n/=2}function c(u,l){return i===1?u[l]:u.readUInt16BE(l*i)}let f;if(o){let u=-1;for(f=n;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*i}else u!==-1&&(f-=f-u),u=-1}else for(n+a>s&&(n=s-a),f=n;f>=0;f--){let u=!0;for(let l=0;l<a;l++)if(c(t,f+l)!==c(e,l)){u=!1;break}if(u)return f}return-1}x.prototype.includes=function(e,n,r){return this.indexOf(e,n,r)!==-1};x.prototype.indexOf=function(e,n,r){return xs(this,e,n,r,!0)};x.prototype.lastIndexOf=function(e,n,r){return xs(this,e,n,r,!1)};function xu(t,e,n,r){n=Number(n)||0;let o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;let i=e.length;r>i/2&&(r=i/2);let s;for(s=0;s<r;++s){let a=parseInt(e.substr(s*2,2),16);if(io(a))return s;t[n+s]=a}return s}function Eu(t,e,n,r){return Gn(to(e,t.length-n),t,n,r)}function ku(t,e,n,r){return Gn(Du(e),t,n,r)}function Bu(t,e,n,r){return Gn(Ss(e),t,n,r)}function Au(t,e,n,r){return Gn(_u(e,t.length-n),t,n,r)}x.prototype.write=function(e,n,r,o){if(n===void 0)o="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")o=n,r=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(r)?(r=r>>>0,o===void 0&&(o="utf8")):(o=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-n;if((r===void 0||r>i)&&(r=i),e.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return xu(this,e,n,r);case"utf8":case"utf-8":return Eu(this,e,n,r);case"ascii":case"latin1":case"binary":return ku(this,e,n,r);case"base64":return Bu(this,e,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Au(this,e,n,r);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};x.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tu(t,e,n){return e===0&&n===t.length?Jr.fromByteArray(t):Jr.fromByteArray(t.slice(e,n))}function Es(t,e,n){n=Math.min(t.length,n);let r=[],o=e;for(;o<n;){let i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=n){let c,f,u,l;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[o+1],(c&192)===128&&(l=(i&31)<<6|c&63,l>127&&(s=l));break;case 3:c=t[o+1],f=t[o+2],(c&192)===128&&(f&192)===128&&(l=(i&15)<<12|(c&63)<<6|f&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:c=t[o+1],f=t[o+2],u=t[o+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(l=(i&15)<<18|(c&63)<<12|(f&63)<<6|u&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),o+=a}return vu(r)}var ms=4096;function vu(t){let e=t.length;if(e<=ms)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=ms));return n}function Iu(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]&127);return r}function Su(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function Cu(t,e,n){let r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let i=e;i<n;++i)o+=Mu[t[i]];return o}function Ru(t,e,n){let r=t.slice(e,n),o="";for(let i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+r[i+1]*256);return o}x.prototype.slice=function(e,n){let r=this.length;e=~~e,n=n===void 0?r:~~n,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<e&&(n=e);let o=this.subarray(e,n);return Object.setPrototypeOf(o,x.prototype),o};function ne(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}x.prototype.readUintLE=x.prototype.readUIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||ne(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return o};x.prototype.readUintBE=x.prototype.readUIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||ne(e,n,this.length);let o=this[e+--n],i=1;for(;n>0&&(i*=256);)o+=this[e+--n]*i;return o};x.prototype.readUint8=x.prototype.readUInt8=function(e,n){return e=e>>>0,n||ne(e,1,this.length),this[e]};x.prototype.readUint16LE=x.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||ne(e,2,this.length),this[e]|this[e+1]<<8};x.prototype.readUint16BE=x.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||ne(e,2,this.length),this[e]<<8|this[e+1]};x.prototype.readUint32LE=x.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||ne(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};x.prototype.readUint32BE=x.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||ne(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};x.prototype.readBigUInt64LE=ht(function(e){e=e>>>0,Kt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&yn(e,this.length-8);let o=n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+r*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});x.prototype.readBigUInt64BE=ht(function(e){e=e>>>0,Kt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&yn(e,this.length-8);let o=n*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r;return(BigInt(o)<<BigInt(32))+BigInt(i)});x.prototype.readIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||ne(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o};x.prototype.readIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||ne(e,n,this.length);let o=n,i=1,s=this[e+--o];for(;o>0&&(i*=256);)s+=this[e+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s};x.prototype.readInt8=function(e,n){return e=e>>>0,n||ne(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};x.prototype.readInt16LE=function(e,n){e=e>>>0,n||ne(e,2,this.length);let r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};x.prototype.readInt16BE=function(e,n){e=e>>>0,n||ne(e,2,this.length);let r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};x.prototype.readInt32LE=function(e,n){return e=e>>>0,n||ne(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};x.prototype.readInt32BE=function(e,n){return e=e>>>0,n||ne(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};x.prototype.readBigInt64LE=ht(function(e){e=e>>>0,Kt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&yn(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});x.prototype.readBigInt64BE=ht(function(e){e=e>>>0,Kt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&yn(e,this.length-8);let o=(n<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r)});x.prototype.readFloatLE=function(e,n){return e=e>>>0,n||ne(e,4,this.length),jt.read(this,e,!0,23,4)};x.prototype.readFloatBE=function(e,n){return e=e>>>0,n||ne(e,4,this.length),jt.read(this,e,!1,23,4)};x.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||ne(e,8,this.length),jt.read(this,e,!0,52,8)};x.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||ne(e,8,this.length),jt.read(this,e,!1,52,8)};function de(t,e,n,r,o,i){if(!x.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}x.prototype.writeUintLE=x.prototype.writeUIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;de(this,e,n,r,a,0)}let i=1,s=0;for(this[n]=e&255;++s<r&&(i*=256);)this[n+s]=e/i&255;return n+r};x.prototype.writeUintBE=x.prototype.writeUIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;de(this,e,n,r,a,0)}let i=r-1,s=1;for(this[n+i]=e&255;--i>=0&&(s*=256);)this[n+i]=e/s&255;return n+r};x.prototype.writeUint8=x.prototype.writeUInt8=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,1,255,0),this[n]=e&255,n+1};x.prototype.writeUint16LE=x.prototype.writeUInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};x.prototype.writeUint16BE=x.prototype.writeUInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};x.prototype.writeUint32LE=x.prototype.writeUInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=e&255,n+4};x.prototype.writeUint32BE=x.prototype.writeUInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};function ks(t,e,n,r,o){Is(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,n}function Bs(t,e,n,r,o){Is(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i=i>>8,t[n+6]=i,i=i>>8,t[n+5]=i,i=i>>8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s=s>>8,t[n+2]=s,s=s>>8,t[n+1]=s,s=s>>8,t[n]=s,n+8}x.prototype.writeBigUInt64LE=ht(function(e,n=0){return ks(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});x.prototype.writeBigUInt64BE=ht(function(e,n=0){return Bs(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});x.prototype.writeIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);de(this,e,n,r,c-1,-c)}let i=0,s=1,a=0;for(this[n]=e&255;++i<r&&(s*=256);)e<0&&a===0&&this[n+i-1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};x.prototype.writeIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);de(this,e,n,r,c-1,-c)}let i=r-1,s=1,a=0;for(this[n+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[n+i+1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};x.prototype.writeInt8=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};x.prototype.writeInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};x.prototype.writeInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};x.prototype.writeInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,4,2147483647,-2147483648),this[n]=e&255,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4};x.prototype.writeInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||de(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};x.prototype.writeBigInt64LE=ht(function(e,n=0){return ks(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});x.prototype.writeBigInt64BE=ht(function(e,n=0){return Bs(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function As(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Ts(t,e,n,r,o){return e=+e,n=n>>>0,o||As(t,e,n,4,34028234663852886e22,-34028234663852886e22),jt.write(t,e,n,r,23,4),n+4}x.prototype.writeFloatLE=function(e,n,r){return Ts(this,e,n,!0,r)};x.prototype.writeFloatBE=function(e,n,r){return Ts(this,e,n,!1,r)};function vs(t,e,n,r,o){return e=+e,n=n>>>0,o||As(t,e,n,8,17976931348623157e292,-17976931348623157e292),jt.write(t,e,n,r,52,8),n+8}x.prototype.writeDoubleLE=function(e,n,r){return vs(this,e,n,!0,r)};x.prototype.writeDoubleBE=function(e,n,r){return vs(this,e,n,!1,r)};x.prototype.copy=function(e,n,r,o){if(!x.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!o&&o!==0&&(o=this.length),n>=e.length&&(n=e.length),n||(n=0),o>0&&o<r&&(o=r),o===r||e.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n<o-r&&(o=e.length-n+r);let i=o-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,r,o):Uint8Array.prototype.set.call(e,this.subarray(r,o),n),i};x.prototype.fill=function(e,n,r,o){if(typeof e=="string"){if(typeof n=="string"?(o=n,n=0,r=this.length):typeof r=="string"&&(o=r,r=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!x.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);let i;if(typeof e=="number")for(i=n;i<r;++i)this[i]=e;else{let s=x.isBuffer(e)?e:x.from(e,o),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-n;++i)this[i+n]=s[i%a]}return this};var Vt={};function oo(t,e,n){Vt[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}oo("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);oo("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);oo("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=gs(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=gs(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r},RangeError);function gs(t){let e="",n=t.length,r=t[0]==="-"?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function Hu(t,e,n){Kt(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&yn(e,t.length-(n+1))}function Is(t,e,n,r,o,i){if(t>n||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${n}${s}`,new Vt.ERR_OUT_OF_RANGE("value",a,t)}Hu(r,o,i)}function Kt(t,e){if(typeof t!="number")throw new Vt.ERR_INVALID_ARG_TYPE(e,"number",t)}function yn(t,e,n){throw Math.floor(t)!==t?(Kt(t,n),new Vt.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new Vt.ERR_BUFFER_OUT_OF_BOUNDS:new Vt.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var Nu=/[^+/0-9A-Za-z-_]/g;function $u(t){if(t=t.split("=")[0],t=t.trim().replace(Nu,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function to(t,e){e=e||1/0;let n,r=t.length,o=null,i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function Du(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function _u(t,e){let n,r,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}function Ss(t){return Jr.toByteArray($u(t))}function Gn(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function Me(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function io(t){return t!==t}var Mu=(function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let r=n*16;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e})();function ht(t){return typeof BigInt>"u"?Pu:t}function Pu(){throw new Error("BigInt not supported")}});var E,g=ru(()=>{"use strict";E=iu(Cs(),1);globalThis.Buffer=E.Buffer});g();g();var Ou={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:se,n:zn,Gx:Rs,Gy:Hs,a:so,d:ao}=Ou,Lu=8n,wn=32,co=64,Te=(t="")=>{throw new Error(t)},Fu=t=>typeof t=="bigint",Ps=t=>typeof t=="string",Uu=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",Wt=(t,e)=>!Uu(t)||typeof e=="number"&&e>0&&t.length!==e?Te("Uint8Array expected"):t,Zn=t=>new Uint8Array(t),ho=t=>Uint8Array.from(t),Os=(t,e)=>t.toString(16).padStart(e,"0"),po=t=>Array.from(Wt(t)).map(e=>Os(e,2)).join(""),Ye={_0:48,_9:57,A:65,F:70,a:97,f:102},Ns=t=>{if(t>=Ye._0&&t<=Ye._9)return t-Ye._0;if(t>=Ye.A&&t<=Ye.F)return t-(Ye.A-10);if(t>=Ye.a&&t<=Ye.f)return t-(Ye.a-10)},mo=t=>{let e="hex invalid";if(!Ps(t))return Te(e);let n=t.length,r=n/2;if(n%2)return Te(e);let o=Zn(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Ns(t.charCodeAt(s)),c=Ns(t.charCodeAt(s+1));if(a===void 0||c===void 0)return Te(e);o[i]=a*16+c}return o},Wn=(t,e)=>Wt(Ps(t)?mo(t):ho(Wt(t)),e),Ls=()=>globalThis?.crypto,Vu=()=>Ls()?.subtle??Te("crypto.subtle must be defined"),fo=(...t)=>{let e=Zn(t.reduce((r,o)=>r+Wt(o).length,0)),n=0;return t.forEach(r=>{e.set(r,n),n+=r.length}),e},ju=(t=wn)=>Ls().getRandomValues(Zn(t)),qn=BigInt,Ct=(t,e,n,r="bad number: out of range")=>Fu(t)&&e<=t&&t<n?t:Te(r),v=(t,e=se)=>{let n=t%e;return n>=0n?n:e+n},Ku=t=>v(t,zn),Fs=(t,e)=>{(t===0n||e<=0n)&&Te("no inverse n="+t+" mod="+e);let n=v(t,e),r=e,o=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=r/n,f=r%n,u=o-s*c,l=i-a*c;r=n,n=f,o=s,i=a,s=u,a=l}return r===1n?v(o,e):Te("no inverse")};var $s=t=>t instanceof Ze?t:Te("Point expected"),uo=2n**256n,Ze=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,r,o){let i=uo;this.ex=Ct(e,0n,i),this.ey=Ct(n,0n,i),this.ez=Ct(r,1n,i),this.et=Ct(o,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,v(e.x*e.y))}static fromBytes(e,n=!1){let r=ao,o=ho(Wt(e,wn)),i=e[31];o[31]=i&-129;let s=go(o);Ct(s,0n,n?uo:se);let c=v(s*s),f=v(c-1n),u=v(r*c+1n),{isValid:l,value:d}=Wu(f,u);l||Te("bad point: y not sqrt");let h=(d&1n)===1n,m=(i&128)!==0;return!n&&d===0n&&m&&Te("bad point: x==0, isLastByteOdd"),m!==h&&(d=v(-d)),new t(d,s,1n,v(d*s))}assertValidity(){let e=so,n=ao,r=this;if(r.is0())throw new Error("bad point: ZERO");let{ex:o,ey:i,ez:s,et:a}=r,c=v(o*o),f=v(i*i),u=v(s*s),l=v(u*u),d=v(c*e),h=v(u*v(d+f)),m=v(l+v(n*v(c*f)));if(h!==m)throw new Error("bad point: equation left != right (1)");let y=v(o*i),b=v(s*a);if(y!==b)throw new Error("bad point: equation left != right (2)");return this}equals(e){let{ex:n,ey:r,ez:o}=this,{ex:i,ey:s,ez:a}=$s(e),c=v(n*a),f=v(i*o),u=v(r*a),l=v(s*o);return c===f&&u===l}is0(){return this.equals(zt)}negate(){return new t(v(-this.ex),this.ey,this.ez,v(-this.et))}double(){let{ex:e,ey:n,ez:r}=this,o=so,i=v(e*e),s=v(n*n),a=v(2n*v(r*r)),c=v(o*i),f=e+n,u=v(v(f*f)-i-s),l=c+s,d=l-a,h=c-s,m=v(u*d),y=v(l*h),b=v(u*h),p=v(d*l);return new t(m,y,p,b)}add(e){let{ex:n,ey:r,ez:o,et:i}=this,{ex:s,ey:a,ez:c,et:f}=$s(e),u=so,l=ao,d=v(n*s),h=v(r*a),m=v(i*l*f),y=v(o*c),b=v((n+r)*(s+a)-d-h),p=v(y-m),A=v(y+m),B=v(h-u*d),P=v(b*p),V=v(A*B),H=v(b*B),U=v(p*A);return new t(P,V,U,H)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return zt;if(Ct(e,1n,zn),e===1n)return this;if(this.equals(qt))return el(e).p;let r=zt,o=qt;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?r=r.add(i):n&&(o=o.add(i));return r}toAffine(){let{ex:e,ey:n,ez:r}=this;if(this.equals(zt))return{x:0n,y:1n};let o=Fs(r,se);return v(r*o)!==1n&&Te("invalid inverse"),{x:v(e*o),y:v(n*o)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),r=Gu(n);return r[31]|=e&1n?128:0,r}toHex(){return po(this.toBytes())}clearCofactor(){return this.multiply(qn(Lu),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(zn/2n,!1).double();return zn%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(Wn(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},qt=new Ze(Rs,Hs,1n,v(Rs*Hs)),zt=new Ze(0n,1n,1n,0n);Ze.BASE=qt;Ze.ZERO=zt;var Gu=t=>mo(Os(Ct(t,0n,uo),co)).reverse(),go=t=>qn("0x"+po(ho(Wt(t)).reverse())),Pe=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=se;return n},zu=t=>{let n=t*t%se*t%se,r=Pe(n,2n)*n%se,o=Pe(r,1n)*t%se,i=Pe(o,5n)*o%se,s=Pe(i,10n)*i%se,a=Pe(s,20n)*s%se,c=Pe(a,40n)*a%se,f=Pe(c,80n)*c%se,u=Pe(f,80n)*c%se,l=Pe(u,10n)*i%se;return{pow_p_5_8:Pe(l,2n)*t%se,b2:n}},Ds=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Wu=(t,e)=>{let n=v(e*e*e),r=v(n*n*e),o=zu(t*r).pow_p_5_8,i=v(t*n*o),s=v(e*i*i),a=i,c=v(i*Ds),f=s===t,u=s===v(-t),l=s===v(-t*Ds);return f&&(i=a),(u||l)&&(i=c),(v(i)&1n)===1n&&(i=v(-i)),{isValid:f||u,value:i}},qu=t=>Ku(go(t)),Yu=(...t)=>Xn.sha512Async(...t);var Zu=t=>Yu(t.hashable).then(t.finish);var Us={zip215:!0},Xu=(t,e,n,r=Us)=>{t=Wn(t,co),e=Wn(e),n=Wn(n,wn);let{zip215:o}=r,i,s,a,c,f=Uint8Array.of();try{i=Ze.fromHex(n,o),s=Ze.fromHex(t.slice(0,wn),o),a=go(t.slice(wn,co)),c=qt.multiply(a,!1),f=fo(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:l=>{if(c==null||!o&&i.isSmallOrder())return!1;let d=qu(l);return s.add(i.multiply(d,!1)).add(c.negate()).clearCofactor().is0()}}},bo=async(t,e,n,r=Us)=>Zu(Xu(t,e,n,r));var Xn={sha512Async:async(...t)=>{let e=Vu(),n=fo(...t);return Zn(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:po,hexToBytes:mo,concatBytes:fo,mod:v,invert:Fs,randomBytes:ju};var Yn=8,Ju=256,Vs=Math.ceil(Ju/Yn)+1,lo=2**(Yn-1),Qu=()=>{let t=[],e=qt,n=e;for(let r=0;r<Vs;r++){n=e,t.push(n);for(let o=1;o<lo;o++)n=n.add(e),t.push(n);e=n.double()}return t},_s,Ms=(t,e)=>{let n=e.negate();return t?n:e},el=t=>{let e=_s||(_s=Qu()),n=zt,r=qt,o=2**Yn,i=o,s=qn(o-1),a=qn(Yn);for(let c=0;c<Vs;c++){let f=Number(t&s);t>>=a,f>lo&&(f-=i,t+=1n);let u=c*lo,l=u,d=u+Math.abs(f)-1,h=c%2!==0,m=f<0;f===0?r=r.add(Ms(h,e[l])):n=n.add(Ms(m,e[d]))}return{p:n,f:r}};g();g();g();function nl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function yo(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Rt(t,...e){if(!nl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Zt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Jn(t,e){Rt(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function js(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Oe(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Qn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ce(t,e){return t<<32-e|t>>>e}var rl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ol(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function il(t){for(let e=0;e<t.length;e++)t[e]=ol(t[e]);return t}var wo=rl?t=>t:il;function sl(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function xn(t){return typeof t=="string"&&(t=sl(t)),Rt(t),t}var Yt=class{};function En(t){let e=r=>t().update(xn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function al(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}function Ks(t,e,n){return t&e^~t&n}function Gs(t,e,n){return t&e^t&n^e&n}var kn=class extends Yt{constructor(e,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Qn(this.buffer)}update(e){Zt(this),e=xn(e),Rt(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Qn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Zt(this),Jn(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,Oe(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let l=s;l<o;l++)n[l]=0;al(r,o-8,BigInt(this.length*8),i),this.process(r,0);let a=Qn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Xe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var re=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);g();var er=BigInt(4294967295),zs=BigInt(32);function cl(t,e=!1){return e?{h:Number(t&er),l:Number(t>>zs&er)}:{h:Number(t>>zs&er)|0,l:Number(t&er)|0}}function tr(t,e=!1){let n=t.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=cl(t[i],e);[r[i],o[i]]=[s,a]}return[r,o]}var xo=(t,e,n)=>t>>>n,Eo=(t,e,n)=>t<<32-n|e>>>n,Ht=(t,e,n)=>t>>>n|e<<32-n,Nt=(t,e,n)=>t<<32-n|e>>>n,Bn=(t,e,n)=>t<<64-n|e>>>n-32,An=(t,e,n)=>t>>>n-32|e<<64-n;var Ws=(t,e,n)=>t<<n|e>>>32-n,qs=(t,e,n)=>e<<n|t>>>32-n,Ys=(t,e,n)=>e<<n-32|t>>>64-n,Zs=(t,e,n)=>t<<n-32|e>>>64-n;function Le(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}var Xs=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Js=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Qs=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),ea=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,ta=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),na=(t,e,n,r,o,i)=>e+n+r+o+i+(t/2**32|0)|0;var ul=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pt=new Uint32Array(64),nr=class extends kn{constructor(e=32){super(64,e,8,!1),this.A=Xe[0]|0,this.B=Xe[1]|0,this.C=Xe[2]|0,this.D=Xe[3]|0,this.E=Xe[4]|0,this.F=Xe[5]|0,this.G=Xe[6]|0,this.H=Xe[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)pt[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){let d=pt[l-15],h=pt[l-2],m=Ce(d,7)^Ce(d,18)^d>>>3,y=Ce(h,17)^Ce(h,19)^h>>>10;pt[l]=y+pt[l-7]+m+pt[l-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Ce(a,6)^Ce(a,11)^Ce(a,25),h=u+d+Ks(a,c,f)+ul[l]+pt[l]|0,y=(Ce(r,2)^Ce(r,13)^Ce(r,22))+Gs(r,o,i)|0;u=f,f=c,c=a,a=s+h|0,s=i,i=o,o=r,r=h+y|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){Oe(pt)}destroy(){this.set(0,0,0,0,0,0,0,0),Oe(this.buffer)}};var ra=tr(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),ll=ra[0],dl=ra[1],mt=new Uint32Array(80),gt=new Uint32Array(80),ko=class extends kn{constructor(e=64){super(128,e,16,!1),this.Ah=re[0]|0,this.Al=re[1]|0,this.Bh=re[2]|0,this.Bl=re[3]|0,this.Ch=re[4]|0,this.Cl=re[5]|0,this.Dh=re[6]|0,this.Dl=re[7]|0,this.Eh=re[8]|0,this.El=re[9]|0,this.Fh=re[10]|0,this.Fl=re[11]|0,this.Gh=re[12]|0,this.Gl=re[13]|0,this.Hh=re[14]|0,this.Hl=re[15]|0}get(){let{Ah:e,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:h,Gl:m,Hh:y,Hl:b}=this;return[e,n,r,o,i,s,a,c,f,u,l,d,h,m,y,b]}set(e,n,r,o,i,s,a,c,f,u,l,d,h,m,y,b){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=h|0,this.Gl=m|0,this.Hh=y|0,this.Hl=b|0}process(e,n){for(let B=0;B<16;B++,n+=4)mt[B]=e.getUint32(n),gt[B]=e.getUint32(n+=4);for(let B=16;B<80;B++){let P=mt[B-15]|0,V=gt[B-15]|0,H=Ht(P,V,1)^Ht(P,V,8)^xo(P,V,7),U=Nt(P,V,1)^Nt(P,V,8)^Eo(P,V,7),S=mt[B-2]|0,K=gt[B-2]|0,L=Ht(S,K,19)^Bn(S,K,61)^xo(S,K,6),ce=Nt(S,K,19)^An(S,K,61)^Eo(S,K,6),q=Qs(U,ce,gt[B-7],gt[B-16]),ee=ea(q,H,L,mt[B-7],mt[B-16]);mt[B]=ee|0,gt[B]=q|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:h,Fl:m,Gh:y,Gl:b,Hh:p,Hl:A}=this;for(let B=0;B<80;B++){let P=Ht(l,d,14)^Ht(l,d,18)^Bn(l,d,41),V=Nt(l,d,14)^Nt(l,d,18)^An(l,d,41),H=l&h^~l&y,U=d&m^~d&b,S=ta(A,V,U,dl[B],gt[B]),K=na(S,p,P,H,ll[B],mt[B]),L=S|0,ce=Ht(r,o,28)^Bn(r,o,34)^Bn(r,o,39),q=Nt(r,o,28)^An(r,o,34)^An(r,o,39),ee=r&i^r&a^i&a,Ne=o&s^o&c^s&c;p=y|0,A=b|0,y=h|0,b=m|0,h=l|0,m=d|0,{h:l,l:d}=Le(f|0,u|0,K|0,L|0),f=a|0,u=c|0,a=i|0,c=s|0,i=r|0,s=o|0;let ie=Xs(L,q,Ne);r=Js(ie,K,ce,ee),o=ie|0}({h:r,l:o}=Le(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=Le(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Le(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Le(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=Le(this.Eh|0,this.El|0,l|0,d|0),{h,l:m}=Le(this.Fh|0,this.Fl|0,h|0,m|0),{h:y,l:b}=Le(this.Gh|0,this.Gl|0,y|0,b|0),{h:p,l:A}=Le(this.Hh|0,this.Hl|0,p|0,A|0),this.set(r,o,i,s,a,c,f,u,l,d,h,m,y,b,p,A)}roundClean(){Oe(mt,gt)}destroy(){Oe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var oa=En(()=>new nr);var rr=En(()=>new ko);g();g();g();function ae(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var ia=ae("fs.createReadStream"),Vm=ae("fs.readFileSync"),jm=ae("fs.existsSync"),Km=ae("fs.writeFileSync"),hl=ae("fs.open"),pl=ae("fs.readdir"),sa=ae("fs.readFile"),ml=ae("fs.stat"),Gm=ae("fs.mkdir"),zm=ae("fs.writeFile"),aa=ae("path.join"),Wm=ae("path.basename"),ca=ae("zlib.createGunzip"),gl=ae("zlib.gzipSync"),qm=ae("zlib.brotliDecompressSync"),Ym=ae("zlib.inflateSync");g();var O=oa;g();g();var fa="Ethereum Anchor";function Xt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}function Bo(t){let e=Xt(t);if(e===null)return null;let n=Xt(e.commit);if(n!==null&&n.anchor!==void 0&&n.anchor!==null)return"authenticated";let r=Xt(e.attribution);return r!==null&&r.name===fa?"legacy-attribution":null}function Ao(t){let e=Xt(t),n=e===null?null:Xt(e.commit),r=n===null?null:Xt(n.anchor);if(r===null)return null;let o=r.blockNumber,i=r.blockHash;return typeof o=="number"&&Number.isFinite(o)&&typeof i=="string"?{blockNumber:o,blockHash:i}:null}g();g();g();g();g();g();var bl=t=>t/2**32|0,yl=t=>t>>>0;function ua(t,e,n,r){let o=bl(n),i=yl(n);t.setUint32(e,r?i:o,r),t.setUint32(e+4,r?o:i,r)}g();function or(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var To=t=>t?`"${t}" `:"";function Je(t,e=""){if(typeof t!="number")throw new TypeError(To(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(To(e)+"expected integer >= 0, got "+t);return t}function Fe(t,e,n=""){if(or(t)&&(e===void 0||t.length===e))return t;e!==void 0&&Je(e,"length");let r=or(t),o=e!==void 0?` of length ${e}`:"",i=r?`length=${t.length}`:`type=${typeof t}`,s=To(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function ir(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Je(t.outputLen),Je(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var wl=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)},la=(t,e)=>{wl(t,e);let n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new TypeError(`"${e}" expected plain object`);if(Object.hasOwn(t,"__proto__"))throw new TypeError(`"${e}.__proto__" is not allowed`)};function Jt(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function sr(t,e){Fe(t,void 0,"output");let n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function Tn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ar(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Re(t,e){return t<<32-e|t>>>e}var ha=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",xl=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function cr(t){if(Fe(t),ha)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=xl[t[n]];return e}function da(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function vo(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(ha)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){let s=da(t.charCodeAt(i)),a=da(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=s*16+a}return r}function pa(...t){let e=0;for(let r=0;r<t.length;r++){let o=t[r];Fe(o),e+=o.length}let n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){let i=t[r];n.set(i,o),o+=i.length}return n}function El(t,e,n="opts"){return la(t,"defaults"),e!==void 0&&la(e,n),Object.assign(Object.create(null),t,e)}function ma(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=El({},e,"info");let n=(o,i)=>t(i).update(o).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=o=>t(o),Object.assign(n,e),Object.freeze(n)}function ga(t=32){Je(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ba=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ya(t,e,n){return t&e^~t&n}function wa(t,e,n){return t&e^t&n^e&n}var fr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,r,o){this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ar(this.buffer)}update(e){Jt(this),Fe(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(o-this.pos,i-a);if(c===o){let f=ar(e);for(;o<=i-a;a+=o)this.process(f,a);s=!0;continue}r.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){Jt(this),sr(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>o-s&&(this.process(r,0),n.fill(0)),ua(r,o-8,this.length*8,i),this.process(r,0),this.roundClean();let a=e===n?r:ar(e),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneIntoMeta(e){let{buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,s&&e.buffer.set(n),e}clone(){return this._cloneInto()}},xa=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var kl=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),bt=new Uint32Array(64),Io=class extends fr{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,n){super(64,e,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let l=0;l<16;l++,n+=4)bt[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){let d=bt[l-15],h=bt[l-2],m=Re(d,7)^Re(d,18)^d>>>3,y=Re(h,17)^Re(h,19)^h>>>10;bt[l]=y+bt[l-7]+m+bt[l-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Re(a,6)^Re(a,11)^Re(a,25),h=u+d+ya(a,c,f)+kl[l]+bt[l]|0,y=(Re(r,2)^Re(r,13)^Re(r,22))+wa(r,o,i)|0;u=f,f=c,c=a,a=s+h|0,s=i,i=o,o=r,r=h+y|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){Tn(bt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Tn(this.buffer)}},So=class extends Io{constructor(){super(32,xa)}};var ur=ma(()=>new So,ba(1));g();function dr(t,e,n=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let r=0;r<t.length;r++)n(t[r],`${e}[${r}]`);return t}var J=(t,e,n)=>Fe(t,e,n),Co=Je;function ka(t,e=""){if(typeof t!="string"){let n=e&&`"${e}" `;throw new TypeError(n+"expected string, got type="+typeof t)}return t}function yt(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function $t(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var Ro=cr,Qe=(...t)=>pa(...t),hr=t=>vo(t),Qt=or,pr=t=>ga(t),lr=BigInt(0),Ea=BigInt(1),Bl=t=>t?`"${t}" `:"";function Ue(t,e=""){if(typeof t!="boolean")throw new TypeError(Bl(e)+"expected boolean, got type="+typeof t);return t}function mr(t){if(typeof t=="bigint"){if(!wt(t))throw new RangeError("positive bigint expected, got "+t)}else Co(t);return t}function Dt(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(n+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let n=e&&`"${e}" `;throw new RangeError(n+"expected safe integer, got "+t)}}function vn(t){let e=mr(t).toString(16);return e.length&1?"0"+e:e}function Ba(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?lr:BigInt("0x"+t)}function Ve(t){return Ba(cr(t))}function Ho(t){return Ba(cr(Al(Fe(t)).reverse()))}function gr(t,e){if(Je(e),e===0)throw new Error("zero output length is invalid");t=mr(t);let n=e*2,r=t.toString(16);if(r.length>n)throw new RangeError("number is too large");return vo(r.padStart(n,"0"))}function No(t,e){return gr(t,e).reverse()}function Al(t){return Uint8Array.from(J(t))}function wt(t){return typeof t=="bigint"&&lr<=t}function $o(t,e,n){return wt(t)&&wt(e)&&wt(n)&&e<=t&&t<n}function Do(t,e,n,r){if(!$o(e,n,r))throw new RangeError("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function en(t){if(t<lr)throw new Error("expected non-negative bigint, got "+t);return t===lr?0:t.toString(2).length}var In=t=>(Dt(t,"n"),(Ea<<BigInt(t))-Ea);function Aa(t,e,n){if(Je(t,"hashLen"),Je(e,"qByteLen"),typeof n!="function")throw new TypeError("hmacFn must be a function");let r=b=>new Uint8Array(b),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=r(t),f=r(t),u=0,l=()=>{c.fill(1),f.fill(0),u=0},d=(...b)=>n(f,Qe(c,...b)),h=(b=o)=>{f=d(i,b),c=d(),b.length!==0&&(f=d(s,b),c=d())},m=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let b=0,p=[];for(;b<e;){c=d();let A=c.slice();p.push(A),b+=c.length}return Qe(...p)};return(b,p)=>{l(),h(b);let A;for(;(A=p(m()))===void 0;)h();return l(),A}}function xt(t,e={},n={},r="object"){yt(t,r),yt(e,"fields"),yt(n,"optFields");function o(s,a,c){let f=r==="object"?`param "${String(s)}"`:`"${r}.${String(s)}"`,u=t[s];if(!Object.hasOwn(t,s)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let l=typeof u;if(l!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${l}`)}let i=(s,a)=>Object.entries(s).forEach(([c,f])=>o(c,f,a));i(e,!1),i(n,!0)}g();g();var Q=BigInt(0),G=BigInt(1),Et=BigInt(2),Sa=BigInt(3),_o=BigInt(4),Ca=BigInt(5),Tl=BigInt(7),Ra=BigInt(8),vl=BigInt(9),Il=BigInt(15),Ha=BigInt(16),Sl=BigInt("0x10000000000000000");function ge(t,e){if(e<=Q)throw new Error("mod: expected positive modulus, got "+e);let n=t%e;return n>=Q?n:e+n}function Na(t,e,n){if(n<=G)throw new Error("pow: expected modulus > 1, got "+n);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<Q)throw new Error("invalid exponent, negatives unsupported");if(e===Q)return G;if(e===G)return t;let r=t%n;if(r<Q&&(r+=n),e<Sl){let a=G;for(;e>Q;)e&G&&(a=a*r%n),r=r*r%n,e>>=G;return a}let o=[];for(;e>Q;)o.push(Number(e&Il)),e>>=_o;let i=new Array(16);i[0]=G,i[1]=r;for(let a=2;a<16;a++)i[a]=i[a-1]*r%n;let s=i[o[o.length-1]];for(let a=o.length-2;a>=0;a--){s=s*s%n,s=s*s%n,s=s*s%n,s=s*s%n;let c=o[a];c!==0&&(s=s*i[c]%n)}return s}function be(t,e,n){if(n<=G)throw new Error("pow2: expected modulus > 1, got "+n);if(e<Q)throw new Error("pow2: expected non-negative exponent, got "+e);let r=t;for(;e-- >Q;)r*=r,r%=n;return r}function Ta(t,e){if(t===Q)throw new Error("invert: expected non-zero number");if(e<=G)throw new Error("invert: expected modulus > 1, got "+e);let n=ge(t,e),r=e,o=Q,i=G;for(;n!==Q;){let a=r/n,c=r-n*a,f=o-i*a;r=n,n=c,o=i,i=f}if(r!==G)throw new Error("invert: does not exist");return ge(o,e)}function $a(t,e){if(e<=G)throw new Error("invertCt: expected prime modulus > 1, got "+e);let n=ge(t,e);if(n===Q)throw new Error("invertCt: expected non-zero number");let r=Na(n,e-Et,e);if(ge(n*r,e)!==G)throw new Error("invertCt: does not exist");return r}function Mo(t,e,n){let r=t;if(!r.eql(r.sqr(e),n))throw new Error("Cannot find square root")}function Po(t,e){if((t&G)===Q)throw new Error(e+": expected odd modulus, got "+t)}function Da(t,e){let n=t,r=(n.ORDER+G)/_o,o=n.pow(e,r);return Mo(n,o,e),o}function Cl(t,e){let n=t,r=(n.ORDER-Ca)/Ra,o=n.mul(e,Et),i=n.pow(o,r),s=n.mul(e,i),a=n.mul(n.mul(s,Et),i),c=n.mul(s,n.sub(a,n.ONE));return Mo(n,c,e),c}function Rl(t){let e=nn(t),n=_a(t),r=n(e,e.neg(e.ONE)),o=n(e,r),i=n(e,e.neg(r)),s=(t+Tl)/Ha;return((a,c)=>{let f=a,u=f.pow(c,s),l=f.mul(u,r),d=f.mul(u,o),h=f.mul(u,i),m=f.eql(f.sqr(l),c),y=f.eql(f.sqr(d),c);u=f.cmov(u,l,m),l=f.cmov(h,d,y);let b=f.eql(f.sqr(l),c),p=f.cmov(u,l,b);return Mo(f,p,c),p})}function _a(t){if(t<Sa)throw new Error("sqrt is not defined for small field");Po(t,"tonelliShanks");let e=t-G,n=0;for(;e%Et===Q;)e/=Et,n++;let r=Et,o=nn(t);for(;va(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Da;let i=o.pow(r,e),s=(e+G)/Et;return function(c,f){let u=c;if(u.is0(f))return f;if(va(u,f)!==1)throw new Error("Cannot find square root");let l=n,d=u.mul(u.ONE,i),h=u.pow(f,e),m=u.pow(f,s);for(;!u.eql(h,u.ONE);){if(u.is0(h))throw new Error("Cannot find square root: probably non-prime P");let y=1,b=u.sqr(h);for(;!u.eql(b,u.ONE);)if(y++,b=u.sqr(b),y===l)throw new Error("Cannot find square root");let p=G<<BigInt(l-y-1),A=u.pow(d,p);l=y,d=u.sqr(A),h=u.mul(h,d),m=u.mul(m,A)}return m}}function Hl(t){return Po(t,"Fp.sqrt"),t%_o===Sa?Da:t%Ra===Ca?Cl:t%Ha===vl?Rl(t):_a(t)}var Nl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function tn(t){if(yt(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);Dt(t.BYTES,"BYTES"),Dt(t.BITS,"BITS");for(let e of Nl)$t(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=G)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Oo(t,e,n=!1){tn(t),dr(e,"nums"),Ue(n,"passZero");let r=t,o=new Array(e.length).fill(n?r.ZERO:void 0),i=e.reduce((a,c,f)=>r.is0(c)?a:(o[f]=a,r.mul(a,c)),r.ONE),s=r.inv(i);return e.reduceRight((a,c,f)=>r.is0(c)?a:(o[f]=r.mul(a,o[f]),r.mul(a,c)),s),o}function va(t,e){tn(t);let n=t;Po(n.ORDER,"FpLegendre");let r=(n.ORDER-G)/Et,o=n.pow(e,r),i=n.eql(o,n.ONE),s=n.eql(o,n.ZERO),a=n.eql(o,n.neg(n.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function $l(t,e){if(e!==void 0&&Co(e),t<=Q)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let n=en(t);if(e!==void 0&&e<n)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${n})`);let r=e!==void 0?e:n,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}var Ia=new WeakMap,br=class{ORDER;BITS;BYTES;isLE;ZERO=Q;ONE=G;_lengths;_mod;constructor(e,n={}){if(e<=G)throw new Error("invalid field: expected ORDER > 1, got "+e);let r;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(r=n.BITS),typeof n.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:n.sqrt,enumerable:!0}),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=Object.freeze(n.allowedLengths.slice())),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));let{nBitLength:o,nByteLength:i}=$l(e,r);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return ge(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return Q<=e&&e<this.ORDER}is0(e){return e===Q}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&G)===G}neg(e){return ge(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return ge(e*e,this.ORDER)}add(e,n){return ge(e+n,this.ORDER)}sub(e,n){return ge(e-n,this.ORDER)}mul(e,n){return ge(e*n,this.ORDER)}pow(e,n){return Na(e,n,this.ORDER)}div(e,n){return ge(e*Ta(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return Ta(e,this.ORDER)}sqrt(e){let n=Ia.get(this);return n||Ia.set(this,n=Hl(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?No(e,this.BYTES):gr(e,this.BYTES)}fromBytes(e,n=!1){J(e);let{_lengths:r,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Ho(e):Ve(e);if(a&&(c=ge(c,s)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Oo(this,e,!0)}cmov(e,n,r){return Ue(r,"condition"),r?n:e}};function nn(t,e={}){return Object.freeze(br.prototype),new br(t,e)}function Ma(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=G)throw new Error("field order must be greater than 1");let e=en(t-G);return Math.ceil(e/8)}function yr(t){let e=Ma(t);return e+Math.ceil(e/2)}function wr(t,e,n=!1){J(t);let r=t.length,o=Ma(e),i=Math.max(yr(e),16);if(r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);let s=n?Ho(t):Ve(t),a=ge(s,e-G)+G;return n?No(a,o):gr(a,o)}var Uo=BigInt(0),Sn=BigInt(1),Dl=BigInt(4),Lo=16,Pa=128,_l=5,Oa=2**31;function rn(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);$t(e.fromAffine,"Point.fromAffine"),$t(e.fromBytes,"Point.fromBytes"),$t(e.fromHex,"Point.fromHex"),yt(e.BASE,"Point.BASE"),yt(e.ZERO,"Point.ZERO"),tn(e.Fp),tn(e.Fn)}function Fa(t,e){rn(t),Ua(e,t);let n=Oo(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function Ml(t,e,n=1){if(!Number.isSafeInteger(t)||t<n||t>e)throw new Error("invalid window size, expected ["+n+".."+e+"], got W="+t)}function Pl(t,e){let n=t*(4*e+128);if(n>Oa)throw new Error("invalid window size: table would need ~"+Math.ceil(n/2**20)+" MiB, max "+Oa/2**20+" MiB")}function Vo(t,e){if(t!==void 0){$t(t,"randomBytes");try{let n=t(e);if(!Qt(n)||n.length!==e)return}catch{return}return t}}function Ua(t,e){dr(t,"points"),t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function Ol(t,e,n){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,o)=>{if(!(n===void 0?e.isValid(r):wt(r)&&r<n))throw new Error("invalid scalar at index "+o)})}var Va=new WeakMap;function Fo(t){return Va.get(t)||1}function Ll(t,e){let n=t.double(),r=[t];for(let o=1;o<e;o++)r.push(r[o-1].add(n));return r}function Fl(t,e){let n=2**e,r=n/2,o=BigInt(n-1),i=[];for(;t>Uo;){let s=0;t&Sn&&(s=Number(t&o),s>=r&&(s-=n),t-=BigInt(s)),i.push(s),t>>=Sn}return i}function Ul(t,e,n){let r=2**e,o=r/2,i=BigInt(r-1),s=BigInt(e),a=[];for(let c=0;c<n;c++){let f=Number(t&i);t>>=s,f>o&&(f-=r,t+=Sn),a.push(f)}if(t!==Uo)throw new Error("invalid wnaf");return a}function Vl(t,e,n){let r=0;for(let i of n)r=Math.max(r,i.length);let o=t;for(let i=r-1;i>=0;i--){i!==r-1&&(o=o.double());for(let s=0;s<n.length;s++){let a=n[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var xr=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){rn(e),this.randomBytes=Vo(n,Lo),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,n,r){let o=Math.ceil(r/n)+1,i=2**(n-1),s=[],a=e;for(let c=0;c<o;c++){let f=a;for(let u=0;u<i;u++)s.push(f),f=f.add(a);a=s[s.length-1].double()}return{W:n,bits:r,windows:o,comp:s}}wnafCachedCT(e,n){let{W:r,windows:o,comp:i}=e,s=2**(r-1),a=Ul(n,r,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let l=a[u],d=u*s,h=Math.abs(l)-1,m=i[d];for(let b=1;b<s;b++)m=b===h?i[d+b]:m;let y=m.negate();l===0?f=f.add(i[d]):c=c.add(l<0?y:m)}return{p:c,f}}getWnafPrecomputes(e,n,r,o){let i=this.wnafPrecomputes.get(n),s=i?.find(a=>a.W===e&&a.bits===r);return s||(s=this.buildWnafTable(n,e,r),typeof o=="function"&&(s={...s,comp:o(s.comp)}),i||(i=[],this.wnafPrecomputes.set(n,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,n){if(this.assertPoint(e),!$o(n,Sn,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,r,o){let i=Fo(e);return i===1?this.fixedWindowCT(e,n,r):this.wnafCachedCT(this.getWnafPrecomputes(i,e,r,o),n)}mulCT(e,n,r){return this.validateMulInput(e,n),this.runCT(e,n,this.bits,r)}mulCTBlinded(e,n,r){if(this.validateMulInput(e,n),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+Pa,i=this.randomBytes(Lo);if(!Qt(i)||i.length!==Lo)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=n+Ve(i)*this.Point.Fn.ORDER;return this.runCT(e,s,o,r)}fixedWindowCT(e,n,r){let o=_l,i=1<<o,s=In(o),a=new Array(i);a[0]=this.ZERO;for(let u=1;u<i;u++)a[u]=a[u-1].add(e);let c=Math.ceil(r/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let h=0;h<o;h++)f=f.double();let l=Number(n>>BigInt(u*o)&s),d=a[0];for(let h=1;h<i;h++)d=h===l?a[h]:d;f=f.add(d)}return{p:f,f}}shouldBlind(e,n){return this.randomBytes===void 0?!1:n===Sn?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,n,r,o){return this.shouldBlind(e,r)?this.mulCTBlinded(e,n,o):this.mulCT(e,n,o)}mulUnsafe(e,n,r){if(this.assertPoint(e),!wt(n))throw new Error("invalid scalar");let o=Fo(e);if(o===1||n>=this.Point.Fn.ORDER)return Er(this.Point,[e],[n],!0);let i=this.getWnafPrecomputes(o,e,this.bits,r);return this.wnafCachedCT(i,n).p}setWindowSize(e,n){this.assertPoint(e),Ml(n,this.bits);let r=Math.ceil((this.bits+Pa)/n)+1;Pl(r*2**(n-1),this.Point.Fp.BYTES),Va.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Fo(e)!==1}};function Er(t,e,n,r=!1){if(rn(t),Ua(e,t),Ue(r,"allowOversized"),Ol(n,t.Fn,r?t.Fn.ORDER**Dl:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(s=>Ll(s,4)),i=n.map(s=>Fl(s,4));return Vl(t.ZERO,o,i)}function La(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return tn(e),e}else return nn(t,{isLE:n})}function ja(t,e,n={},r){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);xt(n);for(let c of["p","n","h"]){let f=e[c];if(!(wt(f)&&f!==Uo))throw new Error(`CURVE.${c} must be positive bigint`)}let o=La(e.p,n.Fp,r),i=La(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function Ka(t,e){return function(r){let o=t(r);return{secretKey:o,publicKey:e(o)}}}g();g();var kr=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(ir(e),Fe(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Tn(o)}update(e){return Jt(this),this.iHash.update(e),this}digestInto(e){Jt(this),sr(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ga=(()=>{let t=((e,n,r)=>new kr(e,n).update(r).digest());return t.create=(e,n)=>new kr(e,n),t})();g();var jl=BigInt(0),jo=class extends Error{constructor(e=""){super(e)}},et={Err:jo,_tlv:{encode:(t,e)=>{let{Err:n}=et;if(Dt(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(ka(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let r=e.length/2,o=vn(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");let i=r>127?vn(o.length/2|128):"";return vn(t)+i+o+e},decode(t,e){let{Err:n}=et;e=J(e,void 0,"DER data");let r=0;if(t<0||t>255)throw new n("tlv.decode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");let o=e[r++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");let f=e.subarray(r,r+c);if(f.length!==c)throw new n("tlv.decode: length bytes not complete");if(f[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(r+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}let a=e.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+s)}}},_int:{encode(t){let{Err:e}=et;if(mr(t),t<jl)throw new e("integer: negative integers are not allowed");let n=vn(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){let{Err:e}=et;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ve(t)}},toSig(t,e){let{Err:n,_int:r,_tlv:o}=et;if(e!==void 0&&(Dt(e,"maxScalarBytes"),e<1))throw new n("invalid signature: maxScalarBytes must be positive");let i=J(t,void 0,"signature"),{v:s,l:a}=o.decode(48,i);if(a.length)throw new n("invalid signature: left bytes after parsing");let{v:c,l:f}=o.decode(2,s),{v:u,l}=o.decode(2,f);if(l.length)throw new n("invalid signature: left bytes after parsing");if(e!==void 0&&(c.length>e||u.length>e))throw new n("invalid signature: integer too large");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:n}=et;xt(t,{r:"bigint",s:"bigint"},{},"sig");let r=e.encode(2,n.encode(t.r)),o=e.encode(2,n.encode(t.s)),i=r+o;return e.encode(48,i)}},Br=(Object.freeze(et._tlv),Object.freeze(et._int),Object.freeze(et));var za=(t,e)=>(t+(t>=0?e:-e)/Wa)/e;function Kl(t,e,n){Do("scalar",t,tt,n);let[[r,o],[i,s]]=e,a=za(s*t,n),c=za(-o*t,n),f=t-a*r-c*i,u=-a*o-c*s,l=f<tt,d=u<tt;l&&(f=-f),d&&(u=-u);let h=In(Math.ceil(en(n)/2))+_t;if(f<tt||f>=h||u<tt||u>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:f,k2neg:d,k2:u}}function zo(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ko(t,e){xt(t);let n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return Ue(n.lowS,"lowS"),Ue(n.prehash,"prehash"),n.format!==void 0&&zo(n.format),n}var tt=BigInt(0),_t=BigInt(1),Wa=BigInt(2),Go=BigInt(3),Gl=BigInt(4);function Ar(t,e={}){let n=ja("weierstrass",t,e),r=n.Fp,o=n.Fn,i=n.CURVE,{h:s,n:a}=i;xt(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f,clearCofactor:u,isTorsionFree:l,fromBytes:d,toBytes:h}=e,m=e.randomBytes===void 0?pr:e.randomBytes;if(c&&(!r.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let y=c?{beta:c.beta,basises:c.basises.map(I=>[...I])}:void 0,b=Ya(r,o);function p(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function A(I,w,k){if(w.is0()){if(!f)throw new Error("bad point: ZERO");return Uint8Array.of(0)}let{x:T,y:C}=w.toAffine(),R=r.toBytes(T);if(Ue(k,"isCompressed"),k){p();let N=!r.isOdd(C);return Qe(qa(N),R)}else return Qe(Uint8Array.of(4),R,r.toBytes(C))}function B(I){J(I,void 0,"Point");let{publicKey:w,publicKeyUncompressed:k}=b,T=I.length,C=I[0],R=I.subarray(1);if(f&&T===1&&C===0)return{x:r.ZERO,y:r.ZERO};if(T===w&&(C===2||C===3)){let N=r.fromBytes(R);if(!r.isValid(N))throw new Error("bad point: is not on curve, wrong x");let D=S(N),_;try{_=r.sqrt(D)}catch(Y){let z=Y instanceof Error?": "+Y.message:"";throw new Error("bad point: is not on curve, sqrt error"+z)}p();let j=r.isOdd(_);return(C&1)===1!==j&&(_=r.neg(_)),{x:N,y:_}}else if(T===k&&C===4){let N=r.BYTES,D=r.fromBytes(R.subarray(0,N)),_=r.fromBytes(R.subarray(N,N*2));if(!K(D,_))throw new Error("bad point: is not on curve");return{x:D,y:_}}else throw new Error(`bad point: got length ${T}, expected compressed=${w} or uncompressed=${k}`)}let P=h===void 0?A:h,V=d===void 0?B:d,H=r.mul(i.b,Go),U=r.is0(i.a)?I=>r.ZERO:I=>r.mul(i.a,I);function S(I){let w=r.sqr(I),k=r.mul(w,I);return r.add(r.add(k,r.mul(I,i.a)),i.b)}function K(I,w){let k=r.sqr(w),T=S(I);return r.eql(k,T)}if(!K(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let L=r.mul(r.pow(i.a,Go),Gl),ce=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(L,ce)))throw new Error("bad curve params: a or b");function q(I,w,k=!1){if(!r.isValid(w)||k&&r.is0(w))throw new Error(`bad point coordinate ${I}`);return typeof w=="object"&&w!==null?r.create(w):w}function ee(I){if(!(I instanceof M))throw new Error("Weierstrass Point expected")}function Ne(I){if(!y||!y.basises)throw new Error("no endo");return Kl(I,y.basises,o.ORDER)}function ie(I,w,k,T){if(!o.isValid(T))throw new RangeError("invalid scalar: out of range");if(y){let{k1neg:C,k1:R,k2neg:N,k2:D}=Ne(T),_=new M(r.mul(k.X,y.beta),k.Y,k.Z);I.push(C?k.negate():k,N?_.negate():_),w.push(R,D)}else I.push(k),w.push(T)}let $e=new WeakSet;class M{static BASE=new M(i.Gx,i.Gy,r.ONE);static ZERO=new M(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=o;X;Y;Z;constructor(w,k,T){this.X=q("x",w),this.Y=q("y",k,!0),this.Z=q("z",T),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){let{x:k,y:T}=w||{};if(!w||!r.isValid(k)||!r.isValid(T))throw new Error("invalid affine point");if(w instanceof M)throw new Error("projective point not allowed");return r.is0(k)&&r.is0(T)?M.ZERO:new M(k,T,r.ONE)}static fromBytes(w){let k=M.fromAffine(V(J(w,void 0,"point")));return k.assertValidity(),k}static fromHex(w){return M.fromBytes(hr(w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=6,k=!0){return De.setWindowSize(this,w),k||this.multiply(Go),this}assertValidity(){let w=this;if(w.is0()){if(f&&r.is0(w.X)&&r.eql(w.Y,r.ONE)&&r.is0(w.Z))return;throw new Error("bad point: ZERO")}if($e.has(w))return;let{x:k,y:T}=w.toAffine();if(!r.isValid(k)||!r.isValid(T))throw new Error("bad point: x or y not field elements");if(!K(k,T))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");$e.add(w)}hasEvenY(){let{y:w}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(w)}equals(w){ee(w);let{X:k,Y:T,Z:C}=this,{X:R,Y:N,Z:D}=w,_=r.eql(r.mul(k,D),r.mul(R,C)),j=r.eql(r.mul(T,D),r.mul(N,C));return _&&j}negate(){return new M(this.X,r.neg(this.Y),this.Z)}double(){let{X:w,Y:k,Z:T}=this,C=r.ZERO,R=r.ZERO,N=r.ZERO,D=r.mul(w,w),_=r.mul(k,k),j=r.mul(T,T),F=r.mul(w,k);return F=r.add(F,F),N=r.mul(w,T),N=r.add(N,N),C=U(N),R=r.mul(H,j),R=r.add(C,R),C=r.sub(_,R),R=r.add(_,R),R=r.mul(C,R),C=r.mul(F,C),N=r.mul(H,N),j=U(j),F=r.sub(D,j),F=U(F),F=r.add(F,N),N=r.add(D,D),D=r.add(N,D),D=r.add(D,j),D=r.mul(D,F),R=r.add(R,D),j=r.mul(k,T),j=r.add(j,j),D=r.mul(j,F),C=r.sub(C,D),N=r.mul(j,_),N=r.add(N,N),N=r.add(N,N),new M(C,R,N)}add(w){ee(w);let{X:k,Y:T,Z:C}=this,{X:R,Y:N,Z:D}=w,_=r.ZERO,j=r.ZERO,F=r.ZERO,Y=r.mul(k,R),z=r.mul(T,N),te=r.mul(C,D),Be=r.add(k,T),W=r.add(R,N);Be=r.mul(Be,W),W=r.add(Y,z),Be=r.sub(Be,W),W=r.add(k,C);let Z=r.add(R,D);return W=r.mul(W,Z),Z=r.add(Y,te),W=r.sub(W,Z),Z=r.add(T,C),_=r.add(N,D),Z=r.mul(Z,_),_=r.add(z,te),Z=r.sub(Z,_),F=U(W),_=r.mul(H,te),F=r.add(_,F),_=r.sub(z,F),F=r.add(z,F),j=r.mul(_,F),z=r.add(Y,Y),z=r.add(z,Y),te=U(te),W=r.mul(H,W),z=r.add(z,te),te=r.sub(Y,te),te=U(te),W=r.add(W,te),Y=r.mul(z,W),j=r.add(j,Y),Y=r.mul(Z,W),_=r.mul(Be,_),_=r.sub(_,Y),Y=r.mul(Be,z),F=r.mul(Z,F),F=r.add(F,Y),new M(_,j,F)}subtract(w){return ee(w),this.add(w.negate())}is0(){return this.equals(M.ZERO)}multiply(w){if(!o.isValidNot0(w))throw new RangeError("invalid scalar: out of range");let{p:k,f:T}=De.mulSecret(this,w,s,me);return me([k,T])[0]}multiplyUnsafe(w){let k=this,T=w;if(!o.isValid(T))throw new RangeError("invalid scalar: out of range");if(T===tt||k.is0())return M.ZERO;if(T===_t)return k;if(De.hasWindowSize(this))return De.mulUnsafe(k,T,me);let C=[],R=[];return ie(C,R,k,T),Er(M,C,R)}mulAddUnsafe(w,k,T){ee(k);let C=[],R=[];return ie(C,R,this,w),ie(C,R,k,T),Er(M,C,R)}toAffine(w){let k=this,T=w;if(T!=null&&!r.isValid(T))throw new RangeError('"invertedZ" expected valid field element');let{X:C,Y:R,Z:N}=k;if(r.eql(N,r.ONE))return{x:C,y:R};let D=k.is0();T==null&&(T=D?r.ONE:r.inv(N));let _=r.mul(C,T),j=r.mul(R,T),F=r.mul(N,T);if(D)return{x:r.ZERO,y:r.ZERO};if(!r.eql(F,r.ONE))throw new Error("invZ was invalid");return{x:_,y:j}}isTorsionFree(){return s===_t?!0:l?l(M,this):De.mulUnsafe(this,a).is0()}clearCofactor(){return s===_t?this:u?u(M,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===_t?this.is0():this.clearCofactor().is0()}toBytes(w=!0){return Ue(w,"isCompressed"),this.assertValidity(),P(M,this,w)}toHex(w=!0){return Ro(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let me=I=>Fa(M,I),De=new xr(M,m);return De.bits>=6&&M.BASE.precompute(6),Object.freeze(M.prototype),Object.freeze(M),M}function qa(t){return Uint8Array.of(t?2:3)}function Ya(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function zl(t,e={}){rn(t);let{Fn:n}=t,r=e.randomBytes===void 0?pr:e.randomBytes,o=Object.assign(Ya(t.Fp,n),{seed:Math.max(yr(n.ORDER),16)});function i(h){try{let m=n.fromBytes(h);return n.isValidNot0(m)}catch{return!1}}function s(h,m){let{publicKey:y,publicKeyUncompressed:b}=o;try{let p=h.length;return m===!0&&p!==y||m===!1&&p!==b?!1:!t.fromBytes(h).is0()}catch{return!1}}function a(h){return h=h===void 0?r(o.seed):h,wr(J(h,o.seed,"seed"),n.ORDER)}function c(h,m=!0){return t.BASE.multiply(n.fromBytes(h)).toBytes(m)}function f(h){let{secretKey:m,publicKey:y,publicKeyUncompressed:b}=o,p=n._lengths;if(!Qt(h))return;let A=J(h,void 0,"key").length,B=A===y||A===b,P=A===m||!!p?.includes(A);if(!(B&&P))return B}function u(h,m,y=!0){if(f(h)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let b=n.fromBytes(h),p=t.fromBytes(m);if(p.is0())throw new Error("invalid public key: point at infinity");return p.multiply(b).toBytes(y)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},d=Ka(a,c);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:d,Point:t,utils:l,lengths:o})}function Tr(t,e,n={}){rn(t);let r=e;ir(r),xt(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},n),i=o.randomBytes===void 0?pr:o.randomBytes,s=o.hmac===void 0?(I,w)=>Ga(r,I,w):o.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:u}=c,l=yr(f),d=Vo(i,l),{keygen:h,getPublicKey:m,getSharedSecret:y,utils:b,lengths:p}=zl(t,o),A={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},B=f*Wa+_t<a.ORDER;function P(I){let w=f>>_t;return I>w}function V(I,w){if(!c.isValidNot0(w))throw new Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return w}function H(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function U(I,w,k){return H(),(I===k?0:2)|Number(a.isOdd(w))}function S(){if(B)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function K(I,w){zo(w);let k=p.signature,T=w==="compact"?k:w==="recovered"?k+1:void 0;return J(I,T)}class L{r;s;recovery;constructor(w,k,T){if(this.r=V("r",w),this.s=V("s",k),T!=null){if(S(),![0,1,2,3].includes(T))throw new Error("invalid recovery id");this.recovery=T}Object.freeze(this)}static fromBytes(w,k=A.format){K(w,k);let T;if(k==="der"){if(w.length>2*c.BYTES+16)throw new Br.Err("invalid signature: DER signature too long");let{r:D,s:_}=Br.toSig(J(w),c.BYTES+1);return new L(D,_)}k==="recovered"&&(T=w[0],k="compact",w=w.subarray(1));let C=p.signature/2,R=w.subarray(0,C),N=w.subarray(C,C*2);return new L(c.fromBytes(R),c.fromBytes(N),T)}static fromHex(w,k){return this.fromBytes(hr(w),k)}assertRecovery(){let{recovery:w}=this;if(w==null)throw new Error("invalid recovery id: must be present");return w}addRecoveryBit(w){return new L(this.r,this.s,w)}recoverPublicKey(w){let{r:k,s:T}=this,C=this.assertRecovery(),R=C===2||C===3?k+f:k;if(!a.isValid(R))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let N=a.toBytes(R),D=t.fromBytes(Qe(qa((C&1)===0),N)),_=c.inv(R),j=q(J(w,void 0,"msgHash")),F=c.create(-j*_),Y=c.create(T*_),z=t.BASE.mulAddUnsafe(F,D,Y);if(z.is0())throw new Error("invalid recovery: point at infinify");return z.assertValidity(),z}hasHighS(){return P(this.s)}toBytes(w=A.format){if(zo(w),w==="der")return hr(Br.hexFromSig(this));let{r:k,s:T}=this,C=c.toBytes(k),R=c.toBytes(T);return w==="recovered"?(S(),Qe(Uint8Array.of(this.assertRecovery()),C,R)):Qe(C,R)}toHex(w){return Ro(this.toBytes(w))}}Object.freeze(L.prototype),Object.freeze(L);let ce=o.bits2int===void 0?function(w){if(w.length>8192)throw new Error("input is too large");let k=Ve(w),T=w.length*8-u;return T>0?k>>BigInt(T):k}:o.bits2int,q=o.bits2int_modN===void 0?function(w){return c.create(ce(w))}:o.bits2int_modN,ee=In(u);function Ne(I){return Do("num < 2^"+u,I,tt,ee),c.toBytes(I)}function ie(I,w){return J(I,void 0,"message"),w?J(r(I),void 0,"prehashed message"):I}function $e(I,w,k){let{lowS:T,prehash:C,extraEntropy:R}=Ko(k,A);I=ie(I,C);let N=q(I),D=c.fromBytes(w);if(!c.isValidNot0(D))throw new Error("invalid private key");let _=[Ne(D),Ne(N)];if(R!=null&&R!==!1){let z=R===!0?i(p.secretKey):R;_.push(J(z,void 0,"extraEntropy"))}let j=Qe(..._),F=N;function Y(z){let te=ce(z);if(!c.isValidNot0(te))return;let Be=t.BASE.multiply(te).toAffine(),W=c.create(Be.x);if(W===tt)return;let Z;if(d!==void 0){let bn=Ve(wr(d(l),f)),Yf=c.inv(c.mul(bn,te)),Zf=c.mul(bn,F),Xf=c.mul(bn,D);Z=c.create(Yf*c.create(Zf+Xf*W))}else{let bn=$a(te,f);Z=c.create(bn*c.create(F+W*D))}if(Z===tt)return;let qr=U(Be.x,Be.y,W),as=Z;return T&&P(Z)&&(as=c.neg(Z),qr^=1),new L(W,as,B?void 0:qr)}return{seed:j,k2sig:Y}}function M(I,w,k={}){let{seed:T,k2sig:C}=$e(I,w,k);return Aa(r.outputLen,c.BYTES,s)(T,C).toBytes(k.format)}function me(I,w,k,T={}){let{lowS:C,prehash:R,format:N}=Ko(T,A);if(k=J(k,void 0,"publicKey"),w=ie(w,R),!Qt(I)){let D=I instanceof L?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+D)}K(I,N);try{let D=L.fromBytes(I,N),_=t.fromBytes(k);if(_.is0()||C&&D.hasHighS())return!1;let{r:j,s:F}=D,Y=q(w),z=c.inv(F),te=c.create(Y*z),Be=c.create(j*z),W=t.BASE.mulAddUnsafe(te,_,Be);if(W.is0())return!1;let Z=W.toAffine();return!(c.create(Z.x)!==j||N==="recovered"&&D.recovery!==U(Z.x,Z.y,j))}catch{return!1}}function De(I,w,k={}){let{prehash:T}=Ko(k,A);return w=ie(w,T),L.fromBytes(I,"recovered").recoverPublicKey(w).toBytes()}return Object.freeze({keygen:h,getPublicKey:m,getSharedSecret:y,utils:b,lengths:p,Point:t,sign:M,verify:me,recoverPublicKey:De,Signature:L,hash:r})}var Wl={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var ql=Ar(Wl),Za=Tr(ql,ur);var qo=globalThis.crypto,Wo=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=O.create();else if(n==="sha512")this.hasher=rr.create();else throw new Error(`createHash: unsupported algorithm ${e} in the browser verifier`)}update(e){return this.hasher.update(typeof e=="string"?new TextEncoder().encode(e):e),this}digest(e){let n=this.hasher.digest(),r=E.Buffer.from(n);return e===void 0?r:r.toString(e)}};function vr(t){return new Wo(t)}function Yo(t){let e=[];return{update(n){return e.push(n),this},verify(n,r){try{let o=n instanceof Uint8Array?n:n.key,i=o.subarray(o.length-65);if(i.length!==65||i[0]!==4)return!1;let s=0;for(let f of e)s+=f.length;let a=new Uint8Array(s),c=0;for(let f of e)a.set(f,c),c+=f.length;return Za.verify(r,O(a),i,{format:"der",prehash:!1,lowS:!1})}catch{return!1}}}}g();function ye(t){let e=Xa(t);return new TextEncoder().encode(e)}function Xa(t){return JSON.stringify(Zo(t))}function Zo(t){if(t===null||typeof t!="object"){if(typeof t>"u")throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");if(typeof t=="function"||typeof t=="symbol")throw new TypeError(`bitgraph-core/canonical: ${typeof t} values are not serializable to canonical JSON`);if(typeof t=="bigint")throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; convert to string (decimal) before canonicalizing");return t}if(Array.isArray(t))return t.map(Zo);let e={};for(let n of Object.keys(t).sort()){let r=t[n];typeof r>"u"||(e[n]=Zo(r))}return e}function Ir(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}async function Sr(t){let{proof:e,bytes:n,trustAnchors:r,context:o}=t,i=await Ja(e,n,r,o??Xo);return i===null?{valid:!0}:od(i)}async function we(t){let{proof:e,trustAnchors:n,context:r}=t,o=await Ja(e,void 0,n,r??Xo);return o===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:o}}async function Ja(t,e,n,r){let o=Zl(t);if(o!==null)return o;let i=e===void 0?void 0:O(e),s;try{s=on(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(i!==void 0&&!Ir(i,s))return"artifact digest mismatch: the provided bytes do not match the committed digest";let a;try{a=on(t.signer.publicKeyB64)}catch{return"signer.publicKeyB64 is not valid base64"}if(a.length!==32)return`signer.publicKeyB64 decodes to ${a.length} bytes; expected 32 (Ed25519)`;let c={version:t.version,artifact:t.artifact,commit:t.commit,publicKeyB64:t.signer.publicKeyB64,enforcement:t.environment.enforcement,measurement:t.environment.measurement};t.environment.attestation!==void 0&&(c.attestationFormat=t.environment.attestation.format),t.agency!==void 0&&(c.actor=t.agency.actor),t.policy!==void 0&&(c.policy=t.policy),t.attribution!==void 0&&(c.attribution=t.attribution);let f=ye(c),u;try{u=on(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(u.length!==64)return`signer.signatureB64 decodes to ${u.length} bytes; expected 64 (Ed25519)`;let l;try{l=await bo(u,f,a)}catch(h){return`signature verification error: ${h instanceof Error?h.message:String(h)}`}if(!l)return"signature verification failed: signature does not match";if(t.agency!==void 0){let h=Ql(t);if(h!==null)return h}if(t.slotAllocation!==void 0){let h=await ed(t);if(h!==null)return h}let d=null;if(t.commit.epochLink!==void 0){let{error:h,pending:m}=rd(t,r);if(h!==null)return h;d=m}if(n!==void 0){let h=Xl(t,n);if(h!==null)return h}return d!==null&&r.consumedPredecessors.set(d.key,d.toEpochId),null}var Yl=new Set(["stub","hw-key","measured-tee"]);function Zl(t){if(t===null||typeof t!="object")return"proof must be an object";let e=t;if(e.version!=="bitgraph/1")return`unsupported proof version: ${String(e.version)}`;if(!Cn(e.artifact))return"proof.artifact is missing or not an object";let n=e.artifact;if(n.hashAlg!=="sha256")return`unsupported hashAlg: ${String(n.hashAlg)}`;if(typeof n.digestB64!="string"||n.digestB64.length===0)return"proof.artifact.digestB64 must be a non-empty string";if(!Cn(e.commit))return"proof.commit is missing or not an object";let r=e.commit;if(typeof r.nonceB64!="string"||r.nonceB64.length===0)return"proof.commit.nonceB64 must be a non-empty string";if(r.counter!==void 0&&typeof r.counter!="string")return"proof.commit.counter must be a string when present";if(r.time!==void 0&&(typeof r.time!="number"||!Number.isFinite(r.time)||r.time<0))return"proof.commit.time must be a non-negative finite number when present";if(r.prevB64!==void 0&&typeof r.prevB64!="string")return"proof.commit.prevB64 must be a string when present";if(r.epochId!==void 0&&typeof r.epochId!="string")return"proof.commit.epochId must be a string when present";if(!Cn(e.signer))return"proof.signer is missing or not an object";let o=e.signer;if(typeof o.publicKeyB64!="string"||o.publicKeyB64.length===0)return"proof.signer.publicKeyB64 must be a non-empty string";if(typeof o.signatureB64!="string"||o.signatureB64.length===0)return"proof.signer.signatureB64 must be a non-empty string";if(!Cn(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!Yl.has(i.enforcement))return"proof.environment.enforcement must be one of: stub, hw-key, measured-tee";if(typeof i.measurement!="string"||i.measurement.length===0)return"proof.environment.measurement must be a non-empty string";if(i.attestation!==void 0){if(!Cn(i.attestation))return"proof.environment.attestation must be an object when present";let s=i.attestation;if(typeof s.format!="string"||s.format.length===0)return"proof.environment.attestation.format must be a non-empty string";if(typeof s.reportB64!="string"||s.reportB64.length===0)return"proof.environment.attestation.reportB64 must be a non-empty string"}return null}function Xl(t,e){if(e.requireEnforcement!==void 0&&t.environment.enforcement!==e.requireEnforcement)return`enforcement tier "${t.environment.enforcement}" does not meet required tier "${e.requireEnforcement}"`;if(e.allowedMeasurements!==void 0&&e.allowedMeasurements.length>0&&!e.allowedMeasurements.includes(t.environment.measurement))return`measurement "${t.environment.measurement}" is not in the allowed set`;if(e.allowedPublicKeys!==void 0&&e.allowedPublicKeys.length>0&&!e.allowedPublicKeys.includes(t.signer.publicKeyB64))return"proof public key is not in the allowed set";if(e.requireAttestation===!0&&t.environment.attestation===void 0)return"policy requires attestation but proof has none";if(e.requireAttestationFormat!==void 0&&e.requireAttestationFormat.length>0){if(t.environment.attestation===void 0)return"policy requires attestation format but proof has no attestation";if(!e.requireAttestationFormat.includes(t.environment.attestation.format))return`attestation format "${t.environment.attestation.format}" is not in the required set`}if(e.minCounter!==void 0||e.maxCounter!==void 0){if(t.commit.counter===void 0)return"policy requires a counter but proof has none";let n;try{n=BigInt(t.commit.counter)}catch{return"could not parse proof counter value as integer"}if(e.minCounter!==void 0){let r;try{r=BigInt(e.minCounter)}catch{return"could not parse policy minCounter as integer"}if(n<r)return`counter ${t.commit.counter} is below minimum ${e.minCounter}`}if(e.maxCounter!==void 0){let r;try{r=BigInt(e.maxCounter)}catch{return"could not parse policy maxCounter as integer"}if(n>r)return`counter ${t.commit.counter} is above maximum ${e.maxCounter}`}}if(e.minTime!==void 0||e.maxTime!==void 0){if(t.commit.time===void 0)return"policy requires a time field but proof has none";if(e.minTime!==void 0&&t.commit.time<e.minTime)return`commit time ${t.commit.time} is before minimum ${e.minTime}`;if(e.maxTime!==void 0&&t.commit.time>e.maxTime)return`commit time ${t.commit.time} is after maximum ${e.maxTime}`}if(e.requireEpochId===!0&&(t.commit.epochId===void 0||t.commit.epochId.length===0))return"policy requires epochId but proof has none";if(e.requireActor===!0&&t.agency===void 0)return"policy requires actor (agency) but proof has none";if(e.allowedActorKeyIds!==void 0&&e.allowedActorKeyIds.length>0){if(t.agency===void 0)return"policy requires allowed actor key ID but proof has no agency";if(!e.allowedActorKeyIds.includes(t.agency.actor.keyId))return"actor key ID is not in the allowed set"}if(e.allowedActorProviders!==void 0&&e.allowedActorProviders.length>0){if(t.agency===void 0)return"policy requires allowed actor provider but proof has no agency";if(!e.allowedActorProviders.includes(t.agency.actor.provider))return`actor provider "${t.agency.actor.provider}" is not in the allowed set`}if(e.allowedOrigins!==void 0&&e.allowedOrigins.length>0){if(t.agency===void 0)return"policy requires an allowed origin but proof has no agency";let n=t.agency.authorization;if(!("format"in n)||n.format!=="webauthn")return"policy requires an allowed WebAuthn origin but the authorization is not WebAuthn";let r;try{r=JSON.parse(n.clientDataJSON).origin}catch{r=void 0}if(typeof r!="string"||!e.allowedOrigins.includes(r))return`WebAuthn origin "${r??"(none)"}" is not in the allowed set`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (the reserved position's record) but proof has none":null}function Jl(t,e){if(typeof t!="string"||t.length===0)return"agency: clientDataJSON missing origin field";let n;try{n=new URL(t).hostname.toLowerCase()}catch{return"agency: clientDataJSON origin is not a valid origin"}if(!n)return"agency: clientDataJSON origin has no host";let r=e.subarray(0,32).toString("hex"),o=n.split("."),i=[];for(let a=0;a<o.length;a++){let c=o.slice(a).join(".");if(a>0&&o.length-a<2)break;i.push(c)}return i.some(a=>vr("sha256").update(a,"utf8").digest("hex")===r)?null:"agency: authenticatorData rpIdHash does not match the origin's domain"}function Ql(t){let e=t.agency,{actor:n,authorization:r}=e,o="format"in r&&r.format==="webauthn";if(typeof n.keyId!="string"||n.keyId.length===0)return"agency.actor.keyId must be a non-empty string";if(typeof n.publicKeyB64!="string"||n.publicKeyB64.length===0)return"agency.actor.publicKeyB64 must be a non-empty string";if(n.algorithm!=="ES256")return`agency.actor.algorithm must be "ES256", got "${String(n.algorithm)}"`;if(typeof n.provider!="string"||n.provider.length===0)return"agency.actor.provider must be a non-empty string";if(r.purpose!=="bitgraph/commit-authorize/v1")return`agency.authorization.purpose must be "bitgraph/commit-authorize/v1", got "${String(r.purpose)}"`;if(typeof r.signatureB64!="string"||r.signatureB64.length===0)return"agency.authorization.signatureB64 must be a non-empty string";let i;try{i=E.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(vr("sha256").update(i).digest("hex")!==n.keyId)return"agency: actor.keyId does not match SHA-256 of public key";if(r.actorKeyId!==n.keyId)return"agency: authorization.actorKeyId does not match actor.keyId";if(r.artifactHash!==t.artifact.digestB64){let c=e.batchContext;if(!c||!Array.isArray(c.batchDigests)||!c.batchDigests.includes(t.artifact.digestB64)||c.batchDigests[0]!==r.artifactHash)return"agency: authorization.artifactHash does not match proof.artifact.digestB64"}let a;try{a=E.Buffer.from(r.signatureB64,"base64")}catch{return"agency.authorization.signatureB64 is not valid base64"}try{if(o){let c=r;if(typeof c.clientDataJSON!="string"||!c.clientDataJSON)return"agency: WebAuthn authorization missing clientDataJSON";if(typeof c.authenticatorDataB64!="string"||!c.authenticatorDataB64)return"agency: WebAuthn authorization missing authenticatorDataB64";let f;try{f=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(f.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${f.type}"`;if(!f.challenge)return"agency: clientDataJSON missing challenge field";let u=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;u.length%4;)u+="=";if(u!==r.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let l=E.Buffer.from(c.authenticatorDataB64,"base64");if(l.length<37)return"agency: authenticatorData too short";let d=l[32];if(!(d&1))return"agency: authenticatorData UP flag not set";if(!(d&4))return"agency: authenticatorData UV flag not set";let h=Jl(f.origin,l);if(h!==null)return h;let m=vr("sha256").update(E.Buffer.from(c.clientDataJSON,"utf8")).digest(),y=E.Buffer.concat([l,m]),b=Yo("SHA256");if(b.update(y),!b.verify({key:i,format:"der",type:"spki"},a))return"agency: WebAuthn P-256 signature verification failed"}else{let c={purpose:r.purpose,actorKeyId:r.actorKeyId,artifactHash:r.artifactHash,challenge:r.challenge,timestamp:r.timestamp};"protocolVersion"in r&&r.protocolVersion!==void 0&&(c.protocolVersion=r.protocolVersion);let f=E.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),u=Yo("SHA256");if(u.update(f),!u.verify({key:i,format:"der",type:"spki"},a))return"agency: P-256 signature verification failed"}}catch(c){return`agency: P-256 signature verification error: ${c instanceof Error?c.message:String(c)}`}return null}async function ed(t){let e=t.slotAllocation;if(e.version!=="bitgraph/slot/1")return`slotAllocation.version must be "bitgraph/slot/1", got "${String(e.version)}"`;if(typeof e.nonceB64!="string"||e.nonceB64.length===0)return"slotAllocation.nonceB64 must be a non-empty string";if(typeof e.counter!="string"||e.counter.length===0)return"slotAllocation.counter must be a non-empty string";if(e.time!==void 0&&(typeof e.time!="number"||!Number.isFinite(e.time)||e.time<0))return"slotAllocation.time must be a non-negative finite number when present";if(typeof e.epochId!="string"||e.epochId.length===0)return"slotAllocation.epochId must be a non-empty string";if(typeof e.publicKeyB64!="string"||e.publicKeyB64.length===0)return"slotAllocation.publicKeyB64 must be a non-empty string";if(typeof e.signatureB64!="string"||e.signatureB64.length===0)return"slotAllocation.signatureB64 must be a non-empty string";let n={version:e.version,nonceB64:e.nonceB64,counter:e.counter,...e.time!==void 0?{time:e.time}:{},epochId:e.epochId,publicKeyB64:e.publicKeyB64,...e.chainId?{chainId:e.chainId}:{}},r=ye(n),o,i;try{o=on(e.signatureB64),i=on(e.publicKeyB64)}catch{return"slotAllocation contains invalid base64"}if(o.length!==64)return`slotAllocation.signatureB64 decodes to ${o.length} bytes; expected 64 (Ed25519)`;if(i.length!==32)return`slotAllocation.publicKeyB64 decodes to ${i.length} bytes; expected 32 (Ed25519)`;let s;try{s=await bo(o,r,i)}catch(l){return`slotAllocation signature verification error: ${l instanceof Error?l.message:String(l)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let l of c)if(a.has(l))return`slotAllocation body contains forbidden field '${l}' \u2014 causal independence violated`;if(typeof t.commit.slotHashB64!="string"||t.commit.slotHashB64.length===0)return"commit.slotHashB64 must be present when slotAllocation is present";let f=O(r),u;try{u=on(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!Ir(f,u))return"commit.slotHashB64 does not match SHA-256 of the canonical position record: position binding broken";if(e.nonceB64!==t.commit.nonceB64)return"slotAllocation.nonceB64 does not match commit.nonceB64";if(typeof t.commit.slotCounter!="string"||t.commit.slotCounter.length===0)return"commit.slotCounter must be present when slotAllocation is present";if(t.commit.slotCounter!==e.counter)return"commit.slotCounter does not match slotAllocation.counter";if(t.commit.counter===void 0)return"commit.counter must be present for position ordering verification";try{let l=BigInt(e.counter),d=BigInt(t.commit.counter);if(l>=d)return`slotAllocation.counter (${e.counter}) must be less than commit.counter (${t.commit.counter})`}catch{return"could not parse the reserved or commit counter as an integer"}return e.publicKeyB64!==t.signer.publicKeyB64?"slotAllocation.publicKeyB64 does not match signer.publicKeyB64 \u2014 different enclave":t.commit.epochId!==void 0&&e.epochId!==t.commit.epochId?"slotAllocation.epochId does not match commit.epochId \u2014 different lifecycle":null}function sn(){return{consumedPredecessors:new Map}}var Xo=sn();function td(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=O(new TextEncoder().encode(e));return E.Buffer.from(n).toString("base64")}function nd(t){let e=t.commit.epochLink;if(typeof e.prevEpochId!="string"||e.prevEpochId.length===0)return"epochLink.prevEpochId must be a non-empty string";if(typeof e.prevPublicKeyB64!="string"||e.prevPublicKeyB64.length===0)return"epochLink.prevPublicKeyB64 must be a non-empty string";if(typeof e.prevCounter!="string"||e.prevCounter.length===0)return"epochLink.prevCounter must be a non-empty string";if(typeof e.prevProofHashB64!="string"||e.prevProofHashB64.length===0)return"epochLink.prevProofHashB64 must be a non-empty string";if(typeof e.toEpochId!="string"||e.toEpochId.length===0)return"epochLink.toEpochId must be a non-empty string";if(typeof e.toPublicKeyB64!="string"||e.toPublicKeyB64.length===0)return"epochLink.toPublicKeyB64 must be a non-empty string";try{BigInt(e.prevCounter)}catch{return"epochLink.prevCounter is not a valid decimal string"}return t.commit.epochId!==void 0&&e.toEpochId!==t.commit.epochId?`epochLink.toEpochId "${e.toEpochId}" does not match proof commit.epochId "${t.commit.epochId}" \u2014 successor binding broken`:e.toPublicKeyB64!==t.signer.publicKeyB64?"epochLink.toPublicKeyB64 does not match proof signer.publicKeyB64 \u2014 successor binding broken":e.prevEpochId===e.toEpochId?"epochLink.prevEpochId equals toEpochId \u2014 epoch link must cross epoch boundary":e.prevPublicKeyB64===e.toPublicKeyB64?"epochLink.prevPublicKeyB64 equals toPublicKeyB64 \u2014 epochs must have different keys":null}function rd(t,e){let n=nd(t);if(n!==null)return{error:n,pending:null};let r=t.commit.epochLink,o=td(r),i=e.consumedPredecessors.get(o);return i!==void 0?i!==r.toEpochId?{error:`FORK DETECTED: predecessor (epoch=${r.prevEpochId.slice(0,12)}..., counter=${r.prevCounter}) already consumed by epoch ${i.slice(0,12)}..., but this proof claims consumption by epoch ${r.toEpochId.slice(0,12)}... \u2014 single-successor invariant violated`,pending:null}:{error:null,pending:null}:{error:null,pending:{key:o,toEpochId:r.toEpochId}}}function nt(){Xo.consumedPredecessors.clear()}function od(t){return{valid:!1,reason:t}}function Cn(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function on(t){let e=E.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}g();function kt(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};e.attribution&&(o.attribution=e.attribution),r?.attestation&&(o.attestationFormat=r.attestation.format);let i=ye(o),s=O(i);return Qo(s)}var Qa=["proofHash","ethereum"];function Jo(t){let e=t,n=e;if(Qa.some(o=>Object.prototype.hasOwnProperty.call(e,o))){n={};for(let o of Object.keys(e))Qa.includes(o)||(n[o]=e[o])}let r=ye(n);return Qo(O(r))}function Qo(t){if(typeof E.Buffer<"u")return E.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function ec(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};r?.attestation!==void 0&&(o.attestationFormat=r.attestation.format);let i=e.agency;return i!==void 0&&(o.actor=i.actor),e.policy!==void 0&&(o.policy=e.policy),e.attribution!==void 0&&(o.attribution=e.attribution),o}function an(t){return Qo(O(ye(ec(t))))}g();g();var id=new Uint8Array([0]),sd=new Uint8Array([1]);function tc(...t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}function Rn(t){return O(tc(id,t))}function ei(t,e){return O(tc(sd,t,e))}function Hn(t,e,n,r){if(!Number.isInteger(e)||!Number.isInteger(n)||n<1||e<0||e>=n||t.length!==32)return null;let o=e,i=n-1,s=t;for(let a of r){if(a.length!==32||i===0)return null;if((o&1)===1||o===i){if(s=ei(a,s),(o&1)===0)for(;(o&1)===0&&o!==0;)o>>>=1,i>>>=1}else s=ei(s,a);o>>>=1,i>>>=1}return i!==0?null:s}var ve="bitgraph-fuse/1",oc=(()=>{let t=new TextEncoder().encode(ve),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})(),ic=ve,$n="BGFUSE01",Dn=48,Bt="bitgraph-fuse/manifest.json",ot="bitgraph-fuse/original",cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nn={};for(let t=0;t<cn.length;t++)Nn[cn[t]]=t;function He(t){let e="";for(let n=0;n<t.length;n+=3){let r=t[n],o=n+1<t.length?t[n+1]:0,i=n+2<t.length?t[n+2]:0;e+=cn[r>>2]+cn[(r&3)<<4|o>>4],e+=n+1<t.length?cn[(o&15)<<2|i>>6]:"=",e+=n+2<t.length?cn[i&63]:"="}return e}function Ie(t){if(typeof t!="string"||t.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))return null;let e=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-e),r=0;for(let o=0;o<t.length;o+=4){let i=Nn[t[o]]<<18|Nn[t[o+1]]<<12|(t[o+2]==="="?0:Nn[t[o+2]])<<6|(t[o+3]==="="?0:Nn[t[o+3]]);n[r++]=i>>16&255,r<n.length&&(n[r++]=i>>8&255),r<n.length&&(n[r++]=i&255)}return He(n)!==t?null:n}function Ee(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function fn(t){if(typeof t!="string"||t.length%2!==0||!/^[0-9a-f]*$/.test(t))return null;let e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function oe(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function je(...t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}var xe=t=>new TextEncoder().encode(t);function sc(t){return{version:t.version,nonceB64:t.nonceB64,counter:t.counter,...t.time!==void 0?{time:t.time}:{},epochId:t.epochId,publicKeyB64:t.publicKeyB64,...t.chainId?{chainId:t.chainId}:{}}}function Rr(t){return O(ye(sc(t)))}function ac(t){let e=Ie(t.nonceB64);if(e===null||e.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return je(oc,Rr(t),e)}function cc(t){return O(ac(t))}var ni="bitgraph-fuse/2",ri=ni,fc=(()=>{let t=new TextEncoder().encode(ni),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})(),oi="bitgraph-fuse/3",ii=oi,uc=(()=>{let t=new TextEncoder().encode(oi),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})();function Hr(t){return t===ic?1:t===ri?2:t===ii?3:null}function un(t){let e=t.commit?.slotAnchor,n=t.commit?.slotFloor;if(e&&n)throw new TypeError("the proof signs two floors (commit.slotAnchor and commit.slotFloor); it is ambiguous and binds neither");if(n){if(n.chain!=="base"||n.evmChainId!==8453)throw new TypeError("commit.slotFloor does not name Base mainnet");if(typeof n.blockHash!="string"||!/^0x[0-9a-f]{64}$/.test(n.blockHash))throw new TypeError("commit.slotFloor.blockHash is not a 32-byte hash");if(!Number.isSafeInteger(n.blockNumber)||!Number.isSafeInteger(n.blockTimestamp))throw new TypeError("commit.slotFloor carries no block number or time");return{chain:"base",blockNumber:n.blockNumber,blockHash:n.blockHash,blockTimestamp:n.blockTimestamp}}if(e){if(typeof e.blockHash!="string")throw new TypeError("commit.slotAnchor.blockHash is missing");return{chain:"ethereum",blockNumber:e.blockNumber,blockHash:e.blockHash.toLowerCase(),anchorCounter:e.counter}}return null}function lc(t){let e=typeof t=="string"?fn(t.toLowerCase().replace(/^0x/,"")):t;if(e===null||e.length!==32)throw new TypeError("the floor block hash must be 32 bytes");return e}function dc(t,e){let n=Ie(t.nonceB64);if(n===null||n.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return je(fc,Rr(t),n,lc(e))}function hc(t,e){return O(dc(t,e))}function pc(t,e){let n=Ie(t.nonceB64);if(n===null||n.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return je(uc,Rr(t),n,lc(e))}function mc(t,e){return O(pc(t,e))}function ln(t,e){let n=Hr(t.attribution?.name);if(n===1||n===null)return cc(e);let r=un(t);if(n===2){if(r?.chain!=="ethereum")throw new TypeError("a bitgraph-fuse/2 proof must carry a signed commit.slotAnchor to bind");return hc(e,r.blockHash)}if(r?.chain!=="base")throw new TypeError("a bitgraph-fuse/3 proof must carry a signed commit.slotFloor (a Base block) to bind");return mc(e,r.blockHash)}function Mt(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e!==void 0&&e.length!==32)throw new TypeError("originDigest must be 32 bytes");let n={type:ve,...e!==void 0?{origin:{algorithm:"sha256",digest:Ee(e)}}:{},slotCommitment:{algorithm:"sha256",digest:Ee(t)}};return ye(n)}function rt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}function it(t){if(!rt(t)||Object.keys(t).length!==2||t.algorithm!=="sha256"||typeof t.digest!="string")return null;let n=fn(t.digest);return n!==null&&n.length===32?n:null}function _n(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!rt(n))return null;let r=Object.keys(n).sort(),o=r.length===2?["slotCommitment","type"]:r.length===3?["origin","slotCommitment","type"]:null;if(o===null||r.join(",")!==o.join(",")||n.type!==ve)return null;let i=it(n.slotCommitment);if(i===null)return null;let s;if("origin"in n){let a=it(n.origin);if(a===null)return null;s=a}return oe(Mt(i,s),t)?s!==void 0?{commitment:i,originDigest:s}:{commitment:i}:null}var fe=512,gc=8589934591,ad=gc;function cd(t,e){let n=t.toString(8).padStart(e-1,"0")+"\0";if(n.length!==e)throw new RangeError("field overflow");return xe(n)}function st(t,e){if(e>ad)throw new RangeError("container entries are limited to 8 GiB");let n=new Uint8Array(fe),r=xe(t);if(r.length>100)throw new RangeError("ustar name too long");n.set(r,0),n.set(xe("0000644\0"),100),n.set(xe("0000000\0"),108),n.set(xe("0000000\0"),116),n.set(cd(e,12),124),n.set(xe("00000000000\0"),136),n.set(xe(" "),148),n[156]=48,n.set(xe("ustar\0"),257),n.set(xe("00"),263);let o=0;for(let i of n)o+=i;return n.set(xe(o.toString(8).padStart(6,"0")+"\0 "),148),n}function at(t){return(fe-t%fe)%fe}function nc(t,e){return je(st(Bt,e.length),e,new Uint8Array(at(e.length)),st(ot,t.length),t,new Uint8Array(at(t.length)),new Uint8Array(fe*2))}function bc(t){let e=[],n=0;for(;n+fe<=t.length;){let r=t.subarray(n,n+fe);if(r.every(f=>f===0)){let f=t.subarray(n);return f.length!==fe*2||!f.every(u=>u===0)?null:e}let o=r.indexOf(0,0),i=new TextDecoder().decode(r.subarray(0,o<0||o>100?100:o)),s=new TextDecoder().decode(r.subarray(124,135));if(!/^[0-7]{11}$/.test(s))return null;let a=parseInt(s,8);if(n+fe+a>t.length)return null;let c=t.subarray(n+fe,n+fe+a);e.push({name:i,data:c,headerBytes:r}),n+=fe+a+at(a)}return null}var fd={id:"trailer/1",form:"A",byteExact:!0,build({original:t,commitment:e}){if(t===void 0)throw new TypeError("trailer/1 requires the original bytes");if(e.length!==32)throw new TypeError("commitment must be 32 bytes");return je(t,xe($n),new Uint8Array(8),e)},locate(t){if(t.length<Dn)return null;let e=t.subarray(t.length-Dn);return!oe(e.subarray(0,8),xe($n))||!e.subarray(8,16).every(n=>n===0)?null:{commitment:new Uint8Array(e.subarray(16,48)),originalBytes:t.subarray(0,t.length-Dn)}},frame({commitment:t}){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");return{prefix:new Uint8Array(0),suffix:je(xe($n),new Uint8Array(8),t)}},scanPrefix(){return new Uint8Array(0)}},ud={id:"container/1",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/1 requires the original bytes");let r=e??O(t);return nc(t,Mt(n,r))},locate(t){let e=bc(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==Bt||r.name!==ot)return null;let o=_n(n.data);if(o===null||o.originDigest===void 0)return null;let i=nc(r.data,n.data);return!oe(i,t)||!oe(O(r.data),o.originDigest)?null:{commitment:o.commitment,originDigest:o.originDigest,originalBytes:r.data}},frame({originalSize:t,originDigest:e,commitment:n}){let r=Mt(n,e);return{prefix:je(st(Bt,r.length),r,new Uint8Array(at(r.length)),st(ot,t)),suffix:je(new Uint8Array(at(t)),new Uint8Array(fe*2))}},scanPrefix(){return null}};function rc(t,e){return je(st(ot,t.length),t,new Uint8Array(at(t.length)),st(Bt,e.length),e,new Uint8Array(at(e.length)),new Uint8Array(fe*2))}var ld={id:"container/2",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/2 requires the original bytes");let r=e??O(t);return rc(t,Mt(n,r))},locate(t){let e=bc(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==ot||r.name!==Bt)return null;let o=_n(r.data);if(o===null||o.originDigest===void 0)return null;let i=rc(n.data,r.data);return!oe(i,t)||!oe(O(n.data),o.originDigest)?null:{commitment:o.commitment,originDigest:o.originDigest,originalBytes:n.data}},frame({originalSize:t,originDigest:e,commitment:n}){let r=Mt(n,e);return{prefix:st(ot,t),suffix:je(new Uint8Array(at(t)),st(Bt,r.length),r,new Uint8Array(at(r.length)),new Uint8Array(fe*2))}},scanPrefix(t){return st(ot,t)}},dd={id:"produced/1",form:"C",byteExact:!1,build({original:t,originDigest:e,commitment:n}){if(t!==void 0)throw new TypeError("produced/1 takes no original; pass originDigest for a source reference");return Mt(n,e)},locate(t){let e=_n(t);return e===null?null:e.originDigest!==void 0?{commitment:e.commitment,originDigest:e.originDigest}:{commitment:e.commitment}}},Ot=Object.freeze([fd,ud,ld,dd]),Pt="set/1";var yc=/^[a-z0-9][a-z0-9-]*\/[1-9][0-9]*$/;function wc(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e.length===0)throw new TypeError("a set lists at least one member");let n=[],r=new Set;for(let i of e){if(i.artifact.length!==32)throw new TypeError("member artifact digest must be 32 bytes");if(i.origin.length!==32)throw new TypeError("member origin digest must be 32 bytes");if(!yc.test(i.placement))throw new TypeError(`member placement "${i.placement}" is not a placement id`);if(i.placement===Pt||i.placement===Lt)throw new TypeError("a set cannot list a set as a member");let s=Ee(i.artifact);if(r.has(s))throw new TypeError(`duplicate member artifact digest ${s}`);r.add(s),n.push({artifact:{algorithm:"sha256",digest:s},origin:{algorithm:"sha256",digest:Ee(i.origin)},placement:i.placement})}n.sort((i,s)=>i.artifact.digest<s.artifact.digest?-1:1);let o={members:n,placement:Pt,slotCommitment:{algorithm:"sha256",digest:Ee(t)},type:ve};return ye(o)}function si(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!rt(n)||Object.keys(n).sort().join(",")!=="members,placement,slotCommitment,type"||n.type!==ve||n.placement!==Pt)return null;let r=it(n.slotCommitment);if(r===null)return null;let o=n.members;if(!Array.isArray(o)||o.length===0)return null;let i=[];for(let a of o){if(!rt(a)||Object.keys(a).sort().join(",")!=="artifact,origin,placement")return null;let c=it(a.artifact),f=it(a.origin),u=a.placement;if(c===null||f===null||typeof u!="string"||!yc.test(u)||u===Pt||u===Lt)return null;i.push({artifact:c,origin:f,placement:u})}let s;try{s=wc(r,i)}catch{return null}return oe(s,t)?{commitment:r,members:i}:null}var hd={id:Pt,form:"C",byteExact:!1,build(){throw new TypeError("set/1 is built with buildSetManifest(commitment, members)")},locate(t){let e=si(t);return e===null?null:{commitment:e.commitment}}},Lt="set/2",xc=`${ve}/member`,Cr=1e6;function Ec(t,e,n){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(n.length!==32)throw new TypeError("root must be 32 bytes");if(!Number.isInteger(e)||e<1||e>Cr)throw new TypeError(`count must be an integer from 1 to ${Cr}`);let r={count:e,placement:Lt,root:{algorithm:"sha256",digest:Ee(n)},slotCommitment:{algorithm:"sha256",digest:Ee(t)},type:ve};return ye(r)}function ai(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!rt(n)||Object.keys(n).sort().join(",")!=="count,placement,root,slotCommitment,type"||n.type!==ve||n.placement!==Lt)return null;let r=n.count;if(typeof r!="number"||!Number.isInteger(r)||r<1||r>Cr)return null;let o=it(n.slotCommitment),i=it(n.root);if(o===null||i===null)return null;let s;try{s=Ec(o,r,i)}catch{return null}return oe(s,t)?{commitment:o,count:r,root:i}:null}var pd={id:Lt,form:"C",byteExact:!1,build(){throw new TypeError("set/2 is built with buildSetRoot(commitment, count, root)")},locate(t){let e=ai(t);return e===null?null:{commitment:e.commitment}}};function Ft(t){return[...Ot,hd,pd].find(e=>e.id===t)}var ci="base64url",md=[ci];function fi(t){return typeof t=="string"&&md.includes(t)}function ui(t,e,n){if(n!==ci)return[];let r=He(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),o=new TextEncoder().encode(r),i=[];if(o.length===0||o.length>t.length)return i;e:for(let s=0;s+o.length<=t.length;s++){for(let a=0;a<o.length;a++)if(t[s+a]!==o[a])continue e;i.push(s)}return i}function At(t){let e=t.attribution,n=Hr(e?.name);if(e===void 0||n===null||e.title==="tree/1")return null;let r=typeof e.title=="string"&&e.title.length>0,o={placement:r?e.title:null,placementSource:r?"attribution":null,source:"attribution",version:n};if(typeof e.message=="string"&&e.message.length>0){let i=Ie(e.message);i!==null&&i.length===32&&(o.originDigest=i,o.originSource="attribution")}return o}function li(t,e){if(t===null)return e;if(e===null)return t;let n={...t};return n.placement===null&&e.placement!==null&&(n.placement=e.placement,n.placementSource="manifest"),n.originDigest===void 0&&e.originDigest!==void 0&&(n.originDigest=e.originDigest,n.originSource="manifest"),n}function di(t){let e=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return null}})():t;if(!rt(e)||e.type!==ve)return null;let n=e.manifest;if(!rt(n)||n.placement!==void 0&&typeof n.placement!="string"||it(n.artifact)===null||n.origin!==void 0&&it(n.origin)===null||n.fusedFile!==null&&typeof n.fusedFile!="string")return null;let o=e.proof;if(!rt(o)||o.version!=="bitgraph/1")return null;let i={type:ve,manifest:{placement:typeof n.placement=="string"?n.placement:"",...n.origin!==void 0?{origin:n.origin}:{},artifact:n.artifact,fusedFile:n.fusedFile},proof:o};if(e.fusePayload!==void 0){if(!rt(e.fusePayload))return null;i.fusePayload=e.fusePayload}return i}function hi(t){let e=t.manifest.placement.length>0,n={placement:e?t.manifest.placement:null,placementSource:e?"manifest":null,source:"manifest"};if(t.manifest.origin!==void 0){let r=fn(t.manifest.origin.digest);r!==null&&r.length===32&&(n.originDigest=r,n.originSource="manifest")}return n}g();var Tt=512,Nr=250,kc=t=>(Tt-t%Tt)%Tt;var kb={"container/1":{prefixLength:Tt+Nr+kc(Nr)+Tt,manifestAt:Tt,originalHeaderAt:Tt+Nr+kc(Nr)},"container/2":{prefixLength:Tt,manifestAt:null,originalHeaderAt:0}};g();function mi(t){let e=t.commit;if(typeof e.counter!="string"||typeof e.slotCounter!="string"||typeof e.epochId!="string")return null;let n;try{n=(BigInt(e.counter)-BigInt(e.slotCounter)).toString()}catch{return null}return{slotCounter:e.slotCounter,commitCounter:e.counter,epochId:e.epochId,chainId:typeof e.chainId=="string"?e.chainId:null,positions:n}}function Bc(t){return`The exact fused bytes could not feasibly have been finalized before position ${t.slotCounter} was reserved and signed for them, and were committed no later than position ${t.commitCounter}.`}function pi(t,e,n){if(e===null)return[];let r=[];return t==="FUSED_FROM_ORIGIN"?r.push(`The supplied original rebuilds the committed fused artifact byte for byte, so these exact original bytes existed no later than commit position ${e.commitCounter}.`):t==="FUSED_DIRECT"&&n&&r.push("The fused bytes carry an origin digest that matches the signed marker; the original itself was not supplied and was not checked."),(t==="FUSED_DIRECT"||t==="FUSED_FROM_ORIGIN")&&r.push(Bc(e)),t==="RECORDED"&&r.push(`These exact bytes existed no later than commit position ${e.commitCounter}.`),r}function gd(t,e){return t===null?[]:[`The enclave reserved and signed position ${t.slotCounter} before this artifact's digest reached it.`,`These exact bytes contain that position's commitment, first at byte ${e}, so they were assembled after position ${t.slotCounter} existed and were committed at position ${t.commitCounter}.`]}var bd=["Containing the commitment does not show it was an input to the artifact's production: bytes appended to a finished file pass the same check. What the commitment was to the work is the producer's claim, not this result's."];async function $r(t){let{proof:e,bytes:n}=t,r=t.frame===void 0||t.frame===null?null:di(t.frame)??null,o=O(n),i=He(o),s=e?.artifact?.digestB64??"",a=(b,p,A)=>({category:b,proof:p.proof??{valid:!0},marker:p.marker??null,placement:p.placement??null,fileDigestB64:i,artifactDigestB64:s,originDigestB64:p.originDigestB64??null,slotCommitmentB64:p.slotCommitmentB64??null,span:p.span??null,policy:p.policy??{spanExceeded:!1,maxPositions:null},offsets:p.offsets??[],statements:p.statements??[],limits:b==="CARRIED_INLINE"?bd:[],carriedBy:p.carriedBy??null,reason:A}),c=await we(t.trustAnchors!==void 0?{proof:e,trustAnchors:t.trustAnchors}:{proof:e});if(!c.valid){let b=c.reason??"proof failed verification";return a("INVALID_UNDERLYING_PROOF",{proof:{valid:!1,reason:b}},b)}let f=li(At(e),r!==null?hi(r):null),u=f?.originDigest,l=u!==void 0?He(u):null,d=mi(e),h=t.maxPositions===void 0?null:BigInt(t.maxPositions),m={spanExceeded:h!==null&&d!==null&&BigInt(d.positions)>h,maxPositions:h===null?null:h.toString()},y={proof:{valid:!0},marker:f,originDigestB64:l,span:d,policy:m};if(i===s){if(f===null)return a("RECORDED",{...y,statements:pi("RECORDED",d,!1)},null);let b=e.slotAllocation;if(b===void 0)return a("INVALID_SLOT_COMMITMENT",y,"the proof carries no slot record, so no commitment can be recomputed");let p;try{p=ln(e,b)}catch(H){return a("INVALID_SLOT_COMMITMENT",y,`commitment could not be recomputed: ${H instanceof Error?H.message:String(H)}`)}let A=He(p);if(fi(f.placement)){let H=f.placement,U={kind:"encoding",id:H};if(u!==void 0)return a("INVALID_ORIGIN_ATTRIBUTION",{...y,slotCommitmentB64:A,carriedBy:U},"the marker declares an origin, but an artifact made with the commitment inside it has no original");let S=ui(n,p,H);return S.length===0?a("COMMITMENT_ABSENT",{...y,slotCommitmentB64:A,carriedBy:U},`the artifact's bytes do not contain the commitment in encoding "${H}"`):a("CARRIED_INLINE",{...y,slotCommitmentB64:A,carriedBy:U,offsets:S,statements:gd(d,S[0])},null)}let B=f.placement===null?void 0:Ft(f.placement),P=B===void 0?null:B.locate(n);if(f.placement===null){for(let H of Ot){let U=H.locate(n);if(U!==null){B=H,P=U;break}}if(B===void 0)return a("INVALID_SLOT_COMMITMENT",{...y,slotCommitmentB64:A},"no registered placement finds a commitment in the fused bytes")}else if(B===void 0)return a("UNDETERMINED_PLACEMENT",{...y,slotCommitmentB64:A},`placement "${f.placement}" is not registered; the commitment cannot be located`);if(P===null)return a("INVALID_SLOT_COMMITMENT",{...y,slotCommitmentB64:A,placement:B.id},`no ${B.id} commitment found in the fused bytes`);if(!oe(P.commitment,p))return a("INVALID_SLOT_COMMITMENT",{...y,slotCommitmentB64:A,placement:B.id},"the commitment in the fused bytes does not match the proof's slot record");let V=!1;if(u!==void 0){let H=P.originDigest??(P.originalBytes!==void 0?O(P.originalBytes):void 0);if(H!==void 0){if(!oe(H,u))return a("INVALID_ORIGIN_ATTRIBUTION",{...y,slotCommitmentB64:A,placement:B.id},f.originSource==="attribution"?"the origin digest in the signed attribution does not match the origin inside the fused bytes":"the origin digest in the manifest does not match the origin inside the fused bytes");V=!0}}return a("FUSED_DIRECT",{...y,slotCommitmentB64:A,placement:B.id,carriedBy:{kind:"placement",id:B.id},statements:pi("FUSED_DIRECT",d,V)},null)}if(u!==void 0&&oe(o,u)){let b=e.slotAllocation;if(b===void 0)return a("INVALID_SLOT_COMMITMENT",y,"the proof carries no slot record, so the fused bytes cannot be rebuilt");let p;try{p=ln(e,b)}catch(H){return a("INVALID_SLOT_COMMITMENT",y,`commitment could not be recomputed: ${H instanceof Error?H.message:String(H)}`)}let A=He(p),B=f!==null&&f.placement!==null?Ft(f.placement):void 0;if(f!==null&&f.placement!==null&&B===void 0)return a("UNDETERMINED_PLACEMENT",{...y,slotCommitmentB64:A},`placement "${f.placement}" is not registered; the fused bytes cannot be rebuilt`);let P=B!==void 0?[B]:Ot.filter(H=>H.byteExact),V=e.artifact.digestB64;for(let H of P){if(!H.byteExact)continue;let U;try{U=H.build({original:n,originDigest:u,commitment:p})}catch{continue}if(He(O(U))===V)return a("FUSED_FROM_ORIGIN",{...y,slotCommitmentB64:A,placement:H.id,carriedBy:{kind:"placement",id:H.id},statements:pi("FUSED_FROM_ORIGIN",d,!0)},null)}return a("RECONSTRUCTION_MISMATCH",{...y,slotCommitmentB64:A,placement:B?.id??null},B!==void 0?`rebuilding ${B.id} from this file and the proof's position record does not reproduce the committed artifact digest`:"no registered byte-exact placement rebuilds the committed artifact digest from this file")}return a("NO_MATCH",y,"this file matches neither the committed artifact digest nor the origin digest; the proof proves nothing about it")}g();g();g();var kd=BigInt(0),Mn=BigInt(1),Bd=BigInt(2),Ad=BigInt(7),Td=BigInt(256),vd=BigInt(113),vc=[],Ic=[],Sc=[];for(let t=0,e=Mn,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],vc.push(2*(5*r+n)),Ic.push((t+1)*(t+2)/2%64);let o=kd;for(let i=0;i<7;i++)e=(e<<Mn^(e>>Ad)*vd)%Td,e&Bd&&(o^=Mn<<(Mn<<BigInt(i))-Mn);Sc.push(o)}var Cc=tr(Sc,!0),Id=Cc[0],Sd=Cc[1],Ac=(t,e,n)=>n>32?Ys(t,e,n):Ws(t,e,n),Tc=(t,e,n)=>n>32?Zs(t,e,n):qs(t,e,n);function Cd(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,f=n[c],u=n[c+1],l=Ac(f,u,1)^n[a],d=Tc(f,u,1)^n[a+1];for(let h=0;h<50;h+=10)t[s+h]^=l,t[s+h+1]^=d}let o=t[2],i=t[3];for(let s=0;s<24;s++){let a=Ic[s],c=Ac(o,i,a),f=Tc(o,i,a),u=vc[s];o=t[u],i=t[u+1],t[u]=c,t[u+1]=f}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Id[r],t[1]^=Sd[r]}Oe(n)}var gi=class t extends Yt{constructor(e,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,yo(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=js(this.state)}clone(){return this._cloneInto()}keccak(){wo(this.state32),Cd(this.state32,this.rounds),wo(this.state32),this.posOut=0,this.pos=0}update(e){Zt(this),e=xn(e),Rt(e);let{blockLen:n,state:r}=this,o=e.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){Zt(this,!1),Rt(e),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=e.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);e.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return yo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Jn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Oe(this.state)}_cloneInto(e){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return e||(e=new t(n,r,o,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=o,e.enableXOF=s,e.destroyed=this.destroyed,e}},Rd=(t,e,n)=>En(()=>new gi(e,t,n));var Dr=Rd(1,136,256/8);var Hd=Uint8Array.from([66,71,80,82,79,79,70,1]);var Nd=8*1024*1024;var Fb=new TextEncoder;g();g();g();g();g();var yi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},$d={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Rc=BigInt(2);function Dd(t){let e=yi.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=be(u,n,e)*u%e,d=be(l,n,e)*u%e,h=be(d,Rc,e)*f%e,m=be(h,o,e)*h%e,y=be(m,i,e)*m%e,b=be(y,a,e)*y%e,p=be(b,c,e)*b%e,A=be(p,a,e)*y%e,B=be(A,n,e)*u%e,P=be(B,s,e)*m%e,V=be(P,r,e)*f%e,H=be(V,Rc,e);if(!bi.eql(bi.sqr(H),t))throw new Error("Cannot find square root");return H}var bi=nn(yi.p,{sqrt:Dd}),_d=Ar(yi,{Fp:bi,endo:$d}),Hc=Tr(_d,ur);function he(t){let e=t.startsWith("0x")||t.startsWith("0X")?t.slice(2):t;if(e.length%2&&(e="0"+e),!/^[0-9a-fA-F]*$/.test(e))throw new TypeError("not hex");let n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++)n[r]=parseInt(e.slice(r*2,r*2+2),16);return n}function Se(t){let e="0x";for(let n of t)e+=n.toString(16).padStart(2,"0");return e}function Ke(t){return Dr(t)}function _r(...t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}function hn(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function Nc(t,e){if(t<56)return Uint8Array.of(e+t);let n=[];for(let r=t;r>0;r=Math.floor(r/256))n.unshift(r%256);return Uint8Array.of(e+55+n.length,...n)}function Ge(t){if(t instanceof Uint8Array)return t.length===1&&t[0]<128?t:_r(Nc(t.length,128),t);let e=_r(...t.map(Ge));return _r(Nc(e.length,192),e)}function pn(t){let[e,n]=Dc(t,0);if(n!==t.length)throw new TypeError("rlp: trailing bytes");return e}function $c(t,e,n){if(e+n>t.length)throw new TypeError("rlp: truncated length");if(t[e]===0)throw new TypeError("rlp: length with a leading zero");let r=0;for(let o=0;o<n;o++)r=r*256+t[e+o];if(r<56)throw new TypeError("rlp: long form for a short length");return r}function Dc(t,e){if(e>=t.length)throw new TypeError("rlp: truncated");let n=t[e];if(n<128)return[t.slice(e,e+1),e+1];if(n<=183){let c=n-128,f=e+1+c;if(f>t.length)throw new TypeError("rlp: truncated string");if(c===1&&t[e+1]<128)throw new TypeError("rlp: single byte should encode as itself");return[t.slice(e+1,f),f]}if(n<=191){let c=n-183,f=$c(t,e+1,c),u=e+1+c;if(u+f>t.length)throw new TypeError("rlp: truncated string");return[t.slice(u,u+f),u+f]}let r,o;if(n<=247)o=n-192,r=e+1;else{let c=n-247;o=$c(t,e+1,c),r=e+1+c}let i=r+o;if(i>t.length)throw new TypeError("rlp: truncated list");let s=[],a=r;for(;a<i;){let[c,f]=Dc(t,a);s.push(c),a=f}if(a!==i)throw new TypeError("rlp: list overran its length");return[s,i]}function dn(t,e){if(!(t instanceof Uint8Array))throw new TypeError(`${e}: expected a byte string`);return t}function Mr(t,e){if(!Array.isArray(t))throw new TypeError(`${e}: expected a list`);return t}function ct(t,e){let n=dn(t,e);if(n.length>0&&n[0]===0)throw new TypeError(`${e}: integer with a leading zero`);let r=0n;for(let o of n)r=r<<8n|BigInt(o);return r}function mn(t){let e=Mr(pn(t),"header");if(e.length<15)throw new TypeError("header: too few fields");let n=ct(e[8],"header.number"),r=ct(e[11],"header.timestamp");if(n>BigInt(Number.MAX_SAFE_INTEGER)||r>BigInt(Number.MAX_SAFE_INTEGER))throw new TypeError("header: number out of range");let o=dn(e[4],"header.transactionsRoot"),i=dn(e[0],"header.parentHash");if(o.length!==32||i.length!==32)throw new TypeError("header: bad root length");return{hash:Se(Ke(t)),parentHash:Se(i),transactionsRoot:Se(o),number:Number(n),timestamp:Number(r)}}function wi(t){if(t.length<2||t[0]!==2)throw new TypeError("tx: not an EIP-1559 (type 2) transaction");let e=Mr(pn(t.slice(1)),"tx");if(e.length!==12)throw new TypeError("tx: a type-2 transaction has 12 fields");let n=ct(e[0],"tx.chainId"),r=ct(e[1],"tx.nonce"),o=dn(e[5],"tx.to");if(o.length!==0&&o.length!==20)throw new TypeError("tx: bad recipient length");let i=ct(e[6],"tx.value"),s=dn(e[7],"tx.data");Mr(e[8],"tx.accessList");let a=ct(e[9],"tx.yParity"),c=ct(e[10],"tx.r"),f=ct(e[11],"tx.s");if(a>1n)throw new TypeError("tx: yParity must be 0 or 1");let u=Ke(_r(Uint8Array.of(2),Ge(e.slice(0,9)))),l=he(c.toString(16).padStart(64,"0")+f.toString(16).padStart(64,"0")),d=Hc.Signature.fromBytes(l,"compact");if(d.hasHighS())throw new TypeError("tx: high-s signature");let h=d.addRecoveryBit(Number(a)).recoverPublicKey(u).toBytes(!1),m=Se(Ke(h.slice(1)).slice(12));return{type:2,chainId:n,nonce:r,to:o.length===0?null:Se(o),value:i,data:s,from:m,hash:Se(Ke(t))}}function _c(t){let e=[];for(let n of t)e.push(n>>4,n&15);return e}function Md(t){if(t.length===0)throw new TypeError("mpt: empty path");let e=_c(t),n=e[0];if(n>3)throw new TypeError("mpt: bad path flag");let r=n>=2,o=n%2===1;if(!o&&e[1]!==0)throw new TypeError("mpt: even path must pad with zero");return[e.slice(o?1:2),r]}function Pn(t,e,n){let r=_c(e),o=t,i=0,s=0;for(;;){let a;if(o.length===32){let f=n[s++];if(!f||!hn(Ke(f),o))return null;a=f}else a=o;let c;try{c=Mr(pn(a),"mpt node")}catch{return null}if(c.length===17){if(i===r.length){let u=c[16];return u instanceof Uint8Array&&u.length>0?u:null}let f=c[r[i]];if(i+=1,f===void 0)return null;if(f instanceof Uint8Array){if(f.length===0)return null;o=f}else o=Ge(f);continue}if(c.length===2){let f,u;try{[f,u]=Md(dn(c[0],"mpt path"))}catch{return null}for(let d=0;d<f.length;d++)if(r[i+d]!==f[d])return null;if(i+=f.length,u){if(i!==r.length)return null;let d=c[1];return d instanceof Uint8Array?d:null}let l=c[1];o=l instanceof Uint8Array?l:Ge(l);continue}return null}}function gn(t){if(!Number.isInteger(t)||t<0)throw new RangeError("tx index");if(t===0)return Ge(new Uint8Array(0));let e=[];for(let n=t;n>0;n=Math.floor(n/256))e.unshift(n%256);return Ge(Uint8Array.from(e))}var Pr="bitgraph-ceiling/1",Or="BGC1",xi=84;function Mc(t){if(t.length!==xi)throw new TypeError(`payload is ${t.length} bytes, expected ${xi}`);let e=new TextDecoder().decode(t.slice(0,4));if(e!==Or)throw new TypeError(`payload magic is ${JSON.stringify(e)}, expected ${Or}`);let n=new DataView(t.buffer,t.byteOffset,t.byteLength);return{root:t.slice(4,36),prev:t.slice(36,68),firstPos:n.getBigUint64(68),lastPos:n.getBigUint64(76)}}function Pc(t){let e=Ie(t);if(!e||e.length!==32)throw new TypeError("proofHash must decode to 32 bytes");return Rn(e)}function Pd(t){return new Date(t*1e3).toISOString().slice(11,19)}function Oc(t,e,n,r=!1){let o=`Base block ${e.toLocaleString("en-US")} at ${Pd(n)} UTC`;return r?`Ceiling: included in ${o}. A settlement pointer to Ethereum is attached; check it with verifySettlementPointer.`:t==="safe"||t==="finalized"?`Ceiling: included in ${o}. BitGraph's Base node reported the block "${t}" when this file was written; that report is not proven here, and no settlement evidence is attached.`:`Ceiling: included in ${o}. Relies on Base's sequencer until its batch data is on Ethereum; no settlement evidence is attached.`}async function On(t,e,n){let r=[],o=(i,s)=>(r.push({name:i,ok:!1,detail:s}),{ok:!1,reason:`${i}: ${s}`,checks:r,headerCheckedAgainstChain:!1});try{return await Od(t,e,n,r,o)}catch(i){return o("malformed",`a field of the sidecar is malformed: ${i instanceof Error?i.message:String(i)}`)}}async function Od(t,e,n,r,o){let i=(p,A)=>r.push(A===void 0?{name:p,ok:!0}:{name:p,ok:!0,detail:A});if(e?.version!==Pr)return o("format",`not a ${Pr} sidecar`);if(!n.proofAlreadyVerified){let p=await we({proof:t,context:sn(),...n.trustAnchors?{trustAnchors:n.trustAnchors}:{}});if(!p.valid)return o("proof",`the proof does not verify (${p.reason??"invalid"})`);i("proof","signature valid")}let s;try{s=kt(t)}catch(p){return o("record",`cannot hash the proof (${p.message})`)}if(s!==e.proofHash)return o("record","this sidecar belongs to a different proof");let a;try{a=Hn(Pc(s),e.leafIndex,e.leafCount,e.merklePath.map(he))}catch{a=null}if(!a)return o("merkle","the path does not fit the leaf index and tree size");if(Se(a)!==e.root.toLowerCase())return o("merkle","the leaf and path do not reach the root");if(i("merkle",`leaf ${e.leafIndex} of ${e.leafCount} reaches the root`),!e.anchor)return{ok:!1,reason:"ceiling pending: no transaction included yet",checks:r,status:"pending",headerCheckedAgainstChain:!1};let c=e.anchor,f;try{f=he(c.payload);let p=Mc(f);if(Se(p.root)!==e.root.toLowerCase())return o("payload","the payload's root is not this sidecar's root");i("payload",`${Or}, positions ${p.firstPos}-${p.lastPos}`)}catch(p){return o("payload",p.message)}let u;try{u=he(c.rawTx);let p=wi(u),A=n.writerAddress.toLowerCase();if(p.from!==A)return o("sender",`the transaction was signed by ${p.from}, not the declared writer ${A}`);if(p.to!==A)return o("sender",`the transaction is addressed to ${p.to??"a contract creation"}, not to the writer`);if(p.chainId!==BigInt(n.chainId))return o("chain",`the transaction is for chain ${p.chainId}, expected ${n.chainId}`);if(c.chainId!==n.chainId)return o("chain",`the sidecar names chain ${c.chainId}, expected ${n.chainId}`);if(!hn(p.data,f))return o("payload","the transaction's data is not the payload");if(p.hash!==c.txHash.toLowerCase())return o("transaction","the raw transaction does not hash to txHash");i("sender",`signed by ${p.from}`)}catch(p){return o("transaction",p.message)}let l;try{l=mn(he(c.blockHeader))}catch(p){return o("header",p.message)}if(l.hash!==c.blockHash.toLowerCase())return o("header","the header does not hash to blockHash");if(l.number!==c.blockNumber)return o("header",`the header is block ${l.number}, the sidecar says ${c.blockNumber}`);if(l.timestamp!==c.blockTimestamp)return o("header",`the header's timestamp is ${l.timestamp}, the sidecar says ${c.blockTimestamp}`);let d=Pn(he(l.transactionsRoot),gn(c.txIndex),c.txInclusionProof.map(he));if(!d||!hn(d,u))return o("inclusion","the transaction is not in this block");i("inclusion",`transaction ${c.txIndex} of block ${l.number}`);let h;try{h=un(t)}catch(p){return o("floor",p.message)}let m=null;if(h){m={chain:h.chain,blockNumber:h.blockNumber,blockHash:h.blockHash,blockTimestamp:null};let p=e.floor;if(p!=null){if(typeof p!="object"||typeof p.blockHeader!="string"||p.blockHeader.length===0)return o("floor","the sidecar carries a floor without a header (absence is null; a present floor carries its header)");let A;try{A=he(p.blockHeader)}catch{return o("floor","the carried floor header does not decode")}let B=Fr(h,A,p.chain);if(!B.ok){if(B.reason.startsWith("the header does not decode"))return o("floor","the carried floor header does not decode");let P=h.chain==="base"?"slotFloor":"slotAnchor",V=h.chain==="ethereum"&&p.chain===void 0?"":`: ${B.reason}`;return o("floor",`the carried floor header does not match the proof's signed ${P}${V}`)}m.blockTimestamp=B.header.timestamp,i("floor",`${Fc(h.chain)} block ${B.header.number}, header checked against the signed hash`)}}let y=m?.blockTimestamp!=null?l.timestamp-m.blockTimestamp:null,b=e.status;return{ok:!0,checks:r,status:b,window:{floor:m??{chain:null,blockNumber:0,blockHash:"",blockTimestamp:null},ceiling:{chainId:c.chainId,blockNumber:l.number,blockHash:l.hash,blockTimestamp:l.timestamp},widthSeconds:y},label:Oc(b,l.number,l.timestamp,typeof e.settlement=="object"&&e.settlement!==null),headerCheckedAgainstChain:!1}}async function Lr(t,e){if(!t.anchor)return{onChain:null,detail:"no anchor to check"};try{let n=(await e(t.anchor.blockNumber))?.toLowerCase();return n?n===t.anchor.blockHash.toLowerCase()?{onChain:!0,detail:`block ${t.anchor.blockNumber} matches the chain`}:{onChain:!1,detail:`the chain's block ${t.anchor.blockNumber} is ${n}, not this header`}:{onChain:null,detail:"the RPC did not return that block"}}catch(n){return{onChain:null,detail:`header not checked against chain (${n.message})`}}}var Ei=1686789347,ki=2;function Lc(t,e){return e===Ei+ki*t}var Fc=t=>t==="base"?"Base":"Ethereum";function Fr(t,e,n){let r=n??"ethereum";if(r!=="ethereum"&&r!=="base")return{ok:!1,reason:`the header names an unknown chain (${JSON.stringify(n)})`};let o=s=>s==="base"?"a Base block":"an Ethereum block";if(r!==t.chain)return{ok:!1,reason:`the header is given as ${o(r)}, and the proof signs ${o(t.chain)}`};let i;try{i=mn(e)}catch(s){return{ok:!1,reason:`the header does not decode (${s.message})`}}if(i.hash!==t.blockHash.toLowerCase())return{ok:!1,reason:`the header does not hash to the signed ${Fc(t.chain)} block hash`};if(i.number!==t.blockNumber)return{ok:!1,reason:`the header is block ${i.number}, the proof signs block ${t.blockNumber}`};if(t.chain==="base"){if(i.timestamp!==t.blockTimestamp)return{ok:!1,reason:`the header's time is ${i.timestamp}, the proof signs ${t.blockTimestamp}`};if(!Lc(i.number,i.timestamp))return{ok:!1,reason:`Base block ${i.number} is stamped ${i.timestamp}, off Base mainnet's schedule (${Ei+ki*i.number})`}}return{ok:!0,header:i}}g();var Uc=Object.freeze([{version:"genesis",since:"2026-05-15",pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92"},{version:"v2",since:"2026-06-27",pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a"},{version:"v4",since:"2026-07-05",pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb"},{version:"v5",since:"2026-07-29",pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f"},{version:"v6",since:"2026-09-05",pcr0:"cd8ba52d340fb1be78610b59953ded2ceca23be1cfcc7ab504a26b8fdcd7ba92090f49e28a32d008df046ec4212f77bf"},{version:"v7",since:"2026-09-06",pcr0:"394c3cf515651dc27187d85e4716c12dfeb99c1227f1fe0eacfaa427d80018e1a28ebba9469e99c7936601f901d74e1d"},{version:"v8",since:"2026-09-07",pcr0:"eccfc1c78006f4b74f929c992785575c908a0f60eca08ff638cd6c0842f993f182ebb002457b8ef3e732a6a10805c72b"},{version:"v9",since:"2026-09-30",pcr0:"934feb8bb6f4f7e2d2f85d902a7d5edd0981f706d9d2385638988ac096a05ea0583c3d00eef2a7947865ec66efc1fcf8"},{version:"v10",since:"2026-10-08",pcr0:"5a947cc66095adcceefa9e5ece5d1416dfe08c3470df1bcaa5b2bc5267b0480e6cdc172fe077cd06b0afb07614307973"}].map(t=>Object.freeze(t))),Bi=Object.freeze(Uc.map(t=>t.pcr0));g();var Ld=Object.freeze({l1ChainId:1,batchInbox:"0xff00000000000000000000000000000000008453",batcher:"0x5050f69a9786f081509234f1a7f4684b5e5b76c9"});g();g();g();var zc="bitgraph-tree/1",rh=(()=>{let t=new TextEncoder().encode(zc),e=new Uint8Array(t.length+1);return e.set(t,0),e})();var Wc="QazdIR0JYtHQwQuIISo7bvH1gxUvTS2cY+tW6BjUIRs=",qc="9O3sqlxqi6IQPVJd50NfjJtwWWoslZ9gpIIzbrRzAiU=",oh=Object.freeze([Wc,qc]);var ih=Object.freeze({0:"as-is",1:"trailer/1",2:"container/1",3:"container/2"});g();var K0=new Uint8Array(32);g();g();async function*Zc(t,e){let n=new Ti(t,e?.maxTotalBytes),r=e?.maxEntryCount??Number.POSITIVE_INFINITY,o=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(u,l)=>{if(u>o)throw new Error(`tar: ${l} metadata entry of ${u} bytes exceeds the ${o}-byte cap`)};for(;;){let u=await n.readExact(512);if(u===null||yh(u))return;if(++c>r)throw new Error(`tar: archive exceeds the maximum of ${r} entries`);let l=gh(u),d=l.typeflag;if(d==="x"||d==="g"){f(l.size,"PAX");let B=await Yc(n,l.size);await n.skip(Ur(l.size));let P=wh(B);d==="x"?i=P:s=xh(s,P);continue}if(d==="L"){f(l.size,"GNU long-name");let B=await Yc(n,l.size);await n.skip(Ur(l.size)),a=Ut(Eh(B));continue}if(d==="K"){await n.skip(l.size+Ur(l.size));continue}let h=l.name;s!==null&&s.has("path")&&(h=s.get("path")),a!==null&&(h=a),i!==null&&i.has("path")&&(h=i.get("path"));let m=l.size,y=i?.get("size")??s?.get("size");if(y!==void 0){let B=Number(y);if(!Number.isSafeInteger(B)||B<0)throw new Error("tar: invalid PAX size value");m=B}i=null,a=null;let b=d==="0"||d==="\0",p={remaining:m},A=mh(n,p);yield{path:h,size:m,kind:b?"file":"other",typeflag:d,body:A},p.remaining>0&&(await n.skip(p.remaining),p.remaining=0),await n.skip(Ur(m))}}async function*mh(t,e){for(;e.remaining>0;){let n=await t.readSome(e.remaining);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");e.remaining-=n.length,yield n}}async function Yc(t,e){if(e===0)return new Uint8Array(0);let n=await t.readExact(e);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream)");return n}function gh(t){bh(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),r=Ut(Ai(t,0,100));if(Ut(Ai(t,257,6))==="ustar"){let s=Ut(Ai(t,345,155));s.length>0&&(r=`${s}/${r}`)}let i=Xc(t.subarray(124,136));return{name:r,size:i,typeflag:n}}function Ai(t,e,n){let r=t.subarray(e,e+n),o=r.indexOf(0);return o===-1&&(o=r.length),r.subarray(0,o)}function Xc(t){if(t.length>0&&(t[0]&128)!==0){let r=0n;for(let o=0;o<t.length;o++){let i=o===0?t[0]&127:t[o];r=r<<8n|BigInt(i)}if(r>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("tar: numeric field exceeds the supported range");return Number(r)}let e=Ut(t).trim().replace(/\0+$/,"").trim();if(e.length===0)return 0;let n=Number.parseInt(e,8);if(!Number.isSafeInteger(n)||n<0)throw new Error(`tar: invalid octal numeric field: "${e}"`);return n}function bh(t){let e=Xc(t.subarray(148,156)),n=0;for(let r=0;r<512;r++)n+=r>=148&&r<156?32:t[r];if(n!==e)throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)")}function yh(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function wh(t){let e=new Map,n=0;for(;n<t.length;){let r=n;for(;r<t.length&&t[r]!==32;)r++;if(r>=t.length)throw new Error("tar: malformed PAX record (no length delimiter)");let o=Number(Ut(t.subarray(n,r)));if(!Number.isInteger(o)||o<=0||n+o>t.length)throw new Error("tar: malformed PAX record (bad length)");let i=t.subarray(r+1,n+o);if(i.length===0||i[i.length-1]!==10)throw new Error("tar: malformed PAX record (missing newline)");let s=Ut(i.subarray(0,i.length-1)),a=s.indexOf("=");if(a===-1)throw new Error("tar: malformed PAX record (missing '=')");e.set(s.slice(0,a),s.slice(a+1)),n+=o}return e}function xh(t,e){let n=new Map(t??[]);for(let[r,o]of e)n.set(r,o);return n}function Ut(t){return new TextDecoder("utf-8").decode(t)}function Eh(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var Ti=class{iter;chunks=[];head=0;available=0;ended=!1;totalPulled=0;maxTotalBytes;constructor(e,n){this.iter=e[Symbol.asyncIterator](),this.maxTotalBytes=n??Number.POSITIVE_INFINITY}async fill(){if(this.ended)return!1;let e=await this.iter.next();if(e.done===!0)return this.ended=!0,!1;let n=e.value;if(n.length>0){if(this.totalPulled+=n.length,this.totalPulled>this.maxTotalBytes)throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);this.chunks.push(n),this.available+=n.length}return!0}async readExact(e){for(;this.available<e;)if(!await this.fill()){if(this.available===0)return null;throw new Error("tar: truncated archive (unexpected end of stream)")}return this.take(e)}async readSome(e){for(;this.available===0;)if(!await this.fill())return null;let n=this.chunks[0],r=Math.min(e,n.length-this.head),o=n.subarray(this.head,this.head+r);return this.advance(r,n),o}async skip(e){let n=e;for(;n>0;){let r=await this.readSome(n);if(r===null)throw new Error("tar: truncated archive (unexpected end of stream)");n-=r.length}}take(e){let n=new Uint8Array(e),r=0;for(;r<e;){let o=this.chunks[0],i=Math.min(e-r,o.length-this.head);n.set(o.subarray(this.head,this.head+i),r),r+=i,this.advance(i,o)}return n}advance(e,n){this.head+=e,this.available-=e,this.head===n.length&&(this.chunks.shift(),this.head=0)}};function Ur(t){return(512-t%512)%512}g();var bx=new Uint8Array([0]);function Jc(t){let e=Array.from(t,r=>({pathBytes:kh(r.path),entryDigest:r.entryDigest}));e.sort((r,o)=>Bh(r.pathBytes,o.pathBytes));let n=O.create();for(let r of e)n.update(r.entryDigest);return E.Buffer.from(n.digest()).toString("base64")}function kh(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Bh(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let o=t[r]-e[r];if(o!==0)return o}return t.length-e.length}var Qc=8*1024*1024,of={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},ef=new Uint8Array([0]),tf="manifest.json",vi="bitgraph-bundle/1",Ah="bitgraph-anchor-witness/1",nf="bitgraph-ceiling/1",Th="bitgraph-ceiling-status/1";var sf=new WeakMap;async function Ii(t,e){let n=[],r=0,o=0,i=[],s=new Map,a=Array.from(t).sort((f,u)=>f.path<u.path?-1:f.path>u.path?1:0);for(let f of a){o++;let u=ff(f.path);if(u.unsafe){r++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${u.reason}`});continue}let l=await Ch(u.path,void 0,void 0,af(f.open()));i.push(Rh(u.path,l)),s.set(u.path,f)}let c=Ih({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:o,skippedUnsafePaths:r});return sf.set(c,s),c}async function*af(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function vh(t){let e=[],n=0;for await(let r of af(t.open()))e.push(r),n+=r.length;return Ri(e,n)}function Ih(t){let{bundlePath:e,container:n,scanned:r,strippedRootPrefix:o,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let S of r){let K=S.rawPath,L=S.entryDigestFull;o!==void 0&&(K=S.rawPath.slice(o.length+1),L=S.entryDigestStripped),c.has(K)&&i.push({code:"duplicate-path",path:K,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(K,{path:K,sha256Hex:S.sha256Hex,byteLength:S.byteLength,entryDigest:L,...S.json!==void 0?{json:S.json}:{}})}let f=Array.from(c.values()),u=Jc(f.filter(S=>S.path!==tf).map(S=>({path:S.path,entryDigest:S.entryDigest}))),l=[],d=new Map,h=[],m=[],y=[],b=[],p=new Map,A,B=0,P=0,V=0;for(let S of f){if(S.path===tf){A=Mh(S,u,i);continue}let L=Nh(S.json)??S.json;if(L!==void 0&&uf(L)){let q=L.version;if(q==="bitgraph/1"){B++;let ee=$h(S,L,d,l,i);ee==="exact-duplicate"&&P++,ee==="semantic-duplicate"&&V++;continue}h.push({code:"unsupported-version",path:S.path,version:q,fileSha256Hex:S.sha256Hex}),i.push({code:"unsupported-version",path:S.path,message:`proof-shaped file rejected: version "${q}" is not "bitgraph/1"`,details:{version:q}}),rf(S,p);continue}if(L!==void 0&&L.version===Ah){m.push({path:S.path,fileSha256Hex:S.sha256Hex,witness:L});continue}let ce=L!==void 0?L.version:void 0;if(ce===nf||ce===Th){(ce===nf?y:b).push({path:S.path,fileSha256Hex:S.sha256Hex,json:L});continue}rf(S,p)}for(let S of l){let K=_h(S.proof.artifact);if(K===null)continue;let L=p.get(K);L!==void 0&&L.matchedProofHashes.push(S.proofHash)}let H=Array.from(p.values()),U={observed:l.length,proofFiles:B,exactDuplicates:P,semanticDuplicates:V,unsupportedVersion:h.length,artifacts:H.length,witnesses:m.length,ceilings:y.length+b.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...o!==void 0?{strippedRootPrefix:o}:{},entriesScanned:s,proofs:l,unsupportedVersions:h,artifacts:H,witnesses:m,ceilings:y,ceilingStatuses:b,...A!==void 0?{manifest:A}:{},computedContentsHashB64:u,findings:i,counts:U}}async function*Si(t){yield*cf(t,t.artifacts.filter(e=>e.matchedProofHashes.length>0))}async function*Ci(t,e){let n=new Set(e);n.size!==0&&(yield*cf(t,t.artifacts.filter(r=>n.has(r.sha256Hex))))}async function*cf(t,e){if(e.length===0)return;if(t.container==="memory"){let s=sf.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let f=s.get(c);if(f===void 0)continue;let u;try{u=await vh(f)}catch{continue}if(Vr(O(u))===a.sha256Hex){yield{sha256Hex:a.sha256Hex,path:c,bytes:u};break}}return}if(t.container==="directory"){for(let s of e)for(let a of s.paths){let c;try{c=new Uint8Array(await sa(aa(t.bundlePath,...a.split("/"))))}catch{continue}if(Vr(O(c))===s.sha256Hex){yield{sha256Hex:s.sha256Hex,path:a,bytes:c};break}}return}let n=new Map;for(let s of e)for(let a of s.paths)n.set(a,s);let r=new Set,{stream:o,close:i}=Sh(t.bundlePath,t.container);try{for await(let s of Zc(o,of)){if(r.size===e.length)break;if(s.kind!=="file")continue;let a=ff(s.path);if(a.unsafe)continue;let c=a.path;if(t.strippedRootPrefix!==void 0){if(!c.startsWith(`${t.strippedRootPrefix}/`))continue;c=c.slice(t.strippedRootPrefix.length+1)}let f=n.get(c);if(f===void 0||r.has(f.sha256Hex))continue;let u=[],l=0;for await(let h of s.body)u.push(h.slice()),l+=h.length;let d=Ri(u,l);Vr(O(d))===f.sha256Hex&&(r.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:d})}}finally{i()}}function Sh(t,e){let n=ia(t);if(e==="tar-gz"){let r=ca();return n.pipe(r),n.on("error",o=>r.destroy(o)),{stream:r,close:()=>{r.destroy(),n.destroy()}}}return{stream:n,close:()=>n.destroy()}}async function Ch(t,e,n,r){let o=new TextEncoder,i=O.create(),s=O.create();s.update(o.encode(t)),s.update(ef);let a=e===void 0?void 0:O.create();a!==void 0&&(a.update(o.encode(e)),a.update(ef));let c=n===void 0||n<=Qc,f=[],u=0;for await(let l of r)i.update(l),s.update(l),a?.update(l),u+=l.length,c&&(u>Qc?(f.length=0,c=!1):f.push(l.slice()));return{sha256Hex:Vr(i.digest()),byteLength:u,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:Ri(f,u)}:{}}}function Rh(t,e){let n=e.buffered===void 0?void 0:Hh(e.buffered);return{rawPath:t,sha256Hex:e.sha256Hex,byteLength:e.byteLength,entryDigestFull:e.entryDigestFull,...e.entryDigestStripped!==void 0?{entryDigestStripped:e.entryDigestStripped}:{},...n!==void 0?{json:n}:{}}}function Hh(t){let e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let n;try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}let r;try{r=JSON.parse(n)}catch{return}if(!(r===null||typeof r!="object"||Array.isArray(r)))return r}function ff(t){if(t.includes("\0"))return{path:t,unsafe:!0,reason:"path contains a NUL byte"};let e=t.startsWith("/"),n=t.split("/").filter(o=>o!==""&&o!=="."),r=n.join("/");return e?{path:r,unsafe:!0,reason:"absolute path"}:n.some(o=>o==="..")?{path:r,unsafe:!0,reason:"path escapes the bundle root"}:r===""?{path:r,unsafe:!0,reason:"empty path"}:{path:r,unsafe:!1}}function ue(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Nh(t){if(!ue(t)||t.type!=="bitgraph-fuse/1")return;let e=t.proof;return uf(e)?e:void 0}function uf(t){return ue(t)?typeof t.version=="string"&&ue(t.artifact)&&ue(t.commit)&&ue(t.signer):!1}function $h(t,e,n,r,o){let i=kt(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=Dh(e,i);a==="mismatch"&&o.push({code:"proofhash-mismatch",path:t.path,message:"embedded proofHash does not match the computed canonical proof hash",details:{embedded:e.proofHash,computed:i}});let c=n.get(i);if(c!==void 0){let b=c.sources.some(p=>p.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),o.push({code:b?"exact-duplicate":"semantic-duplicate",path:t.path,message:b?"byte-identical copy of an already observed proof":"different byte encoding of an already observed proof (same canonical identity)",details:{proofHash:i,firstObservedAt:c.sources[0].path}}),b?"exact-duplicate":"semantic-duplicate"}let f=ue(e.commit)?e.commit:{},u=ue(e.signer)?e.signer:{},l=ue(e.environment)?e.environment:{},d=ke(f.counter),h=ke(f.epochId),m=ke(f.chainId),y={proofHash:i,chainHash:Jo(e),proof:e,sources:[s],version:"bitgraph/1",...d!==void 0?{counter:d}:{},...ke(f.slotCounter)!==void 0?{slotCounter:ke(f.slotCounter)}:{},...ke(f.prevB64)!==void 0?{prevB64:ke(f.prevB64)}:{},...h!==void 0?{epochId:h}:{},chainId:m!==void 0&&m.length>0?m:"global",...ke(u.publicKeyB64)!==void 0?{publicKeyB64:ke(u.publicKeyB64)}:{},...ke(l.measurement)!==void 0?{measurement:ke(l.measurement)}:{},...ke(l.enforcement)!==void 0?{enforcement:ke(l.enforcement)}:{},hasSlotAllocation:ue(e.slotAllocation),hasAttestation:ue(l.attestation),hasAgency:ue(e.agency),hasEpochLink:ue(f.epochLink),embeddedProofHash:a,chainless:d===void 0&&h===void 0};return n.set(i,y),r.push(y),"new"}function Dh(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function ke(t){return typeof t=="string"?t:void 0}function rf(t,e){let n=e.get(t.sha256Hex);if(n!==void 0){n.paths.push(t.path);return}e.set(t.sha256Hex,{sha256Hex:t.sha256Hex,sha256B64:E.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function _h(t){if(!ue(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=E.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function Mh(t,e,n){if(t.json===void 0)return n.push({code:"manifest-unparseable",path:t.path,message:"root manifest.json did not parse as a single JSON object; proceeding as if no manifest were present"}),{path:t.path,parsed:!1,recognized:!1,problems:[]};let r=t.json,o=r.version;if(o!==vi)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(o)} is not "${vi}"; the manifest was not interpreted`,...typeof o=="string"?{details:{version:o}}:{}}),{path:t.path,parsed:!0,...typeof o=="string"?{version:o}:{},recognized:!1,problems:[]};let i=Ph(r);for(let c of i)n.push({code:"manifest-field-invalid",path:t.path,message:c});let s={path:t.path,parsed:!0,version:vi,recognized:!0,manifest:r,problems:i},a=r.contentsHashB64;if(typeof a=="string"&&a.length>0){let c=a===e;s.contentsHash={declaredB64:a,computedB64:e,match:c},c||n.push({code:"manifest-contents-hash-mismatch",path:t.path,message:"manifest contentsHashB64 does not match the computed contents hash; the bundle held is not byte-for-byte the bundle the manifest describes. Advisory: this does not fail any proof.",details:{declared:a,computed:e}})}return s}function Ph(t){let e=[],n=r=>Array.isArray(r)&&r.every(o=>typeof o=="string");if(t.epochIds!==void 0&&!n(t.epochIds)&&e.push("manifest.epochIds must be an array of strings when present"),t.chainIds!==void 0&&!n(t.chainIds)&&e.push("manifest.chainIds must be an array of strings when present"),t.proofCount!==void 0&&(typeof t.proofCount!="number"||!Number.isInteger(t.proofCount)||t.proofCount<0)&&e.push("manifest.proofCount must be a non-negative integer when present"),t.counterRanges!==void 0&&(Array.isArray(t.counterRanges)&&t.counterRanges.every(o=>ue(o)&&typeof o.epochId=="string"&&typeof o.chainId=="string"&&typeof o.min=="string"&&typeof o.max=="string")||e.push("manifest.counterRanges must be an array of { epochId, chainId, min, max } string fields when present")),t.generatedAt!==void 0&&typeof t.generatedAt!="string"&&e.push("manifest.generatedAt must be a string when present"),t.contentsHashB64!==void 0){let r=t.contentsHashB64,o=typeof r=="string"&&r.length>0;if(o){let i=E.Buffer.from(r,"base64");o=i.toString("base64")===r&&i.length===32}o||e.push("manifest.contentsHashB64 must be standard base64 of 32 bytes when present")}return t.artifactsIncluded!==void 0&&typeof t.artifactsIncluded!="boolean"&&e.push("manifest.artifactsIncluded must be a boolean when present"),t.openEpochs!==void 0&&(Array.isArray(t.openEpochs)&&t.openEpochs.every(o=>ue(o)&&typeof o.epochId=="string"&&typeof o.counterAtSnapshot=="string")||e.push("manifest.openEpochs must be an array of { epochId, counterAtSnapshot } string fields when present")),e}function Vr(t){return E.Buffer.from(t).toString("hex")}function Ri(t,e){let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}g();async function Hi(t,e){nt();let n=e?.trustAnchors,r=new Map(t.proofs.map(f=>[f.proofHash,f])),o=new Map;for(let f of t.artifacts){if(f.matchedProofHashes.length===0)continue;let u=f.matchedProofHashes.map(l=>r.get(l)).filter(l=>l!==void 0);o.set(f.sha256Hex,u)}for await(let f of Si(t)){let u=o.get(f.sha256Hex)??[];for(let l of u){if(l.verification!==void 0)continue;let d=await Sr({proof:l.proof,bytes:f.bytes,...n!==void 0?{trustAnchors:n}:{}}),h={tier:"full",status:d.valid?"verified":"failed",...d.reason!==void 0?{reason:d.reason}:{},artifactPath:f.path};l.verification=h}}for(let f of t.proofs){if(f.verification!==void 0)continue;let u=await we({proof:f.proof,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"integrity",status:u.valid?"artifact-unavailable":"failed",...u.reason!==void 0?{reason:u.reason}:{}};f.verification=l}let i=0,s=0,a=0,c=0;for(let f of t.proofs){let u=f.verification?.status;u==="verified"?i++:u==="failed"?s++:u==="artifact-unavailable"&&a++,f.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}g();g();var lf=new WeakMap;async function ft(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=lf.get(t);if(n!==void 0)return n;nt();let r=!1;try{r=(await we({proof:t.proof})).valid}catch{r=!1}return nt(),lf.set(t,r),r}function X(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function ze(t,e){let n=X(t.counter),r=X(e.counter);return n!==void 0&&r!==void 0&&n!==r?n<r?-1:1:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:t.proofHash<e.proofHash?-1:t.proofHash>e.proofHash?1:0}function pe(t,e,n){let r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}async function $i(t){let e=[],n=[],r=new Map;for(let f of t.proofs){if(f.chainless){e.push(f.proofHash);continue}if(f.publicKeyB64===void 0){n.push(f.proofHash);continue}let u={publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId},l=JSON.stringify([u.publicKeyB64,u.epochId??null,u.chainId]),d=r.get(l);d===void 0?r.set(l,{key:u,members:[f]}):d.members.push(f)}let o=[...r.values()].sort((f,u)=>Oh(f.key,u.key)),i=[],s=new Set,a=new Map;for(let f of o){let u=Lh(f.key,f.members,s);i.push(u);for(let l of u.memberProofHashes)a.set(l,f.key)}let c=await Vh(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function Oh(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";return n!==r?n<r?-1:1:t.publicKeyB64!==e.publicKeyB64?t.publicKeyB64<e.publicKeyB64?-1:1:0}function Lh(t,e,n){let r=new Map(e.map(d=>[d.chainHash,d])),o=new Map,i=new Set,s=new Map;for(let d of e)s.set(d.proofHash,d.proofHash);let a=d=>{let h=d;for(;s.get(h)!==h;)h=s.get(h);let m=d;for(;m!==h;){let y=s.get(m);s.set(m,h),m=y}return h},c=(d,h)=>{let m=a(d),y=a(h);m!==y&&s.set(m,y)};for(let d of e){if(d.prevB64===void 0)continue;let h=r.get(d.prevB64);h===void 0||h.proofHash===d.proofHash||(i.add(d.proofHash),pe(o,h.proofHash,d),n.add(h.proofHash),c(h.proofHash,d.proofHash))}let f=new Map;for(let d of e)pe(f,a(d.proofHash),d);let u=[];for(let d of f.values())u.push(Fh(d,o,i));u.sort(Uh);let l=[...e].sort(ze).map(d=>d.proofHash);return{key:t,memberProofHashes:l,components:u}}function Fh(t,e,n){let r=[...t].sort(ze),o=r.filter(d=>d.prevB64===void 0),i=r.filter(d=>d.prevB64!==void 0&&!n.has(d.proofHash)),s=r.filter(d=>(e.get(d.proofHash)??[]).length===0),a=new Set,c=[],f=d=>{let h=[d];for(;h.length>0;){let m=h.pop();if(a.has(m))continue;a.add(m),c.push(m);let y=[...e.get(m)??[]].sort(ze);for(let b=y.length-1;b>=0;b--)h.push(y[b].proofHash)}};for(let d of[...o,...i])f(d.proofHash);for(let d of r)a.has(d.proofHash)||f(d.proofHash);let u,l;for(let d of t)for(let h of[d.counter,d.slotCounter]){let m=X(h);m!==void 0&&((u===void 0||m<u)&&(u=m),(l===void 0||m>l)&&(l=m))}return{memberProofHashes:c,genesisProofHashes:o.map(d=>d.proofHash),brokenLinkProofHashes:i.map(d=>d.proofHash),terminalProofHashes:s.map(d=>d.proofHash),hasCounterEvidence:u!==void 0,...u!==void 0&&l!==void 0?{positionRange:{min:String(u),max:String(l)}}:{}}}function Uh(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}async function Vh(t,e,n,r){let o=new Map;for(let d of e){let h=d.key.epochId;if(h===void 0)continue;let m=o.get(h);m===void 0&&(m={chainIds:new Set,publicKeys:new Set,proofCount:0},o.set(h,m)),m.chainIds.add(d.key.chainId),m.publicKeys.add(d.key.publicKeyB64),m.proofCount+=d.memberProofHashes.length}let i=new Map(t.proofs.map(d=>[d.chainHash,d])),s=[];for(let d of t.proofs){if(!d.hasEpochLink)continue;let h=jh(d);h!==null&&s.push(await Kh(h,d,i,o,n,r))}let a=zh(s),c=new Set,f=new Map,u=new Map;for(let d of s)d.hardEdge&&(c.add(d.fromEpochId),c.add(d.toEpochId),Ni(f,d.toEpochId,d.fromEpochId),Ni(u,d.fromEpochId,d.toEpochId));return{epochs:[...o.entries()].sort(([d],[h])=>d<h?-1:d>h?1:0).map(([d,h])=>({epochId:d,chainIds:[...h.chainIds].sort(),publicKeysB64:[...h.publicKeys].sort(),proofCount:h.proofCount,ordering:c.has(d)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...f.get(d)??[]].sort(),linkedSuccessorEpochIds:[...u.get(d)??[]].sort()})),edges:s,orderedPairs:a}}function jh(t){let e=t.proof.commit;if(e===null||typeof e!="object")return null;let n=e.epochLink;if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,o=["prevEpochId","prevPublicKeyB64","prevCounter","prevProofHashB64","toEpochId","toPublicKeyB64"],i={};for(let s of o){let a=r[s];if(typeof a!="string"||a.length===0)return null;i[s]=a}return i}async function Kh(t,e,n,r,o,i){let s=await ft(e),a=n.get(t.prevProofHashB64);if(a===void 0){let d=r.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:d?"terminal-missing":"dangling",viaProofValid:s,hardEdge:!1}}let c=[];a.epochId!==t.prevEpochId&&c.push(`the referenced proof's epochId (${a.epochId??"absent"}) does not match epochLink.prevEpochId (${t.prevEpochId})`),a.publicKeyB64!==t.prevPublicKeyB64&&c.push("the referenced proof's signer key does not match epochLink.prevPublicKeyB64"),Gh(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await ft(a),u=c.length===0,l=i.has(a.proofHash);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:"matched",predecessorProofHash:a.proofHash,metadataConsistent:u,...u?{}:{inconsistencies:c},...l?{referencedProofIsTerminal:!o.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:u&&s&&f}}function Gh(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=X(t),r=X(e);return n!==void 0&&r!==void 0&&n===r}function zh(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(Ni(e,i.fromEpochId,i.toEpochId),n.add(i.fromEpochId),n.add(i.toEpochId));let r=new Set;for(let i of n){let s=new Set,a=[...e.get(i)??[]];for(;a.length>0;){let c=a.pop();if(!s.has(c)){s.add(c);for(let f of e.get(c)??[])a.push(f)}}for(let c of s)c!==i&&r.add(`${i}\0${c}`)}let o=[];for(let i of r){let[s,a]=i.split("\0");r.has(`${a}\0${s}`)||o.push({beforeEpochId:s,afterEpochId:a})}return o.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),o}function Ni(t,e,n){let r=t.get(e);r===void 0?t.set(e,new Set([n])):r.add(n)}g();var Wh=1e4;async function Di(t,e){let n=[],r=[],o=[],i=new Map(t.proofs.map(c=>[c.proofHash,c])),s=new Map(t.proofs.map(c=>[c.chainHash,c])),a=new Map;for(let c of e.partitions)for(let f of c.memberProofHashes)a.set(f,c.key);for(let c of e.partitions){let f=c.memberProofHashes.map(u=>i.get(u));qh(c,f,n),await df(c,f,"counter",n,r),await df(c,f,"slot",n,r),await Yh(c,f,n,r),await Zh(c,f,s,n,r),Xh(c,f,s,a,n,o),await Qh(c,f,n,r),ep(c,f,n)}return await tp(e.epochRelationships.edges,i,n,r),{anomalies:n,divergences:r,boundaryEntryPoints:o}}function qh(t,e,n){let r=new Set;for(let l of e){let d=X(l.counter);d!==void 0&&r.add(d);let h=X(l.slotCounter);h!==void 0&&r.add(h)}if(r.size<2)return;let o=[...r].sort((l,d)=>l<d?-1:l>d?1:0),i=[],s=[],a=0n;for(let l=1;l<o.length;l++){let d=o[l-1]+1n,h=o[l]-1n;if(!(d>h)){i.push({start:String(d),end:String(h)}),a+=h-d+1n;for(let m=d;m<=h&&s.length<Wh;m++)s.push(String(m))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},f=String(o[0]),u=String(o[o.length-1]);n.push({code:"unexplained-counter-positions",partition:t.key,proofHashes:[],message:`${a} counter position${a===1n?"":"s"} within the observed range [${f}, ${u}] of this partition ${a===1n?"is":"are"} neither a commit position nor a referenced reserved position in the supplied bundle. Such ${a===1n?"a position":"positions"} may mean a proof is absent from the bundle, or a position that was reserved but never committed (a routine, benign occurrence); this offline audit cannot distinguish the two. It does not, by itself, establish that the authority failed to create or withheld any proof.`,details:c})}async function df(t,e,n,r,o){let i=new Map;for(let s of e){let a=n==="counter"?s.counter:s.slotCounter;if(a===void 0)continue;let c=X(a);pe(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of _i(i)){if(a.length<2)continue;let{parties:c,context:f}=await jr(a);if(c.length<2)continue;let u=s.startsWith("raw:")?s.slice(4):s,l=n==="counter"?"counter-collision":"slot-collision";r.push({code:l,partition:t.key,proofHashes:a.map(d=>d.proofHash),message:n==="counter"?`${c.length} distinct valid proofs claim commit counter ${u} in one partition. The audit does not choose between them; all parties are preserved for adjudication.`:`${c.length} distinct valid proofs reference reserved position ${u} in one partition. A reserved position is consumed exactly once; all parties are preserved for adjudication.`,details:{position:u,validParties:c.map(d=>d.proofHash),invalidObserved:f.map(d=>d.proofHash)}}),o.push({kind:l,partition:t.key,contested:n==="counter"?{counter:u}:{slotCounter:u},parties:c.map(We),invalidContext:f.map(We),explanation:n==="counter"?`Two or more independently valid proof objects claim commit counter ${u} in the same signer, epoch, and chain partition. A commit counter position can be consumed only once, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them; every party and its predecessor relationship is preserved for adjudication.`:`Two or more independently valid proof objects reference reserved position ${u} in the same signer, epoch, and chain partition. A reserved position is allocated once and consumed by one commit, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them.`})}}async function Yh(t,e,n,r){let o=new Map,i=new Map;for(let a of e){let c=X(a.counter);c!==void 0&&pe(o,String(c),a);let f=X(a.slotCounter);f!==void 0&&pe(i,String(f),a)}let s=[...o.keys()].filter(a=>i.has(a)).sort((a,c)=>BigInt(a)<BigInt(c)?-1:BigInt(a)>BigInt(c)?1:0);for(let a of s){let c=o.get(a),f=i.get(a),u=[];for(let p of c)await ft(p)&&u.push(p);let l=[];for(let p of f)await ft(p)&&l.push(p);if(!u.some(p=>l.some(A=>A.proofHash!==p.proofHash)))continue;let h=new Map;for(let p of[...u,...l])h.set(p.proofHash,p);let m=[...h.values()],y=new Map;for(let p of[...c,...f])y.set(p.proofHash,p);let b=[...y.values()].filter(p=>!h.has(p.proofHash));n.push({code:"cross-kind-position-reuse",partition:t.key,proofHashes:[...y.keys()],message:`Counter position ${a} is committed by one proof and reserved by a different proof in the same partition. A single causal position is consumed once, as a reservation or as a commit, never both across distinct proofs. The audit does not choose between them; all parties are preserved for adjudication.`,details:{position:a,commitParties:u.map(p=>p.proofHash),slotParties:l.map(p=>p.proofHash),validParties:m.map(p=>p.proofHash),invalidObserved:b.map(p=>p.proofHash)}}),r.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:m.map(We),invalidContext:b.map(We),explanation:`Two or more independently valid proof objects allocate counter position ${a} in the same signer, epoch, and chain partition through different roles: at least one commits at it and at least one reserves it. Each position in a chain is consumed exactly once, so at most one of these allocations can belong to the authoritative sequence. This pattern only arises through enclave malfunction, replay, or compromise. The audit tool does not choose between them; every party is preserved for adjudication.`})}}async function Zh(t,e,n,r,o){let i=new Map;for(let s of e)s.prevB64!==void 0&&pe(i,s.prevB64,s);for(let[s,a]of _i(i)){if(a.length<2)continue;let{parties:c,context:f}=await jr(a);if(c.length<2)continue;let u=n.has(s);r.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(l=>l.proofHash),message:`${c.length} distinct valid proofs claim the same predecessor hash: a detectable fork. All branches are preserved; the audit does not choose between them.`,details:{prevB64:s,predecessorObserved:u,validParties:c.map(l=>l.proofHash),invalidObserved:f.map(l=>l.proofHash)}}),o.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map(We),invalidContext:f.map(We),explanation:`Two or more independently valid proof objects name the same predecessor proof in their prevB64 hash link. Each proof has exactly one successor in an intact chain, so this is a fork: the history diverges into multiple branches at that predecessor${u?", which is itself observed in the bundle":", which is absent from the bundle"}. All branches are shown; the audit tool does not select one.`})}}function Xh(t,e,n,r,o,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let f=X(c.counter);f!==void 0&&(a===void 0||f<a)&&(a=f)}for(let c of[...e].sort(ze)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!Jh(c.prevB64)){o.push({code:"chain-break-malformed",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 is not standard base64 of 32 bytes, so it can never match a canonical proof hash. The predecessor link is unusable as reconstruction evidence.",details:{prevB64:c.prevB64}});continue}let f=n.get(c.prevB64);if(f!==void 0){let d=r.get(f.proofHash);o.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,f.proofHash],message:"commit.prevB64 resolves to an observed proof outside this proof's own signer, epoch, and chain partition. prevB64 never bridges partitions (each epoch and chain keeps its own hash chain), so this link does not join the two.",details:{prevB64:c.prevB64,predecessorProofHash:f.proofHash,predecessorPartition:d!==void 0?{publicKeyB64:d.publicKeyB64,...d.epochId!==void 0?{epochId:d.epochId}:{},chainId:d.chainId}:"unchained-or-unpartitioned"}});continue}let u=X(c.counter);if(u===void 0||a===void 0||u<=a){i.push({partition:t.key,proofHash:c.proofHash,prevB64:c.prevB64});continue}o.push({code:"chain-break-missing",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 references a predecessor proof that is absent from the supplied bundle, and a lower-positioned proof IS present, so this is an interior break (a hole), not the excerpt's starting boundary. The chain cannot be reconstructed across this link from the supplied evidence; this does not, by itself, establish that the predecessor never existed.",details:{prevB64:c.prevB64}})}}function Jh(t){if(t.length===0)return!1;let e=E.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function Qh(t,e,n,r){let o=[...e.filter(a=>a.prevB64===void 0)].sort(ze);if(o.length<2)return;let{parties:i,context:s}=await jr(o);n.push({code:"multiple-genesis",partition:t.key,proofHashes:o.map(a=>a.proofHash),message:`${o.length} proofs in one partition carry no prevB64 link. An epoch has exactly one first proof, so at most one of these can be the genesis of this partition's chain.`,details:{validParties:i.map(a=>a.proofHash),invalidObserved:s.map(a=>a.proofHash)}}),!(i.length<2)&&r.push({kind:"multiple-genesis",partition:t.key,contested:{...t.key.epochId!==void 0?{epochId:t.key.epochId}:{},chainId:t.key.chainId},parties:i.map(We),invalidContext:s.map(We),explanation:"Two or more independently valid proof objects in the same signer, epoch, and chain partition carry no predecessor link, each presenting itself as the first proof of the chain. An epoch has exactly one first proof, so at most one of these can be the genesis. The audit tool does not choose between them."})}function ep(t,e,n){for(let r of[...e].sort(ze)){let o=X(r.slotCounter),i=X(r.counter);o===void 0||i===void 0||o<i||n.push({code:"slot-order-violation",partition:t.key,proofHashes:[r.proofHash],message:"commit.slotCounter is not strictly less than commit.counter. The position must be reserved before the commit that consumes it, so this proof's declared positions contradict the nonce-first construction order.",details:{slotCounter:r.slotCounter,counter:r.counter}})}}async function tp(t,e,n,r){for(let s of t)s.resolution==="terminal-missing"?n.push({code:"epochlink-terminal-missing",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch that is observed in the bundle, but the referenced terminal proof is absent from the bundle. The lineage claim cannot be confirmed from the supplied evidence; this does not, by itself, establish that the terminal never existed.",details:{link:{...s.link}}}):s.resolution==="dangling"?n.push({code:"epochlink-dangling",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch and terminal proof, neither of which is observed in the bundle. The lineage claim dangles into unobserved history; it cannot be confirmed from the supplied evidence.",details:{link:{...s.link}}}):s.metadataConsistent===!1&&n.push({code:"epochlink-mismatch",proofHashes:[s.viaProofHash,...s.predecessorProofHash!==void 0?[s.predecessorProofHash]:[]],message:"commit.epochLink's prevProofHashB64 matches an observed proof, but the link's declared epoch, signer key, or counter disagrees with that proof. The hash reference and the declared metadata cannot both be right.",details:{link:{...s.link},inconsistencies:s.inconsistencies??[]}});let o=new Map;for(let s of t)pe(o,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of _i(o)){let a=new Set(s.map(d=>d.link.toEpochId));if(a.size<2)continue;let c=s.map(d=>e.get(d.viaProofHash)),{parties:f,context:u}=await jr(c),l=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(d=>d.viaProofHash),message:`The same predecessor terminal (epoch ${l.prevEpochId}, counter ${l.prevCounter}) is consumed by genesis proofs of ${a.size} distinct successor epochs. A predecessor may be consumed by at most one successor epoch, so this is a detectable fork at the epoch boundary. All branches are preserved.`,details:{prevEpochId:l.prevEpochId,prevCounter:l.prevCounter,prevProofHashB64:l.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:f.map(d=>d.proofHash),invalidObserved:u.map(d=>d.proofHash)}}),!(f.length<2)&&r.push({kind:"epochlink-fork",contested:{prevEpochId:l.prevEpochId,prevCounter:l.prevCounter,prevProofHashB64:l.prevProofHashB64},parties:f.map(We),invalidContext:u.map(We),explanation:"Two or more independently valid epoch-genesis proofs consume the same terminal proof of a prior epoch through their epochLink. The single-successor rule allows a terminal to be consumed by exactly one successor epoch, so at most one of these lineages can be the authoritative continuation. Note that whichever party verified second in this run carries a fork-detection failure from the canonical verifier; that ordering is an artifact of verification order, not evidence of which branch is authoritative. The audit tool does not choose between them."})}let i=new Map;for(let s of t){if(s.resolution!=="matched")continue;let a=i.get(s.fromEpochId);a===void 0?i.set(s.fromEpochId,new Set([s.toEpochId])):a.add(s.toEpochId)}for(let s of np(i)){let a=t.filter(c=>c.resolution==="matched"&&s.includes(c.fromEpochId)&&s.includes(c.toEpochId)).map(c=>c.viaProofHash);n.push({code:"epochlink-cycle",proofHashes:a,message:`Epoch lineage links form a cycle among ${s.length} epochs. Each link claims its successor epoch came after its predecessor, so a cycle means these ordering claims contradict each other; no ordering is asserted for the epochs involved.`,details:{epochIds:s}})}}function np(t){let e=new Map,n=new Set,r=[...t.keys()].sort();for(let o of r){if(n.has(o))continue;let i=[],s=new Set,a=new Map,c=[o];for(;c.length>0;){let f=c[c.length-1];s.has(f)||(s.add(f),i.push(f),a.set(f,[...t.get(f)??[]].sort()));let l=a.get(f).shift();if(l===void 0){c.pop(),s.delete(f),i.pop(),n.add(f);continue}if(s.has(l)){let d=i.indexOf(l),h=i.slice(d),m=rp(h);e.set(m.join("|"),m);continue}n.has(l)||c.push(l)}}return[...e.values()].sort((o,i)=>{let s=o.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function rp(t){let e=0;for(let n=1;n<t.length;n++)t[n]<t[e]&&(e=n);return[...t.slice(e),...t.slice(0,e)]}async function jr(t){let e=[],n=[];for(let r of t)await ft(r)?e.push(r):n.push(r);return{parties:e,context:n}}function We(t){let e=t.verification;return{proofHash:t.proofHash,sourcePaths:t.sources.map(n=>n.path),...e!==void 0?{verificationTier:e.tier,verificationStatus:e.status,...e.reason!==void 0?{verificationReason:e.reason}:{}}:{},...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.prevB64!==void 0?{prevB64:t.prevB64}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.measurement!==void 0?{measurement:t.measurement}:{}}}function _i(t){return[...t.entries()].sort(([e],[n])=>{let r=/^[0-9]+$/.test(e)?BigInt(e):void 0,o=/^[0-9]+$/.test(n)?BigInt(n):void 0;return r!==void 0&&o!==void 0&&r!==o?r<o?-1:1:r!==void 0&&o===void 0?-1:r===void 0&&o!==void 0?1:e<n?-1:e>n?1:0})}g();function Mi(t){let e=new Map;for(let a of t.proofs){let c=JSON.stringify([a.measurement??null,a.publicKeyB64??null,a.epochId??null,a.chainId,a.hasAttestation]),f=e.get(c);if(f!==void 0){f.proofHashes.push(a.proofHash);continue}e.set(c,{...a.measurement!==void 0?{measurement:a.measurement}:{},...a.publicKeyB64!==void 0?{publicKeyB64:a.publicKeyB64}:{},...a.epochId!==void 0?{epochId:a.epochId}:{},chainId:a.chainId,attestationPresent:a.hasAttestation,proofHashes:[a.proofHash]})}let n=[...e.values()].sort(op),r=new Map;for(let a of t.proofs)a.epochId!==void 0&&pe(r,a.epochId,a);let o=[];for(let[a,c]of[...r.entries()].sort(([f],[u])=>f<u?-1:f>u?1:0)){let f=new Set,u=new Set;for(let l of c)l.publicKeyB64!==void 0&&f.add(l.publicKeyB64),l.measurement!==void 0&&u.add(l.measurement);f.size>=2&&o.push({code:"mid-epoch-signer-change",proofHashes:c.map(l=>l.proofHash),message:`${f.size} distinct signer keys appear within epoch ${a}. A single enclave boot generates exactly one keypair per epoch, so multiple keys under one epochId cannot come from one healthy authority lifecycle. All key groups are preserved for adjudication.`,details:{epochId:a,publicKeysB64:[...f].sort()}}),u.size>=2&&o.push({code:"mid-epoch-measurement-change",proofHashes:c.map(l=>l.proofHash),message:`${u.size} distinct declared measurements appear within epoch ${a}. A single enclave boot has exactly one measurement, so multiple declared measurements under one epochId cannot come from one healthy authority lifecycle. Declared measurements are self-reported; attestation validation is reported separately.`,details:{epochId:a,measurements:[...u].sort()}})}let i=new Map;for(let a of t.proofs){if(a.publicKeyB64===void 0||a.epochId===void 0)continue;let c=i.get(a.publicKeyB64);c===void 0?i.set(a.publicKeyB64,new Set([a.epochId])):c.add(a.epochId)}let s=[...i.entries()].filter(([,a])=>a.size>=2).map(([a,c])=>({publicKeyB64:a,epochIds:[...c].sort()})).sort((a,c)=>a.publicKeyB64<c.publicKeyB64?-1:a.publicKeyB64>c.publicKeyB64?1:0);return{groups:n,anomalies:o,sharedSignersAcrossEpochs:s}}function op(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";if(n!==r)return n<r?-1:1;let o=t.publicKeyB64??"",i=e.publicKeyB64??"";if(o!==i)return o<i?-1:1;let s=t.measurement??"",a=e.measurement??"";return s!==a?s<a?-1:1:t.attestationPresent!==e.attestationPresent?t.attestationPresent?-1:1:0}g();var hf="ethereum-anchor",ip=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function Oi(t){let e=[],n=[],r=[];for(let o of t.proofs){let i=sp(o),s=Bo(o.proof);if(s===null){i===hf&&(n.push(o.proofHash),r.push({code:"anchor-metadata-only-claim",...Pi(o),message:"unsigned metadata.type claims ethereum-anchor, but the proof carries neither a signed commit.anchor nor the signed attribution name. Metadata is advisory and unsigned; the proof is not treated as an anchor.",details:{proofHash:o.proofHash}}));continue}let a=i===hf?"agrees":i===void 0?"absent":"disagrees";a==="disagrees"&&r.push({code:"anchor-metadata-disagreement",...Pi(o),message:`this proof is a signed Ethereum anchor, but unsigned metadata.type is ${JSON.stringify(i)}. The signed field governs; the disagreement is recorded.`,details:{proofHash:o.proofHash,metadataType:i}});let c=Ao(o.proof),f=c?.blockHash??pf(o,"message"),u=pf(o,"title"),l=c!==null?String(c.blockNumber):u!==void 0?ip.exec(u)?.[1]??void 0:void 0;l===void 0&&s==="legacy-attribution"&&r.push({code:"anchor-title-unparseable",...Pi(o),message:u===void 0?"anchor proof carries no signed attribution.title; the signed block number is absent":"anchor attribution.title does not parse as an Etherscan block URL; the signed block number is treated as absent",details:{proofHash:o.proofHash,...u!==void 0?{title:u}:{}}});let d=o.verification;e.push({proofHash:o.proofHash,...o.epochId!==void 0?{epochId:o.epochId}:{},chainId:o.chainId,...o.counter!==void 0?{counter:o.counter}:{},...o.slotCounter!==void 0?{slotCounter:o.slotCounter}:{},...f!==void 0?{blockHash:f}:{},...l!==void 0?{blockNumber:l}:{},metadataCorroboration:a,...d!==void 0?{verificationTier:d.tier,verificationStatus:d.status,...d.reason!==void 0?{verificationReason:d.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:r}}function pf(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function sp(t){let e=t.proof.metadata;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.type;return typeof n=="string"?n:void 0}function Pi(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}g();g();function bf(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=yf(t,0);if(n!==t.length)throw new Error(`RLP: ${t.length-n} trailing byte(s) after the top-level item`);if(!Array.isArray(e))throw new Error("RLP: top-level item is not a list");return e}function yf(t,e){let n=wf(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=Kr(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=gf(t,e+1,a),f=e+1+a,u=Kr(t,f,c);return{item:t.subarray(f,u),next:u}}if(n<=247){let a=n-192,c=Kr(t,e+1,a);return{item:mf(t,e+1,c),next:c}}let r=n-247,o=gf(t,e+1,r),i=e+1+r,s=Kr(t,i,o);return{item:mf(t,i,s),next:s}}function mf(t,e,n){let r=[],o=e;for(;o<n;){let i=yf(t,o);if(i.next>n)throw new Error("RLP: list item overruns its list payload");r.push(i.item),o=i.next}return r}function gf(t,e,n){if(n<1||n>8)throw new Error(`RLP: invalid length-of-length ${n}`);let r=0;for(let o=0;o<n;o++)r=r*256+wf(t,e+o);if(r>t.length)throw new Error("RLP: declared length exceeds the input size");return r}function Kr(t,e,n){let r=e+n;if(r>t.length)throw new Error("RLP: item is truncated");return r}function wf(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function Li(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function xf(t){if(!t.startsWith("0x"))return null;let e=t.slice(2);if(e.length%2!==0||!/^[0-9a-fA-F]*$/.test(e))return null;let n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++)n[r]=Number.parseInt(e.slice(r*2,r*2+2),16);return n}function Ef(t){return`0x${E.Buffer.from(t).toString("hex")}`}var kf=8,Bf=11,ap=/^0x[0-9a-fA-F]{64}$/,cp=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function Ui(t,e){let n=[],r=[],o=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=fp(i);if(s.failure!==void 0){let u={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(u),r.push(Fi(u));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),f=e.anchors.filter(u=>{let l=u.blockHash?.toLowerCase();return l!==void 0&&(l===a||l===c)});if(f.length===0){let u={witnessPath:i.path,verified:!1,reason:"witness-unmatched",detail:"neither the locally recomputed block hash nor the claimed blockHash matches any observed anchor's signed attribution.message",computedBlockHash:a};n.push(u),r.push(Fi(u));continue}for(let u of f){let l=o.get(u.proofHash),d=l!==void 0&&await ft(l),h=up(s,i.path,u.proofHash,l,d);n.push(h),h.verified||r.push(Fi(h))}}return{outcomes:n,findings:r}}function fp(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return Gr("headerRlpHex is missing or not a string");let r=e.blockNumber;if(typeof r!="number"||!Number.isInteger(r)||r<0)return Gr("blockNumber is missing or not a non-negative integer");let o=e.blockHash;if(typeof o!="string"||!ap.test(o))return Gr("blockHash is missing or not 0x followed by 64 hex characters");let i=xf(n);if(i===null)return Gr("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=bf(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:Ef(Dr(i)),items:s,claimedHash:o,claimedNumber:BigInt(r)}}function Gr(t){return{failure:{reason:"witness-malformed",detail:t}}}function up(t,e,n,r,o){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(p,A,B)=>({...s,verified:!1,reason:p,detail:A,...B?.blockNumber!==void 0?{blockNumber:B.blockNumber}:{}});if(r===void 0||!o)return a("witness-anchor-invalid","the candidate anchor proof is not cryptographically valid; the witness confers nothing");let c=lp(r);if(c===void 0||c.toLowerCase()!==i)return a("witness-hash-mismatch",c===void 0?"the anchor carries no signed attribution.message to compare against":"the locally recomputed block hash does not equal the anchor's signed attribution.message");let f=pp(hp(r));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let u=O(new TextEncoder().encode(c));if(!mp(u,f))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let l=t.items,d=l[kf];if(d===void 0||!(d instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${kf} (block number) is missing or not a byte string`);let h=Li(d);if(h!==t.claimedNumber)return a("witness-block-number-mismatch",`the witness claims blockNumber ${t.claimedNumber}, but the header's number field is ${h}`,{blockNumber:String(h)});let m=dp(r);if(m!==void 0){let p=cp.exec(m)?.[1];if(p!==void 0&&BigInt(p)!==h)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${p}, but the header's number field is ${h}`,{blockNumber:String(h)})}if(t.claimedHash.toLowerCase()!==i)return a("witness-claimed-hash-mismatch","the witness's claimed blockHash does not equal the locally recomputed block hash",{blockNumber:String(h)});let y=l[Bf];if(y===void 0||!(y instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Bf} (timestamp) is missing or not a byte string`,{blockNumber:String(h)});let b=Li(y);return b>BigInt(Number.MAX_SAFE_INTEGER)?a("witness-header-shape","header timestamp does not fit a safe integer",{blockNumber:String(h)}):{...s,verified:!0,blockNumber:String(h),timestamp:Number(b)}}function lp(t){return Af(t,"message")}function dp(t){return Af(t,"title")}function Af(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function hp(t){let e=t.proof.artifact;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.digestB64;return typeof n=="string"?n:void 0}function pp(t){if(t===void 0||t.length===0)return null;let e=E.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function mp(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function Fi(t){return{code:t.reason,path:t.witnessPath,message:`anchor witness rejected: ${t.detail??"verification failed"}. The witness confers nothing; the anchor proof's own standing is unchanged.`,details:{...t.anchorProofHash!==void 0?{anchorProofHash:t.anchorProofHash}:{},...t.computedBlockHash!==void 0?{computedBlockHash:t.computedBlockHash}:{}}}}g();function Vi(t,e,n,r){let o=new Map(t.proofs.map(u=>[u.proofHash,u])),i=new Map;for(let u of r.outcomes)!u.verified||u.anchorProofHash===void 0||i.has(u.anchorProofHash)||i.set(u.anchorProofHash,{anchorProofHash:u.anchorProofHash,timestamp:u.timestamp,blockHash:u.computedBlockHash,...u.blockNumber!==void 0?{blockNumber:u.blockNumber}:{}});let s=[...i.keys()].sort(),a=n.anchors.map(u=>u.proofHash).filter(u=>!i.has(u)).sort(),c=[];for(let u of e.partitions)c.push(...gp(u,o,i));let f=kp(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function gp(t,e,n){let r=t.memberProofHashes.map(d=>e.get(d)),o=new Map(r.map(d=>[d.chainHash,d])),i=r.filter(d=>n.has(d.proofHash)),s=new Map;for(let d of r){if(d.prevB64===void 0)continue;let h=o.get(d.prevB64);h===void 0||h.proofHash===d.proofHash||pe(s,h.proofHash,d)}let a=new Map,c=new Map;for(let d of i)a.set(d.proofHash,yp(d,s)),c.set(d.proofHash,wp(d,o));let f=r.map(d=>{let h=new Map,m=new Map,y=X(d.counter);for(let b of i){let p=b.proofHash,A=X(b.counter);d.proofHash===p||a.get(p).has(d.proofHash)?h.set(p,"chain-link"):y!==void 0&&A!==void 0&&y>A&&(h.has(p)||h.set(p,"counter-order")),c.get(p).has(d.proofHash)?m.set(p,"chain-link"):d.proofHash!==p&&y!==void 0&&A!==void 0&&y<A&&(m.has(p)||m.set(p,"counter-order"))}return{member:d,lower:Tf("not-before",h,n),upper:Tf("not-after",m,n)}}),u=new Map;for(let d of f)pe(u,bp(d),d);let l=[];for(let d of u.values()){let h=d.map(B=>B.member).sort(ze),m=d[0],y=m.lower,b=m.upper,p=y.length>0&&b.length>0?"lower-bounded-with-following-anchor":y.length>0?"lower-bounded":b.length>0?"upper-bounded":"ordered-but-unanchored",A=xp(h);l.push({partition:t.key,memberProofHashes:h.map(B=>B.proofHash),...A!==void 0?{positionRange:A}:{},status:p,lowerBounds:y,upperBounds:b})}return l.sort(Ep),l}function Tf(t,e,n){if(e.size===0)return[];let r=[...e.entries()].map(([c,f])=>({anchorHash:c,evidenceKind:f,info:n.get(c)})),o=(c,f)=>f===void 0?!0:c.info.timestamp!==f.info.timestamp?t==="not-before"?c.info.timestamp>f.info.timestamp:c.info.timestamp<f.info.timestamp:c.evidenceKind!==f.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<f.anchorHash,i,s;for(let c of r)o(c,i)&&(i=c),c.evidenceKind==="chain-link"&&o(c,s)&&(s=c);let a=[vf(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(vf(t,s)),a}function vf(t,e){let{info:n,evidenceKind:r}=e,o=new Date(n.timestamp*1e3).toISOString(),i=n.blockNumber!==void 0?`Ethereum block ${n.blockNumber}`:"an Ethereum block",s=r==="chain-link"?"Evidence: a verified hash-link path connects these proofs and the anchor.":"Evidence: commit-counter ordering within the partition only, which relies on the authority's counter discipline rather than verifiable hash links (weaker).",a=t==="not-before"?`These proofs were committed no earlier than ${o} (unix ${n.timestamp}), the timestamp of ${i}: the block hash was unpredictable before that time and the anchor commit consumed it. Reading this as a wall-clock floor additionally assumes the anchored header is a genuine, publicly published Ethereum block: this offline audit checks the header's structure and hash binding, not proof-of-work, consensus, or chain membership, so it cannot confirm the block is real. ${s}`:`These proofs existed before the anchor commit that consumed the hash of ${i} (block timestamp ${o}, unix ${n.timestamp}). The block timestamp proves the anchor commit came at or after it, not how promptly; reading it as a wall-clock ceiling additionally assumes the anchor consumed a recently published block. ${s}`;return{kind:t,anchorProofHash:e.anchorHash,...n.blockNumber!==void 0?{blockNumber:n.blockNumber}:{},blockHash:n.blockHash,timestamp:n.timestamp,evidence:r,weaker:r==="counter-order",basis:t==="not-before"?"block-hash-unpredictability":"causal-precedence",boundClass:t==="not-before"?"evidence":"assumption",claim:t==="not-before"?a:"NOT a proof-carried upper bound. "+a}}function bp(t){let e=n=>n.map(r=>`${r.anchorProofHash}:${r.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function yp(t,e){let n=new Set,r=[...e.get(t.proofHash)??[]];for(;r.length>0;){let o=r.pop();if(!n.has(o.proofHash)){n.add(o.proofHash);for(let i of e.get(o.proofHash)??[])r.push(i)}}return n}function wp(t,e){let n=new Set,r=t;for(;r!==void 0&&r.prevB64!==void 0;){let o=e.get(r.prevB64);if(o===void 0||n.has(o.proofHash)||o.proofHash===t.proofHash)break;n.add(o.proofHash),r=o}return n}function xp(t){let e,n;for(let r of t)for(let o of[r.counter,r.slotCounter]){let i=X(o);i!==void 0&&((e===void 0||i<e)&&(e=i),(n===void 0||i>n)&&(n=i))}return e!==void 0&&n!==void 0?{min:String(e),max:String(n)}:void 0}function Ep(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}function If(t){return t?" The representative bound rests on commit-counter ordering rather than a verified hash-link path, which relies on the authority's counter discipline (weaker evidence).":""}function kp(t,e){let n=new Map;for(let i of t.epochRelationships.epochs)n.set(i.epochId,{totalProofCount:i.proofCount,lowerCovered:new Set,upperCovered:new Set});for(let i of e){let s=i.partition.epochId;if(s===void 0)continue;let a=n.get(s);if(a!==void 0){for(let c of i.lowerBounds){for(let f of i.memberProofHashes)a.lowerCovered.add(f);(a.lowerMin===void 0||c.timestamp<a.lowerMin.timestamp||c.timestamp===a.lowerMin.timestamp&&a.lowerMin.weaker&&!c.weaker)&&(a.lowerMin={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}for(let c of i.upperBounds){for(let f of i.memberProofHashes)a.upperCovered.add(f);(a.upperMax===void 0||c.timestamp>a.upperMax.timestamp||c.timestamp===a.upperMax.timestamp&&a.upperMax.weaker&&!c.weaker)&&(a.upperMax={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}}}for(let i of t.epochRelationships.epochs){let s=n.get(i.epochId),a=[];s.lowerMin!==void 0&&a.push({kind:"not-before",anchorProofHash:s.lowerMin.anchorProofHash,...s.lowerMin.blockNumber!==void 0?{blockNumber:s.lowerMin.blockNumber}:{},blockHash:s.lowerMin.blockHash,witnessTimestamp:s.lowerMin.timestamp,coverage:"members-after-anchor",coveredProofCount:s.lowerCovered.size,totalProofCount:s.totalProofCount,basis:"block-hash-unpredictability",evidence:s.lowerMin.evidence,weaker:s.lowerMin.weaker,claim:`${s.lowerCovered.size} of ${s.totalProofCount} observed proofs of this epoch were committed no earlier than unix ${s.lowerMin.timestamp}, grounded in block-hash unpredictability through verified anchor witnesses. This additionally assumes the anchored header is a genuine, publicly published Ethereum block, which this offline audit cannot confirm.`+If(s.lowerMin.weaker)+" The remaining proofs sit causally before the covering anchors and carry no lower bound from this evidence."}),s.upperMax!==void 0&&a.push({kind:"not-after",anchorProofHash:s.upperMax.anchorProofHash,...s.upperMax.blockNumber!==void 0?{blockNumber:s.upperMax.blockNumber}:{},blockHash:s.upperMax.blockHash,witnessTimestamp:s.upperMax.timestamp,coverage:"members-before-anchor",coveredProofCount:s.upperCovered.size,totalProofCount:s.totalProofCount,basis:"causal-precedence",evidence:s.upperMax.evidence,weaker:s.upperMax.weaker,claim:`${s.upperCovered.size} of ${s.totalProofCount} observed proofs of this epoch existed before an anchor commit that consumed a block published at unix ${s.upperMax.timestamp}. Reading that timestamp as a wall-clock ceiling additionally assumes the anchor consumed a recently published block; the causal precedence itself is verified.`+If(s.upperMax.weaker)+" Proofs after the covering anchors are not covered."}),a.length>0&&(i.anchorBounds=a)}let r=[],o=t.epochRelationships.epochs;for(let i of o){let s=n.get(i.epochId);if(s.upperMax!==void 0)for(let a of o){if(a.epochId===i.epochId)continue;let c=n.get(a.epochId);if(c.lowerMin===void 0||s.upperMax.timestamp>=c.lowerMin.timestamp)continue;let f=s.upperMax.evidence,u=c.lowerMin.evidence,l=s.upperMax.weaker||c.lowerMin.weaker;r.push({beforeEpochId:i.epochId,afterEpochId:a.epochId,upperAnchorProofHash:s.upperMax.anchorProofHash,upperBoundTimestamp:s.upperMax.timestamp,lowerAnchorProofHash:c.lowerMin.anchorProofHash,lowerBoundTimestamp:c.lowerMin.timestamp,basis:"anchor-bounds",assumptionDependent:!0,upperEvidence:f,lowerEvidence:u,weaker:l,beforeCoveredProofCount:s.upperCovered.size,beforeTotalProofCount:s.totalProofCount,afterCoveredProofCount:c.lowerCovered.size,afterTotalProofCount:c.totalProofCount,note:`The anchor-covered portion of epoch ${i.epochId} (${s.upperCovered.size} of ${s.totalProofCount} proofs) precedes the anchor-covered portion of epoch ${a.epochId} (${c.lowerCovered.size} of ${c.totalProofCount} proofs): the first is bounded not-after unix ${s.upperMax.timestamp} and the second not-before unix ${c.lowerMin.timestamp}. One-sided evidence about the covered portions only; the not-after side rests on the anchor-freshness assumption documented on its bound.`+(l?" At least one side rests on commit-counter ordering rather than a verified hash-link path (weaker evidence), which relies on the authority's counter discipline.":"")+" This is ordering evidence, never divergence."})}}return r.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),r}g();var Sf="0xf3972408D853c975F86351C311f4310220bbF2a3",Cf=8453;async function ji(t,e={}){let n=e.writer??Sf,r=e.chainId??Cf,o=new Map(t.proofs.map(a=>[a.proofHash,a])),i=[];for(let a of t.ceilings??[]){let c=a.json,f=typeof c.proofHash=="string"?c.proofHash:null,u=f?o.get(f):void 0;if(!u){i.push({path:a.path,proofHash:f,status:"unmatched",reason:"no proof in this bundle has this ceiling's proofHash",onChain:null});continue}let l=await On(u.proof,c,{writerAddress:n,chainId:r});if(!l.ok){let m=l.status==="pending";i.push({path:a.path,proofHash:f,status:m?"pending":"failed",...l.reason?{reason:l.reason}:{},onChain:null});continue}let d=l.window,h={path:a.path,proofHash:f,status:"verified",...l.label?{label:l.label}:{},window:{floorBlock:d.floor.blockNumber||null,floorTime:d.floor.blockTimestamp,ceilingChainId:d.ceiling.chainId,ceilingBlock:d.ceiling.blockNumber,ceilingTime:d.ceiling.blockTimestamp,widthSeconds:d.widthSeconds},onChain:null,onChainDetail:"header not checked against chain"};if(e.getBlockHash){let m=await Lr(c,e.getBlockHash);h.onChain=m.onChain,h.onChainDetail=m.detail,m.onChain===!1&&(h.status="failed",h.reason=`chain: ${m.detail}`)}i.push(h)}let s=(t.ceilingStatuses??[]).map(a=>({path:a.path,status:String(a.json.status??"unknown"),note:String(a.json.note??"")}));return{writer:n,chainId:r,checks:i,statuses:s}}g();g();var Rf=`-----BEGIN CERTIFICATE-----
|
|
140
140
|
MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTEL
|
|
141
141
|
MAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYD
|
|
142
142
|
VQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4
|
|
@@ -149,10 +149,10 @@ R+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYC
|
|
|
149
149
|
MQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPW
|
|
150
150
|
rfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6N
|
|
151
151
|
IwLz3/Y=
|
|
152
|
-
-----END CERTIFICATE-----`;function sh(){return nc.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function rc(){return new Uint8Array(B.Buffer.from(sh(),"base64"))}async function ic(t,e){let n=[],r={},o,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(u=>!u.pass)?.detail,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},...a!==void 0?{certChainLength:a}:{},...c!==void 0?{userDataB64:c}:{}});try{let u=fh(t);if(u===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let d=Xe(u,0).value;if(!Array.isArray(d)||d.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),f();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let h=d[0],l=d[2],m=d[3];if(!(h instanceof Uint8Array)||!(l instanceof Uint8Array)||!(m instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),f();let p=Xe(l,0).value;if(!p||typeof p!="object"||Array.isArray(p))return n.push({name:"Payload Decode",pass:!1,detail:"Could not decode attestation payload"}),f();r=mh(p),o=r[0],i=typeof p.module_id=="string"?p.module_id:void 0,s=typeof p.timestamp=="number"?p.timestamp:void 0;let w=p.user_data;c=w instanceof Uint8Array&&w.length>0?B.Buffer.from(w).toString("base64"):void 0;let b=p.cabundle,k=p.certificate;if(!(k instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),f();a=(Array.isArray(b)?b.length:0)+1;let v=Zo(k),O=hh(h,l),z=await Yo(m,O,v.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:z,detail:z?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!z)return f();if(!Array.isArray(b)||b.length===0||!b.every(A=>A instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let S=[...b,k].map(Zo),_=!0,F="";for(let A=1;A<S.length;A++){let C=S[A],M=S[A-1];if(!await Yo(C.signature,C.tbsCertificate,M.publicKey)){_=!1,F=`Certificate ${A} signature invalid (parent: ${A-1})`;break}}if(n.push({name:"Certificate Chain",pass:_,detail:_?`${S.length} certificates, each signed by parent`:F}),!_)return f();let G=e?.trustedRootCaDer===void 0,q=Zo(e?.trustedRootCaDer??rc()),ge=S[0],D=await Yo(ge.signature,ge.tbsCertificate,q.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:D,detail:D?G?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":G?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!D)return f();let ae=!0,re=`All ${S.length} certificate validity windows contain the document timestamp`;if(s===void 0)ae=!1,re="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let A=0;A<S.length;A++){let C=S[A];if(s<C.notBeforeMs||s>C.notAfterMs){ae=!1,re=`Certificate ${A} validity window [${new Date(C.notBeforeMs).toISOString()}, ${new Date(C.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:ae,detail:re}),!ae)return f();let L;e?.expectedPcr0!==void 0&&(L=o===e.expectedPcr0,n.push({name:"PCR0 Match",pass:L,detail:L?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(o??"").slice(0,16)}...`}));let E;return e?.expectedUserDataB64!==void 0&&(E=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:E,detail:E?"Attestation user_data matches this proof's canonical hash":c!==void 0?"Attestation user_data does not match this proof":"Attestation carries no user_data to bind"})),{documentValid:!0,checks:n,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},certChainLength:a,...c!==void 0?{userDataB64:c}:{},...L!==void 0?{pcr0Matches:L}:{},...E!==void 0?{userDataMatches:E}:{}}}catch(u){return n.push({name:"Verification Error",pass:!1,detail:u instanceof Error?u.message:String(u)}),f()}}async function Xo(t,e,n){let r=[],o=[],i={proofsWithDeclaredMeasurement:0,proofsWithDocument:0,documentsValidated:0,documentsFailed:0,pcr0Matches:0,pcr0Mismatches:0,userDataBound:0,userDataUnbound:0};for(let s of t.proofs){let a=s.measurement!==void 0&&s.measurement.length>0?s.measurement:void 0;a!==void 0&&i.proofsWithDeclaredMeasurement++;let c=ch(s),f={proofHash:s.proofHash,declaredMeasurementPresent:a!==void 0,...a!==void 0?{declaredMeasurement:a}:{},documentPresent:c!==void 0,...c?.format!==void 0?{attestationFormat:c.format}:{},documentValidated:!1,checks:[]};if(c!==void 0){i.proofsWithDocument++;let u=await ic(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:bo(s.proof),...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});f.documentValidated=u.documentValid,f.checks=u.checks,u.pcr0!==void 0&&(f.attestedPcr0=u.pcr0),f.pcrs=u.pcrs,u.moduleId!==void 0&&(f.moduleId=u.moduleId),u.timestamp!==void 0&&(f.timestamp=u.timestamp),u.certChainLength!==void 0&&(f.certChainLength=u.certChainLength),u.userDataB64!==void 0&&(f.userDataB64=u.userDataB64),u.documentValid?(i.documentsValidated++,u.pcr0Matches!==void 0&&(f.pcr0MatchesDeclared=u.pcr0Matches,u.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,o.push({code:"attestation-measurement-mismatch",...Go(s),message:"the validated attestation document's PCR0 does not equal the proof's declared environment.measurement. Declared and attested measurements are reported separately and disagree here.",details:{proofHash:s.proofHash,declared:a,...u.pcr0!==void 0?{attested:u.pcr0}:{}}}))),u.userDataMatches!==void 0&&(f.userDataBoundToProof=u.userDataMatches,u.userDataMatches?i.userDataBound++:(i.userDataUnbound++,o.push({code:"attestation-user-data-mismatch",...Go(s),message:"the validated attestation document's user_data is not bound to this proof's canonical hash. A genuine attestation lifted from another proof would look exactly like this.",details:{proofHash:s.proofHash,...u.userDataB64!==void 0?{userDataB64:u.userDataB64}:{}}})))):(i.documentsFailed++,u.failure!==void 0&&(f.validationFailure=u.failure),o.push({code:"attestation-invalid",...Go(s),message:`attestation document failed offline validation: ${u.failure??"unknown"}. Presence of a document is reported separately and proves nothing by itself.`,details:{proofHash:s.proofHash}}))}r.push(f)}return e!==void 0&&ah(e,r),{records:r,findings:o,counts:i}}function ah(t,e){let n=new Map(e.map(r=>[r.proofHash,r]));for(let r of t.groups){if(!r.attestationPresent)continue;let o=r.proofHashes.map(f=>n.get(f)).filter(f=>f!==void 0&&f.documentPresent);if(o.length===0)continue;let i=o.filter(f=>f.documentValidated),s=o.length-i.length,a=[...new Set(i.map(f=>f.attestedPcr0).filter(f=>f!==void 0))].sort(),c=a.length===1?a[0]:void 0;r.attested={status:s===0&&i.length>0?"validated":"validation-failed",...c!==void 0?{attestedMeasurement:c}:{},...c!==void 0&&r.measurement!==void 0?{matchesDeclared:c===r.measurement}:{},validatedProofCount:i.length,failedProofCount:s,...a.length>1?{attestedMeasurements:a}:{}}}}function ch(t){let e=t.proof.environment;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.attestation;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n.reportB64;if(typeof r!="string"||r.length===0)return;let o=n.format;return{reportB64:r,...typeof o=="string"?{format:o}:{}}}function Go(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function fh(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function Jo(t){return t<24?new Uint8Array([t]):t<256?new Uint8Array([24,t]):t<65536?new Uint8Array([25,t>>8,t&255]):new Uint8Array([26,t>>>24&255,t>>>16&255,t>>>8&255,t&255])}function Wo(t){let e=Jo(t.length);e[0]=e[0]&31|64;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function uh(t){let e=new TextEncoder().encode(t),n=Jo(e.length);n[0]=n[0]&31|96;let r=new Uint8Array(n.length+e.length);return r.set(n,0),r.set(e,n.length),r}function dh(t){let e=Jo(t.length);e[0]=e[0]&31|128;let n=e.length+t.reduce((i,s)=>i+s.length,0),r=new Uint8Array(n),o=0;r.set(e,o),o+=e.length;for(let i of t)r.set(i,o),o+=i.length;return r}function hh(t,e){return dh([uh("Signature1"),Wo(t),Wo(new Uint8Array(0)),Wo(e)])}function Xe(t,e=0){let n=t[e];if(n===void 0)throw new Error("CBOR: unexpected end of input");let r=n>>5,o=n&31;e++;let i=a=>{let c=t[a];if(c===void 0)throw new Error("CBOR: unexpected end of input");return c};function s(){if(o<24)return o;if(o===24){let a=i(e);return e+=1,a}if(o===25){let a=i(e)<<8|i(e+1);return e+=2,a}if(o===26){let a=(i(e)<<24|i(e+1)<<16|i(e+2)<<8|i(e+3))>>>0;return e+=4,a}if(o===27){let a=0;for(let c=0;c<8;c++)a=a*256+i(e+c);return e+=8,a}throw new Error(`Unsupported CBOR length info: ${o}`)}switch(r){case 0:return{value:s(),offset:e};case 1:return{value:-1-s(),offset:e};case 2:{let a=s();if(e+a>t.length)throw new Error("CBOR: byte string is truncated");return{value:t.slice(e,e+a),offset:e+a}}case 3:{let a=s();if(e+a>t.length)throw new Error("CBOR: text string is truncated");return{value:new TextDecoder().decode(t.slice(e,e+a)),offset:e+a}}case 4:{if(o===31){let f=[];for(;i(e)!==255;){let u=Xe(t,e);f.push(u.value),e=u.offset}return{value:f,offset:e+1}}let a=s(),c=[];for(let f=0;f<a;f++){let u=Xe(t,e);c.push(u.value),e=u.offset}return{value:c,offset:e}}case 5:{if(o===31){let f={};for(;i(e)!==255;){let u=Xe(t,e);e=u.offset;let d=Xe(t,e);e=d.offset,f[String(u.value)]=d.value}return{value:f,offset:e+1}}let a=s(),c={};for(let f=0;f<a;f++){let u=Xe(t,e);e=u.offset;let d=Xe(t,e);e=d.offset,c[String(u.value)]=d.value}return{value:c,offset:e}}case 6:return s(),Xe(t,e);case 7:{if(o===20)return{value:!1,offset:e};if(o===21)return{value:!0,offset:e};if(o===22)return{value:null,offset:e};if(o===23)return{value:void 0,offset:e};throw new Error(`Unsupported CBOR simple value: ${o}`)}default:throw new Error(`Unsupported CBOR major type: ${r}`)}}function Zo(t){let n=ln(t,0).contentStart,r=se(t,n),o=t.slice(n,r.end);n=r.end,n=se(t,n).end;let s=se(t,n),a=t.slice(s.contentStart+1,s.end),c=ph(a,48),{publicKey:f,notBeforeMs:u,notAfterMs:d}=lh(o);return{tbsCertificate:o,signature:c,publicKey:f,notBeforeMs:u,notAfterMs:d}}function se(t,e){let n=t[e];if(n===void 0)throw new Error("DER: unexpected end of input");let r=e+1,o=t[r++];if(o===void 0)throw new Error("DER: unexpected end of input");if(o&128){let s=o&127;o=0;for(let a=0;a<s;a++){let c=t[r++];if(c===void 0)throw new Error("DER: unexpected end of input");o=o*256+c}}let i=r+o;if(i>t.length)throw new Error("DER: element is truncated");return{tag:n,contentStart:r,contentEnd:i,end:i}}function ln(t,e){let n=se(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function lh(t){let n=ln(t,0).contentStart;t[n]===160&&(n=se(t,n).end),n=se(t,n).end,n=se(t,n).end,n=se(t,n).end;let r=ln(t,n),o=r.contentStart,i=se(t,o);o=i.end;let s=se(t,o),a=oc(t,i),c=oc(t,s);n=r.end,n=se(t,n).end;let u=ln(t,n).contentStart;u=se(t,u).end;let h=se(t,u);return{publicKey:t.slice(h.contentStart+1,h.end),notBeforeMs:a,notAfterMs:c}}function oc(t,e){let n=String.fromCharCode(...t.slice(e.contentStart,e.contentEnd)),r,o;if(e.tag===23){if(!/^\d{12}Z$/.test(n))throw new Error(`DER: malformed UTCTime "${n}"`);let u=Number.parseInt(n.slice(0,2),10);r=u<50?2e3+u:1900+u,o=n.slice(2)}else if(e.tag===24){if(!/^\d{14}Z$/.test(n))throw new Error(`DER: malformed GeneralizedTime "${n}"`);r=Number.parseInt(n.slice(0,4),10),o=n.slice(4)}else throw new Error(`DER: expected a Time value, got tag 0x${e.tag.toString(16)}`);let i=Number.parseInt(o.slice(0,2),10),s=Number.parseInt(o.slice(2,4),10),a=Number.parseInt(o.slice(4,6),10),c=Number.parseInt(o.slice(6,8),10),f=Number.parseInt(o.slice(8,10),10);return Date.UTC(r,i-1,s,a,c,f)}function ph(t,e){let r=ln(t,0).contentStart,o=se(t,r);if(o.tag!==2)throw new Error("Expected INTEGER for r");let i=t.slice(o.contentStart,o.end);r=o.end;let s=se(t,r);if(s.tag!==2)throw new Error("Expected INTEGER for s");let a=t.slice(s.contentStart,s.end);if(i[0]===0&&i.length>e&&(i=i.slice(1)),a[0]===0&&a.length>e&&(a=a.slice(1)),i.length>e||a.length>e)throw new Error("ECDSA signature component longer than the curve coordinate size");let c=new Uint8Array(e*2);return c.set(i,e-i.length),c.set(a,e*2-a.length),c}async function Yo(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let r=await fo.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await fo.subtle.verify({name:"ECDSA",hash:"SHA-384"},r,t,e)}catch{return!1}}function mh(t){let e={},n=t.pcrs;if(!n||typeof n!="object")return e;for(let[r,o]of Object.entries(n))if(o instanceof Uint8Array){let i=B.Buffer.from(o).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(r)]=i)}return e}y();var cr="0.4.1";function sc(){return cr}async function Qo(t,e){let n=e?.startedAt??new Date().toISOString(),r=await Po(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),o=await Do(t),i=await No(t,o),s=Oo(t),a=Uo(t),c=await zo(t,a),f=qo(t,o,a,c),u=await Xo(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:sc(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:r,reconstruction:o,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:f,attestations:u}}y();y();y();y();y();function fr(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}y();y();var ei="0.14.0";var xh=[{pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92",label:"genesis",period:"2026-05-15 to 2026-06-27"},{pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a",label:"enclave v2 (reproducible)",period:"2026-06-27 to 2026-07-05"},{pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb",label:"enclave v4 (reproducible)",period:"2026-07-05 to 2026-07-29"},{pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f",label:"enclave v5 (reproducible)",period:"2026-07-29 to 2026-09-05"},{pcr0:"cd8ba52d340fb1be78610b59953ded2ceca23be1cfcc7ab504a26b8fdcd7ba92090f49e28a32d008df046ec4212f77bf",label:"enclave v6 (reproducible)",period:"2026-09-05 to 2026-09-06"},{pcr0:"394c3cf515651dc27187d85e4716c12dfeb99c1227f1fe0eacfaa427d80018e1a28ebba9469e99c7936601f901d74e1d",label:"enclave v7 (reproducible, authenticated anchors)",period:"2026-09-06 to 2026-09-07"},{pcr0:"eccfc1c78006f4b74f929c992785575c908a0f60eca08ff638cd6c0842f993f182ebb002457b8ef3e732a6a10805c72b",label:"enclave v8 (reproducible, authenticated anchors and the floor gate)",period:"2026-09-07 onward"}],Eh=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function dc(t,e){let n=e,r=await Qo(t,{startedAt:""});if(n?.fuseEvidence===void 0){let o=await Bh(t);n={...n,fuseEvidence:o.evidence,fuseOriginHexes:o.originHexes}}return vh(r,n)}async function Bh(t){let e=new Map,n=new Set,r=[],o=new Set;for(let s of t.proofs){let a=kt(s.proof);if(a===null)continue;let c=qt(s.proof.artifact.digestB64),f=c!==null?we(c):null,u=a.originDigest!==void 0?we(a.originDigest):null;r.push({proof:s,artifactHex:f,originHex:u}),f!==null&&o.add(f),u!==null&&o.add(u)}if(r.length===0)return{evidence:e,originHexes:n};let i=new Map;for await(let s of Ro(t,o))i.has(s.sha256Hex)||i.set(s.sha256Hex,s.bytes);Ve();try{for(let s of r){let a=s.artifactHex!==null?i.get(s.artifactHex):void 0,c=s.originHex!==null?i.get(s.originHex):void 0;c!==void 0&&s.originHex!==null&&n.add(s.originHex);let f=a??c;f!==void 0&&e.set(s.proof.proofHash,await Io({proof:s.proof.proof,bytes:f}))}}finally{Ve()}return{evidence:e,originHexes:n}}function vh(t,e){let n=e?.webCryptoAvailable??!0,r=new Map(t.anchors.anchors.map(p=>[p.proofHash,p])),o=new Map(t.attestations.records.map(p=>[p.proofHash,p])),i=new Map;for(let p of t.temporal.segments)for(let w of p.memberProofHashes)i.set(w,p);let s=new Map;for(let p of t.witnesses.outcomes){if(p.anchorProofHash===void 0)continue;let w=s.get(p.anchorProofHash)??[];w.push(p),s.set(p.anchorProofHash,w)}let a=new Map;for(let p of t.ingest.artifacts)for(let w of p.matchedProofHashes)!a.has(w)&&p.paths[0]!==void 0&&a.set(w,p.paths[0]);let c=[],f=[];for(let p of t.ingest.proofs){let w=r.get(p.proofHash);w!==void 0?f.push(Ph(p,w,s.get(p.proofHash)??[])):c.push(Ah(p,o.get(p.proofHash),i.get(p.proofHash),a.get(p.proofHash),n,e?.fuseEvidence,r))}ac(c),ac(f);let u=Mh(t),d=Dh(t,c,f,e?.fuseOriginHexes),h=Nh(f.length>0),l=[...c.map(p=>p.result),...f.map(p=>p.result),...u.map(p=>p.result)],m=l.length===0?"UNDETERMINED":fr(l);return{check:"bitgraph-check/1",result:m,summary:Lh(m,c,f,u),recordings:c,anchors:f,contradictions:u,notes:d,notChecked:h,evaluator:{name:"bitgraph-player",version:ei,audit:cr},network:"none"}}function ac(t){let e=n=>[n.epochId??"",n.counter!==void 0&&/^[0-9]+$/.test(n.counter)?BigInt(n.counter):void 0];t.sort((n,r)=>{let[o,i]=e(n),[s,a]=e(r);return o!==s?o<s?-1:1:i===void 0||a===void 0?i===void 0?a===void 0?0:1:-1:i<a?-1:i>a?1:0})}function Ah(t,e,n,r,o,i,s){let a=[],c=t.verification,f=t.proof.artifact.digestB64;c?.tier==="full"?a.push({name:"file",result:c.status==="verified"||c.status==="failed"?"TRUE":"UNDETERMINED",detail:c.status==="verified"||c.status==="failed"?`${r??"the matched file"} hashes to the recorded digest ${f}`:`no file in this bundle hashes to the recorded digest ${f}`}):a.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${f}; the recording cannot be bound to bytes in hand`}),c===void 0?a.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):c.status==="failed"?a.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${c.reason??"unspecified failure"}`}):a.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${ri(t.publicKeyB64)}`});let u=Th(e,o);a.push(u.line),a.push(Hh(u.attestedPcr0,u.line.result));let d=kt(t.proof),h;if(d!==null){let m=Ih(n,s,t.slotCounter,t.chainId),p=Sh(d.placement,d.originDigest!==void 0?t.proof.attribution?.message??null:null,i?.get(t.proofHash),m,t);a.push(p.line),h=p.fused}let l=fr(a.map(m=>m.result));return{proofHash:t.proofHash,digestB64:f,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...r!==void 0&&c?.tier==="full"?{filePath:r}:{},lines:a,result:l,bounds:Ch(n),...h!==void 0?{fused:h}:{}}}var ni="bitgraph:main";function Ih(t,e,n,r=ni){if(r!==ni||t===void 0||e===void 0||n===void 0||!/^[0-9]+$/.test(n))return null;let o=BigInt(n),i;for(let s of t.lowerBounds){if(s.kind!=="not-before")continue;let a=e.get(s.anchorProofHash);if(a===void 0||a.counter===void 0||!/^[0-9]+$/.test(a.counter)||BigInt(a.counter)>=o)continue;if(i===void 0){i=s;continue}let c=s.blockNumber!==void 0?BigInt(s.blockNumber):BigInt(s.timestamp),f=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);c>f&&(i=s)}return i===void 0?null:{...i.blockNumber!==void 0?{blockNumber:i.blockNumber}:{},blockHash:i.blockHash,timestamp:i.timestamp,anchorProofHash:i.anchorProofHash,evidence:"counter-order"}}var kh="floor undetermined: no anchor precedes this slot in its epoch";function cc(t){return`anchored block ${t.blockNumber!==void 0?`#${t.blockNumber}`:t.blockHash} (${new Date(t.timestamp*1e3).toISOString()})`}function Sh(t,e,n,r,o){let i=o.slotCounter??"?",s=t!==null?` (placement ${t})`:" (placement undeclared)",a=r!==null?`assembled after ${cc(r)}, the last verified anchor preceding slot ${i} in this epoch`:o.chainId!==ni?`floor undetermined: the slot is on chain "${o.chainId}", not the anchored chain`:kh,c=n?.span!==void 0&&n.span!==null?{slotCounter:n.span.slotCounter,commitCounter:n.span.commitCounter,positions:n.span.positions}:o.slotCounter!==void 0&&o.counter!==void 0?{slotCounter:o.slotCounter,commitCounter:o.counter,positions:(BigInt(o.counter)-BigInt(o.slotCounter)).toString()}:null,f=(n?.statements??[]).map(h=>r!==null?h.replace(`at position ${i},`,`at position ${i}, which followed ${cc(r)},`):h),u=(h,l)=>({category:h,placement:n?.placement??t,originDigestB64:n?.originDigestB64??e,evidence:l,statements:f,floor:r,floorDetail:a,span:c});if(n===void 0)return{line:{name:"fused",result:"UNDETERMINED",detail:`marked fused${s}, but neither the fused bytes nor ${e!==null?"the original":"an original"} is in this bundle, so the commitment to slot ${i} cannot be checked`},fused:u("NO_EVIDENCE",null)};let d=n.category==="FUSED_FROM_ORIGIN"||n.fileDigestB64!==n.artifactDigestB64&&n.category!=="NO_MATCH"?"original":"fused-bytes";switch(n.category){case"FUSED_DIRECT":return{line:{name:"fused",result:"TRUE",detail:`the fused bytes carry the commitment to slot ${i}${s}`},fused:u(n.category,"fused-bytes")};case"FUSED_FROM_ORIGIN":return{line:{name:"fused",result:"TRUE",detail:`the original rebuilds the committed fused bytes${s}; they carry the commitment to slot ${i}`},fused:u(n.category,"original")};case"INVALID_SLOT_COMMITMENT":return{line:{name:"fused",result:"FALSE",detail:`the fused bytes do not carry the commitment to this proof's slot ${i}: ${n.reason??""}`},fused:u(n.category,d)};case"INVALID_ORIGIN_ATTRIBUTION":return{line:{name:"fused",result:"FALSE",detail:`the declared origin contradicts the origin inside the fused bytes: ${n.reason??""}`},fused:u(n.category,d)};case"RECONSTRUCTION_MISMATCH":return{line:{name:"fused",result:"FALSE",detail:`the file matching the declared origin does not rebuild the committed fused bytes: ${n.reason??""}`},fused:u(n.category,"original")};case"UNDETERMINED_PLACEMENT":return{line:{name:"fused",result:"UNDETERMINED",detail:`${n.reason??"the placement is not registered"}; this verifier cannot check the commitment`},fused:u(n.category,d)};case"INVALID_UNDERLYING_PROOF":return{line:{name:"fused",result:"UNDETERMINED",detail:"not checked: the proof itself does not verify (see the signature line)"},fused:u(n.category,d)};default:return{line:{name:"fused",result:"UNDETERMINED",detail:`the commitment could not be checked: ${n.reason??n.category}`},fused:u(n.category,d)}}}function Th(t,e){return t===void 0||!t.documentPresent?{line:{name:"attestation",result:"UNDETERMINED",detail:"no attestation document in this proof"}}:e?t.documentValidated?t.userDataBoundToProof!==!0?{line:{name:"attestation",result:"FALSE",detail:"attestation document validates but its user_data is not this proof: the document belongs to some other proof"},attestedPcr0:t.attestedPcr0}:t.pcr0MatchesDeclared!==!0?{line:{name:"attestation",result:"FALSE",detail:`attestation validates and binds this proof, but its PCR0 ${pn(t.attestedPcr0)} is not the measurement the signed body declares ${pn(t.declaredMeasurement)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"TRUE",detail:`AWS Nitro attestation validates to the AWS root, binds this exact proof (user_data), and attests PCR0 ${pn(t.attestedPcr0)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"FALSE",detail:`attestation document does not validate: ${t.validationFailure??"unspecified failure"}`}}:{line:{name:"attestation",result:"UNDETERMINED",detail:"attestation not checked: this environment cannot verify ECDSA P-384 (no WebCrypto); open the verifier from a file or https page, or run bitgraph-play check"}}}function Hh(t,e){if(e!=="TRUE"||t===void 0)return{name:"enclave",result:"UNDETERMINED",detail:"enclave identity rests on a validated attestation, which this recording does not have here"};let n=xh.find(r=>r.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${pn(t)} is not among the BitGraph enclave measurements this verifier knows (player ${ei}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${pn(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function Ch(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=fc(t.lowerBounds,"not-before"),n=fc(t.upperBounds,"not-after"),r=e===void 0?void 0:uc(e),o=n===void 0?void 0:uc(n),i=r!==void 0&&o!==void 0?"lower-bounded-with-following-anchor":r!==void 0?"lower-bounded":o!==void 0?"upper-bounded":"unanchored",s=i==="unanchored"?"no verified Ethereum anchor bounds this recording in this bundle":`recorded ${Rh(i,r,o)}`;return{status:i,...r!==void 0?{notBefore:r}:{},...o!==void 0?{notAfter:o}:{},detail:s}}function Rh(t,e,n){switch(t){case"lower-bounded-with-following-anchor":return`after Ethereum block ${ht(e)} (header verified in this bundle); precedes an anchor that consumed block ${ht(n)} (header verified), an anchor-latency assumption rather than an upper bound on this recording`+ti(e.weaker||n.weaker);case"lower-bounded":return`after Ethereum block ${ht(e)} (header verified in this bundle); no verified upper bound here`+ti(e.weaker);case"upper-bounded":return`before Ethereum block ${ht(n)} (header verified in this bundle); no verified lower bound here`+ti(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function fc(t,e){let n=t.filter(o=>o.kind===e);return n.length===0?void 0:[...n].sort((o,i)=>{let s=o.blockNumber!==void 0?BigInt(o.blockNumber):BigInt(o.timestamp),a=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);return s!==a?e==="not-before"?s>a?-1:1:s<a?-1:1:o.weaker!==i.weaker?o.weaker?1:-1:0})[0]}function uc(t){return{...t.blockNumber!==void 0?{blockNumber:t.blockNumber}:{},blockHash:t.blockHash,timestamp:t.timestamp,anchorProofHash:t.anchorProofHash,evidence:t.evidence,weaker:t.weaker}}function $h(t){switch(t.status){case"lower-bounded-with-following-anchor":return`after Ethereum block ${ht(t.notBefore)}, then an anchor at block ${ht(t.notAfter)}`;case"lower-bounded":return`after Ethereum block ${ht(t.notBefore)}`;case"upper-bounded":return`before Ethereum block ${ht(t.notAfter)}`;default:return"with no Ethereum bound in this bundle"}}function ht(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function ti(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function Ph(t,e,n){let r=[],o=t.verification;o===void 0?r.push({name:"signature",result:"UNDETERMINED",detail:"the anchor proof was not verified"}):o.status==="failed"?r.push({name:"signature",result:"FALSE",detail:`the anchor proof does not verify: ${o.reason??"unspecified failure"}`}):r.push({name:"signature",result:"TRUE",detail:`anchor proof verifies under signer key ${ri(t.publicKeyB64)}`});let i;if(n.length>0){let s=n.find(a=>a.verified);if(s!==void 0)i=s.witnessPath,r.push({name:"witness",result:"TRUE",detail:`block header ${s.witnessPath} hashes (keccak-256) to the anchored block hash${e.blockNumber!==void 0?` of block ${e.blockNumber}`:""}`});else{let a=n[0];i=a.witnessPath,r.push({name:"witness",result:"FALSE",detail:`block header ${a.witnessPath} contradicts this anchor: ${a.detail??a.reason??"witness verification failed"}`})}}return{proofHash:t.proofHash,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...e.blockNumber!==void 0?{blockNumber:e.blockNumber}:{},...e.blockHash!==void 0?{blockHash:e.blockHash}:{},...i!==void 0?{witnessPath:i}:{},lines:r,result:fr(r.map(s=>s.result))}}function Mh(t){let e=[],n=new Set,r=o=>{n.has(o)||(n.add(o),e.push({name:"contradiction",result:"FALSE",detail:o}))};for(let o of t.anomalies.anomalies)Eh.has(o.code)||r(`${o.code}: ${o.message}`);for(let o of t.anomalies.divergences)r(`${o.kind}: ${o.explanation}`);for(let o of t.authorities.anomalies)r(`${o.code}: ${o.message}`);for(let o of t.witnesses.findings)(o.code==="witness-unmatched"||o.code==="witness-malformed"||o.code==="witness-rlp-invalid")&&r(`${o.code}: ${o.message}`);for(let o of t.ingest.findings)o.code==="proofhash-mismatch"&&r(`${o.code}: ${o.message}${o.path!==void 0?` (${o.path})`:""}`);return e}function Dh(t,e,n,r){let o=[],i=0n,s=0;for(let d of t.anomalies.anomalies)if(d.code==="unexplained-counter-positions"){let h=d.details?.count;h!==void 0&&/^[0-9]+$/.test(h)&&(i+=BigInt(h))}else d.code==="chain-break-missing"&&(s+=d.proofHashes.length);i>0n&&o.push(`${i} causal position${i===1n?"":"s"} between the earliest and latest recording here ${i===1n?"is":"are"} not in this bundle: normal for an export, which is an excerpt of the chain; a full-epoch audit checks them`),s>0&&o.push(`${s} recording${s===1?"":"s"} link${s===1?"s":""} to a predecessor that is not in this bundle: normal for an export`);let a=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&r?.has(d.sha256Hex)===!0);a.length>0&&o.push(`${a.length} file${a.length===1?"":"s"} in this bundle ${a.length===1?"is":"are"} the original of a fused recording: ${a.slice(0,5).map(d=>d.paths[0]??"(unnamed)").join(", ")}${a.length>5?", \u2026":""}. The original itself receives only the ceiling (it existed no later than the commit); the fused bytes receive the interval`);let c=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&r?.has(d.sha256Hex)!==!0);if(c.length>0&&e.length>0){let d=c.slice(0,5).map(h=>`${h.paths[0]??"(unnamed)"} (sha256:${h.sha256Hex.slice(0,16)}\u2026)`).join(", ");o.push(`${c.length} file${c.length===1?"":"s"} in this bundle match${c.length===1?"es":""} no recording here: ${d}${c.length>5?", \u2026":""}. If ${c.length===1?"it":"one of them"} was meant to be a recorded file, its bytes differ from what was recorded`)}let f=n.filter(d=>d.witnessPath===void 0);f.length>0&&o.push(`${f.length} Ethereum anchor${f.length===1?"":"s"} in this bundle ha${f.length===1?"s":"ve"} no block-header witness file, so ${f.length===1?"its":"their"} block hash${f.length===1?" is":"es are"} not verified here and no bound is derived from ${f.length===1?"it":"them"}`);for(let d of t.ingest.unsupportedVersions)o.push(`${d.path} is proof-shaped but its version "${d.version}" is not bitgraph/1; it was not checked`);let u=t.ingest.counts;if((u.exactDuplicates>0||u.semanticDuplicates>0)&&o.push(`${u.exactDuplicates+u.semanticDuplicates} duplicate proof file${u.exactDuplicates+u.semanticDuplicates===1?"":"s"} collapsed to one recording each`),t.ingest.manifest!==void 0)for(let d of t.ingest.findings)typeof d.code=="string"&&d.code.startsWith("manifest-")&&o.push(`${d.code}: ${d.message}`);return e.length===0&&n.length===0&&o.push("no BitGraph proofs were found in this bundle"),o}function Nh(t){let e=[];return t&&e.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e.push("whether the public ledger holds these exact recordings at these positions: this is an offline check; drop the file on bitgraph.ing to compare against the ledger"),e.push("whether an epoch key was later quarantined: that is published outside any bundle"),e}function Lh(t,e,n,r){if(e.length===0&&n.length===0)return"UNDETERMINED: no BitGraph proofs were found in this bundle.";let o=e.length,i=`${o} recording${o===1?"":"s"}`;if(t==="TRUE"){let a=e[0];return o===1&&a!==void 0?`TRUE: this file was recorded${a.counter!==void 0?` at position ${a.counter}${a.epochId!==void 0?` of epoch ${ri(a.epochId)}`:""}`:""}, ${$h(a.bounds)}.`:`TRUE: ${i} verified: files match, signatures and attestations hold, enclave measurements published${n.length>0?", Ethereum bounds verified from block headers in the bundle":""}.`}if(t==="FALSE")return`FALSE: evidence in this bundle contradicts itself. ${[...e.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...n.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...r.map(c=>c.detail)][0]??""}`.trim();let s=[...e.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail)),...n.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail))];return`UNDETERMINED: nothing here contradicts the ${i}, but the evidence does not fully decide. ${s[0]??""}`.trim()}function ri(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function pn(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}In.sha512Async=async(...t)=>Rn(In.concatBytes(...t));var bc=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function yc(t){return new Promise((e,n)=>{let r=[],o=()=>{t.readEntries(i=>{if(i.length===0){e(r);return}r.push(...i),o()},n)};o()})}function Oh(t){return new Promise((e,n)=>t.file(e,n))}async function ai(t,e,n){if(t.isFile){let r=await Oh(t);n.push({path:e+t.name,file:r});return}if(t.isDirectory){let r=t.createReader(),o=await yc(r);for(let i of o)i.name!==".DS_Store"&&await ai(i,`${e}${t.name}/`,n)}}async function Fh(t){let n=Array.from(t.items??[]).map(o=>typeof o.webkitGetAsEntry=="function"?o.webkitGetAsEntry():null).filter(o=>o!==null);if(n.length===0)return Array.from(t.files??[]).map(o=>({path:o.name,file:o}));let r=[];if(n.length===1&&n[0]!==void 0&&n[0].isDirectory){let o=n[0];for(let i of await yc(o.createReader()))i.name!==".DS_Store"&&await ai(i,"",r)}else for(let o of n)await ai(o,"",r);return r.length===0?Array.from(t.files??[]).map(o=>({path:o.name,file:o})):r}function hc(t){let e=Array.from(t.files??[]),n=e.map(s=>s.webkitRelativePath||s.name),r=n.map(s=>s.indexOf("/")),o=n.length>0&&r.every(s=>s>0)?n[0].slice(0,r[0]):void 0,i=o!==void 0&&n.every(s=>s.startsWith(`${o}/`));return e.map((s,a)=>({path:i?n[a].slice(o.length+1):n[a],file:s})).filter(s=>!s.path.endsWith("/.DS_Store")&&s.path!==".DS_Store")}function _h(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function $(t,e={},n=[]){let r=document.createElement(t);for(let[o,i]of Object.entries(e))o==="class"?r.className=i:r.setAttribute(o,i);for(let o of n)r.append(typeof o=="string"?document.createTextNode(o):o);return r}function ci(t){return t==="TRUE"?null:$("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function gn(t,e,n={}){let r=$("div",{class:"field-head"},[$("span",{class:"field-label"},[t])]),o=n.mark!==void 0?ci(n.mark):null;return o!==null&&r.append(o),$("div",{class:"field"},[r,$("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function lt(t,e,n={}){let r=n.open===!0,o=$("span",{class:"chev","aria-hidden":"true"});o.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 6 L15 12 L9 18"/></svg>';let i=$("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(r)},[$("span",{},[t]),o]),s=$("div",{class:"opener-body"},e),a=$("section",{class:"card"},[i,s]),c=()=>{i.classList.toggle("open",r),i.setAttribute("aria-expanded",String(r)),s.hidden=!r,o.classList.toggle("open",r)};return i.addEventListener("click",()=>{r=!r,c()}),c(),a}function Uh(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function jh(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function Kh(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function mn(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function Vh(t){return new Date(t*1e3).toLocaleString("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",timeZoneName:"short"})}function lc(t){let e=t.bounds,n=i=>$("span",{class:"when-grey"},[i]),r=i=>$("span",{class:"when-dark"},[i]),o=$("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;o.append($("div",{class:"when-date"},[Kh(i.timestamp)]));let s=$("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("after "),r(mn(e.notBefore.timestamp,!0)),n(", then an anchor at "),r(mn(e.notAfter.timestamp,!1)),n(" (not an upper bound)")):e.notBefore!==void 0?s.append(n("after "),r(mn(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("no lower bound in this bundle; an anchor followed at "),r(mn(e.notAfter.timestamp,!0)),n(" (not an upper bound)")),o.append(s)}else o.append($("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return o}function oi(t){if(t.fused===void 0)return null;let e=i=>$("span",{class:"when-grey"},[i]),n=i=>$("span",{class:"when-dark"},[i]),r=$("div",{class:"when"}),o=$("div",{class:"when-line"});return t.fused.floor!==null?o.append(e("fused bytes assembled after "),n(mn(t.fused.floor.timestamp,!0)),e(`, the last anchor before slot ${t.fused.span?.slotCounter??"?"}`)):o.append(e(t.fused.floorDetail)),r.append(o),r}var zh=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,qh=/\.(mp4|m4v|mov|webm|ogv)$/i,Gh=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,Wh=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function Zh(t){let e=t.subarray(0,Math.min(2048,t.length));if(!e.length)return!1;let n=0;for(let r of e){if(r===0)return!1;(r===9||r===10||r===13||r>=32)&&n++}return n/e.length>.97}function Yh(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":zh.test(n)?"image":qh.test(n)?"video":Gh.test(n)?"audio":Wh.test(n)||Zh(e)?"text":"other"}function Xh(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Jh(t,e,n){if(n==="image"||n==="video"){let r=URL.createObjectURL(t),o=n==="image"?$("img",{src:r,alt:t.name,style:"display:block;max-width:100%;max-height:min(70vh,640px);width:auto;height:auto;object-fit:contain;border-radius:0"}):$("video",{src:r,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return $("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[o])}if(n==="audio"){let r=URL.createObjectURL(t);return $("div",{style:"padding:20px 16px"},[$("audio",{src:r,controls:"",style:"display:block;width:100%"})])}if(n==="text")try{let r=new TextDecoder("utf-8",{fatal:!1}).decode(e.subarray(0,6e3)),o=r.split(`
|
|
152
|
+
-----END CERTIFICATE-----`;function Bp(){return Rf.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function Hf(){return new Uint8Array(E.Buffer.from(Bp(),"base64"))}async function $f(t,e){let n=[],r={},o,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(u=>!u.pass)?.detail,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},...a!==void 0?{certChainLength:a}:{},...c!==void 0?{userDataB64:c}:{}});try{let u=vp(t);if(u===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let l=ut(u,0).value;if(!Array.isArray(l)||l.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),f();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let d=l[0],h=l[2],m=l[3];if(!(d instanceof Uint8Array)||!(h instanceof Uint8Array)||!(m instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),f();let y=ut(h,0).value;if(!y||typeof y!="object"||Array.isArray(y))return n.push({name:"Payload Decode",pass:!1,detail:"Could not decode attestation payload"}),f();r=Np(y),o=r[0],i=typeof y.module_id=="string"?y.module_id:void 0,s=typeof y.timestamp=="number"?y.timestamp:void 0;let b=y.user_data;c=b instanceof Uint8Array&&b.length>0?E.Buffer.from(b).toString("base64"):void 0;let p=y.cabundle,A=y.certificate;if(!(A instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),f();a=(Array.isArray(p)?p.length:0)+1;let B=zi(A),P=Cp(d,h),V=await Wi(m,P,B.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:V,detail:V?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!V)return f();if(!Array.isArray(p)||p.length===0||!p.every(M=>M instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let H=[...p,A].map(zi),U=!0,S="";for(let M=1;M<H.length;M++){let me=H[M],De=H[M-1];if(!await Wi(me.signature,me.tbsCertificate,De.publicKey)){U=!1,S=`Certificate ${M} signature invalid (parent: ${M-1})`;break}}if(n.push({name:"Certificate Chain",pass:U,detail:U?`${H.length} certificates, each signed by parent`:S}),!U)return f();let K=e?.trustedRootCaDer===void 0,L=zi(e?.trustedRootCaDer??Hf()),ce=H[0],q=await Wi(ce.signature,ce.tbsCertificate,L.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:q,detail:q?K?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":K?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!q)return f();let ee=!0,Ne=`All ${H.length} certificate validity windows contain the document timestamp`;if(s===void 0)ee=!1,Ne="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let M=0;M<H.length;M++){let me=H[M];if(s<me.notBeforeMs||s>me.notAfterMs){ee=!1,Ne=`Certificate ${M} validity window [${new Date(me.notBeforeMs).toISOString()}, ${new Date(me.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:ee,detail:Ne}),!ee)return f();let ie;e?.expectedPcr0!==void 0&&(ie=o===e.expectedPcr0,n.push({name:"PCR0 Match",pass:ie,detail:ie?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(o??"").slice(0,16)}...`}));let $e;return e?.expectedUserDataB64!==void 0&&($e=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:$e,detail:$e?"Attestation user_data matches this proof's canonical hash":c!==void 0?"Attestation user_data does not match this proof":"Attestation carries no user_data to bind"})),{documentValid:!0,checks:n,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},certChainLength:a,...c!==void 0?{userDataB64:c}:{},...ie!==void 0?{pcr0Matches:ie}:{},...$e!==void 0?{userDataMatches:$e}:{}}}catch(u){return n.push({name:"Verification Error",pass:!1,detail:u instanceof Error?u.message:String(u)}),f()}}async function qi(t,e,n){let r=[],o=[],i={proofsWithDeclaredMeasurement:0,proofsWithDocument:0,documentsValidated:0,documentsFailed:0,pcr0Matches:0,pcr0Mismatches:0,userDataBound:0,userDataUnbound:0};for(let s of t.proofs){let a=s.measurement!==void 0&&s.measurement.length>0?s.measurement:void 0;a!==void 0&&i.proofsWithDeclaredMeasurement++;let c=Tp(s),f={proofHash:s.proofHash,declaredMeasurementPresent:a!==void 0,...a!==void 0?{declaredMeasurement:a}:{},documentPresent:c!==void 0,...c?.format!==void 0?{attestationFormat:c.format}:{},documentValidated:!1,checks:[]};if(c!==void 0){i.proofsWithDocument++;let u=await $f(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:an(s.proof),...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});f.documentValidated=u.documentValid,f.checks=u.checks,u.pcr0!==void 0&&(f.attestedPcr0=u.pcr0),f.pcrs=u.pcrs,u.moduleId!==void 0&&(f.moduleId=u.moduleId),u.timestamp!==void 0&&(f.timestamp=u.timestamp),u.certChainLength!==void 0&&(f.certChainLength=u.certChainLength),u.userDataB64!==void 0&&(f.userDataB64=u.userDataB64),u.documentValid?(i.documentsValidated++,u.pcr0Matches!==void 0&&(f.pcr0MatchesDeclared=u.pcr0Matches,u.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,o.push({code:"attestation-measurement-mismatch",...Ki(s),message:"the validated attestation document's PCR0 does not equal the proof's declared environment.measurement. Declared and attested measurements are reported separately and disagree here.",details:{proofHash:s.proofHash,declared:a,...u.pcr0!==void 0?{attested:u.pcr0}:{}}}))),u.userDataMatches!==void 0&&(f.userDataBoundToProof=u.userDataMatches,u.userDataMatches?i.userDataBound++:(i.userDataUnbound++,o.push({code:"attestation-user-data-mismatch",...Ki(s),message:"the validated attestation document's user_data is not bound to this proof's canonical hash. A genuine attestation lifted from another proof would look exactly like this.",details:{proofHash:s.proofHash,...u.userDataB64!==void 0?{userDataB64:u.userDataB64}:{}}})))):(i.documentsFailed++,u.failure!==void 0&&(f.validationFailure=u.failure),o.push({code:"attestation-invalid",...Ki(s),message:`attestation document failed offline validation: ${u.failure??"unknown"}. Presence of a document is reported separately and proves nothing by itself.`,details:{proofHash:s.proofHash}}))}r.push(f)}return e!==void 0&&Ap(e,r),{records:r,findings:o,counts:i}}function Ap(t,e){let n=new Map(e.map(r=>[r.proofHash,r]));for(let r of t.groups){if(!r.attestationPresent)continue;let o=r.proofHashes.map(f=>n.get(f)).filter(f=>f!==void 0&&f.documentPresent);if(o.length===0)continue;let i=o.filter(f=>f.documentValidated),s=o.length-i.length,a=[...new Set(i.map(f=>f.attestedPcr0).filter(f=>f!==void 0))].sort(),c=a.length===1?a[0]:void 0;r.attested={status:s===0&&i.length>0?"validated":"validation-failed",...c!==void 0?{attestedMeasurement:c}:{},...c!==void 0&&r.measurement!==void 0?{matchesDeclared:c===r.measurement}:{},validatedProofCount:i.length,failedProofCount:s,...a.length>1?{attestedMeasurements:a}:{}}}}function Tp(t){let e=t.proof.environment;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.attestation;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n.reportB64;if(typeof r!="string"||r.length===0)return;let o=n.format;return{reportB64:r,...typeof o=="string"?{format:o}:{}}}function Ki(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function vp(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=E.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function Yi(t){return t<24?new Uint8Array([t]):t<256?new Uint8Array([24,t]):t<65536?new Uint8Array([25,t>>8,t&255]):new Uint8Array([26,t>>>24&255,t>>>16&255,t>>>8&255,t&255])}function Gi(t){let e=Yi(t.length);e[0]=e[0]&31|64;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function Ip(t){let e=new TextEncoder().encode(t),n=Yi(e.length);n[0]=n[0]&31|96;let r=new Uint8Array(n.length+e.length);return r.set(n,0),r.set(e,n.length),r}function Sp(t){let e=Yi(t.length);e[0]=e[0]&31|128;let n=e.length+t.reduce((i,s)=>i+s.length,0),r=new Uint8Array(n),o=0;r.set(e,o),o+=e.length;for(let i of t)r.set(i,o),o+=i.length;return r}function Cp(t,e){return Sp([Ip("Signature1"),Gi(t),Gi(new Uint8Array(0)),Gi(e)])}function ut(t,e=0){let n=t[e];if(n===void 0)throw new Error("CBOR: unexpected end of input");let r=n>>5,o=n&31;e++;let i=a=>{let c=t[a];if(c===void 0)throw new Error("CBOR: unexpected end of input");return c};function s(){if(o<24)return o;if(o===24){let a=i(e);return e+=1,a}if(o===25){let a=i(e)<<8|i(e+1);return e+=2,a}if(o===26){let a=(i(e)<<24|i(e+1)<<16|i(e+2)<<8|i(e+3))>>>0;return e+=4,a}if(o===27){let a=0;for(let c=0;c<8;c++)a=a*256+i(e+c);return e+=8,a}throw new Error(`Unsupported CBOR length info: ${o}`)}switch(r){case 0:return{value:s(),offset:e};case 1:return{value:-1-s(),offset:e};case 2:{let a=s();if(e+a>t.length)throw new Error("CBOR: byte string is truncated");return{value:t.slice(e,e+a),offset:e+a}}case 3:{let a=s();if(e+a>t.length)throw new Error("CBOR: text string is truncated");return{value:new TextDecoder().decode(t.slice(e,e+a)),offset:e+a}}case 4:{if(o===31){let f=[];for(;i(e)!==255;){let u=ut(t,e);f.push(u.value),e=u.offset}return{value:f,offset:e+1}}let a=s(),c=[];for(let f=0;f<a;f++){let u=ut(t,e);c.push(u.value),e=u.offset}return{value:c,offset:e}}case 5:{if(o===31){let f={};for(;i(e)!==255;){let u=ut(t,e);e=u.offset;let l=ut(t,e);e=l.offset,f[String(u.value)]=l.value}return{value:f,offset:e+1}}let a=s(),c={};for(let f=0;f<a;f++){let u=ut(t,e);e=u.offset;let l=ut(t,e);e=l.offset,c[String(u.value)]=l.value}return{value:c,offset:e}}case 6:return s(),ut(t,e);case 7:{if(o===20)return{value:!1,offset:e};if(o===21)return{value:!0,offset:e};if(o===22)return{value:null,offset:e};if(o===23)return{value:void 0,offset:e};throw new Error(`Unsupported CBOR simple value: ${o}`)}default:throw new Error(`Unsupported CBOR major type: ${r}`)}}function zi(t){let n=Ln(t,0).contentStart,r=le(t,n),o=t.slice(n,r.end);n=r.end,n=le(t,n).end;let s=le(t,n),a=t.slice(s.contentStart+1,s.end),c=Hp(a,48),{publicKey:f,notBeforeMs:u,notAfterMs:l}=Rp(o);return{tbsCertificate:o,signature:c,publicKey:f,notBeforeMs:u,notAfterMs:l}}function le(t,e){let n=t[e];if(n===void 0)throw new Error("DER: unexpected end of input");let r=e+1,o=t[r++];if(o===void 0)throw new Error("DER: unexpected end of input");if(o&128){let s=o&127;o=0;for(let a=0;a<s;a++){let c=t[r++];if(c===void 0)throw new Error("DER: unexpected end of input");o=o*256+c}}let i=r+o;if(i>t.length)throw new Error("DER: element is truncated");return{tag:n,contentStart:r,contentEnd:i,end:i}}function Ln(t,e){let n=le(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function Rp(t){let n=Ln(t,0).contentStart;t[n]===160&&(n=le(t,n).end),n=le(t,n).end,n=le(t,n).end,n=le(t,n).end;let r=Ln(t,n),o=r.contentStart,i=le(t,o);o=i.end;let s=le(t,o),a=Nf(t,i),c=Nf(t,s);n=r.end,n=le(t,n).end;let u=Ln(t,n).contentStart;u=le(t,u).end;let d=le(t,u);return{publicKey:t.slice(d.contentStart+1,d.end),notBeforeMs:a,notAfterMs:c}}function Nf(t,e){let n=String.fromCharCode(...t.slice(e.contentStart,e.contentEnd)),r,o;if(e.tag===23){if(!/^\d{12}Z$/.test(n))throw new Error(`DER: malformed UTCTime "${n}"`);let u=Number.parseInt(n.slice(0,2),10);r=u<50?2e3+u:1900+u,o=n.slice(2)}else if(e.tag===24){if(!/^\d{14}Z$/.test(n))throw new Error(`DER: malformed GeneralizedTime "${n}"`);r=Number.parseInt(n.slice(0,4),10),o=n.slice(4)}else throw new Error(`DER: expected a Time value, got tag 0x${e.tag.toString(16)}`);let i=Number.parseInt(o.slice(0,2),10),s=Number.parseInt(o.slice(2,4),10),a=Number.parseInt(o.slice(4,6),10),c=Number.parseInt(o.slice(6,8),10),f=Number.parseInt(o.slice(8,10),10);return Date.UTC(r,i-1,s,a,c,f)}function Hp(t,e){let r=Ln(t,0).contentStart,o=le(t,r);if(o.tag!==2)throw new Error("Expected INTEGER for r");let i=t.slice(o.contentStart,o.end);r=o.end;let s=le(t,r);if(s.tag!==2)throw new Error("Expected INTEGER for s");let a=t.slice(s.contentStart,s.end);if(i[0]===0&&i.length>e&&(i=i.slice(1)),a[0]===0&&a.length>e&&(a=a.slice(1)),i.length>e||a.length>e)throw new Error("ECDSA signature component longer than the curve coordinate size");let c=new Uint8Array(e*2);return c.set(i,e-i.length),c.set(a,e*2-a.length),c}async function Wi(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let r=await qo.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await qo.subtle.verify({name:"ECDSA",hash:"SHA-384"},r,t,e)}catch{return!1}}function Np(t){let e={},n=t.pcrs;if(!n||typeof n!="object")return e;for(let[r,o]of Object.entries(n))if(o instanceof Uint8Array){let i=E.Buffer.from(o).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(r)]=i)}return e}g();var zr="0.7.0";function Df(){return zr}async function Zi(t,e){let n=e?.startedAt??new Date().toISOString(),r=await Hi(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),o=await $i(t),i=await Di(t,o),s=Mi(t),a=Oi(t),c=await Ui(t,a),f=Vi(t,o,a,c),u=await ji(t,e?.ceilings??{}),l=await qi(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:Df(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:r,reconstruction:o,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:f,attestations:l,ceilings:u}}g();g();g();g();g();function Wr(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}g();g();var Xi="0.16.0";function Ff(t){let e=t.temporal;return{floors:e.signedFloors??[],problems:e.floorProblems??[]}}var Pp=[{pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92",label:"genesis",period:"2026-05-15 to 2026-06-27"},{pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a",label:"enclave v2 (reproducible)",period:"2026-06-27 to 2026-07-05"},{pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb",label:"enclave v4 (reproducible)",period:"2026-07-05 to 2026-07-29"},{pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f",label:"enclave v5 (reproducible)",period:"2026-07-29 to 2026-09-05"},{pcr0:"cd8ba52d340fb1be78610b59953ded2ceca23be1cfcc7ab504a26b8fdcd7ba92090f49e28a32d008df046ec4212f77bf",label:"enclave v6 (reproducible)",period:"2026-09-05 to 2026-09-06"},{pcr0:"394c3cf515651dc27187d85e4716c12dfeb99c1227f1fe0eacfaa427d80018e1a28ebba9469e99c7936601f901d74e1d",label:"enclave v7 (reproducible, authenticated anchors)",period:"2026-09-06 to 2026-09-07"},{pcr0:"eccfc1c78006f4b74f929c992785575c908a0f60eca08ff638cd6c0842f993f182ebb002457b8ef3e732a6a10805c72b",label:"enclave v8 (reproducible, authenticated anchors and the floor gate)",period:"2026-09-07 to 2026-09-30"},{pcr0:"934feb8bb6f4f7e2d2f85d902a7d5edd0981f706d9d2385638988ac096a05ea0583c3d00eef2a7947865ec66efc1fcf8",label:"enclave v9 (reproducible; the allocation returns the floor anchor, for bitgraph-fuse/2)",period:"2026-09-30 to 2026-10-07"},{pcr0:"5a947cc66095adcceefa9e5ece5d1416dfe08c3470df1bcaa5b2bc5267b0480e6cdc172fe077cd06b0afb07614307973",label:"enclave v10 (reproducible; the floor is a Base block fixed at allocation, for bitgraph-fuse/3)",period:"2026-10-08 onward"}],Op=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function Uf(t,e){let n=e,r=await Zi(t,{startedAt:""});if(n?.fuseEvidence===void 0){let o=await Lp(t);n={...n,fuseEvidence:o.evidence,fuseOriginHexes:o.originHexes}}return Fp(r,n)}async function Lp(t){let e=new Map,n=new Set,r=[],o=new Set;for(let s of t.proofs){let a=At(s.proof);if(a===null)continue;let c=Ie(s.proof.artifact.digestB64),f=c!==null?Ee(c):null,u=a.originDigest!==void 0?Ee(a.originDigest):null;r.push({proof:s,artifactHex:f,originHex:u}),f!==null&&o.add(f),u!==null&&o.add(u)}if(r.length===0)return{evidence:e,originHexes:n};let i=new Map;for await(let s of Ci(t,o))i.has(s.sha256Hex)||i.set(s.sha256Hex,s.bytes);nt();try{for(let s of r){let a=s.artifactHex!==null?i.get(s.artifactHex):void 0,c=s.originHex!==null?i.get(s.originHex):void 0;c!==void 0&&s.originHex!==null&&n.add(s.originHex);let f=a??c;f!==void 0&&e.set(s.proof.proofHash,await $r({proof:s.proof.proof,bytes:f}))}}finally{nt()}return{evidence:e,originHexes:n}}function Fp(t,e){let n=e?.webCryptoAvailable??!0,r=new Map(t.anchors.anchors.map(b=>[b.proofHash,b])),o=new Map(t.attestations.records.map(b=>[b.proofHash,b])),i=new Map(Ff(t).floors.map(b=>[b.proofHash,b])),s=new Map;for(let b of t.temporal.segments)for(let p of b.memberProofHashes)s.set(p,b);let a=new Map;for(let b of t.witnesses.outcomes){if(b.anchorProofHash===void 0)continue;let p=a.get(b.anchorProofHash)??[];p.push(b),a.set(b.anchorProofHash,p)}let c=new Map;for(let b of t.ingest.artifacts)for(let p of b.matchedProofHashes)!c.has(p)&&b.paths[0]!==void 0&&c.set(p,b.paths[0]);let f=[],u=[];for(let b of t.ingest.proofs){let p=r.get(b.proofHash);p!==void 0?u.push(Xp(b,p,a.get(b.proofHash)??[])):f.push(Up(b,o.get(b.proofHash),s.get(b.proofHash),c.get(b.proofHash),n,e?.fuseEvidence,r,i.get(b.proofHash)))}_f(f),_f(u);let l=Jp(t),d=Qp(t,f,u,e?.fuseOriginHexes),h=em(u.length>0,i.size>0),m=[...f.map(b=>b.result),...u.map(b=>b.result),...l.map(b=>b.result)],y=m.length===0?"UNDETERMINED":Wr(m);return{check:"bitgraph-check/1",result:y,summary:tm(y,f,u,l),recordings:f,anchors:u,contradictions:l,notes:d,notChecked:h,evaluator:{name:"bitgraph-player",version:Xi,audit:zr},network:"none"}}function _f(t){let e=n=>[n.epochId??"",n.counter!==void 0&&/^[0-9]+$/.test(n.counter)?BigInt(n.counter):void 0];t.sort((n,r)=>{let[o,i]=e(n),[s,a]=e(r);return o!==s?o<s?-1:1:i===void 0||a===void 0?i===void 0?a===void 0?0:1:-1:i<a?-1:i>a?1:0})}function Up(t,e,n,r,o,i,s,a){let c=[],f=t.verification,u=t.proof.artifact.digestB64;f?.tier==="full"?c.push({name:"file",result:f.status==="verified"||f.status==="failed"?"TRUE":"UNDETERMINED",detail:f.status==="verified"||f.status==="failed"?`${r??"the matched file"} hashes to the recorded digest ${u}`:`no file in this bundle hashes to the recorded digest ${u}`}):c.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${u}; the recording cannot be bound to bytes in hand`}),f===void 0?c.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):f.status==="failed"?c.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${f.reason??"unspecified failure"}`}):c.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${ts(t.publicKeyB64)}`});let l=zp(e,o);c.push(l.line),c.push(Wp(l.attestedPcr0,l.line.result));let d=At(t.proof),h;if(d!==null){let y=a!==void 0?jp(a):Vp(n,s,t.slotCounter,t.chainId),b=Gp(d.placement,d.originDigest!==void 0?t.proof.attribution?.message??null:null,i?.get(t.proofHash),y,t,a);c.push(b.line),h=b.fused}let m=Wr(c.map(y=>y.result));return{proofHash:t.proofHash,digestB64:u,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...r!==void 0&&f?.tier==="full"?{filePath:r}:{},lines:c,result:m,bounds:qp(n,a),...h!==void 0?{fused:h}:{}}}var es="bitgraph:main";function Vp(t,e,n,r=es){if(r!==es||t===void 0||e===void 0||n===void 0||!/^[0-9]+$/.test(n))return null;let o=BigInt(n),i;for(let s of t.lowerBounds){if(s.kind!=="not-before")continue;let a=e.get(s.anchorProofHash);if(a===void 0||a.counter===void 0||!/^[0-9]+$/.test(a.counter)||BigInt(a.counter)>=o)continue;if(i===void 0){i=s;continue}let c=s.blockNumber!==void 0?BigInt(s.blockNumber):BigInt(s.timestamp),f=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);c>f&&(i=s)}return i===void 0?null:{...i.blockNumber!==void 0?{blockNumber:i.blockNumber}:{},blockHash:i.blockHash,timestamp:i.timestamp,anchorProofHash:i.anchorProofHash,evidence:"counter-order"}}function jp(t){return t.bound!=="not-before"?null:{chain:"base",blockNumber:String(t.blockNumber),blockHash:t.blockHash,timestamp:t.blockTimestamp,anchorProofHash:t.proofHash,evidence:"signed-floor",timeSource:t.header==="checked"?"header":"signed"}}var Kp="floor undetermined: no anchor precedes this slot in its epoch";function Ji(t){let e=t.blockNumber!==void 0?`#${t.blockNumber}`:t.blockHash;return`${t.chain==="base"?"Base":"anchored"} block ${e} (${new Date(t.timestamp*1e3).toISOString()})`}function Gp(t,e,n,r,o,i){let s=o.slotCounter??"?",a=t!==null?` (placement ${t})`:" (placement undeclared)",c=r!==null&&r.chain==="base"?`assembled after ${Ji(r)}, the Base block this recording signs as its floor`+(r.timeSource==="signed"?"; no header for it is in this bundle, so confirming the block needs a Base lookup":""):r!==null?`assembled after ${Ji(r)}, the last verified anchor preceding slot ${s} in this epoch`:i!==void 0?`floor undetermined: the Base floor this recording signs is not used as a bound (${i.withheldReason??"withheld"})`:o.chainId!==es?`floor undetermined: the slot is on chain "${o.chainId}", not the anchored chain`:Kp,f=n?.span!==void 0&&n.span!==null?{slotCounter:n.span.slotCounter,commitCounter:n.span.commitCounter,positions:n.span.positions}:o.slotCounter!==void 0&&o.counter!==void 0?{slotCounter:o.slotCounter,commitCounter:o.counter,positions:(BigInt(o.counter)-BigInt(o.slotCounter)).toString()}:null,u=(n?.statements??[]).map(h=>r!==null?h.replace(`at position ${s},`,`at position ${s}, which followed ${Ji(r)},`):h),l=(h,m)=>({category:h,placement:n?.placement??t,originDigestB64:n?.originDigestB64??e,evidence:m,statements:u,floor:r,floorDetail:c,span:f});if(n===void 0)return{line:{name:"fused",result:"UNDETERMINED",detail:`marked fused${a}, but neither the fused bytes nor ${e!==null?"the original":"an original"} is in this bundle, so the commitment to slot ${s} cannot be checked`},fused:l("NO_EVIDENCE",null)};let d=n.category==="FUSED_FROM_ORIGIN"||n.fileDigestB64!==n.artifactDigestB64&&n.category!=="NO_MATCH"?"original":"fused-bytes";switch(n.category){case"FUSED_DIRECT":return{line:{name:"fused",result:"TRUE",detail:`the fused bytes carry the commitment to slot ${s}${a}`},fused:l(n.category,"fused-bytes")};case"FUSED_FROM_ORIGIN":return{line:{name:"fused",result:"TRUE",detail:`the original rebuilds the committed fused bytes${a}; they carry the commitment to slot ${s}`},fused:l(n.category,"original")};case"INVALID_SLOT_COMMITMENT":return{line:{name:"fused",result:"FALSE",detail:`the fused bytes do not carry the commitment to this proof's slot ${s}: ${n.reason??""}`},fused:l(n.category,d)};case"INVALID_ORIGIN_ATTRIBUTION":return{line:{name:"fused",result:"FALSE",detail:`the declared origin contradicts the origin inside the fused bytes: ${n.reason??""}`},fused:l(n.category,d)};case"RECONSTRUCTION_MISMATCH":return{line:{name:"fused",result:"FALSE",detail:`the file matching the declared origin does not rebuild the committed fused bytes: ${n.reason??""}`},fused:l(n.category,"original")};case"UNDETERMINED_PLACEMENT":return{line:{name:"fused",result:"UNDETERMINED",detail:`${n.reason??"the placement is not registered"}; this verifier cannot check the commitment`},fused:l(n.category,d)};case"INVALID_UNDERLYING_PROOF":return{line:{name:"fused",result:"UNDETERMINED",detail:"not checked: the proof itself does not verify (see the signature line)"},fused:l(n.category,d)};default:return{line:{name:"fused",result:"UNDETERMINED",detail:`the commitment could not be checked: ${n.reason??n.category}`},fused:l(n.category,d)}}}function zp(t,e){return t===void 0||!t.documentPresent?{line:{name:"attestation",result:"UNDETERMINED",detail:"no attestation document in this proof"}}:e?t.documentValidated?t.userDataBoundToProof!==!0?{line:{name:"attestation",result:"FALSE",detail:"attestation document validates but its user_data is not this proof: the document belongs to some other proof"},attestedPcr0:t.attestedPcr0}:t.pcr0MatchesDeclared!==!0?{line:{name:"attestation",result:"FALSE",detail:`attestation validates and binds this proof, but its PCR0 ${Fn(t.attestedPcr0)} is not the measurement the signed body declares ${Fn(t.declaredMeasurement)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"TRUE",detail:`AWS Nitro attestation validates to the AWS root, binds this exact proof (user_data), and attests PCR0 ${Fn(t.attestedPcr0)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"FALSE",detail:`attestation document does not validate: ${t.validationFailure??"unspecified failure"}`}}:{line:{name:"attestation",result:"UNDETERMINED",detail:"attestation not checked: this environment cannot verify ECDSA P-384 (no WebCrypto); open the verifier from a file or https page, or run bitgraph-play check"}}}function Wp(t,e){if(e!=="TRUE"||t===void 0)return{name:"enclave",result:"UNDETERMINED",detail:"enclave identity rests on a validated attestation, which this recording does not have here"};let n=Pp.find(r=>r.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${Fn(t)} is not among the BitGraph enclave measurements this verifier knows (player ${Xi}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${Fn(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function qp(t,e){let n=e!==void 0&&e.bound==="withheld"?`; the Base floor it signs is not used as a bound (${e.withheldReason??"withheld"})`:"";if(t===void 0)return{status:"unanchored",detail:`no verified Ethereum anchor bounds this recording in this bundle${n}`};let r=Pf(t.lowerBounds,"not-before"),o=Pf(t.upperBounds,"not-after"),i=r===void 0?void 0:Of(r),s=o===void 0?void 0:Of(o),a=i!==void 0&&s!==void 0?"lower-bounded-with-following-anchor":i!==void 0?"lower-bounded":s!==void 0?"upper-bounded":"unanchored",c=a==="unanchored"?`no verified Ethereum anchor bounds this recording in this bundle${n}`:`recorded ${Yp(a,i,s)}${n}`;return{status:a,...i!==void 0?{notBefore:i}:{},...s!==void 0?{notAfter:s}:{},detail:c}}function Yp(t,e,n){switch(t){case"lower-bounded-with-following-anchor":return`${Mf(e)}; precedes an anchor that consumed block ${lt(n)} (header verified), an anchor-latency assumption rather than an upper bound on this recording`+Qi(e.weaker||n.weaker);case"lower-bounded":return`${Mf(e)}; no verified upper bound here`+Qi(e.weaker);case"upper-bounded":return`with no verified lower bound in this bundle; an anchor that consumed block ${lt(n)} followed (header verified), which is not an upper bound`+Qi(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function Mf(t){return t.chain!=="base"?`after Ethereum block ${lt(t)} (header verified in this bundle)`:t.timeSource==="header"?`after Base block ${lt(t)} (its floor, header checked in this bundle)`:`after Base block ${lt(t)} (its floor, at the time the proof signs; confirming the block needs a Base lookup)`}function Pf(t,e){let n=t.filter(o=>o.kind===e);return n.length===0?void 0:[...n].sort((o,i)=>{let s=o.chain===i.chain,a=s&&o.blockNumber!==void 0?BigInt(o.blockNumber):BigInt(o.timestamp),c=s&&i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);return a!==c?e==="not-before"?a>c?-1:1:a<c?-1:1:o.weaker!==i.weaker?o.weaker?1:-1:0})[0]}function Of(t){return{...t.chain==="base"?{chain:"base"}:{},...t.blockNumber!==void 0?{blockNumber:t.blockNumber}:{},blockHash:t.blockHash,timestamp:t.timestamp,anchorProofHash:t.anchorProofHash,evidence:t.evidence,weaker:t.weaker,...t.timeSource!==void 0?{timeSource:t.timeSource}:{}}}function Zp(t){switch(t.status){case"lower-bounded-with-following-anchor":return`after ${Lf(t.notBefore)} block ${lt(t.notBefore)}, then an anchor at block ${lt(t.notAfter)}`;case"lower-bounded":return`after ${Lf(t.notBefore)} block ${lt(t.notBefore)}`;case"upper-bounded":return`with no lower bound in this bundle, then an anchor at block ${lt(t.notAfter)} (not an upper bound)`;default:return"with no Ethereum bound in this bundle"}}function Lf(t){return t.chain==="base"?"Base":"Ethereum"}function lt(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function Qi(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function Xp(t,e,n){let r=[],o=t.verification;o===void 0?r.push({name:"signature",result:"UNDETERMINED",detail:"the anchor proof was not verified"}):o.status==="failed"?r.push({name:"signature",result:"FALSE",detail:`the anchor proof does not verify: ${o.reason??"unspecified failure"}`}):r.push({name:"signature",result:"TRUE",detail:`anchor proof verifies under signer key ${ts(t.publicKeyB64)}`});let i;if(n.length>0){let s=n.find(a=>a.verified);if(s!==void 0)i=s.witnessPath,r.push({name:"witness",result:"TRUE",detail:`block header ${s.witnessPath} hashes (keccak-256) to the anchored block hash${e.blockNumber!==void 0?` of block ${e.blockNumber}`:""}`});else{let a=n[0];i=a.witnessPath,r.push({name:"witness",result:"FALSE",detail:`block header ${a.witnessPath} contradicts this anchor: ${a.detail??a.reason??"witness verification failed"}`})}}return{proofHash:t.proofHash,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...e.blockNumber!==void 0?{blockNumber:e.blockNumber}:{},...e.blockHash!==void 0?{blockHash:e.blockHash}:{},...i!==void 0?{witnessPath:i}:{},lines:r,result:Wr(r.map(s=>s.result))}}function Jp(t){let e=[],n=new Set,r=o=>{n.has(o)||(n.add(o),e.push({name:"contradiction",result:"FALSE",detail:o}))};for(let o of t.anomalies.anomalies)Op.has(o.code)||r(`${o.code}: ${o.message}`);for(let o of t.anomalies.divergences)r(`${o.kind}: ${o.explanation}`);for(let o of t.authorities.anomalies)r(`${o.code}: ${o.message}`);for(let o of t.witnesses.findings)(o.code==="witness-unmatched"||o.code==="witness-malformed"||o.code==="witness-rlp-invalid")&&r(`${o.code}: ${o.message}`);for(let o of Ff(t).problems)r(`${o.code}: ${o.message}${o.path!==void 0?` (${o.path})`:""}`);for(let o of t.ingest.findings)o.code==="proofhash-mismatch"&&r(`${o.code}: ${o.message}${o.path!==void 0?` (${o.path})`:""}`);return e}function Qp(t,e,n,r){let o=[],i=0n,s=0;for(let l of t.anomalies.anomalies)if(l.code==="unexplained-counter-positions"){let d=l.details?.count;d!==void 0&&/^[0-9]+$/.test(d)&&(i+=BigInt(d))}else l.code==="chain-break-missing"&&(s+=l.proofHashes.length);i>0n&&o.push(`${i} causal position${i===1n?"":"s"} between the earliest and latest recording here ${i===1n?"is":"are"} not in this bundle: normal for an export, which is an excerpt of the chain; the positions between belong to whoever holds those recordings`),s>0&&o.push(`${s} recording${s===1?"":"s"} link${s===1?"s":""} to a predecessor that is not in this bundle: normal for an export`);let a=t.ingest.artifacts.filter(l=>l.matchedProofHashes.length===0&&r?.has(l.sha256Hex)===!0);a.length>0&&o.push(`${a.length} file${a.length===1?"":"s"} in this bundle ${a.length===1?"is":"are"} the original of a fused recording: ${a.slice(0,5).map(l=>l.paths[0]??"(unnamed)").join(", ")}${a.length>5?", \u2026":""}. The original carries no floor of its own: the commit that consumed its digest shows it existed by that position, an order, not a time ceiling. The fused bytes carry the floor`);let c=t.ingest.artifacts.filter(l=>l.matchedProofHashes.length===0&&r?.has(l.sha256Hex)!==!0);if(c.length>0&&e.length>0){let l=c.slice(0,5).map(d=>`${d.paths[0]??"(unnamed)"} (sha256:${d.sha256Hex.slice(0,16)}\u2026)`).join(", ");o.push(`${c.length} file${c.length===1?"":"s"} in this bundle match${c.length===1?"es":""} no recording here: ${l}${c.length>5?", \u2026":""}. If ${c.length===1?"it":"one of them"} was meant to be a recorded file, its bytes differ from what was recorded`)}let f=n.filter(l=>l.witnessPath===void 0);f.length>0&&o.push(`${f.length} Ethereum anchor${f.length===1?"":"s"} in this bundle ha${f.length===1?"s":"ve"} no block-header witness file, so ${f.length===1?"its":"their"} block hash${f.length===1?" is":"es are"} not verified here and no bound is derived from ${f.length===1?"it":"them"}`);for(let l of t.ingest.unsupportedVersions)o.push(`${l.path} is proof-shaped but its version "${l.version}" is not bitgraph/1; it was not checked`);let u=t.ingest.counts;if((u.exactDuplicates>0||u.semanticDuplicates>0)&&o.push(`${u.exactDuplicates+u.semanticDuplicates} duplicate proof file${u.exactDuplicates+u.semanticDuplicates===1?"":"s"} collapsed to one recording each`),t.ingest.manifest!==void 0)for(let l of t.ingest.findings)typeof l.code=="string"&&l.code.startsWith("manifest-")&&o.push(`${l.code}: ${l.message}`);return e.length===0&&n.length===0&&o.push("no BitGraph proofs were found in this bundle"),o}function em(t,e=!1){let n=[];return t&&n.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e&&n.push("whether the Base floor blocks are Base's own: a header in the bundle is checked here against the signed block, but that the block is on Base's chain needs a Base node or a block explorer"),n.push("whether the anchors in this bundle are the ones BitGraph published: this is an offline check; the published anchors are listed at bitgraph.ing/ledger"),n.push("whether an epoch key was later quarantined: that is published outside any bundle"),n}function tm(t,e,n,r){if(e.length===0&&n.length===0)return"UNDETERMINED: no BitGraph proofs were found in this bundle.";let o=e.length,i=`${o} recording${o===1?"":"s"}`;if(t==="TRUE"){let a=e[0];return o===1&&a!==void 0?`TRUE: this file was recorded${a.counter!==void 0?` at position ${a.counter}${a.epochId!==void 0?` of epoch ${ts(a.epochId)}`:""}`:""}, ${Zp(a.bounds)}.`:`TRUE: ${i} verified: files match, signatures and attestations hold, enclave measurements published${n.length>0?", Ethereum bounds verified from block headers in the bundle":""}.`}if(t==="FALSE")return`FALSE: evidence in this bundle contradicts itself. ${[...e.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...n.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...r.map(c=>c.detail)][0]??""}`.trim();let s=[...e.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail)),...n.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail))];return`UNDETERMINED: nothing here contradicts the ${i}, but the evidence does not fully decide. ${s[0]??""}`.trim()}function ts(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function Fn(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}Xn.sha512Async=async(...t)=>rr(Xn.concatBytes(...t));var Wf=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function qf(t){return new Promise((e,n)=>{let r=[],o=()=>{t.readEntries(i=>{if(i.length===0){e(r);return}r.push(...i),o()},n)};o()})}function nm(t){return new Promise((e,n)=>t.file(e,n))}async function is(t,e,n){if(t.isFile){let r=await nm(t);n.push({path:e+t.name,file:r});return}if(t.isDirectory){let r=t.createReader(),o=await qf(r);for(let i of o)i.name!==".DS_Store"&&await is(i,`${e}${t.name}/`,n)}}async function rm(t){let n=Array.from(t.items??[]).map(o=>typeof o.webkitGetAsEntry=="function"?o.webkitGetAsEntry():null).filter(o=>o!==null);if(n.length===0)return Array.from(t.files??[]).map(o=>({path:o.name,file:o}));let r=[];if(n.length===1&&n[0]!==void 0&&n[0].isDirectory){let o=n[0];for(let i of await qf(o.createReader()))i.name!==".DS_Store"&&await is(i,"",r)}else for(let o of n)await is(o,"",r);return r.length===0?Array.from(t.files??[]).map(o=>({path:o.name,file:o})):r}function Vf(t){let e=Array.from(t.files??[]),n=e.map(s=>s.webkitRelativePath||s.name),r=n.map(s=>s.indexOf("/")),o=n.length>0&&r.every(s=>s>0)?n[0].slice(0,r[0]):void 0,i=o!==void 0&&n.every(s=>s.startsWith(`${o}/`));return e.map((s,a)=>({path:i?n[a].slice(o.length+1):n[a],file:s})).filter(s=>!s.path.endsWith("/.DS_Store")&&s.path!==".DS_Store")}function om(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function $(t,e={},n=[]){let r=document.createElement(t);for(let[o,i]of Object.entries(e))o==="class"?r.className=i:r.setAttribute(o,i);for(let o of n)r.append(typeof o=="string"?document.createTextNode(o):o);return r}function ss(t){return t==="TRUE"?null:$("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function Vn(t,e,n={}){let r=$("div",{class:"field-head"},[$("span",{class:"field-label"},[t])]),o=n.mark!==void 0?ss(n.mark):null;return o!==null&&r.append(o),$("div",{class:"field"},[r,$("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function vt(t,e,n={}){let r=n.open===!0,o=$("span",{class:"chev","aria-hidden":"true"});o.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 6 L15 12 L9 18"/></svg>';let i=$("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(r)},[$("span",{},[t]),o]),s=$("div",{class:"opener-body"},e),a=$("section",{class:"card"},[i,s]),c=()=>{i.classList.toggle("open",r),i.setAttribute("aria-expanded",String(r)),s.hidden=!r,o.classList.toggle("open",r)};return i.addEventListener("click",()=>{r=!r,c()}),c(),a}function im(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function sm(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function am(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function Un(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function cm(t){return new Date(t*1e3).toLocaleString("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",timeZoneName:"short"})}function jf(t){let e=t.bounds,n=i=>$("span",{class:"when-grey"},[i]),r=i=>$("span",{class:"when-dark"},[i]),o=$("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;o.append($("div",{class:"when-date"},[am(i.timestamp)]));let s=$("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("after "),r(Un(e.notBefore.timestamp,!0)),n(", then an anchor at "),r(Un(e.notAfter.timestamp,!1)),n(" (not an upper bound)")):e.notBefore!==void 0?(s.append(n("after "),r(Un(e.notBefore.timestamp,!0))),e.notBefore.chain==="base"&&s.append(n(`, Base block ${e.notBefore.blockNumber??e.notBefore.blockHash}, the floor this recording signs`))):e.notAfter!==void 0&&s.append(n("no lower bound in this bundle; an anchor followed at "),r(Un(e.notAfter.timestamp,!0)),n(" (not an upper bound)")),o.append(s)}else o.append($("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return o}function ns(t){if(t.fused===void 0)return null;let e=i=>$("span",{class:"when-grey"},[i]),n=i=>$("span",{class:"when-dark"},[i]),r=$("div",{class:"when"}),o=$("div",{class:"when-line"});return t.fused.floor!==null?o.append(e("fused bytes assembled after "),n(Un(t.fused.floor.timestamp,!0)),e(t.fused.floor.chain==="base"?`, Base block ${t.fused.floor.blockNumber??t.fused.floor.blockHash}, the floor this recording signs`:`, the last anchor before slot ${t.fused.span?.slotCounter??"?"}`)):o.append(e(t.fused.floorDetail)),r.append(o),r}var fm=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,um=/\.(mp4|m4v|mov|webm|ogv)$/i,lm=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,dm=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function hm(t){let e=t.subarray(0,Math.min(2048,t.length));if(!e.length)return!1;let n=0;for(let r of e){if(r===0)return!1;(r===9||r===10||r===13||r>=32)&&n++}return n/e.length>.97}function pm(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":fm.test(n)?"image":um.test(n)?"video":lm.test(n)?"audio":dm.test(n)||hm(e)?"text":"other"}function mm(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function gm(t,e,n){if(n==="image"||n==="video"){let r=URL.createObjectURL(t),o=n==="image"?$("img",{src:r,alt:t.name,style:"display:block;max-width:100%;max-height:min(70vh,640px);width:auto;height:auto;object-fit:contain;border-radius:0"}):$("video",{src:r,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return $("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[o])}if(n==="audio"){let r=URL.createObjectURL(t);return $("div",{style:"padding:20px 16px"},[$("audio",{src:r,controls:"",style:"display:block;width:100%"})])}if(n==="text")try{let r=new TextDecoder("utf-8",{fatal:!1}).decode(e.subarray(0,6e3)),o=r.split(`
|
|
153
153
|
`),i=o.slice(0,24).join(`
|
|
154
154
|
`).slice(0,3e3),s=o.length>24||r.length>i.length||e.byteLength>6e3;return $("pre",{class:"excerpt"},[i+(s?`
|
|
155
|
-
\u2026`:"")])}catch{return null}return null}function
|
|
155
|
+
\u2026`:"")])}catch{return null}return null}function Kf(t,e,n,r){let o=t.lines.find(s=>s.name==="file"),i=$("div",{class:r?"file-row above":"file-row"});if(t.filePath!==void 0){let s=$("span",{class:"file-ident"},[$("span",{class:"file-name"},[t.filePath])]);e!==void 0&&s.append(document.createTextNode(` \xB7 ${mm(e.size)}`)),i.append(s);let a=$("span",{class:"file-right"});e!==void 0&&n!==void 0&&(n==="image"||n==="text"||n==="pdf")&&a.append($("a",{class:"bg-arrow-link",href:URL.createObjectURL(e),target:"_blank",rel:"noopener"},["Open ",$("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]));let c=o!==void 0?ss(o.result):null;c!==null&&a.append(c),a.childNodes.length>0&&i.append(a)}else{i.append($("span",{class:"file-missing"},["file not in this bundle"]));let s=o!==void 0?ss(o.result):null;s!==null&&i.append(s)}return i}function dt(t,e,n=!1){return Vn(t,e,{mono:n})}function Gf(t,e){let n=document.getElementById("title-action");if(n===null)return;let r=$("a",{class:"bg-arrow-link",href:"#"},[t+" ",$("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]);r.addEventListener("click",o=>{o.preventDefault(),e()}),n.replaceChildren(r)}function zf(t){let e={file:"File",signature:"Signature",attestation:"Hardware Enclave attestation",enclave:"Enclave identity",witness:"Block header",contradiction:"Contradiction",fused:"Fused artifact"};return t.lines.map(n=>Vn(e[n.name]??n.name,n.detail,{mark:n.result}))}function bm(t,e,n,r){let o=e==="before"?"Recorded after this block":e==="after"?"An anchor followed this recording (not an upper bound)":`Ethereum anchor ${n+1}`,i=[];if(t.blockNumber!==void 0&&i.push(dt("Block",sm(t.blockNumber),!0)),r!==void 0&&i.push(dt("Block Time",cm(r))),t.blockHash!==void 0&&i.push(dt("Block Hash",t.blockHash,!0)),t.counter!==void 0&&i.push(dt("Anchor position",`#${t.counter}`,!0)),t.blockNumber!==void 0){let s=$("a",{class:"field-link",href:`https://etherscan.io/block/${t.blockNumber}`,target:"_blank",rel:"noopener"},[`https://etherscan.io/block/${t.blockNumber}`]);i.push($("div",{class:"field"},[$("span",{class:"field-label"},["Etherscan"]),s]))}for(let s of t.lines)i.push(Vn(s.name==="witness"?"Block header":"Anchor signature",s.detail,{mark:s.result}));return t.witnessPath===void 0&&i.push(Vn("Block header","no block-header witness in this bundle, so this anchor's block hash is not verified here and it bounds nothing")),vt(t.result==="TRUE"?o:`${o} [${t.result}]`,i)}async function ym(t,e,n,r){e.replaceChildren();let o=()=>location.reload();if(t.recordings.length===0&&t.anchors.length===0){n.textContent="No BitGraph Found",e.append($("section",{class:"card primary"},[$("div",{class:"notice"},["No BitGraph proof was found in what you chose. A recording is a folder named for the file it holds, like BitGraph (photo.jpg). Inside it are proof.json, the file itself, and an ethereum-anchors folder."])])),Gf("Choose a recording folder",o),e.append(vt("Report JSON",[$("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let f=document.getElementById("more");f.replaceChildren(),f.hidden=!0;return}n.textContent=im(t.result);let i=t.recordings.length===1?t.recordings[0]:void 0,s=$("section",{class:"card primary"});if(t.result!=="TRUE"&&s.append($("div",{class:`notice ${t.result.toLowerCase()}`},[t.summary])),i!==void 0){s.append(jf(i));let f=ns(i);f!==null&&s.append(f);let u=i.filePath!==void 0?r.get(i.filePath):void 0,l,d=null;if(u!==void 0){let h=new Uint8Array(await u.arrayBuffer());l=pm(u.name,h),d=gm(u,h,l)}d!==null&&s.append(d),s.append(Kf(i,u,l,d!==null)),i.counter!==void 0&&s.append(dt("Position",`#${i.counter}${i.epochId!==void 0?` \xB7 epoch ${i.epochId}`:""}`,!0)),s.append(dt("File Hash",i.digestB64,!0))}else if(t.recordings.length>1)for(let f of t.recordings)s.append(Kf(f,f.filePath!==void 0?r.get(f.filePath):void 0,void 0,!1));else s.append(dt("Recordings","no recordings in this bundle"));if(e.append(s),Gf("Check another BitGraph",o),i!==void 0){let f=i.lines.filter(u=>u.result!=="TRUE").length;e.append(vt(f===0?"Recording checks":`Recording checks ${f} not verified`,zf(i),{open:t.result!=="TRUE"}))}else t.recordings.forEach((f,u)=>{e.append(vt(`Recording ${u+1}: ${f.filePath??f.digestB64.slice(0,16)+"\u2026"} [${f.result}]`,[jf(f),...ns(f)!==null?[ns(f)]:[],...f.counter!==void 0?[dt("Position",`#${f.counter}${f.epochId!==void 0?` \xB7 epoch ${f.epochId}`:""}`,!0)]:[],dt("File Hash",f.digestB64,!0),...zf(f)],{open:f.result!=="TRUE"}))});let a=new Map;for(let f of t.recordings)f.bounds.notBefore&&a.set(f.bounds.notBefore.anchorProofHash,f.bounds.notBefore.timestamp),f.bounds.notAfter&&a.set(f.bounds.notAfter.anchorProofHash,f.bounds.notAfter.timestamp);t.anchors.forEach((f,u)=>{let l="other";i!==void 0&&(i.bounds.notBefore?.anchorProofHash===f.proofHash?l="before":i.bounds.notAfter?.anchorProofHash===f.proofHash&&(l="after")),e.append(bm(f,l,u,a.get(f.proofHash)))}),t.contradictions.length>0&&e.append(vt(`Contradictions ${t.contradictions.length}`,t.contradictions.map(f=>Vn("Contradiction",f.detail,{mark:"FALSE"})),{open:!0,tone:"danger"})),t.notes.length>0&&e.append(vt(`Notes ${t.notes.length}`,[$("ul",{class:"list"},t.notes.map(f=>$("li",{},[f])))])),e.append(vt("Not checked",[$("ul",{class:"list"},t.notChecked.map(f=>$("li",{},[f])))])),e.append(vt("Report JSON",[$("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let c=document.getElementById("more");c.replaceChildren(),c.hidden=!0}async function rs(t){let e=document.getElementById("drop"),n=document.getElementById("results"),r=document.getElementById("status");if(t.length===0){r.textContent="Nothing readable was dropped.";return}e.classList.add("busy"),r.textContent=`Checking ${t.length} file${t.length===1?"":"s"}\u2026`;try{let o=await Ii(om(t),{label:"dropped"}),i=await Uf(o,{webCryptoAvailable:Wf});document.getElementById("camera").hidden=!0,document.getElementById("deck").hidden=!0,document.querySelector(".bitgraph-wrap")?.classList.add("bitgraph-results"),document.querySelector(".bitgraph-hero")?.classList.add("results"),r.textContent="",n.hidden=!1;let s=new Map(t.map(a=>[a.path,a.file]));await ym(i,n,document.getElementById("title"),s),document.title=`${i.result} \xB7 BitGraph verify`}catch(o){r.textContent=`The check could not run: ${o.message}`}finally{e.classList.remove("busy")}}function os(){let t=document.querySelector(".bitgraph-wrap");t&&t.style.setProperty("--bg-wrap-min",`${Math.round(window.innerHeight)}px`)}function wm(){let t=document.getElementById("drop"),e=document.getElementById("status"),n=document.getElementById("pick-files"),r=document.getElementById("pick-folder");os(),window.addEventListener("resize",os),window.addEventListener("orientationchange",os),Wf||(e.textContent="This browser context has no WebCrypto, so attestations will read UNDETERMINED here; open the file directly (file://) or over https, or run bitgraph-play check.");let o=!1,i=!1,s=!1,a=()=>{t.classList.toggle("hot",o||i||s),t.classList.toggle("over",s)};t.addEventListener("mouseenter",()=>{o=!0,a()}),t.addEventListener("mouseleave",()=>{o=!1,a()}),t.addEventListener("focusin",()=>{i=!0,a()}),t.addEventListener("focusout",()=>{i=!1,a()});let c=f=>{f.preventDefault(),f.stopPropagation()};for(let f of["dragenter","dragover"])t.addEventListener(f,u=>{c(u),s=!0,a()}),document.body.addEventListener(f,c);for(let f of["dragleave","drop"])t.addEventListener(f,u=>{c(u),s=!1,a()}),document.body.addEventListener(f,c);t.addEventListener("drop",f=>{let u=f.dataTransfer;u!==null&&(e.textContent="Reading the drop\u2026",rm(u).then(l=>{if(l.length===0){e.textContent="Nothing readable was dropped. Click the box and choose the recording's folder instead.";return}return rs(l)},l=>{e.textContent=`The drop could not be read here: ${l.message}. Click the box and choose the recording's folder instead.`}))}),t.addEventListener("click",()=>r.click()),t.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),r.click())}),n.addEventListener("change",()=>void rs(Vf(n))),r.addEventListener("change",()=>void rs(Vf(r)))}document.addEventListener("DOMContentLoaded",wm);})();
|
|
156
156
|
|
|
157
157
|
</script>
|
|
158
158
|
</body>
|